diff --git a/.clang-tidy b/.clang-tidy index 4022a3f68..caf62ab7f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,9 @@ -Checks: '-*,readability-braces-around-statements' +Checks: '-*,readability-braces-around-statements,readability-inconsistent-declaration-parameter-name' WarningsAsErrors: '' HeaderFilterRegex: '(src|include)\/.*\.h$' FormatStyle: 'file' CheckOptions: + # Require argument names to match exactly (instead of allowing a name to be a prefix/suffix of another) + # Note: 'true' is expected by clang-tidy 12+ but '1' is used for compatibility with older versions + - key: readability-inconsistent-declaration-parameter-name.Strict + value: 1 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..94b8cdfa2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM ubuntu:22.04 as build +ENV TZ=UTC + +# Install Required Dependencies +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \ + apt-get update && apt-get install -y \ + curl \ + build-essential \ + binutils-mips-linux-gnu \ + pkg-config \ + python3 \ + python3-pip \ + git \ + wget \ + unzip \ + vbindiff \ + vim \ + clang-tidy-11 \ + clang-format-11 \ + libpng-dev && \ + apt clean && \ + rm -rf /var/lib/apt/lists/* + +# Install practicerom +RUN curl https://practicerom.com/public/packages/debian/pgp.pub | \ + apt-key add - && echo deb http://practicerom.com/public/packages/debian staging main >/etc/apt/sources.list.d/practicerom.list && apt update + +RUN apt-get install -y practicerom-dev + +COPY requirements.txt requirements.txt + +RUN python3 -m pip install --no-cache-dir -r requirements.txt + +ENV LANG C.UTF-8 + +RUN mkdir /mm + +WORKDIR /mm + +RUN git config --global --add safe.directory /mm + +ENTRYPOINT ["/bin/bash", "-c"] diff --git a/Jenkinsfile b/Jenkinsfile index fb60f0aca..a627ead7c 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...' @@ -93,7 +99,7 @@ pipeline { branch 'master' } agent{ - label 'master' + label 'zeldaret_website' } steps { unstash 'reports' diff --git a/Makefile b/Makefile index f33f60848..75ad3a54c 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,9 @@ N_THREADS ?= $(shell nproc) #### Setup #### +# Ensure the map file being created using English localization +export LANG := C + ifeq ($(NON_MATCHING),1) CFLAGS := -DNON_MATCHING CPPFLAGS := -DNON_MATCHING @@ -113,6 +116,7 @@ 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 @@ -184,9 +188,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))) @@ -262,9 +268,20 @@ $(ROM): $(ELF) $(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 #### @@ -313,9 +330,11 @@ 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 $@ @@ -334,13 +353,13 @@ build/data/%.o: data/%.s build/src/overlays/%.o: src/overlays/%.c $(CC_CHECK) $< $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< - $(OBJDUMP_CMD) -# TODO: `() || true` is currently necessary to suppress `Error 1 (ignored)` make warnings caused by `test`, but this will go away if -# the following is moved to a separate rule that is only run once when all the required objects have been compiled. - $(ZAPD) bovl -eh -i $@ -cfg $< --outputpath $(@D)/$(notdir $(@D))_reloc.s - (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 $@ $< diff --git a/README.md b/README.md index f48230b90..d94b47950 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,12 @@ please be aware that the codebase could drastically change at any time. Also not 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, 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). +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/games/mm), and for more information you can get in touch with the team on our [Discord server](https://discord.zelda64.dev). 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,13 +129,12 @@ md5sum: WARNING: 1 computed checksum did NOT match This means that something is wrong with the ROM's contents. Either the baserom files are incorrect due to a bad ROM, or some of the code is not matching. -Running `make init` will also make the `./expected` directory and copy all of the files there, which will be useful when running the diff script. The diff script is useful in decompiling functions and can be ran with this command: `./tools/asm-differ/diff.py -wmo3 ` +Running `make init` will also make the `./expected` directory and copy all of the files there, which will be useful when running the diff script. The diff script is useful in decompiling functions and can be run with this command: `./tools/asm-differ/diff.py -wmo3 ` -**Note**: to speed up the build, you can pass `-jN` to `make setup` and `make`, where N is the number of threads to use in the build, e.g. `make -j4`. The generally-accepted wisdom is to use the number of virtual cores your computer has, which is the output of `nproc` (which should be installed as part of `coreutils`). +**Note**: to speed up the build, you can pass `-jN` to `make setup` and `make`, where N is the number of threads to use in the build, e.g. `make -j4`. The generally-accepted wisdom is to use the number of virtual cores your computer has, which is the output of `nproc` (which should be installed as part of `coreutils`). The disadvantage that the ordering of the terminal output is scrambled, so for debugging it is best to stick to one thread (i.e. not pass `-jN`). (`-j` also exists, which uses unlimited jobs, but is generally slower.) - ## Contributing All contributions are welcome. This is a group effort, and even small contributions can make a difference. @@ -143,4 +144,4 @@ Please note that is is our strict policy that *Anyone who wishes to contribute t 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), [Style Guide](docs/STYLE.md) and our [Code Review Guidelines](docs/REVIEWING.md) to see what code quality guidelines we follow. +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/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml index 03329f0c5..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/icon_item_dungeon_static.xml b/assets/xml/interface/icon_item_dungeon_static.xml new file mode 100644 index 000000000..04ba39338 --- /dev/null +++ b/assets/xml/interface/icon_item_dungeon_static.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/interface/icon_item_field_static.xml b/assets/xml/interface/icon_item_field_static.xml new file mode 100644 index 000000000..8fe3a9299 --- /dev/null +++ b/assets/xml/interface/icon_item_field_static.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/interface/icon_item_jpn_static.xml b/assets/xml/interface/icon_item_jpn_static.xml new file mode 100644 index 000000000..aff93d07e --- /dev/null +++ b/assets/xml/interface/icon_item_jpn_static.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/interface/parameter_static.xml b/assets/xml/interface/parameter_static.xml index 33ab40de4..a2ab9e0c5 100644 --- a/assets/xml/interface/parameter_static.xml +++ b/assets/xml/interface/parameter_static.xml @@ -75,9 +75,9 @@ - - - + + + @@ -119,14 +119,15 @@ - - - - - - - + + + + + + + + diff --git a/assets/xml/misc/link_animetion.xml b/assets/xml/misc/link_animetion.xml new file mode 100644 index 000000000..2bb5826dd --- /dev/null +++ b/assets/xml/misc/link_animetion.xml @@ -0,0 +1,699 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/gameplay_dangeon_keep.xml b/assets/xml/objects/gameplay_dangeon_keep.xml index 9d5a9901a..493290604 100644 --- a/assets/xml/objects/gameplay_dangeon_keep.xml +++ b/assets/xml/objects/gameplay_dangeon_keep.xml @@ -1,10 +1,10 @@  - - - - - + + + + + @@ -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..eac855669 100644 --- a/assets/xml/objects/gameplay_field_keep.xml +++ b/assets/xml/objects/gameplay_field_keep.xml @@ -12,14 +12,14 @@ - - - - - - - - + + + + + + + + @@ -40,8 +40,8 @@ - - + + diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index f73e9252f..16cbf0b85 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -1,4 +1,5 @@  + @@ -11,7 +12,7 @@ - + @@ -19,8 +20,8 @@ - - + + @@ -29,7 +30,7 @@ - + @@ -37,11 +38,14 @@ - - + + + - + + + @@ -68,703 +72,722 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -786,17 +809,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -810,17 +833,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -828,50 +851,55 @@ - - - - - + + + + + - - - - + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + - + @@ -891,11 +919,11 @@ - - - - - + + + + + @@ -903,33 +931,40 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -940,13 +975,13 @@ - - - - - - - + + + + + + + @@ -970,16 +1005,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -993,66 +1028,66 @@ - - - - - - - + + + + + + + - - + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + @@ -1071,53 +1106,56 @@ - - - - - - - - - - - + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + @@ -1148,55 +1186,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - + + + + + + + + @@ -1213,37 +1254,44 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1252,10 +1300,12 @@ - - - - + + + + + + @@ -1283,12 +1333,18 @@ - - - - + + + + + + + + + + - + @@ -1301,14 +1357,17 @@ + + - + - + + @@ -1330,22 +1389,25 @@ - - + + - - - - + + + + + + + - - - - - + + + + + @@ -1392,36 +1454,39 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + @@ -1429,7 +1494,7 @@ - + diff --git a/assets/xml/objects/object_ah.xml b/assets/xml/objects/object_ah.xml index 3644f2a90..71b031a01 100644 --- a/assets/xml/objects/object_ah.xml +++ b/assets/xml/objects/object_ah.xml @@ -1,9 +1,9 @@  - - - - + + + + @@ -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..790ca3d8a 100644 --- a/assets/xml/objects/object_al.xml +++ b/assets/xml/objects/object_al.xml @@ -1,75 +1,75 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_am.xml b/assets/xml/objects/object_am.xml index b0737cb50..259700dc8 100644 --- a/assets/xml/objects/object_am.xml +++ b/assets/xml/objects/object_am.xml @@ -1,8 +1,8 @@  - - + + @@ -34,8 +34,8 @@ - - + + diff --git a/assets/xml/objects/object_an1.xml b/assets/xml/objects/object_an1.xml index 2c212923d..d0f5f73c5 100644 --- a/assets/xml/objects/object_an1.xml +++ b/assets/xml/objects/object_an1.xml @@ -1,16 +1,16 @@  - - - - - - - - - - - + + + + + + + + + + + @@ -52,7 +52,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -81,8 +81,8 @@ - - - + + + diff --git a/assets/xml/objects/object_an2.xml b/assets/xml/objects/object_an2.xml index 3adcc27f7..a1785e5dd 100644 --- a/assets/xml/objects/object_an2.xml +++ b/assets/xml/objects/object_an2.xml @@ -1,12 +1,12 @@  - + - - - - + + + + diff --git a/assets/xml/objects/object_an3.xml b/assets/xml/objects/object_an3.xml index 2d94b81b7..2fa21dadc 100644 --- a/assets/xml/objects/object_an3.xml +++ b/assets/xml/objects/object_an3.xml @@ -1,12 +1,12 @@  - + - - - + + + diff --git a/assets/xml/objects/object_an4.xml b/assets/xml/objects/object_an4.xml index 57088a072..a6bb94e37 100644 --- a/assets/xml/objects/object_an4.xml +++ b/assets/xml/objects/object_an4.xml @@ -1,15 +1,15 @@  - - - - - - - - - - - + + + + + + + + + + + diff --git a/assets/xml/objects/object_and.xml b/assets/xml/objects/object_and.xml index 17cff4597..a076a1c07 100644 --- a/assets/xml/objects/object_and.xml +++ b/assets/xml/objects/object_and.xml @@ -1,6 +1,6 @@  - + @@ -67,13 +67,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/objects/object_ani.xml b/assets/xml/objects/object_ani.xml index f039e0114..fb17e4e75 100644 --- a/assets/xml/objects/object_ani.xml +++ b/assets/xml/objects/object_ani.xml @@ -1,11 +1,11 @@  - - - - - - + + + + + + @@ -21,7 +21,7 @@ - + @@ -36,13 +36,13 @@ - + - + @@ -53,15 +53,15 @@ - + - - - + + + - - + + - + 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_astr_obj.xml b/assets/xml/objects/object_astr_obj.xml index 7a87bd61b..75a8e7ca2 100644 --- a/assets/xml/objects/object_astr_obj.xml +++ b/assets/xml/objects/object_astr_obj.xml @@ -5,9 +5,9 @@ - + - + diff --git a/assets/xml/objects/object_az.xml b/assets/xml/objects/object_az.xml index d4382673f..ea6fd5e7d 100644 --- a/assets/xml/objects/object_az.xml +++ b/assets/xml/objects/object_az.xml @@ -1,145 +1,169 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bai.xml b/assets/xml/objects/object_bai.xml index 4225bec84..419f37b29 100644 --- a/assets/xml/objects/object_bai.xml +++ b/assets/xml/objects/object_bai.xml @@ -1,7 +1,7 @@  - - + + @@ -47,7 +47,7 @@ - - + + diff --git a/assets/xml/objects/object_bal.xml b/assets/xml/objects/object_bal.xml index a16e2fb1f..a31c0e29f 100644 --- a/assets/xml/objects/object_bal.xml +++ b/assets/xml/objects/object_bal.xml @@ -1,9 +1,9 @@  - - - - + + + + @@ -68,14 +68,14 @@ - - - - - - - - - + + + + + + + + + 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 c9c6a0a90..e03cdb0e2 100644 --- a/assets/xml/objects/object_bb.xml +++ b/assets/xml/objects/object_bb.xml @@ -42,6 +42,6 @@ - + diff --git a/assets/xml/objects/object_bba.xml b/assets/xml/objects/object_bba.xml index 144c685e4..c3a5d0424 100644 --- a/assets/xml/objects/object_bba.xml +++ b/assets/xml/objects/object_bba.xml @@ -18,10 +18,10 @@ - - - - + + + + @@ -41,11 +41,11 @@ - + - - + + diff --git a/assets/xml/objects/object_bdoor.xml b/assets/xml/objects/object_bdoor.xml index a57339f3b..2e64110f5 100644 --- a/assets/xml/objects/object_bdoor.xml +++ b/assets/xml/objects/object_bdoor.xml @@ -1,18 +1,31 @@  + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bee.xml b/assets/xml/objects/object_bee.xml index 8f1d704cf..ab9699e84 100644 --- a/assets/xml/objects/object_bee.xml +++ b/assets/xml/objects/object_bee.xml @@ -1,28 +1,38 @@  + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bg.xml b/assets/xml/objects/object_bg.xml index 0602f987d..272968b8d 100644 --- a/assets/xml/objects/object_bg.xml +++ b/assets/xml/objects/object_bg.xml @@ -1,8 +1,8 @@  - - - + + + @@ -51,12 +51,12 @@ - - - - - - + + + + + + @@ -107,6 +107,6 @@ - + diff --git a/assets/xml/objects/object_bh.xml b/assets/xml/objects/object_bh.xml index 84f3050c0..b4cc95393 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_big_fwall.xml b/assets/xml/objects/object_big_fwall.xml index f3f51a488..bb8b838be 100644 --- a/assets/xml/objects/object_big_fwall.xml +++ b/assets/xml/objects/object_big_fwall.xml @@ -1,6 +1,6 @@  - + diff --git a/assets/xml/objects/object_bigicicle.xml b/assets/xml/objects/object_bigicicle.xml index 3e1a7fd7e..f02767256 100644 --- a/assets/xml/objects/object_bigicicle.xml +++ b/assets/xml/objects/object_bigicicle.xml @@ -2,11 +2,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_bigokuta.xml b/assets/xml/objects/object_bigokuta.xml index 21ead0501..7c2928b23 100644 --- a/assets/xml/objects/object_bigokuta.xml +++ b/assets/xml/objects/object_bigokuta.xml @@ -1,10 +1,10 @@  - - - - - + + + + + @@ -34,25 +34,25 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bigpo.xml b/assets/xml/objects/object_bigpo.xml index 531a151c6..e10052e3c 100644 --- a/assets/xml/objects/object_bigpo.xml +++ b/assets/xml/objects/object_bigpo.xml @@ -1,14 +1,14 @@  - - - - - - + + + + + + - + @@ -19,8 +19,8 @@ - - + + diff --git a/assets/xml/objects/object_bigslime.xml b/assets/xml/objects/object_bigslime.xml index 5b7530add..93c2ef807 100644 --- a/assets/xml/objects/object_bigslime.xml +++ b/assets/xml/objects/object_bigslime.xml @@ -1,30 +1,30 @@  - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -65,59 +65,59 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - + + - + - + - + - + - + - - + + diff --git a/assets/xml/objects/object_bji.xml b/assets/xml/objects/object_bji.xml index b41ac1546..697ee565c 100644 --- a/assets/xml/objects/object_bji.xml +++ b/assets/xml/objects/object_bji.xml @@ -1,23 +1,25 @@  - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -36,22 +38,27 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bjt.xml b/assets/xml/objects/object_bjt.xml index 6266711ab..a4943f6ee 100644 --- a/assets/xml/objects/object_bjt.xml +++ b/assets/xml/objects/object_bjt.xml @@ -1,23 +1,27 @@  + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + 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..2eb08a1ef 100644 --- a/assets/xml/objects/object_boj.xml +++ b/assets/xml/objects/object_boj.xml @@ -1,20 +1,20 @@  - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -58,7 +58,7 @@ - + @@ -75,20 +75,20 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bombf.xml b/assets/xml/objects/object_bombf.xml index a0e5cdef3..f27d67bc1 100644 --- a/assets/xml/objects/object_bombf.xml +++ b/assets/xml/objects/object_bombf.xml @@ -1,8 +1,8 @@  - - - + + + diff --git a/assets/xml/objects/object_bombiwa.xml b/assets/xml/objects/object_bombiwa.xml index 6dbcaf2b5..903d5bd40 100644 --- a/assets/xml/objects/object_bombiwa.xml +++ b/assets/xml/objects/object_bombiwa.xml @@ -2,26 +2,26 @@ - + - + - + - + - + - + diff --git a/assets/xml/objects/object_boss01.xml b/assets/xml/objects/object_boss01.xml index 6a10080a3..08730f034 100644 --- a/assets/xml/objects/object_boss01.xml +++ b/assets/xml/objects/object_boss01.xml @@ -1,189 +1,232 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss02.xml b/assets/xml/objects/object_boss02.xml index 9a400554b..8a80a57f2 100644 --- a/assets/xml/objects/object_boss02.xml +++ b/assets/xml/objects/object_boss02.xml @@ -62,7 +62,7 @@ - + @@ -120,6 +120,6 @@ - + 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..9490dd878 100644 --- a/assets/xml/objects/object_boss05.xml +++ b/assets/xml/objects/object_boss05.xml @@ -1,7 +1,7 @@  - - + + @@ -24,10 +24,10 @@ - - - - + + + + @@ -72,10 +72,10 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_boss07.xml b/assets/xml/objects/object_boss07.xml index 15a2e162d..b1f6cb417 100644 --- a/assets/xml/objects/object_boss07.xml +++ b/assets/xml/objects/object_boss07.xml @@ -1,216 +1,270 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_boss_hakugin.xml b/assets/xml/objects/object_boss_hakugin.xml index 62d6fb91f..ba04a3071 100644 --- a/assets/xml/objects/object_boss_hakugin.xml +++ b/assets/xml/objects/object_boss_hakugin.xml @@ -1,82 +1,106 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_botihasira.xml b/assets/xml/objects/object_botihasira.xml index 93c59f42f..f949abcc7 100644 --- a/assets/xml/objects/object_botihasira.xml +++ b/assets/xml/objects/object_botihasira.xml @@ -1,6 +1,6 @@  - + diff --git a/assets/xml/objects/object_box.xml b/assets/xml/objects/object_box.xml index fb1fb3fd5..be4f34b87 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..40bce73f2 100644 --- a/assets/xml/objects/object_bsb.xml +++ b/assets/xml/objects/object_bsb.xml @@ -1,27 +1,27 @@  - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -72,9 +72,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_bsmask.xml b/assets/xml/objects/object_bsmask.xml index e776cde1a..92e8148e9 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_bubble.xml b/assets/xml/objects/object_bubble.xml index 4397a017f..da2f01d47 100644 --- a/assets/xml/objects/object_bubble.xml +++ b/assets/xml/objects/object_bubble.xml @@ -1,6 +1,6 @@  - - + + diff --git a/assets/xml/objects/object_cha.xml b/assets/xml/objects/object_cha.xml index 12835da1f..79b008353 100644 --- a/assets/xml/objects/object_cha.xml +++ b/assets/xml/objects/object_cha.xml @@ -1,7 +1,7 @@  - - + + diff --git a/assets/xml/objects/object_cne.xml b/assets/xml/objects/object_cne.xml index fccbf539f..135aae7a2 100644 --- a/assets/xml/objects/object_cne.xml +++ b/assets/xml/objects/object_cne.xml @@ -18,7 +18,7 @@ - + @@ -38,12 +38,12 @@ - - - - - - + + + + + + diff --git a/assets/xml/objects/object_comb.xml b/assets/xml/objects/object_comb.xml index df9359acc..d2b00b0dd 100644 --- a/assets/xml/objects/object_comb.xml +++ b/assets/xml/objects/object_comb.xml @@ -1,8 +1,8 @@  - + - + 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_crace_object.xml b/assets/xml/objects/object_crace_object.xml index 06c007989..af0cb89e0 100644 --- a/assets/xml/objects/object_crace_object.xml +++ b/assets/xml/objects/object_crace_object.xml @@ -1,8 +1,9 @@  + - - - - + + + + diff --git a/assets/xml/objects/object_crow.xml b/assets/xml/objects/object_crow.xml index de51da580..068ca790a 100644 --- a/assets/xml/objects/object_crow.xml +++ b/assets/xml/objects/object_crow.xml @@ -1,6 +1,6 @@  - + @@ -19,6 +19,6 @@ - + diff --git a/assets/xml/objects/object_cs.xml b/assets/xml/objects/object_cs.xml index 803d2b02c..cc9dfbe74 100644 --- a/assets/xml/objects/object_cs.xml +++ b/assets/xml/objects/object_cs.xml @@ -2,25 +2,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -89,9 +89,9 @@ - - - - + + + + diff --git a/assets/xml/objects/object_ctower_rot.xml b/assets/xml/objects/object_ctower_rot.xml index 3a04c474e..ad2336257 100644 --- a/assets/xml/objects/object_ctower_rot.xml +++ b/assets/xml/objects/object_ctower_rot.xml @@ -67,34 +67,34 @@ - - + + - + - - + + - - + + - + - + - - + + 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_dblue_object.xml b/assets/xml/objects/object_dblue_object.xml index d49b368e1..8611c539b 100644 --- a/assets/xml/objects/object_dblue_object.xml +++ b/assets/xml/objects/object_dblue_object.xml @@ -1,78 +1,148 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 8a45dd04a..909231a77 100644 --- a/assets/xml/objects/object_dekunuts.xml +++ b/assets/xml/objects/object_dekunuts.xml @@ -38,7 +38,7 @@ - + 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_dkjail_obj.xml b/assets/xml/objects/object_dkjail_obj.xml index 219181c6d..ada181475 100644 --- a/assets/xml/objects/object_dkjail_obj.xml +++ b/assets/xml/objects/object_dkjail_obj.xml @@ -1,6 +1,6 @@  - + diff --git a/assets/xml/objects/object_dnj.xml b/assets/xml/objects/object_dnj.xml new file mode 100644 index 000000000..3b4f27579 --- /dev/null +++ b/assets/xml/objects/object_dnj.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnk.xml b/assets/xml/objects/object_dnk.xml index ad69c7722..bec6ce45d 100644 --- a/assets/xml/objects/object_dnk.xml +++ b/assets/xml/objects/object_dnk.xml @@ -44,7 +44,7 @@ - + diff --git a/assets/xml/objects/object_dno.xml b/assets/xml/objects/object_dno.xml index a320be10f..e5b3323dc 100644 --- a/assets/xml/objects/object_dno.xml +++ b/assets/xml/objects/object_dno.xml @@ -1,86 +1,106 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_dnp.xml b/assets/xml/objects/object_dnp.xml deleted file mode 100644 index 376368578..000000000 --- a/assets/xml/objects/object_dnp.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/assets/xml/objects/object_dnq.xml b/assets/xml/objects/object_dnq.xml index 830e6d8e4..4a21dbfef 100644 --- a/assets/xml/objects/object_dnq.xml +++ b/assets/xml/objects/object_dnq.xml @@ -1,94 +1,100 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..8de3f4653 100644 --- a/assets/xml/objects/object_dodongo.xml +++ b/assets/xml/objects/object_dodongo.xml @@ -58,11 +58,17 @@ - + - - + + + + + + + + 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_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 3cb6468b9..709224f9d 100644 --- a/assets/xml/objects/object_efc_tw.xml +++ b/assets/xml/objects/object_efc_tw.xml @@ -8,6 +8,6 @@ - + diff --git a/assets/xml/objects/object_eg.xml b/assets/xml/objects/object_eg.xml index 46d3e0089..6aba85e62 100644 --- a/assets/xml/objects/object_eg.xml +++ b/assets/xml/objects/object_eg.xml @@ -1,106 +1,154 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 cbbf0057c..d12a94d66 100644 --- a/assets/xml/objects/object_famos.xml +++ b/assets/xml/objects/object_famos.xml @@ -22,7 +22,7 @@ - + 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_fbdemo_triforce.xml b/assets/xml/objects/object_fbdemo_triforce.xml new file mode 100644 index 000000000..a00c9bf13 --- /dev/null +++ b/assets/xml/objects/object_fbdemo_triforce.xml @@ -0,0 +1,8 @@ + + + + + + + + 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..4d9a86e51 100644 --- a/assets/xml/objects/object_fish.xml +++ b/assets/xml/objects/object_fish.xml @@ -35,7 +35,7 @@ - + @@ -43,17 +43,17 @@ - - + + - - + + - - + + - - + + @@ -73,12 +73,12 @@ - - - + + + - - + + @@ -95,11 +95,11 @@ - - + + - - + + @@ -131,7 +131,7 @@ - + @@ -144,15 +144,15 @@ - - - - + + + + - - - - + + + + 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_fusen.xml b/assets/xml/objects/object_fusen.xml index 0ff9e9f6c..2e115b2b7 100644 --- a/assets/xml/objects/object_fusen.xml +++ b/assets/xml/objects/object_fusen.xml @@ -1,7 +1,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..a9c930215 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..f08536c90 100644 --- a/assets/xml/objects/object_grasshopper.xml +++ b/assets/xml/objects/object_grasshopper.xml @@ -1,67 +1,79 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_gs.xml b/assets/xml/objects/object_gs.xml index 1e9b159df..eebe60035 100644 --- a/assets/xml/objects/object_gs.xml +++ b/assets/xml/objects/object_gs.xml @@ -1,8 +1,9 @@  + - - - - + + + + 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..99578e996 100644 --- a/assets/xml/objects/object_harfgibud.xml +++ b/assets/xml/objects/object_harfgibud.xml @@ -1,120 +1,131 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 ae025f327..19ea49b6b 100644 --- a/assets/xml/objects/object_hs.xml +++ b/assets/xml/objects/object_hs.xml @@ -46,6 +46,6 @@ - + diff --git a/assets/xml/objects/object_ice_block.xml b/assets/xml/objects/object_ice_block.xml index ba755d100..dd25c06d5 100644 --- a/assets/xml/objects/object_ice_block.xml +++ b/assets/xml/objects/object_ice_block.xml @@ -5,7 +5,7 @@ - + @@ -21,8 +21,8 @@ - + - + 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_inibs_object.xml b/assets/xml/objects/object_inibs_object.xml index e1d454ae7..db78735fb 100644 --- a/assets/xml/objects/object_inibs_object.xml +++ b/assets/xml/objects/object_inibs_object.xml @@ -1,35 +1,43 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..9ae61accf 100644 --- a/assets/xml/objects/object_kaizoku_obj.xml +++ b/assets/xml/objects/object_kaizoku_obj.xml @@ -2,18 +2,18 @@ - - + + - - + + - - + + diff --git a/assets/xml/objects/object_kamejima.xml b/assets/xml/objects/object_kamejima.xml index 9b45ad478..cce285475 100644 --- a/assets/xml/objects/object_kamejima.xml +++ b/assets/xml/objects/object_kamejima.xml @@ -1,78 +1,99 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..d36766ee4 100644 --- a/assets/xml/objects/object_kin2_obj.xml +++ b/assets/xml/objects/object_kin2_obj.xml @@ -1,34 +1,52 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..f500ba141 100644 --- a/assets/xml/objects/object_kz.xml +++ b/assets/xml/objects/object_kz.xml @@ -12,6 +12,7 @@ + @@ -20,6 +21,7 @@ + @@ -30,19 +32,21 @@ + - + - + - + + @@ -52,30 +56,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + 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..2fe50d9bc 100644 --- a/assets/xml/objects/object_link_boy.xml +++ b/assets/xml/objects/object_link_boy.xml @@ -2,42 +2,45 @@ - - + + - + - - - - - - - - - + + + + + + + + + + - + - - - - - - - + + + + + + + + - - - - + + + + + - + @@ -46,36 +49,38 @@ - + - - + + - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_child.xml b/assets/xml/objects/object_link_child.xml index 51145033c..23d3cf09c 100644 --- a/assets/xml/objects/object_link_child.xml +++ b/assets/xml/objects/object_link_child.xml @@ -1,25 +1,28 @@  - - - - - - - + + + + + + + - - - - - - + + + + + + + + + - - - + + + @@ -29,37 +32,44 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - - + + + + + @@ -67,49 +77,51 @@ - + + - + - + - + - - - - + + + + - + - + + - - - + + + - + - - - + + + @@ -122,35 +134,60 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_goron.xml b/assets/xml/objects/object_link_goron.xml index 2fe3906fb..48eef4dd9 100644 --- a/assets/xml/objects/object_link_goron.xml +++ b/assets/xml/objects/object_link_goron.xml @@ -1,8 +1,13 @@  - + + + + + - + + @@ -17,26 +22,28 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -45,9 +52,9 @@ - + - + @@ -59,10 +66,10 @@ - + - + @@ -72,37 +79,40 @@ - + - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_nuts.xml b/assets/xml/objects/object_link_nuts.xml index e3dab39da..a00c44db4 100644 --- a/assets/xml/objects/object_link_nuts.xml +++ b/assets/xml/objects/object_link_nuts.xml @@ -1,23 +1,24 @@  - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -53,27 +54,28 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_link_zora.xml b/assets/xml/objects/object_link_zora.xml index d36aaa420..5833293b8 100644 --- a/assets/xml/objects/object_link_zora.xml +++ b/assets/xml/objects/object_link_zora.xml @@ -1,8 +1,22 @@  - + + + + + + + + + + + + + + - + + @@ -15,24 +29,26 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -48,42 +64,51 @@ - - + + - + - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_lotus.xml b/assets/xml/objects/object_lotus.xml index a9835b81b..b9f40033c 100644 --- a/assets/xml/objects/object_lotus.xml +++ b/assets/xml/objects/object_lotus.xml @@ -1,8 +1,9 @@  + - - - - + + + + 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_market_obj.xml b/assets/xml/objects/object_market_obj.xml index 81ab838f1..8ad9436cc 100644 --- a/assets/xml/objects/object_market_obj.xml +++ b/assets/xml/objects/object_market_obj.xml @@ -1,65 +1,69 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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_mtoride.xml b/assets/xml/objects/object_mtoride.xml index a79547730..145fcd33f 100644 --- a/assets/xml/objects/object_mtoride.xml +++ b/assets/xml/objects/object_mtoride.xml @@ -1,49 +1,71 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_mu.xml b/assets/xml/objects/object_mu.xml index 925cb74e9..37886e8f5 100644 --- a/assets/xml/objects/object_mu.xml +++ b/assets/xml/objects/object_mu.xml @@ -1,62 +1,63 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_nb.xml b/assets/xml/objects/object_nb.xml index e8a695b52..7ac63e118 100644 --- a/assets/xml/objects/object_nb.xml +++ b/assets/xml/objects/object_nb.xml @@ -1,46 +1,58 @@  + - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_niw.xml b/assets/xml/objects/object_niw.xml index 0e533fb6e..157d2b302 100644 --- a/assets/xml/objects/object_niw.xml +++ b/assets/xml/objects/object_niw.xml @@ -35,6 +35,6 @@ - + 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_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..aa95db9bc 100644 --- a/assets/xml/objects/object_ob.xml +++ b/assets/xml/objects/object_ob.xml @@ -1,84 +1,101 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 e10afa135..cad1c57bd 100644 --- a/assets/xml/objects/object_okuta.xml +++ b/assets/xml/objects/object_okuta.xml @@ -60,7 +60,7 @@ - + diff --git a/assets/xml/objects/object_os_anime.xml b/assets/xml/objects/object_os_anime.xml index 7957dd58d..379beff0a 100644 --- a/assets/xml/objects/object_os_anime.xml +++ b/assets/xml/objects/object_os_anime.xml @@ -12,11 +12,11 @@ - - - - - + + + + + diff --git a/assets/xml/objects/object_osn.xml b/assets/xml/objects/object_osn.xml index b31660e6a..d6109c717 100644 --- a/assets/xml/objects/object_osn.xml +++ b/assets/xml/objects/object_osn.xml @@ -1,117 +1,139 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 e3b4d2d93..2322740d5 100644 --- a/assets/xml/objects/object_raf.xml +++ b/assets/xml/objects/object_raf.xml @@ -53,6 +53,6 @@ - + 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..72510149c 100644 --- a/assets/xml/objects/object_ru2.xml +++ b/assets/xml/objects/object_ru2.xml @@ -1,78 +1,98 @@  + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_rz.xml b/assets/xml/objects/object_rz.xml index a75e033f0..9bf8961a9 100644 --- a/assets/xml/objects/object_rz.xml +++ b/assets/xml/objects/object_rz.xml @@ -1,13 +1,13 @@  - - - - - - - - + + + + + + + + @@ -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 4a8e01867..c4b256f68 100644 --- a/assets/xml/objects/object_shn.xml +++ b/assets/xml/objects/object_shn.xml @@ -103,7 +103,7 @@ - + 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 fde2d911f..dd5f42c17 100644 --- a/assets/xml/objects/object_snowman.xml +++ b/assets/xml/objects/object_snowman.xml @@ -43,7 +43,7 @@ - + @@ -58,7 +58,7 @@ - + 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..678e11693 100644 --- a/assets/xml/objects/object_test3.xml +++ b/assets/xml/objects/object_test3.xml @@ -7,7 +7,8 @@ - + + @@ -17,7 +18,16 @@ - + + + + + + + + + + @@ -63,6 +73,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..9f024f9cb 100644 --- a/assets/xml/objects/object_trt.xml +++ b/assets/xml/objects/object_trt.xml @@ -1,94 +1,106 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_tru.xml b/assets/xml/objects/object_tru.xml index dd0e6d20c..db35ec604 100644 --- a/assets/xml/objects/object_tru.xml +++ b/assets/xml/objects/object_tru.xml @@ -1,108 +1,117 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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_umajump.xml b/assets/xml/objects/object_umajump.xml index 6d86b4298..cec43c3a6 100644 --- a/assets/xml/objects/object_umajump.xml +++ b/assets/xml/objects/object_umajump.xml @@ -2,7 +2,7 @@ - + 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..0f6fe168b 100644 --- a/assets/xml/objects/object_warp1.xml +++ b/assets/xml/objects/object_warp1.xml @@ -1,59 +1,79 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 3d9ce392d..b6c5b640d 100644 --- a/assets/xml/objects/object_wf.xml +++ b/assets/xml/objects/object_wf.xml @@ -62,7 +62,7 @@ - + @@ -132,7 +132,7 @@ - + diff --git a/assets/xml/objects/object_wiz.xml b/assets/xml/objects/object_wiz.xml index 947cab3c7..51fcae3a7 100644 --- a/assets/xml/objects/object_wiz.xml +++ b/assets/xml/objects/object_wiz.xml @@ -1,102 +1,148 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..45fb179cc 100644 --- a/assets/xml/objects/object_zod.xml +++ b/assets/xml/objects/object_zod.xml @@ -1,50 +1,72 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_zog.xml b/assets/xml/objects/object_zog.xml index 627bb676a..8d9e6ebdb 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..a1364a842 100644 --- a/assets/xml/objects/object_zos.xml +++ b/assets/xml/objects/object_zos.xml @@ -1,69 +1,84 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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_Dm_Char01.xml b/assets/xml/overlays/ovl_Dm_Char01.xml index 3f855c376..2aa05fcb6 100644 --- a/assets/xml/overlays/ovl_Dm_Char01.xml +++ b/assets/xml/overlays/ovl_Dm_Char01.xml @@ -1,6 +1,7 @@ + - + diff --git a/assets/xml/overlays/ovl_Dm_Char08.xml b/assets/xml/overlays/ovl_Dm_Char08.xml new file mode 100644 index 000000000..4d96a8eb4 --- /dev/null +++ b/assets/xml/overlays/ovl_Dm_Char08.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + 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_Sth.xml b/assets/xml/overlays/ovl_En_Sth.xml index 80393fc2d..51b29870d 100644 --- a/assets/xml/overlays/ovl_En_Sth.xml +++ b/assets/xml/overlays/ovl_En_Sth.xml @@ -2,13 +2,13 @@ - - - - - - - - + + + + + + + + diff --git a/assets/xml/overlays/ovl_En_Sth2.xml b/assets/xml/overlays/ovl_En_Sth2.xml new file mode 100644 index 000000000..cd458db36 --- /dev/null +++ b/assets/xml/overlays/ovl_En_Sth2.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Jgame_Light.xml b/assets/xml/overlays/ovl_Obj_Jgame_Light.xml new file mode 100644 index 000000000..e6b740aca --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Jgame_Light.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Obj_Toudai.xml b/assets/xml/overlays/ovl_Obj_Toudai.xml new file mode 100644 index 000000000..989c47a72 --- /dev/null +++ b/assets/xml/overlays/ovl_Obj_Toudai.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Spot.xml b/assets/xml/overlays/ovl_Oceff_Spot.xml new file mode 100644 index 000000000..f4e9beea7 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Spot.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Storm.xml b/assets/xml/overlays/ovl_Oceff_Storm.xml new file mode 100644 index 000000000..6b8dc0228 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Storm.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe.xml b/assets/xml/overlays/ovl_Oceff_Wipe.xml new file mode 100644 index 000000000..17a056175 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe2.xml b/assets/xml/overlays/ovl_Oceff_Wipe2.xml new file mode 100644 index 000000000..c43ced3c0 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe3.xml b/assets/xml/overlays/ovl_Oceff_Wipe3.xml new file mode 100644 index 000000000..d8be72985 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe3.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe4.xml b/assets/xml/overlays/ovl_Oceff_Wipe4.xml new file mode 100644 index 000000000..995ad18b1 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe4.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/assets/xml/overlays/ovl_Oceff_Wipe5.xml b/assets/xml/overlays/ovl_Oceff_Wipe5.xml new file mode 100644 index 000000000..52f197428 --- /dev/null +++ b/assets/xml/overlays/ovl_Oceff_Wipe5.xml @@ -0,0 +1,9 @@ + + + + + + + + + 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/CONTRIBUTING.md b/docs/CONTRIBUTING.md similarity index 90% rename from CONTRIBUTING.md rename to docs/CONTRIBUTING.md index e0839bb2d..493486e79 100644 --- a/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,7 +1,6 @@ # Contributing to the Majora's Mask Decompilation Project - -Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! +Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask* for the N64! All contributions are welcome. This is a group effort, and even small contributions can make a difference. Some tasks also don't require much knowledge to get started. This document is meant to be a set of tips and guidelines for contributing to the project. @@ -9,19 +8,17 @@ For general information about the project, see [our readme](https://github.com/z Most discussions happen on our [Discord Server](https://discord.zelda64.dev) where you are welcome to ask if you need help getting started, or if you have any questions regarding this project and other decompilation projects. - ## Useful Links - [Installation guide](https://github.com/zeldaret/mm/blob/master/README.md#installation) - Instructions for getting this repository set up and built on your machine. -- [Style Guide](docs/STYLE.md) - Description of the project style that we ask contributors to adhere to. -- [Code Review Guidelines](docs/REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. +- [Style Guide](STYLE.md) - Description of the project style that we ask contributors to adhere to. +- [Code Review Guidelines](REVIEWING.md) - These are the guidelines that reviewers will be using when reviewing your code. Good to be familiar with these before submitting your code. - [Zelda 64 Reverse Engineering Website](https://zelda64.dev/mm) - Our homepage, with FAQ and progress graph :chart_with_upwards_trend:. -- [MM decomp tutorial](docs/tutorial/contents.md) Detailed tutorial for learning in general how decomp works and how to decompile a small, simple file. +- [MM decomp tutorial](tutorial/contents.md) Detailed tutorial for learning in general how decomp works and how to decompile a small, simple file. - [Introduction to OOT decomp](https://github.com/zeldaret/oot/blob/master/docs/tutorial/contents.md) - The tutorial the MM one was based on. For OOT, but largely applicable to MM as well. Covers slightly different topics, including how to get your data OK with `vbindiff`. - The `#resources` channel on the Discord contains many more links on specific details of decompiling IDO MIPS code. - ## Getting Started ### What should I know to take part? @@ -36,7 +33,6 @@ The [OoT Decompilation Project](https://github.com/zeldaret/oot) is farther alon This project only uses *publicly available code*. - **N.B.** Anyone who wishes to contribute to the OOT or MM projects **must not have accessed leaked source code at any point in time** for Nintendo 64 SDK, iQue player SDK, libultra, Ocarina of Time, Majora's Mask, Animal Crossing/Animal Forest, or any other game that shares the same game engine or significant portions of code to a Zelda 64 game or any other console similar to the Nintendo 64. ### Environment Setup @@ -46,27 +42,27 @@ You should be able to build a matching ROM before you start making any changes. ### First Contribution -Usually, the best place to get started is to decompile an actor overlay. +Usually, the best place to get started is to decompile an actor overlay. An *actor* is any thing in the game that moves or performs actions or interactions. This includes things like Link, enemies, NPCs, doors, pots, etc. Actors are good for a first file because they are generally small, self-contained systems. We recommend that you [join the Discord](https://discord.zelda64.dev/) to say hello and get suggestions on where to start on the `#mm-decomp` channel. We track who is working on what on some Google Sheets available in the Discord. Once you've decided on or been recommended a good first file, mark it as Reserved. -The workflow is: -- Reserve a file, -- decompile it, -- submit a PR, +The workflow is: + +- Reserve a file, +- decompile it, +- submit a PR, - repeat while addressing review comments. The expectation is that one reservation goes to one file which ends up in a one file PR, although naturally some files are more sensibly worked on as a group, for example two actors that work together. This also does not apply to large asset files like `gameplay_keep`: you can just reserve the parts that are used in your files. If possible, we expect reserved files to be completed. If you find you cannot complete a file, because it is intractable for one reason or another, or real-life circumstances get in the way, please talk to one of the leads in Discord; we may find someone else interested in helping you finish, or who is happy to take over the file from you completely. If you unreserve a file on which you have useful progress, please leave a link to your branch in the Notes column on the Google Sheet that the next person who works on the file can use. - ## Style Guide & Conventions -See the [Style Guide](docs/STYLE.md). +See the [Style Guide](STYLE.md). ## `NON_MATCHING` and `NON_EQUIVALENT` @@ -74,17 +70,18 @@ If you make significant progress on decompiling a function, but can't get it to ```c #ifdef NON_MATCHING -void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { +void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v) { // ... } #else -void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v); +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](tools/decomp-permuter) to find a closer match, + +- using the [decomp-permuter](https://github.com/simonlindholm/decomp-permuter) to find a closer match, - Asking in `#mm-decomp-help` in Discord; the easiest way to allow other people to play around with the function you are stuck on is to make a scratch on [decomp.me](http://decomp.me). `NON_EQUIVALENT` can be used with the same syntax as `NON_MATCHING`, but it is used to mark sections of code which do not match *and* do not have the same behavior as the original code. @@ -104,8 +101,7 @@ Documenting is more than just adding comments. Documenting also includes: Overlays are not required to be documented at this time, but files from `code/` and `boot/` should be documented. When documentation on a file has been started it should be as complete as reasonable. -See the [Style Guide](docs/STYLE.md) for more details on documentation style. - +See the [Style Guide](STYLE.md) for more details on documentation style. ## Pull Requests (PRs) @@ -125,13 +121,15 @@ Feel free to reach out on the Discord if you have any questions about these step ### Pull Request Process After opening a PR, the Jenkins agent will test formatting, the contents of the spec, build the rom and check for warnings. -If there is an error, double-check that you can successfully +If there is an error, double-check that you can successfully + ```bash make disasm ./extract_assets.py -f make clean make ``` + locally. If the build is `OK`, the next thing to check is that all added/modified files were `git add`-ed to your commit. The final check before posting on Discord for help is that there are no new warnings added to the code causing Jenkins to fail. You can check this by running: `tools/warnings_count/check_new_warnings.sh`. Each PR needs a review from two reviewers, at least one a project lead, and final approval from Kenix. diff --git a/docs/REVIEWING.md b/docs/REVIEWING.md index 11545fb27..8b70f2711 100644 --- a/docs/REVIEWING.md +++ b/docs/REVIEWING.md @@ -1,6 +1,6 @@ # Reviewing Pull Requests to the Majora's Mask Decompilation Project -Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask*! +Thanks for helping us reverse engineer *The Legend of Zelda: Majora's Mask*! We encourage all contributors to participate in code review: this is your codebase too! Every review submitted helps us keep code quality high and code merged in more quickly. @@ -11,13 +11,11 @@ Most discussions happen on our [Discord Server](https://discord.zelda64.dev) whe Other links are available in the [CONTRIBUTING.md](CONTRIBUTING.md) - ## Getting Started ### What should I know to take part in the review process? -You should first famiiarise yourself with our [Contributing guide](CONTRIBUTING.md) and [Style guide](docs/STYLE.md). It is also recommended that you have already successfully submitted a merged pull request to understand how the process works before submitting a review. - +You should first famiiarise yourself with our [Contributing guide](CONTRIBUTING.md) and [Style guide](STYLE.md). It is also recommended that you have already successfully submitted a merged pull request to understand how the process works before submitting a review. ## Pull Requests (PRs) @@ -29,6 +27,7 @@ You should first famiiarise yourself with our [Contributing guide](CONTRIBUTING. - If someone does not address your comments and expresses that a different way is better than yours, look for feedback from other contributors (we encourage discussing this sort of thing in Discord, since long GitHub conversations get hard to read). The project leads will have final say in these situations. All decisions are generally guided by a consensus of contributors. ### Reviewer Checklist + - [ ] Jenkins build is successful. - [ ] `make` builds a matching ROM. - [ ] `format.sh` was run. diff --git a/docs/STYLE.md b/docs/STYLE.md index 6524e05d6..0cf1d051b 100644 --- a/docs/STYLE.md +++ b/docs/STYLE.md @@ -44,26 +44,31 @@ A lot of formatting is done by clang-format, such as There are various other conventions that it does not catch, though: - Blank line between declarations and code: + ```c s32 var; func(); ``` + - combine declarations and definitions if possible: + ```c s32 var = 0; func(); ``` + instead of + ```c s32 var; var = 0; func(); ``` -- blank lines between switch cases if they're long (use your judgement). +- blank lines between switch cases if they're long (use your judgement). ## Numbers @@ -98,6 +103,7 @@ Floats usually need an `f` on the end to match, or IDO will use doubles. Our flo - When conditions are `&&`d or `||`d together, use brackets around each that includes an arithmetic comparison or bitwise operator (i.e. not `!var` or `func()`, but ones with `==` or `&` etc.) - Flag checks or functions that return booleans do not need the `== 0`/`!= 0`. - Prefer `if-else` over `if { return; }`, i.e. + ```c if (cond) { foo(); @@ -105,7 +111,9 @@ Floats usually need an `f` on the end to match, or IDO will use doubles. Our flo bar(); } ``` + over + ```c if (cond) { foo(); @@ -113,15 +121,16 @@ Floats usually need an `f` on the end to match, or IDO will use doubles. Our flo } bar(); ``` -**Exception**: After `Actor_MarkForDeath` or sometimes setting the action function, if it makes sense to do so (this expresses the finality a bit better). + +**Exception**: After `Actor_Kill` 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, + - `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. @@ -139,18 +148,19 @@ All compound flag lists (e.g. `ACTOR_FLAG_4 | ACTOR_FLAG_8`) should be listed in - Use `sizeof` or `ARRAY_COUNT`/`ARRAY_COUNTU` where it makes sense, e.g. in loops that are using an array. - clang-format sometimes does weird things to array formatting. Experiment with and without a comma after the last element and see which looks better. -## GlobalCtx2 +## Play2 -In some particular instances, IDO requires the function argument `globalCtx` to be cast to a second variable of the same type to match. In these particular instances, the function argument should be renamed to `globalCtx2` and than this `globalCtx2` just assigned to a stack variable called `globalCtx`. This cast should occur before the actor `THIS` cast is made. For example in `z_en_firefly.c` +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, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +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, GlobalContext* globalCtx) { +void BgGoronOyu_Init(Actor* thisx, PlayState* play) { s32 pad; BgGoronOyu* this = THIS; CollisionHeader* colHeader = NULL; @@ -158,10 +168,10 @@ void BgGoronOyu_Init(Actor* thisx, GlobalContext* globalCtx) { In general, pads should be `s32`, or `s16`/`s8` if required. - ## Documentation and Comments Documentation includes: + - Naming functions - Naming struct variables - Naming data @@ -175,13 +185,16 @@ Documentation includes: If you are not sure what something does, it is better to leave it unnamed than name it wrongly. It is fine to make a note of something you are not sure about when PRing, it means the reviewers will pay special attention to it. We use comments for: + - Top of file: a short description of the system. For actors there is already a brief description of our current understanding, but feel free to add to it. -- For function descriptions, we use multiline comments, +- For function descriptions, we use multiline comments, + ```c /** * Describe what the function does */ ``` + These are *optional*: if you think the code is clear enough, you do not need to put a comment. You can use Doxygen formatting if you think it adds something, but it is also not required. - If something in a function is strange, or unintuitive, do leave a comment explaining what's going on. We use `//` for this. - We also use `//` for temporary comments above a function. Feel free to use `TODO:` in these if appropriate. @@ -199,7 +212,7 @@ All functions should go in the main C file in the same order as the assembly (th - If in doubt, leave all the data at the top of the file. Reviewers will decide for you. - Data must go in the same order as in the assembly files, but is only constrained by other data, not functions or rodata. -- Some data has to be inline static to match. Generally it's better to not use `static` on data outside funtions until the file is matching, since `static` data is left out of the mapfile and this makes debugging harder. +- Some data has to be inline static to match. Generally it's better to not use `static` on data outside funtions until the file is matching, since `static` data is left out of the mapfile and this makes debugging harder. - *This is even more true of bss, where we have trouble with IDO unpredictably reordering it in certain files.* - For small arrays or simple data that is used in only one function, we usually inline it, if it fits in the ordering. - Generally data that is only used by the draw functions is put down near them: this is one of the few consistencies in ordering of actors' functions. @@ -207,15 +220,19 @@ All functions should go in the main C file in the same order as the assembly (th ### Enums and defines - Actors that bitpack params should have macros made for each access or write that is made. `z_en_dg.h` has an undocumented example, + ```c #define ENDG_GET_FC00(thisx) (((thisx)->params & 0xFC00) >> 0xA) #define ENDG_GET_3E0(thisx) (((thisx)->params & 0x3E0) >> 5) ``` + while `z_en_firefly.h` has a documented one, + ```c #define KEESE_INVISIBLE (1 << 0xF) #define KEESE_GET_MAIN_TYPE(thisx) ((thisx)->params & 0x7FFF) ``` + - In a similar manner, actors that use `home.rot.(x|y|z)` like params should also macros made for accesses and writes. (See, e.g. `z_obj_bean.h`.) - Stuff that only the actor itself will use goes in the C file unless needed in the header. - Anything actor-specific that might be used by another file goes in the header, in particular params access macros. diff --git a/docs/tools.md b/docs/tools.md index 6fec9caf8..0aba4fa47 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -23,7 +23,7 @@ - [`tools/warnings_count/check_new_warnings.sh`](#toolswarnings_countcheck_new_warningssh) - [`tools/warnings_count/update_current_warnings.sh`](#toolswarnings_countupdate_current_warningssh) - [`fixle.sh`](#fixlesh) - - [`format.sh`](#formatsh) + - [`format.py`](#formatpy) - [External tools](#external-tools) - [mips_to_c](#mips_to_c) - [Permuter](#permuter) @@ -196,9 +196,31 @@ If you have to add new warnings, **and have permission from the leads**, run thi Fixes line endings in the repo to Linux style (LF), which is required for the build process to work. (You may be better off creating a new clone directly in Linux/WSL, though) -### `format.sh` +### `format.py` -Formats all C files in the repo using `clang-format-11` (instructions on how to install this version are pinned in Discord if you can't get it from your package manager in the usual way). This will touch all files in the repo, so the next `make` will take longer. +Formats all C files in the repo using `clang-format-11`, `clang-tidy`, and `clang-apply-replacements` (when multiprocessing). This will touch all files in the repo, so the next `make` will take longer. + +You can specify how many threads you would like this to run with by adding the `-jN` flag. Where N is the number of threads. By default this will run using 1 thread (i.e. `-j1`). + +`clang-11` is available in many native package managers, but if not try: + +Linux: +Download llvm's setup script, run it, than install normally +```bash +wget https://apt.llvm.org/llvm.sh +chmod +x llvm.sh +sudo ./llvm.sh 11 +rm llvm.sh +sudo apt install clang-format-11 clang-tidy-11 clang-apply-replacements-11 +``` + +Mac: +Install with brew, than create symlinks for `clang-tidy` and `clang-apply-replacements` to use properly +```bash +brew install llvm clang-format-11 +ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy" +ln -s "$(brew --prefix llvm)/bin/clang-apply-replacements" "/usr/local/bin/clang-apply-replacements" +``` ## External tools @@ -286,6 +308,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..96ba7a43d 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -16,17 +16,17 @@ 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 = { +ActorInit En_Ms_InitVars = { ACTOR_EN_MS, ACTORCAT_NPC, FLAGS, @@ -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..591f12a2b 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,14 +20,14 @@ 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 -const ActorInit En_Recepgirl_InitVars = { +ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, FLAGS, @@ -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; @@ -124,8 +122,6 @@ typedef struct EnRecepgirl { /* 0x02AC */ char unk_2AC[0x8]; } EnRecepgirl; // size = 0x2B4 -extern const ActorInit En_Recepgirl_InitVars; - #endif // Z_EN_RECEPGIRL_H ``` @@ -133,15 +129,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 +154,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 +178,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 +198,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 +207,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 +225,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 +233,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 +245,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 +263,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 +272,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 +302,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 +320,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; @@ -333,7 +335,7 @@ For now, we do not want to consider the data that mips2c has kindly imported for ```C #if 0 -const ActorInit En_Recepgirl_InitVars = { +ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, FLAGS, @@ -364,7 +366,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 +382,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 +411,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 +433,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 +483,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 +501,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 +525,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 +538,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 +587,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 +654,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 +670,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 +679,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 +689,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..6884ebb12 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,19 +29,21 @@ 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 = { +ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, FLAGS, @@ -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,8 +97,9 @@ endseg ``` Next remove all the externs, and uncomment their corresponding commented data: + ```C -const ActorInit En_Recepgirl_InitVars = { +ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, FLAGS, @@ -111,22 +122,24 @@ 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 = { +ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, FLAGS, @@ -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 7e8435da9..68c90ef66 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,17 +38,17 @@ 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 = { +ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, FLAGS, @@ -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,7 +229,7 @@ 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) { @@ -241,18 +239,18 @@ void func_80C10590(GlobalContext *globalCtx, s32 limbIndex, Actor *thisx) { } // #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,21 +306,24 @@ 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 = { +ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, 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,7 +437,7 @@ 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) { @@ -431,6 +446,7 @@ void EnRecepgirl_UnkLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } } ``` + 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 4eb22bf4f..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,20 +169,24 @@ 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_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_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) { @@ -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,14 +215,14 @@ 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; @@ -218,29 +232,35 @@ void ObjTree_Draw(Actor *thisx, GlobalContext *globalCtx) { 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_RotateZYX(sp36, 0, sp34, 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_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..f4030be5b 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[] = { [...] @@ -136,7 +149,8 @@ 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: +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 RGBA16 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..1c8ba6b5b 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" + /* 0x0F5C */ u32 regionsVisited; // "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/format.py b/format.py new file mode 100755 index 000000000..5b3cd3158 --- /dev/null +++ b/format.py @@ -0,0 +1,176 @@ +#!/usr/bin/env python3 + +import argparse +import glob +import multiprocessing +import os +import re +import shutil +import subprocess +import sys +import tempfile +from functools import partial +from typing import List + + +# clang-format, clang-tidy and clang-apply-replacements default version +# Version 11 is used when available for more consistency between contributors +CLANG_VER = 11 + +# Clang-Format options (see .clang-format for rules applied) +FORMAT_OPTS = "-i -style=file" + +# Clang-Tidy options (see .clang-tidy for checks enabled) +TIDY_OPTS = "-p ." +TIDY_FIX_OPTS = "--fix --fix-errors" + +# Clang-Apply-Replacements options (used for multiprocessing) +APPLY_OPTS = "" + +# Compiler options used with Clang-Tidy +# Normal warnings are disabled with -Wno-everything to focus only on tidying +INCLUDES = "-Iinclude -Isrc -Ibuild -I." +DEFINES = "-D_LANGUAGE_C -DNON_MATCHING" +COMPILER_OPTS = f"-fno-builtin -std=gnu90 -m32 -Wno-everything {INCLUDES} {DEFINES}" + + +def get_clang_executable(allowed_executables: List[str]): + for executable in allowed_executables: + try: + subprocess.check_call([executable, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return executable + except FileNotFoundError or subprocess.CalledProcessError: + pass + return None + + +def get_tidy_version(tidy_executable: str): + tidy_version_run = subprocess.run([tidy_executable, "--version"], stdout=subprocess.PIPE, universal_newlines=True) + match = re.search(r"LLVM version ([0-9]+)", tidy_version_run.stdout) + return int(match.group(1)) + + +CLANG_FORMAT = get_clang_executable([f"clang-format-{CLANG_VER}"]) +if CLANG_FORMAT is None: + sys.exit(f"Error: clang-format-{CLANG_VER} found") + +CLANG_TIDY = get_clang_executable([f"clang-tidy-{CLANG_VER}", "clang-tidy"]) +if CLANG_TIDY is None: + sys.exit(f"Error: neither clang-tidy-{CLANG_VER} nor clang-tidy found") + +CLANG_APPLY_REPLACEMENTS = get_clang_executable([f"clang-apply-replacements-{CLANG_VER}", "clang-apply-replacements"]) + +# Try to detect the clang-tidy version and add --fix-notes for version 13+ +# This is used to ensure all fixes are applied properly in recent versions +if get_tidy_version(CLANG_TIDY) >= 13: + TIDY_FIX_OPTS += " --fix-notes" + + +def list_chunks(list: List, chunk_length: int): + for i in range(0, len(list), chunk_length): + yield list[i : i + chunk_length] + + +def run_clang_format(files: List[str]): + exec_str = f"{CLANG_FORMAT} {FORMAT_OPTS} {' '.join(files)}" + subprocess.run(exec_str, shell=True) + + +def run_clang_tidy(files: List[str]): + exec_str = f"{CLANG_TIDY} {TIDY_OPTS} {TIDY_FIX_OPTS} {' '.join(files)} -- {COMPILER_OPTS}" + subprocess.run(exec_str, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + +def run_clang_tidy_with_export(tmp_dir: str, files: List[str]): + (handle, tmp_file) = tempfile.mkstemp(suffix=".yaml", dir=tmp_dir) + os.close(handle) + + exec_str = f"{CLANG_TIDY} {TIDY_OPTS} --export-fixes={tmp_file} {' '.join(files)} -- {COMPILER_OPTS}" + subprocess.run(exec_str, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + +def run_clang_apply_replacements(tmp_dir: str): + exec_str = f"{CLANG_APPLY_REPLACEMENTS} {APPLY_OPTS} {tmp_dir}" + subprocess.run(exec_str, shell=True) + + +def add_final_new_line(file: str): + # https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html + # "gets the last character of the file pipes it into read, which will exit with a nonzero exit + # code if it encounters EOF before newline (so, if the last character of the file isn't a newline). + # If read exits nonzero, then append a newline onto the file using echo (if read exits 0, + # that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616) + exec_str = f"tail -c1 {file} | read -r _ || echo >> {file}" + subprocess.run(exec_str, shell=True) + + +def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int): + if nb_jobs != 1: + print(f"Formatting files with {nb_jobs} jobs") + else: + print(f"Formatting files with a single job (consider using -j to make this faster)") + + # Format files in chunks to improve performance while still utilizing jobs + file_chunks = list(list_chunks(src_files, (len(src_files) // nb_jobs) + 1)) + + print("Running clang-format...") + # clang-format only applies changes in the given files, so it's safe to run in parallel + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(run_clang_format, file_chunks) + + print("Running clang-tidy...") + if nb_jobs > 1: + # clang-tidy may apply changes in #included files, so when running it in parallel we use --export-fixes + # then we call clang-apply-replacements to apply all suggested fixes at the end + tmp_dir = tempfile.mkdtemp() + + try: + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(partial(run_clang_tidy_with_export, tmp_dir), file_chunks) + + run_clang_apply_replacements(tmp_dir) + finally: + shutil.rmtree(tmp_dir) + else: + run_clang_tidy(src_files) + + print("Adding missing final new lines...") + # Adding final new lines is safe to do in parallel and can be applied to all types of files + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(add_final_new_line, src_files + extra_files) + + print("Done formatting files.") + + +def main(): + parser = argparse.ArgumentParser(description="Format files in the codebase to enforce most style rules") + parser.add_argument("files", metavar="file", nargs="*") + parser.add_argument( + "-j", + dest="jobs", + type=int, + nargs="?", + default=1, + help="number of jobs to run (default: 1 without -j, number of cpus with -j)", + ) + args = parser.parse_args() + + nb_jobs = args.jobs or multiprocessing.cpu_count() + if nb_jobs > 1: + if CLANG_APPLY_REPLACEMENTS is None: + sys.exit( + f"Error: neither clang-apply-replacements-{CLANG_VER} nor clang-apply-replacements found (required to use -j)" + ) + + if args.files: + files = args.files + extra_files = [] + else: + files = glob.glob("src/**/*.c", recursive=True) + extra_files = glob.glob("assets/**/*.xml", recursive=True) + + format_files(files, extra_files, nb_jobs) + + +if __name__ == "__main__": + main() diff --git a/format.sh b/format.sh deleted file mode 100755 index 1c9389a9a..000000000 --- a/format.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -FORMAT_VER="11" -FORMAT_OPTS="-i -style=file" -TIDY_OPTS="-p . --fix --fix-errors" -COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING" - -# https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html -# "gets the last character of the file pipes it into read, which will exit with a nonzero exit code if it encounters EOF before newline (so, if the last character of the file isn't a newline). If read exits nonzero, then append a newline onto the file using echo (if read exits 0, that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616) -function add_final_newline () { - for file in "$@" - do - tail -c1 $file | read -r _ || echo >> $file - done -} -export -f add_final_newline - -shopt -s globstar - -if [ -z `command -v clang-format-${FORMAT_VER}` ] -then - echo "clang-format-${FORMAT_VER} not found. Exiting." - exit 1 -fi - -if (( $# > 0 )); then - echo "Formatting file(s) $*" - echo "Running clang-format..." - clang-format-${FORMAT_VER} ${FORMAT_OPTS} "$@" - echo "Running clang-tidy..." - clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null - echo "Adding missing final new lines..." - add_final_newline "$@" - echo "Done formatting file(s) $*" - exit -fi - -echo "Formatting C files. This will take a bit" -echo "Running clang-format..." -clang-format-${FORMAT_VER} ${FORMAT_OPTS} src/**/*.c -echo "Running clang-tidy..." -clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null -echo "Adding missing final new lines..." -find src/ -type f -name "*.c" -exec bash -c 'add_final_newline "$@"' bash {} + -find assets/xml/ -type f -name "*.xml" -exec bash -c 'add_final_newline "$@"' bash {} + -echo "Done formatting all files." diff --git a/include/PR/abi.h b/include/PR/abi.h index 49d539762..15ae5d911 100644 --- a/include/PR/abi.h +++ b/include/PR/abi.h @@ -53,6 +53,7 @@ #define A_INIT 0x01 #define A_CONTINUE 0x00 #define A_LOOP 0x02 +#define A_ADPCM_SHORT 0x04 #define A_OUT 0x02 #define A_LEFT 0x02 #define A_RIGHT 0x00 @@ -331,13 +332,20 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(a2); \ } -#define aClearBuffer(pkt, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \ - _a->words.w1 = (unsigned int)(c); \ -} +/* + * Clears DMEM by writing zeros. + * + * @param pkt pointer to an Acmd buffer + * @param dmem DMEM address to clear + * @param size number of bytes to clear (rounded up to the next multiple of 16) + */ +#define aClearBuffer(pkt, dmem, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(dmem, 0, 24); \ + _a->words.w1 = (uintptr_t)(size); \ + } #define aEnvMixer(pkt, dmemi, count, swapLR, x0, x1, x2, x3, m, bits) \ { \ @@ -368,14 +376,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \ } -#define aLoadBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(d, 0, 16); \ - _a->words.w1 = (unsigned int)(s); \ -} +/* + * Loads a buffer to DMEM from any physical source address, KSEG0, or KSEG1 + * + * @param pkt pointer to an Acmd buffer + * @param addrSrc Any physical source address, KSEG0, or KSEG1 + * @param dmemDest DMEM destination address + * @param size number of bytes to copy (rounded down to the next multiple of 16) + */ +#define aLoadBuffer(pkt, addrSrc, dmemDest, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemDest, 0, 16)); \ + _a->words.w1 = (uintptr_t)(addrSrc); \ + } #define aMix(pkt, f, g, i, o) \ { \ @@ -404,14 +419,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(s); \ } -#define aSaveBuffer(pkt, s, d, c) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | \ - _SHIFTL((c) >> 4, 16, 8) | _SHIFTL(s, 0, 16); \ - _a->words.w1 = (unsigned int)(d); \ -} +/* + * Stores a buffer from DMEM to any physical source address, KSEG0, or KSEG1 + * + * @param pkt pointer to an Acmd buffer + * @param dmemSrc DMEM source address + * @param addrDest Any physical source address, KSEG0, or KSEG1 + * @param size number of bytes to copy (rounded down to the next multiple of 16) + */ +#define aSaveBuffer(pkt, dmemSrc, addrDest, size) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \ + _a->words.w1 = (uintptr_t)(addrDest); \ + } #define aSegment(pkt, s, b) \ { \ @@ -501,14 +523,21 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int)(addr); \ } -#define aDuplicate(pkt, count, dmemi, dmemo, a4) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | \ - _SHIFTL(count, 16, 8) | _SHIFTL(dmemi, 0, 16)); \ - _a->words.w1 = _SHIFTL(dmemo, 16, 16) | _SHIFTL(a4, 0, 16); \ -} +/* + * Duplicates 128 bytes of data a specified number of times. + * + * @param pkt pointer to an Acmd buffer + * @param numCopies number of times to duplicate 128 bytes from src + * @param dmemSrc DMEM source address + * @param dmemDest DMEM destination address for the duplicates, size 128 * numCopies + */ +#define aDuplicate(pkt, numCopies, dmemSrc, dmemDest) \ + { \ + Acmd* _a = (Acmd*)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | _SHIFTL(numCopies, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \ + _a->words.w1 = _SHIFTL(dmemDest, 16, 16) | _SHIFTL(0x80, 0, 16); \ + } #define aAddMixer(pkt, count, dmemi, dmemo, a4) \ { \ diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 8e5aefe8e..07fa0ac2c 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. @@ -2371,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 @@ -2391,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 */ @@ -2597,11 +2599,11 @@ _DW({ \ gsSPLoadUcodeEx((uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) #define gSPLoadUcodeL(pkt, ucode) \ - gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) + gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&ucode##TextStart), \ + OS_K0_TO_PHYSICAL(&ucode##DataStart)) #define gsSPLoadUcodeL(ucode) \ - gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) + gsSPLoadUcode(OS_K0_TO_PHYSICAL(&ucode##TextStart), \ + OS_K0_TO_PHYSICAL(&ucode##DataStart)) #endif #ifdef F3DEX_GBI_2 @@ -2865,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 @@ -3570,7 +3572,7 @@ _DW({ \ #define gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, \ pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ 0 , cmt, maskt, shiftt, cms, masks, shifts); \ @@ -3586,7 +3588,7 @@ _DW({ \ gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ ((height)-1) << G_TEXTURE_IMAGE_FRAC); \ -} +}) #define gDPLoadTextureBlockYuv(pkt, timg, fmt, siz, width, height, \ pal, cms, cmt, masks, maskt, shifts, shiftt) \ @@ -3877,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); \ @@ -3892,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 */ @@ -4130,7 +4132,7 @@ _DW({ \ #define gDPLoadMultiTile(pkt, timg, tmem, rtile, fmt, siz, width, height,\ uls, ult, lrs, lrt, pal, \ cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ +_DW({ \ gDPSetTextureImage(pkt, fmt, siz, width, timg); \ gDPSetTile(pkt, fmt, siz, \ (((((lrs)-(uls)+1) * siz##_TILE_BYTES)+7)>>3), tmem, \ @@ -4152,7 +4154,7 @@ _DW({ \ (ult)<>1), timg); \ gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ @@ -4267,7 +4269,7 @@ _DW({ \ (ult)<> 28) #define SEGMENT_ADDR(num, off) (((num) << 24) + (off)) diff --git a/include/alignment.h b/include/alignment.h new file mode 100644 index 000000000..e26a1d3f3 --- /dev/null +++ b/include/alignment.h @@ -0,0 +1,28 @@ +#ifndef ALIGNMENT_H +#define ALIGNMENT_H + +#define ALIGN8(val) (((val) + 7) & ~7) +#define ALIGN16(val) (((val) + 0xF) & ~0xF) +#define ALIGN32(val) (((val) + 0x1F) & ~0x1F) +#define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) + +#ifdef __GNUC__ +#define ALIGNED8 __attribute__ ((aligned (8))) +#else +#define ALIGNED8 +#endif + +#ifdef __sgi /* IDO compiler */ +#define ALIGNOF(x) __builtin_alignof(x) +#elif (__STDC_VERSION__ >= 201112L) /* C11 */ +#define ALIGNOF(x) _Alignof(x) +#else /* __GNUC__ */ +#define ALIGNOF(x) __alignof__(x) +#endif + +#define ALIGN_MASK(n) (~((n) - 1)) + +#define ALIGNOF_MASK(x) ALIGN_MASK(ALIGNOF(x)) + +#endif diff --git a/include/audiothread_cmd.h b/include/audiothread_cmd.h new file mode 100644 index 000000000..c9e6703dc --- /dev/null +++ b/include/audiothread_cmd.h @@ -0,0 +1,644 @@ +#ifndef AUDIOTHREAD_CMD_H +#define AUDIOTHREAD_CMD_H + +/** + * Audio thread commands to safely transfer information/requests/data + * from the external graph thread to the internal audio thread + */ + +typedef enum { + // Channel Commands + /* 0x00 */ AUDIOCMD_OP_NOOP, + /* 0x01 */ AUDIOCMD_OP_CHANNEL_SET_VOL_SCALE, + /* 0x02 */ AUDIOCMD_OP_CHANNEL_SET_VOL, + /* 0x03 */ AUDIOCMD_OP_CHANNEL_SET_PAN, + /* 0x04 */ AUDIOCMD_OP_CHANNEL_SET_FREQ_SCALE, + /* 0x05 */ AUDIOCMD_OP_CHANNEL_SET_REVERB_VOLUME, + /* 0x06 */ AUDIOCMD_OP_CHANNEL_SET_IO, + /* 0x07 */ AUDIOCMD_OP_CHANNEL_SET_PAN_WEIGHT, + /* 0x08 */ AUDIOCMD_OP_CHANNEL_SET_MUTE, + /* 0x09 */ AUDIOCMD_OP_CHANNEL_SET_MUTE_FLAGS, + /* 0x0A */ AUDIOCMD_OP_CHANNEL_SET_VIBRATO_DEPTH, + /* 0x0B */ AUDIOCMD_OP_CHANNEL_SET_VIBRATO_RATE, + /* 0x0C */ AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_SIZE, + /* 0x0D */ AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_GAIN, + /* 0x0E */ AUDIOCMD_OP_CHANNEL_SET_STEREO, + /* 0x0F */ AUDIOCMD_OP_CHANNEL_SET_SET_START_POS, + /* 0x10 */ AUDIOCMD_OP_CHANNEL_SET_SFX_STATE, + /* 0x11 */ AUDIOCMD_OP_CHANNEL_SET_REVERB_INDEX, + /* 0x12 */ AUDIOCMD_OP_CHANNEL_SET_SURROUND_EFFECT_INDEX, + /* 0x13 */ AUDIOCMD_OP_CHANNEL_SET_FILTER, + /* 0x14 */ AUDIOCMD_OP_CHANNEL_SET_GAIN, + // SeqPlayer Commands + /* 0x41 */ AUDIOCMD_OP_SEQPLAYER_FADE_VOLUME_SCALE = 0x41, + /* 0x46 */ AUDIOCMD_OP_SEQPLAYER_SET_IO = 0x46, + /* 0x47 */ AUDIOCMD_OP_SEQPLAYER_SET_TEMPO, + /* 0x48 */ AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION, + /* 0x49 */ AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO, + /* 0x4A */ AUDIOCMD_OP_SEQPLAYER_FADE_TO_SET_VOLUME, + /* 0x4B */ AUDIOCMD_OP_SEQPLAYER_FADE_TO_SCALED_VOLUME, + /* 0x4C */ AUDIOCMD_OP_SEQPLAYER_RESET_VOLUME, + /* 0x4D */ AUDIOCMD_OP_SEQPLAYER_SET_BEND, + /* 0x4E */ AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO_TICKS, + // Global Commands + /* 0x81 */ AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS = 0x81, + /* 0x82 */ AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER, + /* 0x83 */ AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER, + /* 0x85 */ AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS = 0x85, + /* 0x90 */ AUDIOCMD_OP_GLOBAL_SET_CHANNEL_MASK = 0x90, + /* 0xE0 */ AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT = 0xE0, + /* 0xE1 */ AUDIOCMD_OP_GLOBAL_SET_SFX_FONT, + /* 0xE2 */ AUDIOCMD_OP_GLOBAL_SET_INSTRUMENT_FONT, + /* 0xE3 */ AUDIOCMD_OP_GLOBAL_POP_PERSISTENT_CACHE, + /* 0xE4 */ AUDIOCMD_OP_GLOBAL_SET_CUSTOM_FUNCTION, // TODO: check + /* 0xE5 */ AUDIOCMD_OP_GLOBAL_E5, // TODO: check + /* 0xE6 */ AUDIOCMD_OP_GLOBAL_SET_REVERB_DATA, + /* 0xF0 */ AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE = 0xF0, + /* 0xF1 */ AUDIOCMD_OP_GLOBAL_MUTE, + /* 0xF2 */ AUDIOCMD_OP_GLOBAL_UNMUTE, + /* 0xF3 */ AUDIOCMD_OP_GLOBAL_SYNC_LOAD_INSTRUMENT, + /* 0xF4 */ AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK, + /* 0xF5 */ AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT, + /* 0xF6 */ AUDIOCMD_OP_GLOBAL_DISCARD_SEQ_FONTS, + /* 0xF8 */ AUDIOCMD_OP_GLOBAL_STOP_AUDIOCMDS = 0xF8, + /* 0xF9 */ AUDIOCMD_OP_GLOBAL_RESET_AUDIO_HEAP, + /* 0xFA */ AUDIOCMD_OP_GLOBAL_NOOP_1, // used but no code exists for it + /* 0xFB */ AUDIOCMD_OP_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION, + /* 0xFC */ AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SEQ, + /* 0xFD */ AUDIOCMD_OP_GLOBAL_NOOP_2, // used but no code exists for it + /* 0xFE */ AUDIOCMD_OP_GLOBAL_DISABLE_ALL_SEQPLAYERS +} AudioThreadCmdOp; + +#define AUDIO_MK_CMD(b0, b1, b2, b3) (_SHIFTL(b0, 24, 8) | _SHIFTL(b1, 16, 8) | _SHIFTL(b2, 8, 8) | _SHIFTL(b3, 0, 8)) + +#define AUDIOCMD_ALL_SEQPLAYERS 0xFF +// Pass to a AUDIOCMD_CHANNEL_ command in place of a channelIndex to try and apply to all channels. +// Then uses `threadCmdChannelMask` to determine which channels to apply the command to. +#define AUDIOCMD_ALL_CHANNELS 0xFF + +// ==== Audio Thread Channel Commands ==== + +/** + * Set the volumeScale on a given channel + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param volumeScale (f32) the volume scale for the sequence. No change in volume is 1.0f + */ +#define AUDIOCMD_CHANNEL_SET_VOL_SCALE(seqPlayerIndex, channelIndex, volumeScale) \ + AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_VOL_SCALE, seqPlayerIndex, channelIndex, 0), \ + volumeScale) + +/** + * Set the volume on a given channel + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param volume (f32) the target volume for the sequence. Default volume is 1.0f + */ +#define AUDIOCMD_CHANNEL_SET_VOL(seqPlayerIndex, channelIndex, volume) \ + AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_VOL, seqPlayerIndex, channelIndex, 0), volume) + +/** + * Set the pan + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param pan (s8) the pan applied to the channel + */ +#define AUDIOCMD_CHANNEL_SET_PAN(seqPlayerIndex, channelIndex, pan) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_PAN, seqPlayerIndex, channelIndex, 0), pan) + +/** + * Set frequency scale + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param freqScale (f32) the scaling factor to shift the pitch. + */ +#define AUDIOCMD_CHANNEL_SET_FREQ_SCALE(seqPlayerIndex, channelIndex, freqScale) \ + AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_FREQ_SCALE, seqPlayerIndex, channelIndex, 0), \ + freqScale) + +/** + * Set reverb volume + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param reverbVolume (s8) volume to set the reverb to (dry/wet mix) + */ +#define AUDIOCMD_CHANNEL_SET_REVERB_VOLUME(seqPlayerIndex, channelIndex, reverbVolume) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_REVERB_VOLUME, seqPlayerIndex, channelIndex, 0), \ + reverbVolume) + +/** + * Write a value that can be read as input directly by the sequence itself. This will be set to the channel + * ioPort, which will only affect a single channel + * + * @param seqPlayerIndex the index of the seqPlayer to write the input to + * @param channelIndex the index of the channel to write the input to + * @param ioPort the index of the array to store the input-output value + * @param ioData (s8) the value that's written to the input-output array + */ +#define AUDIOCMD_CHANNEL_SET_IO(seqPlayerIndex, channelIndex, ioPort, ioData) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_IO, seqPlayerIndex, channelIndex, ioPort), ioData) + +/** + * Set the proportion of pan that comes from the channel + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param panChannelWeight (u8) proportion of pan that comes from the channel. + * Set to 0 for layer-only, and 128 for channel-only. + */ +#define AUDIOCMD_CHANNEL_SET_PAN_WEIGHT(seqPlayerIndex, channelIndex, panChannelWeight) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_PAN_WEIGHT, seqPlayerIndex, channelIndex, 0), \ + panChannelWeight) + +/** + * Mute a specified channel. How a muted channel behaves will depend on channel mute flags + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param muted (s8) set true to mute + */ +#define AUDIOCMD_CHANNEL_SET_MUTE(seqPlayerIndex, channelIndex, muted) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_MUTE, seqPlayerIndex, channelIndex, 0), muted) + +/** + * Set the muteFlags for a specified channel + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param muteFlags (s8) Affected how a muted channel behaves. See `MUTE_BEHAVIOR_` macros + */ +#define AUDIOCMD_CHANNEL_SET_MUTE_FLAGS(seqPlayerIndex, channelIndex, muteFlags) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_MUTE_FLAGS, seqPlayerIndex, channelIndex, 0), muteFlags) + +/** + * Set the vibrato depth (magnitude/amplitude/extent) + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param vibratoDepthTarget (s8) the vibrato depth scaled down by 1/8th + */ +#define AUDIOCMD_CHANNEL_SET_VIBRATO_DEPTH(seqPlayerIndex, channelIndex, vibratoDepthTarget) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_VIBRATO_DEPTH, seqPlayerIndex, channelIndex, 0), \ + vibratoDepthTarget) + +/** + * Set the vibrato rate (freq/pitch) + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param vibratoRateTarget (s8) the vibrato rate scaled down by 1/32nd + */ +#define AUDIOCMD_CHANNEL_SET_VIBRATO_RATE(seqPlayerIndex, channelIndex, vibratoRateTarget) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_VIBRATO_RATE, seqPlayerIndex, channelIndex, 0), \ + vibratoRateTarget) + +/** + * Set the comb filter size + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param combFilterSize (s8) delay number of sample bytes to offset and add back to itself + */ +#define AUDIOCMD_CHANNEL_SET_COMB_FILTER_SIZE(seqPlayerIndex, channelIndex, combFilterSize) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_SIZE, seqPlayerIndex, channelIndex, 0), \ + combFilterSize) + +/** + * Set the comb filter gain + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param combFilterGain (u16) strength of the signal added back to itself + */ +#define AUDIOCMD_CHANNEL_SET_COMB_FILTER_GAIN(seqPlayerIndex, channelIndex, combFilterGain) \ + AudioThread_QueueCmdU16(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_GAIN, seqPlayerIndex, channelIndex, 0), \ + combFilterGain) + +/** + * Set the stereo bits + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the channel to modify + * @param stereoData (s8) bit-packed stereo information. See `StereoData` + */ +#define AUDIOCMD_CHANNEL_SET_STEREO(seqPlayerIndex, channelIndex, stereoData) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_STEREO, seqPlayerIndex, channelIndex, 0), stereoData) + +/** + * Set the start position of a sample. + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the seqPlayer to modify + * @param startSamplePos + */ +#define AUDIOCMD_CHANNEL_SET_SET_START_POS(seqPlayerIndex, channelIndex, startSamplePos) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_SET_START_POS, seqPlayerIndex, channelIndex, 0), \ + startSamplePos) + +/** + * Set the address of the sfxState to read from. + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the seqPlayer to modify + * @param sfxState + */ +#define AUDIOCMD_CHANNEL_SET_SFX_STATE(seqPlayerIndex, channelIndex, sfxState) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_SFX_STATE, seqPlayerIndex, channelIndex, 0), sfxState) + +/** + * Set the reverb index. + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the seqPlayer to modify + * @param reverbIndex + */ +#define AUDIOCMD_CHANNEL_SET_REVERB_INDEX(seqPlayerIndex, channelIndex, reverbIndex) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_REVERB_INDEX, seqPlayerIndex, channelIndex, 0), \ + reverbIndex) + +/** + * Set the surround effect index. + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the seqPlayer to modify + * @param surroundEffectIndex + */ +#define AUDIOCMD_CHANNEL_SET_SURROUND_EFFECT_INDEX(seqPlayerIndex, channelIndex, surroundEffectIndex) \ + AudioThread_QueueCmdS8( \ + AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_SURROUND_EFFECT_INDEX, seqPlayerIndex, channelIndex, 0), \ + surroundEffectIndex) + +/** + * Set a filter. + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the seqPlayer to modify + * @param filterCutoff + * @param filter + */ +#define AUDIOCMD_CHANNEL_SET_FILTER(seqPlayerIndex, channelIndex, filterCutoff, filter) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_FILTER, seqPlayerIndex, channelIndex, filterCutoff), \ + filter) + +/** + * Set the gain. + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param channelIndex the index of the seqPlayer to modify + * @param gain + */ +#define AUDIOCMD_CHANNEL_SET_GAIN(seqPlayerIndex, channelIndex, gain) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_GAIN, seqPlayerIndex, channelIndex, 0), gain) + +// ==== Audio Thread SeqPlayer Commands ==== + +/** + * Set the fade volume scale + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param fadeVolumeScale (f32) multiplicative scaling factor to apply to volume + */ +#define AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE(seqPlayerIndex, fadeVolumeScale) \ + AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_FADE_VOLUME_SCALE, seqPlayerIndex, 0, 0), \ + fadeVolumeScale) + +/** + * Write a value that can be read as input directly by the sequence itself. This will be set to the global + * ioPort, which can affect the entire sequence + * + * @param seqPlayerIndex the index of the seqPlayer to write the input to + * @param ioPort the index of the array to store the input-output value + * @param ioData (s8) the value that's written to the input-output array + */ +#define AUDIOCMD_SEQPLAYER_SET_IO(seqPlayerIndex, ioPort, ioData) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_IO, seqPlayerIndex, 0, ioPort), ioData) + +/** + * Set the tempo (bpm) of a sequence on a given seqPlayer + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param tempo (s32) the tempo for the sequence, in bpm + */ +#define AUDIOCMD_SEQPLAYER_SET_TEMPO(seqPlayerIndex, tempo) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_TEMPO, seqPlayerIndex, 0, 0), tempo) + +/** + * Set the transposition + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param transposition (s8) the number of semitones to increase or decrease by for all notes on the seqPlayer + */ +#define AUDIOCMD_SEQPLAYER_SET_TRANSPOSITION(seqPlayerIndex, transposition) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION, seqPlayerIndex, 0, 0), transposition) + +/** + * Set tempoChange in bpm + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param tempoChange (s32) difference in tempo to change, in bpm + */ +#define AUDIOCMD_SEQPLAYER_CHANGE_TEMPO(seqPlayerIndex, tempoChange) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO, seqPlayerIndex, 0, 0), tempoChange) + +/** + * Set tempoChange in ticks per minute + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param tempoChange (s32) difference in tempo to change, in ticks per minute + */ +#define AUDIOCMD_SEQPLAYER_CHANGE_TEMPO_TICKS(seqPlayerIndex, tempoChange) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO_TICKS, seqPlayerIndex, 0, 0), tempoChange) + +/** + * Fade the volume to the target volume requested in the command + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param fadeVolume target volume to fade to + * @param fadeTimer (s32) number of ticks to fade to `fadeVolume` + */ +#define AUDIOCMD_SEQPLAYER_FADE_TO_SET_VOLUME(seqPlayerIndex, fadeVolume, fadeTimer) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_FADE_TO_SET_VOLUME, seqPlayerIndex, fadeVolume, 0), \ + fadeTimer) + +/** + * Fade the volume to the current volume scaled by a scale factor + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param fadeVolumeScale scaling factor to apply to volume to get the targetVolume + * @param fadeTimer (s32) number of ticks to fade to `targetVolume` + */ +#define AUDIOCMD_SEQPLAYER_FADE_TO_SCALED_VOLUME(seqPlayerIndex, fadeVolumeScale, fadeTimer) \ + AudioThread_QueueCmdS32( \ + AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_FADE_TO_SCALED_VOLUME, seqPlayerIndex, fadeVolumeScale, 0), fadeTimer) + +/** + * Reset to the default volume of the seqPlayer + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param fadeTimer (s32) number of ticks to fade the sequence back to its default volume + */ +#define AUDIOCMD_SEQPLAYER_RESET_VOLUME(seqPlayerIndex, fadeTimer) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_RESET_VOLUME, seqPlayerIndex, 0, 0), fadeTimer) + +/** + * Set the bend + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param bend (f32) ratio relative to 1.0f to scale channel frequencies by + */ +#define AUDIOCMD_SEQPLAYER_SET_BEND(seqPlayerIndex, bend) \ + AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_BEND, seqPlayerIndex, 0, 0), bend) + +// ==== Audio Thread Global Commands ==== + +/** + * Synchronously load a sequence in parts + * + * @param seqId the id of the sequence to load, see `SeqId` + * @param flags set `& 1` to load the sequence, set `& 2` to load the soundfonts + * @param data + */ +#define AUDIOCMD_GLOBAL_SYNC_LOAD_SEQ_PARTS(seqId, flags, data) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS, 0, seqId, flags), data) + +/** + * Synchronously initialize a sequence player + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param seqId the id of the sequence to play, see `SeqId` + * @param fadeInTimer (s32) number of ticks to fade in the sequence to the requested volume + */ +#define AUDIOCMD_GLOBAL_INIT_SEQPLAYER(seqPlayerIndex, seqId, fadeInTimer) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER, seqPlayerIndex, seqId, 0), fadeInTimer) + +/** + * Disable a sequence player + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param fadeOutTimer (s32) number of ticks to fade out the sequence + */ +#define AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(seqPlayerIndex, fadeOutTimer) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER, seqPlayerIndex, 0, 0), fadeOutTimer) + +/** + * Synchronously initialize a sequence player and skip ticks, + * allowing the sequence to start somewhere other than the beginning of the sequences + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param seqId the id of the sequence to play, see `SeqId` + * @param skipTicks (s32) number of ticks to skip before starting the sequence + */ +#define AUDIOCMD_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS(seqPlayerIndex, seqId, skipTicks) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS, seqPlayerIndex, seqId, 0), \ + skipTicks) + +/** + * When processing an audio thread channel command on all channels, set which channels to process + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param threadCmdChannelMask (u16) bitfield for 16 channels. Turn bit on to allow audio thread commands of type + * "Channel" to process that channel with `AUDIOCMD_ALL_CHANNELS` set. + */ +#define AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, threadCmdChannelMask) \ + AudioThread_QueueCmdU16(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_CHANNEL_MASK, seqPlayerIndex, 0, 0), \ + threadCmdChannelMask) + +/** + * Set a drum ptr within a soundfont + * + * @param fontId the id of the soundfont to set the drum in + * @param drumId the id of the drum to set + * @param drumPtr (s32) the ptr to the `Drum` struct + */ +#define AUDIOCMD_GLOBAL_SET_DRUM_FONT(fontId, drumId, drumPtr) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT, 0, fontId, drumId), drumPtr) + +/** + * Set a soundeffect ptr within a soundfont + * + * @param fontId the id of the soundfont to set the sound effect in + * @param soundEffectId the id of the sound effect to set + * @param soundEffectPtr (s32) the ptr to the `SoundEffect` struct + */ +#define AUDIOCMD_GLOBAL_SET_SFX_FONT(fontId, soundEffectId, soundEffectPtr) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_SFX_FONT, 0, fontId, soundEffectId), soundEffectPtr) + +/** + * Set an instrument ptr within a soundfont + * + * @param fontId the id of the soundfont to set the instrument in + * @param instId the id of the instrument to set + * @param instPtr (s32) the ptr to the `Instrument` struct + */ +#define AUDIOCMD_GLOBAL_SET_INSTRUMENT_FONT(fontId, instId, instPtr) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_INSTRUMENT_FONT, 0, fontId, instId), instPtr) + +/** + * Pop the persistent cache of the specified table + * + * @param tableType (s32) see the `SampleBankTableType` enum + */ +#define AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(tableType) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_POP_PERSISTENT_CACHE, 0, 0, 0), tableType) + +/** + * Set a custom function. + * + * @param functionType + * @param functionPtr + */ +#define AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(functionType, functionPtr) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_CUSTOM_FUNCTION, 0, 0, functionType), functionPtr) + +/** + * Do something related to the unloaded-type audio data in the heap. + * + * @param tableType + * @param id + * @param type + * @param data + */ +#define AUDIOCMD_GLOBAL_E5(tableType, id, type, data) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_E5, tableType, id, type), data) + +/** + * Set reverb data. + * + * @param reverbIndex + * @param dataType + * @param data + */ +#define AUDIOCMD_GLOBAL_SET_REVERB_DATA(reverbIndex, dataType, data) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_REVERB_DATA, dataType, reverbIndex, 0), data) + +/** + * Change the sound mode of audio + * + * @param soundMode (s32) see the `SoundMode` enum + */ +#define AUDIOCMD_GLOBAL_SET_SOUND_MODE(soundMode) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE, 0, 0, 0), soundMode) + +/** + * Mute a sequence player + * + * @param seqPlayerIndex the index of the seqPlayer to modify + */ +#define AUDIOCMD_GLOBAL_MUTE(seqPlayerIndex) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_MUTE, seqPlayerIndex, 0, 0), 0) + +/** + * Unmute a sequence player + * + * @param seqPlayerIndex the index of the seqPlayer to modify + * @param restart (s32) if set to 1, then notes with the `MUTE_FLAGS_STOP_SAMPLES` flag set are marked as finished + */ +#define AUDIOCMD_GLOBAL_UNMUTE(seqPlayerIndex, restart) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_UNMUTE, seqPlayerIndex, 0, 0), restart) + +/** + * Synchronously load an instrument + * + * @param fontId the id of the soundfont to load + * @param instId If below 0x7F, the id of the instrument to use. If equal to 0x7F, load the drum using the drumId + * @param drumId the id of the drum to use + */ +#define AUDIOCMD_GLOBAL_SYNC_LOAD_INSTRUMENT(fontId, instId, drumId) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SYNC_LOAD_INSTRUMENT, fontId, instId, drumId), 0) + +/** + * Asynchronously load a sample bank + * + * @param sampleBankId the id of the samplebank to load + * @param retData return data from `externalLoadQueue` + */ +#define AUDIOCMD_GLOBAL_ASYNC_LOAD_SAMPLE_BANK(sampleBankId, retData) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK, sampleBankId, 0, retData), 0) + +/** + * Asynchronously load a font + * + * @param fontId the id of the soundfont to load + * @param retData return data from `externalLoadQueue` + */ +#define AUDIOCMD_GLOBAL_ASYNC_LOAD_FONT(fontId, retData) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT, fontId, 20, retData), 0) + +/** + * Discard sequence fonts + * + * @param seqId the id of the sequence to discard, see `SeqId` + */ +#define AUDIOCMD_GLOBAL_DISCARD_SEQ_FONTS(seqId) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_DISCARD_SEQ_FONTS, 0, seqId, 0), 0) + +/** + * Stop processing all audio thread commands + */ +#define AUDIOCMD_GLOBAL_STOP_AUDIOCMDS() \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_STOP_AUDIOCMDS, 0, 0, 0), 0) + +/** + * Reset Audio Heap + * + * @param specId (s32) index for the audio specifications to set high-level audio parameters + */ +#define AUDIOCMD_GLOBAL_RESET_AUDIO_HEAP(specId) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_RESET_AUDIO_HEAP, 0, 0, 0), specId) + +/** + * No Operation. No code exists for this OP + * + * @param arg0 No info + * @param arg1 No info + * @param arg2 No info + * @param data (s32) No info + */ +#define AUDIOCMD_GLOBAL_NOOP_1(arg0, arg1, arg2, data) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_NOOP_1, arg0, arg1, arg2), data) + +/** + * Set a custom function that runs every audio thread update, see `AudioCustomUpdateFunction` + * + * @param functionPtr (s32) address of the function to run once every audio frame + */ +#define AUDIOCMD_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION(functionPtr) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION, 0, 0, 0), functionPtr) + +/** + * Asynchronously load a sequence + * + * @param seqId the id of the sequence to load, see `SeqId` + * @param retData return data from `externalLoadQueue` + */ +#define AUDIOCMD_GLOBAL_ASYNC_LOAD_SEQ(seqId, retData) \ + AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SEQ, seqId, 0, retData), 0) + +/** + * No Operation. No code exists for this OP + * + * @param arg0 No info + * @param arg1 No info + * @param arg2 No info + * @param data (s32) No info + */ +#define AUDIOCMD_GLOBAL_NOOP_2(arg0, arg1, arg2, data) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_NOOP_2, arg0, arg1, arg2), data) + +/** + * Disable all sequence players + * + * @param flags (s32) Set `AUDIO_NOTE_RELEASE` to discard all sequences. + * + * @note Also set `AUDIO_NOTE_SAMPLE_NOTES` will also only discard sampled notes, but the sequences are disabled anyway. + * Not setting `AUDIO_NOTE_RELEASE` should make this command useless + */ +#define AUDIOCMD_GLOBAL_DISABLE_ALL_SEQPLAYERS(flags) \ + AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_DISABLE_ALL_SEQPLAYERS, 0, 0, 0), flags) + +#endif diff --git a/include/color.h b/include/color.h index 438d857ad..d0cdb62f5 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 { @@ -45,4 +51,6 @@ typedef union { u16 rgba; } Color_RGBA16; +#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0)) + #endif diff --git a/include/functions.h b/include/functions.h index b4ff2ad8d..5e74e635f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1,29 +1,29 @@ -#ifndef _FUNCTIONS_H_ -#define _FUNCTIONS_H_ +#ifndef FUNCTIONS_H +#define FUNCTIONS_H #include "z64.h" void bootproc(void); void Idle_ThreadEntry(void* arg); -void ViConfig_UpdateVi(u32 arg0); +void ViConfig_UpdateVi(u32 mode); void ViConfig_UpdateBlack(void); -s32 DmaMgr_DmaRomToRam(u32 src, void* dst, size_t size); -s32 DmaMgr_DmaHandler(OSPiHandle* piHandle, OSIoMesg* mb, s32 direction); -DmaEntry* DmaMgr_FindDmaEntry(u32 vromAddr); -u32 DmaMgr_TranslateVromToRom(u32 vromAddr); -s32 DmaMgr_FindDmaIndex(u32 vromAddr); -const char* func_800809F4(u32 param_1); +s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size); +s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); +DmaEntry* DmaMgr_FindDmaEntry(uintptr_t vrom); +u32 DmaMgr_TranslateVromToRom(uintptr_t vrom); +s32 DmaMgr_FindDmaIndex(uintptr_t vrom); +const char* func_800809F4(uintptr_t param_1); void DmaMgr_ProcessMsg(DmaRequest* req); void DmaMgr_ThreadEntry(void* arg); -s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* callback, void* callbackMesg); +s32 DmaMgr_SendRequestImpl(DmaRequest* request, void* vramStart, uintptr_t vromStart, size_t size, UNK_TYPE4 unused, OSMesgQueue* queue, void* msg); s32 DmaMgr_SendRequest0(void* vramStart, uintptr_t vromStart, size_t size); void DmaMgr_Start(void); void DmaMgr_Stop(void); void* Yaz0_FirstDMA(void); void* Yaz0_NextDMA(void* curSrcPos); -s32 Yaz0_DecompressImpl(u8* hdr, u8* dst); -void Yaz0_Decompress(u32 romStart, void* dst, size_t size); -void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* add, OSMesgQueue* msgQ); +s32 Yaz0_DecompressImpl(u8* src, u8* dst); +void Yaz0_Decompress(uintptr_t romStart, void* dst, size_t size); +void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* client, OSMesgQueue* msgQueue); void IrqMgr_RemoveClient(IrqMgr* irqmgr, IrqMgrClient* remove); void IrqMgr_SendMesgForClient(IrqMgr* irqmgr, OSMesg msg); void IrqMgr_JamMesgForClient(IrqMgr* irqmgr, OSMesg msg); @@ -85,7 +85,7 @@ void Fault_HangupFaultClient(const char* arg0, char* arg1); void Fault_AddHungupAndCrashImpl(const char* arg0, char* arg1); void Fault_AddHungupAndCrash(const char* filename, u32 line); void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled); -void FaultDrawer_DrawRecImpl(s32 xstart, s32 ystart, s32 xend, s32 yend, u16 color); +void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 color); void FaultDrawer_DrawChar(char c); s32 FaultDrawer_ColorToPrintColor(u16 color); void FaultDrawer_UpdatePrintColor(void); @@ -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(Mtx* m1, MtxF* m2); -void MtxConv_L2F(MtxF* m1, Mtx* m2); + +void MtxConv_F2L(Mtx* mtx, MtxF* mf); +void MtxConv_L2F(MtxF* mtx, Mtx* mf); + void __assert(const char* file, u32 lineNum); // void func_800862B4(void); void* SystemArena_MallocMin1(u32 size); @@ -169,7 +150,7 @@ f32 func_80086814(f32 x); // void func_80086AF0(void); f32 func_80086B30(f32 y, f32 x); // void func_80086C18(void); -f32 func_80086C48(f32 param_1); +f32 func_80086C48(f32 x); // void func_80086C70(void); f64 func_80086C7C(f64 param_1); s32 func_80086C88(f32 param_1); @@ -183,7 +164,7 @@ f64 func_80086CEC(f64 param_1); s32 func_80086CF8(f32 param_1); s32 func_80086D08(f64 param_1); // void func_80086D18(void); -// void func_80086D24(void); +f64 func_80086D24(f64); s32 func_80086D30(f32 param_1); s32 func_80086D40(f64 param_1); // void func_80086D50(void); @@ -191,18 +172,18 @@ 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); void Rand_Seed_Variable(u32* rndNum, u32 seed); -u32 Rand_Next_Variable(u32* param_1); -f32 Rand_ZeroOne_Variable(u32* param_1); -f32 Rand_Centered_Variable(u32* param_1); +u32 Rand_Next_Variable(u32* rndNum); +f32 Rand_ZeroOne_Variable(u32* rndNum); +f32 Rand_Centered_Variable(u32* rndNum); -void* proutSprintf(void* s, const char* buf, size_t n); +void* proutSprintf(void* dst, const char* fmt, size_t size); s32 vsprintf(char* dst, char* fmt, va_list args); -s32 sprintf(char* s, char* fmt, ...); +s32 sprintf(char* dst, char* fmt, ...); s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args); s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...); void Sleep_Cycles(OSTime time); @@ -213,13 +194,13 @@ void Sleep_Sec(u32 sec); // void __osSetCause(void); s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags); s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes); -void osViExtendVStart(u32 param_1); +void osViExtendVStart(u32 a0); void osStopThread(OSThread* t); s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags); OSIntMask osSetIntMask(OSIntMask im); // OSIntMask osGetIntMask(void); // void osVoiceSetWord(void); -// void guScale(void); +void guScale(Mtx* mtx, f32 x, f32 y, f32 z); f32 sinf(f32 __x); s16 sins(u16 x); OSTask* _VirtualToPhysicalTask(OSTask* intp); @@ -245,8 +226,8 @@ OSThread* __osPopThread(OSThread** param_1); // void __osNop(void); void __osDispatchThread(void); void __osCleanupThread(void); -void __osDequeueThread(OSThread** param_1, OSThread* param_2); -void osDestroyThread(OSThread* puParm1); +void __osDequeueThread(OSThread** queue, OSThread* t); +void osDestroyThread(OSThread* t); // void __osVoiceCheckResult(void); void bzero(void* begin, s32 length); @@ -255,13 +236,13 @@ void __osSiGetAccess(void); void __osSiRelAccess(void); s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data); void __osContGetInitData(u8* pattern, OSContStatus* data); -void __osPackRequestData(u8 cmd); +void __osPackRequestData(u8 poll); void osCreateThread(OSThread* t, OSId id, void* entry, void* arg, void* sp, OSPri p); s32 osContStartReadData(OSMesgQueue* mq); void osContGetReadData(OSContPad* data); void __osPackReadData(void); // void osVoiceGetReadData(void); -uintptr_t osVirtualToPhysical(void* vaddr); +uintptr_t osVirtualToPhysical(void* virtualAddress); u32 __osGetSR(void); void __osSetSR(u32 value); void osWritebackDCache(void* vaddr, s32 nbytes); @@ -275,7 +256,7 @@ s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size) s32 __osSiRawStartDma(s32 direction, void* dramAddr); s32 osEPiLinkHandle(OSPiHandle* handle); void osViBlack(u8 active); -s32 __osSiRawReadIo(u32 devAddr, u32* data); +s32 __osSiRawReadIo(uintptr_t devAddr, u32* data); OSId osGetThreadId(OSThread* t); void osSpTaskYield(void); s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page); @@ -299,7 +280,7 @@ void __osPiGetAccess(void); void __osPiRelAccess(void); void __osDevMgrMain(void* arg); // void func_8008C640(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7, UNK_TYPE1 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE4 param_13, UNK_TYPE4 param_14, UNK_TYPE4 param_15, UNK_TYPE4 param_16, UNK_TYPE4 param_17, UNK_TYPE4 param_18); -s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, size_t size); +s32 __osPiRawStartDma(s32 direction, uintptr_t devAddr, void* dramAddr, size_t size); u16 __osSumcalc(u8* ptr, s32 length); s32 __osIdCheckSum(u16* ptr, u16* checkSum, u16* idSum); s32 __osRepairPackId(OSPfs* pfs, __OSPackId* badid, __OSPackId* newid); @@ -311,12 +292,12 @@ void guMtxL2F(MtxF* m1, Mtx* m2); u32 osGetMemSize(void); s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo); void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m); -f32 sqrtf(f32 __x); +f32 sqrtf(f32 f); s32 osAfterPreNMI(void); s32 osContStartQuery(OSMesgQueue* mq); void osContGetQuery(OSContStatus* data); -void guLookAtHiliteF(float 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, f32 xl2, f32 yl2, f32 zl2, s32 twidth, s32 theight); -void guLookAtHilite(Mtx* m, 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, f32 xl2, f32 yl2, f32 zl2, s32 twidth, s32 theight); +void guLookAtHiliteF(float 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, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight); +void guLookAtHilite(Mtx* m, 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, f32 xl2, f32 yl2, f32 zl2, s32 hiliteWidth, s32 hiliteHeight); s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap); void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac); // void osVoiceClearDictionary(void); @@ -324,9 +305,9 @@ void osUnmapTLBAll(void); s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); // void __osVoiceContRead2(void); u8 __osVoiceContDataCrc(u8* data, size_t numBytes); -const char* strchr(const char* __s, s32 __c); -size_t strlen(const char* __s); -void* memcpy(void* __dest, const void* __src, size_t __n); +const char* strchr(const char* s, s32 c); +size_t strlen(const char* s); +void* memcpy(void* s1, const void* s2, size_t n); void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msq, s32 count); void osInvalICache(void* vaddr, size_t nbytes); void osInvalDCache(void* vaddr, size_t nbytes); @@ -339,24 +320,24 @@ s32 __osSpDeviceBusy(void); s32 __osSiDeviceBusy(void); // void guMtxIdent(void); s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag); -void osSetThreadPri(OSThread* t, OSPri pri); +void osSetThreadPri(OSThread* t, OSPri p); OSPri osGetThreadPri(OSThread* t); -s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data); +s32 __osEPiRawReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data); void osViSwapBuffer(void* frameBufPtr); -void guPositionF(float mf[4][4], f32 r, f32 p, f32 h, f32 s, f32 x, f32 y, f32 z); -void guPosition(Mtx* m, f32 r, f32 p, f32 h, f32 s, f32 x, f32 y, f32 z); -s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size); +void guPositionF(float mf[4][4], f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z); +void guPosition(Mtx* m, f32 rot, f32 pitch, f32 yaw, f32 scale, f32 x, f32 y, f32 z); +s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, void* dramAddr, size_t size); OSYieldResult osSpTaskYielded(OSTask* task); s32 bcmp(void* __s1, void* __s2, size_t __n); OSTime osGetTime(void); -void guRotateF(float mf[4][4], f32 a, f32 x, f32 y, f32 z); +void guRotateF(float m[4][4], f32 a, f32 x, f32 y, f32 z); void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); // void osVoiceInit(void); s32 __osContChannelReset(OSMesgQueue* mq, s32 channel); // void __osVoiceSetADConverter(void); s32 osAiSetFrequency(u32 frequency); -s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); +s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* buffer); // void __osVoiceContWrite20(void); u8 __osContAddressCrc(u16 addr); u8 __osContDataCrc(u8* data); @@ -370,7 +351,7 @@ void bcopy(void* __src, void* __dest, size_t __n); void __osResetGlobalIntMask(u32 mask); // void osPfsDeleteFile(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void __osPfsReleasePages(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -void guOrthoF(float mf[4][4], f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale); +void guOrthoF(float m[4][4], f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale); void guOrtho(Mtx* m, f32 l, f32 r, f32 b, f32 t, f32 n, f32 f, f32 scale); OSIntMask __osDisableInt(void); void __osRestoreInt(OSIntMask im); @@ -378,13 +359,13 @@ void __osViInit(void); void __osViSwapContext(void); OSMesgQueue* osPiGetCmdQueue(void); f32 cosf(f32 __x); -s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data); +s32 osEPiReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); void osSetTime(OSTime ticks); // void osVoiceStopReadData(void); void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount); -s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern); +s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern); // void __osPfsRequestData(void); // void __osPfsGetInitData(void); s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status); @@ -399,23 +380,23 @@ u32 __osGetFpcCsr(void); // void __osPfsCheckRamArea(void); // void osPfsChecker(void); u32 osAiGetLength(void); -s32 osEPiWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data); +s32 osEPiWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data); void osMapTLBRdb(void); void osYieldThread(void); -// void guTranslate(void); +void guTranslate(Mtx* mtx, f32 x, f32 y, f32 z); u32 __osGetCause(void); s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force); -s32 __osEPiRawWriteIo(OSPiHandle* handle, u32 devAddr, u32 data); +s32 __osEPiRawWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data); s32 osSetTimer(OSTimer* t, OSTime value, OSTime interval, OSMesgQueue* mq, OSMesg msg); -void _Ldtob(_Pft* px, u8 code); +void _Ldtob(_Pft* args, u8 type); // void _Ldunscale(void); void _Genld(_Pft* px, u8 code, u8* p, s16 nsig, s16 xexp); ldiv_t ldiv(long numer, long denom); lldiv_t lldiv(long long numer, long long denom); -void _Litob(_Pft* px, u8 code); -s32 __osSiRawWriteIo(u32 devAddr, u32 data); +void _Litob(_Pft* args, u8 type); +s32 __osSiRawWriteIo(uintptr_t devAddr, u32 data); u32 __osSpGetStatus(void); -void __osSpSetStatus(u32 value); +void __osSpSetStatus(u32 data); void osCreateViManager(OSPri pri); // void viMgrMain(OSDevMgr* iParm1); __OSViContext* __osViGetCurrentContext(void); @@ -423,17 +404,17 @@ void osWritebackDCacheAll(void); OSThread* __osGetCurrFaultedThread(void); // void osVoiceMaskDictionary(void); void guMtxF2L(float mf[4][4], Mtx* m); -void osStartThread(OSThread* param_1); +void osStartThread(OSThread* t); void osViSetYScale(f32 value); void osViSetXScale(f32 value); long long __d_to_ll(double d); long long __f_to_ll(float f); unsigned long long __d_to_ull(double d); unsigned long long __f_to_ull(float f); -double __ll_to_d(long long l); -float __ll_to_f(long long l); -double __ull_to_d(unsigned long long l); -float __ull_to_f(unsigned long long l); +double __ll_to_d(long long s); +float __ll_to_f(long long s); +double __ull_to_d(unsigned long long u); +float __ull_to_f(unsigned long long u); // void osVoiceCheckWord(void); // void osVoiceControlGain(void); // void osVoiceStartReadData(void); @@ -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,165 @@ 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_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f32 arg3, s16 angle, CollisionPoly* colPoly, s32 arg6); +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 bgId); 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_Delete(EffectSs* effectSs); 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); -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_Copy(PlayState* play, EffectSs* effectsSs); +void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initData); +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 arg0, s16 arg1, s32 arg2); +s16 func_800B09D0(s16 arg0, s16 arg1, f32 arg2); +u8 func_800B0A24(u8 arg0, u8 arg1, f32 arg2); +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 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, - s16 scaleStep, s16 life); +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* pos, Vec3f* velocity, Vec3f* accel); // 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 alphaStep, s16 fadeDelay, s32 life); +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 EffectSsStick_Spawn(PlayState* play, Vec3f* pos, s16 yaw); // 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* pos, s32 reg0); -// 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 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 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(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scaleMax, u8 type); +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16* playerDetected, s16 flags); +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 EffectSsIcePiece_SpawnBurst(PlayState* play, Vec3f* refPos, f32 scale); +void func_800B2B44(PlayState* play, Actor* actor, Vec3f* pos, f32 scale); // 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 EffectSsFireTail_SpawnFlameOnPlayer(PlayState* play, f32 scale, s16 bodyPart, f32 colorIntensity); +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 life); +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 Overlay_LoadGameState(GameStateOverlay* overlayEntry); +void Overlay_FreeGameState(GameStateOverlay* overlayEntry); 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); -void Actor_MarkForDeath(Actor* actor); +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_Kill(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,68 +647,68 @@ 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 magnitude, s16 baseYaw); 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); +s32 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); 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_GetSlopeDirection(CollisionPoly* floorPoly, Vec3f* slopeNormal, s16* downwardSlopeYaw); +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, PlayerItemAction exchangeItemId); +s32 func_800B85E0(Actor* actor, PlayState* play, f32 radius, PlayerItemAction 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); +PlayerItemAction 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, GetItemId getItemId, f32 xzRange, f32 yRange); +s32 Actor_PickUpNearby(Actor* actor, PlayState* play, GetItemId getItemId); +s32 Actor_LiftActor(Actor* actor, PlayState* play); +s32 Actor_PickUpFar(Actor* actor, PlayState* play, GetItemId 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 +716,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 bgId, Vec3f* arg4); +void Actor_DeactivateLens(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 Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown); +void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, 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 +772,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); @@ -804,15 +782,15 @@ void ActorOverlayTable_Init(void); void ActorOverlayTable_Cleanup(void); void SSNode_SetValue(SSNode* node, s16* polyIndex, u16 next); -void SSList_SetNull(SSList* head); +void SSList_SetNull(SSList* ssList); 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); -void BgCheck_Vec3fToVec3s(Vec3s* vertex, Vec3f* vector); +void BgCheck_Vec3sToVec3f(Vec3s* src, Vec3f* dest); +void BgCheck_Vec3fToVec3s(Vec3s* dest, Vec3f* src); f32 func_800BFD84(CollisionPoly *poly, f32 arg1, f32 arg2); s32 func_800BFDEC(CollisionPoly* polyA, CollisionPoly* polyB, u32* outVtxId0, u32* outVtxId1); s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vertices); @@ -827,25 +805,25 @@ 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 checkDist, 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_EntityRaycastFloor6(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos, f32 chkDist); +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 checkDist); f32 BgCheck_EntityRaycastFloor7(CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos); f32 BgCheck_AnyRaycastFloor1(CollisionContext* colCtx, CollisionPoly* outPoly, Vec3f* pos); f32 BgCheck_AnyRaycastFloor2(CollisionContext* colCtx, CollisionPoly* outPoly, s32* bgId, Vec3f* pos); @@ -860,20 +838,20 @@ s32 BgCheck_EntitySphVsWall4(CollisionContext* colCtx, Vec3f* posResult, Vec3f* s32 BgCheck_CheckCeilingImpl(CollisionContext* colCtx, u16 xpFlags, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, s32* outBgId, Actor* actor); s32 BgCheck_AnyCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight); s32 BgCheck_EntityCheckCeiling(CollisionContext* colCtx, f32* outY, Vec3f* pos, f32 checkHeight, CollisionPoly** outPoly, s32* outBgId, Actor* actor); -s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, Actor* actor); -s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId, Actor* actor, f32 chkDist); -s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); -s32 BgCheck_AnyLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkOneFace); -s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace); -s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 chkWall, s32 chkFloor, s32 chkCeil, s32 chkOneFace, s32* bgId); +s32 BgCheck_CameraLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_CameraLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_EntityLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_EntityLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId, Actor* actor); +s32 BgCheck_EntityLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId, Actor* actor, f32 checkDist); +s32 BgCheck_ProjectileLineTest(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); +s32 BgCheck_AnyLineTest1(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkOneFace); +s32 BgCheck_AnyLineTest2(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace); +s32 BgCheck_AnyLineTest3(CollisionContext* colCtx, Vec3f* posA, Vec3f* posB, Vec3f* posResult, CollisionPoly** outPoly, s32 checkWall, s32 checkFloor, s32 checkCeil, s32 checkOneFace, s32* bgId); s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* center, f32 radius, Actor* actor, u16 bciFlags); 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 +861,47 @@ 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 func_800C6554(PlayState* play, DynaCollisionContext* dyna); +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 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 DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyna); +void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader); +void CollisionHeader_GetVirtual(CollisionHeader* colHeader, CollisionHeader** dest); +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); @@ -940,34 +923,34 @@ u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 SurfaceType_GetConveyorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); 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 surfaceCheckDist, 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 BgCheck2_UpdateActorPosition(CollisionContext* colCtx, s32 bgId, Actor* actor); +void BgCheck2_UpdateActorYRotation(CollisionContext* colCtx, s32 bgId, Actor* actor); +void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 bgId); +u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 bgId, 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); -void DynaPolyActor_SetRidingMovingStateByIndex(CollisionContext* colCtx, s32 index); +void DynaPolyActor_SetRidingMovingStateByIndex(CollisionContext* colCtx, s32 bgId); void DynaPolyActor_SetRidingRotatingState(DynaPolyActor* dynaActor); -void DynaPolyActor_SetRidingRotatingStateByIndex(CollisionContext* colCtx, s32 index); +void DynaPolyActor_SetRidingRotatingStateByIndex(CollisionContext* colCtx, s32 bgId); void DynaPolyActor_SetSwitchPressedState(DynaPolyActor* dynaActor); void DynaPolyActor_SetHeavySwitchPressedState(DynaPolyActor* dynaActor); s32 DynaPolyActor_IsInRidingFallingState(DynaPolyActor* dynaActor); @@ -975,155 +958,14 @@ 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); -// void func_800CBC84(void); -// void func_800CBFA4(void); -// void func_800CC000(void); -// void func_800CC128(void); -// void func_800CC1C4(void); -// void func_800CC260(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6); -// void func_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 func_800CC938(void); -// void func_800CC958(void); -// void func_800CC9C0(void); -// void func_800CCCEC(void); -// void func_800CD04C(void); -// void func_800CD288(void); -// void func_800CD2E0(void); -// void func_800CD2F0(void); -// void func_800CD3E4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800CD44C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_800CD634(void); -// void func_800CD6CC(void); -// void func_800CD6F8(void); -// void func_800CD834(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800CDA14(void); -// void func_800CDB6C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6); -// void func_800CDE6C(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); -// void func_800CE2B8(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_TYPE2 param_9); -// void func_800CE5E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_800CE79C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_800CE930(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_800CEAD8(void); -// void func_800CEC38(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_800CED90(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -s32 Camera_ModeNop(Camera* camera); -s32 Camera_ModeNORM1(Camera* camera); -s32 Camera_ModeNORM2(Camera* camera); -s32 Camera_ModeNORM3(Camera* camera); -s32 Camera_ModeNORM4(Camera* camera); -s32 Camera_ModeNORM0(Camera* camera); -s32 Camera_ModePARA1(Camera* camera); -s32 Camera_ModePARA2(Camera* camera); -s32 Camera_ModePARA3(Camera* camera); -s32 Camera_ModePARA4(Camera* camera); -s32 Camera_ModePARA0(Camera* camera); -s32 Camera_ModeJUMP1(Camera* camera); -s32 Camera_ModeJUMP2(Camera* camera); -s32 Camera_ModeJUMP3(Camera* camera); -s32 Camera_ModeJUMP4(Camera* camera); -s32 Camera_ModeJUMP0(Camera* camera); -s32 Camera_ModeBATT1(Camera* camera); -s32 Camera_ModeBATT2(Camera* camera); -s32 Camera_ModeBATT3(Camera* camera); -s32 Camera_ModeBATT4(Camera* camera); -s32 Camera_ModeBATT0(Camera* camera); -s32 Camera_ModeKEEP1(Camera* camera); -s32 Camera_ModeKEEP2(Camera* camera); -s32 Camera_ModeKEEP3(Camera* camera); -s32 Camera_ModeKEEP4(Camera* camera); -// void func_800D7C44(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7, UNK_TYPE1 param_8, UNK_TYPE1 param_9, UNK_TYPE1 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12); -s32 Camera_ModeKEEP0(Camera* camera); -s32 Camera_ModeFIXD1(Camera* camera); -s32 Camera_ModeFIXD2(Camera* camera); -s32 Camera_ModeFIXD3(Camera* camera); -s32 Camera_ModeFIXD4(Camera* camera); -s32 Camera_ModeFIXD0(Camera* camera); -s32 Camera_ModeSUBJ1(Camera* camera); -s32 Camera_ModeSUBJ2(Camera* camera); -s32 Camera_ModeSUBJ3(Camera* camera); -s32 Camera_ModeSUBJ4(Camera* camera); -s32 Camera_ModeSUBJ0(Camera* camera); -s32 Camera_ModeDATA0(Camera* camera); -s32 Camera_ModeDATA1(Camera* camera); -s32 Camera_ModeDATA2(Camera* camera); -s32 Camera_ModeDATA3(Camera* camera); -s32 Camera_ModeDATA4(Camera* camera); -s32 Camera_ModeUNIQ1(Camera* camera); -s32 Camera_ModeUNIQ2(Camera* camera); -s32 Camera_ModeUNIQ3(Camera* camera); -s32 Camera_ModeUNIQ4(Camera* camera); -s32 Camera_ModeUNIQ5(Camera* camera); -s32 Camera_ModeUNIQ0(Camera* camera); -s32 Camera_ModeUNIQ6(Camera* camera); -s32 Camera_ModeUNIQ7(Camera* camera); -s32 Camera_ModeUNIQ8(Camera* camera); -s32 Camera_ModeUNIQ9(Camera* camera); -s32 Camera_ModeDEMO1(Camera* camera); -s32 Camera_ModeDEMO2(Camera* camera); -s32 Camera_ModeDEMO3(Camera* camera); -s32 Camera_ModeDEMO4(Camera* camera); -s32 Camera_ModeDEMO5(Camera* camera); -s32 Camera_ModeDEMO6(Camera* camera); -s32 Camera_ModeDEMO7(Camera* camera); -s32 Camera_ModeDEMO8(Camera* camera); -s32 Camera_ModeDEMO9(Camera* camera); -s32 Camera_ModeDEMO0(Camera* camera); -s32 Camera_ModeSPEC0(Camera* camera); -s32 Camera_ModeSPEC1(Camera* camera); -s32 Camera_ModeSPEC2(Camera* camera); -s32 Camera_ModeSPEC3(Camera* camera); -s32 Camera_ModeSPEC4(Camera* camera); -s32 Camera_ModeSPEC5(Camera* camera); -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); +s32 DynaPolyActor_ValidateMove(PlayState* play, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, s16 startHeight); + +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); @@ -1133,255 +975,256 @@ Vec3s* Camera_Update(Vec3s* param_1, Camera* camera); // void func_800DF498(void); u32 Camera_SetMode(Camera* camera, s16 mode, s8 param_3); s32 Camera_ChangeMode(Camera* camera, s16 mode); -// void func_800DF86C(void); +s32 func_800DF86C(Camera* camera, s16 arg1); // 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 bgCamIndex, 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); // UNK_TYPE4 func_800E0228(void); -// void func_800E0238(void); +void func_800E0238(Camera* camera); void Camera_SetToTrackActor(Camera* camera, Actor* actor); void Camera_SetTargetActor(Camera* camera, Actor* actor); f32 Camera_GetWaterYPos(Camera* camera); void func_800E0348(Camera* camera); + DamageTable* DamageTable_Get(s32 index); void DamageTable_Clear(DamageTable* damageTable); 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 focusHeight); +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 +1236,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_GetSceneLayer(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 QuestHint_GetTatlTextId(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,124 +1289,116 @@ 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); // void func_800FDC94(void); // void func_800FE390(void); // void func_800FE3E0(void); -void func_800FE484(void); -void func_800FE498(void); -// void func_800FE4A8(void); -u32 func_800FE4B8(GlobalContext* globalCtx); +void Environment_StopTime(void); +void Environment_StartTime(void); +u8 Environment_IsTimeStopped(void); +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,21 +1463,21 @@ 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); void* Lib_SegmentedToVirtual(void* ptr); void* Lib_SegmentedToVirtualNull(void* ptr); +void* Lib_VirtualToPhysical(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,29 +1489,29 @@ 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); -void ZeldaArena_Free(void* param_1); +void* ZeldaArena_Realloc(void* ptr, size_t newSize); +void ZeldaArena_Free(void* ptr); void* ZeldaArena_Calloc(u32 num, size_t size); -void ZeldaArena_GetSizes(size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); +void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc); s32 ZeldaArena_Check(); void ZeldaArena_Init(void* start, size_t size); void ZeldaArena_Cleanup(); @@ -1708,7 +1521,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,29 +1534,29 @@ 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(PlayState* play); +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); -// void func_801068FC(void); +void* func_801068FC(PlayState* play, void* arg1, size_t size); // void func_80106BEC(void); // void func_80106D08(void); // void func_80106D5C(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); @@ -1752,11 +1565,11 @@ void func_80105818(GlobalContext* globalCtx, u32 uParm2, TransitionActorEntry* p // void func_80108558(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_80108A10(void); // void func_80108A64(void); -// void func_80108AF8(void); -// void func_801090B0(void); -// void func_80109124(void); +void func_80108AF8(PlayState* play); +s32 func_801090B0(s32 arg0); +s32 func_80109124(s16 arg0); // void func_801091F0(void); -// void func_80109428(void); +void func_80109428(PlayState* play); // void func_801094A0(void); // void func_801094C8(void); // void func_801094F8(void); @@ -1796,21 +1609,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(PlayState* play); +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 +1675,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, void* param_3, UNK_PTR param_4, s32* param_5); void Nmi_Init(void); void Nmi_SetPrenmiStart(void); // s32 Nmi_GetPrenmiHasStarted(void); @@ -1885,232 +1698,135 @@ Vec3f* OLib_Vec3fDiffDegF(Vec3f* dest, Vec3f* a, Vec3f* b); Vec3s* OLib_Vec3fDiffBinAng(Vec3s* dest, Vec3f* a, Vec3f* b); void OLib_DbCameraVec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); void OLib_DbCameraVec3fSum(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); -// void func_8010CB80(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -// void func_8010CD98(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -// void func_8010CFBC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14); -// void func_8010D2D4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11); -// void func_8010D480(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10, UNK_TYPE2 param_11, UNK_TYPE2 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14, UNK_TYPE4 param_15, UNK_TYPE4 param_16); -// void func_8010D7D0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE2 param_10); -// void func_8010D9F4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7, UNK_TYPE2 param_8, UNK_TYPE2 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE2 param_13, UNK_TYPE2 param_14); -// void func_8010DC58(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_8010DE38(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE2 param_6); -// void func_8010E028(void); -// void func_8010E968(void); -void func_8010E9F0(s16 arg0, s16 arg1); -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 Interface_ChangeAlpha(u16 param_1); -// void func_8010EF9C(void); -// void func_8010F0D4(void); -// void func_8010F1A8(void); -// 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_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); -// void func_801153C8(void); -// void func_80115428(void); -void func_8011552C(GlobalContext* globalCtx, 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_80115D5C(GameState* gamestate); -// void func_80115DB4(void); -// void func_80116088(void); -// void func_80116114(void); -// void func_80116348(void); -// void func_80116918(void); -// void func_80116FD8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_801170B8(void); -// void func_80117100(void); -// void func_80117A20(void); -// void func_80117BD0(void); -// void func_80118084(void); -// void func_80118890(void); -// void func_80118BA4(void); -// void func_80119030(void); -// void func_80119610(void); -void func_8011B4E0(GlobalContext* globalCtx, 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_8011C898(void); -// void func_8011CA64(void); -// void func_8011E3B4(void); -// void func_8011E730(void); -// void func_8011F0E0(UNK_TYPE4 ctxt); -// void func_80120F90(void); -// void func_80121000(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_TYPE1 param_8, UNK_TYPE1 param_9, UNK_TYPE1 param_10, UNK_TYPE4 param_11, UNK_TYPE4 param_12, UNK_TYPE4 param_13, UNK_TYPE4 param_14); -// 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); + +Gfx* Gfx_DrawTexRectRGBA16(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); +Gfx* Gfx_DrawTexRectIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); +Gfx* Gfx_DrawTexRectI8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy); +Gfx* Gfx_DrawTexQuadIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, u16 point); +Gfx* Gfx_DrawTexQuad4b(Gfx* gfx, TexturePtr texture, s32 fmt, s16 textureWidth, s16 textureHeight, u16 point); + +void Interface_StartTimer(s16 timerId, s16 seconds); +void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState); +void Interface_NewDay(PlayState* play, s32 day); +void Interface_SetHudVisibility(u16 hudVisibility); +void func_80110038(PlayState* play); +void Interface_SetSceneRestrictions(PlayState* play); +void Interface_InitMinigame(PlayState* play); +void Interface_LoadItemIconImpl(PlayState* play, u8 btn); +void Interface_LoadItemIcon(PlayState* play, u8 btn); +void func_80112C0C(PlayState* play, u16 flag); +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_8011552C(PlayState* play, u16 arg1); +void func_801155B4(PlayState* play, s16 arg1); +void func_80115764(PlayState* play, UNK_TYPE arg1); +void func_80115844(PlayState* play, s16 doAction); +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 Magic_Add(PlayState* play, s16 magicToAdd); +void Magic_Reset(PlayState* play); +s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type); +void Interface_SetPerfectLetters(PlayState* play, s16 perfectLettersType); +void Interface_StartMoonCrash(PlayState* play); +void Interface_Draw(PlayState* play); +void Interface_Update(PlayState* play); +void Interface_Destroy(PlayState* play); +void Interface_Init(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(Actor* thisx, PlayState* play); +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); +s32 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(Actor* thisx, PlayState* play2); +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); +ItemId func_8012364C(PlayState* play, Player* player, s32 arg2); +PlayerItemAction func_80123810(PlayState* play); +PlayerModelGroup Player_ActionToModelGroup(Player* player, PlayerItemAction itemAction); +void Player_SetModelsForHoldingShield(Player* player); +void Player_SetModels(Player* player, PlayerModelGroup modelGroup); +void Player_SetModelGroup(Player* player, PlayerModelGroup modelGroup); +void func_80123C58(Player* player); +void Player_SetEquipmentData(PlayState* play, Player* player); +void Player_UpdateBottleHeld(PlayState* play, Player* player, ItemId itemId, PlayerItemAction itemAction); 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, PlayerItemAction itemAction); +s32 func_80124148(Player* player); +s32 Player_ActionToMeleeWeapon(PlayerItemAction itemAction); +s32 Player_GetMeleeWeaponHeld(Player* player); +s32 Player_IsHoldingTwoHandedWeapon(Player* player); +s32 Player_ActionToBottle(Player* player, PlayerItemAction itemAction); +s32 Player_GetBottleHeld(Player* Player); +s32 Player_ActionToExplosive(Player* player, PlayerItemAction itemAction); s32 Player_GetExplosiveHeld(Player* player); -// void func_80124278(void); +s32 Player_ActionToSword(Actor* actor, PlayerItemAction itemAction); 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, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* arg3, Vec3f* arg4); -// 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); -void PreNMI_Stop(PreNMIContext* prenmiCtx); -void PreNMI_Update(PreNMIContext* prenmiCtx); -void PreNMI_Draw(PreNMIContext* prenmiCtx); -void PreNMI_Main(PreNMIContext* prenmiCtx); -void PreNMI_Destroy(PreNMIContext* prenmiCtx); -void PreNMI_Init(PreNMIContext* prenmiCtx); -f32 Quake_Random(void); -void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPertubation, f32 horizontalPertubation); -s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake); -s16 Quake_GetFreeIndex(void); -QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx); -void Quake_Remove(QuakeRequest* req); -QuakeRequest* Quake_GetRequest(s16 idx); -u32 Quake_SetValue(s16 idx, s16 valueType, s16 value); -u32 Quake_SetSpeed(s16 idx, s16 value); -u32 Quake_SetCountdown(s16 idx, s16 value); -s16 Quake_GetCountdown(s16 idx); -u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset); -u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset); -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_SetCountdown(s16 countdown); -s16 Distortion_GetCountdown(void); -s16 Distortion_GetType(void); -void Distortion_SetType(s32 type); -void Distortion_ClearType(s32 type); -s32 Distortion_GetUnderwaterCurrentSpeed(Player* player); -void Distortion_Update(void); -s32 Quake_NumActiveQuakes(void); +s32 Player_GetEnvironmentalHazard(PlayState* play); +void func_80124420(Player* player); +void func_80124618(struct_80124618 arg0[], f32 curFrame, Vec3f* arg2); +void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, PlayerTransformation playerForm, 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 currentMask); +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); + Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); @@ -2133,7 +1849,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,180 +1907,180 @@ 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); +s32 Inventory_IsMapVisible(s16 sceneId); +void Inventory_SetWorldMapCloudVisibility(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); -s32 Object_GetIndex(ObjectContext* objectCtx, s16 id); +s32 Object_GetIndex(ObjectContext* objectCtx, s16 objectId); 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); -void 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_HeaderCmdSetRegionVisitedFlag(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* primColorResult, 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); -s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result); -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); -void SkelAnime_GetFrameData(AnimationHeader* animation, s32 currentFrame, s32 limbCount, Vec3s* dst); +s32 Entrance_GetSceneId(u16 entrance); +s32 Entrance_GetSceneIdAbsolute(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 frame, s32 limbCount, Vec3s* frameTable); 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* copyFlag); +void AnimationContext_SetCopyFalse(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); +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, void* jointTableBuffer, void* morphTableBuffer, 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 weight); +void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, void* blendTableBuffer); +void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, void* blendTableBuffer); 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_InitSkin(GameState* gameState, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animationSeg); +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* animation); void SkelAnime_SetUpdate(SkelAnime* skelAnime); s32 SkelAnime_Update(SkelAnime* skelAnime); s32 SkelAnime_Morph(SkelAnime* skelAnime); @@ -2385,15 +2101,15 @@ void Animation_EndLoop(SkelAnime* skelAnime); void Animation_Reverse(SkelAnime* skelAnime); void SkelAnime_CopyFrameTableTrue(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); void SkelAnime_CopyFrameTableFalse(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* copyFlag); -void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle); +void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, 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); void SkinMatrix_MtxFMtxFMult(MtxF* mfB, MtxF* mfA, MtxF* dest); -void SkinMatrix_GetClear(MtxF** puParm1); -void SkinMatrix_GetClear(MtxF** mf); +void SkinMatrix_GetClear(MtxF** mfp); +void SkinMatrix_GetClear(MtxF** mfp); void SkinMatrix_MtxFCopy(MtxF* src, MtxF* dest); s32 SkinMatrix_Invert(MtxF* src, MtxF* dest); void SkinMatrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z); @@ -2414,105 +2130,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 SubS_InCsMode(GlobalContext* globalCtx); -s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); -void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); -void 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 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, GameState* gameState, u8* tex); -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); -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 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(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); -s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); -s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); -s32 SubS_TurnToPointStep(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); -// 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); -void func_8013F050(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); -void View_SetScale(View* view, f32 scale); -void View_GetScale(View* view, f32* scale); -void func_8013F0D0(View* view, f32 fovy, f32 zNear, f32 zFar); -void func_8013F100(View* view, f32* fovy, f32* zNear, f32* zFar); -void func_8013F120(View* view, f32 fovy, f32 zNear, f32 zFar); -void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar); -void View_SetViewport(View* view, Viewport* viewport); -void View_GetViewport(View* view, Viewport* viewport); -void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry); -void View_SyncAndWriteScissor(View* view, Gfx** gfx); -void View_SetScissorForLetterbox(View* view); -s32 View_SetDistortionDirRot(View* view, f32 dirRotX, f32 dirRotY, f32 dirRotZ); -s32 View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ); -s32 View_SetDistortionSpeed(View* view, f32 speed); -s32 View_InitDistortion(View* view); -s32 View_ClearDistortion(View* view); -s32 View_SetDistortion(View* view, Vec3f dirRot, Vec3f scale, f32 speed); -s32 View_StepDistortion(View* view, Mtx* projectionMtx); -void View_RenderView(View* view, s32 uParm2); -s32 View_RenderToPerspectiveMatrix(View* view); -s32 View_RenderToOrthographicMatrix(View* view); -s32 func_8013FBC8(View* view); -s32 func_8013FD74(View* view); -s32 func_80140024(View* view); -s32 func_801400CC(View* view, Gfx** gfxp); void func_80140260(OSViMode* vimode); // void func_8014026C(OSViMode* param_1, UNK_TYPE1 param_2, s32 param_3, s32 param_4, s32 param_5, s32 param_6, s32 param_7, s32 param_8, UNK_TYPE4 param_9, s32 param_10, s16 param_11, u32 param_12, UNK_TYPE4 param_13); // void func_80140730(void); @@ -2528,40 +2145,41 @@ void func_80140E80(void* param_1); // void func_80140EA0(void); // void func_80140EAC(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_80141008(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -// void func_8014116C(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_8014116C(Gfx** gfxP, u16* arg1, u16* arg2, s32 width, s32 height, s32 arg5); // void func_801411B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); // void func_80141200(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_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); + +s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* roomVtx, 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 Skybox_Setup(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId); +void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId); +void Skybox_Init(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId); 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 arg1); // void func_80148CBC(void); // void func_80148D64(void); // void func_80149048(void); @@ -2569,29 +2187,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 decodedBufPos); // 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_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 func_80150A84(PlayState* play); +void func_80150D08(PlayState* play, u32 uParm2); +void func_801514B0(PlayState* play, u16 arg1, u8 arg2); +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 arg1); // 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); @@ -2602,38 +2220,26 @@ 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); // void Message_LoadRupeesNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); // void Message_LoadTimeNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void Message_LoadAreaTextNES(void); +// void Message_LoadOwlWarpTextNES(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); -s32 ShrinkWindow_GetLetterboxTarget(void); -void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude); -s32 ShrinkWindow_GetLetterboxMagnitude(void); -void ShrinkWindow_SetPillarboxTarget(s32 target); -s32 ShrinkWindow_GetPillarboxTarget(void); -void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude); -s32 ShrinkWindow_GetPillarboxMagnitude(void); -void ShrinkWindow_Init(void); -void ShrinkWindow_Destroy(void); -void ShrinkWindow_Update(s32 framerateDivisor); -void ShrinkWindow_Draw(GraphicsContext* gfxCtx); // void func_80161180(void); s32 func_8016119C(Camera* camera, DbCameraUnkStruct* arg1); // void func_8016122C(void); @@ -2658,16 +2264,16 @@ 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 func_80163C90(void); -// void func_80163D80(void); +void KaleidoScopeCall_Init(PlayState* play); +void KaleidoScopeCall_Destroy(PlayState* play); +void KaleidoScopeCall_Update(PlayState* play); +void KaleidoScopeCall_Draw(PlayState* play); +void Transition_Init(TransitionContext* transitionCtx); +void Transition_Destroy(TransitionContext* transitionCtx); // void func_80163DC0(void); // void func_8016418C(void); // void func_8016424C(void); @@ -2685,19 +2291,22 @@ void* TransitionFade_Init(void* param_1); // void TransitionFade_IsDone(void); // void TransitionFade_SetColor(void); // void TransitionFade_SetType(void); -// void TransitionCircle_Start(void); -// void TransitionCircle_Init(void); -// void TransitionCircle_Destroy(void); -// void TransitionCircle_Update(void); -// void TransitionCircle_SetColor(void); -// void TransitionCircle_SetType(void); -void func_80164C14(Gfx** arg0, TexturePtr* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32 arg6); -// void TransitionCircle_Draw(void); -// void TransitionCircle_IsDone(void); -// void func_801651B0(void); -// void func_80165224(void); -// void func_80165288(void); -// void func_8016537C(void); +void TransitionOverlay_ClearLoadInfo(TransitionOverlay *overlayEntry); +void TransitionOverlay_SetSegment(TransitionOverlay *overlayEntry, void* vramStart, void* vramEnd, uintptr_t vromStart, uintptr_t vromEnd); +void TransitionCircle_Start(void* thisx); +void* TransitionCircle_Init(void* thisx); +void TransitionCircle_Destroy(void* thisx); +void TransitionCircle_Update(void* thisx); +void TransitionCircle_SetColor(void* thisx, u32 color); +void TransitionCircle_SetType(void* thisx, s32 type); +void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, s32 arg3, s32 masks, s32 maskt, + f32 arg6); +void TransitionCircle_Draw(void* thisx, Gfx** gfxp); +s32 TransitionCircle_IsDone(void* thisx); +void* TransitionOverlay_VramToRam(TransitionOverlay *overlayEntry, void* vramAddr); +void TransitionOverlay_VramToRamArray(TransitionOverlay *overlayEntry, void** vramAddrs, s32 count); +s32 TransitionOverlay_Load(TransitionOverlay *overlayEntry); +s32 TransitionOverlay_Free(TransitionOverlay *overlayEntry); void func_80165438(UNK_PTR param_1); // void func_80165444(s32 param_1, UNK_TYPE4 param_2, UNK_TYPE4 param_3, UNK_TYPE4 param_4, UNK_TYPE4 param_5); // void func_80165460(void); @@ -2707,62 +2316,62 @@ void func_80165658(u32 arg0); void func_8016566C(u32 arg0); void func_80165690(void); // void func_801656A4(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_80165DCC(void); -// void func_80165DF0(void); +void func_80165DCC(s32 arg0); +void func_80165DF0(void); // void func_80165E1C(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); -// void func_801663C4(void); -// void func_80166644(void); +Gfx* func_801660B8(PlayState* play, Gfx* gfx); +void Play_Destroy(GameState* thisx); +void Play_CompressI8ToI5(void* srcI8, void* destI5, size_t size); +void Play_DecompressI5ToI8(void* srcI5, void* destI8, size_t size); // 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 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); -s16 Play_GetOriginalSceneNumber(s16 sceneNum); -void Play_SaveCycleSceneFlags(GameState* gameState); -void Play_SetRespawnData(GameState* gameState, s32 respawnNumber, u16 sceneSetup, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw); -void Play_SetupRespawnPoint(GameState* gameState, s32 respawnNumber, s32 playerParams); -void func_80169EFC(GameState* gameState); -void func_80169F78(GameState* gameState); -void func_80169FDC(GameState* gameState); -s32 func_80169FFC(GameState* gameState); -s32 FrameAdvance_IsEnabled(GameState* gameState); -s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw); -s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos); -s32 func_8016A168(void); -void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 cutscene); -void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5); +void Play_Draw(PlayState* play); +void func_80168DAC(PlayState* play); +void Play_Main(PlayState* play); +s32 Play_InCsMode(PlayState* this); +f32 func_80169100(PlayState* play, MtxF* mtx, CollisionPoly** arg2, s32* arg3, Vec3f* feetPosPtr); +void func_801691F0(PlayState* play, MtxF* mtx, Vec3f* arg2); +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* this, Vec3f* worldPos, Vec3f* screenPos); +s16 Play_CreateSubCamera(PlayState* this); +s16 Play_GetActiveCamId(PlayState* this); +s32 Play_ChangeCameraStatus(PlayState* this, s16 camId, s16 status); +void Play_ClearCamera(PlayState* this, s16 camId); +Camera* Play_GetCamera(PlayState* this, s16 camId); +s32 Play_SetCameraAtEye(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye); +s32 Play_SetCameraAtEyeUp(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up); +s32 Play_SetCameraFov(PlayState* this, s16 camId, f32 fov); +s32 Play_SetCameraRoll(PlayState* this, s16 camId, s16 roll); +void Play_CopyCamera(PlayState* this, s16 destCamId, s16 srcCamId); +s32 func_80169A50(PlayState* this, s16 camId, Player* player, s16 setting); +s32 Play_ChangeCameraSetting(PlayState* this, s16 camId, s16 setting); +void func_80169AFC(PlayState* this, s16 camId, s16 timer); +u16 Play_GetActorCsCamSetting(PlayState* this, s32 csCamDataIndex); +Vec3s* Play_GetActorCsCamFuncData(PlayState* this, s32 csCamDataIndex); +s16 Play_GetOriginalSceneId(s16 sceneId); +void Play_SaveCycleSceneFlags(GameState* thisx); +void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entrance, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw); +void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams); +void func_80169EFC(GameState* thisx); +void func_80169F78(GameState* thisx); +void func_80169FDC(GameState* thisx); +s32 func_80169FFC(GameState* thisx); +s32 FrameAdvance_IsEnabled(GameState* thisx); +s32 func_8016A02C(GameState* thisx, Actor* actor, s16* yaw); +s32 Play_IsUnderwater(PlayState* this, Vec3f* pos); +s32 Play_IsDebugCamEnabled(void); +void Play_AssignPlayerActorCsIdsFromScene(GameState* thisx, s32 startActorCsId); +void Play_FillScreen(GameState* gameState, s16 fillScreenOn, u8 red, u8 green, u8 blue, u8 alpha); void Play_Init(GameState* gameState); // void func_8016AC10(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); // void func_8016AE1C(void); @@ -2774,7 +2383,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); @@ -2833,33 +2442,30 @@ 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); void AudioMgr_ThreadEntry(void* arg); void AudioMgr_Unlock(AudioMgr* audioMgr); void AudioMgr_Init(AudioMgr* audioMgr, void* stack, OSPri pri, OSId id, SchedContext* sched, IrqMgr* irqMgr); -void TitleSetup_GameStateResetContext(void); -void TitleSetup_InitImpl(GameState* gameState); -void TitleSetup_Destroy(GameState* gameState); -void TitleSetup_Init(GameState* gameState); + 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); void GameState_InitArena(GameState* gameState, size_t size); void GameState_Realloc(GameState* gameState, size_t size); -void GameState_Init(GameState* gameState, GameStateFunc gameStateInit, GraphicsContext* gfxCtx); +void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx); void GameState_Destroy(GameState* gameState); -GameStateFunc GameState_GetNextStateInit(GameState* gameState); -size_t GameState_GetNextStateSize(GameState* gameState); +GameStateFunc GameState_GetInit(GameState* gameState); +size_t GameState_GetSize(GameState* gameState); u32 GameState_IsRunning(GameState* gameState); s32 GameState_GetArenaSize(GameState* gameState); s32 func_80173B48(GameState* gameState); @@ -2889,10 +2495,10 @@ 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_80174F7C(void); -// void func_80174F9C(void); +void func_80174F24(void (*arg0)(void*), void* arg1); +void func_80174F44(void (*arg0)(void*), void* arg1); +void func_80174F7C(void (*arg0)(s32), void* arg1); +void func_80174F9C(void (*arg0)(s32), void* arg1); // OSMesgQueue* Padmgr_GetEventCallback(void); // void func_80175008(void); void Padmgr_SetEventCallback(OSMesg pvParm1); @@ -2901,10 +2507,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); @@ -2945,9 +2551,11 @@ void SpeedMeter_DrawTimeEntries(void* displayList, GraphicsContext* gfxCtx); // void func_80177A84(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); //void func_80177AC8(void); 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 Mtx_SetTranslateScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, f32 translateZ); +void Mtx_SetRotationMtx(Mtx* mtx, s32 angle, f32 axisX, f32 axisY, f32 axisZ); +void Mtx_SetTranslationRotationScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s32 angle, f32 axisX, f32 axisY, f32 axisZ,f32 translateX, f32 translateY, f32 translateZ); + // void func_80178750(void); // void func_80178818(void); void func_80178978(void); @@ -2961,8 +2569,8 @@ s32 func_80178A94(s32 param_1, s32 param_2); // void func_80178C80(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80178D7C(void); // void func_80178DAC(void); -// void func_80178E3C(void); -// void func_80178E7C(void); +void func_80178E3C(u8*, s32, s32, s32); +void func_80178E7C(uintptr_t arg0, void* arg1, size_t size); // void Check_WriteRGBA16Pixel(u16* buffer, u32 x, u32 y, u32 value); // void Check_WriteI4Pixel(u16* buffer, u32 x, u32 y, u32 value); // void Check_DrawI4Texture(u16* buffer, u32 x, u32 y, u32 width, u32 height, u8* texture); @@ -3073,20 +2681,16 @@ 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); +s16 Math_Atan2S(f32 y, f32 x); +f32 Math_Atan2F(f32 y, f32 x); +s16 Math_Atan2S_XY(f32 x, f32 y); +f32 Math_Atan2F_XY(f32 x, f32 y); 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); @@ -3096,7 +2700,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); @@ -3113,9 +2717,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, - OverrideKeyframeDrawScaled overrideKeyframeDraw, PostKeyframeDrawScaled postKeyframeDraw, - Actor* actor); +void func_8018450C(PlayState* play, SkeletonInfo* skeleton, Mtx* mtx, OverrideKeyframeDrawScaled overrideKeyframeDraw, PostKeyframeDrawScaled postKeyframeDraw, Actor* actor); // void func_801845A4(void); // void func_801845C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_80184638(void); @@ -3166,56 +2768,17 @@ 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); -// void func_80187DE8(void); -// void func_80187E58(void); -// void func_80187F00(void); -// void func_80187FB0(void); -// void func_80187FE8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188034(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188078(void); -// void func_801880C4(void); -// void func_801880E8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188124(void); -// void func_8018814C(void); -// void func_80188174(void); -// void func_801881A8(void); -// void func_801881C4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_801881F8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188264(void); -// void func_80188288(void); -// void func_801882A0(void); -// void func_80188304(void); -// void func_801884A0(void); -// void func_80188698(void); -// void func_8018883C(void); -// void func_801888E4(void); -// void func_801889A4(void); -// void func_80188A50(void); -// void func_80188AFC(void); -// void func_80188C48(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188CB4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80188D28(void); -// void func_80188D68(void); -// void func_80188DDC(void); -// void func_80188FBC(void); -// void func_80189064(void); -// void func_80189620(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_8018A4B4(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_8018A768(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_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); + +Acmd* AudioSynth_Update(Acmd* abiCmdStart, s32* numAbiCmds, s16* aiBufStart, s32 numSamplesPerFrame); + void AudioHeap_DiscardFont(s32 fontId); void* AudioHeap_WritebackDCache(void* addr, size_t size); void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size); void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size); void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size); void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size); -void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size); -void AudioHeap_PopCache(s32 tableType); +void AudioHeap_InitPool(AudioAllocPool* pool, void* addr, size_t size); +void AudioHeap_PopPersistentCache(s32 tableType); void AudioHeap_InitMainPool(size_t initPoolSize); void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id); void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id); @@ -3226,14 +2789,15 @@ void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id); void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size); void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr, s8 medium, s32 cache); void AudioHeap_ApplySampleBankCache(s32 sampleBankId); -void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags); +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 isFirstInit); + void AudioLoad_DecreaseSampleDmaTtls(void); void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium); void AudioLoad_InitSampleDmaBuffers(s32 numNotes); s32 AudioLoad_IsFontLoadComplete(s32 fontId); s32 AudioLoad_IsSeqLoadComplete(s32 seqId); -void AudioLoad_SetFontLoadStatus(s32 fontId, s32 status); -void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 status); +void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus); +void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus); void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3); s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId); void AudioLoad_AsyncLoadSeq(s32 seqId, s32 arg1, s32 retData, OSMesgQueue* retQueue); @@ -3241,9 +2805,9 @@ void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 arg1, s32 retData, OSMe void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* retQueue); u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts); void AudioLoad_DiscardSeqFonts(s32 seqId); -void func_8018FA60(u32 tableType, u32 id, s32 arg2, s32 arg3); -s32 AudioLoad_SyncIniPlayer(s32 playerIdx, s32 seqId, s32 arg2); -s32 AudioLoad_SyncInitSetSeqqPlayerSkipTicks(s32 playerIdx, s32 seqId, s32 skipTicks); +void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data); +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); @@ -3255,52 +2819,33 @@ 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); -// void func_801936D8(void); -// void func_8019372C(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 func_801938D0(void); -// void func_80193900(void); -// void func_80193990(void); -// void func_801939A8(void); -// void func_80193AEC(void); -// void func_80193BA0(void); -// void func_80193C04(void); -// void func_80193C5C(void); -// void func_80193CB4(void); -// void func_80193D08(void); -// void func_80193DA4(void); -// void func_80193E6C(void); -// void func_80193EA8(void); -// void func_80194080(void); -// void func_80194304(void); -// void func_80194328(void); -// void func_8019435C(void); -// void func_8019439C(void); -// void func_801943D0(void); -// void func_8019440C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_80194528(void); -// void func_80194548(void); -// void func_80194568(void); -u32 Audio_NextRandom(void); -void Audio_InitMesgQueues(void); + +AudioTask* AudioThread_Update(void); +void AudioThread_QueueCmdF32(u32 opArgs, f32 data); +void AudioThread_QueueCmdS32(u32 opArgs, s32 data); +void AudioThread_QueueCmdS8(u32 opArgs, s8 data); +void AudioThread_QueueCmdU16(u32 opArgs, u16 data); +s32 AudioThread_ScheduleProcessCmds(void); +u32 AudioThread_GetExternalLoadQueueMsg(u32* retMsg); +u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts); +s32 func_80193C5C(void); +s32 AudioThread_ResetAudioHeap(s32 specId); +void AudioThread_PreNMIInternal(void); +s32 AudioThread_GetEnabledNotesCount(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); +TunedSample* AudioPlayback_GetInstrumentTunedSample(Instrument* instrument, s32 semitone); Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId); Drum* AudioPlayback_GetDrum(s32 fontId, s32 drumId); -SoundFontSound* AudioPlayback_GetSfx(s32 fontId, s32 sfxId); +SoundEffect* AudioPlayback_GetSoundEffect(s32 fontId, s32 sfxId); s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value); void AudioPlayback_SeqLayerNoteDecay(SequenceLayer* layer); void AudioPlayback_SeqLayerNoteRelease(SequenceLayer* layer); @@ -3312,131 +2857,71 @@ 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 seqPlayerIndex); 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 unused, u8 timer); +void 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 func_8019E014(void); +void AudioOcarina_PlayLongScarecrowAfterCredits(void); + +void Audio_Update(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 func_8019F5AC(void); -// void func_8019F638(void); -// void func_8019F780(void); +void AudioSfx_LowerSfxSettingsReverb(Vec3f* pos, s8 isReverbLowered); +f32 func_8019F5AC(f32 arg0); +void func_8019F638(Vec3f* arg0, u16 sfxId, f32 arg2); +void func_8019F780(Vec3f* arg0, u16 sfxId, f32 arg2); // void func_8019F7D8(void); -// void func_8019F830(void); +void func_8019F830(Vec3f* arg0, u16 arg1); void func_8019F88C(Vec3f* arg0, u16 sfxId, UNK_TYPE arg2); -// void func_8019F900(void); +void func_8019F900(Vec3f* pos, u8 chargeLevel); // void func_8019FA18(void); void func_8019FAD8(Vec3f* param_1, u16 sfxId, f32 param_3); void func_8019FB0C(Vec3f* arg0, u16 sfxId, f32 arg2, s32 arg3); void func_8019FC20(Vec3f* pos, u16 sfxId); -// void func_8019FCB8(void); -// void func_8019FD90(void); +void func_8019FCB8(Vec3f* arg0, u16 arg1, f32 arg2); +void func_8019FD90(s8 arg0, s8 arg1); void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); // void func_8019FE1C(void); void func_8019FE74(f32* arg0, f32 arg1, s32 arg2); @@ -3446,8 +2931,8 @@ void Audio_PlaySfxForRiver(Vec3f* pos, f32 freqScale); // void Audio_PlaySfxForWaterfall(void); // void Audio_StepFreqLerp(void); void func_801A0124(Vec3f* pos, u8 arg1); -// void func_801A0184(void); -// void func_801A01C4(void); +void func_801A0184(void); +void func_801A01C4(void); void func_801A0204(s8 seqId); void func_801A0238(s32 arg0, s32 arg1); // void Audio_SetGanonsTowerBgmVolumeLevel(void); @@ -3455,7 +2940,7 @@ 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(Vec3f* pos, u16 sfxId, u8 val); // void func_801A09D4(void); @@ -3474,34 +2959,30 @@ 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); -// void func_801A257C(void); -void func_801A25E4(u16 seqId, u8 dayMinusOne); -// void func_801A2670(void); -// void func_801A2778(void); +void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne); +void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne); // void func_801A27E8(void); // void func_801A281C(void); void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); void func_801A2BB8(s32 seqId); void func_801A2C20(void); // void func_801A2C44(void); -void func_801A2C88(u16 seqId); -void func_801A2D54(u16 seqId); +void Audio_PlaySequenceInCutscene(u16 seqId); +void Audio_StopSequenceInCutscene(u16 seqId); s32 Audio_IsSequencePlaying(u8 seqId); -void func_801A2E54(s32 bgmId); -void func_801A2ED8(void); -// void func_801A2F88(void); +void Audio_PlayBgm_StorePrevBgm(u16 seqId); +void Audio_RestorePrevBgm(void); // void func_801A3000(void); // void func_801A3038(void); -void func_801A3098(u16 seqId); +void Audio_PlayFanfare(u16 seqId); // void func_801A312C(void); void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); -// void func_801A3238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); -// void func_801A32CC(void); -// void func_801A3590(void); +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData); +void Audio_SetSequenceMode(u8 seqMode); +void Audio_UpdateEnemyBgmVolume(f32 dist); u8 func_801A3950(s32 playerIndex, s32 isChannelIOSet); u8 func_801A39F8(void); void func_801A3A7C(s32 arg0); @@ -3510,47 +2991,45 @@ void func_801A3AEC(s32 arg0); void func_801A3B48(UNK_TYPE arg0); // void func_801A3B90(void); void func_801A3CD8(s8 param_1); -// void func_801A3CF4(void); +void func_801A3CF4(s8 arg0); void func_801A3D98(s8 audioSetting); -// void func_801A3E38(void); +void func_801A3E38(u8 arg0); // void func_801A3EC0(void); -void Audio_SetCutsceneFlag(u8 flag); +void Audio_SetCutsceneFlag(s8 flag); // void func_801A3F6C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_801A3FB4(void); // void func_801A3FFC(UNK_TYPE1 param_1); -void audio_setBGM(u32 bgmID); +void Audio_SetSpec(u32 specId); void func_801A4058(UNK_TYPE arg0); // void func_801A41C8(void); -// void func_801A41F8(void); +void func_801A41F8(UNK_TYPE arg0); // void func_801A429C(void); // 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); +// void Audio_ResetRequestedSceneSeqId(void); // void func_801A44D4(void); s32 func_801A46F8(void); void func_801A4748(Vec3f* pos, u16 sfxId); 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_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData); +void Audio_PlayAmbience(u8 ambienceId); +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); void func_801A5080(u16 arg0); u16 func_801A5100(void); -// void func_801A5118(void); +void func_801A5118(void); UNK_TYPE func_801A51F0(UNK_TYPE arg0); // void func_801A5228(void); // void func_801A5390(void); @@ -3563,46 +3042,41 @@ 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 func_801A7D04(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 Audio_StopSequence(u8 playerIndex, u16 fadeTimer); // 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 func_801A8D5C(void); +void func_801A89D0(void); +u16 Audio_GetActiveSequence(u8 playerIndex); +s32 func_801A8ABC(u32 cmdVal, u32 cmdMask); +void Audio_SetVolumeScale(u8 playerIndex, u8 scaleIndex, u8 targetVol, u8 volFadeTimer); +void func_801A8D5C(void); // void func_801A8E90(void); -// void func_801A9768(void); -// void func_801A982C(void); +u8 func_801A9768(void); +u8 func_801A982C(void); // 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..b652cc132 --- /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* this); +void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a); +void GfxPrint_SetPosPx(GfxPrint* this, s32 x, s32 y); +void GfxPrint_SetPos(GfxPrint* this, s32 x, s32 y); +void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y); +void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c); +void GfxPrint_PrintChar(GfxPrint* this, u8 c); +void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount); +void GfxPrint_PrintString(GfxPrint* this, const char* str); +void* GfxPrint_Callback(void* arg, const char* str, size_t size); +void GfxPrint_Init(GfxPrint* this); +void GfxPrint_Destroy(GfxPrint* printer); +void GfxPrint_Open(GfxPrint* this, Gfx* dList); +Gfx* GfxPrint_Close(GfxPrint* this); +s32 GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args); +s32 GfxPrint_Printf(GfxPrint* this, 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/initvars.h b/include/initvars.h index 11a6719e9..50668a14c 100644 --- a/include/initvars.h +++ b/include/initvars.h @@ -34,580 +34,12 @@ extern EffectSsInit Effect_Ss_Ice_Smoke_InitVars; extern EffectSsInit Effect_En_Ice_Block_InitVars; extern EffectSsInit Effect_Ss_Sbn_InitVars; -extern ActorInit Player_InitVars; -extern ActorInit Arms_Hook_InitVars; -extern ActorInit Arrow_Fire_InitVars; -extern ActorInit Arrow_Ice_InitVars; -extern ActorInit Arrow_Light_InitVars; -extern ActorInit Bg_Astr_Bombwall_InitVars; -extern ActorInit Bg_Botihasira_InitVars; -extern ActorInit Bg_Breakwall_InitVars; -extern ActorInit Bg_Crace_Movebg_InitVars; -extern ActorInit Bg_Ctower_Gear_InitVars; -extern ActorInit Bg_Ctower_Rot_InitVars; -extern ActorInit Bg_Danpei_Movebg_InitVars; -extern ActorInit Bg_Dblue_Balance_InitVars; -extern ActorInit Bg_Dblue_Elevator_InitVars; -extern ActorInit Bg_Dblue_Movebg_InitVars; -extern ActorInit Bg_Dblue_Waterfall_InitVars; -extern ActorInit Bg_Dkjail_Ivy_InitVars; -extern ActorInit Bg_Dy_Yoseizo_InitVars; -extern ActorInit Bg_F40_Block_InitVars; -extern ActorInit Bg_F40_Flift_InitVars; -extern ActorInit Bg_F40_Switch_InitVars; -extern ActorInit Bg_F40_Swlift_InitVars; -extern ActorInit Bg_Fire_Wall_InitVars; -extern ActorInit Bg_Fu_Kaiten_InitVars; -extern ActorInit Bg_Fu_Mizu_InitVars; -extern ActorInit Bg_Goron_Oyu_InitVars; -extern ActorInit Bg_Haka_Bombwall_InitVars; -extern ActorInit Bg_Haka_Curtain_InitVars; -extern ActorInit Bg_Haka_Tomb_InitVars; -extern ActorInit Bg_Hakugin_Bombwall_InitVars; -extern ActorInit Bg_Hakugin_Elvpole_InitVars; -extern ActorInit Bg_Hakugin_Post_InitVars; -extern ActorInit Bg_Hakugin_Switch_InitVars; -extern ActorInit Bg_Icefloe_InitVars; -extern ActorInit Bg_Icicle_InitVars; -extern ActorInit Bg_Ikana_Block_InitVars; -extern ActorInit Bg_Ikana_Bombwall_InitVars; -extern ActorInit Bg_Ikana_Dharma_InitVars; -extern ActorInit Bg_Ikana_Mirror_InitVars; -extern ActorInit Bg_Ikana_Ray_InitVars; -extern ActorInit Bg_Ikana_Rotaryroom_InitVars; -extern ActorInit Bg_Ikana_Shutter_InitVars; -extern ActorInit Bg_Ikninside_InitVars; -extern ActorInit Bg_Iknin_Susceil_InitVars; -extern ActorInit Bg_Iknv_Doukutu_InitVars; -extern ActorInit Bg_Iknv_Obj_InitVars; -extern ActorInit Bg_Ingate_InitVars; -extern ActorInit Bg_Inibs_Movebg_InitVars; -extern ActorInit Bg_Keikoku_Saku_InitVars; -extern ActorInit Bg_Keikoku_Spr_InitVars; -extern ActorInit Bg_Kin2_Bombwall_InitVars; -extern ActorInit Bg_Kin2_Fence_InitVars; -extern ActorInit Bg_Kin2_Picture_InitVars; -extern ActorInit Bg_Kin2_Shelf_InitVars; -extern ActorInit Bg_Ladder_InitVars; -extern ActorInit Bg_Last_Bwall_InitVars; -extern ActorInit Bg_Lbfshot_InitVars; -extern ActorInit Bg_Lotus_InitVars; -extern ActorInit Bg_Market_Step_InitVars; -extern ActorInit Bg_Mbar_Chair_InitVars; -extern ActorInit Bg_Numa_Hana_InitVars; -extern ActorInit Bg_Open_Shutter_InitVars; -extern ActorInit Bg_Open_Spot_InitVars; -extern ActorInit Bg_Sinkai_Kabe_InitVars; -extern ActorInit Bg_Spdweb_InitVars; -extern ActorInit Bg_Spout_Fire_InitVars; -extern ActorInit Bg_Tobira01_InitVars; -extern ActorInit Bg_Umajump_InitVars; -extern ActorInit Boss_01_InitVars; -extern ActorInit Boss_02_InitVars; -extern ActorInit Boss_03_InitVars; -extern ActorInit Boss_04_InitVars; -extern ActorInit Boss_05_InitVars; -extern ActorInit Boss_06_InitVars; -extern ActorInit Boss_07_InitVars; -extern ActorInit Boss_Hakugin_InitVars; -extern ActorInit Demo_Effect_InitVars; -extern ActorInit Demo_Getitem_InitVars; -extern ActorInit Demo_Kankyo_InitVars; -extern ActorInit Demo_Moonend_InitVars; -extern ActorInit Demo_Shd_InitVars; -extern ActorInit Demo_Syoten_InitVars; -extern ActorInit Demo_Tre_Lgt_InitVars; -extern ActorInit Dm_Ah_InitVars; -extern ActorInit Dm_Al_InitVars; -extern ActorInit Dm_An_InitVars; -extern ActorInit Dm_Bal_InitVars; -extern ActorInit Dm_Char00_InitVars; -extern ActorInit Dm_Char01_InitVars; -extern ActorInit Dm_Char02_InitVars; -extern ActorInit Dm_Char03_InitVars; -extern ActorInit Dm_Char04_InitVars; -extern ActorInit Dm_Char05_InitVars; -extern ActorInit Dm_Char06_InitVars; -extern ActorInit Dm_Char07_InitVars; -extern ActorInit Dm_Char08_InitVars; -extern ActorInit Dm_Char09_InitVars; -extern ActorInit Dm_Gm_InitVars; -extern ActorInit Dm_Hina_InitVars; -extern ActorInit Dm_Nb_InitVars; -extern ActorInit Dm_Opstage_InitVars; -extern ActorInit Dm_Ravine_InitVars; -extern ActorInit Dm_Sa_InitVars; -extern ActorInit Dm_Statue_InitVars; -extern ActorInit Dm_Stk_InitVars; -extern ActorInit Dm_Tag_InitVars; -extern ActorInit Dm_Tsg_InitVars; -extern ActorInit Dm_Zl_InitVars; -extern ActorInit Door_Ana_InitVars; -extern ActorInit Door_Shutter_InitVars; -extern ActorInit Door_Spiral_InitVars; -extern ActorInit Door_Warp1_InitVars; -extern ActorInit Eff_Change_InitVars; -extern ActorInit Eff_Dust_InitVars; -extern ActorInit Eff_Kamejima_Wave_InitVars; -extern ActorInit Eff_Lastday_InitVars; -extern ActorInit Eff_Stk_InitVars; -extern ActorInit Eff_Zoraband_InitVars; -extern ActorInit Elf_Msg_InitVars; -extern ActorInit Elf_Msg2_InitVars; -extern ActorInit Elf_Msg3_InitVars; -extern ActorInit Elf_Msg4_InitVars; -extern ActorInit Elf_Msg5_InitVars; -extern ActorInit Elf_Msg6_InitVars; -extern ActorInit En_Ah_InitVars; -extern ActorInit En_Akindonuts_InitVars; -extern ActorInit En_Al_InitVars; -extern ActorInit En_Am_InitVars; -extern ActorInit En_An_InitVars; -extern ActorInit En_And_InitVars; -extern ActorInit En_Ani_InitVars; -extern ActorInit En_Aob_01_InitVars; -extern ActorInit En_Arrow_InitVars; -extern ActorInit En_Attack_Niw_InitVars; -extern ActorInit En_Az_InitVars; -extern ActorInit En_Baba_InitVars; -extern ActorInit En_Baguo_InitVars; -extern ActorInit En_Baisen_InitVars; -extern ActorInit En_Bal_InitVars; -extern ActorInit En_Bat_InitVars; -extern ActorInit En_Bb_InitVars; -extern ActorInit En_Bba_01_InitVars; -extern ActorInit En_Bbfall_InitVars; -extern ActorInit En_Bee_InitVars; -extern ActorInit En_Bh_InitVars; -extern ActorInit En_Bigokuta_InitVars; -extern ActorInit En_Bigpamet_InitVars; -extern ActorInit En_Bigpo_InitVars; -extern ActorInit En_Bigslime_InitVars; -extern ActorInit En_Bji_01_InitVars; -extern ActorInit En_Bjt_InitVars; -extern ActorInit En_Boj_01_InitVars; -extern ActorInit En_Boj_02_InitVars; -extern ActorInit En_Boj_03_InitVars; -extern ActorInit En_Boj_04_InitVars; -extern ActorInit En_Boj_05_InitVars; -extern ActorInit En_Bom_InitVars; -extern ActorInit En_Bombal_InitVars; -extern ActorInit En_Bombers_InitVars; -extern ActorInit En_Bombers2_InitVars; -extern ActorInit En_Bombf_InitVars; -extern ActorInit En_Bomjima_InitVars; -extern ActorInit En_Bomjimb_InitVars; -extern ActorInit En_Bom_Bowl_Man_InitVars; -extern ActorInit En_Bom_Chu_InitVars; -extern ActorInit En_Boom_InitVars; -extern ActorInit En_Box_InitVars; -extern ActorInit En_Bsb_InitVars; -extern ActorInit En_Bu_InitVars; -extern ActorInit En_Bubble_InitVars; -extern ActorInit En_Butte_InitVars; -extern ActorInit En_Cha_InitVars; -extern ActorInit En_Clear_Tag_InitVars; -extern ActorInit En_Cne_01_InitVars; -extern ActorInit En_Col_Man_InitVars; -extern ActorInit En_Cow_InitVars; -extern ActorInit En_Crow_InitVars; -extern ActorInit En_Dai_InitVars; -extern ActorInit En_Daiku_InitVars; -extern ActorInit En_Daiku2_InitVars; -extern ActorInit En_Death_InitVars; -extern ActorInit En_Dekubaba_InitVars; -extern ActorInit En_Dekunuts_InitVars; -extern ActorInit En_Demo_heishi_InitVars; -extern ActorInit En_Dg_InitVars; -extern ActorInit En_Dinofos_InitVars; -extern ActorInit En_Dnb_InitVars; -extern ActorInit En_Dnh_InitVars; -extern ActorInit En_Dnk_InitVars; -extern ActorInit En_Dno_InitVars; -extern ActorInit En_Dnp_InitVars; -extern ActorInit En_Dnq_InitVars; -extern ActorInit En_Dns_InitVars; -extern ActorInit En_Dodongo_InitVars; -extern ActorInit En_Door_InitVars; -extern ActorInit En_Door_Etc_InitVars; -extern ActorInit En_Dragon_InitVars; -extern ActorInit En_Drs_InitVars; -extern ActorInit En_Ds2n_InitVars; -extern ActorInit En_Dt_InitVars; -extern ActorInit En_Dy_Extra_InitVars; -extern ActorInit En_Egblock_InitVars; -extern ActorInit En_Egol_InitVars; -extern ActorInit En_Elf_InitVars; -extern ActorInit En_Elfbub_InitVars; -extern ActorInit En_Elfgrp_InitVars; -extern ActorInit En_Elforg_InitVars; -extern ActorInit En_Encount1_InitVars; -extern ActorInit En_Encount2_InitVars; -extern ActorInit En_Encount3_InitVars; -extern ActorInit En_Encount4_InitVars; -extern ActorInit En_Ending_Hero_InitVars; -extern ActorInit En_Ending_Hero2_InitVars; -extern ActorInit En_Ending_Hero3_InitVars; -extern ActorInit En_Ending_Hero4_InitVars; -extern ActorInit En_Ending_Hero5_InitVars; -extern ActorInit En_Ending_Hero6_InitVars; -extern ActorInit En_Estone_InitVars; -extern ActorInit En_Fall_InitVars; -extern ActorInit En_Fall2_InitVars; -extern ActorInit En_Famos_InitVars; -extern ActorInit En_Fg_InitVars; -extern ActorInit En_Firefly_InitVars; -extern ActorInit En_Firefly2_InitVars; -extern ActorInit En_Fire_Rock_InitVars; -extern ActorInit En_Fish_InitVars; -extern ActorInit En_Fishing_InitVars; -extern ActorInit En_Fish2_InitVars; -extern ActorInit En_Floormas_InitVars; -extern ActorInit En_Fr_InitVars; -extern ActorInit En_Fsn_InitVars; -extern ActorInit En_Fu_InitVars; -extern ActorInit En_Fu_Kago_InitVars; -extern ActorInit En_Fu_Mato_InitVars; -extern ActorInit En_Fz_InitVars; -extern ActorInit En_Gakufu_InitVars; -extern ActorInit En_Gamelupy_InitVars; -extern ActorInit En_Gb2_InitVars; -extern ActorInit En_Ge1_InitVars; -extern ActorInit En_Ge2_InitVars; -extern ActorInit En_Ge3_InitVars; -extern ActorInit En_Geg_InitVars; -extern ActorInit En_Gg_InitVars; -extern ActorInit En_Gg2_InitVars; -extern ActorInit En_Giant_InitVars; -extern ActorInit En_Ginko_Man_InitVars; -extern ActorInit En_GirlA_InitVars; -extern ActorInit En_Gk_InitVars; -extern ActorInit En_Gm_InitVars; -extern ActorInit En_Go_InitVars; -extern ActorInit En_Goroiwa_InitVars; -extern ActorInit En_Grasshopper_InitVars; -extern ActorInit En_Gs_InitVars; -extern ActorInit En_Guard_Nuts_InitVars; -extern ActorInit En_Guruguru_InitVars; -extern ActorInit En_Hakurock_InitVars; -extern ActorInit En_Hanabi_InitVars; -extern ActorInit En_Hata_InitVars; -extern ActorInit En_Heishi_InitVars; -extern ActorInit En_Hg_InitVars; -extern ActorInit En_Hgo_InitVars; -extern ActorInit En_Hidden_Nuts_InitVars; -extern ActorInit En_Hint_Skb_InitVars; -extern ActorInit En_Hit_Tag_InitVars; -extern ActorInit En_Holl_InitVars; -extern ActorInit En_Honotrap_InitVars; -extern ActorInit En_Horse_InitVars; -extern ActorInit En_Horse_Game_Check_InitVars; -extern ActorInit En_Horse_Link_Child_InitVars; -extern ActorInit En_Hs_InitVars; -extern ActorInit En_Hs2_InitVars; -extern ActorInit En_Ig_InitVars; -extern ActorInit En_Ik_InitVars; -extern ActorInit En_In_InitVars; -extern ActorInit En_Insect_InitVars; -extern ActorInit En_Invadepoh_InitVars; -extern ActorInit En_Invadepoh_Demo_InitVars; -extern ActorInit En_Invisible_Ruppe_InitVars; -extern ActorInit En_Ishi_InitVars; -extern ActorInit En_Item00_InitVars; -extern ActorInit En_Ja_InitVars; -extern ActorInit En_Jc_Mato_InitVars; -extern ActorInit En_Jg_InitVars; -extern ActorInit En_Jgame_Tsn_InitVars; -extern ActorInit En_Js_InitVars; -extern ActorInit En_Jso_InitVars; -extern ActorInit En_Jso2_InitVars; -extern ActorInit En_Kaizoku_InitVars; -extern ActorInit En_Kakasi_InitVars; -extern ActorInit En_Kame_InitVars; -extern ActorInit En_Kanban_InitVars; -extern ActorInit En_Karebaba_InitVars; -extern ActorInit En_Kbt_InitVars; -extern ActorInit En_Kendo_Js_InitVars; -extern ActorInit En_Kgy_InitVars; -extern ActorInit En_Kitan_InitVars; -extern ActorInit En_Knight_InitVars; -extern ActorInit En_Kujiya_InitVars; -extern ActorInit En_Kusa_InitVars; -extern ActorInit En_Kusa2_InitVars; -extern ActorInit En_Lift_Nuts_InitVars; -extern ActorInit En_Light_InitVars; -extern ActorInit En_Look_Nuts_InitVars; -extern ActorInit En_Ma4_InitVars; -extern ActorInit En_Mag_InitVars; -extern ActorInit En_Maruta_InitVars; -extern ActorInit En_Ma_Yto_InitVars; -extern ActorInit En_Ma_Yts_InitVars; -extern ActorInit En_Minideath_InitVars; -extern ActorInit En_Minifrog_InitVars; -extern ActorInit En_Minislime_InitVars; -extern ActorInit En_Mk_InitVars; -extern ActorInit En_Mkk_InitVars; -extern ActorInit En_Mm_InitVars; -extern ActorInit En_Mm2_InitVars; -extern ActorInit En_Mm3_InitVars; -extern ActorInit En_Mnk_InitVars; -extern ActorInit En_Ms_InitVars; -extern ActorInit En_Mt_tag_InitVars; -extern ActorInit En_Mushi2_InitVars; -extern ActorInit En_Muto_InitVars; -extern ActorInit En_M_Fire1_InitVars; -extern ActorInit En_M_Thunder_InitVars; -extern ActorInit En_Nb_InitVars; -extern ActorInit En_Neo_Reeba_InitVars; -extern ActorInit En_Nimotsu_InitVars; -extern ActorInit En_Niw_InitVars; -extern ActorInit En_Nnh_InitVars; -extern ActorInit En_Nutsball_InitVars; -extern ActorInit En_Nwc_InitVars; -extern ActorInit En_Okarina_Effect_InitVars; -extern ActorInit En_Okarina_Tag_InitVars; -extern ActorInit En_Okuta_InitVars; -extern ActorInit En_Onpuman_InitVars; -extern ActorInit En_Osk_InitVars; -extern ActorInit En_Osn_InitVars; -extern ActorInit En_Ossan_InitVars; -extern ActorInit En_Ot_InitVars; -extern ActorInit En_Owl_InitVars; -extern ActorInit En_Pamera_InitVars; -extern ActorInit En_Pametfrog_InitVars; -extern ActorInit En_Paper_InitVars; -extern ActorInit En_Part_InitVars; -extern ActorInit En_Peehat_InitVars; -extern ActorInit En_Pm_InitVars; -extern ActorInit En_Poh_InitVars; -extern ActorInit En_Po_Composer_InitVars; -extern ActorInit En_Po_Fusen_InitVars; -extern ActorInit En_Po_Sisters_InitVars; -extern ActorInit En_Pp_InitVars; -extern ActorInit En_Pr_InitVars; -extern ActorInit En_Pr2_InitVars; -extern ActorInit En_Prz_InitVars; -extern ActorInit En_Pst_InitVars; -extern ActorInit En_Racedog_InitVars; -extern ActorInit En_Raf_InitVars; -extern ActorInit En_Railgibud_InitVars; -extern ActorInit En_Rail_Skb_InitVars; -extern ActorInit En_Rat_InitVars; -extern ActorInit En_Rd_InitVars; -extern ActorInit En_Recepgirl_InitVars; -extern ActorInit En_Rg_InitVars; -extern ActorInit En_River_Sound_InitVars; -extern ActorInit En_Rr_InitVars; -extern ActorInit En_Rsn_InitVars; -extern ActorInit En_Ru_InitVars; -extern ActorInit En_Ruppecrow_InitVars; -extern ActorInit En_Rz_InitVars; -extern ActorInit En_Sb_InitVars; -extern ActorInit En_Scopecoin_InitVars; -extern ActorInit En_Scopecrow_InitVars; -extern ActorInit En_Scopenuts_InitVars; -extern ActorInit En_Sc_Ruppe_InitVars; -extern ActorInit En_Sda_InitVars; -extern ActorInit En_Sekihi_InitVars; -extern ActorInit En_Sellnuts_InitVars; -extern ActorInit En_Shn_InitVars; -extern ActorInit En_Si_InitVars; -extern ActorInit En_Skb_InitVars; -extern ActorInit En_Slime_InitVars; -extern ActorInit En_Snowman_InitVars; -extern ActorInit En_Snowwd_InitVars; -extern ActorInit En_Sob1_InitVars; -extern ActorInit En_Ssh_InitVars; -extern ActorInit En_St_InitVars; -extern ActorInit En_Sth_InitVars; -extern ActorInit En_Sth2_InitVars; -extern ActorInit En_Stone_heishi_InitVars; -extern ActorInit En_Stop_heishi_InitVars; -extern ActorInit En_Stream_InitVars; -extern ActorInit En_Suttari_InitVars; -extern ActorInit En_Sw_InitVars; -extern ActorInit En_Syateki_Crow_InitVars; -extern ActorInit En_Syateki_Dekunuts_InitVars; -extern ActorInit En_Syateki_Man_InitVars; -extern ActorInit En_Syateki_Okuta_InitVars; -extern ActorInit En_Syateki_Wf_InitVars; -extern ActorInit En_S_Goro_InitVars; -extern ActorInit En_Tab_InitVars; -extern ActorInit En_Tag_Obj_InitVars; -extern ActorInit En_Takaraya_InitVars; -extern ActorInit En_Talk_InitVars; -extern ActorInit En_Talk_Gibud_InitVars; -extern ActorInit En_Tanron1_InitVars; -extern ActorInit En_Tanron2_InitVars; -extern ActorInit En_Tanron3_InitVars; -extern ActorInit En_Tanron4_InitVars; -extern ActorInit En_Tanron5_InitVars; -extern ActorInit En_Tanron6_InitVars; -extern ActorInit En_Test_InitVars; -extern ActorInit En_Test2_InitVars; -extern ActorInit En_Test3_InitVars; -extern ActorInit En_Test4_InitVars; -extern ActorInit En_Test5_InitVars; -extern ActorInit En_Test6_InitVars; -extern ActorInit En_Test7_InitVars; -extern ActorInit En_Tg_InitVars; -extern ActorInit En_Thiefbird_InitVars; -extern ActorInit En_Time_Tag_InitVars; -extern ActorInit En_Tite_InitVars; -extern ActorInit En_Tk_InitVars; -extern ActorInit En_Torch_InitVars; -extern ActorInit En_Torch2_InitVars; -extern ActorInit En_Toto_InitVars; -extern ActorInit En_Trt_InitVars; -extern ActorInit En_Trt2_InitVars; -extern ActorInit En_Tru_InitVars; -extern ActorInit En_Tru_Mt_InitVars; -extern ActorInit En_Tsn_InitVars; -extern ActorInit En_Tubo_Trap_InitVars; -extern ActorInit En_Twig_InitVars; -extern ActorInit En_Viewer_InitVars; -extern ActorInit En_Vm_InitVars; -extern ActorInit En_Wallmas_InitVars; -extern ActorInit En_Warp_tag_InitVars; -extern ActorInit En_Warp_Uzu_InitVars; -extern ActorInit En_Water_Effect_InitVars; -extern ActorInit En_Wdhand_InitVars; -extern ActorInit En_Weather_Tag_InitVars; -extern ActorInit En_Wf_InitVars; -extern ActorInit En_Wiz_InitVars; -extern ActorInit En_Wiz_Brock_InitVars; -extern ActorInit En_Wiz_Fire_InitVars; -extern ActorInit En_Wood02_InitVars; -extern ActorInit En_Yb_InitVars; -extern ActorInit En_Zl1_InitVars; -extern ActorInit En_Zl4_InitVars; -extern ActorInit En_Zo_InitVars; -extern ActorInit En_Zob_InitVars; -extern ActorInit En_Zod_InitVars; -extern ActorInit En_Zog_InitVars; -extern ActorInit En_Zoraegg_InitVars; -extern ActorInit En_Zos_InitVars; -extern ActorInit En_Zot_InitVars; -extern ActorInit En_Zov_InitVars; -extern ActorInit En_Zow_InitVars; -extern ActorInit Item_B_Heart_InitVars; -extern ActorInit Item_Etcetera_InitVars; -extern ActorInit Item_Inbox_InitVars; -extern ActorInit Mir_Ray_InitVars; -extern ActorInit Mir_Ray2_InitVars; -extern ActorInit Mir_Ray3_InitVars; -extern ActorInit Object_Kankyo_InitVars; -extern ActorInit Obj_Aqua_InitVars; -extern ActorInit Obj_Armos_InitVars; -extern ActorInit Obj_Bean_InitVars; -extern ActorInit Obj_Bell_InitVars; -extern ActorInit Obj_Bigicicle_InitVars; -extern ActorInit Obj_Blockstop_InitVars; -extern ActorInit Obj_Boat_InitVars; -extern ActorInit Obj_Bombiwa_InitVars; -extern ActorInit Obj_Boyo_InitVars; -extern ActorInit Obj_Chan_InitVars; -extern ActorInit Obj_Chikuwa_InitVars; -extern ActorInit Obj_Comb_InitVars; -extern ActorInit Obj_Danpeilift_InitVars; -extern ActorInit Obj_Demo_InitVars; -extern ActorInit Obj_Dhouse_InitVars; -extern ActorInit Obj_Dinner_InitVars; -extern ActorInit Obj_Dora_InitVars; -extern ActorInit Obj_Dowsing_InitVars; -extern ActorInit Obj_Driftice_InitVars; -extern ActorInit Obj_Ending_InitVars; -extern ActorInit Obj_Entotu_InitVars; -extern ActorInit Obj_Etcetera_InitVars; -extern ActorInit Obj_Fireshield_InitVars; -extern ActorInit Obj_Flowerpot_InitVars; -extern ActorInit Obj_Funen_InitVars; -extern ActorInit Obj_Ghaka_InitVars; -extern ActorInit Obj_Grass_InitVars; -extern ActorInit Obj_Grass_Carry_InitVars; -extern ActorInit Obj_Grass_Unit_InitVars; -extern ActorInit Obj_Hakaisi_InitVars; -extern ActorInit Obj_Hamishi_InitVars; -extern ActorInit Obj_Hana_InitVars; -extern ActorInit Obj_Hariko_InitVars; -extern ActorInit Obj_Hgdoor_InitVars; -extern ActorInit Obj_Hsblock_InitVars; -extern ActorInit Obj_HsStump_InitVars; -extern ActorInit Obj_Hugebombiwa_InitVars; -extern ActorInit Obj_Hunsui_InitVars; -extern ActorInit Obj_Iceblock_InitVars; -extern ActorInit Obj_Ice_Poly_InitVars; -extern ActorInit Obj_Jgame_Light_InitVars; -extern ActorInit Obj_Jg_Gakki_InitVars; -extern ActorInit Obj_Kendo_Kanban_InitVars; -extern ActorInit Obj_Kepn_Koya_InitVars; -extern ActorInit Obj_Kibako_InitVars; -extern ActorInit Obj_Kibako2_InitVars; -extern ActorInit Obj_Kinoko_InitVars; -extern ActorInit Obj_Kzsaku_InitVars; -extern ActorInit Obj_Lift_InitVars; -extern ActorInit Obj_Lightblock_InitVars; -extern ActorInit Obj_Lightswitch_InitVars; -extern ActorInit Obj_Lupygamelift_InitVars; -extern ActorInit Obj_Makekinsuta_InitVars; -extern ActorInit Obj_Makeoshihiki_InitVars; -extern ActorInit Obj_Milk_Bin_InitVars; -extern ActorInit Obj_Mine_InitVars; -extern ActorInit Obj_Moon_Stone_InitVars; -extern ActorInit Obj_Mure_InitVars; -extern ActorInit Obj_Mure2_InitVars; -extern ActorInit Obj_Mure3_InitVars; -extern ActorInit Obj_Mu_Pict_InitVars; -extern ActorInit Obj_Nozoki_InitVars; -extern ActorInit Obj_Ocarinalift_InitVars; -extern ActorInit Obj_Oshihiki_InitVars; -extern ActorInit Obj_Purify_InitVars; -extern ActorInit Obj_Pzlblock_InitVars; -extern ActorInit Obj_Raillift_InitVars; -extern ActorInit Obj_Roomtimer_InitVars; -extern ActorInit Obj_Rotlift_InitVars; -extern ActorInit Obj_Shutter_InitVars; -extern ActorInit Obj_Skateblock_InitVars; -extern ActorInit Obj_Smork_InitVars; -extern ActorInit Obj_Snowball_InitVars; -extern ActorInit Obj_Snowball2_InitVars; -extern ActorInit Obj_Sound_InitVars; -extern ActorInit Obj_Spidertent_InitVars; -extern ActorInit Obj_Spinyroll_InitVars; -extern ActorInit Obj_Switch_InitVars; -extern ActorInit Obj_Swprize_InitVars; -extern ActorInit Obj_Syokudai_InitVars; -extern ActorInit Obj_Takaraya_Wall_InitVars; -extern ActorInit Obj_Taru_InitVars; -extern ActorInit Obj_Toge_InitVars; -extern ActorInit Obj_Tokeidai_InitVars; -extern ActorInit Obj_Tokei_Step_InitVars; -extern ActorInit Obj_Tokei_Tobira_InitVars; -extern ActorInit Obj_Tokei_Turret_InitVars; -extern ActorInit Obj_Toudai_InitVars; -extern ActorInit Obj_Tree_InitVars; -extern ActorInit Obj_Tsubo_InitVars; -extern ActorInit Obj_Um_InitVars; -extern ActorInit Obj_Usiyane_InitVars; -extern ActorInit Obj_Visiblock_InitVars; -extern ActorInit Obj_Vspinyroll_InitVars; -extern ActorInit Obj_Warpstone_InitVars; -extern ActorInit Obj_Wind_InitVars; -extern ActorInit Obj_Wturn_InitVars; -extern ActorInit Obj_Y2lift_InitVars; -extern ActorInit Obj_Y2shutter_InitVars; -extern ActorInit Obj_Yado_InitVars; -extern ActorInit Obj_Yasi_InitVars; -extern ActorInit Oceff_Spot_InitVars; -extern ActorInit Oceff_Storm_InitVars; -extern ActorInit Oceff_Wipe_InitVars; -extern ActorInit Oceff_Wipe2_InitVars; -extern ActorInit Oceff_Wipe3_InitVars; -extern ActorInit Oceff_Wipe4_InitVars; -extern ActorInit Oceff_Wipe5_InitVars; -extern ActorInit Oceff_Wipe6_InitVars; -extern ActorInit Oceff_Wipe7_InitVars; -extern ActorInit Shot_Sun_InitVars; -extern ActorInit TG_Sw_InitVars; +extern TransitionInit TransitionFade_InitVars; +extern TransitionInit TransitionTriforce_InitVars; +extern TransitionInit TransitionWipe1_InitVars; +extern TransitionInit TransitionWipe3_InitVars; +extern TransitionInit TransitionWipe4_InitVars; +extern TransitionInit TransitionCircle_InitVars; +extern TransitionInit TransitionWipe5_InitVars; #endif 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 bb7315b3d..913ccac4a 100644 --- a/include/macros.h +++ b/include/macros.h @@ -11,116 +11,72 @@ #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 STOP_GAMESTATE(curState) \ + do { \ + GameState* state = curState; \ + \ + state->running = false; \ + } while(0) -#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 SET_NEXT_GAMESTATE(curState, nextInit, nextSize) \ + do { \ + GameState* state = curState; \ + \ + (state)->init = nextInit; \ + (state)->size = nextSize; \ + } while (0) -#define GET_PLAYER(globalCtx) ((Player*)(globalCtx)->actorCtx.actorLists[ACTORCAT_PLAYER].first) +#define GET_PLAYER(play) ((Player*)(play)->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))) - #define TIME_TO_MINUTES_ALT_F(time) ((time) / (0x10000 / (24.0f * 60.0f))) + +#define TIME_TO_SECONDS_F(time) ((time) * ((24.0f * 60.0f * 60.0f) / 0x10000)) + +#define CLOCK_TIME_F(hr, min) (((hr) * 60.0f + (min)) * (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 CLOCK_TIME_ALT2_F(hr, min) ((((hr) + (min) / 60.0f) * 60.0f) / (24.0f * 60.0f / 0x10000)) #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]) +// To be used with `Magic_Add`, but ensures enough magic is added to fill the magic bar to capacity +#define MAGIC_FILL_TO_CAPACITY (((void)0, gSaveContext.magicFillTarget) + (gSaveContext.save.playerData.isDoubleMagicAcquired + 1) * MAGIC_NORMAL_METER) + +#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) #define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask)) +#define ALIGN8(val) (((val) + 7) & ~7) +#define ALIGN16(val) (((val) + 0xF) & ~0xF) +#define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) + extern GraphicsContext* __gfxCtx; #define WORK_DISP __gfxCtx->work.p @@ -158,7 +114,7 @@ extern GraphicsContext* __gfxCtx; #define VTX_T(x, y, z, s, t, cr, cg, cb, a) \ { { x, y, z }, 0, { s, t }, { cr, cg, cb, a }, } -#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - (size)))) +#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) // Custom gbi macro #define gDPSetTileCustom(pkt, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ @@ -175,11 +131,6 @@ extern GraphicsContext* __gfxCtx; } \ (void)0 -#define ALIGN8(val) (((val) + 7) & ~7) -#define ALIGN16(val) (((val) + 0xF) & ~0xF) -#define ALIGN64(val) (((val) + 0x3F) & ~0x3F) -#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) - #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) @@ -201,10 +152,4 @@ extern GraphicsContext* __gfxCtx; #define OVERLAY_RELOCATION_OFFSET(overlayEntry) ((uintptr_t)((overlayEntry)->vramStart) - (uintptr_t)((overlayEntry)->loadedRamAddr)) #define VRAM_PTR_SIZE(entry) ((uintptr_t)((entry)->vramEnd) - (uintptr_t)((entry)->vramStart)) -#ifdef __GNUC__ -#define ALIGNED8 __attribute__ ((aligned (8))) -#else -#define ALIGNED8 -#endif - #endif // MACROS_H 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.h b/include/os.h index 838d8234a..6e34bd428 100644 --- a/include/os.h +++ b/include/os.h @@ -47,7 +47,7 @@ typedef struct { /* 0x04 */ u16 transferMode; /* 0x06 */ u16 blockNum; /* 0x08 */ s32 sectorNum; - /* 0x0C */ u32 devAddr; + /* 0x0C */ uintptr_t devAddr; /* 0x10 */ u32 bmCtlShadow; /* 0x14 */ u32 seqCtlShadow; /* 0x18 */ __OSBlockInfo block[2]; @@ -62,7 +62,7 @@ typedef struct OSPiHandle { /* 0x07 */ u8 relDuration; /* 0x08 */ u8 pulse; /* 0x09 */ u8 domain; - /* 0x0C */ u32 baseAddress; + /* 0x0C */ uintptr_t baseAddress; /* 0x10 */ u32 speed; /* 0x14 */ __OSTranxInfo transferInfo; } OSPiHandle; // size = 0x74 @@ -70,7 +70,7 @@ typedef struct OSPiHandle { typedef struct { /* 0x0 */ u8 type; - /* 0x4 */ u32 address; + /* 0x4 */ uintptr_t address; } OSPiInfo; // size = 0x8 @@ -97,8 +97,8 @@ typedef struct { /* 0x08 */ OSMesgQueue* cmdQueue; /* 0x0C */ OSMesgQueue* evtQueue; /* 0x10 */ OSMesgQueue* acsQueue; - /* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t); - /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t); + /* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t); + /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t); } OSDevMgr; // size = 0x1C typedef u64 OSTime; diff --git a/include/os_internal.h b/include/os_internal.h index 3c6d4eee4..2d82b41a9 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 @@ -12,8 +12,8 @@ typedef struct { /* 0x08 */ OSMesgQueue* cmdQueue; /* 0x0C */ OSMesgQueue* eventQueue; /* 0x10 */ OSMesgQueue* accessQueue; - /* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t); - /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t); + /* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t); + /* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t); } OSMgrArgs; // size = 0x1C #endif diff --git a/include/os_malloc.h b/include/os_malloc.h index 6b1cceab5..6f6bbf900 100644 --- a/include/os_malloc.h +++ b/include/os_malloc.h @@ -29,7 +29,7 @@ void* __osMalloc(Arena* arena, size_t size); void* __osMallocR(Arena* arena, size_t size); void __osFree(Arena* arena, void* ptr); void* __osRealloc(Arena* arena, void* ptr, size_t newSize); -void __osGetSizes(Arena* arena, size_t* maxFreeBlock, size_t* bytesFree, size_t* bytesAllocated); +void __osGetSizes(Arena* arena, size_t* outMaxFree, size_t* outFree, size_t* outAlloc); s32 __osCheckArena(Arena* arena); #endif diff --git a/include/regs.h b/include/regs.h index 9942242a7..b19131748 100644 --- a/include/regs.h +++ b/include/regs.h @@ -43,61 +43,99 @@ #define bREG(r) BASE_REG(28, r) /* TODO: Actually confirm these, in case of miss-match it's at least a simple list to `sed` */ -#define R_ENABLE_ARENA_DBG SREG(0) // Same as OoT -#define R_RUN_SPEED_LIMIT REG(45) -#define R_UPDATE_RATE SREG(30) -#define R_PAUSE_MENU_MODE SREG(94) -#define R_C_UP_ICON_X YREG(88) -#define R_C_UP_ICON_Y YREG(89) -#define R_MAGIC_FILL_COLOR(i) ZREG(0 + i) -#define R_C_BTN_COLOR(i) ZREG(39 + i) -#define R_B_BTN_COLOR(i) ZREG(43 + i) -#define R_START_LABEL_DD(i) ZREG(48 + i) -#define R_START_LABEL_Y(i) ZREG(51 + i) -#define R_START_LABEL_X(i) ZREG(54 + i) -#define R_C_UP_BTN_X ZREG(62) -#define R_C_UP_BTN_Y ZREG(63) -#define R_START_BTN_X ZREG(68) -#define R_START_BTN_Y ZREG(69) -#define R_ITEM_BTN_X(i) ZREG(70 + i) -#define R_ITEM_BTN_Y(i) ZREG(74 + i) -#define R_ITEM_BTN_DD(i) ZREG(78 + i) -#define R_ITEM_ICON_X(i) ZREG(82 + i) -#define R_ITEM_ICON_Y(i) ZREG(86 + i) -#define R_ITEM_ICON_DD(i) ZREG(90 + i) -#define R_A_BTN_Y XREG(16) -#define R_A_BTN_X XREG(17) -#define R_A_ICON_Y XREG(19) -#define R_A_ICON_X XREG(20) -#define R_A_BTN_COLOR(i) XREG(22 + i) -#define R_MAGIC_BAR_SMALL_Y XREG(48) -#define R_MAGIC_BAR_X XREG(49) -#define R_MAGIC_BAR_LARGE_Y XREG(50) -#define R_MAGIC_FILL_X XREG(51) -#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) -#define R_DGN_MINIMAP_Y WREG(69) -#define R_MAP_INDEX VREG(11) -#define R_MAP_TEX_INDEX_BASE VREG(12) -#define R_MAP_TEX_INDEX VREG(13) -#define R_COMPASS_SCALE_X VREG(14) -#define R_COMPASS_SCALE_Y VREG(15) -#define R_COMPASS_OFFSET_X VREG(16) -#define R_COMPASS_OFFSET_Y VREG(17) -#define R_MINIMAP_COLOR(i) VREG(18 + i) -#define R_ITEM_AMMO_X(i) VREG(64 + i) -#define R_ITEM_AMMO_Y(i) VREG(68 + i) -#define R_ITEM_ICON_WIDTH(i) VREG(76 + i) -#define R_ITEM_BTN_WIDTH(i) VREG(80 + i) +#define R_TIME_SPEED REG(15) +#define R_RUN_SPEED_LIMIT REG(45) -#define R_FB_FILTER_TYPE SREG(80) -#define R_FB_FILTER_PRIM_COLOR(c) SREG(81 + c) -#define R_FB_FILTER_A SREG(84) -#define R_FB_FILTER_ENV_COLOR(c) SREG(85 + c) +#define R_ENABLE_ARENA_DBG SREG(0) // Same as OoT +#define R_UPDATE_RATE SREG(30) +#define R_FB_FILTER_TYPE SREG(80) +#define R_FB_FILTER_PRIM_COLOR(c) SREG(81 + c) +#define R_FB_FILTER_A SREG(84) +#define R_FB_FILTER_ENV_COLOR(c) SREG(85 + c) +#define R_PAUSE_BG_PRERENDER_STATE SREG(94) + +#define R_PLAY_FILL_SCREEN_ON MREG(64) +#define R_PLAY_FILL_SCREEN_R MREG(65) +#define R_PLAY_FILL_SCREEN_G MREG(66) +#define R_PLAY_FILL_SCREEN_B MREG(67) +#define R_PLAY_FILL_SCREEN_ALPHA MREG(68) + +#define R_PAUSE_WORLD_MAP_YAW YREG(24) +#define R_PAUSE_WORLD_MAP_Y_OFFSET YREG(25) +#define R_PAUSE_WORLD_MAP_DEPTH YREG(26) +#define R_PICTO_FOCUS_BORDER_TOPLEFT_X YREG(32) +#define R_PICTO_FOCUS_BORDER_TOPLEFT_Y YREG(33) +#define R_PICTO_FOCUS_BORDER_TOPRIGHT_X YREG(34) +#define R_PICTO_FOCUS_BORDER_TOPRIGHT_Y YREG(35) +#define R_PICTO_FOCUS_BORDER_BOTTOMLEFT_X YREG(36) +#define R_PICTO_FOCUS_BORDER_BOTTOMLEFT_Y YREG(37) +#define R_PICTO_FOCUS_BORDER_BOTTOMRIGHT_X YREG(38) +#define R_PICTO_FOCUS_BORDER_BOTTOMRIGHT_Y YREG(39) +#define R_PICTO_FOCUS_ICON_X YREG(40) +#define R_PICTO_FOCUS_ICON_Y YREG(41) +#define R_PICTO_FOCUS_TEXT_X YREG(42) +#define R_PICTO_FOCUS_TEXT_Y YREG(43) +#define R_PAUSE_DBG_QUEST_CURSOR_ON YREG(69) +#define R_PAUSE_DBG_QUEST_CURSOR_X YREG(70) +#define R_PAUSE_DBG_QUEST_CURSOR_Y YREG(71) + +#define R_MAGIC_FILL_COLOR(i) ZREG(0 + i) +#define R_C_BTN_COLOR(i) ZREG(39 + i) +#define R_B_BTN_COLOR(i) ZREG(43 + i) +#define R_START_LABEL_DD(i) ZREG(48 + i) +#define R_START_LABEL_Y(i) ZREG(51 + i) +#define R_START_LABEL_X(i) ZREG(54 + i) +#define R_C_UP_BTN_X ZREG(62) +#define R_C_UP_BTN_Y ZREG(63) +#define R_START_BTN_X ZREG(68) +#define R_START_BTN_Y ZREG(69) +#define R_ITEM_BTN_X(i) ZREG(70 + i) +#define R_ITEM_BTN_Y(i) ZREG(74 + i) +#define R_ITEM_BTN_DD(i) ZREG(78 + i) +#define R_ITEM_ICON_X(i) ZREG(82 + i) +#define R_ITEM_ICON_Y(i) ZREG(86 + i) +#define R_ITEM_ICON_DD(i) ZREG(90 + i) + +#define R_MAGIC_DBG_SET_UPGRADE XREG(4) +#define R_A_BTN_Y XREG(16) +#define R_A_BTN_X XREG(17) +#define R_A_ICON_Y XREG(19) +#define R_A_ICON_X XREG(20) +#define R_A_BTN_COLOR(i) XREG(22 + i) +#define R_A_BTN_Y_OFFSET XREG(31) +#define R_MAGIC_CONSUME_TIMER_GIANTS_MASK XREG(41) +#define R_THREE_DAY_CLOCK_Y_POS XREG(43) +#define R_THREE_DAY_CLOCK_SUN_MOON_CUTOFF XREG(44) +#define R_THREE_DAY_CLOCK_HOUR_DIGIT_CUTOFF XREG(45) +#define R_PAUSE_DBG_MAP_CLOUD_ON XREG(50) +#define R_PAUSE_DBG_MAP_CLOUD_X XREG(52) +#define R_PAUSE_DBG_MAP_CLOUD_Y XREG(53) +#define R_MOON_CRASH_TIMER_Y XREG(80) +#define R_MOON_CRASH_TIMER_X XREG(81) +#define R_PAUSE_OWLWARP_ALPHA XREG(87) +#define R_STORY_FILL_SCREEN_ALPHA XREG(91) +#define R_REVERSE_FLOOR_INDEX XREG(94) +#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_B_LABEL_X(i) WREG(40 + i) +#define R_B_LABEL_Y(i) WREG(43 + i) +#define R_DGN_MINIMAP_X WREG(68) +#define R_DGN_MINIMAP_Y WREG(69) + +#define R_MAP_INDEX VREG(11) +#define R_MAP_TEX_INDEX_BASE VREG(12) +#define R_MAP_TEX_INDEX VREG(13) +#define R_COMPASS_SCALE_X VREG(14) +#define R_COMPASS_SCALE_Y VREG(15) +#define R_COMPASS_OFFSET_X VREG(16) +#define R_COMPASS_OFFSET_Y VREG(17) +#define R_MINIMAP_COLOR(i) VREG(18 + i) +#define R_ITEM_AMMO_X(i) VREG(64 + i) +#define R_ITEM_AMMO_Y(i) VREG(68 + i) +#define R_ITEM_ICON_WIDTH(i) VREG(76 + i) +#define R_ITEM_BTN_WIDTH(i) VREG(80 + i) #endif diff --git a/include/segment_symbols.h b/include/segment_symbols.h index e133437cc..ccb5488d1 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -53,7 +53,9 @@ DECLARE_ROM_SEGMENT(map_grand_static) DECLARE_ROM_SEGMENT(item_name_static) DECLARE_ROM_SEGMENT(map_name_static) DECLARE_ROM_SEGMENT(icon_item_static_test) +DECLARE_ROM_SEGMENT(icon_item_static_old) DECLARE_ROM_SEGMENT(icon_item_24_static_test) +DECLARE_ROM_SEGMENT(icon_item_24_static_old) DECLARE_ROM_SEGMENT(schedule_dma_static_test) DECLARE_ROM_SEGMENT(schedule_static) DECLARE_ROM_SEGMENT(story_static) @@ -76,147 +78,16 @@ DECLARE_OVERLAY_SEGMENT(daytelop) DECLARE_OVERLAY_SEGMENT(kaleido_scope) DECLARE_OVERLAY_SEGMENT(player_actor) -DECLARE_OVERLAY_SEGMENT(En_Test) -DECLARE_OVERLAY_SEGMENT(En_GirlA) -DECLARE_OVERLAY_SEGMENT(En_Part) -DECLARE_OVERLAY_SEGMENT(En_Light) -DECLARE_OVERLAY_SEGMENT(En_Door) -DECLARE_OVERLAY_SEGMENT(En_Box) -DECLARE_OVERLAY_SEGMENT(En_Pametfrog) -DECLARE_OVERLAY_SEGMENT(En_Okuta) -DECLARE_OVERLAY_SEGMENT(En_Bom) -DECLARE_OVERLAY_SEGMENT(En_Wallmas) -DECLARE_OVERLAY_SEGMENT(En_Dodongo) -DECLARE_OVERLAY_SEGMENT(En_Firefly) -DECLARE_OVERLAY_SEGMENT(En_Horse) -DECLARE_OVERLAY_SEGMENT(En_Arrow) -DECLARE_OVERLAY_SEGMENT(En_Elf) -DECLARE_OVERLAY_SEGMENT(En_Niw) -DECLARE_OVERLAY_SEGMENT(En_Tite) -DECLARE_OVERLAY_SEGMENT(En_Peehat) -DECLARE_OVERLAY_SEGMENT(En_Holl) -DECLARE_OVERLAY_SEGMENT(En_Dinofos) -DECLARE_OVERLAY_SEGMENT(En_Hata) -DECLARE_OVERLAY_SEGMENT(En_Zl1) -DECLARE_OVERLAY_SEGMENT(En_Viewer) -DECLARE_OVERLAY_SEGMENT(En_Bubble) -DECLARE_OVERLAY_SEGMENT(Door_Shutter) -DECLARE_OVERLAY_SEGMENT(En_Boom) -DECLARE_OVERLAY_SEGMENT(En_Torch2) -DECLARE_OVERLAY_SEGMENT(En_Minifrog) -DECLARE_OVERLAY_SEGMENT(En_St) -DECLARE_OVERLAY_SEGMENT(Obj_Wturn) -DECLARE_OVERLAY_SEGMENT(En_River_Sound) -DECLARE_OVERLAY_SEGMENT(En_Ossan) -DECLARE_OVERLAY_SEGMENT(En_Famos) -DECLARE_OVERLAY_SEGMENT(En_Bombf) -DECLARE_OVERLAY_SEGMENT(En_Am) -DECLARE_OVERLAY_SEGMENT(En_Dekubaba) -DECLARE_OVERLAY_SEGMENT(En_M_Fire1) -DECLARE_OVERLAY_SEGMENT(En_M_Thunder) -DECLARE_OVERLAY_SEGMENT(Bg_Breakwall) -DECLARE_OVERLAY_SEGMENT(Door_Warp1) -DECLARE_OVERLAY_SEGMENT(Obj_Syokudai) -DECLARE_OVERLAY_SEGMENT(Item_B_Heart) -DECLARE_OVERLAY_SEGMENT(En_Dekunuts) -DECLARE_OVERLAY_SEGMENT(En_Bbfall) -DECLARE_OVERLAY_SEGMENT(Arms_Hook) -DECLARE_OVERLAY_SEGMENT(En_Bb) -DECLARE_OVERLAY_SEGMENT(Bg_Keikoku_Spr) -DECLARE_OVERLAY_SEGMENT(En_Wood02) -DECLARE_OVERLAY_SEGMENT(En_Death) -DECLARE_OVERLAY_SEGMENT(En_Minideath) -DECLARE_OVERLAY_SEGMENT(En_Vm) -DECLARE_OVERLAY_SEGMENT(Demo_Effect) -DECLARE_OVERLAY_SEGMENT(Demo_Kankyo) -DECLARE_OVERLAY_SEGMENT(En_Floormas) -DECLARE_OVERLAY_SEGMENT(En_Rd) -DECLARE_OVERLAY_SEGMENT(Bg_F40_Flift) -DECLARE_OVERLAY_SEGMENT(Obj_Mure) -DECLARE_OVERLAY_SEGMENT(En_Sw) -DECLARE_OVERLAY_SEGMENT(Object_Kankyo) -DECLARE_OVERLAY_SEGMENT(En_Horse_Link_Child) -DECLARE_OVERLAY_SEGMENT(Door_Ana) -DECLARE_OVERLAY_SEGMENT(En_Encount1) -DECLARE_OVERLAY_SEGMENT(Demo_Tre_Lgt) -DECLARE_OVERLAY_SEGMENT(En_Encount2) -DECLARE_OVERLAY_SEGMENT(En_Fire_Rock) -DECLARE_OVERLAY_SEGMENT(Bg_Ctower_Rot) -DECLARE_OVERLAY_SEGMENT(Mir_Ray) -DECLARE_OVERLAY_SEGMENT(En_Sb) -DECLARE_OVERLAY_SEGMENT(En_Bigslime) -DECLARE_OVERLAY_SEGMENT(En_Karebaba) -DECLARE_OVERLAY_SEGMENT(En_In) -DECLARE_OVERLAY_SEGMENT(En_Bom_Chu) -DECLARE_OVERLAY_SEGMENT(En_Horse_Game_Check) -DECLARE_OVERLAY_SEGMENT(En_Rr) -DECLARE_OVERLAY_SEGMENT(En_Fr) -DECLARE_OVERLAY_SEGMENT(En_Fishing) -DECLARE_OVERLAY_SEGMENT(Obj_Oshihiki) -DECLARE_OVERLAY_SEGMENT(Eff_Dust) -DECLARE_OVERLAY_SEGMENT(Bg_Umajump) -DECLARE_OVERLAY_SEGMENT(En_Insect) -DECLARE_OVERLAY_SEGMENT(En_Butte) -DECLARE_OVERLAY_SEGMENT(En_Fish) -DECLARE_OVERLAY_SEGMENT(Item_Etcetera) -DECLARE_OVERLAY_SEGMENT(Arrow_Fire) -DECLARE_OVERLAY_SEGMENT(Arrow_Ice) -DECLARE_OVERLAY_SEGMENT(Arrow_Light) -DECLARE_OVERLAY_SEGMENT(Obj_Kibako) -DECLARE_OVERLAY_SEGMENT(Obj_Tsubo) -DECLARE_OVERLAY_SEGMENT(En_Ik) -DECLARE_OVERLAY_SEGMENT(Demo_Shd) -DECLARE_OVERLAY_SEGMENT(En_Dns) -DECLARE_OVERLAY_SEGMENT(Elf_Msg) -DECLARE_OVERLAY_SEGMENT(En_Honotrap) -DECLARE_OVERLAY_SEGMENT(En_Tubo_Trap) -DECLARE_OVERLAY_SEGMENT(Obj_Ice_Poly) -DECLARE_OVERLAY_SEGMENT(En_Fz) -DECLARE_OVERLAY_SEGMENT(En_Kusa) -DECLARE_OVERLAY_SEGMENT(Obj_Bean) -DECLARE_OVERLAY_SEGMENT(Obj_Bombiwa) -DECLARE_OVERLAY_SEGMENT(Obj_Switch) -DECLARE_OVERLAY_SEGMENT(Obj_Lift) -DECLARE_OVERLAY_SEGMENT(Obj_Hsblock) -DECLARE_OVERLAY_SEGMENT(En_Okarina_Tag) -DECLARE_OVERLAY_SEGMENT(En_Goroiwa) -DECLARE_OVERLAY_SEGMENT(En_Daiku) -DECLARE_OVERLAY_SEGMENT(En_Nwc) -DECLARE_OVERLAY_SEGMENT(Item_Inbox) -DECLARE_OVERLAY_SEGMENT(En_Ge1) -DECLARE_OVERLAY_SEGMENT(Obj_Blockstop) -DECLARE_OVERLAY_SEGMENT(En_Sda) -DECLARE_OVERLAY_SEGMENT(En_Clear_Tag) -DECLARE_OVERLAY_SEGMENT(En_Gm) -DECLARE_OVERLAY_SEGMENT(En_Ms) -DECLARE_OVERLAY_SEGMENT(En_Hs) -DECLARE_OVERLAY_SEGMENT(Bg_Ingate) -DECLARE_OVERLAY_SEGMENT(En_Kanban) -DECLARE_OVERLAY_SEGMENT(En_Attack_Niw) -DECLARE_OVERLAY_SEGMENT(En_Mk) -DECLARE_OVERLAY_SEGMENT(En_Owl) -DECLARE_OVERLAY_SEGMENT(En_Ishi) -DECLARE_OVERLAY_SEGMENT(Obj_Hana) -DECLARE_OVERLAY_SEGMENT(Obj_Lightswitch) -DECLARE_OVERLAY_SEGMENT(Obj_Mure2) -DECLARE_OVERLAY_SEGMENT(En_Fu) -DECLARE_OVERLAY_SEGMENT(En_Stream) -DECLARE_OVERLAY_SEGMENT(En_Mm) -DECLARE_OVERLAY_SEGMENT(En_Weather_Tag) -DECLARE_OVERLAY_SEGMENT(En_Ani) -DECLARE_OVERLAY_SEGMENT(En_Js) -DECLARE_OVERLAY_SEGMENT(En_Okarina_Effect) -DECLARE_OVERLAY_SEGMENT(En_Mag) -DECLARE_OVERLAY_SEGMENT(Elf_Msg2) -DECLARE_OVERLAY_SEGMENT(Bg_F40_Swlift) -DECLARE_OVERLAY_SEGMENT(En_Kakasi) -DECLARE_OVERLAY_SEGMENT(Obj_Makeoshihiki) -DECLARE_OVERLAY_SEGMENT(Oceff_Spot) -DECLARE_OVERLAY_SEGMENT(En_Torch) -DECLARE_OVERLAY_SEGMENT(Shot_Sun) -DECLARE_OVERLAY_SEGMENT(Obj_Roomtimer) -DECLARE_OVERLAY_SEGMENT(En_Ssh) -DECLARE_OVERLAY_SEGMENT(Oceff_Wipe) +#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName) DECLARE_OVERLAY_SEGMENT(name) +#define DEFINE_ACTOR_INTERNAL(_name, _enumValue, _allocType, _debugName) +#define DEFINE_ACTOR_UNSET(_enumValue) + +#include "tables/actor_table.h" + +#undef DEFINE_ACTOR +#undef DEFINE_ACTOR_INTERNAL +#undef DEFINE_ACTOR_UNSET + DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dust) DECLARE_OVERLAY_SEGMENT(Effect_Ss_Kirakira) DECLARE_OVERLAY_SEGMENT(Effect_Ss_Bomb2) @@ -246,446 +117,14 @@ DECLARE_OVERLAY_SEGMENT(Effect_Ss_Extra) DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dead_Db) DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dead_Dd) DECLARE_OVERLAY_SEGMENT(Effect_Ss_Dead_Ds) -DECLARE_OVERLAY_SEGMENT(Oceff_Storm) -DECLARE_OVERLAY_SEGMENT(Obj_Demo) -DECLARE_OVERLAY_SEGMENT(En_Minislime) -DECLARE_OVERLAY_SEGMENT(En_Nutsball) -DECLARE_OVERLAY_SEGMENT(Oceff_Wipe2) -DECLARE_OVERLAY_SEGMENT(Oceff_Wipe3) -DECLARE_OVERLAY_SEGMENT(En_Dg) -DECLARE_OVERLAY_SEGMENT(En_Si) -DECLARE_OVERLAY_SEGMENT(Obj_Comb) -DECLARE_OVERLAY_SEGMENT(Obj_Kibako2) -DECLARE_OVERLAY_SEGMENT(En_Hs2) -DECLARE_OVERLAY_SEGMENT(Obj_Mure3) -DECLARE_OVERLAY_SEGMENT(En_Tg) -DECLARE_OVERLAY_SEGMENT(En_Wf) -DECLARE_OVERLAY_SEGMENT(En_Skb) -DECLARE_OVERLAY_SEGMENT(En_Gs) -DECLARE_OVERLAY_SEGMENT(Obj_Sound) -DECLARE_OVERLAY_SEGMENT(En_Crow) -DECLARE_OVERLAY_SEGMENT(En_Cow) -DECLARE_OVERLAY_SEGMENT(Oceff_Wipe4) -DECLARE_OVERLAY_SEGMENT(En_Zo) DECLARE_OVERLAY_SEGMENT(Effect_Ss_Ice_Smoke) -DECLARE_OVERLAY_SEGMENT(Obj_Makekinsuta) -DECLARE_OVERLAY_SEGMENT(En_Ge3) -DECLARE_OVERLAY_SEGMENT(Obj_Hamishi) -DECLARE_OVERLAY_SEGMENT(En_Zl4) -DECLARE_OVERLAY_SEGMENT(En_Mm2) -DECLARE_OVERLAY_SEGMENT(Door_Spiral) -DECLARE_OVERLAY_SEGMENT(Obj_Pzlblock) -DECLARE_OVERLAY_SEGMENT(Obj_Toge) -DECLARE_OVERLAY_SEGMENT(Obj_Armos) -DECLARE_OVERLAY_SEGMENT(Obj_Boyo) -DECLARE_OVERLAY_SEGMENT(En_Grasshopper) -DECLARE_OVERLAY_SEGMENT(Obj_Grass) -DECLARE_OVERLAY_SEGMENT(Obj_Grass_Carry) -DECLARE_OVERLAY_SEGMENT(Obj_Grass_Unit) -DECLARE_OVERLAY_SEGMENT(Bg_Fire_Wall) -DECLARE_OVERLAY_SEGMENT(En_Bu) -DECLARE_OVERLAY_SEGMENT(En_Encount3) -DECLARE_OVERLAY_SEGMENT(En_Jso) -DECLARE_OVERLAY_SEGMENT(Obj_Chikuwa) -DECLARE_OVERLAY_SEGMENT(En_Knight) -DECLARE_OVERLAY_SEGMENT(En_Warp_tag) -DECLARE_OVERLAY_SEGMENT(En_Aob_01) -DECLARE_OVERLAY_SEGMENT(En_Boj_01) -DECLARE_OVERLAY_SEGMENT(En_Boj_02) -DECLARE_OVERLAY_SEGMENT(En_Boj_03) -DECLARE_OVERLAY_SEGMENT(En_Encount4) -DECLARE_OVERLAY_SEGMENT(En_Bom_Bowl_Man) -DECLARE_OVERLAY_SEGMENT(En_Syateki_Man) -DECLARE_OVERLAY_SEGMENT(Bg_Icicle) -DECLARE_OVERLAY_SEGMENT(En_Syateki_Crow) -DECLARE_OVERLAY_SEGMENT(En_Boj_04) -DECLARE_OVERLAY_SEGMENT(En_Cne_01) -DECLARE_OVERLAY_SEGMENT(En_Bba_01) -DECLARE_OVERLAY_SEGMENT(En_Bji_01) -DECLARE_OVERLAY_SEGMENT(Bg_Spdweb) -DECLARE_OVERLAY_SEGMENT(En_Mt_tag) -DECLARE_OVERLAY_SEGMENT(Boss_01) -DECLARE_OVERLAY_SEGMENT(Boss_02) -DECLARE_OVERLAY_SEGMENT(Boss_03) -DECLARE_OVERLAY_SEGMENT(Boss_04) -DECLARE_OVERLAY_SEGMENT(Boss_05) -DECLARE_OVERLAY_SEGMENT(Boss_06) -DECLARE_OVERLAY_SEGMENT(Boss_07) -DECLARE_OVERLAY_SEGMENT(Bg_Dy_Yoseizo) -DECLARE_OVERLAY_SEGMENT(En_Boj_05) -DECLARE_OVERLAY_SEGMENT(En_Sob1) -DECLARE_OVERLAY_SEGMENT(En_Go) -DECLARE_OVERLAY_SEGMENT(En_Raf) -DECLARE_OVERLAY_SEGMENT(Obj_Funen) -DECLARE_OVERLAY_SEGMENT(Obj_Raillift) -DECLARE_OVERLAY_SEGMENT(Bg_Numa_Hana) -DECLARE_OVERLAY_SEGMENT(Obj_Flowerpot) -DECLARE_OVERLAY_SEGMENT(Obj_Spinyroll) -DECLARE_OVERLAY_SEGMENT(Dm_Hina) -DECLARE_OVERLAY_SEGMENT(En_Syateki_Wf) -DECLARE_OVERLAY_SEGMENT(Obj_Skateblock) DECLARE_OVERLAY_SEGMENT(Effect_En_Ice_Block) -DECLARE_OVERLAY_SEGMENT(Obj_Iceblock) -DECLARE_OVERLAY_SEGMENT(En_Bigpamet) -DECLARE_OVERLAY_SEGMENT(Bg_Dblue_Movebg) -DECLARE_OVERLAY_SEGMENT(En_Syateki_Dekunuts) -DECLARE_OVERLAY_SEGMENT(Elf_Msg3) -DECLARE_OVERLAY_SEGMENT(En_Fg) -DECLARE_OVERLAY_SEGMENT(Dm_Ravine) -DECLARE_OVERLAY_SEGMENT(Dm_Sa) -DECLARE_OVERLAY_SEGMENT(En_Slime) -DECLARE_OVERLAY_SEGMENT(En_Pr) -DECLARE_OVERLAY_SEGMENT(Obj_Toudai) -DECLARE_OVERLAY_SEGMENT(Obj_Entotu) -DECLARE_OVERLAY_SEGMENT(Obj_Bell) -DECLARE_OVERLAY_SEGMENT(En_Syateki_Okuta) -DECLARE_OVERLAY_SEGMENT(Obj_Shutter) -DECLARE_OVERLAY_SEGMENT(Dm_Zl) -DECLARE_OVERLAY_SEGMENT(En_Ru) -DECLARE_OVERLAY_SEGMENT(En_Elfgrp) -DECLARE_OVERLAY_SEGMENT(Dm_Tsg) -DECLARE_OVERLAY_SEGMENT(En_Baguo) -DECLARE_OVERLAY_SEGMENT(Obj_Vspinyroll) -DECLARE_OVERLAY_SEGMENT(Obj_Smork) -DECLARE_OVERLAY_SEGMENT(En_Test2) -DECLARE_OVERLAY_SEGMENT(En_Test3) -DECLARE_OVERLAY_SEGMENT(En_Test4) -DECLARE_OVERLAY_SEGMENT(En_Bat) -DECLARE_OVERLAY_SEGMENT(En_Sekihi) -DECLARE_OVERLAY_SEGMENT(En_Wiz) -DECLARE_OVERLAY_SEGMENT(En_Wiz_Brock) -DECLARE_OVERLAY_SEGMENT(En_Wiz_Fire) -DECLARE_OVERLAY_SEGMENT(Eff_Change) -DECLARE_OVERLAY_SEGMENT(Dm_Statue) -DECLARE_OVERLAY_SEGMENT(Obj_Fireshield) -DECLARE_OVERLAY_SEGMENT(Bg_Ladder) -DECLARE_OVERLAY_SEGMENT(En_Mkk) -DECLARE_OVERLAY_SEGMENT(Demo_Getitem) -DECLARE_OVERLAY_SEGMENT(En_Dnb) -DECLARE_OVERLAY_SEGMENT(En_Dnh) -DECLARE_OVERLAY_SEGMENT(En_Dnk) -DECLARE_OVERLAY_SEGMENT(En_Dnq) -DECLARE_OVERLAY_SEGMENT(Bg_Keikoku_Saku) -DECLARE_OVERLAY_SEGMENT(Obj_Hugebombiwa) -DECLARE_OVERLAY_SEGMENT(En_Firefly2) -DECLARE_OVERLAY_SEGMENT(En_Rat) -DECLARE_OVERLAY_SEGMENT(En_Water_Effect) -DECLARE_OVERLAY_SEGMENT(En_Kusa2) -DECLARE_OVERLAY_SEGMENT(Bg_Spout_Fire) -DECLARE_OVERLAY_SEGMENT(En_Dy_Extra) -DECLARE_OVERLAY_SEGMENT(En_Bal) -DECLARE_OVERLAY_SEGMENT(En_Ginko_Man) -DECLARE_OVERLAY_SEGMENT(En_Warp_Uzu) -DECLARE_OVERLAY_SEGMENT(Obj_Driftice) -DECLARE_OVERLAY_SEGMENT(En_Look_Nuts) -DECLARE_OVERLAY_SEGMENT(En_Mushi2) -DECLARE_OVERLAY_SEGMENT(En_Fall) -DECLARE_OVERLAY_SEGMENT(En_Mm3) -DECLARE_OVERLAY_SEGMENT(Bg_Crace_Movebg) -DECLARE_OVERLAY_SEGMENT(En_Dno) -DECLARE_OVERLAY_SEGMENT(En_Pr2) -DECLARE_OVERLAY_SEGMENT(En_Prz) -DECLARE_OVERLAY_SEGMENT(En_Jso2) -DECLARE_OVERLAY_SEGMENT(Obj_Etcetera) -DECLARE_OVERLAY_SEGMENT(En_Egol) -DECLARE_OVERLAY_SEGMENT(Obj_Mine) -DECLARE_OVERLAY_SEGMENT(Obj_Purify) -DECLARE_OVERLAY_SEGMENT(En_Tru) -DECLARE_OVERLAY_SEGMENT(En_Trt) -DECLARE_OVERLAY_SEGMENT(En_Test5) -DECLARE_OVERLAY_SEGMENT(En_Test6) -DECLARE_OVERLAY_SEGMENT(En_Az) -DECLARE_OVERLAY_SEGMENT(En_Estone) -DECLARE_OVERLAY_SEGMENT(Bg_Hakugin_Post) -DECLARE_OVERLAY_SEGMENT(Dm_Opstage) -DECLARE_OVERLAY_SEGMENT(Dm_Stk) -DECLARE_OVERLAY_SEGMENT(Dm_Char00) -DECLARE_OVERLAY_SEGMENT(Dm_Char01) -DECLARE_OVERLAY_SEGMENT(Dm_Char02) -DECLARE_OVERLAY_SEGMENT(Dm_Char03) -DECLARE_OVERLAY_SEGMENT(Dm_Char04) -DECLARE_OVERLAY_SEGMENT(Dm_Char05) -DECLARE_OVERLAY_SEGMENT(Dm_Char06) -DECLARE_OVERLAY_SEGMENT(Dm_Char07) -DECLARE_OVERLAY_SEGMENT(Dm_Char08) -DECLARE_OVERLAY_SEGMENT(Dm_Char09) -DECLARE_OVERLAY_SEGMENT(Obj_Tokeidai) -DECLARE_OVERLAY_SEGMENT(En_Mnk) -DECLARE_OVERLAY_SEGMENT(En_Egblock) -DECLARE_OVERLAY_SEGMENT(En_Guard_Nuts) -DECLARE_OVERLAY_SEGMENT(Bg_Hakugin_Bombwall) -DECLARE_OVERLAY_SEGMENT(Obj_Tokei_Tobira) -DECLARE_OVERLAY_SEGMENT(Bg_Hakugin_Elvpole) -DECLARE_OVERLAY_SEGMENT(En_Ma4) -DECLARE_OVERLAY_SEGMENT(En_Twig) -DECLARE_OVERLAY_SEGMENT(En_Po_Fusen) -DECLARE_OVERLAY_SEGMENT(En_Door_Etc) -DECLARE_OVERLAY_SEGMENT(En_Bigokuta) -DECLARE_OVERLAY_SEGMENT(Bg_Icefloe) DECLARE_OVERLAY_SEGMENT(fbdemo_triforce) DECLARE_OVERLAY_SEGMENT(fbdemo_wipe1) DECLARE_OVERLAY_SEGMENT(fbdemo_wipe3) DECLARE_OVERLAY_SEGMENT(fbdemo_wipe4) DECLARE_OVERLAY_SEGMENT(fbdemo_wipe5) DECLARE_OVERLAY_SEGMENT(Effect_Ss_Sbn) -DECLARE_OVERLAY_SEGMENT(Obj_Ocarinalift) -DECLARE_OVERLAY_SEGMENT(En_Time_Tag) -DECLARE_OVERLAY_SEGMENT(Bg_Open_Shutter) -DECLARE_OVERLAY_SEGMENT(Bg_Open_Spot) -DECLARE_OVERLAY_SEGMENT(Bg_Fu_Kaiten) -DECLARE_OVERLAY_SEGMENT(Obj_Aqua) -DECLARE_OVERLAY_SEGMENT(En_Elforg) -DECLARE_OVERLAY_SEGMENT(En_Elfbub) -DECLARE_OVERLAY_SEGMENT(En_Fu_Mato) -DECLARE_OVERLAY_SEGMENT(En_Fu_Kago) -DECLARE_OVERLAY_SEGMENT(En_Osn) -DECLARE_OVERLAY_SEGMENT(Bg_Ctower_Gear) -DECLARE_OVERLAY_SEGMENT(En_Trt2) -DECLARE_OVERLAY_SEGMENT(Obj_Tokei_Step) -DECLARE_OVERLAY_SEGMENT(Bg_Lotus) -DECLARE_OVERLAY_SEGMENT(En_Kame) -DECLARE_OVERLAY_SEGMENT(Obj_Takaraya_Wall) -DECLARE_OVERLAY_SEGMENT(Bg_Fu_Mizu) -DECLARE_OVERLAY_SEGMENT(En_Sellnuts) -DECLARE_OVERLAY_SEGMENT(Bg_Dkjail_Ivy) -DECLARE_OVERLAY_SEGMENT(Obj_Visiblock) -DECLARE_OVERLAY_SEGMENT(En_Takaraya) -DECLARE_OVERLAY_SEGMENT(En_Tsn) -DECLARE_OVERLAY_SEGMENT(En_Ds2n) -DECLARE_OVERLAY_SEGMENT(En_Fsn) -DECLARE_OVERLAY_SEGMENT(En_Shn) -DECLARE_OVERLAY_SEGMENT(En_Stop_heishi) -DECLARE_OVERLAY_SEGMENT(Obj_Bigicicle) -DECLARE_OVERLAY_SEGMENT(En_Lift_Nuts) -DECLARE_OVERLAY_SEGMENT(En_Tk) -DECLARE_OVERLAY_SEGMENT(Bg_Market_Step) -DECLARE_OVERLAY_SEGMENT(Obj_Lupygamelift) -DECLARE_OVERLAY_SEGMENT(En_Test7) -DECLARE_OVERLAY_SEGMENT(Obj_Lightblock) -DECLARE_OVERLAY_SEGMENT(Mir_Ray2) -DECLARE_OVERLAY_SEGMENT(En_Wdhand) -DECLARE_OVERLAY_SEGMENT(En_Gamelupy) -DECLARE_OVERLAY_SEGMENT(Bg_Danpei_Movebg) -DECLARE_OVERLAY_SEGMENT(En_Snowwd) -DECLARE_OVERLAY_SEGMENT(En_Pm) -DECLARE_OVERLAY_SEGMENT(En_Gakufu) -DECLARE_OVERLAY_SEGMENT(Elf_Msg4) -DECLARE_OVERLAY_SEGMENT(Elf_Msg5) -DECLARE_OVERLAY_SEGMENT(En_Col_Man) -DECLARE_OVERLAY_SEGMENT(En_Talk_Gibud) -DECLARE_OVERLAY_SEGMENT(En_Giant) -DECLARE_OVERLAY_SEGMENT(Obj_Snowball) -DECLARE_OVERLAY_SEGMENT(Boss_Hakugin) -DECLARE_OVERLAY_SEGMENT(En_Gb2) -DECLARE_OVERLAY_SEGMENT(En_Onpuman) -DECLARE_OVERLAY_SEGMENT(Bg_Tobira01) -DECLARE_OVERLAY_SEGMENT(En_Tag_Obj) -DECLARE_OVERLAY_SEGMENT(Obj_Dhouse) -DECLARE_OVERLAY_SEGMENT(Obj_Hakaisi) -DECLARE_OVERLAY_SEGMENT(Bg_Hakugin_Switch) -DECLARE_OVERLAY_SEGMENT(En_Snowman) -DECLARE_OVERLAY_SEGMENT(TG_Sw) -DECLARE_OVERLAY_SEGMENT(En_Po_Sisters) -DECLARE_OVERLAY_SEGMENT(En_Pp) -DECLARE_OVERLAY_SEGMENT(En_Hakurock) -DECLARE_OVERLAY_SEGMENT(En_Hanabi) -DECLARE_OVERLAY_SEGMENT(Obj_Dowsing) -DECLARE_OVERLAY_SEGMENT(Obj_Wind) -DECLARE_OVERLAY_SEGMENT(En_Racedog) -DECLARE_OVERLAY_SEGMENT(En_Kendo_Js) -DECLARE_OVERLAY_SEGMENT(Bg_Botihasira) -DECLARE_OVERLAY_SEGMENT(En_Fish2) -DECLARE_OVERLAY_SEGMENT(En_Pst) -DECLARE_OVERLAY_SEGMENT(En_Poh) -DECLARE_OVERLAY_SEGMENT(Obj_Spidertent) -DECLARE_OVERLAY_SEGMENT(En_Zoraegg) -DECLARE_OVERLAY_SEGMENT(En_Kbt) -DECLARE_OVERLAY_SEGMENT(En_Gg) -DECLARE_OVERLAY_SEGMENT(En_Maruta) -DECLARE_OVERLAY_SEGMENT(Obj_Snowball2) -DECLARE_OVERLAY_SEGMENT(En_Gg2) -DECLARE_OVERLAY_SEGMENT(Obj_Ghaka) -DECLARE_OVERLAY_SEGMENT(En_Dnp) -DECLARE_OVERLAY_SEGMENT(En_Dai) -DECLARE_OVERLAY_SEGMENT(Bg_Goron_Oyu) -DECLARE_OVERLAY_SEGMENT(En_Kgy) -DECLARE_OVERLAY_SEGMENT(En_Invadepoh) -DECLARE_OVERLAY_SEGMENT(En_Gk) -DECLARE_OVERLAY_SEGMENT(En_An) -DECLARE_OVERLAY_SEGMENT(En_Bee) -DECLARE_OVERLAY_SEGMENT(En_Ot) -DECLARE_OVERLAY_SEGMENT(En_Dragon) -DECLARE_OVERLAY_SEGMENT(Obj_Dora) -DECLARE_OVERLAY_SEGMENT(En_Bigpo) -DECLARE_OVERLAY_SEGMENT(Obj_Kendo_Kanban) -DECLARE_OVERLAY_SEGMENT(Obj_Hariko) -DECLARE_OVERLAY_SEGMENT(En_Sth) -DECLARE_OVERLAY_SEGMENT(Bg_Sinkai_Kabe) -DECLARE_OVERLAY_SEGMENT(Bg_Haka_Curtain) -DECLARE_OVERLAY_SEGMENT(Bg_Kin2_Bombwall) -DECLARE_OVERLAY_SEGMENT(Bg_Kin2_Fence) -DECLARE_OVERLAY_SEGMENT(Bg_Kin2_Picture) -DECLARE_OVERLAY_SEGMENT(Bg_Kin2_Shelf) -DECLARE_OVERLAY_SEGMENT(En_Rail_Skb) -DECLARE_OVERLAY_SEGMENT(En_Jg) -DECLARE_OVERLAY_SEGMENT(En_Tru_Mt) -DECLARE_OVERLAY_SEGMENT(Obj_Um) -DECLARE_OVERLAY_SEGMENT(En_Neo_Reeba) -DECLARE_OVERLAY_SEGMENT(Bg_Mbar_Chair) -DECLARE_OVERLAY_SEGMENT(Bg_Ikana_Block) -DECLARE_OVERLAY_SEGMENT(Bg_Ikana_Mirror) -DECLARE_OVERLAY_SEGMENT(Bg_Ikana_Rotaryroom) -DECLARE_OVERLAY_SEGMENT(Bg_Dblue_Balance) -DECLARE_OVERLAY_SEGMENT(Bg_Dblue_Waterfall) -DECLARE_OVERLAY_SEGMENT(En_Kaizoku) -DECLARE_OVERLAY_SEGMENT(En_Ge2) -DECLARE_OVERLAY_SEGMENT(En_Ma_Yts) -DECLARE_OVERLAY_SEGMENT(En_Ma_Yto) -DECLARE_OVERLAY_SEGMENT(Obj_Tokei_Turret) -DECLARE_OVERLAY_SEGMENT(Bg_Dblue_Elevator) -DECLARE_OVERLAY_SEGMENT(Obj_Warpstone) -DECLARE_OVERLAY_SEGMENT(En_Zog) -DECLARE_OVERLAY_SEGMENT(Obj_Rotlift) -DECLARE_OVERLAY_SEGMENT(Obj_Jg_Gakki) -DECLARE_OVERLAY_SEGMENT(Bg_Inibs_Movebg) -DECLARE_OVERLAY_SEGMENT(En_Zot) -DECLARE_OVERLAY_SEGMENT(Obj_Tree) -DECLARE_OVERLAY_SEGMENT(Obj_Y2lift) -DECLARE_OVERLAY_SEGMENT(Obj_Y2shutter) -DECLARE_OVERLAY_SEGMENT(Obj_Boat) -DECLARE_OVERLAY_SEGMENT(Obj_Taru) -DECLARE_OVERLAY_SEGMENT(Obj_Hunsui) -DECLARE_OVERLAY_SEGMENT(En_Jc_Mato) -DECLARE_OVERLAY_SEGMENT(Mir_Ray3) -DECLARE_OVERLAY_SEGMENT(En_Zob) -DECLARE_OVERLAY_SEGMENT(Elf_Msg6) -DECLARE_OVERLAY_SEGMENT(Obj_Nozoki) -DECLARE_OVERLAY_SEGMENT(En_Toto) -DECLARE_OVERLAY_SEGMENT(En_Railgibud) -DECLARE_OVERLAY_SEGMENT(En_Baba) -DECLARE_OVERLAY_SEGMENT(En_Suttari) -DECLARE_OVERLAY_SEGMENT(En_Zod) -DECLARE_OVERLAY_SEGMENT(En_Kujiya) -DECLARE_OVERLAY_SEGMENT(En_Geg) -DECLARE_OVERLAY_SEGMENT(Obj_Kinoko) -DECLARE_OVERLAY_SEGMENT(Obj_Yasi) -DECLARE_OVERLAY_SEGMENT(En_Tanron1) -DECLARE_OVERLAY_SEGMENT(En_Tanron2) -DECLARE_OVERLAY_SEGMENT(En_Tanron3) -DECLARE_OVERLAY_SEGMENT(Obj_Chan) -DECLARE_OVERLAY_SEGMENT(En_Zos) -DECLARE_OVERLAY_SEGMENT(En_S_Goro) -DECLARE_OVERLAY_SEGMENT(En_Nb) -DECLARE_OVERLAY_SEGMENT(En_Ja) -DECLARE_OVERLAY_SEGMENT(Bg_F40_Block) -DECLARE_OVERLAY_SEGMENT(Bg_F40_Switch) -DECLARE_OVERLAY_SEGMENT(En_Po_Composer) -DECLARE_OVERLAY_SEGMENT(En_Guruguru) -DECLARE_OVERLAY_SEGMENT(Oceff_Wipe5) -DECLARE_OVERLAY_SEGMENT(En_Stone_heishi) -DECLARE_OVERLAY_SEGMENT(Oceff_Wipe6) -DECLARE_OVERLAY_SEGMENT(En_Scopenuts) -DECLARE_OVERLAY_SEGMENT(En_Scopecrow) -DECLARE_OVERLAY_SEGMENT(Oceff_Wipe7) -DECLARE_OVERLAY_SEGMENT(Eff_Kamejima_Wave) -DECLARE_OVERLAY_SEGMENT(En_Hg) -DECLARE_OVERLAY_SEGMENT(En_Hgo) -DECLARE_OVERLAY_SEGMENT(En_Zov) -DECLARE_OVERLAY_SEGMENT(En_Ah) -DECLARE_OVERLAY_SEGMENT(Obj_Hgdoor) -DECLARE_OVERLAY_SEGMENT(Bg_Ikana_Bombwall) -DECLARE_OVERLAY_SEGMENT(Bg_Ikana_Ray) -DECLARE_OVERLAY_SEGMENT(Bg_Ikana_Shutter) -DECLARE_OVERLAY_SEGMENT(Bg_Haka_Bombwall) -DECLARE_OVERLAY_SEGMENT(Bg_Haka_Tomb) -DECLARE_OVERLAY_SEGMENT(En_Sc_Ruppe) -DECLARE_OVERLAY_SEGMENT(Bg_Iknv_Doukutu) -DECLARE_OVERLAY_SEGMENT(Bg_Iknv_Obj) -DECLARE_OVERLAY_SEGMENT(En_Pamera) -DECLARE_OVERLAY_SEGMENT(Obj_HsStump) -DECLARE_OVERLAY_SEGMENT(En_Hidden_Nuts) -DECLARE_OVERLAY_SEGMENT(En_Zow) -DECLARE_OVERLAY_SEGMENT(En_Talk) -DECLARE_OVERLAY_SEGMENT(En_Al) -DECLARE_OVERLAY_SEGMENT(En_Tab) -DECLARE_OVERLAY_SEGMENT(En_Nimotsu) -DECLARE_OVERLAY_SEGMENT(En_Hit_Tag) -DECLARE_OVERLAY_SEGMENT(En_Ruppecrow) -DECLARE_OVERLAY_SEGMENT(En_Tanron4) -DECLARE_OVERLAY_SEGMENT(En_Tanron5) -DECLARE_OVERLAY_SEGMENT(En_Tanron6) -DECLARE_OVERLAY_SEGMENT(En_Daiku2) -DECLARE_OVERLAY_SEGMENT(En_Muto) -DECLARE_OVERLAY_SEGMENT(En_Baisen) -DECLARE_OVERLAY_SEGMENT(En_Heishi) -DECLARE_OVERLAY_SEGMENT(En_Demo_heishi) -DECLARE_OVERLAY_SEGMENT(En_Dt) -DECLARE_OVERLAY_SEGMENT(En_Cha) -DECLARE_OVERLAY_SEGMENT(Obj_Dinner) -DECLARE_OVERLAY_SEGMENT(Eff_Lastday) -DECLARE_OVERLAY_SEGMENT(Bg_Ikana_Dharma) -DECLARE_OVERLAY_SEGMENT(En_Akindonuts) -DECLARE_OVERLAY_SEGMENT(Eff_Stk) -DECLARE_OVERLAY_SEGMENT(En_Ig) -DECLARE_OVERLAY_SEGMENT(En_Rg) -DECLARE_OVERLAY_SEGMENT(En_Osk) -DECLARE_OVERLAY_SEGMENT(En_Sth2) -DECLARE_OVERLAY_SEGMENT(En_Yb) -DECLARE_OVERLAY_SEGMENT(En_Rz) -DECLARE_OVERLAY_SEGMENT(En_Scopecoin) -DECLARE_OVERLAY_SEGMENT(En_Bjt) -DECLARE_OVERLAY_SEGMENT(En_Bomjima) -DECLARE_OVERLAY_SEGMENT(En_Bomjimb) -DECLARE_OVERLAY_SEGMENT(En_Bombers) -DECLARE_OVERLAY_SEGMENT(En_Bombers2) -DECLARE_OVERLAY_SEGMENT(En_Bombal) -DECLARE_OVERLAY_SEGMENT(Obj_Moon_Stone) -DECLARE_OVERLAY_SEGMENT(Obj_Mu_Pict) -DECLARE_OVERLAY_SEGMENT(Bg_Ikninside) -DECLARE_OVERLAY_SEGMENT(Eff_Zoraband) -DECLARE_OVERLAY_SEGMENT(Obj_Kepn_Koya) -DECLARE_OVERLAY_SEGMENT(Obj_Usiyane) -DECLARE_OVERLAY_SEGMENT(En_Nnh) -DECLARE_OVERLAY_SEGMENT(Obj_Kzsaku) -DECLARE_OVERLAY_SEGMENT(Obj_Milk_Bin) -DECLARE_OVERLAY_SEGMENT(En_Kitan) -DECLARE_OVERLAY_SEGMENT(Bg_Astr_Bombwall) -DECLARE_OVERLAY_SEGMENT(Bg_Iknin_Susceil) -DECLARE_OVERLAY_SEGMENT(En_Bsb) -DECLARE_OVERLAY_SEGMENT(En_Recepgirl) -DECLARE_OVERLAY_SEGMENT(En_Thiefbird) -DECLARE_OVERLAY_SEGMENT(En_Jgame_Tsn) -DECLARE_OVERLAY_SEGMENT(Obj_Jgame_Light) -DECLARE_OVERLAY_SEGMENT(Obj_Yado) -DECLARE_OVERLAY_SEGMENT(Demo_Syoten) -DECLARE_OVERLAY_SEGMENT(Demo_Moonend) -DECLARE_OVERLAY_SEGMENT(Bg_Lbfshot) -DECLARE_OVERLAY_SEGMENT(Bg_Last_Bwall) -DECLARE_OVERLAY_SEGMENT(En_And) -DECLARE_OVERLAY_SEGMENT(En_Invadepoh_Demo) -DECLARE_OVERLAY_SEGMENT(Obj_Danpeilift) -DECLARE_OVERLAY_SEGMENT(En_Fall2) -DECLARE_OVERLAY_SEGMENT(Dm_Al) -DECLARE_OVERLAY_SEGMENT(Dm_An) -DECLARE_OVERLAY_SEGMENT(Dm_Ah) -DECLARE_OVERLAY_SEGMENT(Dm_Nb) -DECLARE_OVERLAY_SEGMENT(En_Drs) -DECLARE_OVERLAY_SEGMENT(En_Ending_Hero) -DECLARE_OVERLAY_SEGMENT(Dm_Bal) -DECLARE_OVERLAY_SEGMENT(En_Paper) -DECLARE_OVERLAY_SEGMENT(En_Hint_Skb) -DECLARE_OVERLAY_SEGMENT(Dm_Tag) -DECLARE_OVERLAY_SEGMENT(En_Bh) -DECLARE_OVERLAY_SEGMENT(En_Ending_Hero2) -DECLARE_OVERLAY_SEGMENT(En_Ending_Hero3) -DECLARE_OVERLAY_SEGMENT(En_Ending_Hero4) -DECLARE_OVERLAY_SEGMENT(En_Ending_Hero5) -DECLARE_OVERLAY_SEGMENT(En_Ending_Hero6) -DECLARE_OVERLAY_SEGMENT(Dm_Gm) -DECLARE_OVERLAY_SEGMENT(Obj_Swprize) -DECLARE_OVERLAY_SEGMENT(En_Invisible_Ruppe) -DECLARE_OVERLAY_SEGMENT(Obj_Ending) -DECLARE_OVERLAY_SEGMENT(En_Rsn) DECLARE_ROM_SEGMENT(gameplay_keep) DECLARE_ROM_SEGMENT(gameplay_field_keep) @@ -922,7 +361,7 @@ DECLARE_ROM_SEGMENT(object_driftice) DECLARE_ROM_SEGMENT(object_fall) DECLARE_ROM_SEGMENT(object_hanareyama_obj) DECLARE_ROM_SEGMENT(object_crace_object) -DECLARE_ROM_SEGMENT(object_dnq) +DECLARE_ROM_SEGMENT(object_dno) DECLARE_ROM_SEGMENT(object_obj_tokeidai) DECLARE_ROM_SEGMENT(object_eg) DECLARE_ROM_SEGMENT(object_tru) @@ -993,7 +432,7 @@ DECLARE_ROM_SEGMENT(object_gg) DECLARE_ROM_SEGMENT(object_maruta) DECLARE_ROM_SEGMENT(object_ghaka) DECLARE_ROM_SEGMENT(object_oyu) -DECLARE_ROM_SEGMENT(object_dnp) +DECLARE_ROM_SEGMENT(object_dnq) DECLARE_ROM_SEGMENT(object_dai) DECLARE_ROM_SEGMENT(object_kgy) DECLARE_ROM_SEGMENT(object_fb) @@ -1014,7 +453,7 @@ DECLARE_ROM_SEGMENT(object_gi_loach) DECLARE_ROM_SEGMENT(object_gi_seahorse) DECLARE_ROM_SEGMENT(object_bigpo) DECLARE_ROM_SEGMENT(object_hariko) -DECLARE_ROM_SEGMENT(object_dno) +DECLARE_ROM_SEGMENT(object_dnj) DECLARE_ROM_SEGMENT(object_sinkai_kabe) DECLARE_ROM_SEGMENT(object_kin2_obj) DECLARE_ROM_SEGMENT(object_ishi) diff --git a/include/sequence.h b/include/sequence.h index d46e96aea..857609d4b 100644 --- a/include/sequence.h +++ b/include/sequence.h @@ -4,7 +4,7 @@ #define NA_BGM_STOP 0x100000FF #define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects -#define NA_BGM_NATURE_AMBIENCE 0x01 // Ambient background noises +#define NA_BGM_AMBIENCE 0x01 // Ambient background noises #define NA_BGM_TERMINA_FIELD 0x02 // Termina Field #define NA_BGM_CHASE 0x03 // Forest Chase #define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" @@ -40,7 +40,7 @@ #define NA_BGM_GET_ITEM 0x22 // Item Catch #define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT #define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_TIMED_MINI_GAME 0x25 // Playing a timed Minigame #define NA_BGM_GORON_RACE 0x26 // Goron Race #define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" #define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" @@ -134,11 +134,12 @@ #define NA_BGM_DISABLED 0xFFFF typedef enum { - /* 0 */ SEQ_PLAYER_BGM_MAIN, - /* 1 */ SEQ_PLAYER_FANFARE, - /* 2 */ SEQ_PLAYER_SFX, - /* 3 */ SEQ_PLAYER_BGM_SUB, - /* 4 */ SEQ_PLAYER_NATURE + /* 0 */ SEQ_PLAYER_BGM_MAIN, + /* 1 */ SEQ_PLAYER_FANFARE, + /* 2 */ SEQ_PLAYER_SFX, + /* 3 */ SEQ_PLAYER_BGM_SUB, + /* 4 */ SEQ_PLAYER_AMBIENCE, + /* 0xFF */ SEQ_PLAYER_INVALID = 0xFF } SequencePlayerId; typedef enum { @@ -160,119 +161,120 @@ typedef enum { } ChannelIOPort; typedef enum { - /* 0x0 */ NATURE_CHANNEL_STREAM_0, - /* 0x1 */ NATURE_CHANNEL_CRITTER_0, - /* 0x2 */ NATURE_CHANNEL_CRITTER_1, - /* 0x3 */ NATURE_CHANNEL_CRITTER_2, - /* 0x4 */ NATURE_CHANNEL_CRITTER_3, - /* 0x5 */ NATURE_CHANNEL_CRITTER_4, - /* 0x6 */ NATURE_CHANNEL_CRITTER_5, - /* 0x7 */ NATURE_CHANNEL_CRITTER_6, - /* 0x8 */ NATURE_CHANNEL_CRITTER_7, - /* 0xC */ NATURE_CHANNEL_STREAM_1 = 12, - /* 0xD */ NATURE_CHANNEL_UNK, - /* 0xE */ NATURE_CHANNEL_RAIN, - /* 0xF */ NATURE_CHANNEL_LIGHTNING -} NatureChannelIdx; // playerIdx = 4 + /* 0x0 */ AMBIENCE_CHANNEL_STREAM_0, + /* 0x1 */ AMBIENCE_CHANNEL_CRITTER_0, + /* 0x2 */ AMBIENCE_CHANNEL_CRITTER_1, + /* 0x3 */ AMBIENCE_CHANNEL_CRITTER_2, + /* 0x4 */ AMBIENCE_CHANNEL_CRITTER_3, + /* 0x5 */ AMBIENCE_CHANNEL_CRITTER_4, + /* 0x6 */ AMBIENCE_CHANNEL_CRITTER_5, + /* 0x7 */ AMBIENCE_CHANNEL_CRITTER_6, + /* 0x8 */ AMBIENCE_CHANNEL_CRITTER_7, + /* 0xC */ AMBIENCE_CHANNEL_STREAM_1 = 12, + /* 0xD */ AMBIENCE_CHANNEL_SOUND_MODE, + /* 0xE */ AMBIENCE_CHANNEL_RAIN, + /* 0xF */ AMBIENCE_CHANNEL_LIGHTNING +} AmbienceChannelIndex; // playerIndex = SEQ_PLAYER_AMBIENCE typedef enum { - /* 0x00 */ NATURE_AMBIENCE_0, - /* 0x01 */ NATURE_AMBIENCE_1, - /* 0x02 */ NATURE_AMBIENCE_2, - /* 0x03 */ NATURE_AMBIENCE_3, - /* 0x04 */ NATURE_AMBIENCE_4, - /* 0x05 */ NATURE_AMBIENCE_5, - /* 0x06 */ NATURE_AMBIENCE_6, - /* 0x07 */ NATURE_AMBIENCE_7, - /* 0x08 */ NATURE_AMBIENCE_8, - /* 0x09 */ NATURE_AMBIENCE_9, - /* 0x0A */ NATURE_AMBIENCE_A, - /* 0x0B */ NATURE_AMBIENCE_B, - /* 0x0C */ NATURE_AMBIENCE_C, - /* 0x0D */ NATURE_AMBIENCE_D, - /* 0x0E */ NATURE_AMBIENCE_E, - /* 0x0F */ NATURE_AMBIENCE_F, - /* 0x10 */ NATURE_AMBIENCE_10, - /* 0x11 */ NATURE_AMBIENCE_11, - /* 0x12 */ NATURE_AMBIENCE_12, - /* 0x13 */ NATURE_AMBIENCE_13 -} NatureAmbienceId; // playerIdx = 4 + /* 0x00 */ AMBIENCE_ID_00, + /* 0x01 */ AMBIENCE_ID_01, + /* 0x02 */ AMBIENCE_ID_02, + /* 0x03 */ AMBIENCE_ID_03, + /* 0x04 */ AMBIENCE_ID_04, + /* 0x05 */ AMBIENCE_ID_05, + /* 0x06 */ AMBIENCE_ID_06, + /* 0x07 */ AMBIENCE_ID_07, + /* 0x08 */ AMBIENCE_ID_08, + /* 0x09 */ AMBIENCE_ID_09, + /* 0x0A */ AMBIENCE_ID_0A, + /* 0x0B */ AMBIENCE_ID_0B, + /* 0x0C */ AMBIENCE_ID_0C, + /* 0x0D */ AMBIENCE_ID_0D, + /* 0x0E */ AMBIENCE_ID_0E, + /* 0x0F */ AMBIENCE_ID_0F, + /* 0x10 */ AMBIENCE_ID_10, + /* 0x11 */ AMBIENCE_ID_11, + /* 0x12 */ AMBIENCE_ID_12, + /* 0x13 */ AMBIENCE_ID_13, + /* 0xFF */ AMBIENCE_ID_DISABLED = 0xFF +} AmbienceId; // playerIndex = SEQ_PLAYER_AMBIENCE typedef enum { - /* 0x00 */ NATURE_STREAM_0, - /* 0x01 */ NATURE_STREAM_1, - /* 0x02 */ NATURE_STREAM_2, - /* 0x03 */ NATURE_STREAM_3 -} NatureStreamId; + /* 0x00 */ AMBIENCE_STREAM_0, + /* 0x01 */ AMBIENCE_STREAM_1, + /* 0x02 */ AMBIENCE_STREAM_2, + /* 0x03 */ AMBIENCE_STREAM_3 +} AmbienceStreamId; typedef enum { - /* 0x00 */ NATURE_CRITTER_00, - /* 0x01 */ NATURE_CRITTER_01, - /* 0x02 */ NATURE_CRITTER_02, - /* 0x03 */ NATURE_CRITTER_03, - /* 0x04 */ NATURE_CRITTER_04, - /* 0x05 */ NATURE_CRITTER_05, - /* 0x06 */ NATURE_CRITTER_06, - /* 0x07 */ NATURE_CRITTER_07, - /* 0x08 */ NATURE_CRITTER_08, - /* 0x09 */ NATURE_CRITTER_09, - /* 0x0A */ NATURE_CRITTER_10, - /* 0x0B */ NATURE_CRITTER_11, - /* 0x0C */ NATURE_CRITTER_12, - /* 0x0D */ NATURE_CRITTER_13, - /* 0x0E */ NATURE_CRITTER_14, - /* 0x0F */ NATURE_CRITTER_15, - /* 0x10 */ NATURE_CRITTER_16, - /* 0x11 */ NATURE_CRITTER_17, - /* 0x12 */ NATURE_CRITTER_18, - /* 0x13 */ NATURE_CRITTER_19 -} NatureAmimalId; + /* 0x00 */ AMBIENCE_CRITTER_00, + /* 0x01 */ AMBIENCE_CRITTER_01, + /* 0x02 */ AMBIENCE_CRITTER_02, + /* 0x03 */ AMBIENCE_CRITTER_03, + /* 0x04 */ AMBIENCE_CRITTER_04, + /* 0x05 */ AMBIENCE_CRITTER_05, + /* 0x06 */ AMBIENCE_CRITTER_06, + /* 0x07 */ AMBIENCE_CRITTER_07, + /* 0x08 */ AMBIENCE_CRITTER_08, + /* 0x09 */ AMBIENCE_CRITTER_09, + /* 0x0A */ AMBIENCE_CRITTER_10, + /* 0x0B */ AMBIENCE_CRITTER_11, + /* 0x0C */ AMBIENCE_CRITTER_12, + /* 0x0D */ AMBIENCE_CRITTER_13, + /* 0x0E */ AMBIENCE_CRITTER_14, + /* 0x0F */ AMBIENCE_CRITTER_15, + /* 0x10 */ AMBIENCE_CRITTER_16, + /* 0x11 */ AMBIENCE_CRITTER_17, + /* 0x12 */ AMBIENCE_CRITTER_18, + /* 0x13 */ AMBIENCE_CRITTER_19 +} AmbienceCritterId; -#define NATURE_IO_CRITTER_0_TYPE(type) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_0_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_0_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_0_PORT5(reverb) NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_0_TYPE(type) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_0_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_0_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_0_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_1_TYPE(type) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_1_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_1_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_1_PORT5(reverb) NATURE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_1_TYPE(type) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_1_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_1_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_1_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_1, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_2_TYPE(type) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_2_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_2_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_2_PORT5(reverb) NATURE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_2_TYPE(type) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_2_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_2_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_2_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_2, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_3_TYPE(type) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_3_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_3_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_3_PORT5(reverb) NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_3_TYPE(type) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_3_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_3_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_3_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_4_TYPE(type) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_4_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_4_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_4_PORT5(reverb) NATURE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_4_TYPE(type) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_4_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_4_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_4_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_4, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_5_TYPE(type) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_5_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_5_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_5_PORT5(reverb) NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_5_TYPE(type) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_5_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_5_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_5_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_CRITTER_6_TYPE(type) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_2, type -#define NATURE_IO_CRITTER_6_BEND_PITCH(bend) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_3, bend -#define NATURE_IO_CRITTER_6_NUM_LAYERS(num) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_4, num -#define NATURE_IO_CRITTER_6_PORT5(reverb) NATURE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_5, reverb +#define AMBIENCE_IO_CRITTER_6_TYPE(type) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_CRITTER_6_BEND_PITCH(bend) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_3, bend +#define AMBIENCE_IO_CRITTER_6_NUM_LAYERS(num) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_4, num +#define AMBIENCE_IO_CRITTER_6_PORT5(reverb) AMBIENCE_CHANNEL_CRITTER_6, CHANNEL_IO_PORT_5, reverb -#define NATURE_IO_STREAM_0_TYPE(type) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_2, type -#define NATURE_IO_STREAM_0_PORT3(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_3, data -#define NATURE_IO_STREAM_0_PORT4(data) NATURE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_4, data +#define AMBIENCE_IO_STREAM_0_TYPE(type) AMBIENCE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_STREAM_0_PORT3(data) AMBIENCE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_3, data +#define AMBIENCE_IO_STREAM_0_PORT4(data) AMBIENCE_CHANNEL_STREAM_0, CHANNEL_IO_PORT_4, data -#define NATURE_IO_STREAM_1_TYPE(type) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_2, type -#define NATURE_IO_STREAM_1_PORT3(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_3, data -#define NATURE_IO_STREAM_1_PORT4(data) NATURE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_4, data +#define AMBIENCE_IO_STREAM_1_TYPE(type) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_2, type +#define AMBIENCE_IO_STREAM_1_PORT3(data) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_3, data +#define AMBIENCE_IO_STREAM_1_PORT4(data) AMBIENCE_CHANNEL_STREAM_1, CHANNEL_IO_PORT_4, data -#define NATURE_IO_RAIN_PORT4(data) NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data +#define AMBIENCE_IO_RAIN_PORT4(data) AMBIENCE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, data -#define NATURE_IO_ENTRIES_END 0xFF +#define AMBIENCE_IO_ENTRIES_END 0xFF #endif 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 index 536322624..a471e4dde 100644 --- a/include/sys_matrix.h +++ b/include/sys_matrix.h @@ -29,7 +29,7 @@ MtxF* Matrix_GetCurrent(void); /* Basic operations */ -void Matrix_Mult(MtxF* matrix, MatrixMode mode); +void Matrix_Mult(MtxF* mf, 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); diff --git a/include/tables/actor_table.h b/include/tables/actor_table.h new file mode 100644 index 000000000..9019e2b80 --- /dev/null +++ b/include/tables/actor_table.h @@ -0,0 +1,703 @@ +/** + * Actor Table + * + * DEFINE_ACTOR should be used for normal actors + * - Argument 0: Name of the actor overlay segment in the spec (without the ovl_ part) + * - Argument 1: Enum value for this actor + * - Argument 2: Allocation type (normal, permanent or absolute) + * - Argument 3: Actor name, as a string (used for debug prints) + * + * DEFINE_ACTOR_INTERNAL should be used for actors that aren't an overlay, with the same arguments as DEFINE_ACTOR + * + * DEFINE_ACTOR_UNSET is needed to define empty entries from the original game + */ +/* 0x000 */ DEFINE_ACTOR_INTERNAL(Player, ACTOR_PLAYER, ALLOCTYPE_NORMAL, "Player") +/* 0x001 */ DEFINE_ACTOR(En_Test, ACTOR_EN_TEST, ALLOCTYPE_NORMAL, "En_Test") +/* 0x002 */ DEFINE_ACTOR(En_GirlA, ACTOR_EN_GIRLA, ALLOCTYPE_NORMAL, "En_GirlA") +/* 0x003 */ DEFINE_ACTOR(En_Part, ACTOR_EN_PART, ALLOCTYPE_NORMAL, "En_Part") +/* 0x004 */ DEFINE_ACTOR(En_Light, ACTOR_EN_LIGHT, ALLOCTYPE_NORMAL, "En_Light") +/* 0x005 */ DEFINE_ACTOR(En_Door, ACTOR_EN_DOOR, ALLOCTYPE_PERMANENT, "En_Door") +/* 0x006 */ DEFINE_ACTOR(En_Box, ACTOR_EN_BOX, ALLOCTYPE_NORMAL, "En_Box") +/* 0x007 */ DEFINE_ACTOR(En_Pametfrog, ACTOR_EN_PAMETFROG, ALLOCTYPE_NORMAL, "En_Pametfrog") +/* 0x008 */ DEFINE_ACTOR(En_Okuta, ACTOR_EN_OKUTA, ALLOCTYPE_NORMAL, "En_Okuta") +/* 0x009 */ DEFINE_ACTOR(En_Bom, ACTOR_EN_BOM, ALLOCTYPE_PERMANENT, "En_Bom") +/* 0x00A */ DEFINE_ACTOR(En_Wallmas, ACTOR_EN_WALLMAS, ALLOCTYPE_NORMAL, "En_Wallmas") +/* 0x00B */ DEFINE_ACTOR(En_Dodongo, ACTOR_EN_DODONGO, ALLOCTYPE_NORMAL, "En_Dodongo") +/* 0x00C */ DEFINE_ACTOR(En_Firefly, ACTOR_EN_FIREFLY, ALLOCTYPE_NORMAL, "En_Firefly") +/* 0x00D */ DEFINE_ACTOR(En_Horse, ACTOR_EN_HORSE, ALLOCTYPE_NORMAL, "En_Horse") +/* 0x00E */ DEFINE_ACTOR_INTERNAL(En_Item00, ACTOR_EN_ITEM00, ALLOCTYPE_NORMAL, "En_Item00") +/* 0x00F */ DEFINE_ACTOR(En_Arrow, ACTOR_EN_ARROW, ALLOCTYPE_PERMANENT, "En_Arrow") +/* 0x010 */ DEFINE_ACTOR(En_Elf, ACTOR_EN_ELF, ALLOCTYPE_NORMAL, "En_Elf") +/* 0x011 */ DEFINE_ACTOR(En_Niw, ACTOR_EN_NIW, ALLOCTYPE_NORMAL, "En_Niw") +/* 0x012 */ DEFINE_ACTOR(En_Tite, ACTOR_EN_TITE, ALLOCTYPE_NORMAL, "En_Tite") +/* 0x013 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_13) +/* 0x014 */ DEFINE_ACTOR(En_Peehat, ACTOR_EN_PEEHAT, ALLOCTYPE_NORMAL, "En_Peehat") +/* 0x015 */ DEFINE_ACTOR(En_Butte, ACTOR_EN_BUTTE, ALLOCTYPE_NORMAL, "En_Butte") +/* 0x016 */ DEFINE_ACTOR(En_Insect, ACTOR_EN_INSECT, ALLOCTYPE_NORMAL, "En_Insect") +/* 0x017 */ DEFINE_ACTOR(En_Fish, ACTOR_EN_FISH, ALLOCTYPE_NORMAL, "En_Fish") +/* 0x018 */ DEFINE_ACTOR(En_Holl, ACTOR_EN_HOLL, ALLOCTYPE_PERMANENT, "En_Holl") +/* 0x019 */ DEFINE_ACTOR(En_Dinofos, ACTOR_EN_DINOFOS, ALLOCTYPE_NORMAL, "En_Dinofos") +/* 0x01A */ DEFINE_ACTOR(En_Hata, ACTOR_EN_HATA, ALLOCTYPE_NORMAL, "En_Hata") +/* 0x01B */ DEFINE_ACTOR(En_Zl1, ACTOR_EN_ZL1, ALLOCTYPE_NORMAL, "En_Zl1") +/* 0x01C */ DEFINE_ACTOR(En_Viewer, ACTOR_EN_VIEWER, ALLOCTYPE_NORMAL, "En_Viewer") +/* 0x01D */ DEFINE_ACTOR(En_Bubble, ACTOR_EN_BUBBLE, ALLOCTYPE_NORMAL, "En_Bubble") +/* 0x01E */ DEFINE_ACTOR(Door_Shutter, ACTOR_DOOR_SHUTTER, ALLOCTYPE_PERMANENT, "Door_Shutter") +/* 0x01F */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_1F) +/* 0x020 */ DEFINE_ACTOR(En_Boom, ACTOR_EN_BOOM, ALLOCTYPE_PERMANENT, "En_Boom") +/* 0x021 */ DEFINE_ACTOR(En_Torch2, ACTOR_EN_TORCH2, ALLOCTYPE_NORMAL, "En_Torch2") +/* 0x022 */ DEFINE_ACTOR(En_Minifrog, ACTOR_EN_MINIFROG, ALLOCTYPE_NORMAL, "En_Minifrog") +/* 0x023 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_23) +/* 0x024 */ DEFINE_ACTOR(En_St, ACTOR_EN_ST, ALLOCTYPE_NORMAL, "En_St") +/* 0x025 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_25) +/* 0x026 */ DEFINE_ACTOR_INTERNAL(En_A_Obj, ACTOR_EN_A_OBJ, ALLOCTYPE_NORMAL, "En_A_Obj") +/* 0x027 */ DEFINE_ACTOR(Obj_Wturn, ACTOR_OBJ_WTURN, ALLOCTYPE_NORMAL, "Obj_Wturn") +/* 0x028 */ DEFINE_ACTOR(En_River_Sound, ACTOR_EN_RIVER_SOUND, ALLOCTYPE_NORMAL, "En_River_Sound") +/* 0x029 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_29) +/* 0x02A */ DEFINE_ACTOR(En_Ossan, ACTOR_EN_OSSAN, ALLOCTYPE_NORMAL, "En_Ossan") +/* 0x02B */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_2B) +/* 0x02C */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_2C) +/* 0x02D */ DEFINE_ACTOR(En_Famos, ACTOR_EN_FAMOS, ALLOCTYPE_NORMAL, "En_Famos") +/* 0x02E */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_2E) +/* 0x02F */ DEFINE_ACTOR(En_Bombf, ACTOR_EN_BOMBF, ALLOCTYPE_NORMAL, "En_Bombf") +/* 0x030 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_30) +/* 0x031 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_31) +/* 0x032 */ DEFINE_ACTOR(En_Am, ACTOR_EN_AM, ALLOCTYPE_NORMAL, "En_Am") +/* 0x033 */ DEFINE_ACTOR(En_Dekubaba, ACTOR_EN_DEKUBABA, ALLOCTYPE_NORMAL, "En_Dekubaba") +/* 0x034 */ DEFINE_ACTOR(En_M_Fire1, ACTOR_EN_M_FIRE1, ALLOCTYPE_PERMANENT, "En_M_Fire1") +/* 0x035 */ DEFINE_ACTOR(En_M_Thunder, ACTOR_EN_M_THUNDER, ALLOCTYPE_PERMANENT, "En_M_Thunder") +/* 0x036 */ DEFINE_ACTOR(Bg_Breakwall, ACTOR_BG_BREAKWALL, ALLOCTYPE_NORMAL, "Bg_Breakwall") +/* 0x037 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_37) +/* 0x038 */ DEFINE_ACTOR(Door_Warp1, ACTOR_DOOR_WARP1, ALLOCTYPE_NORMAL, "Door_Warp1") +/* 0x039 */ DEFINE_ACTOR(Obj_Syokudai, ACTOR_OBJ_SYOKUDAI, ALLOCTYPE_NORMAL, "Obj_Syokudai") +/* 0x03A */ DEFINE_ACTOR(Item_B_Heart, ACTOR_ITEM_B_HEART, ALLOCTYPE_NORMAL, "Item_B_Heart") +/* 0x03B */ DEFINE_ACTOR(En_Dekunuts, ACTOR_EN_DEKUNUTS, ALLOCTYPE_NORMAL, "En_Dekunuts") +/* 0x03C */ DEFINE_ACTOR(En_Bbfall, ACTOR_EN_BBFALL, ALLOCTYPE_NORMAL, "En_Bbfall") +/* 0x03D */ DEFINE_ACTOR(Arms_Hook, ACTOR_ARMS_HOOK, ALLOCTYPE_PERMANENT, "Arms_Hook") +/* 0x03E */ DEFINE_ACTOR(En_Bb, ACTOR_EN_BB, ALLOCTYPE_NORMAL, "En_Bb") +/* 0x03F */ DEFINE_ACTOR(Bg_Keikoku_Spr, ACTOR_BG_KEIKOKU_SPR, ALLOCTYPE_NORMAL, "Bg_Keikoku_Spr") +/* 0x040 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_40) +/* 0x041 */ DEFINE_ACTOR(En_Wood02, ACTOR_EN_WOOD02, ALLOCTYPE_NORMAL, "En_Wood02") +/* 0x042 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_42) +/* 0x043 */ DEFINE_ACTOR(En_Death, ACTOR_EN_DEATH, ALLOCTYPE_NORMAL, "En_Death") +/* 0x044 */ DEFINE_ACTOR(En_Minideath, ACTOR_EN_MINIDEATH, ALLOCTYPE_NORMAL, "En_Minideath") +/* 0x045 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_45) +/* 0x046 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_46) +/* 0x047 */ DEFINE_ACTOR(En_Vm, ACTOR_EN_VM, ALLOCTYPE_NORMAL, "En_Vm") +/* 0x048 */ DEFINE_ACTOR(Demo_Effect, ACTOR_DEMO_EFFECT, ALLOCTYPE_NORMAL, "Demo_Effect") +/* 0x049 */ DEFINE_ACTOR(Demo_Kankyo, ACTOR_DEMO_KANKYO, ALLOCTYPE_NORMAL, "Demo_Kankyo") +/* 0x04A */ DEFINE_ACTOR(En_Floormas, ACTOR_EN_FLOORMAS, ALLOCTYPE_NORMAL, "En_Floormas") +/* 0x04B */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_4B) +/* 0x04C */ DEFINE_ACTOR(En_Rd, ACTOR_EN_RD, ALLOCTYPE_NORMAL, "En_Rd") +/* 0x04D */ DEFINE_ACTOR(Bg_F40_Flift, ACTOR_BG_F40_FLIFT, ALLOCTYPE_NORMAL, "Bg_F40_Flift") +/* 0x04E */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_4E) +/* 0x04F */ DEFINE_ACTOR(Obj_Mure, ACTOR_OBJ_MURE, ALLOCTYPE_NORMAL, "Obj_Mure") +/* 0x050 */ DEFINE_ACTOR(En_Sw, ACTOR_EN_SW, ALLOCTYPE_NORMAL, "En_Sw") +/* 0x051 */ DEFINE_ACTOR(Object_Kankyo, ACTOR_OBJECT_KANKYO, ALLOCTYPE_NORMAL, "Object_Kankyo") +/* 0x052 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_52) +/* 0x053 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_53) +/* 0x054 */ DEFINE_ACTOR(En_Horse_Link_Child, ACTOR_EN_HORSE_LINK_CHILD, ALLOCTYPE_NORMAL, "En_Horse_Link_Child") +/* 0x055 */ DEFINE_ACTOR(Door_Ana, ACTOR_DOOR_ANA, ALLOCTYPE_NORMAL, "Door_Ana") +/* 0x056 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_56) +/* 0x057 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_57) +/* 0x058 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_58) +/* 0x059 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_59) +/* 0x05A */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_5A) +/* 0x05B */ DEFINE_ACTOR(En_Encount1, ACTOR_EN_ENCOUNT1, ALLOCTYPE_NORMAL, "En_Encount1") +/* 0x05C */ DEFINE_ACTOR(Demo_Tre_Lgt, ACTOR_DEMO_TRE_LGT, ALLOCTYPE_NORMAL, "Demo_Tre_Lgt") +/* 0x05D */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_5D) +/* 0x05E */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_5E) +/* 0x05F */ DEFINE_ACTOR(En_Encount2, ACTOR_EN_ENCOUNT2, ALLOCTYPE_NORMAL, "En_Encount2") +/* 0x060 */ DEFINE_ACTOR(En_Fire_Rock, ACTOR_EN_FIRE_ROCK, ALLOCTYPE_NORMAL, "En_Fire_Rock") +/* 0x061 */ DEFINE_ACTOR(Bg_Ctower_Rot, ACTOR_BG_CTOWER_ROT, ALLOCTYPE_NORMAL, "Bg_Ctower_Rot") +/* 0x062 */ DEFINE_ACTOR(Mir_Ray, ACTOR_MIR_RAY, ALLOCTYPE_NORMAL, "Mir_Ray") +/* 0x063 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_63) +/* 0x064 */ DEFINE_ACTOR(En_Sb, ACTOR_EN_SB, ALLOCTYPE_NORMAL, "En_Sb") +/* 0x065 */ DEFINE_ACTOR(En_Bigslime, ACTOR_EN_BIGSLIME, ALLOCTYPE_NORMAL, "En_Bigslime") +/* 0x066 */ DEFINE_ACTOR(En_Karebaba, ACTOR_EN_KAREBABA, ALLOCTYPE_NORMAL, "En_Karebaba") +/* 0x067 */ DEFINE_ACTOR(En_In, ACTOR_EN_IN, ALLOCTYPE_NORMAL, "En_In") +/* 0x068 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_68) +/* 0x069 */ DEFINE_ACTOR(En_Ru, ACTOR_EN_RU, ALLOCTYPE_NORMAL, "En_Ru") +/* 0x06A */ DEFINE_ACTOR(En_Bom_Chu, ACTOR_EN_BOM_CHU, ALLOCTYPE_PERMANENT, "En_Bom_Chu") +/* 0x06B */ DEFINE_ACTOR(En_Horse_Game_Check, ACTOR_EN_HORSE_GAME_CHECK, ALLOCTYPE_NORMAL, "En_Horse_Game_Check") +/* 0x06C */ DEFINE_ACTOR(En_Rr, ACTOR_EN_RR, ALLOCTYPE_NORMAL, "En_Rr") +/* 0x06D */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_6D) +/* 0x06E */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_6E) +/* 0x06F */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_6F) +/* 0x070 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_70) +/* 0x071 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_71) +/* 0x072 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_72) +/* 0x073 */ DEFINE_ACTOR(En_Fr, ACTOR_EN_FR, ALLOCTYPE_NORMAL, "En_Fr") +/* 0x074 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_74) +/* 0x075 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_75) +/* 0x076 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_76) +/* 0x077 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_77) +/* 0x078 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_78) +/* 0x079 */ DEFINE_ACTOR(En_Fishing, ACTOR_EN_FISHING, ALLOCTYPE_NORMAL, "En_Fishing") +/* 0x07A */ DEFINE_ACTOR(Obj_Oshihiki, ACTOR_OBJ_OSHIHIKI, ALLOCTYPE_NORMAL, "Obj_Oshihiki") +/* 0x07B */ DEFINE_ACTOR(Eff_Dust, ACTOR_EFF_DUST, ALLOCTYPE_NORMAL, "Eff_Dust") +/* 0x07C */ DEFINE_ACTOR(Bg_Umajump, ACTOR_BG_UMAJUMP, ALLOCTYPE_NORMAL, "Bg_Umajump") +/* 0x07D */ DEFINE_ACTOR(Arrow_Fire, ACTOR_ARROW_FIRE, ALLOCTYPE_ABSOLUTE, "Arrow_Fire") +/* 0x07E */ DEFINE_ACTOR(Arrow_Ice, ACTOR_ARROW_ICE, ALLOCTYPE_ABSOLUTE, "Arrow_Ice") +/* 0x07F */ DEFINE_ACTOR(Arrow_Light, ACTOR_ARROW_LIGHT, ALLOCTYPE_ABSOLUTE, "Arrow_Light") +/* 0x080 */ DEFINE_ACTOR(Item_Etcetera, ACTOR_ITEM_ETCETERA, ALLOCTYPE_NORMAL, "Item_Etcetera") +/* 0x081 */ DEFINE_ACTOR(Obj_Kibako, ACTOR_OBJ_KIBAKO, ALLOCTYPE_NORMAL, "Obj_Kibako") +/* 0x082 */ DEFINE_ACTOR(Obj_Tsubo, ACTOR_OBJ_TSUBO, ALLOCTYPE_NORMAL, "Obj_Tsubo") +/* 0x083 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_83) +/* 0x084 */ DEFINE_ACTOR(En_Ik, ACTOR_EN_IK, ALLOCTYPE_NORMAL, "En_Ik") +/* 0x085 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_85) +/* 0x086 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_86) +/* 0x087 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_87) +/* 0x088 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_88) +/* 0x089 */ DEFINE_ACTOR(Demo_Shd, ACTOR_DEMO_SHD, ALLOCTYPE_NORMAL, "Demo_Shd") +/* 0x08A */ DEFINE_ACTOR(En_Dns, ACTOR_EN_DNS, ALLOCTYPE_NORMAL, "En_Dns") +/* 0x08B */ DEFINE_ACTOR(Elf_Msg, ACTOR_ELF_MSG, ALLOCTYPE_NORMAL, "Elf_Msg") +/* 0x08C */ DEFINE_ACTOR(En_Honotrap, ACTOR_EN_HONOTRAP, ALLOCTYPE_NORMAL, "En_Honotrap") +/* 0x08D */ DEFINE_ACTOR(En_Tubo_Trap, ACTOR_EN_TUBO_TRAP, ALLOCTYPE_NORMAL, "En_Tubo_Trap") +/* 0x08E */ DEFINE_ACTOR(Obj_Ice_Poly, ACTOR_OBJ_ICE_POLY, ALLOCTYPE_NORMAL, "Obj_Ice_Poly") +/* 0x08F */ DEFINE_ACTOR(En_Fz, ACTOR_EN_FZ, ALLOCTYPE_NORMAL, "En_Fz") +/* 0x090 */ DEFINE_ACTOR(En_Kusa, ACTOR_EN_KUSA, ALLOCTYPE_NORMAL, "En_Kusa") +/* 0x091 */ DEFINE_ACTOR(Obj_Bean, ACTOR_OBJ_BEAN, ALLOCTYPE_NORMAL, "Obj_Bean") +/* 0x092 */ DEFINE_ACTOR(Obj_Bombiwa, ACTOR_OBJ_BOMBIWA, ALLOCTYPE_NORMAL, "Obj_Bombiwa") +/* 0x093 */ DEFINE_ACTOR(Obj_Switch, ACTOR_OBJ_SWITCH, ALLOCTYPE_NORMAL, "Obj_Switch") +/* 0x094 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_94) +/* 0x095 */ DEFINE_ACTOR(Obj_Lift, ACTOR_OBJ_LIFT, ALLOCTYPE_NORMAL, "Obj_Lift") +/* 0x096 */ DEFINE_ACTOR(Obj_Hsblock, ACTOR_OBJ_HSBLOCK, ALLOCTYPE_NORMAL, "Obj_Hsblock") +/* 0x097 */ DEFINE_ACTOR(En_Okarina_Tag, ACTOR_EN_OKARINA_TAG, ALLOCTYPE_NORMAL, "En_Okarina_Tag") +/* 0x098 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_98) +/* 0x099 */ DEFINE_ACTOR(En_Goroiwa, ACTOR_EN_GOROIWA, ALLOCTYPE_NORMAL, "En_Goroiwa") +/* 0x09A */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_9A) +/* 0x09B */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_9B) +/* 0x09C */ DEFINE_ACTOR(En_Daiku, ACTOR_EN_DAIKU, ALLOCTYPE_NORMAL, "En_Daiku") +/* 0x09D */ DEFINE_ACTOR(En_Nwc, ACTOR_EN_NWC, ALLOCTYPE_NORMAL, "En_Nwc") +/* 0x09E */ DEFINE_ACTOR(Item_Inbox, ACTOR_ITEM_INBOX, ALLOCTYPE_NORMAL, "Item_Inbox") +/* 0x09F */ DEFINE_ACTOR(En_Ge1, ACTOR_EN_GE1, ALLOCTYPE_NORMAL, "En_Ge1") +/* 0x0A0 */ DEFINE_ACTOR(Obj_Blockstop, ACTOR_OBJ_BLOCKSTOP, ALLOCTYPE_NORMAL, "Obj_Blockstop") +/* 0x0A1 */ DEFINE_ACTOR(En_Sda, ACTOR_EN_SDA, ALLOCTYPE_NORMAL, "En_Sda") +/* 0x0A2 */ DEFINE_ACTOR(En_Clear_Tag, ACTOR_EN_CLEAR_TAG, ALLOCTYPE_NORMAL, "En_Clear_Tag") +/* 0x0A3 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_A3) +/* 0x0A4 */ DEFINE_ACTOR(En_Gm, ACTOR_EN_GM, ALLOCTYPE_NORMAL, "En_Gm") +/* 0x0A5 */ DEFINE_ACTOR(En_Ms, ACTOR_EN_MS, ALLOCTYPE_NORMAL, "En_Ms") +/* 0x0A6 */ DEFINE_ACTOR(En_Hs, ACTOR_EN_HS, ALLOCTYPE_NORMAL, "En_Hs") +/* 0x0A7 */ DEFINE_ACTOR(Bg_Ingate, ACTOR_BG_INGATE, ALLOCTYPE_NORMAL, "Bg_Ingate") +/* 0x0A8 */ DEFINE_ACTOR(En_Kanban, ACTOR_EN_KANBAN, ALLOCTYPE_NORMAL, "En_Kanban") +/* 0x0A9 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_A9) +/* 0x0AA */ DEFINE_ACTOR(En_Attack_Niw, ACTOR_EN_ATTACK_NIW, ALLOCTYPE_NORMAL, "En_Attack_Niw") +/* 0x0AB */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_AB) +/* 0x0AC */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_AC) +/* 0x0AD */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_AD) +/* 0x0AE */ DEFINE_ACTOR(En_Mk, ACTOR_EN_MK, ALLOCTYPE_NORMAL, "En_Mk") +/* 0x0AF */ DEFINE_ACTOR(En_Owl, ACTOR_EN_OWL, ALLOCTYPE_NORMAL, "En_Owl") +/* 0x0B0 */ DEFINE_ACTOR(En_Ishi, ACTOR_EN_ISHI, ALLOCTYPE_NORMAL, "En_Ishi") +/* 0x0B1 */ DEFINE_ACTOR(Obj_Hana, ACTOR_OBJ_HANA, ALLOCTYPE_NORMAL, "Obj_Hana") +/* 0x0B2 */ DEFINE_ACTOR(Obj_Lightswitch, ACTOR_OBJ_LIGHTSWITCH, ALLOCTYPE_NORMAL, "Obj_Lightswitch") +/* 0x0B3 */ DEFINE_ACTOR(Obj_Mure2, ACTOR_OBJ_MURE2, ALLOCTYPE_NORMAL, "Obj_Mure2") +/* 0x0B4 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_B4) +/* 0x0B5 */ DEFINE_ACTOR(En_Fu, ACTOR_EN_FU, ALLOCTYPE_NORMAL, "En_Fu") +/* 0x0B6 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_B6) +/* 0x0B7 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_B7) +/* 0x0B8 */ DEFINE_ACTOR(En_Stream, ACTOR_EN_STREAM, ALLOCTYPE_NORMAL, "En_Stream") +/* 0x0B9 */ DEFINE_ACTOR(En_Mm, ACTOR_EN_MM, ALLOCTYPE_NORMAL, "En_Mm") +/* 0x0BA */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_BA) +/* 0x0BB */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_BB) +/* 0x0BC */ DEFINE_ACTOR(En_Weather_Tag, ACTOR_EN_WEATHER_TAG, ALLOCTYPE_NORMAL, "En_Weather_Tag") +/* 0x0BD */ DEFINE_ACTOR(En_Ani, ACTOR_EN_ANI, ALLOCTYPE_NORMAL, "En_Ani") +/* 0x0BE */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_BE) +/* 0x0BF */ DEFINE_ACTOR(En_Js, ACTOR_EN_JS, ALLOCTYPE_NORMAL, "En_Js") +/* 0x0C0 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_C0) +/* 0x0C1 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_C1) +/* 0x0C2 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_C2) +/* 0x0C3 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_C3) +/* 0x0C4 */ DEFINE_ACTOR(En_Okarina_Effect, ACTOR_EN_OKARINA_EFFECT, ALLOCTYPE_NORMAL, "En_Okarina_Effect") +/* 0x0C5 */ DEFINE_ACTOR(En_Mag, ACTOR_EN_MAG, ALLOCTYPE_NORMAL, "En_Mag") +/* 0x0C6 */ DEFINE_ACTOR(Elf_Msg2, ACTOR_ELF_MSG2, ALLOCTYPE_NORMAL, "Elf_Msg2") +/* 0x0C7 */ DEFINE_ACTOR(Bg_F40_Swlift, ACTOR_BG_F40_SWLIFT, ALLOCTYPE_NORMAL, "Bg_F40_Swlift") +/* 0x0C8 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_C8) +/* 0x0C9 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_C9) +/* 0x0CA */ DEFINE_ACTOR(En_Kakasi, ACTOR_EN_KAKASI, ALLOCTYPE_NORMAL, "En_Kakasi") +/* 0x0CB */ DEFINE_ACTOR(Obj_Makeoshihiki, ACTOR_OBJ_MAKEOSHIHIKI, ALLOCTYPE_NORMAL, "Obj_Makeoshihiki") +/* 0x0CC */ DEFINE_ACTOR(Oceff_Spot, ACTOR_OCEFF_SPOT, ALLOCTYPE_ABSOLUTE, "Oceff_Spot") +/* 0x0CD */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_CD) +/* 0x0CE */ DEFINE_ACTOR(En_Torch, ACTOR_EN_TORCH, ALLOCTYPE_NORMAL, "En_Torch") +/* 0x0CF */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_CF) +/* 0x0D0 */ DEFINE_ACTOR(Shot_Sun, ACTOR_SHOT_SUN, ALLOCTYPE_NORMAL, "Shot_Sun") +/* 0x0D1 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_D1) +/* 0x0D2 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_D2) +/* 0x0D3 */ DEFINE_ACTOR(Obj_Roomtimer, ACTOR_OBJ_ROOMTIMER, ALLOCTYPE_NORMAL, "Obj_Roomtimer") +/* 0x0D4 */ DEFINE_ACTOR(En_Ssh, ACTOR_EN_SSH, ALLOCTYPE_NORMAL, "En_Ssh") +/* 0x0D5 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_D5) +/* 0x0D6 */ DEFINE_ACTOR(Oceff_Wipe, ACTOR_OCEFF_WIPE, ALLOCTYPE_ABSOLUTE, "Oceff_Wipe") +/* 0x0D7 */ DEFINE_ACTOR(Oceff_Storm, ACTOR_OCEFF_STORM, ALLOCTYPE_ABSOLUTE, "Oceff_Storm") +/* 0x0D8 */ DEFINE_ACTOR(Obj_Demo, ACTOR_OBJ_DEMO, ALLOCTYPE_NORMAL, "Obj_Demo") +/* 0x0D9 */ DEFINE_ACTOR(En_Minislime, ACTOR_EN_MINISLIME, ALLOCTYPE_NORMAL, "En_Minislime") +/* 0x0DA */ DEFINE_ACTOR(En_Nutsball, ACTOR_EN_NUTSBALL, ALLOCTYPE_NORMAL, "En_Nutsball") +/* 0x0DB */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_DB) +/* 0x0DC */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_DC) +/* 0x0DD */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_DD) +/* 0x0DE */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_DE) +/* 0x0DF */ DEFINE_ACTOR(Oceff_Wipe2, ACTOR_OCEFF_WIPE2, ALLOCTYPE_ABSOLUTE, "Oceff_Wipe2") +/* 0x0E0 */ DEFINE_ACTOR(Oceff_Wipe3, ACTOR_OCEFF_WIPE3, ALLOCTYPE_ABSOLUTE, "Oceff_Wipe3") +/* 0x0E1 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_E1) +/* 0x0E2 */ DEFINE_ACTOR(En_Dg, ACTOR_EN_DG, ALLOCTYPE_NORMAL, "En_Dg") +/* 0x0E3 */ DEFINE_ACTOR(En_Si, ACTOR_EN_SI, ALLOCTYPE_NORMAL, "En_Si") +/* 0x0E4 */ DEFINE_ACTOR(Obj_Comb, ACTOR_OBJ_COMB, ALLOCTYPE_NORMAL, "Obj_Comb") +/* 0x0E5 */ DEFINE_ACTOR(Obj_Kibako2, ACTOR_OBJ_KIBAKO2, ALLOCTYPE_NORMAL, "Obj_Kibako2") +/* 0x0E6 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_E6) +/* 0x0E7 */ DEFINE_ACTOR(En_Hs2, ACTOR_EN_HS2, ALLOCTYPE_NORMAL, "En_Hs2") +/* 0x0E8 */ DEFINE_ACTOR(Obj_Mure3, ACTOR_OBJ_MURE3, ALLOCTYPE_NORMAL, "Obj_Mure3") +/* 0x0E9 */ DEFINE_ACTOR(En_Tg, ACTOR_EN_TG, ALLOCTYPE_NORMAL, "En_Tg") +/* 0x0EA */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_EA) +/* 0x0EB */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_EB) +/* 0x0EC */ DEFINE_ACTOR(En_Wf, ACTOR_EN_WF, ALLOCTYPE_NORMAL, "En_Wf") +/* 0x0ED */ DEFINE_ACTOR(En_Skb, ACTOR_EN_SKB, ALLOCTYPE_NORMAL, "En_Skb") +/* 0x0EE */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_EE) +/* 0x0EF */ DEFINE_ACTOR(En_Gs, ACTOR_EN_GS, ALLOCTYPE_NORMAL, "En_Gs") +/* 0x0F0 */ DEFINE_ACTOR(Obj_Sound, ACTOR_OBJ_SOUND, ALLOCTYPE_NORMAL, "Obj_Sound") +/* 0x0F1 */ DEFINE_ACTOR(En_Crow, ACTOR_EN_CROW, ALLOCTYPE_NORMAL, "En_Crow") +/* 0x0F2 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_F2) +/* 0x0F3 */ DEFINE_ACTOR(En_Cow, ACTOR_EN_COW, ALLOCTYPE_NORMAL, "En_Cow") +/* 0x0F4 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_F4) +/* 0x0F5 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_F5) +/* 0x0F6 */ DEFINE_ACTOR(Oceff_Wipe4, ACTOR_OCEFF_WIPE4, ALLOCTYPE_ABSOLUTE, "Oceff_Wipe4") +/* 0x0F7 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_F7) +/* 0x0F8 */ DEFINE_ACTOR(En_Zo, ACTOR_EN_ZO, ALLOCTYPE_NORMAL, "En_Zo") +/* 0x0F9 */ DEFINE_ACTOR(Obj_Makekinsuta, ACTOR_OBJ_MAKEKINSUTA, ALLOCTYPE_NORMAL, "Obj_Makekinsuta") +/* 0x0FA */ DEFINE_ACTOR(En_Ge3, ACTOR_EN_GE3, ALLOCTYPE_NORMAL, "En_Ge3") +/* 0x0FB */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_FB) +/* 0x0FC */ DEFINE_ACTOR(Obj_Hamishi, ACTOR_OBJ_HAMISHI, ALLOCTYPE_NORMAL, "Obj_Hamishi") +/* 0x0FD */ DEFINE_ACTOR(En_Zl4, ACTOR_EN_ZL4, ALLOCTYPE_NORMAL, "En_Zl4") +/* 0x0FE */ DEFINE_ACTOR(En_Mm2, ACTOR_EN_MM2, ALLOCTYPE_NORMAL, "En_Mm2") +/* 0x0FF */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_FF) +/* 0x100 */ DEFINE_ACTOR(Door_Spiral, ACTOR_DOOR_SPIRAL, ALLOCTYPE_PERMANENT, "Door_Spiral") +/* 0x101 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_101) +/* 0x102 */ DEFINE_ACTOR(Obj_Pzlblock, ACTOR_OBJ_PZLBLOCK, ALLOCTYPE_NORMAL, "Obj_Pzlblock") +/* 0x103 */ DEFINE_ACTOR(Obj_Toge, ACTOR_OBJ_TOGE, ALLOCTYPE_NORMAL, "Obj_Toge") +/* 0x104 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_104) +/* 0x105 */ DEFINE_ACTOR(Obj_Armos, ACTOR_OBJ_ARMOS, ALLOCTYPE_NORMAL, "Obj_Armos") +/* 0x106 */ DEFINE_ACTOR(Obj_Boyo, ACTOR_OBJ_BOYO, ALLOCTYPE_NORMAL, "Obj_Boyo") +/* 0x107 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_107) +/* 0x108 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_108) +/* 0x109 */ DEFINE_ACTOR(En_Grasshopper, ACTOR_EN_GRASSHOPPER, ALLOCTYPE_NORMAL, "En_Grasshopper") +/* 0x10A */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_10A) +/* 0x10B */ DEFINE_ACTOR(Obj_Grass, ACTOR_OBJ_GRASS, ALLOCTYPE_NORMAL, "Obj_Grass") +/* 0x10C */ DEFINE_ACTOR(Obj_Grass_Carry, ACTOR_OBJ_GRASS_CARRY, ALLOCTYPE_NORMAL, "Obj_Grass_Carry") +/* 0x10D */ DEFINE_ACTOR(Obj_Grass_Unit, ACTOR_OBJ_GRASS_UNIT, ALLOCTYPE_NORMAL, "Obj_Grass_Unit") +/* 0x10E */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_10E) +/* 0x10F */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_10F) +/* 0x110 */ DEFINE_ACTOR(Bg_Fire_Wall, ACTOR_BG_FIRE_WALL, ALLOCTYPE_NORMAL, "Bg_Fire_Wall") +/* 0x111 */ DEFINE_ACTOR(En_Bu, ACTOR_EN_BU, ALLOCTYPE_NORMAL, "En_Bu") +/* 0x112 */ DEFINE_ACTOR(En_Encount3, ACTOR_EN_ENCOUNT3, ALLOCTYPE_NORMAL, "En_Encount3") +/* 0x113 */ DEFINE_ACTOR(En_Jso, ACTOR_EN_JSO, ALLOCTYPE_NORMAL, "En_Jso") +/* 0x114 */ DEFINE_ACTOR(Obj_Chikuwa, ACTOR_OBJ_CHIKUWA, ALLOCTYPE_NORMAL, "Obj_Chikuwa") +/* 0x115 */ DEFINE_ACTOR(En_Knight, ACTOR_EN_KNIGHT, ALLOCTYPE_NORMAL, "En_Knight") +/* 0x116 */ DEFINE_ACTOR(En_Warp_tag, ACTOR_EN_WARP_TAG, ALLOCTYPE_NORMAL, "En_Warp_tag") +/* 0x117 */ DEFINE_ACTOR(En_Aob_01, ACTOR_EN_AOB_01, ALLOCTYPE_NORMAL, "En_Aob_01") +/* 0x118 */ DEFINE_ACTOR(En_Boj_01, ACTOR_EN_BOJ_01, ALLOCTYPE_NORMAL, "En_Boj_01") +/* 0x119 */ DEFINE_ACTOR(En_Boj_02, ACTOR_EN_BOJ_02, ALLOCTYPE_NORMAL, "En_Boj_02") +/* 0x11A */ DEFINE_ACTOR(En_Boj_03, ACTOR_EN_BOJ_03, ALLOCTYPE_NORMAL, "En_Boj_03") +/* 0x11B */ DEFINE_ACTOR(En_Encount4, ACTOR_EN_ENCOUNT4, ALLOCTYPE_NORMAL, "En_Encount4") +/* 0x11C */ DEFINE_ACTOR(En_Bom_Bowl_Man, ACTOR_EN_BOM_BOWL_MAN, ALLOCTYPE_NORMAL, "En_Bom_Bowl_Man") +/* 0x11D */ DEFINE_ACTOR(En_Syateki_Man, ACTOR_EN_SYATEKI_MAN, ALLOCTYPE_NORMAL, "En_Syateki_Man") +/* 0x11E */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_11E) +/* 0x11F */ DEFINE_ACTOR(Bg_Icicle, ACTOR_BG_ICICLE, ALLOCTYPE_NORMAL, "Bg_Icicle") +/* 0x120 */ DEFINE_ACTOR(En_Syateki_Crow, ACTOR_EN_SYATEKI_CROW, ALLOCTYPE_NORMAL, "En_Syateki_Crow") +/* 0x121 */ DEFINE_ACTOR(En_Boj_04, ACTOR_EN_BOJ_04, ALLOCTYPE_NORMAL, "En_Boj_04") +/* 0x122 */ DEFINE_ACTOR(En_Cne_01, ACTOR_EN_CNE_01, ALLOCTYPE_NORMAL, "En_Cne_01") +/* 0x123 */ DEFINE_ACTOR(En_Bba_01, ACTOR_EN_BBA_01, ALLOCTYPE_NORMAL, "En_Bba_01") +/* 0x124 */ DEFINE_ACTOR(En_Bji_01, ACTOR_EN_BJI_01, ALLOCTYPE_NORMAL, "En_Bji_01") +/* 0x125 */ DEFINE_ACTOR(Bg_Spdweb, ACTOR_BG_SPDWEB, ALLOCTYPE_NORMAL, "Bg_Spdweb") +/* 0x126 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_126) +/* 0x127 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_127) +/* 0x128 */ DEFINE_ACTOR(En_Mt_tag, ACTOR_EN_MT_TAG, ALLOCTYPE_NORMAL, "En_Mt_tag") +/* 0x129 */ DEFINE_ACTOR(Boss_01, ACTOR_BOSS_01, ALLOCTYPE_NORMAL, "Boss_01") +/* 0x12A */ DEFINE_ACTOR(Boss_02, ACTOR_BOSS_02, ALLOCTYPE_NORMAL, "Boss_02") +/* 0x12B */ DEFINE_ACTOR(Boss_03, ACTOR_BOSS_03, ALLOCTYPE_NORMAL, "Boss_03") +/* 0x12C */ DEFINE_ACTOR(Boss_04, ACTOR_BOSS_04, ALLOCTYPE_NORMAL, "Boss_04") +/* 0x12D */ DEFINE_ACTOR(Boss_05, ACTOR_BOSS_05, ALLOCTYPE_NORMAL, "Boss_05") +/* 0x12E */ DEFINE_ACTOR(Boss_06, ACTOR_BOSS_06, ALLOCTYPE_NORMAL, "Boss_06") +/* 0x12F */ DEFINE_ACTOR(Boss_07, ACTOR_BOSS_07, ALLOCTYPE_NORMAL, "Boss_07") +/* 0x130 */ DEFINE_ACTOR(Bg_Dy_Yoseizo, ACTOR_BG_DY_YOSEIZO, ALLOCTYPE_NORMAL, "Bg_Dy_Yoseizo") +/* 0x131 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_131) +/* 0x132 */ DEFINE_ACTOR(En_Boj_05, ACTOR_EN_BOJ_05, ALLOCTYPE_NORMAL, "En_Boj_05") +/* 0x133 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_133) +/* 0x134 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_134) +/* 0x135 */ DEFINE_ACTOR(En_Sob1, ACTOR_EN_SOB1, ALLOCTYPE_NORMAL, "En_Sob1") +/* 0x136 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_136) +/* 0x137 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_137) +/* 0x138 */ DEFINE_ACTOR(En_Go, ACTOR_EN_GO, ALLOCTYPE_NORMAL, "En_Go") +/* 0x139 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_139) +/* 0x13A */ DEFINE_ACTOR(En_Raf, ACTOR_EN_RAF, ALLOCTYPE_NORMAL, "En_Raf") +/* 0x13B */ DEFINE_ACTOR(Obj_Funen, ACTOR_OBJ_FUNEN, ALLOCTYPE_NORMAL, "Obj_Funen") +/* 0x13C */ DEFINE_ACTOR(Obj_Raillift, ACTOR_OBJ_RAILLIFT, ALLOCTYPE_NORMAL, "Obj_Raillift") +/* 0x13D */ DEFINE_ACTOR(Bg_Numa_Hana, ACTOR_BG_NUMA_HANA, ALLOCTYPE_NORMAL, "Bg_Numa_Hana") +/* 0x13E */ DEFINE_ACTOR(Obj_Flowerpot, ACTOR_OBJ_FLOWERPOT, ALLOCTYPE_NORMAL, "Obj_Flowerpot") +/* 0x13F */ DEFINE_ACTOR(Obj_Spinyroll, ACTOR_OBJ_SPINYROLL, ALLOCTYPE_NORMAL, "Obj_Spinyroll") +/* 0x140 */ DEFINE_ACTOR(Dm_Hina, ACTOR_DM_HINA, ALLOCTYPE_NORMAL, "Dm_Hina") +/* 0x141 */ DEFINE_ACTOR(En_Syateki_Wf, ACTOR_EN_SYATEKI_WF, ALLOCTYPE_NORMAL, "En_Syateki_Wf") +/* 0x142 */ DEFINE_ACTOR(Obj_Skateblock, ACTOR_OBJ_SKATEBLOCK, ALLOCTYPE_NORMAL, "Obj_Skateblock") +/* 0x143 */ DEFINE_ACTOR(Obj_Iceblock, ACTOR_OBJ_ICEBLOCK, ALLOCTYPE_NORMAL, "Obj_Iceblock") +/* 0x144 */ DEFINE_ACTOR(En_Bigpamet, ACTOR_EN_BIGPAMET, ALLOCTYPE_NORMAL, "En_Bigpamet") +/* 0x145 */ DEFINE_ACTOR(En_Syateki_Dekunuts, ACTOR_EN_SYATEKI_DEKUNUTS, ALLOCTYPE_NORMAL, "En_Syateki_Dekunuts") +/* 0x146 */ DEFINE_ACTOR(Elf_Msg3, ACTOR_ELF_MSG3, ALLOCTYPE_NORMAL, "Elf_Msg3") +/* 0x147 */ DEFINE_ACTOR(En_Fg, ACTOR_EN_FG, ALLOCTYPE_NORMAL, "En_Fg") +/* 0x148 */ DEFINE_ACTOR(Dm_Ravine, ACTOR_DM_RAVINE, ALLOCTYPE_NORMAL, "Dm_Ravine") +/* 0x149 */ DEFINE_ACTOR(Dm_Sa, ACTOR_DM_SA, ALLOCTYPE_NORMAL, "Dm_Sa") +/* 0x14A */ DEFINE_ACTOR(En_Slime, ACTOR_EN_SLIME, ALLOCTYPE_NORMAL, "En_Slime") +/* 0x14B */ DEFINE_ACTOR(En_Pr, ACTOR_EN_PR, ALLOCTYPE_NORMAL, "En_Pr") +/* 0x14C */ DEFINE_ACTOR(Obj_Toudai, ACTOR_OBJ_TOUDAI, ALLOCTYPE_NORMAL, "Obj_Toudai") +/* 0x14D */ DEFINE_ACTOR(Obj_Entotu, ACTOR_OBJ_ENTOTU, ALLOCTYPE_NORMAL, "Obj_Entotu") +/* 0x14E */ DEFINE_ACTOR(Obj_Bell, ACTOR_OBJ_BELL, ALLOCTYPE_NORMAL, "Obj_Bell") +/* 0x14F */ DEFINE_ACTOR(En_Syateki_Okuta, ACTOR_EN_SYATEKI_OKUTA, ALLOCTYPE_NORMAL, "En_Syateki_Okuta") +/* 0x150 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_150) +/* 0x151 */ DEFINE_ACTOR(Obj_Shutter, ACTOR_OBJ_SHUTTER, ALLOCTYPE_NORMAL, "Obj_Shutter") +/* 0x152 */ DEFINE_ACTOR(Dm_Zl, ACTOR_DM_ZL, ALLOCTYPE_NORMAL, "Dm_Zl") +/* 0x153 */ DEFINE_ACTOR(En_Elfgrp, ACTOR_EN_ELFGRP, ALLOCTYPE_NORMAL, "En_Elfgrp") +/* 0x154 */ DEFINE_ACTOR(Dm_Tsg, ACTOR_DM_TSG, ALLOCTYPE_NORMAL, "Dm_Tsg") +/* 0x155 */ DEFINE_ACTOR(En_Baguo, ACTOR_EN_BAGUO, ALLOCTYPE_NORMAL, "En_Baguo") +/* 0x156 */ DEFINE_ACTOR(Obj_Vspinyroll, ACTOR_OBJ_VSPINYROLL, ALLOCTYPE_NORMAL, "Obj_Vspinyroll") +/* 0x157 */ DEFINE_ACTOR(Obj_Smork, ACTOR_OBJ_SMORK, ALLOCTYPE_NORMAL, "Obj_Smork") +/* 0x158 */ DEFINE_ACTOR(En_Test2, ACTOR_EN_TEST2, ALLOCTYPE_NORMAL, "En_Test2") +/* 0x159 */ DEFINE_ACTOR(En_Test3, ACTOR_EN_TEST3, ALLOCTYPE_NORMAL, "En_Test3") +/* 0x15A */ DEFINE_ACTOR(En_Test4, ACTOR_EN_TEST4, ALLOCTYPE_NORMAL, "En_Test4") +/* 0x15B */ DEFINE_ACTOR(En_Bat, ACTOR_EN_BAT, ALLOCTYPE_NORMAL, "En_Bat") +/* 0x15C */ DEFINE_ACTOR(En_Sekihi, ACTOR_EN_SEKIHI, ALLOCTYPE_NORMAL, "En_Sekihi") +/* 0x15D */ DEFINE_ACTOR(En_Wiz, ACTOR_EN_WIZ, ALLOCTYPE_NORMAL, "En_Wiz") +/* 0x15E */ DEFINE_ACTOR(En_Wiz_Brock, ACTOR_EN_WIZ_BROCK, ALLOCTYPE_NORMAL, "En_Wiz_Brock") +/* 0x15F */ DEFINE_ACTOR(En_Wiz_Fire, ACTOR_EN_WIZ_FIRE, ALLOCTYPE_NORMAL, "En_Wiz_Fire") +/* 0x160 */ DEFINE_ACTOR(Eff_Change, ACTOR_EFF_CHANGE, ALLOCTYPE_NORMAL, "Eff_Change") +/* 0x161 */ DEFINE_ACTOR(Dm_Statue, ACTOR_DM_STATUE, ALLOCTYPE_NORMAL, "Dm_Statue") +/* 0x162 */ DEFINE_ACTOR(Obj_Fireshield, ACTOR_OBJ_FIRESHIELD, ALLOCTYPE_NORMAL, "Obj_Fireshield") +/* 0x163 */ DEFINE_ACTOR(Bg_Ladder, ACTOR_BG_LADDER, ALLOCTYPE_NORMAL, "Bg_Ladder") +/* 0x164 */ DEFINE_ACTOR(En_Mkk, ACTOR_EN_MKK, ALLOCTYPE_NORMAL, "En_Mkk") +/* 0x165 */ DEFINE_ACTOR(Demo_Getitem, ACTOR_DEMO_GETITEM, ALLOCTYPE_NORMAL, "Demo_Getitem") +/* 0x166 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_166) +/* 0x167 */ DEFINE_ACTOR(En_Dnb, ACTOR_EN_DNB, ALLOCTYPE_NORMAL, "En_Dnb") +/* 0x168 */ DEFINE_ACTOR(En_Dnh, ACTOR_EN_DNH, ALLOCTYPE_NORMAL, "En_Dnh") +/* 0x169 */ DEFINE_ACTOR(En_Dnk, ACTOR_EN_DNK, ALLOCTYPE_NORMAL, "En_Dnk") +/* 0x16A */ DEFINE_ACTOR(En_Dnq, ACTOR_EN_DNQ, ALLOCTYPE_NORMAL, "En_Dnq") +/* 0x16B */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_16B) +/* 0x16C */ DEFINE_ACTOR(Bg_Keikoku_Saku, ACTOR_BG_KEIKOKU_SAKU, ALLOCTYPE_NORMAL, "Bg_Keikoku_Saku") +/* 0x16D */ DEFINE_ACTOR(Obj_Hugebombiwa, ACTOR_OBJ_HUGEBOMBIWA, ALLOCTYPE_NORMAL, "Obj_Hugebombiwa") +/* 0x16E */ DEFINE_ACTOR(En_Firefly2, ACTOR_EN_FIREFLY2, ALLOCTYPE_NORMAL, "En_Firefly2") +/* 0x16F */ DEFINE_ACTOR(En_Rat, ACTOR_EN_RAT, ALLOCTYPE_NORMAL, "En_Rat") +/* 0x170 */ DEFINE_ACTOR(En_Water_Effect, ACTOR_EN_WATER_EFFECT, ALLOCTYPE_NORMAL, "En_Water_Effect") +/* 0x171 */ DEFINE_ACTOR(En_Kusa2, ACTOR_EN_KUSA2, ALLOCTYPE_NORMAL, "En_Kusa2") +/* 0x172 */ DEFINE_ACTOR(Bg_Spout_Fire, ACTOR_BG_SPOUT_FIRE, ALLOCTYPE_NORMAL, "Bg_Spout_Fire") +/* 0x173 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_173) +/* 0x174 */ DEFINE_ACTOR(Bg_Dblue_Movebg, ACTOR_BG_DBLUE_MOVEBG, ALLOCTYPE_NORMAL, "Bg_Dblue_Movebg") +/* 0x175 */ DEFINE_ACTOR(En_Dy_Extra, ACTOR_EN_DY_EXTRA, ALLOCTYPE_NORMAL, "En_Dy_Extra") +/* 0x176 */ DEFINE_ACTOR(En_Bal, ACTOR_EN_BAL, ALLOCTYPE_NORMAL, "En_Bal") +/* 0x177 */ DEFINE_ACTOR(En_Ginko_Man, ACTOR_EN_GINKO_MAN, ALLOCTYPE_NORMAL, "En_Ginko_Man") +/* 0x178 */ DEFINE_ACTOR(En_Warp_Uzu, ACTOR_EN_WARP_UZU, ALLOCTYPE_NORMAL, "En_Warp_Uzu") +/* 0x179 */ DEFINE_ACTOR(Obj_Driftice, ACTOR_OBJ_DRIFTICE, ALLOCTYPE_NORMAL, "Obj_Driftice") +/* 0x17A */ DEFINE_ACTOR(En_Look_Nuts, ACTOR_EN_LOOK_NUTS, ALLOCTYPE_NORMAL, "En_Look_Nuts") +/* 0x17B */ DEFINE_ACTOR(En_Mushi2, ACTOR_EN_MUSHI2, ALLOCTYPE_NORMAL, "En_Mushi2") +/* 0x17C */ DEFINE_ACTOR(En_Fall, ACTOR_EN_FALL, ALLOCTYPE_NORMAL, "En_Fall") +/* 0x17D */ DEFINE_ACTOR(En_Mm3, ACTOR_EN_MM3, ALLOCTYPE_NORMAL, "En_Mm3") +/* 0x17E */ DEFINE_ACTOR(Bg_Crace_Movebg, ACTOR_BG_CRACE_MOVEBG, ALLOCTYPE_NORMAL, "Bg_Crace_Movebg") +/* 0x17F */ DEFINE_ACTOR(En_Dno, ACTOR_EN_DNO, ALLOCTYPE_NORMAL, "En_Dno") +/* 0x180 */ DEFINE_ACTOR(En_Pr2, ACTOR_EN_PR2, ALLOCTYPE_NORMAL, "En_Pr2") +/* 0x181 */ DEFINE_ACTOR(En_Prz, ACTOR_EN_PRZ, ALLOCTYPE_NORMAL, "En_Prz") +/* 0x182 */ DEFINE_ACTOR(En_Jso2, ACTOR_EN_JSO2, ALLOCTYPE_NORMAL, "En_Jso2") +/* 0x183 */ DEFINE_ACTOR(Obj_Etcetera, ACTOR_OBJ_ETCETERA, ALLOCTYPE_NORMAL, "Obj_Etcetera") +/* 0x184 */ DEFINE_ACTOR(En_Egol, ACTOR_EN_EGOL, ALLOCTYPE_NORMAL, "En_Egol") +/* 0x185 */ DEFINE_ACTOR(Obj_Mine, ACTOR_OBJ_MINE, ALLOCTYPE_NORMAL, "Obj_Mine") +/* 0x186 */ DEFINE_ACTOR(Obj_Purify, ACTOR_OBJ_PURIFY, ALLOCTYPE_NORMAL, "Obj_Purify") +/* 0x187 */ DEFINE_ACTOR(En_Tru, ACTOR_EN_TRU, ALLOCTYPE_NORMAL, "En_Tru") +/* 0x188 */ DEFINE_ACTOR(En_Trt, ACTOR_EN_TRT, ALLOCTYPE_NORMAL, "En_Trt") +/* 0x189 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_189) +/* 0x18A */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_18A) +/* 0x18B */ DEFINE_ACTOR(En_Test5, ACTOR_EN_TEST5, ALLOCTYPE_NORMAL, "En_Test5") +/* 0x18C */ DEFINE_ACTOR(En_Test6, ACTOR_EN_TEST6, ALLOCTYPE_NORMAL, "En_Test6") +/* 0x18D */ DEFINE_ACTOR(En_Az, ACTOR_EN_AZ, ALLOCTYPE_NORMAL, "En_Az") +/* 0x18E */ DEFINE_ACTOR(En_Estone, ACTOR_EN_ESTONE, ALLOCTYPE_NORMAL, "En_Estone") +/* 0x18F */ DEFINE_ACTOR(Bg_Hakugin_Post, ACTOR_BG_HAKUGIN_POST, ALLOCTYPE_NORMAL, "Bg_Hakugin_Post") +/* 0x190 */ DEFINE_ACTOR(Dm_Opstage, ACTOR_DM_OPSTAGE, ALLOCTYPE_NORMAL, "Dm_Opstage") +/* 0x191 */ DEFINE_ACTOR(Dm_Stk, ACTOR_DM_STK, ALLOCTYPE_NORMAL, "Dm_Stk") +/* 0x192 */ DEFINE_ACTOR(Dm_Char00, ACTOR_DM_CHAR00, ALLOCTYPE_NORMAL, "Dm_Char00") +/* 0x193 */ DEFINE_ACTOR(Dm_Char01, ACTOR_DM_CHAR01, ALLOCTYPE_NORMAL, "Dm_Char01") +/* 0x194 */ DEFINE_ACTOR(Dm_Char02, ACTOR_DM_CHAR02, ALLOCTYPE_NORMAL, "Dm_Char02") +/* 0x195 */ DEFINE_ACTOR(Dm_Char03, ACTOR_DM_CHAR03, ALLOCTYPE_NORMAL, "Dm_Char03") +/* 0x196 */ DEFINE_ACTOR(Dm_Char04, ACTOR_DM_CHAR04, ALLOCTYPE_NORMAL, "Dm_Char04") +/* 0x197 */ DEFINE_ACTOR(Dm_Char05, ACTOR_DM_CHAR05, ALLOCTYPE_NORMAL, "Dm_Char05") +/* 0x198 */ DEFINE_ACTOR(Dm_Char06, ACTOR_DM_CHAR06, ALLOCTYPE_NORMAL, "Dm_Char06") +/* 0x199 */ DEFINE_ACTOR(Dm_Char07, ACTOR_DM_CHAR07, ALLOCTYPE_NORMAL, "Dm_Char07") +/* 0x19A */ DEFINE_ACTOR(Dm_Char08, ACTOR_DM_CHAR08, ALLOCTYPE_NORMAL, "Dm_Char08") +/* 0x19B */ DEFINE_ACTOR(Dm_Char09, ACTOR_DM_CHAR09, ALLOCTYPE_NORMAL, "Dm_Char09") +/* 0x19C */ DEFINE_ACTOR(Obj_Tokeidai, ACTOR_OBJ_TOKEIDAI, ALLOCTYPE_NORMAL, "Obj_Tokeidai") +/* 0x19D */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_19D) +/* 0x19E */ DEFINE_ACTOR(En_Mnk, ACTOR_EN_MNK, ALLOCTYPE_NORMAL, "En_Mnk") +/* 0x19F */ DEFINE_ACTOR(En_Egblock, ACTOR_EN_EGBLOCK, ALLOCTYPE_NORMAL, "En_Egblock") +/* 0x1A0 */ DEFINE_ACTOR(En_Guard_Nuts, ACTOR_EN_GUARD_NUTS, ALLOCTYPE_NORMAL, "En_Guard_Nuts") +/* 0x1A1 */ DEFINE_ACTOR(Bg_Hakugin_Bombwall, ACTOR_BG_HAKUGIN_BOMBWALL, ALLOCTYPE_NORMAL, "Bg_Hakugin_Bombwall") +/* 0x1A2 */ DEFINE_ACTOR(Obj_Tokei_Tobira, ACTOR_OBJ_TOKEI_TOBIRA, ALLOCTYPE_NORMAL, "Obj_Tokei_Tobira") +/* 0x1A3 */ DEFINE_ACTOR(Bg_Hakugin_Elvpole, ACTOR_BG_HAKUGIN_ELVPOLE, ALLOCTYPE_NORMAL, "Bg_Hakugin_Elvpole") +/* 0x1A4 */ DEFINE_ACTOR(En_Ma4, ACTOR_EN_MA4, ALLOCTYPE_NORMAL, "En_Ma4") +/* 0x1A5 */ DEFINE_ACTOR(En_Twig, ACTOR_EN_TWIG, ALLOCTYPE_NORMAL, "En_Twig") +/* 0x1A6 */ DEFINE_ACTOR(En_Po_Fusen, ACTOR_EN_PO_FUSEN, ALLOCTYPE_NORMAL, "En_Po_Fusen") +/* 0x1A7 */ DEFINE_ACTOR(En_Door_Etc, ACTOR_EN_DOOR_ETC, ALLOCTYPE_NORMAL, "En_Door_Etc") +/* 0x1A8 */ DEFINE_ACTOR(En_Bigokuta, ACTOR_EN_BIGOKUTA, ALLOCTYPE_NORMAL, "En_Bigokuta") +/* 0x1A9 */ DEFINE_ACTOR(Bg_Icefloe, ACTOR_BG_ICEFLOE, ALLOCTYPE_NORMAL, "Bg_Icefloe") +/* 0x1AA */ DEFINE_ACTOR(Obj_Ocarinalift, ACTOR_OBJ_OCARINALIFT, ALLOCTYPE_NORMAL, "Obj_Ocarinalift") +/* 0x1AB */ DEFINE_ACTOR(En_Time_Tag, ACTOR_EN_TIME_TAG, ALLOCTYPE_NORMAL, "En_Time_Tag") +/* 0x1AC */ DEFINE_ACTOR(Bg_Open_Shutter, ACTOR_BG_OPEN_SHUTTER, ALLOCTYPE_NORMAL, "Bg_Open_Shutter") +/* 0x1AD */ DEFINE_ACTOR(Bg_Open_Spot, ACTOR_BG_OPEN_SPOT, ALLOCTYPE_NORMAL, "Bg_Open_Spot") +/* 0x1AE */ DEFINE_ACTOR(Bg_Fu_Kaiten, ACTOR_BG_FU_KAITEN, ALLOCTYPE_NORMAL, "Bg_Fu_Kaiten") +/* 0x1AF */ DEFINE_ACTOR(Obj_Aqua, ACTOR_OBJ_AQUA, ALLOCTYPE_NORMAL, "Obj_Aqua") +/* 0x1B0 */ DEFINE_ACTOR(En_Elforg, ACTOR_EN_ELFORG, ALLOCTYPE_NORMAL, "En_Elforg") +/* 0x1B1 */ DEFINE_ACTOR(En_Elfbub, ACTOR_EN_ELFBUB, ALLOCTYPE_NORMAL, "En_Elfbub") +/* 0x1B2 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_1B2) +/* 0x1B3 */ DEFINE_ACTOR(En_Fu_Mato, ACTOR_EN_FU_MATO, ALLOCTYPE_NORMAL, "En_Fu_Mato") +/* 0x1B4 */ DEFINE_ACTOR(En_Fu_Kago, ACTOR_EN_FU_KAGO, ALLOCTYPE_NORMAL, "En_Fu_Kago") +/* 0x1B5 */ DEFINE_ACTOR(En_Osn, ACTOR_EN_OSN, ALLOCTYPE_NORMAL, "En_Osn") +/* 0x1B6 */ DEFINE_ACTOR(Bg_Ctower_Gear, ACTOR_BG_CTOWER_GEAR, ALLOCTYPE_NORMAL, "Bg_Ctower_Gear") +/* 0x1B7 */ DEFINE_ACTOR(En_Trt2, ACTOR_EN_TRT2, ALLOCTYPE_NORMAL, "En_Trt2") +/* 0x1B8 */ DEFINE_ACTOR(Obj_Tokei_Step, ACTOR_OBJ_TOKEI_STEP, ALLOCTYPE_NORMAL, "Obj_Tokei_Step") +/* 0x1B9 */ DEFINE_ACTOR(Bg_Lotus, ACTOR_BG_LOTUS, ALLOCTYPE_NORMAL, "Bg_Lotus") +/* 0x1BA */ DEFINE_ACTOR(En_Kame, ACTOR_EN_KAME, ALLOCTYPE_NORMAL, "En_Kame") +/* 0x1BB */ DEFINE_ACTOR(Obj_Takaraya_Wall, ACTOR_OBJ_TAKARAYA_WALL, ALLOCTYPE_NORMAL, "Obj_Takaraya_Wall") +/* 0x1BC */ DEFINE_ACTOR(Bg_Fu_Mizu, ACTOR_BG_FU_MIZU, ALLOCTYPE_NORMAL, "Bg_Fu_Mizu") +/* 0x1BD */ DEFINE_ACTOR(En_Sellnuts, ACTOR_EN_SELLNUTS, ALLOCTYPE_NORMAL, "En_Sellnuts") +/* 0x1BE */ DEFINE_ACTOR(Bg_Dkjail_Ivy, ACTOR_BG_DKJAIL_IVY, ALLOCTYPE_NORMAL, "Bg_Dkjail_Ivy") +/* 0x1BF */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_1BF) +/* 0x1C0 */ DEFINE_ACTOR(Obj_Visiblock, ACTOR_OBJ_VISIBLOCK, ALLOCTYPE_NORMAL, "Obj_Visiblock") +/* 0x1C1 */ DEFINE_ACTOR(En_Takaraya, ACTOR_EN_TAKARAYA, ALLOCTYPE_NORMAL, "En_Takaraya") +/* 0x1C2 */ DEFINE_ACTOR(En_Tsn, ACTOR_EN_TSN, ALLOCTYPE_NORMAL, "En_Tsn") +/* 0x1C3 */ DEFINE_ACTOR(En_Ds2n, ACTOR_EN_DS2N, ALLOCTYPE_NORMAL, "En_Ds2n") +/* 0x1C4 */ DEFINE_ACTOR(En_Fsn, ACTOR_EN_FSN, ALLOCTYPE_NORMAL, "En_Fsn") +/* 0x1C5 */ DEFINE_ACTOR(En_Shn, ACTOR_EN_SHN, ALLOCTYPE_NORMAL, "En_Shn") +/* 0x1C6 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_1C6) +/* 0x1C7 */ DEFINE_ACTOR(En_Stop_heishi, ACTOR_EN_STOP_HEISHI, ALLOCTYPE_NORMAL, "En_Stop_heishi") +/* 0x1C8 */ DEFINE_ACTOR(Obj_Bigicicle, ACTOR_OBJ_BIGICICLE, ALLOCTYPE_NORMAL, "Obj_Bigicicle") +/* 0x1C9 */ DEFINE_ACTOR(En_Lift_Nuts, ACTOR_EN_LIFT_NUTS, ALLOCTYPE_NORMAL, "En_Lift_Nuts") +/* 0x1CA */ DEFINE_ACTOR(En_Tk, ACTOR_EN_TK, ALLOCTYPE_NORMAL, "En_Tk") +/* 0x1CB */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_1CB) +/* 0x1CC */ DEFINE_ACTOR(Bg_Market_Step, ACTOR_BG_MARKET_STEP, ALLOCTYPE_NORMAL, "Bg_Market_Step") +/* 0x1CD */ DEFINE_ACTOR(Obj_Lupygamelift, ACTOR_OBJ_LUPYGAMELIFT, ALLOCTYPE_NORMAL, "Obj_Lupygamelift") +/* 0x1CE */ DEFINE_ACTOR(En_Test7, ACTOR_EN_TEST7, ALLOCTYPE_NORMAL, "En_Test7") +/* 0x1CF */ DEFINE_ACTOR(Obj_Lightblock, ACTOR_OBJ_LIGHTBLOCK, ALLOCTYPE_NORMAL, "Obj_Lightblock") +/* 0x1D0 */ DEFINE_ACTOR(Mir_Ray2, ACTOR_MIR_RAY2, ALLOCTYPE_NORMAL, "Mir_Ray2") +/* 0x1D1 */ DEFINE_ACTOR(En_Wdhand, ACTOR_EN_WDHAND, ALLOCTYPE_NORMAL, "En_Wdhand") +/* 0x1D2 */ DEFINE_ACTOR(En_Gamelupy, ACTOR_EN_GAMELUPY, ALLOCTYPE_NORMAL, "En_Gamelupy") +/* 0x1D3 */ DEFINE_ACTOR(Bg_Danpei_Movebg, ACTOR_BG_DANPEI_MOVEBG, ALLOCTYPE_NORMAL, "Bg_Danpei_Movebg") +/* 0x1D4 */ DEFINE_ACTOR(En_Snowwd, ACTOR_EN_SNOWWD, ALLOCTYPE_NORMAL, "En_Snowwd") +/* 0x1D5 */ DEFINE_ACTOR(En_Pm, ACTOR_EN_PM, ALLOCTYPE_NORMAL, "En_Pm") +/* 0x1D6 */ DEFINE_ACTOR(En_Gakufu, ACTOR_EN_GAKUFU, ALLOCTYPE_NORMAL, "En_Gakufu") +/* 0x1D7 */ DEFINE_ACTOR(Elf_Msg4, ACTOR_ELF_MSG4, ALLOCTYPE_NORMAL, "Elf_Msg4") +/* 0x1D8 */ DEFINE_ACTOR(Elf_Msg5, ACTOR_ELF_MSG5, ALLOCTYPE_NORMAL, "Elf_Msg5") +/* 0x1D9 */ DEFINE_ACTOR(En_Col_Man, ACTOR_EN_COL_MAN, ALLOCTYPE_NORMAL, "En_Col_Man") +/* 0x1DA */ DEFINE_ACTOR(En_Talk_Gibud, ACTOR_EN_TALK_GIBUD, ALLOCTYPE_NORMAL, "En_Talk_Gibud") +/* 0x1DB */ DEFINE_ACTOR(En_Giant, ACTOR_EN_GIANT, ALLOCTYPE_NORMAL, "En_Giant") +/* 0x1DC */ DEFINE_ACTOR(Obj_Snowball, ACTOR_OBJ_SNOWBALL, ALLOCTYPE_NORMAL, "Obj_Snowball") +/* 0x1DD */ DEFINE_ACTOR(Boss_Hakugin, ACTOR_BOSS_HAKUGIN, ALLOCTYPE_NORMAL, "Boss_Hakugin") +/* 0x1DE */ DEFINE_ACTOR(En_Gb2, ACTOR_EN_GB2, ALLOCTYPE_NORMAL, "En_Gb2") +/* 0x1DF */ DEFINE_ACTOR(En_Onpuman, ACTOR_EN_ONPUMAN, ALLOCTYPE_NORMAL, "En_Onpuman") +/* 0x1E0 */ DEFINE_ACTOR(Bg_Tobira01, ACTOR_BG_TOBIRA01, ALLOCTYPE_NORMAL, "Bg_Tobira01") +/* 0x1E1 */ DEFINE_ACTOR(En_Tag_Obj, ACTOR_EN_TAG_OBJ, ALLOCTYPE_NORMAL, "En_Tag_Obj") +/* 0x1E2 */ DEFINE_ACTOR(Obj_Dhouse, ACTOR_OBJ_DHOUSE, ALLOCTYPE_NORMAL, "Obj_Dhouse") +/* 0x1E3 */ DEFINE_ACTOR(Obj_Hakaisi, ACTOR_OBJ_HAKAISI, ALLOCTYPE_NORMAL, "Obj_Hakaisi") +/* 0x1E4 */ DEFINE_ACTOR(Bg_Hakugin_Switch, ACTOR_BG_HAKUGIN_SWITCH, ALLOCTYPE_NORMAL, "Bg_Hakugin_Switch") +/* 0x1E5 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_1E5) +/* 0x1E6 */ DEFINE_ACTOR(En_Snowman, ACTOR_EN_SNOWMAN, ALLOCTYPE_NORMAL, "En_Snowman") +/* 0x1E7 */ DEFINE_ACTOR(TG_Sw, ACTOR_TG_SW, ALLOCTYPE_NORMAL, "TG_Sw") +/* 0x1E8 */ DEFINE_ACTOR(En_Po_Sisters, ACTOR_EN_PO_SISTERS, ALLOCTYPE_NORMAL, "En_Po_Sisters") +/* 0x1E9 */ DEFINE_ACTOR(En_Pp, ACTOR_EN_PP, ALLOCTYPE_NORMAL, "En_Pp") +/* 0x1EA */ DEFINE_ACTOR(En_Hakurock, ACTOR_EN_HAKUROCK, ALLOCTYPE_NORMAL, "En_Hakurock") +/* 0x1EB */ DEFINE_ACTOR(En_Hanabi, ACTOR_EN_HANABI, ALLOCTYPE_NORMAL, "En_Hanabi") +/* 0x1EC */ DEFINE_ACTOR(Obj_Dowsing, ACTOR_OBJ_DOWSING, ALLOCTYPE_NORMAL, "Obj_Dowsing") +/* 0x1ED */ DEFINE_ACTOR(Obj_Wind, ACTOR_OBJ_WIND, ALLOCTYPE_NORMAL, "Obj_Wind") +/* 0x1EE */ DEFINE_ACTOR(En_Racedog, ACTOR_EN_RACEDOG, ALLOCTYPE_NORMAL, "En_Racedog") +/* 0x1EF */ DEFINE_ACTOR(En_Kendo_Js, ACTOR_EN_KENDO_JS, ALLOCTYPE_NORMAL, "En_Kendo_Js") +/* 0x1F0 */ DEFINE_ACTOR(Bg_Botihasira, ACTOR_BG_BOTIHASIRA, ALLOCTYPE_NORMAL, "Bg_Botihasira") +/* 0x1F1 */ DEFINE_ACTOR(En_Fish2, ACTOR_EN_FISH2, ALLOCTYPE_NORMAL, "En_Fish2") +/* 0x1F2 */ DEFINE_ACTOR(En_Pst, ACTOR_EN_PST, ALLOCTYPE_NORMAL, "En_Pst") +/* 0x1F3 */ DEFINE_ACTOR(En_Poh, ACTOR_EN_POH, ALLOCTYPE_NORMAL, "En_Poh") +/* 0x1F4 */ DEFINE_ACTOR(Obj_Spidertent, ACTOR_OBJ_SPIDERTENT, ALLOCTYPE_NORMAL, "Obj_Spidertent") +/* 0x1F5 */ DEFINE_ACTOR(En_Zoraegg, ACTOR_EN_ZORAEGG, ALLOCTYPE_NORMAL, "En_Zoraegg") +/* 0x1F6 */ DEFINE_ACTOR(En_Kbt, ACTOR_EN_KBT, ALLOCTYPE_NORMAL, "En_Kbt") +/* 0x1F7 */ DEFINE_ACTOR(En_Gg, ACTOR_EN_GG, ALLOCTYPE_NORMAL, "En_Gg") +/* 0x1F8 */ DEFINE_ACTOR(En_Maruta, ACTOR_EN_MARUTA, ALLOCTYPE_NORMAL, "En_Maruta") +/* 0x1F9 */ DEFINE_ACTOR(Obj_Snowball2, ACTOR_OBJ_SNOWBALL2, ALLOCTYPE_NORMAL, "Obj_Snowball2") +/* 0x1FA */ DEFINE_ACTOR(En_Gg2, ACTOR_EN_GG2, ALLOCTYPE_NORMAL, "En_Gg2") +/* 0x1FB */ DEFINE_ACTOR(Obj_Ghaka, ACTOR_OBJ_GHAKA, ALLOCTYPE_NORMAL, "Obj_Ghaka") +/* 0x1FC */ DEFINE_ACTOR(En_Dnp, ACTOR_EN_DNP, ALLOCTYPE_NORMAL, "En_Dnp") +/* 0x1FD */ DEFINE_ACTOR(En_Dai, ACTOR_EN_DAI, ALLOCTYPE_NORMAL, "En_Dai") +/* 0x1FE */ DEFINE_ACTOR(Bg_Goron_Oyu, ACTOR_BG_GORON_OYU, ALLOCTYPE_NORMAL, "Bg_Goron_Oyu") +/* 0x1FF */ DEFINE_ACTOR(En_Kgy, ACTOR_EN_KGY, ALLOCTYPE_NORMAL, "En_Kgy") +/* 0x200 */ DEFINE_ACTOR(En_Invadepoh, ACTOR_EN_INVADEPOH, ALLOCTYPE_NORMAL, "En_Invadepoh") +/* 0x201 */ DEFINE_ACTOR(En_Gk, ACTOR_EN_GK, ALLOCTYPE_NORMAL, "En_Gk") +/* 0x202 */ DEFINE_ACTOR(En_An, ACTOR_EN_AN, ALLOCTYPE_NORMAL, "En_An") +/* 0x203 */ DEFINE_ACTOR_UNSET(ACTOR_UNSET_203) +/* 0x204 */ DEFINE_ACTOR(En_Bee, ACTOR_EN_BEE, ALLOCTYPE_NORMAL, "En_Bee") +/* 0x205 */ DEFINE_ACTOR(En_Ot, ACTOR_EN_OT, ALLOCTYPE_NORMAL, "En_Ot") +/* 0x206 */ DEFINE_ACTOR(En_Dragon, ACTOR_EN_DRAGON, ALLOCTYPE_NORMAL, "En_Dragon") +/* 0x207 */ DEFINE_ACTOR(Obj_Dora, ACTOR_OBJ_DORA, ALLOCTYPE_NORMAL, "Obj_Dora") +/* 0x208 */ DEFINE_ACTOR(En_Bigpo, ACTOR_EN_BIGPO, ALLOCTYPE_NORMAL, "En_Bigpo") +/* 0x209 */ DEFINE_ACTOR(Obj_Kendo_Kanban, ACTOR_OBJ_KENDO_KANBAN, ALLOCTYPE_NORMAL, "Obj_Kendo_Kanban") +/* 0x20A */ DEFINE_ACTOR(Obj_Hariko, ACTOR_OBJ_HARIKO, ALLOCTYPE_NORMAL, "Obj_Hariko") +/* 0x20B */ DEFINE_ACTOR(En_Sth, ACTOR_EN_STH, ALLOCTYPE_NORMAL, "En_Sth") +/* 0x20C */ DEFINE_ACTOR(Bg_Sinkai_Kabe, ACTOR_BG_SINKAI_KABE, ALLOCTYPE_NORMAL, "Bg_Sinkai_Kabe") +/* 0x20D */ DEFINE_ACTOR(Bg_Haka_Curtain, ACTOR_BG_HAKA_CURTAIN, ALLOCTYPE_NORMAL, "Bg_Haka_Curtain") +/* 0x20E */ DEFINE_ACTOR(Bg_Kin2_Bombwall, ACTOR_BG_KIN2_BOMBWALL, ALLOCTYPE_NORMAL, "Bg_Kin2_Bombwall") +/* 0x20F */ DEFINE_ACTOR(Bg_Kin2_Fence, ACTOR_BG_KIN2_FENCE, ALLOCTYPE_NORMAL, "Bg_Kin2_Fence") +/* 0x210 */ DEFINE_ACTOR(Bg_Kin2_Picture, ACTOR_BG_KIN2_PICTURE, ALLOCTYPE_NORMAL, "Bg_Kin2_Picture") +/* 0x211 */ DEFINE_ACTOR(Bg_Kin2_Shelf, ACTOR_BG_KIN2_SHELF, ALLOCTYPE_NORMAL, "Bg_Kin2_Shelf") +/* 0x212 */ DEFINE_ACTOR(En_Rail_Skb, ACTOR_EN_RAIL_SKB, ALLOCTYPE_NORMAL, "En_Rail_Skb") +/* 0x213 */ DEFINE_ACTOR(En_Jg, ACTOR_EN_JG, ALLOCTYPE_NORMAL, "En_Jg") +/* 0x214 */ DEFINE_ACTOR(En_Tru_Mt, ACTOR_EN_TRU_MT, ALLOCTYPE_NORMAL, "En_Tru_Mt") +/* 0x215 */ DEFINE_ACTOR(Obj_Um, ACTOR_OBJ_UM, ALLOCTYPE_NORMAL, "Obj_Um") +/* 0x216 */ DEFINE_ACTOR(En_Neo_Reeba, ACTOR_EN_NEO_REEBA, ALLOCTYPE_NORMAL, "En_Neo_Reeba") +/* 0x217 */ DEFINE_ACTOR(Bg_Mbar_Chair, ACTOR_BG_MBAR_CHAIR, ALLOCTYPE_NORMAL, "Bg_Mbar_Chair") +/* 0x218 */ DEFINE_ACTOR(Bg_Ikana_Block, ACTOR_BG_IKANA_BLOCK, ALLOCTYPE_NORMAL, "Bg_Ikana_Block") +/* 0x219 */ DEFINE_ACTOR(Bg_Ikana_Mirror, ACTOR_BG_IKANA_MIRROR, ALLOCTYPE_NORMAL, "Bg_Ikana_Mirror") +/* 0x21A */ DEFINE_ACTOR(Bg_Ikana_Rotaryroom, ACTOR_BG_IKANA_ROTARYROOM, ALLOCTYPE_NORMAL, "Bg_Ikana_Rotaryroom") +/* 0x21B */ DEFINE_ACTOR(Bg_Dblue_Balance, ACTOR_BG_DBLUE_BALANCE, ALLOCTYPE_NORMAL, "Bg_Dblue_Balance") +/* 0x21C */ DEFINE_ACTOR(Bg_Dblue_Waterfall, ACTOR_BG_DBLUE_WATERFALL, ALLOCTYPE_NORMAL, "Bg_Dblue_Waterfall") +/* 0x21D */ DEFINE_ACTOR(En_Kaizoku, ACTOR_EN_KAIZOKU, ALLOCTYPE_NORMAL, "En_Kaizoku") +/* 0x21E */ DEFINE_ACTOR(En_Ge2, ACTOR_EN_GE2, ALLOCTYPE_NORMAL, "En_Ge2") +/* 0x21F */ DEFINE_ACTOR(En_Ma_Yts, ACTOR_EN_MA_YTS, ALLOCTYPE_NORMAL, "En_Ma_Yts") +/* 0x220 */ DEFINE_ACTOR(En_Ma_Yto, ACTOR_EN_MA_YTO, ALLOCTYPE_NORMAL, "En_Ma_Yto") +/* 0x221 */ DEFINE_ACTOR(Obj_Tokei_Turret, ACTOR_OBJ_TOKEI_TURRET, ALLOCTYPE_NORMAL, "Obj_Tokei_Turret") +/* 0x222 */ DEFINE_ACTOR(Bg_Dblue_Elevator, ACTOR_BG_DBLUE_ELEVATOR, ALLOCTYPE_NORMAL, "Bg_Dblue_Elevator") +/* 0x223 */ DEFINE_ACTOR(Obj_Warpstone, ACTOR_OBJ_WARPSTONE, ALLOCTYPE_NORMAL, "Obj_Warpstone") +/* 0x224 */ DEFINE_ACTOR(En_Zog, ACTOR_EN_ZOG, ALLOCTYPE_NORMAL, "En_Zog") +/* 0x225 */ DEFINE_ACTOR(Obj_Rotlift, ACTOR_OBJ_ROTLIFT, ALLOCTYPE_NORMAL, "Obj_Rotlift") +/* 0x226 */ DEFINE_ACTOR(Obj_Jg_Gakki, ACTOR_OBJ_JG_GAKKI, ALLOCTYPE_NORMAL, "Obj_Jg_Gakki") +/* 0x227 */ DEFINE_ACTOR(Bg_Inibs_Movebg, ACTOR_BG_INIBS_MOVEBG, ALLOCTYPE_NORMAL, "Bg_Inibs_Movebg") +/* 0x228 */ DEFINE_ACTOR(En_Zot, ACTOR_EN_ZOT, ALLOCTYPE_NORMAL, "En_Zot") +/* 0x229 */ DEFINE_ACTOR(Obj_Tree, ACTOR_OBJ_TREE, ALLOCTYPE_NORMAL, "Obj_Tree") +/* 0x22A */ DEFINE_ACTOR(Obj_Y2lift, ACTOR_OBJ_Y2LIFT, ALLOCTYPE_NORMAL, "Obj_Y2lift") +/* 0x22B */ DEFINE_ACTOR(Obj_Y2shutter, ACTOR_OBJ_Y2SHUTTER, ALLOCTYPE_NORMAL, "Obj_Y2shutter") +/* 0x22C */ DEFINE_ACTOR(Obj_Boat, ACTOR_OBJ_BOAT, ALLOCTYPE_NORMAL, "Obj_Boat") +/* 0x22D */ DEFINE_ACTOR(Obj_Taru, ACTOR_OBJ_TARU, ALLOCTYPE_NORMAL, "Obj_Taru") +/* 0x22E */ DEFINE_ACTOR(Obj_Hunsui, ACTOR_OBJ_HUNSUI, ALLOCTYPE_NORMAL, "Obj_Hunsui") +/* 0x22F */ DEFINE_ACTOR(En_Jc_Mato, ACTOR_EN_JC_MATO, ALLOCTYPE_NORMAL, "En_Jc_Mato") +/* 0x230 */ DEFINE_ACTOR(Mir_Ray3, ACTOR_MIR_RAY3, ALLOCTYPE_NORMAL, "Mir_Ray3") +/* 0x231 */ DEFINE_ACTOR(En_Zob, ACTOR_EN_ZOB, ALLOCTYPE_NORMAL, "En_Zob") +/* 0x232 */ DEFINE_ACTOR(Elf_Msg6, ACTOR_ELF_MSG6, ALLOCTYPE_NORMAL, "Elf_Msg6") +/* 0x233 */ DEFINE_ACTOR(Obj_Nozoki, ACTOR_OBJ_NOZOKI, ALLOCTYPE_NORMAL, "Obj_Nozoki") +/* 0x234 */ DEFINE_ACTOR(En_Toto, ACTOR_EN_TOTO, ALLOCTYPE_NORMAL, "En_Toto") +/* 0x235 */ DEFINE_ACTOR(En_Railgibud, ACTOR_EN_RAILGIBUD, ALLOCTYPE_NORMAL, "En_Railgibud") +/* 0x236 */ DEFINE_ACTOR(En_Baba, ACTOR_EN_BABA, ALLOCTYPE_NORMAL, "En_Baba") +/* 0x237 */ DEFINE_ACTOR(En_Suttari, ACTOR_EN_SUTTARI, ALLOCTYPE_NORMAL, "En_Suttari") +/* 0x238 */ DEFINE_ACTOR(En_Zod, ACTOR_EN_ZOD, ALLOCTYPE_NORMAL, "En_Zod") +/* 0x239 */ DEFINE_ACTOR(En_Kujiya, ACTOR_EN_KUJIYA, ALLOCTYPE_NORMAL, "En_Kujiya") +/* 0x23A */ DEFINE_ACTOR(En_Geg, ACTOR_EN_GEG, ALLOCTYPE_NORMAL, "En_Geg") +/* 0x23B */ DEFINE_ACTOR(Obj_Kinoko, ACTOR_OBJ_KINOKO, ALLOCTYPE_NORMAL, "Obj_Kinoko") +/* 0x23C */ DEFINE_ACTOR(Obj_Yasi, ACTOR_OBJ_YASI, ALLOCTYPE_NORMAL, "Obj_Yasi") +/* 0x23D */ DEFINE_ACTOR(En_Tanron1, ACTOR_EN_TANRON1, ALLOCTYPE_NORMAL, "En_Tanron1") +/* 0x23E */ DEFINE_ACTOR(En_Tanron2, ACTOR_EN_TANRON2, ALLOCTYPE_NORMAL, "En_Tanron2") +/* 0x23F */ DEFINE_ACTOR(En_Tanron3, ACTOR_EN_TANRON3, ALLOCTYPE_NORMAL, "En_Tanron3") +/* 0x240 */ DEFINE_ACTOR(Obj_Chan, ACTOR_OBJ_CHAN, ALLOCTYPE_NORMAL, "Obj_Chan") +/* 0x241 */ DEFINE_ACTOR(En_Zos, ACTOR_EN_ZOS, ALLOCTYPE_NORMAL, "En_Zos") +/* 0x242 */ DEFINE_ACTOR(En_S_Goro, ACTOR_EN_S_GORO, ALLOCTYPE_NORMAL, "En_S_Goro") +/* 0x243 */ DEFINE_ACTOR(En_Nb, ACTOR_EN_NB, ALLOCTYPE_NORMAL, "En_Nb") +/* 0x244 */ DEFINE_ACTOR(En_Ja, ACTOR_EN_JA, ALLOCTYPE_NORMAL, "En_Ja") +/* 0x245 */ DEFINE_ACTOR(Bg_F40_Block, ACTOR_BG_F40_BLOCK, ALLOCTYPE_NORMAL, "Bg_F40_Block") +/* 0x246 */ DEFINE_ACTOR(Bg_F40_Switch, ACTOR_BG_F40_SWITCH, ALLOCTYPE_NORMAL, "Bg_F40_Switch") +/* 0x247 */ DEFINE_ACTOR(En_Po_Composer, ACTOR_EN_PO_COMPOSER, ALLOCTYPE_NORMAL, "En_Po_Composer") +/* 0x248 */ DEFINE_ACTOR(En_Guruguru, ACTOR_EN_GURUGURU, ALLOCTYPE_NORMAL, "En_Guruguru") +/* 0x249 */ DEFINE_ACTOR(Oceff_Wipe5, ACTOR_OCEFF_WIPE5, ALLOCTYPE_ABSOLUTE, "Oceff_Wipe5") +/* 0x24A */ DEFINE_ACTOR(En_Stone_heishi, ACTOR_EN_STONE_HEISHI, ALLOCTYPE_NORMAL, "En_Stone_heishi") +/* 0x24B */ DEFINE_ACTOR(Oceff_Wipe6, ACTOR_OCEFF_WIPE6, ALLOCTYPE_ABSOLUTE, "Oceff_Wipe6") +/* 0x24C */ DEFINE_ACTOR(En_Scopenuts, ACTOR_EN_SCOPENUTS, ALLOCTYPE_NORMAL, "En_Scopenuts") +/* 0x24D */ DEFINE_ACTOR(En_Scopecrow, ACTOR_EN_SCOPECROW, ALLOCTYPE_NORMAL, "En_Scopecrow") +/* 0x24E */ DEFINE_ACTOR(Oceff_Wipe7, ACTOR_OCEFF_WIPE7, ALLOCTYPE_ABSOLUTE, "Oceff_Wipe7") +/* 0x24F */ DEFINE_ACTOR(Eff_Kamejima_Wave, ACTOR_EFF_KAMEJIMA_WAVE, ALLOCTYPE_NORMAL, "Eff_Kamejima_Wave") +/* 0x250 */ DEFINE_ACTOR(En_Hg, ACTOR_EN_HG, ALLOCTYPE_NORMAL, "En_Hg") +/* 0x251 */ DEFINE_ACTOR(En_Hgo, ACTOR_EN_HGO, ALLOCTYPE_NORMAL, "En_Hgo") +/* 0x252 */ DEFINE_ACTOR(En_Zov, ACTOR_EN_ZOV, ALLOCTYPE_NORMAL, "En_Zov") +/* 0x253 */ DEFINE_ACTOR(En_Ah, ACTOR_EN_AH, ALLOCTYPE_NORMAL, "En_Ah") +/* 0x254 */ DEFINE_ACTOR(Obj_Hgdoor, ACTOR_OBJ_HGDOOR, ALLOCTYPE_NORMAL, "Obj_Hgdoor") +/* 0x255 */ DEFINE_ACTOR(Bg_Ikana_Bombwall, ACTOR_BG_IKANA_BOMBWALL, ALLOCTYPE_NORMAL, "Bg_Ikana_Bombwall") +/* 0x256 */ DEFINE_ACTOR(Bg_Ikana_Ray, ACTOR_BG_IKANA_RAY, ALLOCTYPE_NORMAL, "Bg_Ikana_Ray") +/* 0x257 */ DEFINE_ACTOR(Bg_Ikana_Shutter, ACTOR_BG_IKANA_SHUTTER, ALLOCTYPE_NORMAL, "Bg_Ikana_Shutter") +/* 0x258 */ DEFINE_ACTOR(Bg_Haka_Bombwall, ACTOR_BG_HAKA_BOMBWALL, ALLOCTYPE_NORMAL, "Bg_Haka_Bombwall") +/* 0x259 */ DEFINE_ACTOR(Bg_Haka_Tomb, ACTOR_BG_HAKA_TOMB, ALLOCTYPE_NORMAL, "Bg_Haka_Tomb") +/* 0x25A */ DEFINE_ACTOR(En_Sc_Ruppe, ACTOR_EN_SC_RUPPE, ALLOCTYPE_NORMAL, "En_Sc_Ruppe") +/* 0x25B */ DEFINE_ACTOR(Bg_Iknv_Doukutu, ACTOR_BG_IKNV_DOUKUTU, ALLOCTYPE_NORMAL, "Bg_Iknv_Doukutu") +/* 0x25C */ DEFINE_ACTOR(Bg_Iknv_Obj, ACTOR_BG_IKNV_OBJ, ALLOCTYPE_NORMAL, "Bg_Iknv_Obj") +/* 0x25D */ DEFINE_ACTOR(En_Pamera, ACTOR_EN_PAMERA, ALLOCTYPE_NORMAL, "En_Pamera") +/* 0x25E */ DEFINE_ACTOR(Obj_HsStump, ACTOR_OBJ_HSSTUMP, ALLOCTYPE_NORMAL, "Obj_HsStump") +/* 0x25F */ DEFINE_ACTOR(En_Hidden_Nuts, ACTOR_EN_HIDDEN_NUTS, ALLOCTYPE_NORMAL, "En_Hidden_Nuts") +/* 0x260 */ DEFINE_ACTOR(En_Zow, ACTOR_EN_ZOW, ALLOCTYPE_NORMAL, "En_Zow") +/* 0x261 */ DEFINE_ACTOR(En_Talk, ACTOR_EN_TALK, ALLOCTYPE_NORMAL, "En_Talk") +/* 0x262 */ DEFINE_ACTOR(En_Al, ACTOR_EN_AL, ALLOCTYPE_NORMAL, "En_Al") +/* 0x263 */ DEFINE_ACTOR(En_Tab, ACTOR_EN_TAB, ALLOCTYPE_NORMAL, "En_Tab") +/* 0x264 */ DEFINE_ACTOR(En_Nimotsu, ACTOR_EN_NIMOTSU, ALLOCTYPE_NORMAL, "En_Nimotsu") +/* 0x265 */ DEFINE_ACTOR(En_Hit_Tag, ACTOR_EN_HIT_TAG, ALLOCTYPE_NORMAL, "En_Hit_Tag") +/* 0x266 */ DEFINE_ACTOR(En_Ruppecrow, ACTOR_EN_RUPPECROW, ALLOCTYPE_NORMAL, "En_Ruppecrow") +/* 0x267 */ DEFINE_ACTOR(En_Tanron4, ACTOR_EN_TANRON4, ALLOCTYPE_NORMAL, "En_Tanron4") +/* 0x268 */ DEFINE_ACTOR(En_Tanron5, ACTOR_EN_TANRON5, ALLOCTYPE_NORMAL, "En_Tanron5") +/* 0x269 */ DEFINE_ACTOR(En_Tanron6, ACTOR_EN_TANRON6, ALLOCTYPE_NORMAL, "En_Tanron6") +/* 0x26A */ DEFINE_ACTOR(En_Daiku2, ACTOR_EN_DAIKU2, ALLOCTYPE_NORMAL, "En_Daiku2") +/* 0x26B */ DEFINE_ACTOR(En_Muto, ACTOR_EN_MUTO, ALLOCTYPE_NORMAL, "En_Muto") +/* 0x26C */ DEFINE_ACTOR(En_Baisen, ACTOR_EN_BAISEN, ALLOCTYPE_NORMAL, "En_Baisen") +/* 0x26D */ DEFINE_ACTOR(En_Heishi, ACTOR_EN_HEISHI, ALLOCTYPE_NORMAL, "En_Heishi") +/* 0x26E */ DEFINE_ACTOR(En_Demo_heishi, ACTOR_EN_DEMO_HEISHI, ALLOCTYPE_NORMAL, "En_Demo_heishi") +/* 0x26F */ DEFINE_ACTOR(En_Dt, ACTOR_EN_DT, ALLOCTYPE_NORMAL, "En_Dt") +/* 0x270 */ DEFINE_ACTOR(En_Cha, ACTOR_EN_CHA, ALLOCTYPE_NORMAL, "En_Cha") +/* 0x271 */ DEFINE_ACTOR(Obj_Dinner, ACTOR_OBJ_DINNER, ALLOCTYPE_NORMAL, "Obj_Dinner") +/* 0x272 */ DEFINE_ACTOR(Eff_Lastday, ACTOR_EFF_LASTDAY, ALLOCTYPE_NORMAL, "Eff_Lastday") +/* 0x273 */ DEFINE_ACTOR(Bg_Ikana_Dharma, ACTOR_BG_IKANA_DHARMA, ALLOCTYPE_NORMAL, "Bg_Ikana_Dharma") +/* 0x274 */ DEFINE_ACTOR(En_Akindonuts, ACTOR_EN_AKINDONUTS, ALLOCTYPE_NORMAL, "En_Akindonuts") +/* 0x275 */ DEFINE_ACTOR(Eff_Stk, ACTOR_EFF_STK, ALLOCTYPE_NORMAL, "Eff_Stk") +/* 0x276 */ DEFINE_ACTOR(En_Ig, ACTOR_EN_IG, ALLOCTYPE_NORMAL, "En_Ig") +/* 0x277 */ DEFINE_ACTOR(En_Rg, ACTOR_EN_RG, ALLOCTYPE_NORMAL, "En_Rg") +/* 0x278 */ DEFINE_ACTOR(En_Osk, ACTOR_EN_OSK, ALLOCTYPE_NORMAL, "En_Osk") +/* 0x279 */ DEFINE_ACTOR(En_Sth2, ACTOR_EN_STH2, ALLOCTYPE_NORMAL, "En_Sth2") +/* 0x27A */ DEFINE_ACTOR(En_Yb, ACTOR_EN_YB, ALLOCTYPE_NORMAL, "En_Yb") +/* 0x27B */ DEFINE_ACTOR(En_Rz, ACTOR_EN_RZ, ALLOCTYPE_NORMAL, "En_Rz") +/* 0x27C */ DEFINE_ACTOR(En_Scopecoin, ACTOR_EN_SCOPECOIN, ALLOCTYPE_NORMAL, "En_Scopecoin") +/* 0x27D */ DEFINE_ACTOR(En_Bjt, ACTOR_EN_BJT, ALLOCTYPE_NORMAL, "En_Bjt") +/* 0x27E */ DEFINE_ACTOR(En_Bomjima, ACTOR_EN_BOMJIMA, ALLOCTYPE_NORMAL, "En_Bomjima") +/* 0x27F */ DEFINE_ACTOR(En_Bomjimb, ACTOR_EN_BOMJIMB, ALLOCTYPE_NORMAL, "En_Bomjimb") +/* 0x280 */ DEFINE_ACTOR(En_Bombers, ACTOR_EN_BOMBERS, ALLOCTYPE_NORMAL, "En_Bombers") +/* 0x281 */ DEFINE_ACTOR(En_Bombers2, ACTOR_EN_BOMBERS2, ALLOCTYPE_NORMAL, "En_Bombers2") +/* 0x282 */ DEFINE_ACTOR(En_Bombal, ACTOR_EN_BOMBAL, ALLOCTYPE_NORMAL, "En_Bombal") +/* 0x283 */ DEFINE_ACTOR(Obj_Moon_Stone, ACTOR_OBJ_MOON_STONE, ALLOCTYPE_NORMAL, "Obj_Moon_Stone") +/* 0x284 */ DEFINE_ACTOR(Obj_Mu_Pict, ACTOR_OBJ_MU_PICT, ALLOCTYPE_NORMAL, "Obj_Mu_Pict") +/* 0x285 */ DEFINE_ACTOR(Bg_Ikninside, ACTOR_BG_IKNINSIDE, ALLOCTYPE_NORMAL, "Bg_Ikninside") +/* 0x286 */ DEFINE_ACTOR(Eff_Zoraband, ACTOR_EFF_ZORABAND, ALLOCTYPE_NORMAL, "Eff_Zoraband") +/* 0x287 */ DEFINE_ACTOR(Obj_Kepn_Koya, ACTOR_OBJ_KEPN_KOYA, ALLOCTYPE_NORMAL, "Obj_Kepn_Koya") +/* 0x288 */ DEFINE_ACTOR(Obj_Usiyane, ACTOR_OBJ_USIYANE, ALLOCTYPE_NORMAL, "Obj_Usiyane") +/* 0x289 */ DEFINE_ACTOR(En_Nnh, ACTOR_EN_NNH, ALLOCTYPE_NORMAL, "En_Nnh") +/* 0x28A */ DEFINE_ACTOR(Obj_Kzsaku, ACTOR_OBJ_KZSAKU, ALLOCTYPE_NORMAL, "Obj_Kzsaku") +/* 0x28B */ DEFINE_ACTOR(Obj_Milk_Bin, ACTOR_OBJ_MILK_BIN, ALLOCTYPE_NORMAL, "Obj_Milk_Bin") +/* 0x28C */ DEFINE_ACTOR(En_Kitan, ACTOR_EN_KITAN, ALLOCTYPE_NORMAL, "En_Kitan") +/* 0x28D */ DEFINE_ACTOR(Bg_Astr_Bombwall, ACTOR_BG_ASTR_BOMBWALL, ALLOCTYPE_NORMAL, "Bg_Astr_Bombwall") +/* 0x28E */ DEFINE_ACTOR(Bg_Iknin_Susceil, ACTOR_BG_IKNIN_SUSCEIL, ALLOCTYPE_NORMAL, "Bg_Iknin_Susceil") +/* 0x28F */ DEFINE_ACTOR(En_Bsb, ACTOR_EN_BSB, ALLOCTYPE_NORMAL, "En_Bsb") +/* 0x290 */ DEFINE_ACTOR(En_Recepgirl, ACTOR_EN_RECEPGIRL, ALLOCTYPE_NORMAL, "En_Recepgirl") +/* 0x291 */ DEFINE_ACTOR(En_Thiefbird, ACTOR_EN_THIEFBIRD, ALLOCTYPE_NORMAL, "En_Thiefbird") +/* 0x292 */ DEFINE_ACTOR(En_Jgame_Tsn, ACTOR_EN_JGAME_TSN, ALLOCTYPE_NORMAL, "En_Jgame_Tsn") +/* 0x293 */ DEFINE_ACTOR(Obj_Jgame_Light, ACTOR_OBJ_JGAME_LIGHT, ALLOCTYPE_NORMAL, "Obj_Jgame_Light") +/* 0x294 */ DEFINE_ACTOR(Obj_Yado, ACTOR_OBJ_YADO, ALLOCTYPE_NORMAL, "Obj_Yado") +/* 0x295 */ DEFINE_ACTOR(Demo_Syoten, ACTOR_DEMO_SYOTEN, ALLOCTYPE_NORMAL, "Demo_Syoten") +/* 0x296 */ DEFINE_ACTOR(Demo_Moonend, ACTOR_DEMO_MOONEND, ALLOCTYPE_NORMAL, "Demo_Moonend") +/* 0x297 */ DEFINE_ACTOR(Bg_Lbfshot, ACTOR_BG_LBFSHOT, ALLOCTYPE_NORMAL, "Bg_Lbfshot") +/* 0x298 */ DEFINE_ACTOR(Bg_Last_Bwall, ACTOR_BG_LAST_BWALL, ALLOCTYPE_NORMAL, "Bg_Last_Bwall") +/* 0x299 */ DEFINE_ACTOR(En_And, ACTOR_EN_AND, ALLOCTYPE_NORMAL, "En_And") +/* 0x29A */ DEFINE_ACTOR(En_Invadepoh_Demo, ACTOR_EN_INVADEPOH_DEMO, ALLOCTYPE_NORMAL, "En_Invadepoh_Demo") +/* 0x29B */ DEFINE_ACTOR(Obj_Danpeilift, ACTOR_OBJ_DANPEILIFT, ALLOCTYPE_NORMAL, "Obj_Danpeilift") +/* 0x29C */ DEFINE_ACTOR(En_Fall2, ACTOR_EN_FALL2, ALLOCTYPE_NORMAL, "En_Fall2") +/* 0x29D */ DEFINE_ACTOR(Dm_Al, ACTOR_DM_AL, ALLOCTYPE_NORMAL, "Dm_Al") +/* 0x29E */ DEFINE_ACTOR(Dm_An, ACTOR_DM_AN, ALLOCTYPE_NORMAL, "Dm_An") +/* 0x29F */ DEFINE_ACTOR(Dm_Ah, ACTOR_DM_AH, ALLOCTYPE_NORMAL, "Dm_Ah") +/* 0x2A0 */ DEFINE_ACTOR(Dm_Nb, ACTOR_DM_NB, ALLOCTYPE_NORMAL, "Dm_Nb") +/* 0x2A1 */ DEFINE_ACTOR(En_Drs, ACTOR_EN_DRS, ALLOCTYPE_NORMAL, "En_Drs") +/* 0x2A2 */ DEFINE_ACTOR(En_Ending_Hero, ACTOR_EN_ENDING_HERO, ALLOCTYPE_NORMAL, "En_Ending_Hero") +/* 0x2A3 */ DEFINE_ACTOR(Dm_Bal, ACTOR_DM_BAL, ALLOCTYPE_NORMAL, "Dm_Bal") +/* 0x2A4 */ DEFINE_ACTOR(En_Paper, ACTOR_EN_PAPER, ALLOCTYPE_NORMAL, "En_Paper") +/* 0x2A5 */ DEFINE_ACTOR(En_Hint_Skb, ACTOR_EN_HINT_SKB, ALLOCTYPE_NORMAL, "En_Hint_Skb") +/* 0x2A6 */ DEFINE_ACTOR(Dm_Tag, ACTOR_DM_TAG, ALLOCTYPE_NORMAL, "Dm_Tag") +/* 0x2A7 */ DEFINE_ACTOR(En_Bh, ACTOR_EN_BH, ALLOCTYPE_NORMAL, "En_Bh") +/* 0x2A8 */ DEFINE_ACTOR(En_Ending_Hero2, ACTOR_EN_ENDING_HERO2, ALLOCTYPE_NORMAL, "En_Ending_Hero2") +/* 0x2A9 */ DEFINE_ACTOR(En_Ending_Hero3, ACTOR_EN_ENDING_HERO3, ALLOCTYPE_NORMAL, "En_Ending_Hero3") +/* 0x2AA */ DEFINE_ACTOR(En_Ending_Hero4, ACTOR_EN_ENDING_HERO4, ALLOCTYPE_NORMAL, "En_Ending_Hero4") +/* 0x2AB */ DEFINE_ACTOR(En_Ending_Hero5, ACTOR_EN_ENDING_HERO5, ALLOCTYPE_NORMAL, "En_Ending_Hero5") +/* 0x2AC */ DEFINE_ACTOR(En_Ending_Hero6, ACTOR_EN_ENDING_HERO6, ALLOCTYPE_NORMAL, "En_Ending_Hero6") +/* 0x2AD */ DEFINE_ACTOR(Dm_Gm, ACTOR_DM_GM, ALLOCTYPE_NORMAL, "Dm_Gm") +/* 0x2AE */ DEFINE_ACTOR(Obj_Swprize, ACTOR_OBJ_SWPRIZE, ALLOCTYPE_NORMAL, "Obj_Swprize") +/* 0x2AF */ DEFINE_ACTOR(En_Invisible_Ruppe, ACTOR_EN_INVISIBLE_RUPPE, ALLOCTYPE_NORMAL, "En_Invisible_Ruppe") +/* 0x2B0 */ DEFINE_ACTOR(Obj_Ending, ACTOR_OBJ_ENDING, ALLOCTYPE_NORMAL, "Obj_Ending") +/* 0x2B1 */ DEFINE_ACTOR(En_Rsn, ACTOR_EN_RSN, ALLOCTYPE_NORMAL, "En_Rsn") 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..ad2bc2463 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -13,6 +13,8 @@ #include "ultra64/rcp.h" #include "ultra64/rdp.h" #include "ultra64/rsp.h" +#include "ultra64/r4300.h" +#include "ultra64/ucode.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/ucode.h b/include/ultra64/ucode.h new file mode 100644 index 000000000..8a1d89037 --- /dev/null +++ b/include/ultra64/ucode.h @@ -0,0 +1,31 @@ +#ifndef ULTRA64_UCODE_H +#define ULTRA64_UCODE_H + +#include "PR/ultratypes.h" + +#define SP_DRAM_STACK_SIZE8 0x400 +#define SP_DRAM_STACK_SIZE64 (SP_DRAM_STACK_SIZE8 >> 3) + +#define SP_UCODE_SIZE 0x1000 + +#define SP_UCODE_DATA_SIZE 0x800 + +extern u64 rspbootTextStart[]; +extern u64 rspbootTextEnd[]; + +extern u64 aspMainTextStart[]; +extern u64 aspMainTextEnd[]; +extern u64 aspMainDataStart[]; +extern u64 aspMainDataEnd[]; + +extern u64 gspF3DZEX2_NoN_PosLight_fifoTextStart[]; +extern u64 gspF3DZEX2_NoN_PosLight_fifoTextEnd[]; +extern u64 gspF3DZEX2_NoN_PosLight_fifoDataStart[]; +extern u64 gspF3DZEX2_NoN_PosLight_fifoDataEnd[]; + +extern u64 gspS2DEX2_fifoTextStart[]; +extern u64 gspS2DEX2_fifoTextEnd[]; +extern u64 gspS2DEX2_fifoDataStart[]; +extern u64 gspS2DEX2_fifoDataEnd[]; + +#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 c37938555..9381fc7e2 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1,5 +1,5 @@ -#ifndef _VARIABLES_H_ -#define _VARIABLES_H_ +#ifndef VARIABLES_H +#define VARIABLES_H #include "z64.h" #include "segment_symbols.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; @@ -358,12 +358,7 @@ extern u16 viRetrace; extern DmaEntry dmadata[1568]; // extern UNK_TYPE1 D_80186028; extern u64 aspMainTextStart[]; -extern ActorInit En_A_Obj_InitVars; -extern ColliderCylinderInit enAObjCylinderInit; -extern InitChainEntry enAObjInitVar; -extern Gfx* enAObjDisplayLists[2]; -extern UNK_PTR D_801ADF30[5]; -extern UNK_PTR D_801ADF44[12]; + extern u8 sDropTable[DROP_TABLE_SIZE * DROP_TABLE_NUMBER]; extern u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER]; extern s32 D_801AE194[32]; @@ -414,7 +409,6 @@ extern EffectSsOverlay gParticleOverlayTable[39]; extern f32 actorMovementScale; extern TargetRangeParams gTargetRanges[]; extern s16 D_801AED48[8]; -// extern UNK_TYPE4 D_801AED58; extern Color_RGBA8 actorDefaultHitColor; // extern UNK_TYPE1 D_801AED8C; // extern UNK_TYPE4 D_801AED98; @@ -431,396 +425,11 @@ extern Gfx D_801AEFA0[]; // extern UNK_TYPE1 D_801AEFBC; // extern UNK_TYPE1 D_801AEFC0; extern ActorOverlay gActorOverlayTable[ACTOR_ID_MAX]; -extern s32 gMaxActorId; +extern ActorId gMaxActorId; extern BgCheckSceneSubdivisionEntry sSceneSubdivisionList[]; extern BgSpecialSceneMaxObjects sCustomDynapolyMem[]; // extern UNK_TYPE1 D_801B4708; -// extern UNK_TYPE1 D_801B4710; -// extern UNK_TYPE1 D_801B4738; -// extern UNK_TYPE1 D_801B4768; -// extern UNK_TYPE1 D_801B4798; -// extern UNK_TYPE1 D_801B47CC; -// extern UNK_TYPE1 D_801B47F0; -// extern UNK_TYPE1 D_801B4824; -// extern UNK_TYPE1 D_801B4848; -// extern UNK_TYPE1 D_801B486C; -// extern UNK_TYPE1 D_801B4890; -// extern UNK_TYPE1 D_801B48B0; -// extern UNK_TYPE1 D_801B48D4; -// extern UNK_TYPE1 D_801B48F8; -// extern UNK_TYPE1 D_801B491C; -// extern UNK_TYPE1 D_801B4944; -// extern UNK_TYPE1 D_801B4974; -// extern UNK_TYPE1 D_801B49A4; -// extern UNK_TYPE1 D_801B49D4; -// extern UNK_TYPE1 D_801B4A04; -// extern UNK_TYPE1 D_801B4A34; -// extern UNK_TYPE1 D_801B4A5C; -// extern UNK_TYPE1 D_801B4A8C; -// extern UNK_TYPE1 D_801B4ABC; -// extern UNK_TYPE1 D_801B4AE0; -// extern UNK_TYPE1 D_801B4B08; -// extern UNK_TYPE1 D_801B4B38; -// extern UNK_TYPE1 D_801B4B60; -// extern UNK_TYPE1 D_801B4B90; -// extern UNK_TYPE1 D_801B4BB8; -// extern UNK_TYPE1 D_801B4BDC; -// extern UNK_TYPE1 D_801B4C04; -// extern UNK_TYPE1 D_801B4C34; -// extern UNK_TYPE1 D_801B4C5C; -// extern UNK_TYPE1 D_801B4C84; -// extern UNK_TYPE1 D_801B4CAC; -// extern UNK_TYPE1 D_801B4CD4; -// extern UNK_TYPE1 D_801B4CFC; -// extern UNK_TYPE1 D_801B4D24; -// extern UNK_TYPE1 D_801B4D34; -// extern UNK_TYPE1 D_801B4D44; -// extern UNK_TYPE1 D_801B4D68; -// extern UNK_TYPE1 D_801B4D8C; -// extern UNK_TYPE1 D_801B4DB0; -// extern UNK_TYPE1 D_801B4DD4; -// extern UNK_TYPE1 D_801B4DF8; -// extern UNK_TYPE1 D_801B4E2C; -// extern UNK_TYPE1 D_801B4E5C; -// extern UNK_TYPE1 D_801B4E90; -// extern UNK_TYPE1 D_801B4EB4; -// extern UNK_TYPE1 D_801B4ED8; -// extern UNK_TYPE1 D_801B4EDC; -// extern UNK_TYPE1 D_801B4EE4; -// extern UNK_TYPE1 D_801B4EF0; -// extern UNK_TYPE1 D_801B4EF4; -// extern UNK_TYPE1 D_801B4EF8; -// extern UNK_TYPE1 D_801B4F20; -// extern UNK_TYPE1 D_801B4F50; -// extern UNK_TYPE1 D_801B4F78; -// extern UNK_TYPE1 D_801B4FA0; -// extern UNK_TYPE1 D_801B4FC8; -// extern UNK_TYPE1 D_801B4FF0; -// extern UNK_TYPE1 D_801B5018; -// extern UNK_TYPE1 D_801B5034; -// extern UNK_TYPE1 D_801B5050; -// extern UNK_TYPE1 D_801B506C; -// extern UNK_TYPE1 D_801B507C; -// extern UNK_TYPE1 D_801B5094; -// extern UNK_TYPE1 D_801B50BC; -// extern UNK_TYPE1 D_801B50EC; -// extern UNK_TYPE1 D_801B511C; -// extern UNK_TYPE1 D_801B5150; -// extern UNK_TYPE1 D_801B5180; -// extern UNK_TYPE1 D_801B51A8; -// extern UNK_TYPE1 D_801B51D8; -// extern UNK_TYPE1 D_801B51FC; -// extern UNK_TYPE1 D_801B5220; -// extern UNK_TYPE1 D_801B5250; -// extern UNK_TYPE1 D_801B5280; -// extern UNK_TYPE1 D_801B52B0; -// extern UNK_TYPE1 D_801B52E0; -// extern UNK_TYPE1 D_801B5308; -// extern UNK_TYPE1 D_801B5338; -// extern UNK_TYPE1 D_801B535C; -// extern UNK_TYPE1 D_801B5380; -// extern UNK_TYPE1 D_801B53A4; -// extern UNK_TYPE1 D_801B53C8; -// extern UNK_TYPE1 D_801B53EC; -// extern UNK_TYPE1 D_801B5410; -// extern UNK_TYPE1 D_801B5434; -// extern UNK_TYPE1 D_801B5458; -// extern UNK_TYPE1 D_801B547C; -// extern UNK_TYPE1 D_801B54A0; -// extern UNK_TYPE1 D_801B54C4; -// extern UNK_TYPE1 D_801B54E8; -// extern UNK_TYPE1 D_801B550C; -// extern UNK_TYPE1 D_801B5530; -// extern UNK_TYPE1 D_801B5554; -// extern UNK_TYPE1 D_801B5578; -// extern UNK_TYPE1 D_801B559C; -// extern UNK_TYPE1 D_801B55C0; -// extern UNK_TYPE1 D_801B55E4; -// extern UNK_TYPE1 D_801B5608; -// extern UNK_TYPE1 D_801B562C; -// extern UNK_TYPE1 D_801B5650; -// extern UNK_TYPE1 D_801B5674; -// extern UNK_TYPE1 D_801B5698; -// extern UNK_TYPE1 D_801B56BC; -// extern UNK_TYPE1 D_801B56E0; -// extern UNK_TYPE1 D_801B5704; -// extern UNK_TYPE1 D_801B5728; -// extern UNK_TYPE1 D_801B574C; -// extern UNK_TYPE1 D_801B5770; -// extern UNK_TYPE1 D_801B577C; -// extern UNK_TYPE1 D_801B57A4; -// extern UNK_TYPE1 D_801B57CC; -// extern UNK_TYPE1 D_801B57F4; -// extern UNK_TYPE1 D_801B5824; -// extern UNK_TYPE1 D_801B5834; -// extern UNK_TYPE1 D_801B5844; -// extern UNK_TYPE1 D_801B5864; -// extern UNK_TYPE1 D_801B5884; -// extern UNK_TYPE1 D_801B58A0; -// extern UNK_TYPE1 D_801B58BC; -// extern UNK_TYPE1 D_801B58D8; -// extern UNK_TYPE1 D_801B58F4; -// extern UNK_TYPE1 D_801B5904; -// extern UNK_TYPE1 D_801B5928; -// extern UNK_TYPE1 D_801B5950; -// extern UNK_TYPE1 D_801B5978; -// extern UNK_TYPE1 D_801B59A8; -// extern UNK_TYPE1 D_801B59D0; -// extern UNK_TYPE1 D_801B59F4; -// extern UNK_TYPE1 D_801B5A00; -// extern UNK_TYPE1 D_801B5A0C; -// extern UNK_TYPE1 D_801B5A30; -// extern UNK_TYPE1 D_801B5A64; -// extern UNK_TYPE1 D_801B5A94; -// extern UNK_TYPE1 D_801B5ABC; -// extern UNK_TYPE1 D_801B5AF0; -// extern UNK_TYPE1 D_801B5B18; -// extern UNK_TYPE1 D_801B5B40; -// extern UNK_TYPE1 D_801B5B70; -// extern UNK_TYPE1 D_801B5B98; -// extern UNK_TYPE1 D_801B5BC8; -// extern UNK_TYPE1 D_801B5BFC; -// extern UNK_TYPE1 D_801B5C30; -// extern UNK_TYPE1 D_801B5C58; -// extern UNK_TYPE1 D_801B5C80; -// extern UNK_TYPE1 D_801B5CB0; -// extern UNK_TYPE1 D_801B5CCC; -// extern UNK_TYPE1 D_801B5CE8; -// extern UNK_TYPE1 D_801B5D10; -// extern UNK_TYPE1 D_801B5D40; -// extern UNK_TYPE1 D_801B5D74; -// extern UNK_TYPE1 D_801B5D9C; -// extern UNK_TYPE1 D_801B5DC4; -// extern UNK_TYPE1 D_801B5DD4; -// extern UNK_TYPE1 D_801B5DFC; -// extern UNK_TYPE1 D_801B5E2C; -// extern UNK_TYPE1 D_801B5E48; -// extern UNK_TYPE1 D_801B5E64; -// extern UNK_TYPE1 D_801B5E8C; -// extern UNK_TYPE1 D_801B5EB4; -// extern UNK_TYPE1 D_801B5EDC; -// extern UNK_TYPE1 D_801B5F0C; -// extern UNK_TYPE1 D_801B5F34; -// extern UNK_TYPE1 D_801B5F5C; -// extern UNK_TYPE1 D_801B5F8C; -// extern UNK_TYPE1 D_801B5FB0; -// extern UNK_TYPE1 D_801B5FD4; -// extern UNK_TYPE1 D_801B5FF8; -// extern UNK_TYPE1 D_801B601C; -// extern UNK_TYPE1 D_801B6044; -// extern UNK_TYPE1 D_801B6074; -// extern UNK_TYPE1 D_801B60A4; -// extern UNK_TYPE1 D_801B60D8; -// extern UNK_TYPE1 D_801B610C; -// extern UNK_TYPE1 D_801B6130; -// extern UNK_TYPE1 D_801B6154; -// extern UNK_TYPE1 D_801B617C; -// extern UNK_TYPE1 D_801B61AC; -// extern UNK_TYPE1 D_801B61DC; -// extern UNK_TYPE1 D_801B620C; -// extern UNK_TYPE1 D_801B623C; -// extern UNK_TYPE1 D_801B626C; -// extern UNK_TYPE1 D_801B6294; -// extern UNK_TYPE1 D_801B62C4; -// extern UNK_TYPE1 D_801B62F4; -// extern UNK_TYPE1 D_801B631C; -// extern UNK_TYPE1 D_801B634C; -// extern UNK_TYPE1 D_801B6374; -// extern UNK_TYPE1 D_801B63A4; -// extern UNK_TYPE1 D_801B63CC; -// extern UNK_TYPE1 D_801B63FC; -// extern UNK_TYPE1 D_801B6418; -// extern UNK_TYPE1 D_801B6434; -// extern UNK_TYPE1 D_801B645C; -// extern UNK_TYPE1 D_801B648C; -// extern UNK_TYPE1 D_801B64B4; -// extern UNK_TYPE1 D_801B64D8; -// extern UNK_TYPE1 D_801B64FC; -// extern UNK_TYPE1 D_801B652C; -// extern UNK_TYPE1 D_801B655C; -// extern UNK_TYPE1 D_801B6584; -// extern UNK_TYPE1 D_801B65AC; -// extern UNK_TYPE1 D_801B65DC; -// extern UNK_TYPE1 D_801B660C; -// extern UNK_TYPE1 D_801B6640; -// extern UNK_TYPE1 D_801B6674; -// extern UNK_TYPE1 D_801B6698; -// extern UNK_TYPE1 D_801B66C0; -// extern UNK_TYPE1 D_801B66E8; -// extern UNK_TYPE1 D_801B6710; -// extern UNK_TYPE1 D_801B6740; -// extern UNK_TYPE1 D_801B6774; -// extern UNK_TYPE1 D_801B679C; -// extern UNK_TYPE1 D_801B67C4; -// extern UNK_TYPE1 D_801B67EC; -// extern UNK_TYPE1 D_801B681C; -// extern UNK_TYPE1 D_801B684C; -// extern UNK_TYPE1 D_801B6880; -// extern UNK_TYPE1 D_801B68A8; -// extern UNK_TYPE1 D_801B68D0; -// extern UNK_TYPE1 D_801B68F8; -// extern UNK_TYPE1 D_801B692C; -// extern UNK_TYPE1 D_801B6954; -// extern UNK_TYPE1 D_801B697C; -// extern UNK_TYPE1 D_801B69A4; -// extern UNK_TYPE1 D_801B69CC; -// extern UNK_TYPE1 D_801B69FC; -// extern UNK_TYPE1 D_801B6A30; -// extern UNK_TYPE1 D_801B6A58; -// extern UNK_TYPE1 D_801B6A80; -// extern UNK_TYPE1 D_801B6AA8; -// extern UNK_TYPE1 D_801B6AD0; -// extern UNK_TYPE1 D_801B6AF8; -// extern UNK_TYPE1 D_801B6B28; -// extern UNK_TYPE1 D_801B6B50; -// extern UNK_TYPE1 D_801B6B78; -// extern UNK_TYPE1 D_801B6BA0; -// extern UNK_TYPE1 D_801B6BC8; -// extern UNK_TYPE1 D_801B6BF0; -// extern UNK_TYPE1 D_801B6C18; -// extern UNK_TYPE1 D_801B6C48; -// extern UNK_TYPE1 D_801B6C70; -// extern UNK_TYPE1 D_801B6C98; -// extern UNK_TYPE1 D_801B6CC0; -// extern UNK_TYPE1 D_801B6CF0; -// extern UNK_TYPE1 D_801B6D24; -// extern UNK_TYPE1 D_801B6D4C; -// extern UNK_TYPE1 D_801B6D74; -// extern UNK_TYPE1 D_801B6D90; -// extern UNK_TYPE1 D_801B6DB8; -// extern UNK_TYPE1 D_801B6DE0; -// extern UNK_TYPE1 D_801B6E08; -// extern UNK_TYPE1 D_801B6E30; -// extern UNK_TYPE1 D_801B6E58; -// extern UNK_TYPE1 D_801B6E80; -// extern UNK_TYPE1 D_801B6EA8; -// extern UNK_TYPE1 D_801B6ED0; -// extern UNK_TYPE1 D_801B6EF8; -// extern UNK_TYPE1 D_801B6F20; -// extern UNK_TYPE1 D_801B6F50; -// extern UNK_TYPE1 D_801B6F78; -// extern UNK_TYPE1 D_801B6FA0; -// extern UNK_TYPE1 D_801B6FB0; -// extern UNK_TYPE1 D_801B6FD8; -// extern UNK_TYPE1 D_801B7008; -// extern UNK_TYPE1 D_801B703C; -// extern UNK_TYPE1 D_801B7064; -// extern UNK_TYPE1 D_801B708C; -// extern UNK_TYPE1 D_801B70BC; -// extern UNK_TYPE1 D_801B70E4; -// extern UNK_TYPE1 D_801B7114; -// extern UNK_TYPE1 D_801B7148; -// extern UNK_TYPE1 D_801B7170; -// extern UNK_TYPE1 D_801B71A0; -// extern UNK_TYPE1 D_801B71D4; -// extern UNK_TYPE1 D_801B7204; -// extern UNK_TYPE1 D_801B7210; -// extern UNK_TYPE1 D_801B7244; -// extern UNK_TYPE1 D_801B7278; -// extern UNK_TYPE1 D_801B729C; -// extern UNK_TYPE1 D_801B72C0; -// extern UNK_TYPE1 D_801B72E4; -// extern UNK_TYPE1 D_801B7308; -// extern UNK_TYPE1 D_801B732C; -// extern UNK_TYPE1 D_801B7354; -// extern UNK_TYPE1 D_801B7384; -// extern UNK_TYPE1 D_801B73AC; -// extern UNK_TYPE1 D_801B73D4; -// extern UNK_TYPE1 D_801B74C4; -// extern UNK_TYPE1 D_801B759C; -// extern UNK_TYPE1 D_801B75F4; -// extern UNK_TYPE1 D_801B767C; -// extern UNK_TYPE1 D_801B7684; -// extern UNK_TYPE1 D_801B768C; -// extern UNK_TYPE1 D_801B7694; -// extern UNK_TYPE1 D_801B769C; -// extern UNK_TYPE1 D_801B76A4; -// extern UNK_TYPE1 D_801B76AC; -// extern UNK_TYPE1 D_801B777C; -// extern UNK_TYPE1 D_801B784C; -// extern UNK_TYPE1 D_801B791C; -// extern UNK_TYPE1 D_801B7984; -// extern UNK_TYPE1 D_801B79EC; -// extern UNK_TYPE1 D_801B79F4; -// extern UNK_TYPE1 D_801B7AE4; -// extern UNK_TYPE1 D_801B7B14; -// extern UNK_TYPE1 D_801B7B44; -// extern UNK_TYPE1 D_801B7B74; -// extern UNK_TYPE1 D_801B7BA4; -// extern UNK_TYPE1 D_801B7BAC; -// extern UNK_TYPE1 D_801B7BDC; -// extern UNK_TYPE1 D_801B7C0C; -// extern UNK_TYPE1 D_801B7C3C; -// extern UNK_TYPE1 D_801B7C44; -// extern UNK_TYPE1 D_801B7C54; -// extern UNK_TYPE1 D_801B7C5C; -// extern UNK_TYPE1 D_801B7C64; -// extern UNK_TYPE1 D_801B7D34; -// extern UNK_TYPE1 D_801B7D3C; -// extern UNK_TYPE1 D_801B7D44; -// extern UNK_TYPE1 D_801B7D4C; -// extern UNK_TYPE1 D_801B7D54; -// extern UNK_TYPE1 D_801B7D5C; -// extern UNK_TYPE1 D_801B7D64; -// extern UNK_TYPE1 D_801B7DCC; -// extern UNK_TYPE1 D_801B7DD4; -// extern UNK_TYPE1 D_801B7E3C; -// extern UNK_TYPE1 D_801B7F0C; -// extern UNK_TYPE1 D_801B7F14; -// extern UNK_TYPE1 D_801B7F1C; -// extern UNK_TYPE1 D_801B7F24; -// extern UNK_TYPE1 D_801B7F2C; -// extern UNK_TYPE1 D_801B7F34; -// extern UNK_TYPE1 D_801B7F3C; -// extern UNK_TYPE1 D_801B7FAC; -// extern UNK_TYPE1 D_801B807C; -// extern UNK_TYPE1 D_801B8084; -// extern UNK_TYPE1 D_801B8154; -// extern UNK_TYPE1 D_801B8224; -// extern UNK_TYPE1 D_801B82F4; -// extern UNK_TYPE1 D_801B82FC; -// extern UNK_TYPE1 D_801B8304; -// extern UNK_TYPE1 D_801B83D4; -// extern UNK_TYPE1 D_801B83DC; -// extern UNK_TYPE1 D_801B8434; -// extern UNK_TYPE1 D_801B843C; -// extern UNK_TYPE1 D_801B8444; -// extern UNK_TYPE1 D_801B8514; -// extern UNK_TYPE1 D_801B85E4; -// extern UNK_TYPE1 D_801B8664; -// extern UNK_TYPE1 D_801B8754; -// extern UNK_TYPE1 D_801B875C; -// extern UNK_TYPE1 D_801B87C4; -// extern UNK_TYPE1 D_801B8894; -// extern UNK_TYPE1 D_801B8964; -// extern UNK_TYPE1 D_801B8A34; -// extern UNK_TYPE1 D_801B8B04; -// extern UNK_TYPE1 D_801B8BD4; -// extern UNK_TYPE1 D_801B8CAC; -// extern UNK_TYPE1 D_801B8CB4; -// extern UNK_TYPE1 D_801B8D8C; -// extern UNK_TYPE1 D_801B8E5C; -// extern UNK_TYPE1 D_801B8F2C; -// extern UNK_TYPE1 D_801B8F34; -// extern UNK_TYPE1 D_801B900C; -// extern UNK_TYPE1 D_801B90D4; -// extern UNK_TYPE1 D_801B91A4; -// extern UNK_TYPE1 D_801B91AC; -// extern UNK_TYPE1 D_801B927C; -// extern UNK_TYPE1 D_801B9354; -// extern UNK_TYPE1 D_801B9424; -// extern UNK_TYPE1 D_801B94F4; -// extern UNK_TYPE1 D_801B95C4; -// extern UNK_TYPE1 D_801B95CC; -// extern UNK_TYPE1 D_801B969C; -// extern UNK_TYPE1 D_801B976C; -// extern UNK_TYPE1 D_801B979C; -extern CameraStateParams cameraStates[91]; -// extern UNK_TYPE1 D_801B9CE2; -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; // extern UNK_TYPE4 D_801B9E10; // extern UNK_TYPE4 D_801B9E14; @@ -835,8 +444,8 @@ extern camera_update_func cameraUpdateFuncs[71]; // extern UNK_TYPE1 D_801B9E84; // extern UNK_TYPE4 D_801B9EB4; // extern UNK_TYPE4 D_801B9ED4; -// extern UNK_TYPE4 D_801B9F04; -// extern UNK_TYPE2 D_801B9F0C; +// extern UNK_TYPE4 sEarthquakeFreq; +// extern UNK_TYPE2 sEarthquakeTimer; extern UNK_TYPE4 D_801B9F10; extern DamageTable sDamageTablePresets[23]; extern f32 damageMultipliers[16]; @@ -870,7 +479,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 +490,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 +525,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; @@ -1021,308 +629,14 @@ extern UNK_PTR D_801BEC14; // extern UNK_TYPE2 D_801BF5B0; extern UNK_PTR D_801BF5C0; // extern UNK_TYPE1 D_801BF68C; -// extern UNK_TYPE1 D_801BF6C0; -// extern UNK_TYPE1 D_801BF79E; -// extern UNK_TYPE2 D_801BF884; -// extern UNK_TYPE2 D_801BF888; -// extern UNK_TYPE2 D_801BF88C; -// extern UNK_TYPE2 D_801BF890; -// extern UNK_TYPE2 D_801BF898; -// extern UNK_TYPE2 D_801BF89C; -// extern UNK_TYPE2 D_801BF8A0; -// extern UNK_TYPE2 D_801BF8A4; -// extern UNK_TYPE2 D_801BF8A8; -// extern UNK_TYPE2 D_801BF8AC; -// extern UNK_TYPE2 D_801BF8B0; -// extern UNK_TYPE2 D_801BF8DC; -// extern UNK_TYPE2 D_801BF8E0; -// extern UNK_TYPE2 D_801BF8E4; -// extern UNK_TYPE4 D_801BF8E8; -// extern UNK_TYPE4 D_801BF8F0; -// extern UNK_TYPE4 D_801BF8F4; -// extern UNK_TYPE4 D_801BF8F8; -// extern UNK_TYPE4 D_801BF8FC; -// extern UNK_TYPE4 D_801BF930; -// extern UNK_TYPE4 D_801BF934; -// extern UNK_TYPE1 D_801BF968; -// extern UNK_TYPE1 D_801BF96A; -// extern UNK_TYPE1 D_801BF96C; -// extern UNK_TYPE1 D_801BF96E; -// extern UNK_TYPE2 D_801BF970; -// extern UNK_TYPE1 D_801BF972; -// extern UNK_TYPE2 D_801BF974; -// extern UNK_TYPE2 D_801BF978; -// extern UNK_TYPE2 D_801BF97C; -// extern UNK_TYPE4 D_801BF980; -// extern UNK_TYPE1 D_801BF988; -// extern UNK_TYPE1 D_801BF998; -// extern UNK_TYPE2 D_801BF9B0; -// extern UNK_TYPE1 D_801BF9B4; -// extern UNK_TYPE1 D_801BF9BC; -// extern UNK_TYPE1 D_801BF9C4; -// extern UNK_TYPE1 D_801BF9C8; -// extern UNK_TYPE1 D_801BF9CC; -// extern UNK_TYPE2 D_801BF9D4; -// extern UNK_TYPE2 D_801BF9D6; -// extern UNK_TYPE2 D_801BF9D8; -// extern UNK_TYPE2 D_801BF9DA; -// extern UNK_TYPE2 D_801BF9DC; -// extern UNK_TYPE2 D_801BF9DE; -// extern UNK_TYPE2 D_801BF9E0; -// extern UNK_TYPE2 D_801BF9E2; -// extern UNK_TYPE2 D_801BF9E4; -// extern UNK_TYPE2 D_801BF9E6; -// extern UNK_TYPE2 D_801BF9E8; -// extern UNK_TYPE2 D_801BF9EA; -// extern UNK_TYPE2 D_801BF9EC; -// extern UNK_TYPE2 D_801BF9F0; -// extern UNK_TYPE2 D_801BF9F4; -// extern UNK_TYPE2 D_801BF9F8; -// extern UNK_TYPE2 D_801BF9FC; -// extern UNK_TYPE2 D_801BFA00; -// extern UNK_TYPE2 D_801BFA04; -// extern UNK_TYPE2 D_801BFA1C; -// extern UNK_TYPE2 D_801BFA34; -// extern UNK_TYPE2 D_801BFA4C; -// extern UNK_TYPE2 D_801BFA64; -// extern UNK_TYPE2 D_801BFA74; -// extern UNK_TYPE4 D_801BFA84; -// extern UNK_TYPE1 D_801BFAB0; -// extern UNK_TYPE1 D_801BFAB8; -// extern UNK_TYPE1 D_801BFAC4; -// extern UNK_TYPE1 D_801BFACC; -// extern UNK_TYPE1 D_801BFAD4; -// extern UNK_TYPE2 D_801BFAF4; -// extern UNK_TYPE2 D_801BFAF6; -// extern UNK_TYPE2 D_801BFAF8; -// extern UNK_TYPE2 D_801BFAFA; -// extern UNK_TYPE1 D_801BFAFC; -// extern UNK_TYPE1 D_801BFB04; -// extern UNK_TYPE1 D_801BFB0C; -// extern UNK_TYPE1 D_801BFB14; -// extern UNK_TYPE1 D_801BFB1C; -// extern UNK_TYPE1 D_801BFB24; -// extern UNK_TYPE2 D_801BFB2C; -// extern UNK_TYPE2 D_801BFB30; -// extern UNK_TYPE2 D_801BFB34; -// extern UNK_TYPE1 D_801BFB38; -// extern UNK_TYPE1 D_801BFB6C; -// extern UNK_TYPE2 D_801BFBCC; -// extern UNK_TYPE2 D_801BFBD0; -// extern UNK_TYPE2 D_801BFBD4; -// extern UNK_TYPE2 D_801BFBD8; -// extern UNK_TYPE2 D_801BFBDC; -// extern UNK_TYPE2 D_801BFBE0; -// extern UNK_TYPE2 D_801BFBE4; -// extern UNK_TYPE2 D_801BFBE8; -// extern UNK_TYPE1 D_801BFBEC; -// extern UNK_TYPE1 D_801BFBF0; -// extern UNK_TYPE1 D_801BFBF4; -// extern UNK_TYPE1 D_801BFBF8; -// extern UNK_TYPE1 D_801BFBFC; -// extern UNK_TYPE1 D_801BFC00; -// extern UNK_TYPE1 D_801BFC04; -// extern UNK_TYPE1 D_801BFC08; -// extern UNK_TYPE1 D_801BFC0C; -// extern UNK_TYPE1 D_801BFC10; -// extern UNK_TYPE1 D_801BFC14; -// extern UNK_TYPE1 D_801BFC40; -// extern UNK_TYPE2 D_801BFC50; -// extern UNK_TYPE2 D_801BFC60; -// extern UNK_TYPE2 D_801BFC62; -// extern UNK_TYPE2 D_801BFC64; -// extern UNK_TYPE2 D_801BFC6C; -// extern UNK_TYPE2 D_801BFC7C; -// extern UNK_TYPE1 D_801BFC8C; -// extern UNK_TYPE2 D_801BFC98; -// extern UNK_TYPE2 D_801BFCA8; -// extern UNK_TYPE1 D_801BFCB8; -// extern UNK_TYPE4 D_801BFCC4; -// extern UNK_TYPE2 D_801BFCE4; -// extern UNK_TYPE2 D_801BFCE8; -// extern UNK_TYPE2 D_801BFCEA; -// extern UNK_TYPE2 D_801BFCEC; -// extern UNK_TYPE2 D_801BFCEE; -// extern UNK_TYPE2 D_801BFCF0; -// extern UNK_TYPE2 D_801BFCF2; -// extern UNK_TYPE2 D_801BFCF4; -// extern UNK_TYPE2 D_801BFCF8; -// extern UNK_TYPE2 D_801BFCFC; -// extern UNK_TYPE2 D_801BFD0C; -// extern UNK_TYPE1 D_801BFD1C; -// extern UNK_TYPE1 D_801BFD24; -// extern UNK_TYPE1 D_801BFD2C; -// extern UNK_TYPE1 D_801BFD40; -// extern UNK_TYPE1 D_801BFD54; -// extern UNK_TYPE1 D_801BFD64; -// extern UNK_TYPE2 D_801BFD6C; -// extern UNK_TYPE1 D_801BFD84; -// 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 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; -// extern UNK_TYPE1 D_801C00EC; -// extern UNK_TYPE1 D_801C0114; -// extern UNK_TYPE1 D_801C013C; -// extern UNK_TYPE1 D_801C0164; -// extern UNK_TYPE1 D_801C018C; -// extern UNK_TYPE1 D_801C01A4; -// extern UNK_TYPE1 D_801C01CC; -// extern UNK_TYPE1 D_801C01F4; -// extern UNK_TYPE1 D_801C021C; -// extern UNK_TYPE1 D_801C0244; -// extern UNK_TYPE1 D_801C026C; -// extern UNK_TYPE1 D_801C0294; -// extern UNK_TYPE1 D_801C02A8; -// 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; -// extern UNK_TYPE1 D_801C03C0; -// extern UNK_TYPE1 D_801C03E0; -// extern UNK_TYPE1 D_801C0410; -// extern UNK_TYPE1 D_801C0428; -// extern UNK_TYPE1 D_801C0460; -// extern UNK_TYPE1 D_801C0490; -// extern UNK_TYPE1 D_801C0510; -// extern UNK_TYPE1 D_801C0538; -// extern UNK_TYPE1 D_801C0560; -// extern UNK_TYPE1 D_801C0580; -// extern UNK_TYPE1 D_801C05A8; -// 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; -// extern UNK_TYPE1 D_801C0698; -// extern UNK_TYPE1 D_801C06B8; -// extern UNK_TYPE1 D_801C06E0; -// extern UNK_TYPE1 D_801C06F8; -// extern UNK_TYPE1 D_801C0718; -// extern UNK_TYPE1 D_801C0730; -// extern UNK_TYPE1 D_801C0740; -// extern UNK_TYPE1 D_801C0750; -// extern UNK_TYPE1 D_801C0778; -// extern UNK_TYPE1 D_801C0784; -// extern UNK_TYPE1 D_801C07AC; -// extern UNK_TYPE1 D_801C07C0; -// extern UNK_TYPE1 D_801C07F0; -// extern UNK_TYPE1 D_801C0820; -// extern UNK_TYPE1 D_801C0838; -extern Gfx D_801C0850[]; -// extern UNK_TYPE1 D_801C0860; -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; -// extern UNK_TYPE1 D_801C096C; -// extern UNK_TYPE1 D_801C0970; -// extern UNK_TYPE4 D_801C0994; -// extern UNK_TYPE1 D_801C09B8; -// extern UNK_TYPE1 D_801C09DC; -// extern UNK_TYPE1 D_801C0A00; -// extern UNK_TYPE1 D_801C0A24; -// extern UNK_TYPE1 D_801C0A48; -// extern UNK_TYPE1 D_801C0A6C; -// extern UNK_TYPE1 D_801C0A90; -// extern UNK_TYPE1 D_801C0AB4; -// extern UNK_TYPE1 D_801C0ABC; -// extern UNK_TYPE1 D_801C0AC4; -// extern UNK_TYPE1 D_801C0ADC; -extern UNK_PTR D_801C0AF4; -extern UNK_PTR D_801C0AFC; -extern UNK_PTR D_801C0B04; -extern UNK_PTR D_801C0B0C; -// extern UNK_TYPE1 D_801C0B14; -// extern UNK_TYPE1 D_801C0B1C; -// 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; -// extern UNK_TYPE1 D_801C0D60; -// extern UNK_TYPE1 D_801C0D6C; -// extern UNK_TYPE1 D_801C0D78; -// extern UNK_TYPE4 D_801C0D94; -// extern UNK_TYPE4 D_801C0D98; -// extern UNK_TYPE4 D_801C0D9C; -// extern UNK_TYPE4 D_801C0DA0; -// extern UNK_TYPE1 D_801C0DA8; -// extern UNK_TYPE1 D_801C0DD8; -// extern UNK_TYPE1 D_801C0DE4; -// extern UNK_TYPE4 D_801C0DF0; -// extern UNK_TYPE1 D_801C0E04; -// extern UNK_TYPE4 D_801C0E2C; -// extern UNK_TYPE4 D_801C0E40; -// extern UNK_TYPE1 D_801C0E7C; -// extern UNK_TYPE1 D_801C0E94; -// extern UNK_TYPE1 D_801C0EA0; -// extern UNK_TYPE1 D_801C0EAC; -// extern UNK_TYPE1 D_801C0EB8; + +extern FlexSkeletonHeader* gPlayerSkeletons[PLAYER_FORM_MAX]; +extern PlayerModelIndices gPlayerModelTypes[]; +extern struct_80124618 D_801C03A0[]; +extern struct_80124618 D_801C0490[]; +extern Gfx gCullBackDList[]; +extern Gfx gCullFrontDList[]; + extern Gfx sSetupDL[438]; extern Gfx sFillSetupDL[12]; extern Gfx gEmptyDL[1]; @@ -1338,13 +652,13 @@ extern u8 gUpgradeShifts[8]; extern u16 gUpgradeCapacities[][4]; extern u32 gGsFlagsMask[]; extern u32 gGsFlagsShift[]; -extern void* gItemIcons[]; +extern TexturePtr gItemIcons[]; extern u8 gItemSlots[]; extern s16 gItemPrices[]; -extern u16 gScenesPerRegion[11][27]; -extern u32 D_801C2410[]; -extern s16 gLinkFormObjectIndexes[8]; -extern RomFile objectFileTable[643]; +extern u16 gSceneIdsPerRegion[11][27]; +extern u8 gPlayerFormItemRestrictions[PLAYER_FORM_MAX][114]; +extern s16 gPlayerFormObjectIndices[8]; +extern RomFile gObjectTable[643]; extern SceneTableEntry gSceneTable[]; extern UNK_PTR D_801C5C50; // extern UNK_TYPE1 D_801C5C9C; @@ -1353,13 +667,6 @@ extern UNK_PTR D_801C5CB0; // extern UNK_TYPE1 D_801C5DE0; // extern UNK_TYPE1 D_801C5DF0; // extern UNK_TYPE1 D_801C5E00; -extern s32 D_801C5E30[]; // D_801C5E30 -extern u16 D_801C5E48[]; // D_801C5E48 -extern s32 D_801C5E88[]; // D_801C5E88 -extern s32 D_801C5E9C[]; // D_801C5E9C -extern s32 D_801C5EB0[]; // D_801C5EB0 -extern s16 D_801C5EC4[]; // D_801C5EC4 -extern struct_801C5F44 D_801C5F44[]; // D_801C5F44 // extern UNK_TYPE1 D_801C6A70; // extern UNK_TYPE2 D_801C6A74; @@ -1371,7 +678,7 @@ extern struct_801C5F44 D_801C5F44[]; // D_801C5F44 // extern UNK_TYPE2 D_801C6A8C; // extern UNK_TYPE2 D_801C6A90; // extern UNK_TYPE2 D_801C6A94; -// extern UNK_TYPE1 D_801C6A98; +extern u8 D_801C6A98[5][5]; // extern UNK_TYPE1 D_801C6AB8; // extern UNK_TYPE1 D_801C6B28; // extern UNK_TYPE1 D_801CED40; @@ -1387,7 +694,7 @@ extern struct_801C5F44 D_801C5F44[]; // D_801C5F44 extern u8 D_801CFC98; extern s16 D_801CFCA4[9]; // extern UNK_TYPE2 D_801CFCAC; -// extern UNK_TYPE1 D_801CFCB8; +extern s16 gOcarinaSongItemMap[]; // extern UNK_TYPE2 D_801CFCD8; // extern UNK_TYPE2 D_801CFCE4; // extern UNK_TYPE2 D_801CFCF0; @@ -1500,10 +807,8 @@ extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; // extern UNK_TYPE4 D_801D0BB0; // extern UNK_TYPE1 D_801D0C80; // extern UNK_TYPE1 D_801D0CB0; -extern const TransitionInit TransitionFade_InitVars; -// extern UNK_TYPE1 D_801D0D00; -extern const TransitionInit TransitionCircle_InitVars; -extern UNK_TYPE4 D_801D0D50; +extern Gfx D_801D0D00[]; +extern s32 gDbgCamEnabled; // extern UNK_TYPE1 D_801D0D54; // extern UNK_TYPE2 D_801D0D58; // extern UNK_TYPE2 D_801D0D5C; @@ -1574,27 +879,23 @@ extern UNK_PTR D_801D1540; // extern f32 sFactorialTbl[13]; extern Vec3f gZeroVec3f; extern Vec3s gZeroVec3s; -// 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 NoteSubEu gZeroNoteSub; -extern NoteSubEu gDefaultNoteSub; -extern u16 gHeadsetPanQuantization[]; -extern u16 gHeadsetPanQuantization[]; -extern s16 D_801D58A8[]; +extern f32 gBendPitchOneOctaveFrequencies[]; +extern f32 gBendPitchTwoSemitonesFrequencies[]; +extern f32 gPitchFrequencies[]; +extern u8 gDefaultShortNoteVelocityTable[]; +extern u8 gDefaultShortNoteGateTimeTable[]; +extern EnvelopePoint gDefaultEnvelope[]; +extern NoteSampleState gZeroedSampleState; +extern NoteSampleState gDefaultSampleState; +extern u16 gHaasEffectDelaySize[]; +extern u16 gHaasEffectDelaySize[]; +extern s16 gInvalidAdpcmCodeBook[]; extern f32 gHeadsetPanVolume[]; extern f32 gStereoPanVolume[]; extern f32 gDefaultPanVolume[]; @@ -1606,27 +907,15 @@ extern f32 gDefaultPanVolume[]; // extern UNK_TYPE1 D_801D5FD4; extern UNK_PTR D_801D5FE0; // extern UNK_TYPE1 D_801D5FE4; -extern s32 gAudioContextInitalized; +extern s32 gAudioCtxInitalized; // extern UNK_TYPE4 D_801D5FEC; -// extern UNK_TYPE4 D_801D5FF0; -// extern UNK_TYPE4 D_801D5FF4; -// 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 D_801D6200[0x400]; +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; @@ -1680,8 +969,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; @@ -1748,45 +1037,20 @@ 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; -// extern UNK_TYPE1 D_801DB528; -// extern UNK_TYPE1 D_801DB570; -// extern UNK_TYPE1 D_801DB5B8; -// extern UNK_TYPE1 D_801DB600; -// extern UNK_TYPE1 D_801DB648; -// extern UNK_TYPE1 D_801DB690; -// extern UNK_TYPE1 D_801DB6D8; -// extern UNK_TYPE1 D_801DB720; -// extern UNK_TYPE1 D_801DB750; -// extern UNK_TYPE1 D_801DB798; -// extern UNK_TYPE1 D_801DB870; -// extern UNK_TYPE1 D_801DB8B8; -// extern UNK_TYPE1 D_801DB900; -extern UNK_PTR D_801DB930; +extern ReverbSettings* gReverbSettingsTable[]; extern AudioSpec gAudioSpecs[21]; // rodata @@ -2768,7 +2032,7 @@ extern f32 D_801DE860; extern f32 D_801DE864; extern f32 D_801DE868; extern f32 D_801DE884; -extern TexturePtr D_801DE890[]; +extern TexturePtr gCircleTex[]; extern f32 D_801DF090; extern f32 D_801DF094; extern f32 D_801DF0A0; @@ -3017,14 +2281,13 @@ extern f64 D_801E0EB0; // extern UNK_TYPE4 D_801E1068; extern UNK_PTR D_801E10B0; extern const s16 gAudioTatumInit[]; -extern const AudioContextInitSizes gAudioContextInitSizes; +extern const AudioHeapInitSizes gAudioHeapInitSizes; // extern UNK_TYPE4 D_801E1108; // extern UNK_TYPE4 D_801E110C; extern u8 gSoundFontTable[]; extern u8 gSequenceFontTable[]; extern u8 gSequenceTable[]; extern u8 gSampleBankTable[]; -extern u64 aspMainDataStart[]; // bss // extern UNK_TYPE1 D_801ED890; @@ -3062,7 +2325,6 @@ extern TriNorm D_801EDBB0; // extern UNK_TYPE1 D_801EDBD8; // extern UNK_TYPE1 D_801EDBDC; // extern UNK_TYPE1 D_801EDBE0; -extern s16 D_801EDBF0; // extern UNK_TYPE1 D_801EDBF4; // extern UNK_TYPE1 D_801EDBF8; // extern UNK_TYPE1 D_801EDC00; @@ -3202,25 +2464,7 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F57B4; // extern UNK_TYPE1 D_801F5834; // extern NmiBuff* gNMIBuffer; -// extern UNK_TYPE1 D_801F5850; -// extern UNK_TYPE1 D_801F58B0; -// extern UNK_TYPE1 D_801F59AC; -// extern UNK_TYPE1 D_801F59B0; -// extern UNK_TYPE1 D_801F59C8; -// extern UNK_TYPE1 D_801F59D0; -// extern UNK_TYPE1 D_801F59DC; -// 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; @@ -3239,12 +2483,10 @@ extern s16 D_801F4E7A; // extern UNK_TYPE1 D_801F6B1E; // extern UNK_TYPE1 D_801F6B20; // extern UNK_TYPE1 D_801F6B22; -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; @@ -3474,7 +2716,7 @@ extern s32 D_801FD120; // extern UNK_TYPE1 D_801FD434; // extern UNK_TYPE1 D_801FD435; // extern UNK_TYPE1 D_801FD436; -// extern UNK_TYPE1 D_801FD438; +// extern UNK_TYPE1 sPrevAmbienceSeqId; // extern UNK_TYPE1 D_801FD43A; // extern UNK_TYPE1 D_801FD43B; // extern UNK_TYPE1 D_801FD43E; @@ -3510,21 +2752,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; @@ -3535,18 +2777,18 @@ extern SoundRequest D_801FE7C0[1]; // extern UNK_TYPE1 D_8020001E; // extern UNK_TYPE1 D_802000C9; // extern UNK_TYPE1 D_802000D4; -// extern UNK_TYPE1 D_80200140; +extern ActiveSequence gActiveSeqs[]; // extern UNK_TYPE1 D_8020034A; // extern UNK_TYPE1 D_80200B88; // extern UNK_TYPE1 D_80200BBA; // extern UNK_TYPE1 D_80200BCC; // extern UNK_TYPE1 D_80200BCE; // extern UNK_TYPE1 D_80200BD0; -extern AudioContext gAudioContext; // at 0x80200C70 -extern void (*D_80208E68)(void); -extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel); -extern s32 (*D_80208E70)(SoundFontSample*, s32, s8, s32); -extern Acmd* (*D_80208E74)(Acmd*, s32, s32); +extern AudioContext gAudioCtx; // at 0x80200C70 +extern AudioCustomUpdateFunction gAudioCustomUpdateFunction; +extern AudioCustomSeqFunction gAudioCustomSeqFunction; +extern AudioCustomReverbFunction gAudioCustomReverbFunction; +extern AudioCustomSynthFunction gAudioCustomSynthFunction; // post-code buffers extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE]; @@ -3555,14 +2797,14 @@ extern GfxPool gGfxPools[2]; extern u8 gAudioHeap[0x138000]; extern u8 gSystemHeap[UNK_SIZE]; -extern u8 D_80780000[0x4600]; +extern u8 gPictoPhotoI8[PICTO_PHOTO_SIZE]; extern u8 D_80784600[0x56200]; 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 7f1dfd701..b8a3ac01e 100644 --- a/include/z64.h +++ b/include/z64.h @@ -23,18 +23,24 @@ #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 "z64interface.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" @@ -44,6 +50,7 @@ #include "z64skin.h" #include "z64subs.h" #include "z64transition.h" +#include "z64view.h" #include "regs.h" #define Z_THREAD_ID_IDLE 1 @@ -64,10 +71,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 @@ -89,30 +99,19 @@ 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 { - /* 0x0 */ s16 func; - /* 0x2 */ UNK_TYPE1 pad2[0x6]; -} CameraModeParams; // size = 0x8 - -typedef struct { - /* 0x0 */ u32 validModes; - /* 0x4 */ UNK_TYPE1 pad4[0x4]; - /* 0x8 */ CameraModeParams* modes; -} CameraStateParams; // size = 0xC - typedef struct { /* 0x0 */ s16 x; /* 0x2 */ s16 y; @@ -147,7 +146,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; @@ -161,25 +160,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 { @@ -193,17 +173,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 { @@ -289,15 +269,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; @@ -305,20 +276,6 @@ typedef struct { /* 0x10 */ OSTime resetTime; } NmiBuff; // size >= 0x18 -typedef struct { - /* 0x0 */ s8 letterboxTarget; - /* 0x1 */ s8 letterboxMagnitude; - /* 0x2 */ s8 pillarboxTarget; - /* 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 { @@ -416,27 +373,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; @@ -445,44 +381,16 @@ 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 { /* 0x000 */ View view; /* 0x168 */ u8* iconItemSegment; /* 0x16C */ u8* iconItem24Segment; - /* 0x170 */ u8* unk_170; - /* 0x174 */ u8* unk_174; - /* 0x178 */ u8* unk_178; - /* 0x17C */ u8* unk_17C; + /* 0x170 */ u8* iconItemAltSegment; + /* 0x174 */ u8* iconItemLangSegment; + /* 0x178 */ u8* nameSegment; + /* 0x17C */ u8* iconItemVtxSegment; /* 0x180 */ Vtx* itemPageVtx; /* 0x184 */ Vtx* mapPageVtx; /* 0x188 */ Vtx* questPageVtx; @@ -495,170 +403,69 @@ typedef struct { /* 0x1A4 */ Vtx* unk_1A4; /* 0x1A8 */ Vtx* cursorVtx; /* 0x1AC */ OcarinaStaff* ocarinaStaff; - /* 0x1B0 */ DmaRequest unk_1B0; + /* 0x1B0 */ UNK_TYPE1 unk_1B0[0x20]; /* 0x1D0 */ OSMesgQueue loadQueue; /* 0x1E8 */ OSMesg loadMsg; /* 0x1EC */ u16 state; - /* 0x1EE */ u16 debugState; - /* 0x1F0 */ u8 unk_1F0; + /* 0x1EE */ u16 debugEditor; + /* 0x1F0 */ u8 bombersNotebookOpen; /* 0x1F4 */ Vec3f eye; - /* 0x200 */ u16 unk_200; - /* 0x202 */ u16 mode; + /* 0x200 */ u16 mainState; + /* 0x202 */ u16 nextPageMode; // (2 * prev pageIndex) + (scroll left ? 1 : 0) /* 0x204 */ u16 pageIndex; - /* 0x206 */ u16 unk_206; - /* 0x208 */ u16 unk_208; + /* 0x206 */ u16 switchPageTimer; + /* 0x208 */ u16 savePromptState; /* 0x20C */ f32 unk_20C; - /* 0x210 */ f32 unk_210; - /* 0x214 */ f32 unk_214; - /* 0x218 */ f32 unk_218; - /* 0x21C */ f32 unk_21C; - /* 0x220 */ f32 unk_220; + /* 0x210 */ f32 itemPageRoll; // rotation (-z) of the item page into the screen + /* 0x214 */ f32 mapPageRoll; // rotation (+x) of the map page into the screen + /* 0x218 */ f32 questPageRoll; // rotation (+z) of the quest page into the screen + /* 0x21C */ f32 maskPageRoll; // rotation (-z) of the mask page into the screen + /* 0x220 */ f32 roll; /* 0x224 */ u16 alpha; /* 0x226 */ s16 offsetY; - /* 0x228 */ s32 unk_228; - /* 0x22C */ s32 unk_22C; - /* 0x230 */ s32 unk_230; - /* 0x234 */ s32 unk_234; - /* 0x238 */ s16 unk_238[5]; - /* 0x242 */ s16 unk_242[5]; - /* 0x24C */ s16 unk_24C[5]; - /* 0x256 */ s16 unk_256; - /* 0x258 */ s16 unk_258; - /* 0x25A */ s16 unk_25A; - /* 0x25C */ u16 unk_25C; - /* 0x25E */ u16 unk_25E[5]; // ItemId - /* 0x268 */ u16 unk_268[5]; + /* 0x228 */ UNK_TYPE1 unk_228[0x8]; + /* 0x230 */ s32 stickAdjX; + /* 0x234 */ s32 stickAdjY; + /* 0x238 */ s16 cursorPoint[5]; + /* 0x242 */ s16 cursorXIndex[5]; + /* 0x24C */ s16 cursorYIndex[5]; + /* 0x256 */ s16 unk_256; // Uses DungeonItem enum + /* 0x258 */ s16 cursorSpecialPos; + /* 0x25A */ s16 pageSwitchTimer; + /* 0x25C */ u16 namedItem; + /* 0x25E */ u16 cursorItem[5]; + /* 0x268 */ u16 cursorSlot[5]; /* 0x272 */ u16 equipTargetItem; /* 0x274 */ u16 equipTargetSlot; /* 0x276 */ u16 equipTargetCBtn; /* 0x278 */ s16 equipAnimX; /* 0x27A */ s16 equipAnimY; /* 0x27C */ s16 equipAnimAlpha; - /* 0x27E */ s16 unk_27E; + /* 0x27E */ s16 infoPanelOffsetY; /* 0x280 */ u16 unk_280; - /* 0x282 */ u16 unk_282; - /* 0x284 */ s16 unk_284; + /* 0x282 */ u16 nameColorSet; + /* 0x284 */ s16 cursorColorSet; /* 0x286 */ s16 unk_286; /* 0x288 */ f32 unk_288; /* 0x28C */ f32 unk_28C; /* 0x290 */ f32 unk_290; /* 0x294 */ f32 unk_294; /* 0x298 */ f32 unk_298; - /* 0x29C */ s16 unk_29C; - /* 0x29E */ s16 unk_29E; - /* 0x2A0 */ s16 unk_2A0; + /* 0x29C */ s16 promptChoice; // save/continue choice: 0 = yes; 4 = no + /* 0x29E */ s16 promptAlpha; + /* 0x2A0 */ s16 ocarinaSongIndex; /* 0x2A2 */ u8 worldMapPoints[20]; - /* 0x2B6 */ u8 unk_2B6; - /* 0x2B7 */ u8 unk_2B7; - /* 0x2B8 */ u8 unk_2B8; - /* 0x2B9 */ u8 unk_2B9; - /* 0x2BA */ s16 unk_2BA; - /* 0x2BC */ s16 unk_2BC; - /* 0x2BE */ s16 unk_2BE[5]; - /* 0x2C8 */ u16 unk_2C8; - /* 0x2CA */ s16 unk_2CA; + /* 0x2B6 */ u8 unk_2B6; // unused red? + /* 0x2B7 */ u8 unk_2B7; // unused green? + /* 0x2B8 */ u8 unk_2B8; // unused blue? + /* 0x2B9 */ u8 itemDescriptionOn; // helpful description of item given through a message box + /* 0x2BA */ s16 equipAnimScale; // scale of item icon while moving being equipped to c-button + /* 0x2BC */ s16 equipAnimShrinkRate; // rate the scale is shrinking for the item icon while moving being equipped to c-button + /* 0x2BE */ s16 ocarinaButtonsY[5]; + /* 0x2C8 */ u16 unk_2C8; // Uses PauseMenuPage enum for Owl Warp. Never set. + /* 0x2CA */ s16 unk_2CA; // Uses OwlWarpId enum for Owl Warp. Never set. } PauseContext; // size = 0x2D0 -typedef struct { - /* 0x000 */ View view; - /* 0x168 */ Vtx* actionVtx; - /* 0x16C */ Vtx* beatingHeartVtx; - /* 0x170 */ u8* parameterSegment; - /* 0x174 */ u8* doActionSegment; - /* 0x178 */ u8* iconItemSegment; - /* 0x17C */ u8* mapSegment; - /* 0x180 */ u8* unk_180; - /* 0x184 */ DmaRequest dmaRequest_184; - /* 0x1A4 */ DmaRequest dmaRequest_1A4; - /* 0x1C4 */ DmaRequest dmaRequest_1C4; - /* 0x1E4 */ OSMesgQueue loadQueue; - /* 0x1FC */ OSMesg loadMsg; - /* 0x200 */ Viewport viewport; - /* 0x210 */ s16 unk_210; - /* 0x212 */ u16 unk_212; - /* 0x214 */ u16 unk_214; - /* 0x218 */ f32 unk_218; - /* 0x21C */ s16 unk_21C; - /* 0x21E */ s16 unk_21E; - /* 0x220 */ s16 unk_220; - /* 0x222 */ s16 unk_222; - /* 0x224 */ s16 unk_224; - /* 0x226 */ s16 lifeColorChange; - /* 0x228 */ s16 lifeColorChangeDirection; - /* 0x22A */ s16 beatingHeartPrim[3]; - /* 0x230 */ s16 beatingHeartEnv[3]; - /* 0x236 */ s16 heartsPrimR[2]; - /* 0x23A */ s16 heartsPrimG[2]; - /* 0x23E */ s16 heartsPrimB[2]; - /* 0x242 */ s16 heartsEnvR[2]; - /* 0x246 */ s16 heartsEnvG[2]; - /* 0x24A */ s16 heartsEnvB[2]; - /* 0x24E */ s16 health; - /* 0x250 */ s16 unkTimer; - /* 0x252 */ s16 lifeSizeChange; - /* 0x254 */ s16 lifeSizeChangeDirection; // 1 means shrinking, 0 growing - /* 0x256 */ s16 unk_256; - /* 0x258 */ s16 unk_258; - /* 0x25A */ u8 numHorseBoosts; - /* 0x25C */ u16 unk_25C; - /* 0x25E */ u16 unk_25E; - /* 0x260 */ u16 hbaAmmo; - /* 0x262 */ u16 unk_262; - /* 0x264 */ s16 unk_264; - /* 0x266 */ s16 aAlpha; - /* 0x268 */ s16 bAlpha; - /* 0x26A */ s16 cLeftAlpha; - /* 0x26C */ s16 cDownAlpha; - /* 0x26E */ s16 cRightAlpha; - /* 0x270 */ s16 healthAlpha; - /* 0x272 */ s16 magicAlpha; - /* 0x274 */ s16 minimapAlpha; - /* 0x276 */ s16 startAlpha; - /* 0x278 */ s16 unk_278; - /* 0x27A */ s16 unk_27A; - /* 0x27C */ s16 mapRoomNum; - /* 0x27E */ u8 unk_27E; - /* 0x27F */ u8 unk_27F; - /* 0x280 */ u8 unk_280; - /* 0x282 */ s16 unk_282; - /* 0x284 */ s16 unk_284; - /* 0x286 */ s16 unk_286; - /* 0x288 */ s16 unk_288; - /* 0x28A */ s16 unk_28A[8]; - /* 0x29A */ u16 unk_29A[8]; - /* 0x2AA */ s16 unk_2AA[8]; - /* 0x2BC */ f32 unk_2BC[8]; - /* 0x2DC */ f32 unk_2DC[8]; - /* 0x2FC */ s16 unk_2FC[4]; - /* 0x304 */ s16 unk_304; - /* 0x306 */ s16 unk_306; - /* 0x308 */ s16 unk_308; - /* 0x30A */ s16 unk_30A; - /* 0x30C */ s16 unk_30C; - struct { - /* 0x30E */ u8 unk_30E; // "h_gauge" - /* 0x30F */ u8 bButton; - /* 0x310 */ u8 aButton; - /* 0x311 */ u8 tradeItems; - /* 0x312 */ u8 unk_312; - /* 0x313 */ u8 unk_313; - /* 0x314 */ u8 unk_314; - /* 0x315 */ u8 songOfSoaring; - /* 0x316 */ u8 songOfStorms; - /* 0x317 */ u8 unk_317; - /* 0x318 */ u8 pictographBox; - /* 0x319 */ u8 all; // "another"; enables all item restrictions - } restrictions; // size = 0xC - /* 0x31A */ u8 unk_31A; - /* 0x31B */ u8 unk_31B; - /* 0x31C */ u8 unk_31C; - /* 0x320 */ OSMesgQueue unk_320; - /* 0x338 */ OSMesg unk_338; - /* 0x33C */ void* unk_33C; - /* 0x340 */ u32 unk_340; - /* 0x344 */ u32 unk_344; -} InterfaceContext; // size = 0x348 - typedef struct { /* 0x00 */ void* loadedRamAddr; /* 0x04 */ uintptr_t vromStart; @@ -677,10 +484,8 @@ typedef enum { typedef struct { /* 0x00 */ u16 unk_0; - /* 0x02 */ u16 timeIncrement; - /* 0x04 */ f32 unk_4; - /* 0x08 */ f32 unk_8; - /* 0x0C */ f32 unk_C; + /* 0x02 */ u16 sceneTimeSpeed; + /* 0x04 */ Vec3f sunPos; /* 0x10 */ u8 unk_10; /* 0x11 */ u8 unk_11; /* 0x12 */ u8 unk_12; @@ -733,34 +538,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* staticSegments[4]; + /* 0x178 */ void* paletteStaticSegment; + /* 0x17C */ Gfx (*dListBuf)[150]; + /* 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 { @@ -768,8 +573,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 { @@ -814,96 +619,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 TransitionMode { + /* 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 TransitionType { + /* 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; @@ -975,8 +747,8 @@ typedef struct GameState { /* 0x00 */ GraphicsContext* gfxCtx; /* 0x04 */ GameStateFunc main; /* 0x08 */ GameStateFunc destroy; - /* 0x0C */ GameStateFunc nextGameStateInit; - /* 0x10 */ size_t nextGameStateSize; + /* 0x0C */ GameStateFunc init; // Usually the current game state's init, though after stopping, the graph thread will look here to determine the next game state to load. + /* 0x10 */ size_t size; /* 0x14 */ Input input[4]; /* 0x74 */ TwoHeadArena heap; /* 0x84 */ GameAlloc alloc; @@ -988,12 +760,6 @@ typedef struct GameState { /* 0xA3 */ u8 unk_A3; } GameState; // size = 0xA4 -typedef struct PreNMIContext { - /* 0x00 */ GameState state; - /* 0xA4 */ u32 timer; - /* 0xA8 */ UNK_TYPE4 unkA8; -} PreNMIContext; // size = 0xAC - typedef struct { /* 0x00 */ u32 resetting; /* 0x04 */ u32 resetCount; @@ -1001,153 +767,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 struct { - /* 0x00 */ Vec3f atOffset; - /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rollOffset; - /* 0x1A */ s16 zoom; -} ShakeInfo; // size = 0x1C - -typedef struct { - /* 0x00 */ s16 randIdx; - /* 0x02 */ s16 countdownMax; - /* 0x04 */ Camera* camera; - /* 0x08 */ u32 callbackIdx; - /* 0x0C */ s16 verticalMag; - /* 0x0E */ s16 horizontalMag; - /* 0x10 */ s16 zoom; - /* 0x12 */ s16 rollOffset; - /* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane - /* 0x1A */ s16 speed; - /* 0x1C */ s16 isShakePerpendicular; - /* 0x1E */ s16 countdown; - /* 0x20 */ s16 camId; -} QuakeRequest; // size = 0x24 - -typedef struct { - /* 0x00 */ Vec3f atOffset; - /* 0x0C */ Vec3f eyeOffset; - /* 0x18 */ s16 rollOffset; - /* 0x1A */ s16 zoom; - /* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used -} QuakeCamCalc; // size = 0x20 - -typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*); - -#define QUAKE_SPEED (1 << 0) -#define QUAKE_VERTICAL_MAG (1 << 1) -#define QUAKE_HORIZONTAL_MAG (1 << 2) -#define QUAKE_ZOOM (1 << 3) -#define QUAKE_ROLL_OFFSET (1 << 4) -#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5) -#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6) -#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7) -#define QUAKE_COUNTDOWN (1 << 8) -#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9) - -typedef struct { - /* 0x0 */ GlobalContext* globalCtx; - /* 0x4 */ s32 type; // bitfield, highest set bit determines type - /* 0x8 */ s16 countdown; - /* 0xA */ s16 state; -} DistortionContext; // size = 0xC - -typedef enum { - /* 0 */ DISTORTION_INACTIVE, - /* 1 */ DISTORTION_ACTIVE, - /* 2 */ DISTORTION_SETUP -} DistortionState; +typedef void(*room_draw_func)(PlayState* play, Room* room, u32 flags); typedef struct { /* 0x000 */ u8 controllers; // bit 0 is set if controller 1 is plugged in, etc. @@ -1192,7 +820,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 @@ -1251,22 +879,20 @@ struct FireObj { }; // size = 0x8B typedef struct { - /* 0x00 */ u8 seqIndex; - /* 0x01 */ u8 nightSeqIndex; - /* 0x02 */ u8 unk_02; -} SoundContext; // size = 0x3 + /* 0x0 */ u8 seqId; + /* 0x1 */ u8 ambienceId; +} SequenceContext; // size = 0x2 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 @@ -1275,23 +901,23 @@ 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; + /* 0x000A4 */ s16 sceneId; /* 0x000A6 */ u8 sceneConfig; /* 0x000A7 */ char unk_A7[0x9]; /* 0x000B0 */ void* sceneSegment; /* 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; + /* 0x00814 */ SequenceContext sequenceCtx; /* 0x00818 */ LightContext lightCtx; /* 0x00828 */ FrameAdvanceContext frameAdvCtx; /* 0x00830 */ CollisionContext colCtx; @@ -1310,19 +936,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); + /* 0x18794 */ PlayerItemAction (*unk_18794)(struct PlayState* play, Player* player, ItemId itemId); + /* 0x18798 */ s32 (*setPlayerTalkAnim)(struct PlayState* play, LinkAnimationHeader* talkAnim, s32 animMode); /* 0x1879C */ s16 playerActorCsIds[10]; /* 0x187B0 */ MtxF viewProjectionMtxF; /* 0x187F0 */ Vec3f unk_187F0; @@ -1336,33 +962,35 @@ 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; - /* 0x18868 */ void* unk_18868; + /* 0x18868 */ void* naviQuestHints; // leftover from OoT, system which processes this is removed /* 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; - /* 0x18E58 */ char unk_18E58[0x10]; - /* 0x18E68 */ s32 unk_18E68; + /* 0x18E58 */ char unk_18E58[0x4]; + /* 0x18E5C */ TexturePtr pictoPhotoI8; + /* 0x18E60 */ char unk_18E60[0x8]; + /* 0x18E68 */ void* unk_18E68; /* 0x18E6C */ char unk_18E6C[0x3EC]; }; // size = 0x19258 @@ -1388,26 +1016,26 @@ typedef struct { } struct_800BD888_arg1; // size = 0x28 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 struct DebugDispObject { @@ -1426,9 +1054,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 @@ -1441,21 +1069,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 c7724bcd7..370b49e75 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -9,17 +9,19 @@ // 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; +struct EnTorch2; -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 +33,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 +82,11 @@ typedef struct { /* 0x3A */ s16 unk3A; } ActorEnTest20C; // size = 0x3C +typedef struct { + /* 0x0 */ s16 unk_0; // frame? + /* 0x2 */ Vec3s unk_2; // scale +} struct_80124618; // size = 0x8 + typedef struct { /* 0x00 */ s16 id; /* 0x02 */ u8 type; @@ -99,8 +106,8 @@ typedef enum { } AllocType; typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; /* 0x08 */ void* vramStart; /* 0x0C */ void* vramEnd; /* 0x10 */ void* loadedRamAddr; // original name: "allocp" @@ -110,7 +117,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 @@ -202,7 +209,7 @@ typedef enum { * 0x040 : Has touched water (actor is responsible for unsetting this the frame it touches the water) * 0x080 : Similar to & 0x1 but with no velocity check and is cleared every frame * 0x100 : Crushed between a floor and ceiling (triggers a void for player) - * 0x200 : Unknown (only set/used by player so far) + * 0x200 : Only set/used by player, related to interacting with walls */ typedef struct { @@ -217,11 +224,12 @@ typedef struct { /* 0x15A */ s16 pad15A; } DynaPolyActor; // size = 0x15C -typedef enum { + +typedef enum Item00Type { /* 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,7 +262,7 @@ 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) @@ -263,7 +271,7 @@ 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; @@ -275,14 +283,23 @@ 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; /* 0x144 */ EnAObjActionFunc actionFunc; /* 0x148 */ ColliderCylinder collision; - /* 0x194 */ UNK_TYPE1 pad194[0x14]; -} EnAObj; // size = 0x1A8 +} EnAObj; // size = 0x194 + +typedef enum { + /* 0 */ AOBJ_SIGNPOST_OBLONG, + /* 1 */ AOBJ_SIGNPOST_ARROW, +} AObjType; + +#define AOBJ_GET_TEXTID(thisx) ((((thisx)->params >> 8) & 0xFF) | 0x300) +#define AOBJ_GET_TYPE(thisx) (((thisx)->params & 0xFF) - 9) + +#define AOBJ_PARAMS(textId, type) ((((textId - 0x300) & 0xFF) << 8) | (type + 9)) typedef enum { /* 0x00 */ ACTORCAT_SWITCH, @@ -300,6 +317,16 @@ typedef enum { /* 0x0C */ ACTORCAT_MAX } ActorType; +#define ACTORCTX_FLAG_0 (1 << 0) +#define ACTORCTX_FLAG_1 (1 << 1) +#define ACTORCTX_FLAG_PICTO_BOX_ON (1 << 2) +#define ACTORCTX_FLAG_3 (1 << 3) +#define ACTORCTX_FLAG_4 (1 << 4) +#define ACTORCTX_FLAG_5 (1 << 5) +#define ACTORCTX_FLAG_6 (1 << 6) +#define ACTORCTX_FLAG_7 (1 << 7) + + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ f32 unkC; @@ -344,13 +371,13 @@ typedef struct ActorContext_unk_20C { /* 0x4 */ void* ptr; } ActorContext_unk_20C; // size = 0x8 -typedef struct ActorContextFlags { +typedef struct ActorContextSceneFlags { /* 0x00 */ u32 switches[4]; // First 0x40 are permanent, second 0x40 are temporary /* 0x10 */ u32 chest; /* 0x14 */ u32 clearedRoom; /* 0x18 */ u32 clearedRoomTemp; /* 0x1C */ u32 collectible[4]; // bitfield of 128 bits -} ActorContextFlags; // size = 0x2C +} ActorContextSceneFlags; // size = 0x2C typedef struct ActorListEntry { /* 0x0 */ s32 length; // number of actors loaded of this type @@ -358,22 +385,25 @@ typedef struct ActorListEntry { /* 0x8 */ s32 unk_08; } ActorListEntry; // size = 0xC +// Target size when activated +#define LENS_MASK_ACTIVE_SIZE 100 + typedef struct ActorContext { /* 0x000 */ u8 freezeFlashTimer; /* 0x001 */ UNK_TYPE1 pad1; /* 0x002 */ u8 unk2; - /* 0x003 */ u8 unk3; - /* 0x004 */ s8 unk4; - /* 0x005 */ u8 unk5; + /* 0x003 */ u8 lensActive; + /* 0x004 */ s8 lensMaskSize; // The size of the circle when drawn the lens mask. Larger value leads to a smaller circle + /* 0x005 */ u8 flags; /* 0x006 */ UNK_TYPE1 pad6[0x5]; - /* 0x00B */ s8 unkB; + /* 0x00B */ s8 lensActorsDrawn; /* 0x00C */ s16 unkC; /* 0x00E */ u8 totalLoadedActors; /* 0x00F */ u8 undrawnActorCount; /* 0x010 */ ActorListEntry actorLists[ACTORCAT_MAX]; /* 0x0A0 */ Actor* undrawnActors[32]; // Records the first 32 actors drawn each frame /* 0x120 */ TargetContext targetContext; - /* 0x1B8 */ ActorContextFlags flags; + /* 0x1B8 */ ActorContextSceneFlags sceneFlags; /* 0x1E4 */ TitleCardContext titleCtxt; /* 0x1F4 */ u8 unk1F4; /* 0x1F5 */ u8 unk1F5; @@ -384,15 +414,15 @@ typedef struct ActorContext { /* 0x20C */ ActorContext_unk_20C unk_20C[8]; /* 0x24C */ UNK_TYPE1 unk_24C[0x4]; /* 0x250 */ void* absoluteSpace; // Space used to allocate actor overlays of alloc type ALLOCTYPE_ABSOLUTE - /* 0x254 */ u32 unk254[5]; + /* 0x254 */ struct EnTorch2* elegyShells[5]; // PLAYER_FORM_MAX /* 0x268 */ u8 unk268; /* 0x269 */ UNK_TYPE1 pad269[0x3]; /* 0x26C */ Input unk_26C; } 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, @@ -402,699 +432,19 @@ typedef enum { /* 32 */ ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE } ActorDrawDamageEffectType; -typedef enum { - /* 0x000 */ ACTOR_PLAYER, - /* 0x001 */ ACTOR_EN_TEST, - /* 0x002 */ ACTOR_EN_GIRLA, - /* 0x003 */ ACTOR_EN_PART, - /* 0x004 */ ACTOR_EN_LIGHT, - /* 0x005 */ ACTOR_EN_DOOR, - /* 0x006 */ ACTOR_EN_BOX, - /* 0x007 */ ACTOR_EN_PAMETFROG, - /* 0x008 */ ACTOR_EN_OKUTA, - /* 0x009 */ ACTOR_EN_BOM, - /* 0x00A */ ACTOR_EN_WALLMAS, - /* 0x00B */ ACTOR_EN_DODONGO, - /* 0x00C */ ACTOR_EN_FIREFLY, - /* 0x00D */ ACTOR_EN_HORSE, - /* 0x00E */ ACTOR_EN_ITEM00, - /* 0x00F */ ACTOR_EN_ARROW, - /* 0x010 */ ACTOR_EN_ELF, - /* 0x011 */ ACTOR_EN_NIW, - /* 0x012 */ ACTOR_EN_TITE, - /* 0x013 */ ACTOR_UNSET_13, - /* 0x014 */ ACTOR_EN_PEEHAT, - /* 0x015 */ ACTOR_EN_BUTTE, - /* 0x016 */ ACTOR_EN_INSECT, - /* 0x017 */ ACTOR_EN_FISH, - /* 0x018 */ ACTOR_EN_HOLL, - /* 0x019 */ ACTOR_EN_DINOFOS, - /* 0x01A */ ACTOR_EN_HATA, - /* 0x01B */ ACTOR_EN_ZL1, - /* 0x01C */ ACTOR_EN_VIEWER, - /* 0x01D */ ACTOR_EN_BUBBLE, - /* 0x01E */ ACTOR_DOOR_SHUTTER, - /* 0x01F */ ACTOR_UNSET_1F, - /* 0x020 */ ACTOR_EN_BOOM, - /* 0x021 */ ACTOR_EN_TORCH2, - /* 0x022 */ ACTOR_EN_MINIFROG, - /* 0x023 */ ACTOR_UNSET_23, - /* 0x024 */ ACTOR_EN_ST, - /* 0x025 */ ACTOR_UNSET_25, - /* 0x026 */ ACTOR_EN_A_OBJ, - /* 0x027 */ ACTOR_OBJ_WTURN, - /* 0x028 */ ACTOR_EN_RIVER_SOUND, - /* 0x029 */ ACTOR_UNSET_29, - /* 0x02A */ ACTOR_EN_OSSAN, - /* 0x02B */ ACTOR_UNSET_2B, - /* 0x02C */ ACTOR_UNSET_2C, - /* 0x02D */ ACTOR_EN_FAMOS, - /* 0x02E */ ACTOR_UNSET_2E, - /* 0x02F */ ACTOR_EN_BOMBF, - /* 0x030 */ ACTOR_UNSET_30, - /* 0x031 */ ACTOR_UNSET_31, - /* 0x032 */ ACTOR_EN_AM, - /* 0x033 */ ACTOR_EN_DEKUBABA, - /* 0x034 */ ACTOR_EN_M_FIRE1, - /* 0x035 */ ACTOR_EN_M_THUNDER, - /* 0x036 */ ACTOR_BG_BREAKWALL, - /* 0x037 */ ACTOR_UNSET_37, - /* 0x038 */ ACTOR_DOOR_WARP1, - /* 0x039 */ ACTOR_OBJ_SYOKUDAI, - /* 0x03A */ ACTOR_ITEM_B_HEART, - /* 0x03B */ ACTOR_EN_DEKUNUTS, - /* 0x03C */ ACTOR_EN_BBFALL, - /* 0x03D */ ACTOR_ARMS_HOOK, - /* 0x03E */ ACTOR_EN_BB, - /* 0x03F */ ACTOR_BG_KEIKOKU_SPR, - /* 0x040 */ ACTOR_UNSET_40, - /* 0x041 */ ACTOR_EN_WOOD02, - /* 0x042 */ ACTOR_UNSET_42, - /* 0x043 */ ACTOR_EN_DEATH, - /* 0x044 */ ACTOR_EN_MINIDEATH, - /* 0x045 */ ACTOR_UNSET_45, - /* 0x046 */ ACTOR_UNSET_46, - /* 0x047 */ ACTOR_EN_VM, - /* 0x048 */ ACTOR_DEMO_EFFECT, - /* 0x049 */ ACTOR_DEMO_KANKYO, - /* 0x04A */ ACTOR_EN_FLOORMAS, - /* 0x04B */ ACTOR_UNSET_4B, - /* 0x04C */ ACTOR_EN_RD, - /* 0x04D */ ACTOR_BG_F40_FLIFT, - /* 0x04E */ ACTOR_UNSET_4E, - /* 0x04F */ ACTOR_OBJ_MURE, - /* 0x050 */ ACTOR_EN_SW, - /* 0x051 */ ACTOR_OBJECT_KANKYO, - /* 0x052 */ ACTOR_UNSET_52, - /* 0x053 */ ACTOR_UNSET_53, - /* 0x054 */ ACTOR_EN_HORSE_LINK_CHILD, - /* 0x055 */ ACTOR_DOOR_ANA, - /* 0x056 */ ACTOR_UNSET_56, - /* 0x057 */ ACTOR_UNSET_57, - /* 0x058 */ ACTOR_UNSET_58, - /* 0x059 */ ACTOR_UNSET_59, - /* 0x05A */ ACTOR_UNSET_5A, - /* 0x05B */ ACTOR_EN_ENCOUNT1, - /* 0x05C */ ACTOR_DEMO_TRE_LGT, - /* 0x05D */ ACTOR_UNSET_5D, - /* 0x05E */ ACTOR_UNSET_5E, - /* 0x05F */ ACTOR_EN_ENCOUNT2, - /* 0x060 */ ACTOR_EN_FIRE_ROCK, - /* 0x061 */ ACTOR_BG_CTOWER_ROT, - /* 0x062 */ ACTOR_MIR_RAY, - /* 0x063 */ ACTOR_UNSET_63, - /* 0x064 */ ACTOR_EN_SB, - /* 0x065 */ ACTOR_EN_BIGSLIME, - /* 0x066 */ ACTOR_EN_KAREBABA, - /* 0x067 */ ACTOR_EN_IN, - /* 0x068 */ ACTOR_UNSET_68, - /* 0x069 */ ACTOR_EN_RU, - /* 0x06A */ ACTOR_EN_BOM_CHU, - /* 0x06B */ ACTOR_EN_HORSE_GAME_CHECK, - /* 0x06C */ ACTOR_EN_RR, - /* 0x06D */ ACTOR_UNSET_6D, - /* 0x06E */ ACTOR_UNSET_6E, - /* 0x06F */ ACTOR_UNSET_6F, - /* 0x070 */ ACTOR_UNSET_70, - /* 0x071 */ ACTOR_UNSET_71, - /* 0x072 */ ACTOR_UNSET_72, - /* 0x073 */ ACTOR_EN_FR, - /* 0x074 */ ACTOR_UNSET_74, - /* 0x075 */ ACTOR_UNSET_75, - /* 0x076 */ ACTOR_UNSET_76, - /* 0x077 */ ACTOR_UNSET_77, - /* 0x078 */ ACTOR_UNSET_78, - /* 0x079 */ ACTOR_EN_FISHING, - /* 0x07A */ ACTOR_OBJ_OSHIHIKI, - /* 0x07B */ ACTOR_EFF_DUST, - /* 0x07C */ ACTOR_BG_UMAJUMP, - /* 0x07D */ ACTOR_ARROW_FIRE, - /* 0x07E */ ACTOR_ARROW_ICE, - /* 0x07F */ ACTOR_ARROW_LIGHT, - /* 0x080 */ ACTOR_ITEM_ETCETERA, - /* 0x081 */ ACTOR_OBJ_KIBAKO, - /* 0x082 */ ACTOR_OBJ_TSUBO, - /* 0x083 */ ACTOR_UNSET_83, - /* 0x084 */ ACTOR_EN_IK, - /* 0x085 */ ACTOR_UNSET_85, - /* 0x086 */ ACTOR_UNSET_86, - /* 0x087 */ ACTOR_UNSET_87, - /* 0x088 */ ACTOR_UNSET_88, - /* 0x089 */ ACTOR_DEMO_SHD, - /* 0x08A */ ACTOR_EN_DNS, - /* 0x08B */ ACTOR_ELF_MSG, - /* 0x08C */ ACTOR_EN_HONOTRAP, - /* 0x08D */ ACTOR_EN_TUBO_TRAP, - /* 0x08E */ ACTOR_OBJ_ICE_POLY, - /* 0x08F */ ACTOR_EN_FZ, - /* 0x090 */ ACTOR_EN_KUSA, - /* 0x091 */ ACTOR_OBJ_BEAN, - /* 0x092 */ ACTOR_OBJ_BOMBIWA, - /* 0x093 */ ACTOR_OBJ_SWITCH, - /* 0x094 */ ACTOR_UNSET_94, - /* 0x095 */ ACTOR_OBJ_LIFT, - /* 0x096 */ ACTOR_OBJ_HSBLOCK, - /* 0x097 */ ACTOR_EN_OKARINA_TAG, - /* 0x098 */ ACTOR_UNSET_98, - /* 0x099 */ ACTOR_EN_GOROIWA, - /* 0x09A */ ACTOR_UNSET_9A, - /* 0x09B */ ACTOR_UNSET_9B, - /* 0x09C */ ACTOR_EN_DAIKU, - /* 0x09D */ ACTOR_EN_NWC, - /* 0x09E */ ACTOR_ITEM_INBOX, - /* 0x09F */ ACTOR_EN_GE1, - /* 0x0A0 */ ACTOR_OBJ_BLOCKSTOP, - /* 0x0A1 */ ACTOR_EN_SDA, - /* 0x0A2 */ ACTOR_EN_CLEAR_TAG, - /* 0x0A3 */ ACTOR_UNSET_A3, - /* 0x0A4 */ ACTOR_EN_GM, - /* 0x0A5 */ ACTOR_EN_MS, - /* 0x0A6 */ ACTOR_EN_HS, - /* 0x0A7 */ ACTOR_BG_INGATE, - /* 0x0A8 */ ACTOR_EN_KANBAN, - /* 0x0A9 */ ACTOR_UNSET_A9, - /* 0x0AA */ ACTOR_EN_ATTACK_NIW, - /* 0x0AB */ ACTOR_UNSET_AB, - /* 0x0AC */ ACTOR_UNSET_AC, - /* 0x0AD */ ACTOR_UNSET_AD, - /* 0x0AE */ ACTOR_EN_MK, - /* 0x0AF */ ACTOR_EN_OWL, - /* 0x0B0 */ ACTOR_EN_ISHI, - /* 0x0B1 */ ACTOR_OBJ_HANA, - /* 0x0B2 */ ACTOR_OBJ_LIGHTSWITCH, - /* 0x0B3 */ ACTOR_OBJ_MURE2, - /* 0x0B4 */ ACTOR_UNSET_B4, - /* 0x0B5 */ ACTOR_EN_FU, - /* 0x0B6 */ ACTOR_UNSET_B6, - /* 0x0B7 */ ACTOR_UNSET_B7, - /* 0x0B8 */ ACTOR_EN_STREAM, - /* 0x0B9 */ ACTOR_EN_MM, - /* 0x0BA */ ACTOR_UNSET_BA, - /* 0x0BB */ ACTOR_UNSET_BB, - /* 0x0BC */ ACTOR_EN_WEATHER_TAG, - /* 0x0BD */ ACTOR_EN_ANI, - /* 0x0BE */ ACTOR_UNSET_BE, - /* 0x0BF */ ACTOR_EN_JS, - /* 0x0C0 */ ACTOR_UNSET_C0, - /* 0x0C1 */ ACTOR_UNSET_C1, - /* 0x0C2 */ ACTOR_UNSET_C2, - /* 0x0C3 */ ACTOR_UNSET_C3, - /* 0x0C4 */ ACTOR_EN_OKARINA_EFFECT, - /* 0x0C5 */ ACTOR_EN_MAG, - /* 0x0C6 */ ACTOR_ELF_MSG2, - /* 0x0C7 */ ACTOR_BG_F40_SWLIFT, - /* 0x0C8 */ ACTOR_UNSET_C8, - /* 0x0C9 */ ACTOR_UNSET_C9, - /* 0x0CA */ ACTOR_EN_KAKASI, - /* 0x0CB */ ACTOR_OBJ_MAKEOSHIHIKI, - /* 0x0CC */ ACTOR_OCEFF_SPOT, - /* 0x0CD */ ACTOR_UNSET_CD, - /* 0x0CE */ ACTOR_EN_TORCH, - /* 0x0CF */ ACTOR_UNSET_CF, - /* 0x0D0 */ ACTOR_SHOT_SUN, - /* 0x0D1 */ ACTOR_UNSET_D1, - /* 0x0D2 */ ACTOR_UNSET_D2, - /* 0x0D3 */ ACTOR_OBJ_ROOMTIMER, - /* 0x0D4 */ ACTOR_EN_SSH, - /* 0x0D5 */ ACTOR_UNSET_D5, - /* 0x0D6 */ ACTOR_OCEFF_WIPE, - /* 0x0D7 */ ACTOR_OCEFF_STORM, - /* 0x0D8 */ ACTOR_OBJ_DEMO, - /* 0x0D9 */ ACTOR_EN_MINISLIME, - /* 0x0DA */ ACTOR_EN_NUTSBALL, - /* 0x0DB */ ACTOR_UNSET_DB, - /* 0x0DC */ ACTOR_UNSET_DC, - /* 0x0DD */ ACTOR_UNSET_DD, - /* 0x0DE */ ACTOR_UNSET_DE, - /* 0x0DF */ ACTOR_OCEFF_WIPE2, - /* 0x0E0 */ ACTOR_OCEFF_WIPE3, - /* 0x0E1 */ ACTOR_UNSET_E1, - /* 0x0E2 */ ACTOR_EN_DG, - /* 0x0E3 */ ACTOR_EN_SI, - /* 0x0E4 */ ACTOR_OBJ_COMB, - /* 0x0E5 */ ACTOR_OBJ_KIBAKO2, - /* 0x0E6 */ ACTOR_UNSET_E6, - /* 0x0E7 */ ACTOR_EN_HS2, - /* 0x0E8 */ ACTOR_OBJ_MURE3, - /* 0x0E9 */ ACTOR_EN_TG, - /* 0x0EA */ ACTOR_UNSET_EA, - /* 0x0EB */ ACTOR_UNSET_EB, - /* 0x0EC */ ACTOR_EN_WF, - /* 0x0ED */ ACTOR_EN_SKB, - /* 0x0EE */ ACTOR_UNSET_EE, - /* 0x0EF */ ACTOR_EN_GS, - /* 0x0F0 */ ACTOR_OBJ_SOUND, - /* 0x0F1 */ ACTOR_EN_CROW, - /* 0x0F2 */ ACTOR_UNSET_F2, - /* 0x0F3 */ ACTOR_EN_COW, - /* 0x0F4 */ ACTOR_UNSET_F4, - /* 0x0F5 */ ACTOR_UNSET_F5, - /* 0x0F6 */ ACTOR_OCEFF_WIPE4, - /* 0x0F7 */ ACTOR_UNSET_F7, - /* 0x0F8 */ ACTOR_EN_ZO, - /* 0x0F9 */ ACTOR_OBJ_MAKEKINSUTA, - /* 0x0FA */ ACTOR_EN_GE3, - /* 0x0FB */ ACTOR_UNSET_FB, - /* 0x0FC */ ACTOR_OBJ_HAMISHI, - /* 0x0FD */ ACTOR_EN_ZL4, - /* 0x0FE */ ACTOR_EN_MM2, - /* 0x0FF */ ACTOR_UNSET_FF, - /* 0x100 */ ACTOR_DOOR_SPIRAL, - /* 0x101 */ ACTOR_UNSET_101, - /* 0x102 */ ACTOR_OBJ_PZLBLOCK, - /* 0x103 */ ACTOR_OBJ_TOGE, - /* 0x104 */ ACTOR_UNSET_104, - /* 0x105 */ ACTOR_OBJ_ARMOS, - /* 0x106 */ ACTOR_OBJ_BOYO, - /* 0x107 */ ACTOR_UNSET_107, - /* 0x108 */ ACTOR_UNSET_108, - /* 0x109 */ ACTOR_EN_GRASSHOPPER, - /* 0x10A */ ACTOR_UNSET_10A, - /* 0x10B */ ACTOR_OBJ_GRASS, - /* 0x10C */ ACTOR_OBJ_GRASS_CARRY, - /* 0x10D */ ACTOR_OBJ_GRASS_UNIT, - /* 0x10E */ ACTOR_UNSET_10E, - /* 0x10F */ ACTOR_UNSET_10F, - /* 0x110 */ ACTOR_BG_FIRE_WALL, - /* 0x111 */ ACTOR_EN_BU, - /* 0x112 */ ACTOR_EN_ENCOUNT3, - /* 0x113 */ ACTOR_EN_JSO, - /* 0x114 */ ACTOR_OBJ_CHIKUWA, - /* 0x115 */ ACTOR_EN_KNIGHT, - /* 0x116 */ ACTOR_EN_WARP_TAG, - /* 0x117 */ ACTOR_EN_AOB_01, - /* 0x118 */ ACTOR_EN_BOJ_01, - /* 0x119 */ ACTOR_EN_BOJ_02, - /* 0x11A */ ACTOR_EN_BOJ_03, - /* 0x11B */ ACTOR_EN_ENCOUNT4, - /* 0x11C */ ACTOR_EN_BOM_BOWL_MAN, - /* 0x11D */ ACTOR_EN_SYATEKI_MAN, - /* 0x11E */ ACTOR_UNSET_11E, - /* 0x11F */ ACTOR_BG_ICICLE, - /* 0x120 */ ACTOR_EN_SYATEKI_CROW, - /* 0x121 */ ACTOR_EN_BOJ_04, - /* 0x122 */ ACTOR_EN_CNE_01, - /* 0x123 */ ACTOR_EN_BBA_01, - /* 0x124 */ ACTOR_EN_BJI_01, - /* 0x125 */ ACTOR_BG_SPDWEB, - /* 0x126 */ ACTOR_UNSET_126, - /* 0x127 */ ACTOR_UNSET_127, - /* 0x128 */ ACTOR_EN_MT_TAG, - /* 0x129 */ ACTOR_BOSS_01, - /* 0x12A */ ACTOR_BOSS_02, - /* 0x12B */ ACTOR_BOSS_03, - /* 0x12C */ ACTOR_BOSS_04, - /* 0x12D */ ACTOR_BOSS_05, - /* 0x12E */ ACTOR_BOSS_06, - /* 0x12F */ ACTOR_BOSS_07, - /* 0x130 */ ACTOR_BG_DY_YOSEIZO, - /* 0x131 */ ACTOR_UNSET_131, - /* 0x132 */ ACTOR_EN_BOJ_05, - /* 0x133 */ ACTOR_UNSET_133, - /* 0x134 */ ACTOR_UNSET_134, - /* 0x135 */ ACTOR_EN_SOB1, - /* 0x136 */ ACTOR_UNSET_136, - /* 0x137 */ ACTOR_UNSET_137, - /* 0x138 */ ACTOR_EN_GO, - /* 0x139 */ ACTOR_UNSET_139, - /* 0x13A */ ACTOR_EN_RAF, - /* 0x13B */ ACTOR_OBJ_FUNEN, - /* 0x13C */ ACTOR_OBJ_RAILLIFT, - /* 0x13D */ ACTOR_BG_NUMA_HANA, - /* 0x13E */ ACTOR_OBJ_FLOWERPOT, - /* 0x13F */ ACTOR_OBJ_SPINYROLL, - /* 0x140 */ ACTOR_DM_HINA, - /* 0x141 */ ACTOR_EN_SYATEKI_WF, - /* 0x142 */ ACTOR_OBJ_SKATEBLOCK, - /* 0x143 */ ACTOR_OBJ_ICEBLOCK, - /* 0x144 */ ACTOR_EN_BIGPAMET, - /* 0x145 */ ACTOR_EN_SYATEKI_DEKUNUTS, - /* 0x146 */ ACTOR_ELF_MSG3, - /* 0x147 */ ACTOR_EN_FG, - /* 0x148 */ ACTOR_DM_RAVINE, - /* 0x149 */ ACTOR_DM_SA, - /* 0x14A */ ACTOR_EN_SLIME, - /* 0x14B */ ACTOR_EN_PR, - /* 0x14C */ ACTOR_OBJ_TOUDAI, - /* 0x14D */ ACTOR_OBJ_ENTOTU, - /* 0x14E */ ACTOR_OBJ_BELL, - /* 0x14F */ ACTOR_EN_SYATEKI_OKUTA, - /* 0x150 */ ACTOR_UNSET_150, - /* 0x151 */ ACTOR_OBJ_SHUTTER, - /* 0x152 */ ACTOR_DM_ZL, - /* 0x153 */ ACTOR_EN_ELFGRP, - /* 0x154 */ ACTOR_DM_TSG, - /* 0x155 */ ACTOR_EN_BAGUO, - /* 0x156 */ ACTOR_OBJ_VSPINYROLL, - /* 0x157 */ ACTOR_OBJ_SMORK, - /* 0x158 */ ACTOR_EN_TEST2, - /* 0x159 */ ACTOR_EN_TEST3, - /* 0x15A */ ACTOR_EN_TEST4, - /* 0x15B */ ACTOR_EN_BAT, - /* 0x15C */ ACTOR_EN_SEKIHI, - /* 0x15D */ ACTOR_EN_WIZ, - /* 0x15E */ ACTOR_EN_WIZ_BROCK, - /* 0x15F */ ACTOR_EN_WIZ_FIRE, - /* 0x160 */ ACTOR_EFF_CHANGE, - /* 0x161 */ ACTOR_DM_STATUE, - /* 0x162 */ ACTOR_OBJ_FIRESHIELD, - /* 0x163 */ ACTOR_BG_LADDER, - /* 0x164 */ ACTOR_EN_MKK, - /* 0x165 */ ACTOR_DEMO_GETITEM, - /* 0x166 */ ACTOR_UNSET_166, - /* 0x167 */ ACTOR_EN_DNB, - /* 0x168 */ ACTOR_EN_DNH, - /* 0x169 */ ACTOR_EN_DNK, - /* 0x16A */ ACTOR_EN_DNQ, - /* 0x16B */ ACTOR_UNSET_16B, - /* 0x16C */ ACTOR_BG_KEIKOKU_SAKU, - /* 0x16D */ ACTOR_OBJ_HUGEBOMBIWA, - /* 0x16E */ ACTOR_EN_FIREFLY2, - /* 0x16F */ ACTOR_EN_RAT, - /* 0x170 */ ACTOR_EN_WATER_EFFECT, - /* 0x171 */ ACTOR_EN_KUSA2, - /* 0x172 */ ACTOR_BG_SPOUT_FIRE, - /* 0x173 */ ACTOR_UNSET_173, - /* 0x174 */ ACTOR_BG_DBLUE_MOVEBG, - /* 0x175 */ ACTOR_EN_DY_EXTRA, - /* 0x176 */ ACTOR_EN_BAL, - /* 0x177 */ ACTOR_EN_GINKO_MAN, - /* 0x178 */ ACTOR_EN_WARP_UZU, - /* 0x179 */ ACTOR_OBJ_DRIFTICE, - /* 0x17A */ ACTOR_EN_LOOK_NUTS, - /* 0x17B */ ACTOR_EN_MUSHI2, - /* 0x17C */ ACTOR_EN_FALL, - /* 0x17D */ ACTOR_EN_MM3, - /* 0x17E */ ACTOR_BG_CRACE_MOVEBG, - /* 0x17F */ ACTOR_EN_DNO, - /* 0x180 */ ACTOR_EN_PR2, - /* 0x181 */ ACTOR_EN_PRZ, - /* 0x182 */ ACTOR_EN_JSO2, - /* 0x183 */ ACTOR_OBJ_ETCETERA, - /* 0x184 */ ACTOR_EN_EGOL, - /* 0x185 */ ACTOR_OBJ_MINE, - /* 0x186 */ ACTOR_OBJ_PURIFY, - /* 0x187 */ ACTOR_EN_TRU, - /* 0x188 */ ACTOR_EN_TRT, - /* 0x189 */ ACTOR_UNSET_189, - /* 0x18A */ ACTOR_UNSET_18A, - /* 0x18B */ ACTOR_EN_TEST5, - /* 0x18C */ ACTOR_EN_TEST6, - /* 0x18D */ ACTOR_EN_AZ, - /* 0x18E */ ACTOR_EN_ESTONE, - /* 0x18F */ ACTOR_BG_HAKUGIN_POST, - /* 0x190 */ ACTOR_DM_OPSTAGE, - /* 0x191 */ ACTOR_DM_STK, - /* 0x192 */ ACTOR_DM_CHAR00, - /* 0x193 */ ACTOR_DM_CHAR01, - /* 0x194 */ ACTOR_DM_CHAR02, - /* 0x195 */ ACTOR_DM_CHAR03, - /* 0x196 */ ACTOR_DM_CHAR04, - /* 0x197 */ ACTOR_DM_CHAR05, - /* 0x198 */ ACTOR_DM_CHAR06, - /* 0x199 */ ACTOR_DM_CHAR07, - /* 0x19A */ ACTOR_DM_CHAR08, - /* 0x19B */ ACTOR_DM_CHAR09, - /* 0x19C */ ACTOR_OBJ_TOKEIDAI, - /* 0x19D */ ACTOR_UNSET_19D, - /* 0x19E */ ACTOR_EN_MNK, - /* 0x19F */ ACTOR_EN_EGBLOCK, - /* 0x1A0 */ ACTOR_EN_GUARD_NUTS, - /* 0x1A1 */ ACTOR_BG_HAKUGIN_BOMBWALL, - /* 0x1A2 */ ACTOR_OBJ_TOKEI_TOBIRA, - /* 0x1A3 */ ACTOR_BG_HAKUGIN_ELVPOLE, - /* 0x1A4 */ ACTOR_EN_MA4, - /* 0x1A5 */ ACTOR_EN_TWIG, - /* 0x1A6 */ ACTOR_EN_PO_FUSEN, - /* 0x1A7 */ ACTOR_EN_DOOR_ETC, - /* 0x1A8 */ ACTOR_EN_BIGOKUTA, - /* 0x1A9 */ ACTOR_BG_ICEFLOE, - /* 0x1AA */ ACTOR_OBJ_OCARINALIFT, - /* 0x1AB */ ACTOR_EN_TIME_TAG, - /* 0x1AC */ ACTOR_BG_OPEN_SHUTTER, - /* 0x1AD */ ACTOR_BG_OPEN_SPOT, - /* 0x1AE */ ACTOR_BG_FU_KAITEN, - /* 0x1AF */ ACTOR_OBJ_AQUA, - /* 0x1B0 */ ACTOR_EN_ELFORG, - /* 0x1B1 */ ACTOR_EN_ELFBUB, - /* 0x1B2 */ ACTOR_UNSET_1B2, - /* 0x1B3 */ ACTOR_EN_FU_MATO, - /* 0x1B4 */ ACTOR_EN_FU_KAGO, - /* 0x1B5 */ ACTOR_EN_OSN, - /* 0x1B6 */ ACTOR_BG_CTOWER_GEAR, - /* 0x1B7 */ ACTOR_EN_TRT2, - /* 0x1B8 */ ACTOR_OBJ_TOKEI_STEP, - /* 0x1B9 */ ACTOR_BG_LOTUS, - /* 0x1BA */ ACTOR_EN_KAME, - /* 0x1BB */ ACTOR_OBJ_TAKARAYA_WALL, - /* 0x1BC */ ACTOR_BG_FU_MIZU, - /* 0x1BD */ ACTOR_EN_SELLNUTS, - /* 0x1BE */ ACTOR_BG_DKJAIL_IVY, - /* 0x1BF */ ACTOR_UNSET_1BF, - /* 0x1C0 */ ACTOR_OBJ_VISIBLOCK, - /* 0x1C1 */ ACTOR_EN_TAKARAYA, - /* 0x1C2 */ ACTOR_EN_TSN, - /* 0x1C3 */ ACTOR_EN_DS2N, - /* 0x1C4 */ ACTOR_EN_FSN, - /* 0x1C5 */ ACTOR_EN_SHN, - /* 0x1C6 */ ACTOR_UNSET_1C6, - /* 0x1C7 */ ACTOR_EN_STOP_HEISHI, - /* 0x1C8 */ ACTOR_OBJ_BIGICICLE, - /* 0x1C9 */ ACTOR_EN_LIFT_NUTS, - /* 0x1CA */ ACTOR_EN_TK, - /* 0x1CB */ ACTOR_UNSET_1CB, - /* 0x1CC */ ACTOR_BG_MARKET_STEP, - /* 0x1CD */ ACTOR_OBJ_LUPYGAMELIFT, - /* 0x1CE */ ACTOR_EN_TEST7, - /* 0x1CF */ ACTOR_OBJ_LIGHTBLOCK, - /* 0x1D0 */ ACTOR_MIR_RAY2, - /* 0x1D1 */ ACTOR_EN_WDHAND, - /* 0x1D2 */ ACTOR_EN_GAMELUPY, - /* 0x1D3 */ ACTOR_BG_DANPEI_MOVEBG, - /* 0x1D4 */ ACTOR_EN_SNOWWD, - /* 0x1D5 */ ACTOR_EN_PM, - /* 0x1D6 */ ACTOR_EN_GAKUFU, - /* 0x1D7 */ ACTOR_ELF_MSG4, - /* 0x1D8 */ ACTOR_ELF_MSG5, - /* 0x1D9 */ ACTOR_EN_COL_MAN, - /* 0x1DA */ ACTOR_EN_TALK_GIBUD, - /* 0x1DB */ ACTOR_EN_GIANT, - /* 0x1DC */ ACTOR_OBJ_SNOWBALL, - /* 0x1DD */ ACTOR_BOSS_HAKUGIN, - /* 0x1DE */ ACTOR_EN_GB2, - /* 0x1DF */ ACTOR_EN_ONPUMAN, - /* 0x1E0 */ ACTOR_BG_TOBIRA01, - /* 0x1E1 */ ACTOR_EN_TAG_OBJ, - /* 0x1E2 */ ACTOR_OBJ_DHOUSE, - /* 0x1E3 */ ACTOR_OBJ_HAKAISI, - /* 0x1E4 */ ACTOR_BG_HAKUGIN_SWITCH, - /* 0x1E5 */ ACTOR_UNSET_1E5, - /* 0x1E6 */ ACTOR_EN_SNOWMAN, - /* 0x1E7 */ ACTOR_TG_SW, - /* 0x1E8 */ ACTOR_EN_PO_SISTERS, - /* 0x1E9 */ ACTOR_EN_PP, - /* 0x1EA */ ACTOR_EN_HAKUROCK, - /* 0x1EB */ ACTOR_EN_HANABI, - /* 0x1EC */ ACTOR_OBJ_DOWSING, - /* 0x1ED */ ACTOR_OBJ_WIND, - /* 0x1EE */ ACTOR_EN_RACEDOG, - /* 0x1EF */ ACTOR_EN_KENDO_JS, - /* 0x1F0 */ ACTOR_BG_BOTIHASIRA, - /* 0x1F1 */ ACTOR_EN_FISH2, - /* 0x1F2 */ ACTOR_EN_PST, - /* 0x1F3 */ ACTOR_EN_POH, - /* 0x1F4 */ ACTOR_OBJ_SPIDERTENT, - /* 0x1F5 */ ACTOR_EN_ZORAEGG, - /* 0x1F6 */ ACTOR_EN_KBT, - /* 0x1F7 */ ACTOR_EN_GG, - /* 0x1F8 */ ACTOR_EN_MARUTA, - /* 0x1F9 */ ACTOR_OBJ_SNOWBALL2, - /* 0x1FA */ ACTOR_EN_GG2, - /* 0x1FB */ ACTOR_OBJ_GHAKA, - /* 0x1FC */ ACTOR_EN_DNP, - /* 0x1FD */ ACTOR_EN_DAI, - /* 0x1FE */ ACTOR_BG_GORON_OYU, - /* 0x1FF */ ACTOR_EN_KGY, - /* 0x200 */ ACTOR_EN_INVADEPOH, - /* 0x201 */ ACTOR_EN_GK, - /* 0x202 */ ACTOR_EN_AN, - /* 0x203 */ ACTOR_UNSET_203, - /* 0x204 */ ACTOR_EN_BEE, - /* 0x205 */ ACTOR_EN_OT, - /* 0x206 */ ACTOR_EN_DRAGON, - /* 0x207 */ ACTOR_OBJ_DORA, - /* 0x208 */ ACTOR_EN_BIGPO, - /* 0x209 */ ACTOR_OBJ_KENDO_KANBAN, - /* 0x20A */ ACTOR_OBJ_HARIKO, - /* 0x20B */ ACTOR_EN_STH, - /* 0x20C */ ACTOR_BG_SINKAI_KABE, - /* 0x20D */ ACTOR_BG_HAKA_CURTAIN, - /* 0x20E */ ACTOR_BG_KIN2_BOMBWALL, - /* 0x20F */ ACTOR_BG_KIN2_FENCE, - /* 0x210 */ ACTOR_BG_KIN2_PICTURE, - /* 0x211 */ ACTOR_BG_KIN2_SHELF, - /* 0x212 */ ACTOR_EN_RAIL_SKB, - /* 0x213 */ ACTOR_EN_JG, - /* 0x214 */ ACTOR_EN_TRU_MT, - /* 0x215 */ ACTOR_OBJ_UM, - /* 0x216 */ ACTOR_EN_NEO_REEBA, - /* 0x217 */ ACTOR_BG_MBAR_CHAIR, - /* 0x218 */ ACTOR_BG_IKANA_BLOCK, - /* 0x219 */ ACTOR_BG_IKANA_MIRROR, - /* 0x21A */ ACTOR_BG_IKANA_ROTARYROOM, - /* 0x21B */ ACTOR_BG_DBLUE_BALANCE, - /* 0x21C */ ACTOR_BG_DBLUE_WATERFALL, - /* 0x21D */ ACTOR_EN_KAIZOKU, - /* 0x21E */ ACTOR_EN_GE2, - /* 0x21F */ ACTOR_EN_MA_YTS, - /* 0x220 */ ACTOR_EN_MA_YTO, - /* 0x221 */ ACTOR_OBJ_TOKEI_TURRET, - /* 0x222 */ ACTOR_BG_DBLUE_ELEVATOR, - /* 0x223 */ ACTOR_OBJ_WARPSTONE, - /* 0x224 */ ACTOR_EN_ZOG, - /* 0x225 */ ACTOR_OBJ_ROTLIFT, - /* 0x226 */ ACTOR_OBJ_JG_GAKKI, - /* 0x227 */ ACTOR_BG_INIBS_MOVEBG, - /* 0x228 */ ACTOR_EN_ZOT, - /* 0x229 */ ACTOR_OBJ_TREE, - /* 0x22A */ ACTOR_OBJ_Y2LIFT, - /* 0x22B */ ACTOR_OBJ_Y2SHUTTER, - /* 0x22C */ ACTOR_OBJ_BOAT, - /* 0x22D */ ACTOR_OBJ_TARU, - /* 0x22E */ ACTOR_OBJ_HUNSUI, - /* 0x22F */ ACTOR_EN_JC_MATO, - /* 0x230 */ ACTOR_MIR_RAY3, - /* 0x231 */ ACTOR_EN_ZOB, - /* 0x232 */ ACTOR_ELF_MSG6, - /* 0x233 */ ACTOR_OBJ_NOZOKI, - /* 0x234 */ ACTOR_EN_TOTO, - /* 0x235 */ ACTOR_EN_RAILGIBUD, - /* 0x236 */ ACTOR_EN_BABA, - /* 0x237 */ ACTOR_EN_SUTTARI, - /* 0x238 */ ACTOR_EN_ZOD, - /* 0x239 */ ACTOR_EN_KUJIYA, - /* 0x23A */ ACTOR_EN_GEG, - /* 0x23B */ ACTOR_OBJ_KINOKO, - /* 0x23C */ ACTOR_OBJ_YASI, - /* 0x23D */ ACTOR_EN_TANRON1, - /* 0x23E */ ACTOR_EN_TANRON2, - /* 0x23F */ ACTOR_EN_TANRON3, - /* 0x240 */ ACTOR_OBJ_CHAN, - /* 0x241 */ ACTOR_EN_ZOS, - /* 0x242 */ ACTOR_EN_S_GORO, - /* 0x243 */ ACTOR_EN_NB, - /* 0x244 */ ACTOR_EN_JA, - /* 0x245 */ ACTOR_BG_F40_BLOCK, - /* 0x246 */ ACTOR_BG_F40_SWITCH, - /* 0x247 */ ACTOR_EN_PO_COMPOSER, - /* 0x248 */ ACTOR_EN_GURUGURU, - /* 0x249 */ ACTOR_OCEFF_WIPE5, - /* 0x24A */ ACTOR_EN_STONE_HEISHI, - /* 0x24B */ ACTOR_OCEFF_WIPE6, - /* 0x24C */ ACTOR_EN_SCOPENUTS, - /* 0x24D */ ACTOR_EN_SCOPECROW, - /* 0x24E */ ACTOR_OCEFF_WIPE7, - /* 0x24F */ ACTOR_EFF_KAMEJIMA_WAVE, - /* 0x250 */ ACTOR_EN_HG, - /* 0x251 */ ACTOR_EN_HGO, - /* 0x252 */ ACTOR_EN_ZOV, - /* 0x253 */ ACTOR_EN_AH, - /* 0x254 */ ACTOR_OBJ_HGDOOR, - /* 0x255 */ ACTOR_BG_IKANA_BOMBWALL, - /* 0x256 */ ACTOR_BG_IKANA_RAY, - /* 0x257 */ ACTOR_BG_IKANA_SHUTTER, - /* 0x258 */ ACTOR_BG_HAKA_BOMBWALL, - /* 0x259 */ ACTOR_BG_HAKA_TOMB, - /* 0x25A */ ACTOR_EN_SC_RUPPE, - /* 0x25B */ ACTOR_BG_IKNV_DOUKUTU, - /* 0x25C */ ACTOR_BG_IKNV_OBJ, - /* 0x25D */ ACTOR_EN_PAMERA, - /* 0x25E */ ACTOR_OBJ_HSSTUMP, - /* 0x25F */ ACTOR_EN_HIDDEN_NUTS, - /* 0x260 */ ACTOR_EN_ZOW, - /* 0x261 */ ACTOR_EN_TALK, - /* 0x262 */ ACTOR_EN_AL, - /* 0x263 */ ACTOR_EN_TAB, - /* 0x264 */ ACTOR_EN_NIMOTSU, - /* 0x265 */ ACTOR_EN_HIT_TAG, - /* 0x266 */ ACTOR_EN_RUPPECROW, - /* 0x267 */ ACTOR_EN_TANRON4, - /* 0x268 */ ACTOR_EN_TANRON5, - /* 0x269 */ ACTOR_EN_TANRON6, - /* 0x26A */ ACTOR_EN_DAIKU2, - /* 0x26B */ ACTOR_EN_MUTO, - /* 0x26C */ ACTOR_EN_BAISEN, - /* 0x26D */ ACTOR_EN_HEISHI, - /* 0x26E */ ACTOR_EN_DEMO_HEISHI, - /* 0x26F */ ACTOR_EN_DT, - /* 0x270 */ ACTOR_EN_CHA, - /* 0x271 */ ACTOR_OBJ_DINNER, - /* 0x272 */ ACTOR_EFF_LASTDAY, - /* 0x273 */ ACTOR_BG_IKANA_DHARMA, - /* 0x274 */ ACTOR_EN_AKINDONUTS, - /* 0x275 */ ACTOR_EFF_STK, - /* 0x276 */ ACTOR_EN_IG, - /* 0x277 */ ACTOR_EN_RG, - /* 0x278 */ ACTOR_EN_OSK, - /* 0x279 */ ACTOR_EN_STH2, - /* 0x27A */ ACTOR_EN_YB, - /* 0x27B */ ACTOR_EN_RZ, - /* 0x27C */ ACTOR_EN_SCOPECOIN, - /* 0x27D */ ACTOR_EN_BJT, - /* 0x27E */ ACTOR_EN_BOMJIMA, - /* 0x27F */ ACTOR_EN_BOMJIMB, - /* 0x280 */ ACTOR_EN_BOMBERS, - /* 0x281 */ ACTOR_EN_BOMBERS2, - /* 0x282 */ ACTOR_EN_BOMBAL, - /* 0x283 */ ACTOR_OBJ_MOON_STONE, - /* 0x284 */ ACTOR_OBJ_MU_PICT, - /* 0x285 */ ACTOR_BG_IKNINSIDE, - /* 0x286 */ ACTOR_EFF_ZORABAND, - /* 0x287 */ ACTOR_OBJ_KEPN_KOYA, - /* 0x288 */ ACTOR_OBJ_USIYANE, - /* 0x289 */ ACTOR_EN_NNH, - /* 0x28A */ ACTOR_OBJ_KZSAKU, - /* 0x28B */ ACTOR_OBJ_MILK_BIN, - /* 0x28C */ ACTOR_EN_KITAN, - /* 0x28D */ ACTOR_BG_ASTR_BOMBWALL, - /* 0x28E */ ACTOR_BG_IKNIN_SUSCEIL, - /* 0x28F */ ACTOR_EN_BSB, - /* 0x290 */ ACTOR_EN_RECEPGIRL, - /* 0x291 */ ACTOR_EN_THIEFBIRD, - /* 0x292 */ ACTOR_EN_JGAME_TSN, - /* 0x293 */ ACTOR_OBJ_JGAME_LIGHT, - /* 0x294 */ ACTOR_OBJ_YADO, - /* 0x295 */ ACTOR_DEMO_SYOTEN, - /* 0x296 */ ACTOR_DEMO_MOONEND, - /* 0x297 */ ACTOR_BG_LBFSHOT, - /* 0x298 */ ACTOR_BG_LAST_BWALL, - /* 0x299 */ ACTOR_EN_AND, - /* 0x29A */ ACTOR_EN_INVADEPOH_DEMO, - /* 0x29B */ ACTOR_OBJ_DANPEILIFT, - /* 0x29C */ ACTOR_EN_FALL2, - /* 0x29D */ ACTOR_DM_AL, - /* 0x29E */ ACTOR_DM_AN, - /* 0x29F */ ACTOR_DM_AH, - /* 0x2A0 */ ACTOR_DM_NB, - /* 0x2A1 */ ACTOR_EN_DRS, - /* 0x2A2 */ ACTOR_EN_ENDING_HERO, - /* 0x2A3 */ ACTOR_DM_BAL, - /* 0x2A4 */ ACTOR_EN_PAPER, - /* 0x2A5 */ ACTOR_EN_HINT_SKB, - /* 0x2A6 */ ACTOR_DM_TAG, - /* 0x2A7 */ ACTOR_EN_BH, - /* 0x2A8 */ ACTOR_EN_ENDING_HERO2, - /* 0x2A9 */ ACTOR_EN_ENDING_HERO3, - /* 0x2AA */ ACTOR_EN_ENDING_HERO4, - /* 0x2AB */ ACTOR_EN_ENDING_HERO5, - /* 0x2AC */ ACTOR_EN_ENDING_HERO6, - /* 0x2AD */ ACTOR_DM_GM, - /* 0x2AE */ ACTOR_OBJ_SWPRIZE, - /* 0x2AF */ ACTOR_EN_INVISIBLE_RUPPE, - /* 0x2B0 */ ACTOR_OBJ_ENDING, - /* 0x2B1 */ ACTOR_EN_RSN, + +#define DEFINE_ACTOR(_name, enumValue, _allocType, _debugName) enumValue, +#define DEFINE_ACTOR_INTERNAL(_name, enumValue, _allocType, _debugName) enumValue, +#define DEFINE_ACTOR_UNSET(enumValue) enumValue, + +typedef enum ActorId { + #include "tables/actor_table.h" /* 0x2B2 */ ACTOR_ID_MAX // originally "ACTOR_DLF_MAX" -} ActorID; +} ActorId; + +#undef DEFINE_ACTOR +#undef DEFINE_ACTOR_INTERNAL +#undef DEFINE_ACTOR_UNSET typedef enum { /* 0 */ DOORLOCK_NORMAL, @@ -1133,7 +483,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) @@ -1178,4 +528,109 @@ typedef enum { /* 0xC8 */ CLEAR_TAG_SMOKE = 200 } ClearTagType; +typedef enum { + /* 0x00 */ TATL_HINT_ID_DEFAULT, + /* 0x01 */ TATL_HINT_ID_SNAPPER, + /* 0x02 */ TATL_HINT_ID_MINI_BABA, + /* 0x03 */ TATL_HINT_ID_MAD_JELLY, + /* 0x04 */ TATL_HINT_ID_SKULLTULA, + /* 0x05 */ TATL_HINT_ID_RED_CHUCHU, + /* 0x06 */ TATL_HINT_ID_BLUE_CHUCHU, + /* 0x07 */ TATL_HINT_ID_DEKU_BABA, + /* 0x08 */ TATL_HINT_ID_BIO_DEKU_BABA, + /* 0x09 */ TATL_HINT_ID_WILTED_DEKU_BABA, + /* 0x0A */ TATL_HINT_ID_DEXIHAND, + /* 0x0B */ TATL_HINT_ID_NEJIRON, + /* 0x0C */ TATL_HINT_ID_GIANT_BEE, + /* 0x0D */ TATL_HINT_ID_DODONGO, + /* 0x0E */ TATL_HINT_ID_DEEP_PYTHON, + /* 0x0F */ TATL_HINT_ID_DEATH_ARMOS, + /* 0x10 */ TATL_HINT_ID_DINOLFOS, + /* 0x11 */ TATL_HINT_ID_FIRE_KEESE, + /* 0x12 */ TATL_HINT_ID_KEESE, + /* 0x13 */ TATL_HINT_ID_ARMOS, + /* 0x14 */ TATL_HINT_ID_EENO, + /* 0x15 */ TATL_HINT_ID_DRAGONFLY, + /* 0x16 */ TATL_HINT_ID_IGOS_DU_IKANA, + /* 0x17 */ TATL_HINT_ID_GARO, + /* 0x18 */ TATL_HINT_ID_GARO_MASTER, + /* 0x19 */ TATL_HINT_ID_WART, + /* 0x1A */ TATL_HINT_ID_GOMESS, + /* 0x1B */ TATL_HINT_ID_GOHT, + /* 0x1C */ TATL_HINT_ID_BLUE_BUBBLE, + /* 0x1D */ TATL_HINT_ID_KINGS_LACKEYS_DARK_ROOM, + /* 0x1E */ TATL_HINT_ID_KINGS_LACKEYS_LIGHT_ROOM, + /* 0x1F */ TATL_HINT_ID_SKULLWALLTULA, + /* 0x20 */ TATL_HINT_ID_GOLD_SKULLTULA, // Only in JP Ver. + /* 0x21 */ TATL_HINT_ID_CAPTAIN_KEETA, + /* 0x22 */ TATL_HINT_ID_YELLOW_CHUCHU, + /* 0x23 */ TATL_HINT_ID_TAKKURI, + /* 0x24 */ TATL_HINT_ID_RED_BUBBLE, + /* 0x25 */ TATL_HINT_ID_HIPLOOP, + /* 0x26 */ TATL_HINT_ID_MASKED_HIPLOOP, + /* 0x27 */ TATL_HINT_ID_SHELLBLADE, + /* 0x28 */ TATL_HINT_ID_GYORG, // "if you go near, you'll be eaten!" + /* 0x29 */ TATL_HINT_ID_GYORG_STUNNED, // "Jump in and attack it!" + /* 0x2A */ TATL_HINT_ID_REDEAD, + /* 0x2B */ TATL_HINT_ID_2B, + /* 0x2C */ TATL_HINT_ID_BLACK_BOE, + /* 0x2D */ TATL_HINT_ID_GIBDO, + /* 0x2E */ TATL_HINT_ID_TWINMOLD, + /* 0x2F */ TATL_HINT_ID_WEARING_GIANTS_MASK, // Twinmold, JP Ver. only + /* 0x30 */ TATL_HINT_ID_WALLMASTER, + /* 0x31 */ TATL_HINT_ID_FLOORMASTER, + /* 0x32 */ TATL_HINT_ID_MAJORAS_MASK, + /* 0x33 */ TATL_HINT_ID_MAJORAS_INCARNATION, + /* 0x34 */ TATL_HINT_ID_MAJORAS_WRATH, + /* 0x35 */ TATL_HINT_ID_IRON_KNUCKLE, + /* 0x36 */ TATL_HINT_ID_36, // Empty + /* 0x37 */ TATL_HINT_ID_LIKE_LIKE, + /* 0x38 */ TATL_HINT_ID_38, // Empty + /* 0x39 */ TATL_HINT_ID_BEAMOS, + /* 0x3A */ TATL_HINT_ID_3A, // Empty + /* 0x3B */ TATL_HINT_ID_FREEZARD, + /* 0x3C */ TATL_HINT_ID_WHITE_BOE, + /* 0x3D */ TATL_HINT_ID_3D, // Empty + /* 0x3E */ TATL_HINT_ID_3E, // Empty + /* 0x3F */ TATL_HINT_ID_3F, // Empty + /* 0x40 */ TATL_HINT_ID_40, // Empty + /* 0x41 */ TATL_HINT_ID_41, // Empty + /* 0x42 */ TATL_HINT_ID_OCTOROK, + /* 0x43 */ TATL_HINT_ID_43, // Empty + /* 0x44 */ TATL_HINT_ID_POE, + /* 0x45 */ TATL_HINT_ID_GEKKO_SNAPPER, + /* 0x46 */ TATL_HINT_ID_BLUE_TEKTITE, + /* 0x47 */ TATL_HINT_ID_LEEVER, + /* 0x48 */ TATL_HINT_ID_PEAHAT, + /* 0x49 */ TATL_HINT_ID_PEAHAT_LARVA, + /* 0x4A */ TATL_HINT_ID_EYEGORE, + /* 0x4B */ TATL_HINT_ID_WIZROBE, + /* 0x4C */ TATL_HINT_ID_WOLFOS, + /* 0x4D */ TATL_HINT_ID_MAD_SCRUB, + /* 0x4E */ TATL_HINT_ID_4E, // Empty + /* 0x4F */ TATL_HINT_ID_4F, // Empty + /* 0x50 */ TATL_HINT_ID_POE_SISTER_MEG, + /* 0x51 */ TATL_HINT_ID_POE_SISTER_JO, + /* 0x52 */ TATL_HINT_ID_POE_SISTER_BETH, + /* 0x53 */ TATL_HINT_ID_POE_SISTER_AMY, + /* 0x54 */ TATL_HINT_ID_PIRATE, + /* 0x55 */ TATL_HINT_ID_STALCHILD, + /* 0x56 */ TATL_HINT_ID_ICE_KEESE, + /* 0x57 */ TATL_HINT_ID_WHITE_WOLFOS, + /* 0x58 */ TATL_HINT_ID_GUAY, + /* 0x59 */ TATL_HINT_ID_BIG_OCTO, + /* 0x5A */ TATL_HINT_ID_BIG_POE, + /* 0x5B */ TATL_HINT_ID_SKULLFISH, + /* 0x5C */ TATL_HINT_ID_DESBREKO, + /* 0x5D */ TATL_HINT_ID_GREEN_CHUCHU, + /* 0x5E */ TATL_HINT_ID_ODOLWA_1, + /* 0x5F */ TATL_HINT_ID_GEKKO_GIANT_SLIME, + /* 0x60 */ TATL_HINT_ID_BAD_BAT, + /* 0x61 */ TATL_HINT_ID_REAL_BOMBCHU, + /* 0x62 */ TATL_HINT_ID_ODOLWA_2, + /* 0x63 */ TATL_HINT_ID_ODOLWA_3, + /* 0x64 */ TATL_HINT_ID_MUSHROOM, + /* 0xFF */ TATL_HINT_ID_NONE = 0xFF +} TatlHintId; + #endif diff --git a/include/z64animation.h b/include/z64animation.h index 58ddb34df..272a4fb84 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -6,26 +6,29 @@ #include "z64dma.h" #include "z64math.h" -struct GlobalContext; +struct PlayState; struct Actor; struct SkelAnime; +struct PlayerAnimationFrame; #define LINK_ANIMETION_OFFSET(addr, offset) \ - (SEGMENT_ROM_START(link_animetion) + ((u32)addr & 0xFFFFFF) + ((u32)offset)) + (SEGMENT_ROM_START(link_animetion) + ((uintptr_t)addr & 0xFFFFFF) + ((u32)offset)) #define LIMB_DONE 0xFF #define ANIMATION_ENTRY_MAX 50 +#define ANIM_FLAG_1 (1 << 0) #define ANIM_FLAG_UPDATEY (1 << 1) +#define ANIM_FLAG_4 (1 << 2) #define ANIM_FLAG_NOMOVE (1 << 4) -typedef enum { +typedef enum AnimationMode { /* 0 */ ANIMMODE_LOOP, /* 1 */ ANIMMODE_LOOP_INTERP, /* 2 */ ANIMMODE_ONCE, /* 3 */ ANIMMODE_ONCE_INTERP, /* 4 */ ANIMMODE_LOOP_PARTIAL, /* 5 */ ANIMMODE_LOOP_PARTIAL_INTERP -} AnimationModes; +} AnimationMode; typedef enum { /* -1 */ ANIMTAPER_DECEL = -1, @@ -34,49 +37,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 +92,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 +108,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 +160,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 +170,11 @@ typedef struct AnimationContext { } AnimationContext; // size = 0xC84 typedef struct { - /* 0x000 */ AnimationHeaderCommon common; - /* 0x004 */ u32 segment; + /* 0x0 */ AnimationHeaderCommon common; + /* 0x4 */ union { + void* segmentVoid; + struct PlayerAnimationFrame* segment; + }; } LinkAnimationHeader; // size = 0x8 typedef struct SkelAnime { @@ -189,7 +195,7 @@ typedef struct SkelAnime { /* 0x2C */ f32 morphRate; // Reciprocal of the number of frames in the morph /* 0x30 */ union { s32 (*normal)(struct SkelAnime*);// Can be Loop, Partial loop, Play once, Morph, or Tapered morph - s32 (*link)(struct GlobalContext*, struct SkelAnime*); // Loop, Play once, and Morph + 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. @@ -198,82 +204,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; @@ -284,40 +240,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 { @@ -329,18 +285,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; @@ -349,7 +305,7 @@ typedef struct { /* 0x0C */ f32 unk_C; /* 0x10 */ f32 unk_10; /* 0x14 */ s32 unk_14; -} FrameControl; +} FrameControl; // size = 0x18 // FlexKeyframeSkeleton ? typedef struct SkeletonInfo { @@ -360,12 +316,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..bfb66a23a 100644 --- a/include/z64audio.h +++ b/include/z64audio.h @@ -1,16 +1,39 @@ #ifndef Z64_AUDIO_H #define Z64_AUDIO_H -#define MK_AUDIO_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0)) +#include "audiothread_cmd.h" #define NO_LAYER ((SequenceLayer*)(-1)) #define TATUMS_PER_BEAT 48 -#define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone) +#define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioCtx.sequenceChannelNone) +#define SEQ_NUM_CHANNELS 16 +#define SEQ_IO_VAL_NONE -1 + +typedef enum { + /* 0x00 */ AUDIO_CUSTOM_FUNCTION_SEQ_0, + /* 0x01 */ AUDIO_CUSTOM_FUNCTION_SEQ_1, + /* 0x02 */ AUDIO_CUSTOM_FUNCTION_SEQ_2, + /* 0x03 */ AUDIO_CUSTOM_FUNCTION_SEQ_3, + /* 0xFE */ AUDIO_CUSTOM_FUNCTION_SYNTH = 0xFE, + /* 0xFF */ AUDIO_CUSTOM_FUNCTION_REVERB +} AudioCustomFunctions; + +typedef enum { + /* 0 */ SEQPLAYER_STATE_0, + /* 1 */ SEQPLAYER_STATE_FADE_IN, + /* 2 */ SEQPLAYER_STATE_FADE_OUT +} SeqPlayerState; #define MAX_CHANNELS_PER_BANK 3 +#define MUTE_FLAGS_STOP_SAMPLES (1 << 3) // prevent further noteSubEus from playing +#define MUTE_FLAGS_STOP_LAYER (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 @@ -18,22 +41,66 @@ #define ADSR_GOTO -2 #define ADSR_RESTART -3 -#define AIBUF_LEN 0x580 +// size of a single sample point +#define SAMPLE_SIZE sizeof(s16) + +// Samples are processed in groups of 16 called a "frame" +#define SAMPLES_PER_FRAME ADPCMFSIZE + +// The length of one left/right channel is 13 frames +#define DMEM_1CH_SIZE (13 * SAMPLES_PER_FRAME * SAMPLE_SIZE) +// Both left and right channels +#define DMEM_2CH_SIZE (2 * DMEM_1CH_SIZE) + +#define AIBUF_LEN (88 * SAMPLES_PER_FRAME) // number of samples +#define AIBUF_SIZE (AIBUF_LEN * SAMPLE_SIZE) // number of bytes + +// Filter sizes +#define FILTER_SIZE (8 * SAMPLE_SIZE) +#define FILTER_BUF_PART1 (8 * SAMPLE_SIZE) +#define FILTER_BUF_PART2 (8 * SAMPLE_SIZE) + +// Must be the same amount of samples as copied by aDuplicate() (audio microcode) +#define WAVE_SAMPLE_COUNT 64 + +#define AUDIO_RELOCATED_ADDRESS_START K0BASE + +#define REVERB_INDEX_NONE -1 + +// To be used with AudioThread_CountAndReleaseNotes() +#define AUDIO_NOTE_RELEASE (1 << 0) +#define AUDIO_NOTE_SAMPLE_NOTES (1 << 1) typedef enum { - /* 0 */ AUDIO_FS_STEREO, - /* 1 */ AUDIO_FS_HEADSET, - /* 2 */ AUDIO_FS_SURROUND, - /* 3 */ AUDIO_FS_MONO -} AudioFileSelectOption; + /* 0 */ REVERB_DATA_TYPE_SETTINGS, // Reverb Settings (Init) + /* 1 */ REVERB_DATA_TYPE_DELAY, // Reverb Delay (numSamples) + /* 2 */ REVERB_DATA_TYPE_DECAY, // Reverb Decay Ratio + /* 3 */ REVERB_DATA_TYPE_SUB_VOLUME, // Reverb Sub-Volume + /* 4 */ REVERB_DATA_TYPE_VOLUME, // Reverb Volume + /* 5 */ REVERB_DATA_TYPE_LEAK_RIGHT, // Reverb Leak Right Channel + /* 6 */ REVERB_DATA_TYPE_LEAK_LEFT, // Reverb Leak Left Channel + /* 7 */ REVERB_DATA_TYPE_FILTER_LEFT, // Reverb Left Filter + /* 8 */ REVERB_DATA_TYPE_FILTER_RIGHT, // Reverb Right Filter + /* 9 */ REVERB_DATA_TYPE_9 // Reverb Unk +} ReverbDataType; typedef enum { - /* 0 */ AUDIO_MODE_STEREO, - /* 1 */ AUDIO_MODE_HEADSET, - /* 2 */ AUDIO_MODE_UNK, - /* 3 */ AUDIO_MODE_MONO, - /* 4 */ AUDIO_MODE_SURROUND -} AudioSoundMode; + /* 0x1 */ AUDIO_ERROR_NO_INST = 1, + /* 0x3 */ AUDIO_ERROR_INVALID_INST_ID = 3, + /* 0x4 */ AUDIO_ERROR_INVALID_DRUM_SFX_ID, + /* 0x5 */ AUDIO_ERROR_NO_DRUM_SFX, + /* 0x10 */ AUDIO_ERROR_FONT_NOT_LOADED = 0x10 +} AudioError; + +#define AUDIO_ERROR(fontId, id, err) (((fontId << 8) + id) + (err << 24)) + +typedef enum { + /* 0 */ SOUNDMODE_STEREO, + /* 1 */ SOUNDMODE_HEADSET, + /* 2 */ SOUNDMODE_SURROUND_EXTERNAL, + /* 3 */ SOUNDMODE_MONO, + /* 4 */ SOUNDMODE_SURROUND, +} SoundMode; typedef enum { /* 0 */ ADSR_STATE_DISABLED, @@ -56,12 +123,14 @@ typedef enum { } SampleMedium; typedef enum { - /* 0 */ CODEC_ADPCM, - /* 1 */ CODEC_S8, + /* 0 */ CODEC_ADPCM, // 16 2-byte samples (32 bytes) compressed into 4-bit samples (8 bytes) + 1 header byte + /* 1 */ CODEC_S8, // 16 2-byte samples (32 bytes) compressed into 8-bit samples (16 bytes) /* 2 */ CODEC_S16_INMEMORY, - /* 3 */ CODEC_SMALL_ADPCM, + /* 3 */ CODEC_SMALL_ADPCM, // 16 2-byte samples (32 bytes) compressed into 2-bit samples (4 bytes) + 1 header byte /* 4 */ CODEC_REVERB, - /* 5 */ CODEC_S16 + /* 5 */ CODEC_S16, + /* 6 */ CODEC_UNK6, + /* 7 */ CODEC_UNK7 // processed as uncompressed samples } SampleCodec; typedef enum { @@ -86,12 +155,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,51 +208,60 @@ typedef struct { typedef struct { /* 0x0 */ s16 delay; /* 0x2 */ s16 arg; -} AdsrEnvelope; // size = 0x4 +} EnvelopePoint; // size = 0x4 typedef struct { /* 0x00 */ u32 start; - /* 0x04 */ u32 end; + /* 0x04 */ u32 loopEnd; // numSamples into the sample where the loop ends /* 0x08 */ u32 count; - /* 0x0C */ u32 unk_0C; - /* 0x10 */ s16 state[16]; // only exists if count != 0. 8-byte aligned + /* 0x0C */ u32 sampleEnd; // total number of s16-samples in the + /* 0x10 */ s16 predictorState[16]; // only exists if count != 0. 8-byte aligned } AdpcmLoop; // size = 0x30 (or 0x10) +/** + * The procedure used to design the codeBook is based on an adaptive clustering algorithm. + * The size of the codeBook is (8 * order * numPredictors) and is 8-byte aligned + */ typedef struct { /* 0x00 */ s32 order; - /* 0x04 */ s32 npredictors; - /* 0x08 */ s16 book[1]; // size 8 * order * npredictors. 8-byte aligned + /* 0x04 */ s32 numPredictors; + /* 0x08 */ s16 codeBook[1]; // a table of prediction coefficients that the coder selects from to optimize sound quality. } AdpcmBook; // size >= 0x8 typedef struct { /* 0x00 */ u32 unk_0 : 1; - /* 0x00 */ u32 codec : 3; - /* 0x00 */ u32 medium : 2; + /* 0x00 */ u32 codec : 3; // The state of compression or decompression + /* 0x00 */ u32 medium : 2; // Medium where sample is currently stored /* 0x00 */ u32 unk_bit26 : 1; - /* 0x00 */ u32 unk_bit25 : 1; - /* 0x01 */ u32 size : 24; - /* 0x04 */ u8* sampleAddr; - /* 0x08 */ AdpcmLoop* loop; - /* 0x0C */ AdpcmBook* book; -} SoundFontSample; // size = 0x10 + /* 0x00 */ u32 isRelocated : 1; // Has the sample header been relocated (offsets to pointers) + /* 0x01 */ u32 size : 24; // Size of the sample + /* 0x04 */ u8* sampleAddr; // Raw sample data. Offset from the start of the sample bank or absolute address to either rom or ram + /* 0x08 */ AdpcmLoop* loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram + /* 0x0C */ AdpcmBook* book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram +} Sample; // size = 0x10 typedef struct { - /* 0x00 */ SoundFontSample* sample; + /* 0x00 */ Sample* sample; /* 0x04 */ f32 tuning; // frequency scale factor -} SoundFontSound; // size = 0x8 +} TunedSample; // size = 0x8 +/** + * Stores an entry of decompressed samples in a reverb ring buffer. + * By storing the sample in a ring buffer, the time it takes to loop + * around back to the same sample acts as a delay, leading to an echo effect. + */ typedef struct { /* 0x00 */ s16 numSamplesAfterDownsampling; // never read - /* 0x02 */ s16 chunkLen; // never read + /* 0x02 */ s16 numSamples; // never read /* 0x04 */ s16* toDownsampleLeft; /* 0x08 */ s16* toDownsampleRight; // data pointed to by left and right are adjacent in memory /* 0x0C */ s32 startPos; // start pos in ring buffer - /* 0x10 */ s16 lengthA; // first length in ring buffer (from startPos, at most until end) - /* 0x12 */ s16 lengthB; // second length in ring buffer (from pos 0) - /* 0x14 */ u16 unk_14; - /* 0x16 */ u16 unk_16; - /* 0x18 */ u16 unk_18; -} ReverbRingBufferItem; // size = 0x1C + /* 0x10 */ s16 size; // first length in ring buffer (from startPos, at most until end) + /* 0x12 */ s16 wrappedSize; // second length in ring buffer (from pos 0) + /* 0x14 */ u16 loadResamplePitch; + /* 0x16 */ u16 saveResamplePitch; + /* 0x18 */ u16 saveResampleNumSamples; +} ReverbBufferEntry; // size = 0x1C typedef struct { /* 0x000 */ u8 resampleFlags; @@ -191,60 +269,64 @@ typedef struct { /* 0x002 */ u8 framesToIgnore; /* 0x003 */ u8 curFrame; /* 0x004 */ u8 downsampleRate; - /* 0x005 */ s8 unk_05; - /* 0x006 */ u16 windowSize; - /* 0x008 */ s16 unk_08; - /* 0x00A */ s16 unk_0A; - /* 0x00C */ u16 unk_0C; - /* 0x00E */ u16 unk_0E; + /* 0x005 */ s8 mixReverbIndex; // mix in reverb from this index. set to 0xFF to not mix any + /* 0x006 */ u16 delayNumSamples; // number of samples between echos + /* 0x008 */ s16 mixReverbStrength; // the gain/amount to mix in reverb from mixReverbIndex + /* 0x00A */ s16 volume; + /* 0x00C */ u16 decayRatio; // determines how fast reverb dissipate + /* 0x00E */ u16 downsamplePitch; /* 0x010 */ s16 leakRtl; /* 0x012 */ s16 leakLtr; - /* 0x014 */ u16 unk_14; - /* 0x016 */ s16 unk_16; - /* 0x018 */ u8 unk_18; - /* 0x019 */ s8 unk_19; - /* 0x01A */ u16 unk_1A; - /* 0x01C */ u16 unk_1C; - /* 0x01E */ u8 unk_1E; - /* 0x020 */ s32 nextRingBufPos; - /* 0x024 */ s32 unk_24; // May be bufSizePerChan - /* 0x028 */ s16* leftRingBuf; - /* 0x02C */ s16* rightRingBuf; - /* 0x030 */ void* unk_30; - /* 0x034 */ void* unk_34; - /* 0x038 */ void* unk_38; - /* 0x03C */ void* unk_3C; - /* 0x040 */ ReverbRingBufferItem items[2][5]; - /* 0x158 */ ReverbRingBufferItem items2[2][5]; + /* 0x014 */ u16 subDelay; // number of samples between sub echos + /* 0x016 */ s16 subVolume; // strength of the sub echos + /* 0x018 */ u8 resampleEffectOn; + /* 0x019 */ s8 resampleEffectExtraSamples; + /* 0x01A */ u16 resampleEffectLoadUnk; + /* 0x01C */ u16 resampleEffectSaveUnk; + /* 0x01E */ u8 delayNumSamplesAfterDownsampling; + /* 0x020 */ s32 nextReverbBufPos; + /* 0x024 */ s32 delayNumSamplesUnk; // May be bufSizePerChan + /* 0x028 */ s16* leftReverbBuf; + /* 0x02C */ s16* rightReverbBuf; + /* 0x030 */ s16* leftLoadResampleBuf; + /* 0x034 */ s16* rightLoadResampleBuf; + /* 0x038 */ s16* leftSaveResampleBuf; + /* 0x03C */ s16* rightSaveResampleBuf; + /* 0x040 */ ReverbBufferEntry bufEntry[2][5]; + /* 0x158 */ ReverbBufferEntry subBufEntry[2][5]; /* 0x270 */ s16* filterLeft; /* 0x274 */ s16* filterRight; - /* 0x278 */ s16* unk_278; - /* 0x27C */ s16* unk_27C; + /* 0x278 */ s16* filterLeftInit; + /* 0x27C */ s16* filterRightInit; /* 0x280 */ s16* filterLeftState; /* 0x284 */ s16* filterRightState; - /* 0x288 */ SoundFontSound sound; - /* 0x290 */ SoundFontSample sample; + /* 0x288 */ TunedSample tunedSample; + /* 0x290 */ Sample sample; /* 0x2A0 */ AdpcmLoop loop; } SynthesisReverb; // size = 0x2D0 typedef struct { - /* 0x00 */ u8 loaded; + /* 0x00 */ u8 isRelocated; // have the envelope and all samples been relocated (offsets to pointers) /* 0x01 */ u8 normalRangeLo; /* 0x02 */ u8 normalRangeHi; - /* 0x03 */ u8 releaseRate; - /* 0x04 */ AdsrEnvelope* envelope; - /* 0x08 */ SoundFontSound lowNotesSound; - /* 0x10 */ SoundFontSound normalNotesSound; - /* 0x18 */ SoundFontSound highNotesSound; + /* 0x03 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable + /* 0x04 */ EnvelopePoint* envelope; + /* 0x08 */ TunedSample lowPitchTunedSample; + /* 0x10 */ TunedSample normalPitchTunedSample; + /* 0x18 */ TunedSample highPitchTunedSample; } 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; -} Drum; // size = 0x18 + /* 0x02 */ u8 isRelocated; // have tunedSample.sample and envelope been relocated (offsets to pointers) + /* 0x04 */ TunedSample tunedSample; + /* 0x0C */ EnvelopePoint* envelope; +} Drum; // size = 0x10 + +typedef struct { + /* 0x00 */ TunedSample tunedSample; +} SoundEffect; // size = 0x08 typedef struct { /* 0x00 */ u8 numInstruments; @@ -254,7 +336,7 @@ typedef struct { /* 0x04 */ u16 numSfx; /* 0x08 */ Instrument** instruments; /* 0x0C */ Drum** drums; - /* 0x10 */ SoundFontSound* soundEffects; + /* 0x10 */ SoundEffect* soundEffects; } SoundFont; // size = 0x14 typedef struct { @@ -277,23 +359,20 @@ 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; + /* 0x00C */ s16 tempoChange; /* 0x00E */ s16 transposition; /* 0x010 */ u16 delay; /* 0x012 */ u16 fadeTimer; - /* 0x014 */ u16 fadeTimerUnkEu; - /* 0x016 */ u16 unk_16; // New to MM - union { - /* 0x018 */ u8* seqData; - /* 0x018 */ u16* seqData16; - }; + /* 0x014 */ u16 storedFadeTimer; + /* 0x016 */ u16 unk_16; + /* 0x018 */ u8* seqData; /* 0x01C */ f32 fadeVolume; /* 0x020 */ f32 fadeVelocity; /* 0x024 */ f32 volume; @@ -308,20 +387,20 @@ typedef struct { /* 0x09C */ NotePool notePool; /* 0x0DC */ s32 skipTicks; /* 0x0E0 */ u32 scriptCounter; - /* 0x0E4 */ char unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp - /* 0x158 */ s8 soundScriptIO[8]; + /* 0x0E4 */ UNK_TYPE1 unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp + /* 0x158 */ s8 seqScriptIO[8]; } 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 { union { struct { - /* 0x00 */ u8 unk_0b80 : 1; + /* 0x00 */ u8 unused : 1; /* 0x00 */ u8 hang : 1; /* 0x00 */ u8 decay : 1; /* 0x00 */ u8 release : 1; @@ -336,32 +415,30 @@ typedef struct { /* 0x0C */ f32 fadeOutVel; /* 0x10 */ f32 current; /* 0x14 */ f32 target; - /* 0x18 */ char unk_18[4]; - /* 0x1C */ AdsrEnvelope* envelope; + /* 0x18 */ UNK_TYPE1 unk_18[4]; + /* 0x1C */ EnvelopePoint* envelope; } AdsrState; // size = 0x20 -typedef struct { - /* 0x0 */ u8 unused : 2; - /* 0x0 */ u8 bit2 : 2; - /* 0x0 */ u8 strongRight : 1; - /* 0x0 */ u8 strongLeft : 1; - /* 0x0 */ u8 stereoHeadsetEffects : 1; - /* 0x0 */ u8 usesHeadsetPanEffects : 1; +typedef union { + struct { + /* 0x0 */ u8 unused : 2; + /* 0x0 */ u8 type : 2; + /* 0x0 */ u8 strongRight : 1; + /* 0x0 */ u8 strongLeft : 1; + /* 0x0 */ u8 strongReverbRight : 1; + /* 0x0 */ u8 strongReverbLeft : 1; + }; + /* 0x0 */ u8 asByte; } StereoData; // size = 0x1 -typedef union { - /* 0x0 */ StereoData s; - /* 0x0 */ u8 asByte; -} Stereo; // size = 0x1 - typedef struct { - /* 0x00 */ u8 reverb; - /* 0x01 */ u8 unk_1; + /* 0x00 */ u8 targetReverbVol; + /* 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; - /* 0x05 */ u8 unk_4; - /* 0x06 */ u16 unk_6; + /* 0x03 */ u8 surroundEffectIndex; + /* 0x04 */ StereoData stereoData; + /* 0x05 */ u8 combFilterSize; + /* 0x06 */ u16 combFilterGain; /* 0x08 */ f32 freqScale; /* 0x0C */ f32 velocity; /* 0x10 */ s16* filter; @@ -370,11 +447,11 @@ typedef struct { typedef struct VibratoSubStruct { /* 0x0 */ u16 vibratoRateStart; - /* 0x2 */ u16 vibratoExtentStart; + /* 0x2 */ u16 vibratoDepthStart; /* 0x4 */ u16 vibratoRateTarget; - /* 0x6 */ u16 vibratoExtentTarget; + /* 0x6 */ u16 vibratoDepthTarget; /* 0x8 */ u16 vibratoRateChangeDelay; - /* 0xA */ u16 vibratoExtentChangeDelay; + /* 0xA */ u16 vibratoDepthChangeDelay; /* 0xC */ u16 vibratoDelay; } VibratoSubStruct; // size = 0xE @@ -383,7 +460,7 @@ typedef struct SequenceChannel { /* 0x00 */ u8 enabled : 1; /* 0x00 */ u8 finished : 1; /* 0x00 */ u8 stopScript : 1; - /* 0x00 */ u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething + /* 0x00 */ u8 muted : 1; // sets SequenceLayer.muted /* 0x00 */ u8 hasInstrument : 1; /* 0x00 */ u8 stereoHeadsetEffects : 1; /* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity @@ -397,8 +474,8 @@ typedef struct SequenceChannel { /* 0x01 */ u8 asByte; } changes; /* 0x02 */ u8 noteAllocPolicy; - /* 0x03 */ u8 muteBehavior; - /* 0x04 */ u8 reverb; // or dry/wet mix + /* 0x03 */ u8 muteFlags; + /* 0x04 */ u8 targetReverbVol; // or dry/wet mix /* 0x05 */ u8 notePriority; // 0-3 /* 0x06 */ u8 someOtherPriority; /* 0x07 */ u8 fontId; @@ -406,15 +483,15 @@ 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 + /* 0x0F */ u8 combFilterSize; + /* 0x10 */ u8 surroundEffectIndex; + /* 0x11 */ u8 channelIndex; /* 0x12 */ VibratoSubStruct vibrato; /* 0x20 */ u16 delay; - /* 0x22 */ u16 unk_20; + /* 0x22 */ u16 combFilterGain; /* 0x24 */ u16 unk_22; // Used for indexing data /* 0x26 */ s16 instOrWave; // either 0 (none), instrument index + 1, or // 0x80..0x83 for sawtooth/triangle/sine/square waves. @@ -433,33 +510,33 @@ typedef struct SequenceChannel { /* 0x64 */ SeqScriptState scriptState; /* 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 + /* 0xC8 */ s8 seqScriptIO[8]; // bridge between sound script and audio lib, "io ports" + /* 0xD0 */ u8* sfxState; // SfxChannelState /* 0xD4 */ s16* filter; - /* 0xD8 */ Stereo stereo; - /* 0xDC */ s32 unk_DC; // New to MM - /* 0xE0 */ s32 unk_E0; // New to MM + /* 0xD8 */ StereoData stereoData; + /* 0xDC */ s32 startSamplePos; + /* 0xE0 */ s32 unk_E0; } SequenceChannel; // size = 0xE4 // Might also be known as a Track, according to sm64 debug strings (?). typedef struct SequenceLayer { /* 0x00 */ u8 enabled : 1; /* 0x00 */ u8 finished : 1; - /* 0x00 */ u8 stopSomething : 1; + /* 0x00 */ u8 muted : 1; /* 0x00 */ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound /* 0x00 */ u8 bit3 : 1; // "loaded"? /* 0x00 */ u8 ignoreDrumPan : 1; /* 0x00 */ u8 bit1 : 1; // "has initialized continuous notes"? /* 0x00 */ u8 notePropertiesNeedInit : 1; - /* 0x01 */ Stereo stereo; + /* 0x01 */ StereoData stereoData; /* 0x02 */ u8 instOrWave; /* 0x03 */ u8 gateTime; /* 0x04 */ u8 semitone; /* 0x05 */ u8 portamentoTargetNote; /* 0x06 */ u8 pan; // 0..128 /* 0x07 */ u8 notePan; - /* 0x08 */ u8 unk_08; - /* 0x09 */ u8 unk_09; + /* 0x08 */ u8 surroundEffectIndex; + /* 0x09 */ u8 targetReverbVol; union { struct { /* 0x0A */ u16 bit_0 : 1; @@ -501,68 +578,66 @@ typedef struct SequenceLayer { /* 0x50 */ f32 noteVelocity; /* 0x54 */ f32 noteFreqScale; /* 0x58 */ Instrument* instrument; - /* 0x5C */ SoundFontSound* sound; + /* 0x5C */ TunedSample* tunedSample; /* 0x60 */ SequenceChannel* channel; // Not SequenceChannel? /* 0x64 */ SeqScriptState scriptState; /* 0x80 */ AudioListItem listItem; } SequenceLayer; // size = 0x90 typedef struct { - /* 0x00 */ s16 adpcmdecState[0x10]; - /* 0x20 */ s16 finalResampleState[0x10]; - /* 0x40 */ s16 mixEnvelopeState[0x28]; - /* 0x90 */ s16 panResampleState[0x10]; - /* 0xB0 */ s16 panSamplesBuffer[0x20]; - /* 0xF0 */ s16 dummyResampleState[0x10]; -} NoteSynthesisBuffers; // size = 0x110 + /* 0x000 */ s16 adpcmState[16]; + /* 0x020 */ s16 finalResampleState[16]; + /* 0x040 */ s16 filterState[32]; + /* 0x080 */ s16 unusedState[16]; + /* 0x0A0 */ s16 haasEffectDelayState[32]; + /* 0x0E0 */ s16 combFilterState[128]; + /* 0x1E0 */ s16 surroundEffectState[128]; +} NoteSynthesisBuffers; // size = 0x2E0 typedef struct { - /* 0x00 */ u8 restart_bit0 : 1; - /* 0x00 */ u8 restart_bit1 : 1; - /* 0x00 */ u8 restart_bit2 : 1; - /* 0x00 */ u8 restart_bit3 : 1; - /* 0x00 */ u8 restart_bit4 : 1; - /* 0x00 */ u8 restart_bit5 : 1; - /* 0x00 */ u8 restart_bit6 : 1; - /* 0x00 */ u8 restart_bit7 : 1; + /* 0x00 */ u8 atLoopPoint : 1; + /* 0x00 */ u8 stopLoop : 1; /* 0x01 */ u8 sampleDmaIndex; - /* 0x02 */ u8 prevHeadsetPanRight; - /* 0x03 */ u8 prevHeadsetPanLeft; - /* 0x04 */ u8 reverbVol; + /* 0x02 */ u8 prevHaasEffectLeftDelaySize; + /* 0x03 */ u8 prevHaasEffectRightDelaySize; + /* 0x04 */ u8 curReverbVol; /* 0x05 */ u8 numParts; - /* 0x06 */ u16 samplePosFrac; - /* 0x08 */ u16 unk_08; // New to MM - /* 0x0C */ s32 samplePosInt; + /* 0x06 */ u16 samplePosFrac; // Fractional part of the sample position + /* 0x08 */ u16 surroundEffectGain; + /* 0x0C */ s32 samplePosInt; // Integer part of the sample position /* 0x10 */ NoteSynthesisBuffers* synthesisBuffers; /* 0x14 */ s16 curVolLeft; /* 0x16 */ s16 curVolRight; - /* 0x18 */ u16 unk_14; - /* 0x1A */ u16 unk_16; - /* 0x1C */ u16 unk_18; - /* 0x1E */ u8 unk_1A; + /* 0x18 */ UNK_TYPE1 unk_14[0x6]; + /* 0x1E */ u8 combFilterNeedsInit; /* 0x1F */ u8 unk_1F; - /* 0x20 */ u16 unk_1C; - /* 0x22 */ u16 unk_1E; + /* 0x20 */ UNK_TYPE1 unk_20[0x4]; } NoteSynthesisState; // size = 0x24 typedef struct { - /* 0x00 */ struct VibratoSubStruct* vibSubStruct; // MM Something else? + /* 0x00 */ struct VibratoSubStruct* vibSubStruct; // Something else? /* 0x04 */ u32 time; /* 0x08 */ s16* curve; - /* 0x0C */ f32 extent; + /* 0x0C */ f32 depth; /* 0x10 */ f32 rate; /* 0x14 */ u8 active; /* 0x16 */ u16 rateChangeTimer; - /* 0x18 */ u16 extentChangeTimer; + /* 0x18 */ u16 depthChangeTimer; /* 0x1A */ u16 delay; } VibratoState; // size = 0x1C +typedef enum { + /* 0 */ PLAYBACK_STATUS_0, + /* 1 */ PLAYBACK_STATUS_1, + /* 2 */ PLAYBACK_STATUS_2 +} NotePlaybackStatus; + typedef struct { /* 0x00 */ u8 priority; /* 0x01 */ u8 waveId; - /* 0x02 */ u8 sampleCountIndex; + /* 0x02 */ u8 harmonicIndex; // the harmonic index for the synthetic wave contained in gWaveSamples (also matches the base 2 logarithm of the harmonic order) /* 0x03 */ u8 fontId; - /* 0x04 */ u8 unk_04; + /* 0x04 */ u8 status; /* 0x05 */ u8 stereoHeadsetEffects; /* 0x06 */ s16 adsrVolScaleUnused; /* 0x08 */ f32 portamentoFreqScale; @@ -574,73 +649,74 @@ typedef struct { /* 0x34 */ AdsrState adsr; /* 0x54 */ Portamento portamento; /* 0x60 */ VibratoState vibratoState; - /* 0x7C */ char unk_7C[0x8]; - /* 0x84 */ u32 unk_84; -} NotePlaybackState; // size = 0x88 + /* 0x7C */ UNK_TYPE1 pad7C[0x4]; + /* 0x80 */ u8 unk_80; + /* 0x84 */ u32 startSamplePos; + /* 0x88 */ UNK_TYPE1 unk_BC[0x1C]; +} NotePlaybackState; // size = 0xA4 typedef struct { struct { /* 0x00 */ volatile u8 enabled : 1; /* 0x00 */ u8 needsInit : 1; - /* 0x00 */ u8 finished : 1; // ? + /* 0x00 */ u8 finished : 1; /* 0x00 */ u8 unused : 1; - /* 0x00 */ u8 stereoStrongRight : 1; - /* 0x00 */ u8 stereoStrongLeft : 1; - /* 0x00 */ u8 stereoHeadsetEffects : 1; - /* 0x00 */ u8 usesHeadsetPanEffects : 1; // ? + /* 0x00 */ u8 strongRight : 1; + /* 0x00 */ u8 strongLeft : 1; + /* 0x00 */ u8 strongReverbRight : 1; + /* 0x00 */ u8 strongReverbLeft : 1; } bitField0; struct { /* 0x01 */ u8 reverbIndex : 3; /* 0x01 */ u8 bookOffset : 2; /* 0x01 */ u8 isSyntheticWave : 1; /* 0x01 */ u8 hasTwoParts : 1; - /* 0x01 */ u8 usesHeadsetPanEffects2 : 1; + /* 0x01 */ u8 useHaasEffect : 1; } bitField1; - /* 0x02 */ u8 unk_2; - /* 0x03 */ u8 headsetPanRight; - /* 0x04 */ u8 headsetPanLeft; - /* 0x05 */ u8 reverbVol; - /* 0x06 */ u8 unk_06; - /* 0x07 */ u8 unk_07; + /* 0x02 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number + /* 0x03 */ u8 haasEffectLeftDelaySize; + /* 0x04 */ u8 haasEffectRightDelaySize; + /* 0x05 */ u8 targetReverbVol; + /* 0x06 */ u8 harmonicIndexCurAndPrev; // bits 3..2 store curHarmonicIndex, bits 1..0 store prevHarmonicIndex + /* 0x07 */ u8 combFilterSize; /* 0x08 */ u16 targetVolLeft; /* 0x0A */ u16 targetVolRight; - /* 0x0C */ u16 resamplingRateFixedPoint; - /* 0x0E */ u16 unk_0E; - union { - /* 0x10 */ SoundFontSound* soundFontSound; - /* 0x10 */ s16* samples; // used for synthetic waves - } sound; + /* 0x0C */ u16 frequencyFixedPoint; + /* 0x0E */ u16 combFilterGain; + union { + /* 0x10 */ TunedSample* tunedSample; + /* 0x10 */ s16* waveSampleAddr; // used for synthetic waves + }; /* 0x14 */ s16* filter; - /* 0x18 */ u8 unk_18; // New to MM - /* 0x19 */ u8 unk_19; // New to MM - /* 0x1A */ UNK_TYPE1 pad_1A[0x6]; -} NoteSubEu; // size = 0x20 + /* 0x18 */ UNK_TYPE1 unk_18; + /* 0x19 */ u8 surroundEffectIndex; + /* 0x1A */ UNK_TYPE1 unk_1A[0x6]; +} NoteSampleState; // size = 0x20 typedef struct Note { /* 0x00 */ AudioListItem listItem; /* 0x10 */ NoteSynthesisState synthesisState; /* 0x34 */ NotePlaybackState playbackState; - /* 0xBC */ char unk_BC[0x1C]; - /* 0xD8 */ NoteSubEu noteSubEu; + /* 0xD8 */ NoteSampleState sampleState; } Note; // size = 0xF8 typedef struct { /* 0x00 */ u8 downsampleRate; - /* 0x02 */ u16 windowSize; - /* 0x04 */ u16 unk_4; - /* 0x06 */ u16 unk_6; - /* 0x08 */ u16 unk_8; - /* 0x0A */ u16 unk_A; + /* 0x02 */ u16 delayNumSamples; + /* 0x04 */ u16 decayRatio; // determines how fast reverb dissipates + /* 0x06 */ u16 subDelay; + /* 0x08 */ u16 subVolume; + /* 0x0A */ u16 volume; /* 0x0C */ u16 leakRtl; /* 0x0E */ u16 leakLtr; - /* 0x10 */ s8 unk_10; - /* 0x12 */ u16 unk_12; + /* 0x10 */ s8 mixReverbIndex; + /* 0x12 */ u16 mixReverbStrength; /* 0x14 */ s16 lowPassFilterCutoffLeft; /* 0x16 */ s16 lowPassFilterCutoffRight; } ReverbSettings; // size = 0x18 /** - * The high-level audio specifications requested when initializing or resetting the audio heap. + * The high-level audio specifications requested when initializing or resetting the audio pool. * Most often resets during scene transitions, but will highly depend on game play. */ typedef struct { @@ -648,7 +724,8 @@ typedef struct { /* 0x04 */ u8 unk_04; /* 0x05 */ u8 numNotes; /* 0x06 */ u8 numSequencePlayers; - /* 0x07 */ u8 unk_07[0x2]; // unused, set to zero + /* 0x07 */ u8 unk_07; // unused, set to zero + /* 0x08 */ u8 unk_08; // unused, set to zero /* 0x09 */ u8 numReverbs; /* 0x0C */ ReverbSettings* reverbSettings; /* 0x10 */ u16 sampleDmaBufSize1; @@ -674,18 +751,18 @@ typedef struct { /* 0x00 */ s16 specUnk4; /* 0x02 */ u16 samplingFreq; // Target sampling rate in Hz /* 0x04 */ u16 aiSamplingFreq; // True sampling rate set to the audio interface (AI) for the audio digital-analog converter (DAC) - /* 0x06 */ s16 samplesPerFrameTarget; - /* 0x08 */ s16 maxAiBufferLength; - /* 0x0A */ s16 minAiBufferLength; - /* 0x0C */ s16 updatesPerFrame; - /* 0x0E */ s16 samplesPerUpdate; - /* 0x10 */ s16 samplesPerUpdateMax; - /* 0x12 */ s16 samplesPerUpdateMin; + /* 0x06 */ s16 numSamplesPerFrameTarget; + /* 0x08 */ s16 numSamplesPerFrameMax; + /* 0x0A */ s16 numSamplesPerFrameMin; + /* 0x0C */ s16 updatesPerFrame; // for each frame of the audio thread (default 60 fps), number of updates to process audio + /* 0x0E */ s16 numSamplesPerUpdate; + /* 0x10 */ s16 numSamplesPerUpdateMax; + /* 0x12 */ s16 numSamplesPerUpdateMin; /* 0x14 */ s16 numSequencePlayers; /* 0x18 */ f32 resampleRate; - /* 0x1C */ f32 updatesPerFrameInv; - /* 0x20 */ f32 unkUpdatesPerFrameScaled; - /* 0x24 */ f32 unk_24; + /* 0x1C */ f32 updatesPerFrameInv; // inverse (reciprocal) of updatesPerFrame + /* 0x20 */ f32 updatesPerFrameInvScaled; // updatesPerFrameInv scaled down by a factor of 256 + /* 0x24 */ f32 updatesPerFrameScaled; // updatesPerFrame scaled down by a factor of 4 } AudioBufferParameters; // size = 0x28 /** @@ -767,7 +844,7 @@ typedef struct { typedef struct { /* 0x00 */ u32 endAndMediumKey; - /* 0x04 */ SoundFontSample* sample; + /* 0x04 */ Sample* sample; /* 0x08 */ u8* ramAddr; /* 0x0C */ u32 encodedInfo; /* 0x10 */ s32 isFree; @@ -822,7 +899,7 @@ typedef struct { /* 0x14 */ s32 status; /* 0x18 */ size_t bytesRemaining; /* 0x1C */ s8* isDone; // TODO: rename in OoT and sync up here. This is an external status while (s32 status) is an internal status - /* 0x20 */ SoundFontSample sample; + /* 0x20 */ Sample sample; /* 0x30 */ OSMesgQueue msgqueue; /* 0x48 */ OSMesg msg; /* 0x4C */ OSIoMesg ioMesg; @@ -869,11 +946,11 @@ typedef struct { /* 0x0002 */ u16 unk_2; // reads from audio spec unk_14, never used, always set to 0x7FFF /* 0x0004 */ u16 unk_4; /* 0x0006 */ char unk_0006[0xA]; - /* 0x0010 */ s16* curLoadedBook; - /* 0x0014 */ NoteSubEu* noteSubsEu; + /* 0x0010 */ s16* adpcmCodeBook; + /* 0x0014 */ NoteSampleState* sampleStateList; /* 0x0018 */ SynthesisReverb synthesisReverbs[4]; /* 0x0B58 */ char unk_0B58[0x30]; - /* 0x0B88 */ SoundFontSample* usedSamples[128]; + /* 0x0B88 */ Sample* usedSamples[128]; /* 0x0D88 */ AudioPreloadReq preloadSampleStack[128]; /* 0x1788 */ s32 numUsedSamples; /* 0x178C */ s32 preloadSampleStackTop; @@ -889,7 +966,7 @@ typedef struct { /* 0x1E58 */ OSMesg externalLoadMesgBuf[0x10]; /* 0x1E98 */ OSMesgQueue preloadSampleQueue; /* 0x1EB0 */ OSMesg preloadSampleMesgBuf[0x10]; - /* 0x1EF0 */ OSMesgQueue currAudioFrameDmaQueue; + /* 0x1EF0 */ OSMesgQueue curAudioFrameDmaQueue; /* 0x1F08 */ OSMesg currAudioFrameDmaMesgBuf[0x40]; /* 0x2008 */ OSIoMesg currAudioFrameDmaIoMesgBuf[0x40]; /* 0x2608 */ OSMesgQueue syncDmaQueue; @@ -911,7 +988,7 @@ typedef struct { /* 0x285C */ char unk_285C[0x4]; /* 0x2860 */ u8* sequenceFontTable; /* 0x2864 */ u16 numSequences; - /* 0x2868 */ SoundFont* soundFonts; + /* 0x2868 */ SoundFont* soundFontList; /* 0x286C */ AudioBufferParameters audioBufferParameters; /* 0x2994 */ f32 unk_2870; /* 0x2898 */ s32 sampleDmaBufSize1; @@ -920,12 +997,12 @@ typedef struct { /* 0x28B0 */ s32 sampleDmaBufSize; /* 0x28B4 */ s32 maxAudioCmds; /* 0x28B8 */ s32 numNotes; - /* 0x2898 */ s16 tempoInternalToExternal; + /* 0x2898 */ s16 maxTempo; /* 0x28BE */ s8 soundMode; /* 0x28C0 */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread is run since the last audio reset /* 0x28C4 */ s32 curAudioFrameDmaCount; /* 0x28C8 */ s32 rspTaskIndex; - /* 0x28CC */ s32 curAiBuffferIndex; + /* 0x28CC */ s32 curAiBufferIndex; /* 0x28AC */ Acmd* abiCmdBufs[2]; // Pointer to audio heap where the audio binary interface command lists are stored. Two lists that alternative every frame /* 0x28B4 */ Acmd* curAbiCmdBuf; /* 0x28DC */ AudioTask* curTask; @@ -933,16 +1010,16 @@ typedef struct { /* 0x2980 */ f32 unk_2960; /* 0x2984*/ s32 refreshRate; /* 0x2988 */ s16* aiBuffers[3]; // Pointers to the audio buffer allocated on the initPool contained in the audio heap. Stores fully processed digital audio before transferring to the audio interface (AI) - /* 0x2994 */ s16 aiBufLengths[3]; // Number of bytes to transfer to the audio interface buffer + /* 0x2994 */ s16 numSamplesPerFrame[3]; // Number of samples to transfer to the audio interface buffer /* 0x299C */ u32 audioRandom; /* 0x29A0 */ s32 audioErrorFlags; /* 0x29A4 */ volatile u32 resetTimer; - /* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel); + /* 0x29A8 */ u32 (*customSeqFunctions[4])(s8 value, SequenceChannel* channel); /* 0x29B8 */ s8 unk_29B8; - /* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt - /* 0x29C0 */ AudioAllocPool audioSessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset + /* 0x29BC */ s32 numAbiCmdsMax; // sMaxAbiCmdCnt + /* 0x29C0 */ AudioAllocPool sessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset /* 0x29D0 */ AudioAllocPool externalPool; // pool allocated on an external device. Never used in game - /* 0x29E0 */ AudioAllocPool audioInitPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset + /* 0x29E0 */ AudioAllocPool initPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset /* 0x29F0 */ AudioAllocPool miscPool; // A sub-pool to the session pool, /* 0x2A00 */ char unk_29D0[0x20]; // probably two unused pools /* 0x2A20 */ AudioAllocPool cachePool; // The common pool for all cache entries @@ -963,54 +1040,54 @@ typedef struct { /* 0x4398 */ u8 fontLoadStatus[0x30]; /* 0x43C8 */ u8 seqLoadStatus[0x80]; /* 0x4448 */ volatile u8 resetStatus; - /* 0x4449 */ u8 audioResetSpecIdToLoad; + /* 0x4449 */ u8 specId; /* 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; /* 0x4460 */ SequencePlayer seqPlayers[5]; /* 0x4B40 */ SequenceLayer sequenceLayers[80]; /* 0x7840 */ SequenceChannel sequenceChannelNone; - /* 0x7924 */ s32 noteSubEuOffset; + /* 0x7924 */ s32 sampleStateOffset; // Start of the list of sample states for this update. Resets after each audio frame. /* 0x7928 */ AudioListItem layerFreeList; /* 0x7938 */ NotePool noteFreeLists; - /* 0x7978 */ u8 cmdWritePos; - /* 0x7979 */ u8 cmdReadPos; - /* 0x797A */ u8 cmdQueueFinished; - /* 0x797C */ u16 activeChannelsFlags[5]; // bitwise flag for 16 channels. Only channels with bit turned on will be processed + /* 0x7978 */ u8 threadCmdWritePos; + /* 0x7979 */ u8 threadCmdReadPos; + /* 0x797A */ u8 threadCmdQueueFinished; + /* 0x797C */ u16 threadCmdChannelMask[5]; // bit-packed for 16 channels. When processing an audio thread channel command on all channels, only process channels with their bit set. /* 0x7988 */ OSMesgQueue* audioResetQueueP; /* 0x798C */ OSMesgQueue* taskStartQueueP; - /* 0x7990 */ OSMesgQueue* cmdProcQueueP; + /* 0x7990 */ OSMesgQueue* threadCmdProcQueueP; /* 0x7994 */ OSMesgQueue taskStartQueue; - /* 0x79AC */ OSMesgQueue cmdProcQueue; + /* 0x79AC */ OSMesgQueue threadCmdProcQueue; /* 0x79C4 */ OSMesgQueue audioResetQueue; /* 0x79DC */ OSMesg taskStartMsgs[1]; /* 0x79E0 */ OSMesg audioResetMesgs[1]; - /* 0x79E4 */ OSMesg cmdProcMsgs[4]; - /* 0x79F4 */ AudioCmd cmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread - /* 0x81F4 */ char unk_81F4[4]; + /* 0x79E4 */ OSMesg threadCmdProcMsgBuf[4]; + /* 0x79F4 */ AudioCmd threadCmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread + /* 0x81F4 */ UNK_TYPE1 unk_81F4[4]; } AudioContext; // size = 0x81F8 typedef struct { - /* 0x00 */ u8 reverbVol; - /* 0x01 */ u8 unk_1; + /* 0x00 */ u8 targetReverbVol; + /* 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; + /* 0x03 */ u8 surroundEffectIndex; + /* 0x04 */ StereoData stereoData; /* 0x08 */ f32 frequency; /* 0x0C */ f32 velocity; /* 0x10 */ char unk_0C[0x4]; /* 0x14 */ s16* filter; - /* 0x18 */ u8 unk_14; - /* 0x1A */ u16 unk_16; + /* 0x18 */ u8 combFilterSize; + /* 0x1A */ u16 combFilterGain; } NoteSubAttributes; // size = 0x1A typedef struct { /* 0x0 */ size_t heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap` (ideally about the same size) - /* 0x4 */ size_t mainPoolSplitSize; // The entire audio heap is split into two pools. + /* 0x4 */ size_t initPoolSize; // The entire audio heap is split into two pools. /* 0x8 */ size_t permanentPoolSize; -} AudioContextInitSizes; // size = 0xC +} AudioHeapInitSizes; // size = 0xC typedef struct { /* 0x00 */ f32 unk_00; @@ -1039,7 +1116,7 @@ typedef struct { /* 0x204 */ u16 unk_28; /* 0x206 */ u16 unk_250; /* 0x208 */ u16 unk_252; - /* 0x20A */ u16 unk_254; + /* 0x20A */ u16 seqId; /* 0x20C */ u16 unk_256; /* 0x20E */ u16 unk_258; /* 0x210 */ u8 unk_260; @@ -1050,8 +1127,8 @@ typedef struct { /* 0x218 */ u8 unk_4C; /* 0x219 */ u8 unk_4D; /* 0x21A */ u8 unk_4E; - /* 0x21B */ u8 unk_21B; // New to MM -} unk_D_8016E750; // size = 0x21C + /* 0x21B */ u8 unk_21B; +} ActiveSequence; // size = 0x21C typedef struct { /* 0x0 */ u8 unk_0; @@ -1066,58 +1143,54 @@ typedef enum { /* 4 */ BANK_SYSTEM, /* 5 */ BANK_OCARINA, /* 6 */ BANK_VOICE -} SoundBankTypes; +} SfxBankType; typedef enum { /* 0 */ SFX_STATE_EMPTY, /* 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 +1198,79 @@ 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 +typedef void (*AudioCustomUpdateFunction)(void); +typedef u32 (*AudioCustomSeqFunction)(s8 value, SequenceChannel* channel); +typedef s32 (*AudioCustomReverbFunction)(Sample*, s32, s8, s32); +typedef Acmd* (*AudioCustomSynthFunction)(Acmd*, s32, s32); #endif diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 0a5afb3d9..ad5d4c4fb 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; @@ -56,11 +56,6 @@ struct DynaPolyActor; // CollisionContext flags #define BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW 1 -typedef enum { - /* 0 */ CONVEYOR_WATER, - /* 1 */ CONVEYOR_FLOOR -} ConveyorType; - typedef struct { /* 0x0 */ Vec3s pos; } BgVertex; // size = 0x6 @@ -72,27 +67,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; @@ -102,7 +108,7 @@ typedef struct { // 0x0008_0000 = ? // 0x0007_E000 = room index, 0x3F = all rooms // 0x0000_1F00 = lighting setting index - // 0x0000_00FF = CamData index + // 0x0000_00FF = bgCam index } WaterBox; // size = 0x10 typedef struct { @@ -116,7 +122,7 @@ typedef struct { // 0x001C_0000 = ? // 0x0003_E000 = ? // 0x0000_1F00 = scene exit index - // 0x0000_00FF = CamData index + // 0x0000_00FF = bgCam index // Word 1 // 0x0800_0000 = wall damage // 0x07E0_0000 = conveyor direction @@ -137,7 +143,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 +153,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 +230,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 +309,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..9c101bf73 --- /dev/null +++ b/include/z64camera.h @@ -0,0 +1,1611 @@ +#ifndef Z64CAMERA_H +#define Z64CAMERA_H + +#include "ultra64.h" +#include "z64save.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" + +#define CAM_HUD_VISIBILITY_SHIFT 8 +#define CAM_HUD_VISIBILITY_MASK (0x0F00) +#define CAM_HUD_VISIBILITY(hudVisibility) (((hudVisibility) & 0xF) << CAM_HUD_VISIBILITY_SHIFT) + +#define CAM_HUD_VISIBILITY_ALL \ + CAM_HUD_VISIBILITY(0) // HUD_VISIBILITY_ALL +#define CAM_HUD_VISIBILITY_NONE \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_NONE) +#define CAM_HUD_VISIBILITY_NONE_ALT \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_NONE_ALT) +#define CAM_HUD_VISIBILITY_HEARTS_WITH_OVERWRITE \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_HEARTS_WITH_OVERWRITE) +#define CAM_HUD_VISIBILITY_A \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_A) +#define CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE) +#define CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE) +#define CAM_HUD_VISIBILITY_ALL_NO_MINIMAP_W_DISABLED \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_ALL_NO_MINIMAP_W_DISABLED) +#define CAM_HUD_VISIBILITY_B \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_B) +#define CAM_HUD_VISIBILITY_HEARTS_MAGIC \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_HEARTS_MAGIC) +#define CAM_HUD_VISIBILITY_B_ALT \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_B_ALT) +#define CAM_HUD_VISIBILITY_HEARTS \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_HEARTS) +#define CAM_HUD_VISIBILITY_A_B_MINIMAP \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_A_B_MINIMAP) +#define CAM_HUD_VISIBILITY_HEARTS_MAGIC_WITH_OVERWRITE \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_HEARTS_MAGIC_WITH_OVERWRITE) +#define CAM_HUD_VISIBILITY_HEARTS_MAGIC_C \ + CAM_HUD_VISIBILITY(HUD_VISIBILITY_HEARTS_MAGIC_C) +// HUD_VISIBILITY_ALL_NO_MINIMAP and above can not be set using `CAM_HUD_VISIBILITY` +#define CAM_HUD_VISIBILITY_IGNORE \ + CAM_HUD_VISIBILITY(0xF) + +/** + * letterboxFlag: determines the size of the letter-box window. See CAM_LETTERBOX_* enums. + * Can also add on the flag ( | CAM_LETTERBOX_INSTANT) to make the size change immediately + * hudVisibility: hides certain hud icons + * - A value of 0 in camera is translated to a hudVisibility of 50, + * which is the value to restore all hud icons to the screen (CAM_HUD_VISIBILITY_ALL) + * - A value of 0xF in camera results in no change in the hudVisibility (CAM_HUD_VISIBILITY_IGNORE) + * funcFlags: Custom flags for functions + */ +#define CAM_INTERFACE_FLAGS(letterboxFlag, hudVisibility, funcFlags) \ + (((letterboxFlag) & CAM_LETTERBOX_MASK) | (hudVisibility) | ((funcFlags) & 0xFF)) + +// Shrinking the window from the top and bottom with black borders (letterboxing) +#define CAM_LETTERBOX_MASK 0xF000 + +#define CAM_LETTERBOX_SIZE_MASK 0x7000 +#define CAM_LETTERBOX_NONE 0x0000 +// small/medium/large black borders +#define CAM_LETTERBOX_SMALL 0x1000 +#define CAM_LETTERBOX_MEDIUM 0x2000 +#define CAM_LETTERBOX_LARGE 0x3000 +#define CAM_LETTERBOX_NONE_4 0x4000 + +#define CAM_LETTERBOX_INSTANT 0x8000 // Bit to determine whether to set the current value directly (on), or to set the size target (off) + +#define CAM_LETTERBOX_IGNORE 0xF000 // No change in letterbox size, keep the previous size + + +// 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_FOV, + /* 0x08 */ CAM_DATA_08, + /* 0x09 */ CAM_DATA_INTERFACE_FLAGS, + /* 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; + +/*================================ + * MISC DATA + *================================ + */ + +// Camera Collision Check +typedef struct { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f norm; + /* 0x18 */ CollisionPoly* poly; + /* 0x1C */ VecSph sphNorm; + /* 0x24 */ s32 bgId; +} CameraCollision; // size = 0x28 + +typedef struct { + /* 0x00 */ Vec3f collisionClosePoint; + /* 0x0C */ CameraCollision atEyeColChk; + /* 0x34 */ CameraCollision eyeAtColChk; + /* 0x5C */ f32 swingUpdateRate; + /* 0x60 */ s16 pitch; + /* 0x62 */ s16 yaw; + /* 0x64 */ s16 unk_64; + /* 0x66 */ s16 timer; // startSwingTimer +} SwingAnimation; // size = 0x68 + + +/*================================ + * Camera Update-Function Data + *================================ + */ + +#define CAM_FUNCDATA_INTERFACE_FLAGS(interfaceFlags) \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + + +/*================================ + * Camera_Normal1() Data + *================================ + */ + +#define CAM_FUNCDATA_NORM1(yOffset, data01, data02, pitchTarget, eyeStepScale, posStepScale, yawDiffRange, fov, data08, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { pitchTarget, CAM_DATA_03 }, \ + { eyeStepScale, CAM_DATA_04 }, \ + { posStepScale, CAM_DATA_05 }, \ + { yawDiffRange, CAM_DATA_06 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 unk_00; // yOffset + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; // attenuationYawDiffRange + /* 0x18 */ f32 unk_18; // fovTarget + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s16 unk_20; // pitchTarget + /* 0x22 */ s16 interfaceFlags; +} Normal1ReadOnlyData; // size = 0x24 + +typedef struct { + /* 0x00 */ f32 unk_00; // yPos + /* 0x04 */ f32 unk_04; // xzSpeed + /* 0x08 */ s16 unk_08; + /* 0x0A */ s16 unk_0A; // angle + /* 0x0C */ s16 unk_0C; // flags (May be s32) + /* 0x0E */ s16 unk_0E; + /* 0x10 */ f32 unk_10; // set to float +} Normal1ReadWriteData; // size = 0x14 + +typedef struct { + /* 0x00 */ Normal1ReadOnlyData roData; + /* 0x24 */ Normal1ReadWriteData rwData; +} Normal1; // size = 0x38 + +#define NORMAL1_FLAG_0 (1 << 0) +#define NORMAL1_FLAG_1 (1 << 1) +#define NORMAL1_FLAG_2 (1 << 2) +#define NORMAL1_FLAG_3 (1 << 3) +#define NORMAL1_FLAG_4 (1 << 4) +#define NORMAL1_FLAG_5 (1 << 5) +#define NORMAL1_FLAG_6 (1 << 6) +#define NORMAL1_FLAG_7 (1 << 7) + + +/*================================ + * Camera_Normal2() Data + *================================ + */ + +// Unused Camera RemoteBomb Setting + +#define CAM_FUNCDATA_NORM2(yOffset, data01, data02, pitchTarget, data04, fov, data08, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { pitchTarget, CAM_DATA_03 }, \ + { data04, CAM_DATA_04 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +#define NORMAL2_FLAG_1 (1 << 1) + + +/*================================ + * Camera_Normal3() Data + *================================ + */ + +#define CAM_FUNCDATA_NORM3(yOffset, data01, data02, pitchTarget, eyeStepScale, posStepScale, fov, data08, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { pitchTarget, CAM_DATA_03 }, \ + { eyeStepScale, CAM_DATA_04 }, \ + { posStepScale, CAM_DATA_05 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 yOffset; + /* 0x04 */ f32 distMin; + /* 0x08 */ f32 distMax; + /* 0x0C */ f32 yawUpdateRateInv; + /* 0x10 */ f32 pitchUpdateRateInv; + /* 0x14 */ f32 fovTarget; + /* 0x18 */ f32 maxAtLERPScale; + /* 0x1C */ s16 pitchTarget; + /* 0x1E */ s16 interfaceFlags; +} Normal3ReadOnlyData; // size = 0x20 + +typedef struct { + /* 0x00 */ f32 isZero; // set but unused + /* 0x04 */ f32 yPosOffset; + /* 0x08 */ s16 curPitch; + /* 0x0A */ s16 yawUpdateRate; + /* 0x0C */ s16 yawTimer; + /* 0x0E */ s16 distTimer; + /* 0x10 */ s16 flag; + /* 0x12 */ s16 is1200; // set but unused +} Normal3ReadWriteData; // size = 0x14 + +typedef struct { + /* 0x00 */ Normal3ReadOnlyData roData; + /* 0x20 */ Normal3ReadWriteData rwData; +} Normal3; // size = 0x34 + +#define NORMAL3_FLAG_1 (1 << 1) +#define NORMAL3_FLAG_5 (1 << 5) +#define NORMAL3_FLAG_6 (1 << 6) +#define NORMAL3_FLAG_7 (1 << 7) + + +/*================================ + * Camera_Normal0() Data + *================================ + */ + +#define CAM_FUNCDATA_NORM0(yOffset, data01, data02, data21, data04, yawDiffRange, fov, data08, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { data21, CAM_DATA_21 }, \ + { data04, CAM_DATA_04 }, \ + { yawDiffRange, CAM_DATA_06 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ s16 unk_1C; + /* 0x1E */ s16 interfaceFlags; +} Normal0ReadOnlyData; // size = 0x20 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; + /* 0x24 */ f32 unk_24; + /* 0x28 */ f32 unk_28; + /* 0x2C */ s16 unk_2C; +} Normal0ReadWriteData; // size = 0x30 + +typedef struct { + /* 0x00 */ Normal0ReadOnlyData roData; + /* 0x20 */ Normal0ReadWriteData rwData; +} Normal0; // size = 0x50 + +#define NORMAL0_FLAG_0 (1 << 0) +#define NORMAL0_FLAG_2 (1 << 2) +#define NORMAL0_FLAG_4 (1 << 4) +#define NORMAL0_FLAG_7 (1 << 7) + + +/*================================ + * Camera_Parallel1() Data + *================================ + */ + +#define CAM_FUNCDATA_PARA1(yOffset, data01, data02, pitchTarget, data10, data04, data05, fov, data08, interfaceFlags, data11, data12) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { pitchTarget, CAM_DATA_03 }, \ + { data10, CAM_DATA_10 }, \ + { data04, CAM_DATA_04 }, \ + { data05, CAM_DATA_05 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS }, \ + { data11, CAM_DATA_11 }, \ + { data12, CAM_DATA_12 } + +// Same as above but with extra unused entry +#define CAM_FUNCDATA_PARA1_ALT(yOffset, data01, data02, pitchTarget, data10, data04, data05, fov, data08, interfaceFlags, data11, data12, data18) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { pitchTarget, CAM_DATA_03 }, \ + { data10, CAM_DATA_10 }, \ + { data04, CAM_DATA_04 }, \ + { data05, CAM_DATA_05 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS }, \ + { data11, CAM_DATA_11 }, \ + { data12, CAM_DATA_12 }, \ + { data18, CAM_DATA_18 } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 unk_22; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 interfaceFlags; +} Parallel1ReadOnlyData; // size = 0x28 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 timer1; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ s16 unk_1C; + /* 0x1E */ s16 unk_1E; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 timer2; + /* 0x24 */ s16 timer3; + /* 0x26 */ s16 unk_26; +} Parallel1ReadWriteData; // size = 0x28 + +typedef struct { + /* 0x00 */ Parallel1ReadOnlyData roData; + /* 0x28 */ Parallel1ReadWriteData rwData; +} Parallel1; // size = 0x50 + +#define PARALLEL1_FLAG_0 (1 << 0) +#define PARALLEL1_FLAG_1 (1 << 1) +#define PARALLEL1_FLAG_2 (1 << 2) +#define PARALLEL1_FLAG_3 (1 << 3) +#define PARALLEL1_FLAG_4 (1 << 4) +#define PARALLEL1_FLAG_5 (1 << 5) +#define PARALLEL1_FLAG_6 (1 << 6) +#define PARALLEL1_FLAG_7 (1 << 7) + + +/*================================ + * Camera_Parallel2() Data + *================================ + */ + +// Unused Camera Maze Setting + +#define CAM_FUNCDATA_PARA2(yOffset, data02, data01, pitchTarget, data04, fov, data08, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data02, CAM_DATA_02 }, \ + { data01, CAM_DATA_01 }, \ + { pitchTarget, CAM_DATA_03 }, \ + { data04, CAM_DATA_04 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +#define PARALLEL2_FLAG_1 (1 << 1) + + +/*================================ + * Camera_Jump2() Data + *================================ + */ + +#define CAM_FUNCDATA_JUMP2(yOffset, data01, data02, data20, data04, data05, fov, data08, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { data20, CAM_DATA_20 }, \ + { data04, CAM_DATA_04 }, \ + { data05, CAM_DATA_05 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s16 interfaceFlags; +} Jump2ReadOnlyData; // size = 0x24 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 unk_08; + /* 0x0A */ s16 unk_0A; + /* 0x0C */ s16 timer; + /* 0x0E */ s16 unk_0E; + /* 0x10 */ s32 unk_10; // unused? + /* 0x1C */ s16 unk_1C; +} Jump2ReadWriteData; // size = 0x20 + +typedef struct { + /* 0x00 */ Jump2ReadOnlyData roData; + /* 0x24 */ Jump2ReadWriteData rwData; +} Jump2; // size = 0x44 + +#define JUMP2_FLAG_1 (1 << 1) +#define JUMP2_FLAG_2 (1 << 2) + + +/*================================ + * Camera_Jump3() Data + *================================ + */ + +#define CAM_FUNCDATA_JUMP3(yOffset, data01, data02, pitchTarget, data04, data05, yawDiffRange, fov, data08, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { pitchTarget, CAM_DATA_03 }, \ + { data04, CAM_DATA_04 }, \ + { data05, CAM_DATA_05 }, \ + { yawDiffRange, CAM_DATA_06 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 unk_00; // yOffset + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; // attenuationYawDiffRange + /* 0x18 */ f32 unk_18; // fovTarget + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 interfaceFlags; +} Jump3ReadOnlyData; // size = 0x24 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ s16 timer1; + /* 0x0A */ s16 unk_0A; + /* 0x0C */ s32 timer2; + /* 0x10 */ s16 unk_10; + /* 0x12 */ s16 unk_12; + /* 0x1C */ s16 unk_1C; +} Jump3ReadWriteData; // size = 0x20 + +typedef struct { + /* 0x00 */ Jump3ReadOnlyData roData; // yOffset + /* 0x24 */ Jump3ReadWriteData rwData; +} Jump3; // size = 0x44 + +#define JUMP3_FLAG_0 (1 << 0) +#define JUMP3_FLAG_2 (1 << 2) +#define JUMP3_FLAG_3 (1 << 3) +#define JUMP3_FLAG_4 (1 << 4) +#define JUMP3_FLAG_5 (1 << 5) +#define JUMP3_FLAG_6 (1 << 6) +#define JUMP3_FLAG_7 (1 << 7) + + +/*================================ + * Camera_Battle1() Data + *================================ + */ + +#define CAM_FUNCDATA_BATT1(yOffset, data01, data02, data13, data14, data15, data16, data17, fov, data08, interfaceFlags, data11, data18) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { data13, CAM_DATA_13 }, \ + { data14, CAM_DATA_14 }, \ + { data15, CAM_DATA_15 }, \ + { data16, CAM_DATA_16 }, \ + { data17, CAM_DATA_17 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS }, \ + { data11, CAM_DATA_11 }, \ + { data18, CAM_DATA_18 } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ f32 unk_28; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ s16 interfaceFlags; +} Battle1ReadOnlyData; // size = 0x34 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ Actor* unk_08; // targe3t + /* 0x0C */ s32 unk_0C; // unused? + /* 0x10 */ s16 unk_10; + /* 0x12 */ s16 unk_12; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; +} Battle1ReadWriteData; // size = 0x1C + +typedef struct { + /* 0x00 */ Battle1ReadOnlyData roData; + /* 0x24 */ Battle1ReadWriteData rwData; +} Battle1; // size = 0x50 + +#define BATTLE1_FLAG_0 (1 << 0) +#define BATTLE1_FLAG_1 (1 << 1) +#define BATTLE1_FLAG_4 (1 << 4) +#define BATTLE1_FLAG_7 (1 << 7) + + +/*================================ + * Camera_KeepOn1() Data + *================================ + */ + +#define CAM_FUNCDATA_KEEP1(yOffset, data01, data02, data13, data14, data15, data16, data17, fov, data08, interfaceFlags, data11) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { data13, CAM_DATA_13 }, \ + { data14, CAM_DATA_14 }, \ + { data15, CAM_DATA_15 }, \ + { data16, CAM_DATA_16 }, \ + { data17, CAM_DATA_17 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS }, \ + { data11, CAM_DATA_11 } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ f32 unk_28; + /* 0x2C */ s16 interfaceFlags; +} KeepOn1ReadOnlyData; // size = 0x30 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ Actor* unk_0C; + /* 0x10 */ s16 unk_10; + /* 0x12 */ s16 unk_12; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s16 unk_18; +} KeepOn1ReadWriteData; // size = 0x1C + +typedef struct { + /* 0x00 */ KeepOn1ReadOnlyData roData; + /* 0x30 */ KeepOn1ReadWriteData rwData; +} KeepOn1; // size = 0x4C + +#define KEEPON1_FLAG_0 (1 << 0) +#define KEEPON1_FLAG_1 (1 << 1) +#define KEEPON1_FLAG_4 (1 << 4) +#define KEEPON1_FLAG_7 (1 << 7) + + +/*================================ + * Camera_KeepOn3() Data + *================================ + */ + +#define CAM_FUNCDATA_KEEP3(yOffset, data01, data02, data13, data14, data15, data16, data17, fov, data08, timer, interfaceFlags, data18) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { data13, CAM_DATA_13 }, \ + { data14, CAM_DATA_14 }, \ + { data15, CAM_DATA_15 }, \ + { data16, CAM_DATA_16 }, \ + { data17, CAM_DATA_17 }, \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { timer, CAM_DATA_04 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS }, \ + { data18, CAM_DATA_18 } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ f32 unk_28; + /* 0x2C */ s16 timer; // initial timer, stored at twice the value used in code + /* 0x2E */ s16 interfaceFlags; +} KeepOn3ReadOnlyData; // size = 0x30 + +typedef struct { + /* 0x00 */ f32 unk_00; // Vec3f? + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ Actor* unk_0C; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ s16 timer; +} KeepOn3ReadWriteData; // size = 0x20 + +typedef struct { + /* 0x00 */ KeepOn3ReadOnlyData roData; + /* 0x30 */ KeepOn3ReadWriteData rwData; +} KeepOn3; // size = 0x50 + +#define KEEPON3_FLAG_5 (1 << 5) +#define KEEPON3_FLAG_6 (1 << 6) +#define KEEPON3_FLAG_7 (1 << 7) + + +/*================================ + * Camera_KeepOn4() Data + *================================ + */ + +#define CAM_FUNCDATA_KEEP4(yOffset, data01, pitchTarget, data10, data18, fov, interfaceFlags, data04, timer) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { pitchTarget, CAM_DATA_03 }, \ + { data10, CAM_DATA_10 }, \ + { data18, CAM_DATA_18 }, \ + { fov, CAM_DATA_FOV }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS }, \ + { data04, CAM_DATA_04 }, \ + { timer, CAM_DATA_12 } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ s16 interfaceFlags; + /* 0x1E */ s16 timer; +} KeepOn4ReadOnlyData; // size = 0x20 + +typedef struct { + /* 0x00 */ f32 unk_00; // Vec3f? + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ Actor* unk_0C; + /* 0x10 */ s16 unk_10; + /* 0x12 */ s16 unk_12; + /* 0x14 */ s16 timer; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s16 unk_18; +} KeepOn4ReadWriteData; // size = 0x1C + +typedef struct { + /* 0x00 */ KeepOn4ReadOnlyData roData; + /* 0x20 */ KeepOn4ReadWriteData rwData; +} KeepOn4; // size = 0x3C + +#define KEEPON4_FLAG_1 (1 << 1) +#define KEEPON4_FLAG_2 (1 << 2) +#define KEEPON4_FLAG_3 (1 << 3) +#define KEEPON4_FLAG_6 (1 << 6) + + +/*================================ + * Camera_Fixed1() Data + *================================ + */ + +#define CAM_FUNCDATA_FIXD1(yOffset, data04, fov, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data04, CAM_DATA_04 }, \ + { fov, CAM_DATA_FOV }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 fov; + /* 0x0C */ s16 interfaceFlags; +} Fixed1ReadOnlyData; // size = 0x10 + +typedef struct { + /* 0x00 */ PosRot eyePosRotTarget; + /* 0x14 */ s16 fov; + /* 0x18 */ Actor* focalActor; +} Fixed1ReadWriteData; // size = 0x1C + +typedef struct { + /* 0x00 */ Fixed1ReadOnlyData roData; + /* 0x10 */ Fixed1ReadWriteData rwData; +} Fixed1; // size = 0x2C + +#define FIXED1_FLAG_4 (1 << 4) + + +/*================================ + * Camera_Fixed2() Data + *================================ + */ + +#define CAM_FUNCDATA_FIXD2(yOffset, data01, data02, data04, data05, fov, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { data04, CAM_DATA_04 }, \ + { data05, CAM_DATA_05 }, \ + { fov, CAM_DATA_FOV }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ s16 interfaceFlags; +} Fixed2ReadOnlyData; // size = 0x1C + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ s16 unk_1C; +} Fixed2ReadWriteData; // size = 0x20 + +typedef struct { + /* 0x00 */ Fixed2ReadOnlyData roData; + /* 0x1C */ Fixed2ReadWriteData rwData; +} Fixed2; // size = 0x3C + +#define FIXED2_FLAG_0 (1 << 0) +#define FIXED2_FLAG_1 (1 << 1) +#define FIXED2_FLAG_2 (1 << 2) +#define FIXED2_FLAG_3 (1 << 3) +#define FIXED2_FLAG_4 (1 << 4) +#define FIXED2_FLAG_5 (1 << 5) +#define FIXED2_FLAG_6 (1 << 6) +#define FIXED2_FLAG_7 (1 << 7) + + +/*================================ + * Camera_Fixed3() Data + *================================ + */ + +#define CAM_FUNCDATA_FIXD3(interfaceFlags) \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + + +/*================================ + * Camera_Subject1() Data + *================================ + */ + +#define CAM_FUNCDATA_SUBJ1(yOffset, data01, data02, data04, data19, data17, data18, fov, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { data02, CAM_DATA_02 }, \ + { data04, CAM_DATA_04 }, \ + { data19, CAM_DATA_19 }, \ + { data17, CAM_DATA_17 }, \ + { data18, CAM_DATA_18 }, \ + { fov, CAM_DATA_FOV }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s16 interfaceFlags; +} Subject1ReadOnlyData; // size = 0x24 + +typedef struct { + /* 0x0 */ f32 unk_00; + /* 0x4 */ s16 unk_04; // yaw + /* 0x6 */ s16 unk_06; // pitch + /* 0x8 */ s16 timer; +} Subject1ReadWriteData; // size = 0xC + +typedef struct { + /* 0x00 */ Subject1ReadOnlyData roData; + /* 0x24 */ Subject1ReadWriteData rwData; +} Subject1; // size = 0x30 + +#define SUBJECT1_FLAG_4 (1 << 4) + + +/*================================ + * Camera_Unique2() Data + *================================ + */ + +#define CAM_FUNCDATA_UNIQ2(yOffset, data01, fov, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data01, CAM_DATA_01 }, \ + { fov, CAM_DATA_FOV }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 interfaceFlags; +} Unique2ReadOnlyData; // size = 0x14 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ s16 unk_04; +} Unique2ReadWriteData; // size = 0x8 + +typedef struct { + /* 0x00 */ Unique2ReadOnlyData roData; + /* 0x14 */ Unique2ReadWriteData rwData; +} Unique2; // size = 0x1C + +#define UNIQUE2_FLAG_0 (1 << 0) +#define UNIQUE2_FLAG_1 (1 << 1) +#define UNIQUE2_FLAG_4 (1 << 4) +#define UNIQUE2_FLAG_5 (1 << 5) + + +/*================================ + * Camera_Unique0() Data + *================================ + */ + +#define CAM_FUNCDATA_UNIQ0(yOffset, data04, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { data04, CAM_DATA_04 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x0 */ f32 unk_00; + /* 0x4 */ f32 unk_04; + /* 0x8 */ s16 interfaceFlags; +} Unique0ReadOnlyData; // size = 0xC + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ f32 unk_18; + /* 0x1C */ Vec3f unk_1C; + /* 0x28 */ Vec3f unk_28; + /* 0x34 */ Vec3s unk_34; + /* 0x3A */ s16 unk_3A; + /* 0x3C */ s16 timer; + /* 0x3E */ s16 unk_3E; +} Unique0ReadWriteData; // size = 0x40 + +typedef struct { + /* 0x00 */ Unique0ReadOnlyData roData; + /* 0x0C */ Unique0ReadWriteData rwData; +} Unique0; // size = 0x4C + +#define UNIQUE0_FLAG_0 (1 << 0) +#define UNIQUE0_FLAG_1 (1 << 1) +#define UNIQUE0_FLAG_4 (1 << 4) + + +/*================================ + * Camera_Unique6() Data + *================================ + */ + +typedef struct { + /* 0x00 */ s16 interfaceFlags; +} Unique6ReadOnlyData; // size = 0x4 + +typedef struct { + /* 0x00 */ Unique6ReadOnlyData roData; +} Unique6; // size = 0x4 + +#define UNIQUE6_FLAG_0 (1 << 0) + + +/*================================ + * Camera_Unique7() Data + *================================ + */ + +#define CAM_FUNCDATA_UNIQ7(fov, interfaceFlags) \ + { fov, CAM_DATA_FOV }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + + +/*================================ + * Camera_Demo1() Data + *================================ + */ + +typedef struct { + /* 0x00 */ s16 interfaceFlags; +} Demo1ReadOnlyData; // size = 0x4 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ VecSph unk_0C; + /* 0x14 */ VecSph unk_14; + /* 0x1C */ s16 unk_1C; +} Demo1ReadWriteData; // size = 0x20 + +typedef struct { + /* 0x00 */ Demo1ReadOnlyData roData; + /* 0x04 */ Demo1ReadWriteData rwData; +} Demo1; // size = 0x24 + + +/*================================ + * Camera_Demo2() Data + *================================ + */ + +#define CAM_FUNCDATA_DEMO2(fov, data08, interfaceFlags) \ + { fov, CAM_DATA_FOV }, \ + { data08, CAM_DATA_08 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 fov; + /* 0x04 */ f32 unk_04; // unused + /* 0x08 */ s16 interfaceFlags; +} Demo2ReadOnlyData; // size = 0xC + +typedef struct { + /* 0x00 */ Vec3f initialAt; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 animFrame; + /* 0x12 */ s16 yawDir; +} Demo2ReadWriteData; // size = 0x14 + +typedef struct { + /* 0x08 */ Demo2ReadOnlyData roData; + /* 0x0C */ Demo2ReadWriteData rwData; +} Demo2; // size = 0x20 + + +/*================================ + * Camera_Demo3() Data + *================================ + */ + +typedef struct { + /* 0x00 */ s16 interfaceFlags; +} Demo3ReadOnlyData; // size = 0x4 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 timer; +} Demo3ReadWriteData; // size = 0x8 + +typedef struct { + /* 0x00 */ Demo3ReadOnlyData roData; + /* 0x04 */ Demo3ReadWriteData rwData; +} Demo3; // size = 0xC + + +/*================================ + * Camera_Demo4() Data + *================================ + */ + +typedef struct { + /* 0x00 */ s16 interfaceFlags; +} Demo4ReadOnlyData; // size = 0x4 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ VecSph unk_18; // sp18-1C-20--24-26-28 // CutsceneCameraPoint? + /* 0x20 */ s16 unk_20; + /* 0x22 */ s16 timer; +} Demo4ReadWriteData; // size = 0x24 + +typedef struct { + /* 0x00 */ Demo4ReadOnlyData roData; + /* 0x04 */ Demo4ReadWriteData rwData; +} Demo4; // size = 0x28 + + +/*================================ + * Camera_Demo5() Data + *================================ + */ + +typedef struct { + /* 0x00 */ s16 interfaceFlags; +} Demo5ReadOnlyData; // size = 0x4 + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ VecSph unk_1C; + /* 0x24 */ s16 unk_24; + /* 0x26 */ s16 timer; +} Demo5ReadWriteData; // size = 0x28 + +typedef struct { + /* 0x00 */ Demo5ReadOnlyData roData; + /* 0x04 */ Demo5ReadWriteData rwData; +} Demo5; // size = 0x2C + + +/*================================ + * Camera_Demo0() Data + *================================ + */ + +typedef struct { + /* 0x00 */ s16 interfaceFlags; +} Demo0ReadOnlyData; // size = 0x4 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ VecSph subAtToEye; + /* 0x0C */ VecSph atToEye; + /* 0x14 */ s16 unk_14; + /* 0x16 */ s16 unk_16; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 timer; +} Demo0ReadWriteData; // size = 0x1C + +typedef struct { + /* 0x00 */ Demo0ReadOnlyData roData; + /* 0x04 */ Demo0ReadWriteData rwData; +} Demo0; // size = 0x20 + + +/*================================ + * Camera_Special5() Data + *================================ + */ + +#define CAM_FUNCDATA_SPEC5(yOffset, eyeDist, minDistForRot, fov, atMaxLERPScale, timerInit, pitch, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { eyeDist, CAM_DATA_01 }, \ + { minDistForRot, CAM_DATA_02 }, \ + { fov, CAM_DATA_03 }, \ + { atMaxLERPScale, CAM_DATA_FOV }, \ + { timerInit, CAM_DATA_08 }, \ + { pitch, CAM_DATA_12 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 yOffset; + /* 0x04 */ f32 eyeDist; + /* 0x08 */ f32 minDistForRot; + /* 0x0C */ f32 fovTarget; + /* 0x10 */ f32 atMaxLERPScale; + /* 0x14 */ s16 timerInit; + /* 0x16 */ s16 pitch; + /* 0x18 */ s16 interfaceFlags; +} Special5ReadOnlyData; // size = 0x1C + +typedef struct { + /* 0x00 */ s16 animTimer; +} Special5ReadWriteData; // size = 0x4 + +typedef struct { + /* 0x00 */ Special5ReadOnlyData roData; + /* 0x1C */ Special5ReadWriteData rwData; +} Special5; // size = 0x20 + + +/*================================ + * DOOR Data + *================================ + */ + +// For functions that deal with doors, an extra struct is added to the paramData + +typedef struct { + /* 0x00 */ Actor* doorActor; + /* 0x04 */ s16 bgCamIndex; + /* 0x06 */ union { + Vec3s eye; // position of the camera while exiting a spiral staircase + struct { + s16 timer1; // timer while camera is fixed in front of the door + s16 timer2; // timer while camera is behind the door looking at player + s16 timer3; // timer while camera turns around to face forward + }; + }; +} DoorParams; // size = 0xC + +#define CAM_GET_DOOR_PARAMS(type) &((type*)camera->paramData)->doorParams + + +/*================================ + * Camera_Special8() Data + *================================ + */ + +#define CAM_FUNCDATA_SPEC8(yOffset, eyeStepScale, posStepScale, fov, spiralDoorCsLength, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { eyeStepScale, CAM_DATA_04 }, \ + { posStepScale, CAM_DATA_05 }, \ + { fov, CAM_DATA_FOV }, \ + { spiralDoorCsLength, CAM_DATA_12 }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 yOffset; + /* 0x04 */ f32 eyeStepScale; + /* 0x08 */ f32 posStepScale; + /* 0x0C */ f32 fov; + /* 0x10 */ s16 spiralDoorCsLength; + /* 0x12 */ s16 interfaceFlags; +} Special8ReadOnlyData; // size = 0x14 + +typedef struct { + /* 0x00 */ Vec3f eye; + /* 0x0C */ s16 spiralDoorCsFrame; // 1/5th of the length of the cutscene + /* 0x0E */ s16 fov; +} Special8ReadWriteData; // size = 0x10 + +typedef struct { + /* 0x00 */ Special8ReadOnlyData roData; + /* 0x14 */ Special8ReadWriteData rwData; +} Special8; // size = 0x24 + +#define SPECIAL8_FLAG_0 (1 << 0) +#define SPECIAL8_FLAG_3 (1 << 3) + + +/*================================ + * Camera_Special9() Data + *================================ + */ + +#define CAM_FUNCDATA_SPEC9(yOffset, fov, interfaceFlags) \ + { yOffset, CAM_DATA_00 }, \ + { fov, CAM_DATA_FOV }, \ + { interfaceFlags, CAM_DATA_INTERFACE_FLAGS } + +typedef struct { + /* 0x00 */ f32 yOffset; + /* 0x04 */ f32 fov; + /* 0x08 */ s16 interfaceFlags; +} Special9ReadOnlyData; // size = 0xC + +typedef struct { + /* 0x00 */ s16 unk_00; +} Special9ReadWriteData; // size = 0x4 + +typedef struct { + /* 0x00 */ Special9ReadOnlyData roData; + /* 0x0C */ Special9ReadWriteData rwData; +} Special9; // size = 0x10 + +#define SPECIAL9_FLAG_0 (1 << 0) +#define SPECIAL9_FLAG_1 (1 << 1) +#define SPECIAL9_FLAG_3 (1 << 3) + +typedef union { + Normal1 norm1; + Normal3 norm3; + Normal0 norm0; + Parallel1 para1; + Jump2 jump2; + Jump3 jump3; + Battle1 batt1; + KeepOn1 keep1; + KeepOn3 keep3; + KeepOn4 keep4; + Fixed1 fixd1; + Fixed2 fixd2; + Subject1 subj1; + Unique2 uniq2; + Unique0 uniq0; + Unique6 uniq6; + Demo1 demo1; + Demo2 demo2; + Demo3 demo3; + Demo4 demo4; + Demo5 demo5; + Demo0 demo0; + Special5 spec5; + struct { + /* 0x0 */ DoorParams doorParams; + /* 0xC */ union { + Special8 spec8; + Special9 spec9; + }; + }; +} CamParamData; // size = 0x50 + +/*================================ + * MAIN CAMERA STRUCT + *================================ + */ + +typedef struct Camera { + /* 0x000 */ CamParamData paramData; // update function data that's reset every time a new update 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..836fd3555 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 { @@ -283,16 +283,16 @@ typedef enum { } ColChkMassType; typedef enum { - /* 0 */ COLTYPE_HIT0, // Blue blood, white hitmark - /* 1 */ COLTYPE_HIT1, // No blood, dust hitmark - /* 2 */ COLTYPE_HIT2, // Green blood, dust hitmark - /* 3 */ COLTYPE_HIT3, // No blood, white hitmark - /* 4 */ COLTYPE_HIT4, // Water burst, no hitmark - /* 5 */ COLTYPE_HIT5, // No blood, red hitmark - /* 6 */ COLTYPE_HIT6, // Green blood, white hitmark - /* 7 */ COLTYPE_HIT7, // Red blood, white hitmark - /* 8 */ COLTYPE_HIT8, // Blue blood, red hitmark - /* 9 */ COLTYPE_METAL, + /* 0 */ COLTYPE_HIT0, // Blue blood, white hitmark + /* 1 */ COLTYPE_HIT1, // No blood, dust hitmark + /* 2 */ COLTYPE_HIT2, // Green blood, dust hitmark + /* 3 */ COLTYPE_HIT3, // No blood, white hitmark + /* 4 */ COLTYPE_HIT4, // Water burst, no hitmark + /* 5 */ COLTYPE_HIT5, // No blood, red hitmark + /* 6 */ COLTYPE_HIT6, // Green blood, white hitmark + /* 7 */ COLTYPE_HIT7, // Red blood, white hitmark + /* 8 */ COLTYPE_HIT8, // Blue blood, red hitmark + /* 9 */ COLTYPE_METAL, /* 10 */ COLTYPE_NONE, /* 11 */ COLTYPE_WOOD, /* 12 */ COLTYPE_HARD, 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..92c0227f3 100644 --- a/include/z64dma.h +++ b/include/z64dma.h @@ -4,21 +4,21 @@ #include "ultra64.h" typedef struct { - /* 0x00 */ u32 vromAddr; // VROM address (source) - /* 0x04 */ void* dramAddr; // DRAM address (destination) - /* 0x08 */ u32 size; // File Transfer size - /* 0x0C */ char* filename; // Filename for debugging - /* 0x10 */ s32 line; // Line for debugging - /* 0x14 */ s32 unk14; + /* 0x00 */ uintptr_t vromAddr; // VROM address (source) + /* 0x04 */ void* dramAddr; // DRAM address (destination) + /* 0x08 */ u32 size; // File Transfer size + /* 0x0C */ char* filename; // Filename for debugging + /* 0x10 */ s32 line; // Line for debugging + /* 0x14 */ s32 unk14; /* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message - /* 0x1C */ OSMesg notifyMsg; // Completion notification message + /* 0x1C */ OSMesg notifyMsg; // Completion notification message } DmaRequest; // size = 0x20 typedef struct { - /* 0x00 */ u32 vromStart; - /* 0x04 */ u32 vromEnd; - /* 0x08 */ u32 romStart; - /* 0x0C */ u32 romEnd; + /* 0x0 */ uintptr_t vromStart; + /* 0x4 */ uintptr_t vromEnd; + /* 0x8 */ uintptr_t romStart; + /* 0xC */ uintptr_t romEnd; } DmaEntry; // size = 0x10 #endif diff --git a/include/z64effect.h b/include/z64effect.h index 0b848a478..727bf04d2 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,29 +227,29 @@ 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; - /* 0x04 */ u32 vromEnd; + /* 0x00 */ uintptr_t vromStart; + /* 0x04 */ uintptr_t vromEnd; /* 0x08 */ void* vramStart; /* 0x0C */ void* vramEnd; /* 0x10 */ void* loadedRamAddr; @@ -257,7 +257,6 @@ 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/z64interface.h b/include/z64interface.h new file mode 100644 index 000000000..385f80835 --- /dev/null +++ b/include/z64interface.h @@ -0,0 +1,216 @@ +#ifndef Z64INTERFACE_H +#define Z64INTERFACE_H + +#include "ultra64.h" +#include "z64view.h" + +typedef enum { + /* 0 */ A_BTN_STATE_0, + /* 1 */ A_BTN_STATE_1, + /* 2 */ A_BTN_STATE_2, + /* 3 */ A_BTN_STATE_3, + /* 4 */ A_BTN_STATE_4 +} AButtonState; + +typedef enum { + /* 0x00 */ DO_ACTION_ATTACK, + /* 0x01 */ DO_ACTION_CHECK, + /* 0x02 */ DO_ACTION_ENTER, + /* 0x03 */ DO_ACTION_RETURN, + /* 0x04 */ DO_ACTION_OPEN, + /* 0x05 */ DO_ACTION_JUMP, + /* 0x06 */ DO_ACTION_DECIDE, + /* 0x07 */ DO_ACTION_DIVE, + /* 0x08 */ DO_ACTION_FASTER, + /* 0x09 */ DO_ACTION_THROW, + /* 0x0A */ DO_ACTION_NONE, // in do_action_static, the texture at this position is NAVI, however this value is in practice the "No Action" value + /* 0x0B */ DO_ACTION_CLIMB, + /* 0x0C */ DO_ACTION_DROP, + /* 0x0D */ DO_ACTION_DOWN, + /* 0x0E */ DO_ACTION_QUIT, + /* 0x0F */ DO_ACTION_SPEAK, + /* 0x10 */ DO_ACTION_NEXT, + /* 0x11 */ DO_ACTION_GRAB, + /* 0x12 */ DO_ACTION_STOP, + /* 0x13 */ DO_ACTION_PUTAWAY, + /* 0x14 */ DO_ACTION_REEL, + /* 0x15 */ DO_ACTION_INFO, + /* 0x16 */ DO_ACTION_WARP, + /* 0x17 */ DO_ACTION_SNAP, + /* 0x18 */ DO_ACTION_EXPLODE, + /* 0x19 */ DO_ACTION_DANCE, + /* 0x1A */ DO_ACTION_MARCH, + /* 0x1B */ DO_ACTION_1, + /* 0x1C */ DO_ACTION_2, + /* 0x1D */ DO_ACTION_3, + /* 0x1E */ DO_ACTION_4, + /* 0x1F */ DO_ACTION_5, + /* 0x20 */ DO_ACTION_6, + /* 0x21 */ DO_ACTION_7, + /* 0x22 */ DO_ACTION_8, + /* 0x23 */ DO_ACTION_CURL, + /* 0x24 */ DO_ACTION_SURFACE, + /* 0x25 */ DO_ACTION_SWIM, + /* 0x26 */ DO_ACTION_PUNCH, + /* 0x27 */ DO_ACTION_POUND, + /* 0x28 */ DO_ACTION_HOOK, + /* 0x29 */ DO_ACTION_SHOOT, + /* 0x2A */ DO_ACTION_MAX +} DoAction; + +typedef enum { + /* 0 */ MINIGAME_STATE_NONE, + /* 1 */ MINIGAME_STATE_COUNTDOWN_SETUP_3, + /* 2 */ MINIGAME_STATE_COUNTDOWN_3, + /* 3 */ MINIGAME_STATE_COUNTDOWN_SETUP_2, + /* 4 */ MINIGAME_STATE_COUNTDOWN_2, + /* 5 */ MINIGAME_STATE_COUNTDOWN_SETUP_1, + /* 6 */ MINIGAME_STATE_COUNTDOWN_1, + /* 7 */ MINIGAME_STATE_COUNTDOWN_SETUP_GO, + /* 8 */ MINIGAME_STATE_COUNTDOWN_GO, + /* 20 */ MINIGAME_STATE_NO_COUNTDOWN_SETUP = 20, + /* 21 */ MINIGAME_STATE_NO_COUNTDOWN, + /* 30 */ MINIGAME_STATE_PLAYING = 30 +} MinigameState; + +typedef enum { + /* 0 */ PERFECT_LETTERS_TYPE_OFF, + /* 1 */ PERFECT_LETTERS_TYPE_1, + /* 2 */ PERFECT_LETTERS_TYPE_2, + /* 3 */ PERFECT_LETTERS_TYPE_3 +} PerfectLettersType; + +typedef enum { + /* 0 */ PERFECT_LETTERS_STATE_OFF, + /* 1 */ PERFECT_LETTERS_STATE_INIT, + /* 2 */ PERFECT_LETTERS_STATE_ENTER, + /* 3 */ PERFECT_LETTERS_STATE_STATIONARY, // Display for type 1 + /* 4 */ PERFECT_LETTERS_STATE_SPREAD, // Exit for type 1 + /* 5 */ PERFECT_LETTERS_STATE_DISPLAY, + /* 6 */ PERFECT_LETTERS_STATE_EXIT +} PerfectLettersState; + +#define PERFECT_LETTERS_NUM_LETTERS 8 +#define PERFECT_LETTERS_ANGLE_PER_LETTER (0x10000 / PERFECT_LETTERS_NUM_LETTERS) + +typedef enum { + /* 0 */ STORY_DMA_IDLE, + /* 1 */ STORY_DMA_LOADING, + /* 2 */ STORY_DMA_DONE +} StoryLoadStatus; + +typedef enum { + /* 0 */ STORY_STATE_OFF, + /* 1 */ STORY_STATE_INIT, + /* 2 */ STORY_STATE_IDLE, + /* 3 */ STORY_STATE_DESTROY, + /* 4 */ STORY_STATE_SETUP_IDLE, + /* 5 */ STORY_STATE_FADE_OUT, + /* 6 */ STORY_STATE_FADE_IN +} StoryState; + +typedef enum { + /* 0 */ STORY_TYPE_MASK_FESTIVAL, + /* 1 */ STORY_TYPE_GIANTS_LEAVING +} StoryType; + +typedef struct { + /* 0x000 */ View view; + /* 0x168 */ Vtx* actionVtx; + /* 0x16C */ Vtx* beatingHeartVtx; + /* 0x170 */ u8* parameterSegment; + /* 0x174 */ u8* doActionSegment; + /* 0x178 */ u8* iconItemSegment; + /* 0x17C */ u8* mapSegment; + /* 0x180 */ u8* unk_180; // unused segment? + /* 0x184 */ DmaRequest dmaRequest; + /* 0x1A4 */ UNK_TYPE1 unk_1A4[0x40]; // likely 2 DmaRequest + /* 0x1E4 */ OSMesgQueue loadQueue; + /* 0x1FC */ OSMesg loadMsg; + /* 0x200 */ Viewport viewport; + /* 0x210 */ s16 aButtonState; + /* 0x212 */ u16 unk_212; + /* 0x214 */ u16 aButtonDoAction; + /* 0x218 */ f32 aButtonRoll; + /* 0x21C */ s16 unk_21C; + /* 0x21E */ s16 bButtonDoAction; + /* 0x220 */ s16 unk_220; + /* 0x222 */ s16 unk_222; + /* 0x224 */ s16 unk_224; + /* 0x226 */ s16 lifeColorChange; + /* 0x228 */ s16 lifeColorChangeDirection; + /* 0x22A */ s16 beatingHeartPrim[3]; + /* 0x230 */ s16 beatingHeartEnv[3]; + /* 0x236 */ s16 heartsPrimR[2]; + /* 0x23A */ s16 heartsPrimG[2]; + /* 0x23E */ s16 heartsPrimB[2]; + /* 0x242 */ s16 heartsEnvR[2]; + /* 0x246 */ s16 heartsEnvG[2]; + /* 0x24A */ s16 heartsEnvB[2]; + /* 0x24E */ s16 health; + /* 0x250 */ s16 healthTimer; + /* 0x252 */ s16 lifeSizeChange; + /* 0x254 */ s16 lifeSizeChangeDirection; // 1 means shrinking, 0 growing + /* 0x256 */ s16 unk_256; + /* 0x258 */ s16 magicConsumptionTimer; // For certain magic states, 1 unit of magic is consumed every time the timer reaches 0 + /* 0x25A */ u8 numHorseBoosts; + /* 0x25C */ u16 minigamePoints; // Points to add to the minigame score. Reset to 0 every frame. + /* 0x25E */ u16 minigameHiddenPoints; // Points to add to the secondary set of minigame points not displayed. Reset to 0 every frame. + /* 0x260 */ u16 minigameAmmo; + /* 0x262 */ u16 minigameUnusedPoints; // Associated with other minigame points, unused + /* 0x264 */ s16 screenFillAlpha; + /* 0x266 */ s16 aAlpha; + /* 0x268 */ s16 bAlpha; + /* 0x26A */ s16 cLeftAlpha; + /* 0x26C */ s16 cDownAlpha; + /* 0x26E */ s16 cRightAlpha; + /* 0x270 */ s16 healthAlpha; + /* 0x272 */ s16 magicAlpha; + /* 0x274 */ s16 minimapAlpha; + /* 0x276 */ s16 startAlpha; + /* 0x278 */ s16 unk_278; + /* 0x27A */ s16 dungeonOrBossAreaMapIndex; + /* 0x27C */ s16 mapRoomNum; + /* 0x27E */ u8 unk_27E; + /* 0x27F */ u8 unk_27F; + /* 0x280 */ u8 minigameState; + /* 0x282 */ s16 minigameCountdownAlpha; + /* 0x284 */ s16 minigameCountdownScale; + /* 0x286 */ s16 perfectLettersOn; + /* 0x288 */ s16 perfectLettersType; + /* 0x28A */ s16 perfectLettersState[PERFECT_LETTERS_NUM_LETTERS]; + /* 0x29A */ u16 perfectLettersAngles[PERFECT_LETTERS_NUM_LETTERS]; // Angle that follows the projectory of an ellipse + /* 0x2AA */ s16 perfectLettersOffsetX[PERFECT_LETTERS_NUM_LETTERS]; + /* 0x2BC */ f32 perfectLettersSemiAxisX[PERFECT_LETTERS_NUM_LETTERS]; + /* 0x2DC */ f32 perfectLettersSemiAxisY[PERFECT_LETTERS_NUM_LETTERS]; + /* 0x2FC */ s16 perfectLettersPrimColor[4]; + /* 0x304 */ s16 perfectLettersCount; + /* 0x306 */ s16 perfectLettersUnused; + /* 0x308 */ s16 perfectLettersColorIndex; + /* 0x30A */ s16 perfectLettersColorTimer; + /* 0x30C */ s16 perfectLettersTimer; + struct { + /* 0x30E */ u8 hGauge; + /* 0x30F */ u8 bButton; + /* 0x310 */ u8 aButton; + /* 0x311 */ u8 tradeItems; // Includes deed trade quest, anju/kafei trade quest, bottles, and ocarina + /* 0x312 */ u8 songOfTime; + /* 0x313 */ u8 songOfDoubleTime; + /* 0x314 */ u8 invSongOfTime; + /* 0x315 */ u8 songOfSoaring; + /* 0x316 */ u8 songOfStorms; + /* 0x317 */ u8 masks; + /* 0x318 */ u8 pictoBox; + /* 0x319 */ u8 all; // "another"; enables all item restrictions + } restrictions; // size = 0xC + /* 0x31A */ u8 storyState; + /* 0x31B */ u8 storyType; + /* 0x31C */ u8 storyDmaStatus; + /* 0x320 */ OSMesgQueue storyMsgQueue; + /* 0x338 */ OSMesg storyMsgBuf; + /* 0x33C */ u8* storySegment; + /* 0x340 */ uintptr_t storyAddr; + /* 0x344 */ size_t storySize; +} InterfaceContext; // size = 0x348 + +#endif diff --git a/include/z64item.h b/include/z64item.h index 785d56577..d1d36ebba 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -1,5 +1,5 @@ -#ifndef _Z64ITEM_H_ -#define _Z64ITEM_H_ +#ifndef Z64ITEM_H +#define Z64ITEM_H #define DROP_TABLE_SIZE 16 #define DROP_TABLE_NUMBER 17 @@ -7,23 +7,49 @@ // TODO fill out these enums typedef enum { - /* 0x0 */ EQUIP_SWORD, - /* 0x1 */ EQUIP_SHIELD + /* 0 */ EQUIP_TYPE_SWORD, + /* 1 */ EQUIP_TYPE_SHIELD, + /* 2 */ EQUIP_TYPE_TUNIC, // Remnant of OoT + /* 3 */ 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 */ EQUIP_VALUE_TUNIC_NONE, + /* 1 */ EQUIP_VALUE_TUNIC_KOKIRI, + /* 2 */ EQUIP_VALUE_TUNIC_GORON, + /* 3 */ EQUIP_VALUE_TUNIC_ZORA, + /* 4 */ EQUIP_VALUE_TUNIC_MAX +} EquipValueTunic; // Remnant of OoT + +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 { - /* 0x00 */ QUEST_REMAINS_ODOWLA, + /* 0x00 */ QUEST_REMAINS_ODOLWA, /* 0x01 */ QUEST_REMAINS_GOHT, /* 0x02 */ QUEST_REMAINS_GYORG, /* 0x03 */ QUEST_REMAINS_TWINMOLD, @@ -41,11 +67,30 @@ typedef enum { /* 0x0F */ QUEST_SONG_SOARING, /* 0x10 */ QUEST_SONG_STORMS, /* 0x11 */ QUEST_SONG_SUN, - /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, - /* 0x18 */ QUEST_SONG_LULLABY_INTRO = 0x18, - /* 0x19 */ QUEST_UNK_19 // Related to PictoBox + /* 0x12 */ QUEST_BOMBERS_NOTEBOOK, // Obtained Bombers Notebook + /* 0x13 */ QUEST_QUIVER, + /* 0x14 */ QUEST_BOMB_BAG, + /* 0x15 */ QUEST_SKULL_TOKEN, + /* 0x16 */ QUEST_HEART_PIECE, // for `pauseCtx->cursorPoint[PAUSE_QUEST]` + /* 0x17 */ QUEST_17, // Used in a conditional for quest cursors + /* 0x18 */ QUEST_SONG_LULLABY_INTRO, + /* 0x19 */ QUEST_PICTOGRAPH, // A photo from the pictograph box is saved + /* 0x1C */ QUEST_HEART_PIECE_COUNT = 0x1C } QuestItem; +typedef enum { + /* -1 */ DUNGEON_NONE = -1, + /* 0 */ DUNGEON_BOSS_KEY, + /* 1 */ DUNGEON_COMPASS, + /* 2 */ DUNGEON_MAP, + /* 3 */ DUNGEON_STRAY_FAIRIES, + /* 4 */ DUNGEON_FLOOR_INDEX_4, // Top Floor + /* 5 */ DUNGEON_FLOOR_INDEX_3, + /* 6 */ DUNGEON_FLOOR_INDEX_2, + /* 7 */ DUNGEON_FLOOR_INDEX_1, + /* 8 */ DUNGEON_FLOOR_INDEX_0 // Bottom Floor +} DungeonItem; + typedef enum { /* 0x00 */ SLOT_OCARINA, /* 0x01 */ SLOT_BOW, @@ -98,7 +143,7 @@ typedef enum { /* 0xFF */ SLOT_NONE = 0xFF } InventorySlot; -typedef enum { +typedef enum ItemId { /* 0x00 */ ITEM_OCARINA, /* 0x01 */ ITEM_BOW, /* 0x02 */ ITEM_ARROW_FIRE, @@ -135,7 +180,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 +192,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 +236,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, @@ -212,7 +257,9 @@ typedef enum { /* 0x6E */ ITEM_SKULL_TOKEN, /* 0x6F */ ITEM_HEART_CONTAINER, /* 0x70 */ ITEM_HEART_PIECE, - /* 0x73 */ ITEM_SONG_LULLABY_INTRO = 0x73, + /* 0x71 */ ITEM_71, + /* 0x72 */ ITEM_72, + /* 0x73 */ ITEM_SONG_LULLABY_INTRO, /* 0x74 */ ITEM_KEY_BOSS, /* 0x75 */ ITEM_COMPASS, /* 0x76 */ ITEM_DUNGEON_MAP, @@ -228,7 +275,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,12 +307,20 @@ 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, // PLAYER_MASK_BLAST + /* 0xF1 */ ITEM_F1, // PLAYER_MASK_BREMEN + /* 0xF2 */ ITEM_F2, // PLAYER_MASK_KAMARO + /* 0xFC */ ITEM_FC = 0xFC, + /* 0xFD */ ITEM_FD, + /* 0xFE */ ITEM_FE, /* 0xFF */ ITEM_NONE = 0xFF -} ItemID; +} ItemId; -typedef enum { +#define BOTTLE_FIRST 0 +#define BOTTLE_MAX 6 + +typedef enum GetItemId { /* 0x00 */ GI_NONE, /* 0x01 */ GI_RUPEE_GREEN, /* 0x02 */ GI_RUPEE_BLUE, @@ -279,8 +334,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 +354,70 @@ 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, + /* 0x40 */ GI_40, + /* 0x41 */ GI_HOOKSHOT, + /* 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, + /* 0x6C */ GI_6C, + /* 0x6D */ GI_6D, + /* 0x6E */ GI_SEAHORSE, + /* 0x6F */ GI_CHATEAU_BOTTLE, + /* 0x70 */ GI_HYLIAN_LOACH, + /* 0x75 */ GI_75 = 0x75, + /* 0x76 */ GI_ICE_TRAP, /* 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,78 +430,169 @@ 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_2, // 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 -} GetItemID; + /* 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, + /* 0xA2 */ GI_A2, + /* 0xA3 */ GI_A3, + /* 0xA4 */ GI_A4, + /* 0xA5 */ GI_A5, + /* 0xA6 */ GI_A6, + /* 0xA7 */ GI_A7, + /* 0xA8 */ GI_A8, + /* 0xA9 */ GI_BOTTLE_STOLEN, // 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 { +typedef enum GetItemDrawId { + /* -1 */ GID_NONE = -1, /* 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, - /* 0x39 */ GID_39 = 0x39, - /* 0x3A */ GID_3A, + /* 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 -} 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; + /* 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; #endif diff --git a/include/z64light.h b/include/z64light.h index 0c90be713..d9404ab4c 100644 --- a/include/z64light.h +++ b/include/z64light.h @@ -1,5 +1,5 @@ -#ifndef _Z64LIGHT_H_ -#define _Z64LIGHT_H_ +#ifndef Z64LIGHT_H +#define Z64LIGHT_H #include "ultra64.h" #include "PR/gbi.h" @@ -12,8 +12,8 @@ typedef struct { /* 0x09 */ s8 diffusePos2[3]; /* 0x0C */ u8 diffuseColor[3]; /* 0x0F */ u8 fogColor[3]; - /* 0x12 */ u16 fogNear; - /* 0x14 */ u16 fogFar; + /* 0x12 */ s16 fogNear; + /* 0x14 */ s16 fogFar; } LightSettings; // size = 0x16 typedef struct { @@ -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 33f05bb0a..323042b15 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -6,47 +6,47 @@ #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 /* @@ -64,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; @@ -89,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)) @@ -101,6 +101,9 @@ typedef struct { #define BINANG_LERPIMP(v0, v1, t) ((v0) + (s16)(BINANG_SUB((v1), (v0)) * (t))) #define BINANG_LERPIMPINV(v0, v1, t) ((v0) + BINANG_SUB((v1), (v0)) / (t)) +#define LERPWEIGHT(val, prev, next) (((val) - (prev)) / ((next) - (prev))) +#define F32_LERPWEIGHT(val, prev, next) (((f32)(val) - (f32)(prev)) / ((f32)(next) - (f32)(prev))) + #define VEC3F_LERPIMPDST(dst, v0, v1, t){ \ (dst)->x = (v0)->x + (((v1)->x - (v0)->x) * t); \ (dst)->y = (v0)->y + (((v1)->y - (v0)->y) * t); \ @@ -109,17 +112,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 * (0x8000 / 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 / 0x8000) * 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..7d4723e7b --- /dev/null +++ b/include/z64message.h @@ -0,0 +1,180 @@ +#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[0xA]; + /* 0x120BC */ u16 unk_120BC; + /* 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..e800e9138 100644 --- a/include/z64object.h +++ b/include/z64object.h @@ -1,5 +1,5 @@ -#ifndef _Z64OBJECT_H_ -#define _Z64OBJECT_H_ +#ifndef Z64OBJECT_H +#define Z64OBJECT_H #define OBJECT_SPACE_SIZE_DEFAULT 1413120 #define OBJECT_SPACE_SIZE_CLOCK_TOWN 1566720 @@ -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, @@ -404,7 +404,7 @@ typedef enum { /* 0x188 */ OBJECT_FALL, /* 0x189 */ OBJECT_HANAREYAMA_OBJ, /* 0x18A */ OBJECT_CRACE_OBJECT, - /* 0x18B */ OBJECT_DNQ, + /* 0x18B */ OBJECT_DNO, /* 0x18C */ OBJECT_OBJ_TOKEIDAI, /* 0x18D */ OBJECT_EG, /* 0x18E */ OBJECT_TRU, @@ -477,7 +477,7 @@ typedef enum { /* 0x1D1 */ OBJECT_MARUTA, /* 0x1D2 */ OBJECT_GHAKA, /* 0x1D3 */ OBJECT_OYU, - /* 0x1D4 */ OBJECT_DNP, + /* 0x1D4 */ OBJECT_DNQ, /* 0x1D5 */ OBJECT_DAI, /* 0x1D6 */ OBJECT_KGY, /* 0x1D7 */ OBJECT_FB, @@ -508,7 +508,7 @@ typedef enum { /* 0x1F0 */ OBJECT_GI_SEAHORSE, /* 0x1F1 */ OBJECT_BIGPO, /* 0x1F2 */ OBJECT_HARIKO, - /* 0x1F3 */ OBJECT_DNO, + /* 0x1F3 */ OBJECT_DNJ, /* 0x1F4 */ OBJECT_SINKAI_KABE, /* 0x1F5 */ OBJECT_KIN2_OBJ, /* 0x1F6 */ OBJECT_ISHI, diff --git a/include/z64ocarina.h b/include/z64ocarina.h index 56ab48312..3bb99cd62 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; @@ -81,7 +82,7 @@ typedef enum { /* 13 */ OCARINA_INSTRUMENT_PIANO, /* 14 */ OCARINA_INSTRUMENT_BASS_GUITAR, /* 15 */ OCARINA_INSTRUMENT_BABY_SINGING, - /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR // Related to (gSaveContext.weekEventReg[41] & 0x20) + /* 16 */ OCARINA_INSTRUMENT_AMPLIFIED_GUITAR // Related to WEEKEVENTREG_41_20 } OcarinaInstrumentId; typedef enum { @@ -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..e99b261ce 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -1,39 +1,48 @@ #ifndef Z64PLAYER_H #define Z64PLAYER_H -#include "z64actor.h" +#include "alignment.h" #include "os.h" +#include "z64actor.h" struct Player; -typedef enum { - /* 0x00 */ PLAYER_SHIELD_NONE, - /* 0x01 */ PLAYER_SHIELD_HEROS_SHIELD, - /* 0x02 */ PLAYER_SHIELD_MIRROR_SHIELD, - /* 0x03 */ PLAYER_SHIELD_MAX +typedef enum PlayerShield { + /* 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 +typedef enum PlayerBoots { + /* 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 +typedef enum PlayerStrength { + /* 0 */ PLAYER_STRENGTH_DEKU, + /* 1 */ PLAYER_STRENGTH_HUMAN, + /* 2 */ PLAYER_STRENGTH_ZORA, + /* 3 */ PLAYER_STRENGTH_GORON, + /* 4 */ PLAYER_STRENGTH_MAX +} PlayerStrength; + +typedef enum PlayerTransformation { + /* 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 { +typedef enum PlayerMask { /* 0x00 */ PLAYER_MASK_NONE, /* 0x01 */ PLAYER_MASK_TRUTH, /* 0x02 */ PLAYER_MASK_KAFEIS_MASK, @@ -63,87 +72,310 @@ typedef enum { } PlayerMask; typedef enum { - /* 0x00 */ PLAYER_AP_NONE, - /* 0x01 */ PLAYER_AP_UNK_1, - /* 0x02 */ PLAYER_AP_UNK_2, - /* 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, - /* 0x09 */ PLAYER_AP_BOW, - /* 0x0A */ PLAYER_AP_BOW_FIRE, - /* 0x0B */ PLAYER_AP_BOW_ICE, - /* 0x0C */ PLAYER_AP_BOW_LIGHT, - /* 0x0D */ PLAYER_AP_HOOKSHOT, - /* 0x0E */ PLAYER_AP_BOMB, - /* 0x0F */ PLAYER_AP_POWDER_KEG, - /* 0x10 */ PLAYER_AP_BOMBCHU, - /* 0x12 */ PLAYER_AP_NUT = 0x12, - /* 0x13 */ PLAYER_AP_PICTO_BOX, - /* 0x14 */ PLAYER_AP_OCARINA, - /* 0x15 */ PLAYER_AP_BOTTLE, - /* 0x16 */ PLAYER_AP_BOTTLE_FISH, - /* 0x17 */ PLAYER_AP_BOTTLE_SPRING_WATER, - /* 0x18 */ PLAYER_AP_BOTTLE_HOT_SPRING_WATER, - /* 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, - /* 0x1E */ PLAYER_AP_BOTTLE_MUSHROOM, - /* 0x1F */ PLAYER_AP_BOTTLE_HYLIAN_LOACH, - /* 0x20 */ PLAYER_AP_BOTTLE_BUG, - /* 0x21 */ PLAYER_AP_BOTTLE_POE, - /* 0x22 */ PLAYER_AP_BOTTLE_BIG_POE, - /* 0x23 */ PLAYER_AP_BOTTLE_POTION_RED, - /* 0x24 */ PLAYER_AP_BOTTLE_POTION_BLUE, - /* 0x25 */ PLAYER_AP_BOTTLE_POTION_GREEN, - /* 0x26 */ PLAYER_AP_BOTTLE_MILK, - /* 0x27 */ PLAYER_AP_BOTTLE_MILK_HALF, - /* 0x28 */ PLAYER_AP_BOTTLE_CHATEAU, - /* 0x29 */ PLAYER_AP_BOTTLE_FAIRY, - /* 0x2A */ PLAYER_AP_MOON_TEAR, - /* 0x2B */ PLAYER_AP_DEED_LAND, - /* 0x2C */ PLAYER_AP_ROOM_KEY, - /* 0x2D */ PLAYER_AP_LETTER_TO_KAFEI, - /* 0x2E */ PLAYER_AP_MAGIC_BEANS, - /* 0x2F */ PLAYER_AP_DEED_SWAMP, - /* 0x30 */ PLAYER_AP_DEED_MOUNTAIN, - /* 0x31 */ PLAYER_AP_DEED_OCEAN, - /* 0x33 */ PLAYER_AP_LETTER_MAMA = 0x33, - /* 0x36 */ PLAYER_AP_PENDANT_MEMORIES = 0x36, - /* 0x3A */ PLAYER_AP_MASK_TRUTH = 0x3A, - /* 0x3B */ PLAYER_AP_MASK_KAFEIS_MASK, - /* 0x3C */ PLAYER_AP_MASK_ALL_NIGHT, - /* 0x3D */ PLAYER_AP_MASK_BUNNY, - /* 0x3E */ PLAYER_AP_MASK_KEATON, - /* 0x3F */ PLAYER_AP_MASK_GARO, - /* 0x40 */ PLAYER_AP_MASK_ROMANI, - /* 0x41 */ PLAYER_AP_MASK_CIRCUS_LEADER, - /* 0x42 */ PLAYER_AP_MASK_POSTMAN, - /* 0x43 */ PLAYER_AP_MASK_COUPLE, - /* 0x44 */ PLAYER_AP_MASK_GREAT_FAIRY, - /* 0x45 */ PLAYER_AP_MASK_GIBDO, - /* 0x46 */ PLAYER_AP_MASK_DON_GERO, - /* 0x47 */ PLAYER_AP_MASK_KAMARO, - /* 0x48 */ PLAYER_AP_MASK_CAPTAIN, - /* 0x49 */ PLAYER_AP_MASK_STONE, - /* 0x4A */ PLAYER_AP_MASK_BREMEN, - /* 0x4B */ PLAYER_AP_MASK_BLAST, - /* 0x4C */ PLAYER_AP_MASK_SCENTS, - /* 0x4D */ PLAYER_AP_MASK_GIANT, - /* 0x4E */ PLAYER_AP_MASK_FIERCE_DEITY, - /* 0x4F */ PLAYER_AP_MASK_GORON, - /* 0x50 */ PLAYER_AP_MASK_ZORA, - /* 0x51 */ PLAYER_AP_MASK_DEKU, - /* 0x52 */ PLAYER_AP_LENS, - /* 0xFD */ PLAYER_AP_MAX = 0xFD -} PlayerActionParam; + /* 0 */ PLAYER_ENV_HAZARD_NONE, + /* 1 */ PLAYER_ENV_HAZARD_HOTROOM, + /* 2 */ PLAYER_ENV_HAZARD_UNDERWATER_FLOOR, + /* 3 */ PLAYER_ENV_HAZARD_SWIMMING, + /* 4 */ PLAYER_ENV_HAZARD_UNDERWATER_FREE +} PlayerEnvHazard; -typedef struct { - /* 0x00 */ f32 unk_00; - /* 0x04 */ f32 unk_04; +typedef enum PlayerItemAction { + /* -1 */ PLAYER_IA_MINUS1 = -1, + /* 0x00 */ PLAYER_IA_NONE, + /* 0x01 */ PLAYER_IA_LAST_USED, + /* 0x02 */ PLAYER_IA_FISHING_ROD, + /* 0x03 */ PLAYER_IA_SWORD_KOKIRI, + /* 0x04 */ PLAYER_IA_SWORD_RAZOR, + /* 0x05 */ PLAYER_IA_SWORD_GILDED, + /* 0x06 */ PLAYER_IA_SWORD_GREAT_FAIRY, + /* 0x07 */ PLAYER_IA_STICK, + /* 0x08 */ PLAYER_IA_ZORA_FINS, + /* 0x09 */ PLAYER_IA_BOW, + /* 0x0A */ PLAYER_IA_BOW_FIRE, + /* 0x0B */ PLAYER_IA_BOW_ICE, + /* 0x0C */ PLAYER_IA_BOW_LIGHT, + /* 0x0D */ PLAYER_IA_HOOKSHOT, + /* 0x0E */ PLAYER_IA_BOMB, + /* 0x0F */ PLAYER_IA_POWDER_KEG, + /* 0x10 */ PLAYER_IA_BOMBCHU, + /* 0x11 */ PLAYER_IA_11, + /* 0x12 */ PLAYER_IA_NUT, + /* 0x13 */ PLAYER_IA_PICTO_BOX, + /* 0x14 */ PLAYER_IA_OCARINA, + /* 0x15 */ PLAYER_IA_BOTTLE, + /* 0x16 */ PLAYER_IA_BOTTLE_FISH, + /* 0x17 */ PLAYER_IA_BOTTLE_SPRING_WATER, + /* 0x18 */ PLAYER_IA_BOTTLE_HOT_SPRING_WATER, + /* 0x19 */ PLAYER_IA_BOTTLE_ZORA_EGG, + /* 0x1A */ PLAYER_IA_BOTTLE_DEKU_PRINCESS, + /* 0x1B */ PLAYER_IA_BOTTLE_GOLD_DUST, + /* 0x1C */ PLAYER_IA_BOTTLE_1C, + /* 0x1D */ PLAYER_IA_BOTTLE_SEAHORSE, + /* 0x1E */ PLAYER_IA_BOTTLE_MUSHROOM, + /* 0x1F */ PLAYER_IA_BOTTLE_HYLIAN_LOACH, + /* 0x20 */ PLAYER_IA_BOTTLE_BUG, + /* 0x21 */ PLAYER_IA_BOTTLE_POE, + /* 0x22 */ PLAYER_IA_BOTTLE_BIG_POE, + /* 0x23 */ PLAYER_IA_BOTTLE_POTION_RED, + /* 0x24 */ PLAYER_IA_BOTTLE_POTION_BLUE, + /* 0x25 */ PLAYER_IA_BOTTLE_POTION_GREEN, + /* 0x26 */ PLAYER_IA_BOTTLE_MILK, + /* 0x27 */ PLAYER_IA_BOTTLE_MILK_HALF, + /* 0x28 */ PLAYER_IA_BOTTLE_CHATEAU, + /* 0x29 */ PLAYER_IA_BOTTLE_FAIRY, + /* 0x2A */ PLAYER_IA_MOON_TEAR, + /* 0x2B */ PLAYER_IA_DEED_LAND, + /* 0x2C */ PLAYER_IA_ROOM_KEY, + /* 0x2D */ PLAYER_IA_LETTER_TO_KAFEI, + /* 0x2E */ PLAYER_IA_MAGIC_BEANS, + /* 0x2F */ PLAYER_IA_DEED_SWAMP, + /* 0x30 */ PLAYER_IA_DEED_MOUNTAIN, + /* 0x31 */ PLAYER_IA_DEED_OCEAN, + /* 0x32 */ PLAYER_IA_32, + /* 0x33 */ PLAYER_IA_LETTER_MAMA, + /* 0x34 */ PLAYER_IA_34, + /* 0x35 */ PLAYER_IA_35, + /* 0x36 */ PLAYER_IA_PENDANT_OF_MEMORIES, + /* 0x37 */ PLAYER_IA_37, + /* 0x38 */ PLAYER_IA_38, + /* 0x39 */ PLAYER_IA_39, + /* 0x3A */ PLAYER_IA_MASK_TRUTH, + /* 0x3B */ PLAYER_IA_MASK_KAFEIS_MASK, + /* 0x3C */ PLAYER_IA_MASK_ALL_NIGHT, + /* 0x3D */ PLAYER_IA_MASK_BUNNY, + /* 0x3E */ PLAYER_IA_MASK_KEATON, + /* 0x3F */ PLAYER_IA_MASK_GARO, + /* 0x40 */ PLAYER_IA_MASK_ROMANI, + /* 0x41 */ PLAYER_IA_MASK_CIRCUS_LEADER, + /* 0x42 */ PLAYER_IA_MASK_POSTMAN, + /* 0x43 */ PLAYER_IA_MASK_COUPLE, + /* 0x44 */ PLAYER_IA_MASK_GREAT_FAIRY, + /* 0x45 */ PLAYER_IA_MASK_GIBDO, + /* 0x46 */ PLAYER_IA_MASK_DON_GERO, + /* 0x47 */ PLAYER_IA_MASK_KAMARO, + /* 0x48 */ PLAYER_IA_MASK_CAPTAIN, + /* 0x49 */ PLAYER_IA_MASK_STONE, + /* 0x4A */ PLAYER_IA_MASK_BREMEN, + /* 0x4B */ PLAYER_IA_MASK_BLAST, + /* 0x4C */ PLAYER_IA_MASK_SCENTS, + /* 0x4D */ PLAYER_IA_MASK_GIANT, + /* 0x4E */ PLAYER_IA_MASK_FIERCE_DEITY, + /* 0x4F */ PLAYER_IA_MASK_GORON, + /* 0x50 */ PLAYER_IA_MASK_ZORA, + /* 0x51 */ PLAYER_IA_MASK_DEKU, + /* 0x52 */ PLAYER_IA_LENS, + /* 0x53 */ PLAYER_IA_MAX +} PlayerItemAction; + +typedef enum PlayerMeleeWeaponAnimation { + /* 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 + // These animations result in double damage + /* 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 enum PlayerDoorType { + /* -1 */ PLAYER_DOORTYPE_TALKING = -1, // Displays a message instead of opening + /* 0 */ PLAYER_DOORTYPE_NONE, + /* 1 */ PLAYER_DOORTYPE_HANDLE, + /* 2 */ PLAYER_DOORTYPE_SLIDING, + /* 3 */ PLAYER_DOORTYPE_FAKE, // Unused? OoT leftover (?) + /* 4 */ PLAYER_DOORTYPE_STAIRCASE, + /* 5 */ PLAYER_DOORTYPE_PROXIMITY +} PlayerDoorType; + +typedef enum PlayerAnimType { + /* 0 */ PLAYER_ANIMTYPE_0, + /* 1 */ PLAYER_ANIMTYPE_1, + /* 2 */ PLAYER_ANIMTYPE_2, + /* 3 */ PLAYER_ANIMTYPE_3, + /* 4 */ PLAYER_ANIMTYPE_4, + /* 5 */ PLAYER_ANIMTYPE_5, + /* 6 */ PLAYER_ANIMTYPE_MAX +} PlayerAnimType; + +typedef enum PlayerModelType { + // left hand + /* 0 */ PLAYER_MODELTYPE_LH_OPEN, + /* 1 */ PLAYER_MODELTYPE_LH_CLOSED, + /* 2 */ PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, + /* 3 */ PLAYER_MODELTYPE_LH_TWO_HAND_SWORD, + /* 4 */ PLAYER_MODELTYPE_LH_4, + /* 5 */ PLAYER_MODELTYPE_LH_BOTTLE, + // right hand + /* 6 */ PLAYER_MODELTYPE_RH_OPEN, + /* 7 */ PLAYER_MODELTYPE_RH_CLOSED, + /* 8 */ PLAYER_MODELTYPE_RH_SHIELD, + /* 9 */ PLAYER_MODELTYPE_RH_BOW, + /* 10 */ PLAYER_MODELTYPE_RH_INSTRUMENT, + /* 11 */ PLAYER_MODELTYPE_RH_HOOKSHOT, + // sheath + /* 12 */ PLAYER_MODELTYPE_SHEATH_12, + /* 13 */ PLAYER_MODELTYPE_SHEATH_13, + /* 14 */ PLAYER_MODELTYPE_SHEATH_14, + /* 15 */ PLAYER_MODELTYPE_SHEATH_15, + // waist + /* 16 */ PLAYER_MODELTYPE_WAIST, + /* 17 */ PLAYER_MODELTYPE_17, // NULL? + /* 18 */ PLAYER_MODELTYPE_MAX +} PlayerModelType; + +typedef struct PlayerModelIndices { + /* 0x0 */ u8 modelAnimType; // PlayerAnimType enum + /* 0x1 */ u8 leftHandType; // PlayerModelType enum + /* 0x2 */ u8 rightHandType; // PlayerModelType enum + /* 0x3 */ u8 sheathType; // PlayerModelType enum + /* 0x4 */ u8 waistType; // PlayerModelType enum +} PlayerModelIndices; // size = 0x5 + +typedef enum PlayerModelGroup { + /* 0 */ PLAYER_MODELGROUP_0, + /* 1 */ PLAYER_MODELGROUP_1, + /* 2 */ PLAYER_MODELGROUP_ONE_HAND_SWORD, + /* 3 */ PLAYER_MODELGROUP_DEFAULT, // non-specific models, for items that don't have particular link models + /* 4 */ PLAYER_MODELGROUP_4, + /* 5 */ PLAYER_MODELGROUP_TWO_HAND_SWORD, + /* 6 */ PLAYER_MODELGROUP_BOW, + /* 7 */ PLAYER_MODELGROUP_EXPLOSIVES, + /* 8 */ PLAYER_MODELGROUP_8, + /* 9 */ PLAYER_MODELGROUP_HOOKSHOT, + /* 10 */ PLAYER_MODELGROUP_STICK, + /* 11 */ PLAYER_MODELGROUP_INSTRUMENT, + /* 12 */ PLAYER_MODELGROUP_BOTTLE, + /* 13 */ PLAYER_MODELGROUP_13, + /* 14 */ PLAYER_MODELGROUP_ZORA_FINS, + /* 15 */ PLAYER_MODELGROUP_MAX +} PlayerModelGroup; + +typedef enum PlayerEyeIndex { + /* 0 */ PLAYER_EYES_OPEN, + /* 1 */ PLAYER_EYES_HALF, + /* 2 */ PLAYER_EYES_CLOSED, + /* 3 */ PLAYER_EYES_ROLL_RIGHT, + /* 4 */ PLAYER_EYES_ROLL_LEFT, + /* 5 */ PLAYER_EYES_ROLL_UP, + /* 6 */ PLAYER_EYES_ROLL_DOWN, + /* 7 */ PLAYER_EYES_7, + /* 8 */ PLAYER_EYES_MAX +} PlayerEyeIndex; + +typedef enum PlayerMouthIndex { + /* 0 */ PLAYER_MOUTH_CLOSED, + /* 1 */ PLAYER_MOUTH_TEETH, + /* 2 */ PLAYER_MOUTH_ANGRY, + /* 3 */ PLAYER_MOUTH_HAPPY, + /* 4 */ PLAYER_MOUTH_MAX +} PlayerMouthIndex; + +typedef enum PlayerFacialExpression { + /* 0 */ PLAYER_FACE_0, + /* 1 */ PLAYER_FACE_1, + /* 2 */ PLAYER_FACE_2, + /* 3 */ PLAYER_FACE_3, + /* 4 */ PLAYER_FACE_4, + /* 5 */ PLAYER_FACE_5, + /* 6 */ PLAYER_FACE_6, + /* 7 */ PLAYER_FACE_7, + /* 8 */ PLAYER_FACE_8, + /* 9 */ PLAYER_FACE_9, + /* 10 */ PLAYER_FACE_10, + /* 11 */ PLAYER_FACE_11, + /* 12 */ PLAYER_FACE_12, + /* 13 */ PLAYER_FACE_13, + /* 14 */ PLAYER_FACE_14, + /* 15 */ PLAYER_FACE_15 +} PlayerFacialExpression; + +typedef enum PlayerLimb { + /* 0x00 */ PLAYER_LIMB_NONE, + /* 0x01 */ PLAYER_LIMB_ROOT, + /* 0x02 */ PLAYER_LIMB_WAIST, + /* 0x03 */ PLAYER_LIMB_LOWER_ROOT, + /* 0x04 */ PLAYER_LIMB_RIGHT_THIGH, + /* 0x05 */ PLAYER_LIMB_RIGHT_SHIN, + /* 0x06 */ PLAYER_LIMB_RIGHT_FOOT, + /* 0x07 */ PLAYER_LIMB_LEFT_THIGH, + /* 0x08 */ PLAYER_LIMB_LEFT_SHIN, + /* 0x09 */ PLAYER_LIMB_LEFT_FOOT, + /* 0x0A */ PLAYER_LIMB_UPPER_ROOT, + /* 0x0B */ PLAYER_LIMB_HEAD, + /* 0x0C */ PLAYER_LIMB_HAT, + /* 0x0D */ PLAYER_LIMB_COLLAR, + /* 0x0E */ PLAYER_LIMB_LEFT_SHOULDER, + /* 0x0F */ PLAYER_LIMB_LEFT_FOREARM, + /* 0x10 */ PLAYER_LIMB_LEFT_HAND, + /* 0x11 */ PLAYER_LIMB_RIGHT_SHOULDER, + /* 0x12 */ PLAYER_LIMB_RIGHT_FOREARM, + /* 0x13 */ PLAYER_LIMB_RIGHT_HAND, + /* 0x14 */ PLAYER_LIMB_SHEATH, + /* 0x15 */ PLAYER_LIMB_TORSO, + /* 0x16 */ PLAYER_LIMB_MAX +} PlayerLimb; + +typedef enum PlayerBodyPart { + /* 0x00 */ PLAYER_BODYPART_WAIST, // PLAYER_LIMB_WAIST + /* 0x01 */ PLAYER_BODYPART_RIGHT_THIGH, // PLAYER_LIMB_RIGHT_THIGH + /* 0x02 */ PLAYER_BODYPART_RIGHT_SHIN, // PLAYER_LIMB_RIGHT_SHIN + /* 0x03 */ PLAYER_BODYPART_RIGHT_FOOT, // PLAYER_LIMB_RIGHT_FOOT + /* 0x04 */ PLAYER_BODYPART_LEFT_THIGH, // PLAYER_LIMB_LEFT_THIGH + /* 0x05 */ PLAYER_BODYPART_LEFT_SHIN, // PLAYER_LIMB_LEFT_SHIN + /* 0x06 */ PLAYER_BODYPART_LEFT_FOOT, // PLAYER_LIMB_LEFT_FOOT + /* 0x07 */ PLAYER_BODYPART_HEAD, // PLAYER_LIMB_HEAD + /* 0x08 */ PLAYER_BODYPART_HAT, // PLAYER_LIMB_HAT + /* 0x09 */ PLAYER_BODYPART_COLLAR, // PLAYER_LIMB_COLLAR + /* 0x0A */ PLAYER_BODYPART_LEFT_SHOULDER, // PLAYER_LIMB_LEFT_SHOULDER + /* 0x0B */ PLAYER_BODYPART_LEFT_FOREARM, // PLAYER_LIMB_LEFT_FOREARM + /* 0x0C */ PLAYER_BODYPART_LEFT_HAND, // PLAYER_LIMB_LEFT_HAND + /* 0x0D */ PLAYER_BODYPART_RIGHT_SHOULDER, // PLAYER_LIMB_R_SHOULDER + /* 0x0E */ PLAYER_BODYPART_RIGHT_FOREARM, // PLAYER_LIMB_R_FOREARM + /* 0x0F */ PLAYER_BODYPART_RIGHT_HAND, // PLAYER_LIMB_R_HAND + /* 0x10 */ PLAYER_BODYPART_SHEATH, // PLAYER_LIMB_SHEATH + /* 0x11 */ PLAYER_BODYPART_TORSO, // PLAYER_LIMB_TORSO + /* 0x12 */ PLAYER_BODYPART_MAX +} PlayerBodyPart; + +typedef struct PlayerAnimationFrame { + /* 0x000 */ Vec3s frameTable[PLAYER_LIMB_MAX]; + /* 0x108 */ s16 faceInfo; +} PlayerAnimationFrame; // size = 0x10A + +#define PLAYER_LIMB_BUF_SIZE (ALIGN16(sizeof(PlayerAnimationFrame)) + 0xF) + +typedef struct PlayerAgeProperties { + /* 0x00 */ f32 unk_00; // ceilingCheckHeight? + /* 0x04 */ f32 shadowScale; /* 0x08 */ f32 unk_08; /* 0x0C */ f32 unk_0C; /* 0x10 */ f32 unk_10; @@ -156,15 +388,15 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; + /* 0x38 */ f32 unk_38; // wallCheckHeight? /* 0x3C */ f32 unk_3C; /* 0x40 */ f32 unk_40; /* 0x44 */ Vec3s unk_44; /* 0x4A */ Vec3s unk_4A[4]; /* 0x62 */ Vec3s unk_62[4]; /* 0x7A */ Vec3s unk_7A[4]; - /* 0x92 */ u16 unk_92; - /* 0x94 */ u16 unk_94; + /* 0x92 */ u16 voiceSfxIdOffset; + /* 0x94 */ u16 surfaceSfxIdOffset; /* 0x98 */ f32 unk_98; /* 0x9C */ f32 unk_9C; /* 0xA0 */ LinkAnimationHeader* unk_A0; @@ -178,7 +410,6 @@ typedef struct { /* 0xD4 */ LinkAnimationHeader* unk_D4[2]; } PlayerAgeProperties; // size = 0xDC - typedef struct { /* 0x00 */ s32 active; /* 0x04 */ Vec3f tip; @@ -186,7 +417,396 @@ typedef struct { } WeaponInfo; // size = 0x1C -typedef void (*PlayerFuncD58)(struct GlobalContext*, struct Player*); +typedef struct { + /* 0x00 */ u8 unk_00; + /* 0x01 */ u8 alpha; + /* 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 + +typedef enum PlayerCsMode { + /* 0x00 */ PLAYER_CSMODE_0, + /* 0x01 */ PLAYER_CSMODE_1, + /* 0x02 */ PLAYER_CSMODE_2, + /* 0x03 */ PLAYER_CSMODE_3, + /* 0x04 */ PLAYER_CSMODE_4, + /* 0x05 */ PLAYER_CSMODE_5, + /* 0x06 */ PLAYER_CSMODE_6, + /* 0x07 */ PLAYER_CSMODE_7, + /* 0x08 */ PLAYER_CSMODE_8, + /* 0x09 */ PLAYER_CSMODE_9, + /* 0x0A */ PLAYER_CSMODE_10, + /* 0x0B */ PLAYER_CSMODE_11, + /* 0x0C */ PLAYER_CSMODE_12, + /* 0x0D */ PLAYER_CSMODE_13, + /* 0x0E */ PLAYER_CSMODE_14, + /* 0x0F */ PLAYER_CSMODE_15, + /* 0x10 */ PLAYER_CSMODE_16, + /* 0x11 */ PLAYER_CSMODE_17, + /* 0x12 */ PLAYER_CSMODE_18, + /* 0x13 */ PLAYER_CSMODE_19, + /* 0x14 */ PLAYER_CSMODE_20, + /* 0x15 */ PLAYER_CSMODE_21, + /* 0x16 */ PLAYER_CSMODE_22, + /* 0x17 */ PLAYER_CSMODE_23, + /* 0x18 */ PLAYER_CSMODE_24, + /* 0x19 */ PLAYER_CSMODE_25, + /* 0x1A */ PLAYER_CSMODE_26, + /* 0x1B */ PLAYER_CSMODE_27, + /* 0x1C */ PLAYER_CSMODE_28, + /* 0x1D */ PLAYER_CSMODE_29, + /* 0x1E */ PLAYER_CSMODE_30, + /* 0x1F */ PLAYER_CSMODE_31, + /* 0x20 */ PLAYER_CSMODE_32, + /* 0x21 */ PLAYER_CSMODE_33, + /* 0x22 */ PLAYER_CSMODE_34, + /* 0x23 */ PLAYER_CSMODE_35, + /* 0x24 */ PLAYER_CSMODE_36, + /* 0x25 */ PLAYER_CSMODE_37, + /* 0x26 */ PLAYER_CSMODE_38, + /* 0x27 */ PLAYER_CSMODE_39, + /* 0x28 */ PLAYER_CSMODE_40, + /* 0x29 */ PLAYER_CSMODE_41, + /* 0x2A */ PLAYER_CSMODE_42, + /* 0x2B */ PLAYER_CSMODE_43, + /* 0x2C */ PLAYER_CSMODE_44, + /* 0x2D */ PLAYER_CSMODE_45, + /* 0x2E */ PLAYER_CSMODE_46, + /* 0x2F */ PLAYER_CSMODE_47, + /* 0x30 */ PLAYER_CSMODE_48, + /* 0x31 */ PLAYER_CSMODE_49, + /* 0x32 */ PLAYER_CSMODE_50, + /* 0x33 */ PLAYER_CSMODE_51, + /* 0x34 */ PLAYER_CSMODE_52, + /* 0x35 */ PLAYER_CSMODE_53, + /* 0x36 */ PLAYER_CSMODE_54, + /* 0x37 */ PLAYER_CSMODE_55, + /* 0x38 */ PLAYER_CSMODE_56, + /* 0x39 */ PLAYER_CSMODE_57, + /* 0x3A */ PLAYER_CSMODE_58, + /* 0x3B */ PLAYER_CSMODE_59, + /* 0x3C */ PLAYER_CSMODE_60, + /* 0x3D */ PLAYER_CSMODE_61, + /* 0x3E */ PLAYER_CSMODE_62, + /* 0x3F */ PLAYER_CSMODE_63, + /* 0x40 */ PLAYER_CSMODE_64, + /* 0x41 */ PLAYER_CSMODE_65, + /* 0x42 */ PLAYER_CSMODE_66, + /* 0x43 */ PLAYER_CSMODE_67, + /* 0x44 */ PLAYER_CSMODE_68, + /* 0x45 */ PLAYER_CSMODE_69, + /* 0x46 */ PLAYER_CSMODE_70, + /* 0x47 */ PLAYER_CSMODE_71, + /* 0x48 */ PLAYER_CSMODE_72, + /* 0x49 */ PLAYER_CSMODE_73, + /* 0x4A */ PLAYER_CSMODE_74, + /* 0x4B */ PLAYER_CSMODE_75, + /* 0x4C */ PLAYER_CSMODE_76, + /* 0x4D */ PLAYER_CSMODE_77, + /* 0x4E */ PLAYER_CSMODE_78, + /* 0x4F */ PLAYER_CSMODE_79, + /* 0x50 */ PLAYER_CSMODE_80, + /* 0x51 */ PLAYER_CSMODE_81, + /* 0x52 */ PLAYER_CSMODE_82, + /* 0x53 */ PLAYER_CSMODE_83, + /* 0x54 */ PLAYER_CSMODE_84, + /* 0x55 */ PLAYER_CSMODE_85, + /* 0x56 */ PLAYER_CSMODE_86, + /* 0x57 */ PLAYER_CSMODE_87, + /* 0x58 */ PLAYER_CSMODE_88, + /* 0x59 */ PLAYER_CSMODE_89, + /* 0x5A */ PLAYER_CSMODE_90, + /* 0x5B */ PLAYER_CSMODE_91, + /* 0x5C */ PLAYER_CSMODE_92, + /* 0x5D */ PLAYER_CSMODE_93, + /* 0x5E */ PLAYER_CSMODE_94, + /* 0x5F */ PLAYER_CSMODE_95, + /* 0x60 */ PLAYER_CSMODE_96, + /* 0x61 */ PLAYER_CSMODE_97, + /* 0x62 */ PLAYER_CSMODE_98, + /* 0x63 */ PLAYER_CSMODE_99, + /* 0x64 */ PLAYER_CSMODE_100, + /* 0x65 */ PLAYER_CSMODE_101, + /* 0x66 */ PLAYER_CSMODE_102, + /* 0x67 */ PLAYER_CSMODE_103, + /* 0x68 */ PLAYER_CSMODE_104, + /* 0x69 */ PLAYER_CSMODE_105, + /* 0x6A */ PLAYER_CSMODE_106, + /* 0x6B */ PLAYER_CSMODE_107, + /* 0x6C */ PLAYER_CSMODE_108, + /* 0x6D */ PLAYER_CSMODE_109, + /* 0x6E */ PLAYER_CSMODE_110, + /* 0x6F */ PLAYER_CSMODE_111, + /* 0x70 */ PLAYER_CSMODE_112, + /* 0x71 */ PLAYER_CSMODE_113, + /* 0x72 */ PLAYER_CSMODE_114, + /* 0x73 */ PLAYER_CSMODE_115, + /* 0x74 */ PLAYER_CSMODE_116, + /* 0x75 */ PLAYER_CSMODE_117, + /* 0x76 */ PLAYER_CSMODE_118, + /* 0x77 */ PLAYER_CSMODE_119, + /* 0x78 */ PLAYER_CSMODE_120, + /* 0x79 */ PLAYER_CSMODE_121, + /* 0x7A */ PLAYER_CSMODE_122, + /* 0x7B */ PLAYER_CSMODE_123, + /* 0x7C */ PLAYER_CSMODE_124, + /* 0x7D */ PLAYER_CSMODE_125, + /* 0x7E */ PLAYER_CSMODE_126, + /* 0x7F */ PLAYER_CSMODE_127, + /* 0x80 */ PLAYER_CSMODE_128, + /* 0x81 */ PLAYER_CSMODE_129, + /* 0x82 */ PLAYER_CSMODE_130, + /* 0x83 */ PLAYER_CSMODE_131, + /* 0x84 */ PLAYER_CSMODE_132, + /* 0x85 */ PLAYER_CSMODE_133, + /* 0x86 */ PLAYER_CSMODE_134, + /* 0x87 */ PLAYER_CSMODE_135, + /* 0x88 */ PLAYER_CSMODE_136, + /* 0x89 */ PLAYER_CSMODE_137, + /* 0x8A */ PLAYER_CSMODE_138, + /* 0x8B */ PLAYER_CSMODE_139, + /* 0x8C */ PLAYER_CSMODE_MAX +} PlayerCsMode; + + +// +#define PLAYER_STATE1_1 (1 << 0) +// +#define PLAYER_STATE1_2 (1 << 1) +// +#define PLAYER_STATE1_4 (1 << 2) +// +#define PLAYER_STATE1_8 (1 << 3) +// Zora electric shield +#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) +// Related to exit a grotto +#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) +// Disable drawing player +#define PLAYER_STATE2_20000000 (1 << 29) +// Lunge: small forward boost at the end of certain attack animations +#define PLAYER_STATE2_40000000 (1 << 30) +// Void-out +#define PLAYER_STATE2_80000000 (1 << 31) + + +// Ignores collision with floor? +#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) +// Related to form Deku +#define PLAYER_STATE3_100 (1 << 8) +// +#define PLAYER_STATE3_200 (1 << 9) +// +#define PLAYER_STATE3_400 (1 << 10) +// +#define PLAYER_STATE3_800 (1 << 11) +// goron curled +#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) +// Related to form Deku +#define PLAYER_STATE3_40000 (1 << 18) +// +#define PLAYER_STATE3_80000 (1 << 19) +// +#define PLAYER_STATE3_100000 (1 << 20) +// Deku hopping? +#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) + + +#define PLAYER_GET_INITMODE(thisx) (((thisx)->params & 0xF00) >> 8) + +typedef enum PlayerInitMode { + /* 0x0 */ PLAYER_INITMODE_0, + /* 0x1 */ PLAYER_INITMODE_1, // Spawning after pulling/putting-back Master sword // OoT leftover + /* 0x2 */ PLAYER_INITMODE_2, + /* 0x3 */ PLAYER_INITMODE_3, + /* 0x4 */ PLAYER_INITMODE_4, + /* 0x5 */ PLAYER_INITMODE_5, + /* 0x6 */ PLAYER_INITMODE_6, + /* 0x7 */ PLAYER_INITMODE_7, + /* 0x8 */ PLAYER_INITMODE_8, + /* 0x9 */ PLAYER_INITMODE_9, + /* 0xA */ PLAYER_INITMODE_A, + /* 0xB */ PLAYER_INITMODE_B, + /* 0xC */ PLAYER_INITMODE_TELESCOPE, + /* 0xD */ PLAYER_INITMODE_D, + /* 0xE */ PLAYER_INITMODE_E, + /* 0xF */ PLAYER_INITMODE_F +} PlayerInitMode; + +#define PLAYER_PARAMS(startBgCamIndex, initMode) ((startBgCamIndex & 0xFF) | ((initMode & 0xF) << 8)) + +typedef void (*PlayerActionFunc)(struct Player* this, struct PlayState* play); +typedef s32 (*PlayerFuncAC4)(struct Player* this, struct PlayState* play); +typedef void (*PlayerFuncD58)(struct PlayState* play, struct Player* this); typedef struct Player { @@ -194,19 +814,19 @@ typedef struct Player { /* 0x144 */ s8 currentShield; /* 0x145 */ s8 currentBoots; /* 0x146 */ s8 heldItemButton; - /* 0x147 */ s8 itemActionParam; - /* 0x148 */ u8 heldItemId; + /* 0x147 */ s8 heldItemAction; // PlayerItemAction enum + /* 0x148 */ u8 heldItemId; // ItemId enum /* 0x149 */ s8 prevBoots; - /* 0x14A */ s8 heldItemActionParam; - /* 0x14B */ u8 transformation; - /* 0x14C */ u8 modelGroup; + /* 0x14A */ s8 itemAction; // PlayerItemAction enum + /* 0x14B */ u8 transformation; // PlayerTransformation enum + /* 0x14C */ u8 modelGroup; // PlayerModelGroup enum /* 0x14D */ u8 nextModelGroup; /* 0x14E */ s8 unk_14E; - /* 0x14F */ u8 modelAnimType; + /* 0x14F */ u8 modelAnimType; // PlayerAnimType enum /* 0x150 */ u8 leftHandType; /* 0x151 */ u8 rightHandType; /* 0x152 */ u8 sheathType; - /* 0x153 */ u8 currentMask; + /* 0x153 */ u8 currentMask; // PlayerMask enum /* 0x154 */ s8 unk_154; /* 0x155 */ u8 prevMask; /* 0x158 */ Gfx** rightHandDLists; @@ -239,7 +859,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; @@ -256,43 +876,50 @@ typedef struct Player { /* 0x350 */ PosRot leftHandWorld; /* 0x364 */ Actor* rightHandActor; /* 0x368 */ PosRot rightHandWorld; - /* 0x37C */ s8 doorType; + /* 0x37C */ s8 doorType; // PlayerDoorType enum /* 0x37D */ s8 doorDirection; /* 0x37E */ s8 doorTimer; /* 0x37F */ s8 doorNext; // used with spiral staircase /* 0x380 */ Actor* doorActor; - /* 0x384 */ s16 getItemId; + /* 0x384 */ s16 getItemId; // GetItemId enum /* 0x386 */ u16 getItemDirection; /* 0x388 */ Actor* interactRangeActor; /* 0x38C */ s8 mountSide; /* 0x390 */ Actor* rideActor; - /* 0x394 */ u8 csMode; - /* 0x395 */ u8 unk_395; - /* 0x396 */ u8 unk_396; - /* 0x397 */ u8 unk_397; + /* 0x394 */ u8 csMode; // PlayerCsMode enum + /* 0x395 */ u8 prevCsMode; // PlayerCsMode enum + /* 0x396 */ u8 unk_396; // currentActorActionId? + /* 0x397 */ u8 unk_397; // PlayerDoorType enum /* 0x398 */ Actor* unk_398; - /* 0x39C */ s16 unk_39C; - /* 0x39E */ s16 unk_39E; + /* 0x39C */ UNK_TYPE1 unk_39C[0x4]; /* 0x3A0 */ Vec3f unk_3A0; /* 0x3AC */ Vec3f unk_3AC; /* 0x3B8 */ u16 unk_3B8; /* 0x3BA */ s16 unk_3BA; - /* 0x3BC */ s16 unk_3BC; + /* 0x3BC */ s16 subCamId; /* 0x3BE */ char unk_3BE[2]; /* 0x3C0 */ Vec3f unk_3C0; /* 0x3CC */ s16 unk_3CC; /* 0x3CE */ s8 unk_3CE; /* 0x3CF */ u8 unk_3CF; - /* 0x3D0 */ char unk_3D0[0x148]; + /* 0x3D0 */ struct_80122D44_arg1 unk_3D0; + /* 0x4E4 */ UNK_TYPE1 unk_4E4[0x20]; + /* 0x504 */ LightNode* lightNode; + /* 0x508 */ LightInfo lightInfo; /* 0x518 */ ColliderCylinder cylinder; - /* 0x564 */ ColliderQuad swordQuads[2]; + /* 0x564 */ ColliderQuad meleeWeaponQuads[2]; /* 0x664 */ ColliderQuad shieldQuad; /* 0x6E4 */ ColliderCylinder shieldCylinder; - /* 0x730 */ Actor* unk_730; + /* 0x730 */ Actor* targetedActor; // Z/L-Targeted actor /* 0x734 */ char unk_734[4]; /* 0x738 */ s32 unk_738; - /* 0x73C */ s32 blureEffectIndex[3]; - /* 0x748 */ char unk_748[0x320]; + /* 0x73C */ s32 meleeWeaponEffectIndex[3]; + /* 0x748 */ PlayerActionFunc actionFunc; + /* 0x74C */ u8 jointTableBuffer[PLAYER_LIMB_BUF_SIZE]; + /* 0x7EB */ u8 morphTableBuffer[PLAYER_LIMB_BUF_SIZE]; + /* 0x88A */ u8 blendTableBuffer[PLAYER_LIMB_BUF_SIZE]; + /* 0x929 */ u8 unk_929[PLAYER_LIMB_BUF_SIZE]; + /* 0x9C8 */ u8 unk_9C8[PLAYER_LIMB_BUF_SIZE]; /* 0xA68 */ PlayerAgeProperties* ageProperties; // repurposed as "transformation properties"? /* 0xA6C */ u32 stateFlags1; /* 0xA70 */ u32 stateFlags2; @@ -301,18 +928,18 @@ typedef struct Player { /* 0xA7C */ Actor* boomerangActor; /* 0xA80 */ Actor* tatlActor; /* 0xA84 */ s16 tatlTextId; - /* 0xA86 */ s8 unk_A86; - /* 0xA87 */ s8 exchangeItemId; - /* 0xA88 */ Actor* targetActor; - /* 0xA8C */ f32 targetActorDistance; + /* 0xA86 */ s8 unk_A86; // actorCutsceneIndex? + /* 0xA87 */ s8 exchangeItemId; // PlayerItemAction enum + /* 0xA88 */ Actor* talkActor; + /* 0xA8C */ f32 talkActorDistance; /* 0xA90 */ Actor* unk_A90; /* 0xA94 */ f32 unk_A94; /* 0xA98 */ Actor* unk_A98; - /* 0xA9C */ f32 unk_A9C; - /* 0xAA0 */ f32 unk_AA0; + /* 0xA9C */ f32 secretRumbleCharge; // builds per frame until discharges with a rumble request + /* 0xAA0 */ f32 closestSecretDistSq; // Used to augment `secretRumbleCharge`. Cleared every frame /* 0xAA4 */ s8 unk_AA4; /* 0xAA5 */ u8 unk_AA5; - /* 0xAA6 */ u16 unk_AA6; + /* 0xAA6 */ u16 unk_AA6; // flags of some kind /* 0xAA8 */ s16 unk_AA8; /* 0xAAA */ s16 unk_AAA; /* 0xAAC */ Vec3s unk_AAC; @@ -320,29 +947,30 @@ typedef struct Player { /* 0xAB8 */ f32 unk_AB8; /* 0xABC */ f32 unk_ABC; /* 0xAC0 */ f32 unk_AC0; - /* 0xAC4 */ void* unk_AC4; + /* 0xAC4 */ PlayerFuncAC4 unk_AC4; /* 0xAC8 */ f32 unk_AC8; /* 0xACC */ s16 unk_ACC; /* 0xACE */ s8 unk_ACE; - /* 0xACF */ u8 unk_ACF; + /* 0xACF */ u8 putAwayCountdown; // Frames to wait before showing "Put Away" on A /* 0xAD0 */ f32 linearVelocity; /* 0xAD4 */ s16 currentYaw; /* 0xAD6 */ s16 targetYaw; - /* 0xAD8 */ u16 unk_AD8; - /* 0xADA */ s8 swordAnimation; - /* 0xADB */ s8 swordState; + /* 0xAD8 */ u16 underwaterTimer; + /* 0xADA */ s8 meleeWeaponAnimation; + /* 0xADB */ s8 meleeWeaponState; /* 0xADC */ s8 unk_ADC; /* 0xADD */ s8 unk_ADD; /* 0xADE */ u8 unk_ADE; - /* 0xADF */ s8 unk_ADF[4]; - /* 0xAE3 */ s8 unk_AE3[4]; + /* 0xADF */ s8 unk_ADF[4]; // Circular buffer used for testing for triggering a quickspin + /* 0xAE3 */ s8 unk_AE3[4]; // Circular buffer used for ? /* 0xAE7 */ s8 unk_AE7; // a timer /* 0xAE8 */ s16 unk_AE8; // multipurpose timer /* 0xAEC */ f32 unk_AEC; /* 0xAF0 */ Vec3f unk_AF0[2]; - /* 0xB08 */ f32 unk_B08[8]; + /* 0xB08 */ f32 unk_B08[2]; // TODO: Investigate if this member actually is an array + /* 0xB10 */ f32 unk_B10[6]; /* 0xB28 */ s16 unk_B28; //Burning stick timer? - /* 0xB2A */ s8 unk_B2A; + /* 0xB2A */ s8 getItemDrawId; /* 0xB2B */ s8 unk_B2B; /* 0xB2C */ f32 windSpeed; /* 0xB30 */ s16 windAngleX; @@ -356,8 +984,8 @@ typedef struct Player { /* 0xB4C */ s16 unk_B4C; /* 0xB4E */ s16 unk_B4E; /* 0xB50 */ f32 unk_B50; - /* 0xB54 */ f32 unk_B54; - /* 0xB58 */ f32 unk_B58; + /* 0xB54 */ f32 wallHeight; // height used to determine whether link can climb or grab a ledge at the top + /* 0xB58 */ f32 wallDistance; // distance to the colliding wall plane /* 0xB5C */ u8 unk_B5C; /* 0xB5D */ u8 unk_B5D; /* 0xB5E */ u8 unk_B5E; @@ -365,15 +993,15 @@ typedef struct Player { /* 0xB60 */ u16 unk_B60; // blast mask timer? /* 0xB62 */ s16 unk_B62; /* 0xB64 */ u8 unk_B64; - /* 0xB65 */ u8 unk_B65; + /* 0xB65 */ u8 shockTimer; /* 0xB66 */ u8 unk_B66; - /* 0xB67 */ u8 unk_B67; // deku hop timer? - /* 0xB68 */ s16 unk_B68; - /* 0xB6A */ s16 unk_B6A; + /* 0xB67 */ u8 unk_B67; // deku remaining hops counter + /* 0xB68 */ s16 fallStartHeight; // last truncated Y position before falling + /* 0xB6A */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down) /* 0xB6C */ s16 unk_B6C; /* 0xB6E */ s16 unk_B6E; /* 0xB70 */ s16 unk_B70; - /* 0xB72 */ u16 unk_B72; // floor type? + /* 0xB72 */ u16 floorSfxOffset; /* 0xB74 */ u8 unk_B74; /* 0xB75 */ u8 unk_B75; /* 0xB76 */ s16 unk_B76; @@ -381,8 +1009,7 @@ typedef struct Player { /* 0xB7C */ f32 unk_B7C; /* 0xB80 */ f32 unk_B80; /* 0xB84 */ s16 unk_B84; - /* 0xB86 */ s16 unk_B86; - /* 0xB88 */ s16 unk_B88; + /* 0xB86 */ s16 unk_B86[2]; // unknown length /* 0xB8A */ s16 unk_B8A; /* 0xB8C */ s16 unk_B8C; /* 0xB8E */ s16 unk_B8E; @@ -390,12 +1017,12 @@ typedef struct Player { /* 0xB92 */ s16 unk_B92; /* 0xB94 */ s16 unk_B94; /* 0xB96 */ s16 unk_B96; - /* 0xB98 */ WeaponInfo swordInfo[3]; - /* 0xBEC */ Vec3f bodyPartsPos[18]; + /* 0xB98 */ WeaponInfo meleeWeaponInfo[3]; + /* 0xBEC */ Vec3f bodyPartsPos[PLAYER_BODYPART_MAX]; /* 0xCC4 */ MtxF mf_CC4; /* 0xD04 */ MtxF shieldMf; /* 0xD44 */ u8 isBurning; - /* 0xD45 */ u8 flameTimers[18]; // one flame per body part + /* 0xD45 */ u8 flameTimers[PLAYER_BODYPART_MAX]; /* 0xD57 */ u8 unk_D57; /* 0xD58 */ PlayerFuncD58 unk_D58; /* 0xD5C */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame) @@ -404,7 +1031,7 @@ typedef struct Player { /* 0xD5F */ u8 unk_D5F; /* 0xD60 */ f32 unk_D60; /* 0xD64 */ s16 unk_D64; - /* 0xD66 */ u16 unk_D66; + /* 0xD66 */ u16 unk_D66; // sfx /* 0xD68 */ s16 unk_D68; /* 0xD6A */ s8 unk_D6A; /* 0xD6B */ u8 unk_D6B; diff --git a/include/z64quake.h b/include/z64quake.h new file mode 100644 index 000000000..a1272941d --- /dev/null +++ b/include/z64quake.h @@ -0,0 +1,69 @@ +#ifndef Z64QUAKE_H +#define Z64QUAKE_H + +#include "z64math.h" + +struct PlayState; +struct Camera; + +typedef struct { + /* 0x00 */ Vec3f atOffset; + /* 0x0C */ Vec3f eyeOffset; + /* 0x18 */ s16 rollOffset; + /* 0x1A */ s16 zoom; + /* 0x1C */ f32 max; // Set to scaled max data of struct (mag for Vec3f), never used +} QuakeCamCalc; // size = 0x20 + +#define QUAKE_SPEED (1 << 0) +#define QUAKE_VERTICAL_MAG (1 << 1) +#define QUAKE_HORIZONTAL_MAG (1 << 2) +#define QUAKE_ZOOM (1 << 3) +#define QUAKE_ROLL_OFFSET (1 << 4) +#define QUAKE_SHAKE_PLANE_OFFSET_X (1 << 5) +#define QUAKE_SHAKE_PLANE_OFFSET_Y (1 << 6) +#define QUAKE_SHAKE_PLANE_OFFSET_Z (1 << 7) +#define QUAKE_COUNTDOWN (1 << 8) +#define QUAKE_IS_SHAKE_PERPENDICULAR (1 << 9) + +typedef enum { + /* 1 */ QUAKE_TYPE_1 = 1, + /* 2 */ QUAKE_TYPE_2, + /* 3 */ QUAKE_TYPE_3, + /* 4 */ QUAKE_TYPE_4, + /* 5 */ QUAKE_TYPE_5, + /* 6 */ QUAKE_TYPE_6 +} QuakeType; + +u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value); +u32 Quake_SetSpeed(s16 quakeIndex, s16 speed); +u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown); +s16 Quake_GetCountdown(s16 quakeIndex); +u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset); +u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset); +s16 Quake_Add(Camera* camera, u32 type); +s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData); +u32 Quake_Remove(s16 index); +s32 Quake_NumActiveQuakes(void); +void Quake_Init(void); + +#define DISTORTION_TYPE_0 (1 << 0) +#define DISTORTION_TYPE_2 (1 << 2) +#define DISTORTION_TYPE_3 (1 << 3) +#define DISTORTION_TYPE_4 (1 << 4) +#define DISTORTION_TYPE_5 (1 << 5) +#define DISTORTION_TYPE_6 (1 << 6) +#define DISTORTION_TYPE_7 (1 << 7) +#define DISTORTION_TYPE_8 (1 << 8) +#define DISTORTION_TYPE_9 (1 << 9) +#define DISTORTION_TYPE_A (1 << 10) +#define DISTORTION_TYPE_B (1 << 11) + +void Distortion_SetCountdown(s16 countdown); +s16 Distortion_GetCountdown(void); +s16 Distortion_GetType(void); +void Distortion_SetType(s32 type); +void Distortion_ClearType(s32 type); +void Distortion_Init(PlayState* play); +void Distortion_Update(void); + +#endif 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 260701473..f9083144d 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -2,19 +2,20 @@ #define Z64SAVE_H #include "ultra64.h" +#include "z64item.h" #include "z64math.h" #include "os.h" struct GameState; -struct GlobalContext; -struct FileChooseContext; +struct PlayState; +struct FileSelectState; // 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" @@ -24,6 +25,137 @@ typedef enum RespawnMode { #define SAVE_BUFFER_SIZE 0x4000 +typedef enum { + /* 0 */ MAGIC_STATE_IDLE, // Regular gameplay + /* 1 */ MAGIC_STATE_CONSUME_SETUP, // Sets the speed at which the magic border flashes + /* 2 */ MAGIC_STATE_CONSUME, // Consume magic until target is reached or no more magic is available + /* 3 */ MAGIC_STATE_METER_FLASH_1, // Flashes border + /* 4 */ MAGIC_STATE_METER_FLASH_2, // Flashes border and draws yellow magic to preview target consumption + /* 5 */ MAGIC_STATE_RESET, // Reset colors and return to idle + /* 6 */ MAGIC_STATE_METER_FLASH_3, // Flashes border with no additional behaviour + /* 7 */ MAGIC_STATE_CONSUME_LENS, // Magic slowly consumed by Lens of Truth + /* 8 */ MAGIC_STATE_STEP_CAPACITY, // Step `magicCapacity` to full capacity + /* 9 */ MAGIC_STATE_FILL, // Add magic until magicFillTarget is reached + /* 10 */ MAGIC_STATE_CONSUME_GORON_ZORA_SETUP, + /* 11 */ MAGIC_STATE_CONSUME_GORON_ZORA, // Magic slowly consumed by Goron spiked rolling or Zora electric barrier. + /* 12 */ MAGIC_STATE_CONSUME_GIANTS_MASK // Magic slowly consumed by Giant's Mask +} MagicState; + +typedef enum { + /* 0 */ MAGIC_CONSUME_NOW, // Consume magic immediately without preview + /* 1 */ MAGIC_CONSUME_WAIT_NO_PREVIEW, // Sets consume target but waits to consume. No yellow magic preview to target consumption. Unused + /* 2 */ MAGIC_CONSUME_NOW_ALT, // Identical behaviour to MAGIC_CONSUME_NOW. Unused + /* 3 */ MAGIC_CONSUME_LENS, // Lens of Truth consumption + /* 4 */ MAGIC_CONSUME_WAIT_PREVIEW, // Sets consume target but waits to consume. Show magic to be consumed in yellow. + /* 5 */ MAGIC_CONSUME_GORON_ZORA, // Goron spiked rolling or Zora electric barrier slow consumption + /* 6 */ MAGIC_CONSUME_GIANTS_MASK, // Giant's Mask slow consumption + /* 7 */ MAGIC_CONSUME_DEITY_BEAM // Fierce Deity Beam consumption, consumed magic now and not via request +} MagicChangeType; + +#define MAGIC_NORMAL_METER 0x30 +#define MAGIC_DOUBLE_METER (2 * MAGIC_NORMAL_METER) + +// See `R_MAGIC_DBG_SET_UPGRADE` +#define MAGIC_DBG_SET_UPGRADE_NO_ACTION 0 +#define MAGIC_DBG_SET_UPGRADE_NORMAL_METER -1 +#define MAGIC_DBG_SET_UPGRADE_DOUBLE_METER 1 + +#define ENV_HAZARD_TEXT_TRIGGER_HOTROOM (1 << 0) +#define ENV_HAZARD_TEXT_TRIGGER_UNDERWATER (1 << 1) + +#define SECONDS_TO_TIMER(seconds) ((seconds) * 100) + +#define OSTIME_TO_TIMER(osTime) ((osTime) * 64 / 3000 / 10000) +#define OSTIME_TO_TIMER_ALT(osTime) ((osTime) / 10000 * 64 / 3000) + +// 1 centisecond = 10 milliseconds = 1/100 seconds +#define SECONDS_TO_TIMER_PRECISE(seconds, centiSeconds) ((seconds) * 100 + (centiSeconds)) + +typedef enum { + /* 0 */ TIMER_ID_POSTMAN, // postman's counting minigame + /* 1 */ TIMER_ID_MINIGAME_1, // minigame timer + /* 2 */ TIMER_ID_2, + /* 3 */ TIMER_ID_MOON_CRASH, // timer used for mooncrash on the clocktower roof + /* 4 */ TIMER_ID_MINIGAME_2, // minigame timer + /* 5 */ TIMER_ID_ENV_HAZARD, // environmental hazard timer (underwater or hot room) + /* 6 */ TIMER_ID_GORON_RACE_UNUSED, + /* 7 */ TIMER_ID_MAX, + /* 99 */ TIMER_ID_NONE = 99, +} TimerId; + +typedef enum { + /* 0 */ TIMER_COUNT_DOWN, + /* 1 */ TIMER_COUNT_UP +} TimerDirection; + +typedef enum { + /* 0 */ TIMER_STATE_OFF, + /* 1 */ TIMER_STATE_START, + /* 2 */ TIMER_STATE_HOLD_TIMER, // Hold timer frozen at the screen center + /* 3 */ TIMER_STATE_MOVING_TIMER, // Move timer to a target location + /* 4 */ TIMER_STATE_COUNTING, + /* 5 */ TIMER_STATE_STOP, + /* 6 */ TIMER_STATE_6, // like `TIMER_STATE_STOP` but with extra minigame checks + /* 7 */ TIMER_STATE_7, // stopped but still update `timerCurTimes` + /* 8 */ TIMER_STATE_ENV_HAZARD_START, + /* 9 */ TIMER_STATE_ALT_START, + /* 10 */ TIMER_STATE_10, // precursor to `TIMER_STATE_ALT_COUNTING` + /* 11 */ TIMER_STATE_ALT_COUNTING, + /* 12 */ TIMER_STATE_12, // Updated paused time? + /* 13 */ TIMER_STATE_POSTMAN_START, + /* 14 */ TIMER_STATE_POSTMAN_COUNTING, + /* 15 */ TIMER_STATE_POSTMAN_STOP, + /* 16 */ TIMER_STATE_POSTMAN_END +} TimerState; + +typedef enum { + /* 0 */ BOTTLE_TIMER_STATE_OFF, + /* 1 */ BOTTLE_TIMER_STATE_COUNTING +} BottleTimerState; + +typedef enum { + /* 0 */ MINIGAME_STATUS_INACTIVE, + /* 1 */ MINIGAME_STATUS_ACTIVE, + /* 3 */ MINIGAME_STATUS_END = 3 +} MinigameStatus; + +typedef enum { + /* 0 */ HUD_VISIBILITY_IDLE, + /* 1 */ HUD_VISIBILITY_NONE, + /* 2 */ HUD_VISIBILITY_NONE_ALT, // Identical to HUD_VISIBILITY_NONE + /* 3 */ HUD_VISIBILITY_HEARTS_WITH_OVERWRITE, // Uses Interface_UpdateButtonAlphas so gives the opportunity to dim only disabled buttons + /* 4 */ HUD_VISIBILITY_A, + /* 5 */ HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, // Uses Interface_UpdateButtonAlphas so gives the opportunity to dim only disabled buttons + /* 6 */ HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE, // Uses Interface_UpdateButtonAlphas so gives the opportunity to dim only disabled buttons + /* 7 */ HUD_VISIBILITY_ALL_NO_MINIMAP_W_DISABLED, // Only raises button alphas if not disabled + /* 8 */ HUD_VISIBILITY_B, + /* 9 */ HUD_VISIBILITY_HEARTS_MAGIC, + /* 10 */ HUD_VISIBILITY_B_ALT, + /* 11 */ HUD_VISIBILITY_HEARTS, + /* 12 */ HUD_VISIBILITY_A_B_MINIMAP, + /* 13 */ HUD_VISIBILITY_HEARTS_MAGIC_WITH_OVERWRITE, // Uses Interface_UpdateButtonAlphas so gives the opportunity to dim only disabled buttons + /* 14 */ HUD_VISIBILITY_HEARTS_MAGIC_C, + /* 15 */ HUD_VISIBILITY_ALL_NO_MINIMAP, + /* 16 */ HUD_VISIBILITY_A_B_C, + /* 17 */ HUD_VISIBILITY_B_MINIMAP, + /* 18 */ HUD_VISIBILITY_HEARTS_MAGIC_MINIMAP, + /* 19 */ HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP, + /* 20 */ HUD_VISIBILITY_B_MAGIC, + /* 21 */ HUD_VISIBILITY_A_B, + /* 22 */ HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP, + /* 50 */ HUD_VISIBILITY_ALL = 50, + /* 52 */ HUD_VISIBILITY_NONE_INSTANT = 52 +} HudVisibility; + +#define PICTO_PHOTO_WIDTH 160 +#define PICTO_PHOTO_HEIGHT 112 + +#define PICTO_PHOTO_TOPLEFT_X ((SCREEN_WIDTH - PICTO_PHOTO_WIDTH) / 2) +#define PICTO_PHOTO_TOPLEFT_Y ((SCREEN_HEIGHT - PICTO_PHOTO_HEIGHT) / 2) + +#define PICTO_PHOTO_SIZE (PICTO_PHOTO_WIDTH * PICTO_PHOTO_HEIGHT) +#define PICTO_PHOTO_COMPRESSED_SIZE (PICTO_PHOTO_SIZE * 5 / 8) + typedef struct SramContext { /* 0x00 */ u8* readBuff; /* 0x04 */ u8 *saveBuf; @@ -49,22 +181,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 sceneId; // "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 +211,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 +224,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; // 0 for no magic/new load, 1 for magic, 2 for double magic "magic_max" + /* 0x15 */ s8 magic; // current magic available for use "magic_now" + /* 0x16 */ s16 rupees; // "lupy_count" + /* 0x18 */ u16 swordHealth; // "long_sword_hp" + /* 0x1A */ u16 tatlTimer; // "navi_timer" + /* 0x1C */ u8 isMagicAcquired; // "magic_mode" + /* 0x1D */ u8 isDoubleMagicAcquired; // "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 savedSceneId; // "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,7 +262,7 @@ typedef struct Save { /* 0x000C */ u16 time; // "zelda_time" /* 0x000E */ u16 owlSaveLocation; /* 0x0010 */ s32 isNight; // "asahiru_fg" - /* 0x0014 */ s32 daySpeed; // "change_zelda_time" + /* 0x0014 */ s32 timeSpeedOffset; // "change_zelda_time" /* 0x0018 */ s32 day; // "totalday" /* 0x001C */ s32 daysElapsed; // "eventday" /* 0x0020 */ u8 playerForm; // "player_character" @@ -142,8 +275,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 +293,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" + /* 0x0F5C */ u32 regionsVisited; // "area_arrival" + /* 0x0F60 */ u32 worldMapCloudVisibility; // "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 @@ -183,73 +316,73 @@ typedef struct SaveContext { /* 0x1015 */ u8 unk_1015; /* 0x1016 */ u16 jinxTimer; /* 0x1018 */ s16 rupeeAccumulator; // "lupy_udct" - /* 0x101A */ u8 unk_101A[6]; // "bottle_status", one entry for each bottle - /* 0x1020 */ OSTime unk_1020[6]; // "bottle_ostime", one entry for each bottle - /* 0x1050 */ OSTime unk_1050[6]; // "bottle_sub", one entry for each bottle - /* 0x1080 */ OSTime unk_1080[6]; // "bottle_time", one entry for each bottle - /* 0x10B0 */ OSTime unk_10B0[6]; // "bottle_stop_time", one entry for each bottle - /* 0x10E0 */ u64 pictoPhoto[1400]; // buffer containing the pictograph photo + /* 0x101A */ u8 bottleTimerStates[BOTTLE_MAX]; // See the `BottleTimerState` enum. "bottle_status" + /* 0x1020 */ OSTime bottleTimerStartOsTimes[BOTTLE_MAX]; // The osTime when the timer starts. "bottle_ostime" + /* 0x1050 */ u64 bottleTimerTimeLimits[BOTTLE_MAX]; // The original total time given before the timer expires, in centiseconds (1/100th sec). "bottle_sub" + /* 0x1080 */ u64 bottleTimerCurTimes[BOTTLE_MAX]; // The remaining time left before the timer expires, in centiseconds (1/100th sec). "bottle_time" + /* 0x10B0 */ OSTime bottleTimerPausedOsTimes[BOTTLE_MAX]; // The cumulative osTime spent with the timer paused. "bottle_stop_time" + /* 0x10E0 */ u8 pictoPhotoI5[PICTO_PHOTO_COMPRESSED_SIZE]; // buffer containing the pictograph photo, compressed to I5 from I8 /* 0x3CA0 */ s32 fileNum; // "file_no" /* 0x3CA4 */ s16 powderKegTimer; // "big_bom_timer" /* 0x3CA6 */ u8 unk_3CA6; /* 0x3CA7 */ u8 unk_3CA7; // "day_night_flag" /* 0x3CA8 */ s32 gameMode; // "mode" - /* 0x3CAC */ s32 sceneSetupIndex; // "counter" + /* 0x3CAC */ s32 sceneLayer; // "counter" /* 0x3CB0 */ s32 respawnFlag; // "restart_flag" /* 0x3CB4 */ RespawnData respawn[RESPAWN_MODE_MAX]; // "restart_data" /* 0x3DB4 */ f32 entranceSpeed; // "player_wipe_speedF" /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" /* 0x3DBB */ u8 unk_3DBB; // "next_walk" - /* 0x3DBC */ u16 dogParams; // "dog_flag" - /* 0x3DBE */ u8 textTriggerFlags; // "guide_status" + /* 0x3DBC */ s16 dogParams; // "dog_flag" + /* 0x3DBE */ u8 envHazardTextTriggerFlags; // "guide_status" /* 0x3DBF */ u8 showTitleCard; // "name_display" /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" /* 0x3DC2 */ u8 unk_3DC2; // "pad1" - /* 0x3DC8 */ OSTime unk_3DC8; // "get_time" - /* 0x3DD0 */ u8 unk_3DD0[7]; // "event_fg" - /* 0x3DD7 */ u8 unk_3DD7[7]; // "calc_flag" - /* 0x3DE0 */ OSTime unk_3DE0[7]; // "event_ostime" - /* 0x3E18 */ OSTime unk_3E18[7]; // "event_sub" - /* 0x3E50 */ OSTime unk_3E50[7]; // "func_time" - /* 0x3E88 */ OSTime unk_3E88[7]; // "func_end_time" - /* 0x3EC0 */ OSTime unk_3EC0[7]; // "func_stop_time" - /* 0x3EF8 */ s16 timerX[7]; // "event_xp" - /* 0x3F06 */ s16 timerY[7]; // "event_yp" + /* 0x3DC8 */ OSTime postmanTimerStopOsTime; // The osTime when the timer stops for the postman minigame. "get_time" + /* 0x3DD0 */ u8 timerStates[TIMER_ID_MAX]; // See the `TimerState` enum. "event_fg" + /* 0x3DD7 */ u8 timerDirections[TIMER_ID_MAX]; // See the `TimerDirection` enum. "calc_flag" + /* 0x3DE0 */ u64 timerCurTimes[TIMER_ID_MAX]; // For countdown, the remaining time left. For countup, the time since the start. In centiseconds (1/100th sec). "event_ostime" + /* 0x3E18 */ u64 timerTimeLimits[TIMER_ID_MAX]; // The original total time given for the timer to count from, in centiseconds (1/100th sec). "event_sub" + /* 0x3E50 */ OSTime timerStartOsTimes[TIMER_ID_MAX]; // The osTime when the timer starts. "func_time" + /* 0x3E88 */ u64 timerStopTimes[TIMER_ID_MAX]; // The total amount of time taken between the start and end of the timer, in centiseconds (1/100th sec). "func_end_time" + /* 0x3EC0 */ OSTime timerPausedOsTimes[TIMER_ID_MAX]; // The cumulative osTime spent with the timer paused. "func_stop_time" + /* 0x3EF8 */ s16 timerX[TIMER_ID_MAX]; // "event_xp" + /* 0x3F06 */ s16 timerY[TIMER_ID_MAX]; // "event_yp" /* 0x3F14 */ s16 unk_3F14; // "character_change" - /* 0x3F16 */ u8 seqIndex; // "old_bgm" - /* 0x3F17 */ u8 nightSeqIndex; // "old_env" + /* 0x3F16 */ u8 seqId; // "old_bgm" + /* 0x3F17 */ u8 ambienceId; // "old_env" /* 0x3F18 */ u8 buttonStatus[6]; // "button_item" - /* 0x3F1E */ u8 unk_3F1E; // "ck_fg" - /* 0x3F20 */ u16 unk_3F20; // "alpha_type" - /* 0x3F22 */ u16 unk_3F22; // "prev_alpha_type" - /* 0x3F24 */ u16 unk_3F24; // "alpha_count" - /* 0x3F26 */ u16 unk_3F26; // "last_time_type" - /* 0x3F28 */ s16 unk_3F28; // "magic_flag" - /* 0x3F2A */ s16 unk_3F2A; // "recovery_magic_flag" - /* 0x3F2C */ s16 unk_3F2C; // "keep_magic_flag" - /* 0x3F2E */ s16 unk_3F2E; // "magic_now_max" - /* 0x3F30 */ s16 unk_3F30; // "magic_now_now" - /* 0x3F32 */ s16 unk_3F32; // "magic_used" - /* 0x3F34 */ s16 unk_3F34; // "magic_recovery" + /* 0x3F1E */ u8 hudVisibilityForceButtonAlphasByStatus; // if btn alphas are updated through Interface_UpdateButtonAlphas, instead update them through Interface_UpdateButtonAlphasByStatus "ck_fg" + /* 0x3F20 */ u16 nextHudVisibility; // triggers the hud to change visibility to the requested value. Reset to HUD_VISIBILITY_IDLE when target is reached "alpha_type" + /* 0x3F22 */ u16 hudVisibility; // current hud visibility "prev_alpha_type" + /* 0x3F24 */ u16 hudVisibilityTimer; // number of frames in the transition to a new hud visibility. Used to step alpha "alpha_count" + /* 0x3F26 */ u16 prevHudVisibility; // used to store and recover hud visibility for pause menu and text boxes "last_time_type" + /* 0x3F28 */ s16 magicState; // determines magic meter behavior on each frame "magic_flag" + /* 0x3F2A */ s16 isMagicRequested; // a request to add magic has been given "recovery_magic_flag" + /* 0x3F2C */ s16 magicFlag; // Set to 0 in func_80812D94(), otherwise unused "keep_magic_flag" + /* 0x3F2E */ s16 magicCapacity; // maximum magic available "magic_now_max" + /* 0x3F30 */ s16 magicFillTarget; // target used to fill magic "magic_now_now" + /* 0x3F32 */ s16 magicToConsume; // accumulated magic that is requested to be consumed "magic_used" + /* 0x3F34 */ s16 magicToAdd; // accumulated magic that is requested to be added "magic_recovery" /* 0x3F36 */ u16 mapIndex; // "scene_ID" - /* 0x3F38 */ u16 minigameState; // "yabusame_mode" + /* 0x3F38 */ u16 minigameStatus; // "yabusame_mode" /* 0x3F3A */ u16 minigameScore; // "yabusame_total" - /* 0x3F3C */ u16 unk_3F3C; // "yabusame_out_ct" + /* 0x3F3C */ u16 minigameHiddenScore; // "yabusame_out_ct" /* 0x3F3E */ u8 unk_3F3E; // "no_save" /* 0x3F3F */ u8 unk_3F3F; // "flash_flag" /* 0x3F40 */ SaveOptions options; /* 0x3F46 */ u16 unk_3F46; // "NottoriBgm" - /* 0x3F48 */ u8 unk_3F48; // "fade_go" + /* 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,8 +390,8 @@ 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" - /* 0x48CA */ u8 maskMaskBit[27]; // "mask_mask_bit", masks given away on the Moon + /* 0x48C8 */ u16 dungeonIndex; // "scene_id_mix" + /* 0x48CA */ u8 masksGivenOnMoon[27]; // bit-packed, masks given away on the Moon. "mask_mask_bit" } SaveContext; // size = 0x48C8 typedef enum ButtonStatus { @@ -273,25 +406,1129 @@ 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) + +// The day begins at CLOCK_TIME(6, 0) so it must be offset. +#define TIME_UNTIL_MOON_CRASH \ + ((4 - CURRENT_DAY) * DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0))); +#define TIME_UNTIL_NEW_DAY (DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0))); + +#define GET_PLAYER_FORM ((void)0, gSaveContext.save.playerForm) + +#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 C_BTN_ITEM(btn) \ + ((gSaveContext.buttonStatus[(btn)] != BTN_DISABLED) \ + ? BUTTON_ITEM_EQUIP(0, (btn)) \ + : ((gSaveContext.hudVisibility == HUD_VISIBILITY_A_B_C) ? BUTTON_ITEM_EQUIP(0, (btn)) : ITEM_NONE)) + +#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)) + +/** + * gSaveContext.save.weekEventReg + */ + +#define PACK_WEEKEVENTREG_FLAG(index, mask) (((index) << 8) | (mask)) + +#define WEEKEVENTREG_00_01 PACK_WEEKEVENTREG_FLAG(0, 0x01) +#define WEEKEVENTREG_00_02 PACK_WEEKEVENTREG_FLAG(0, 0x02) +#define WEEKEVENTREG_00_04 PACK_WEEKEVENTREG_FLAG(0, 0x04) +#define WEEKEVENTREG_00_08 PACK_WEEKEVENTREG_FLAG(0, 0x08) +#define WEEKEVENTREG_00_10 PACK_WEEKEVENTREG_FLAG(0, 0x10) +#define WEEKEVENTREG_00_20 PACK_WEEKEVENTREG_FLAG(0, 0x20) +#define WEEKEVENTREG_00_40 PACK_WEEKEVENTREG_FLAG(0, 0x40) +#define WEEKEVENTREG_00_80 PACK_WEEKEVENTREG_FLAG(0, 0x80) +#define WEEKEVENTREG_01_01 PACK_WEEKEVENTREG_FLAG(1, 0x01) +#define WEEKEVENTREG_01_02 PACK_WEEKEVENTREG_FLAG(1, 0x02) +#define WEEKEVENTREG_01_04 PACK_WEEKEVENTREG_FLAG(1, 0x04) +#define WEEKEVENTREG_01_08 PACK_WEEKEVENTREG_FLAG(1, 0x08) +#define WEEKEVENTREG_01_10 PACK_WEEKEVENTREG_FLAG(1, 0x10) +#define WEEKEVENTREG_01_20 PACK_WEEKEVENTREG_FLAG(1, 0x20) +#define WEEKEVENTREG_01_40 PACK_WEEKEVENTREG_FLAG(1, 0x40) +#define WEEKEVENTREG_01_80 PACK_WEEKEVENTREG_FLAG(1, 0x80) +#define WEEKEVENTREG_02_01 PACK_WEEKEVENTREG_FLAG(2, 0x01) +#define WEEKEVENTREG_02_02 PACK_WEEKEVENTREG_FLAG(2, 0x02) +#define WEEKEVENTREG_02_04 PACK_WEEKEVENTREG_FLAG(2, 0x04) +#define WEEKEVENTREG_02_08 PACK_WEEKEVENTREG_FLAG(2, 0x08) +#define WEEKEVENTREG_02_10 PACK_WEEKEVENTREG_FLAG(2, 0x10) +#define WEEKEVENTREG_02_20 PACK_WEEKEVENTREG_FLAG(2, 0x20) +#define WEEKEVENTREG_02_40 PACK_WEEKEVENTREG_FLAG(2, 0x40) +#define WEEKEVENTREG_02_80 PACK_WEEKEVENTREG_FLAG(2, 0x80) +#define WEEKEVENTREG_03_01 PACK_WEEKEVENTREG_FLAG(3, 0x01) +#define WEEKEVENTREG_03_02 PACK_WEEKEVENTREG_FLAG(3, 0x02) +#define WEEKEVENTREG_03_04 PACK_WEEKEVENTREG_FLAG(3, 0x04) +#define WEEKEVENTREG_03_08 PACK_WEEKEVENTREG_FLAG(3, 0x08) +#define WEEKEVENTREG_03_10 PACK_WEEKEVENTREG_FLAG(3, 0x10) +#define WEEKEVENTREG_03_20 PACK_WEEKEVENTREG_FLAG(3, 0x20) +#define WEEKEVENTREG_03_40 PACK_WEEKEVENTREG_FLAG(3, 0x40) +#define WEEKEVENTREG_03_80 PACK_WEEKEVENTREG_FLAG(3, 0x80) +#define WEEKEVENTREG_04_01 PACK_WEEKEVENTREG_FLAG(4, 0x01) +#define WEEKEVENTREG_04_02 PACK_WEEKEVENTREG_FLAG(4, 0x02) +#define WEEKEVENTREG_04_04 PACK_WEEKEVENTREG_FLAG(4, 0x04) +#define WEEKEVENTREG_04_08 PACK_WEEKEVENTREG_FLAG(4, 0x08) +#define WEEKEVENTREG_04_10 PACK_WEEKEVENTREG_FLAG(4, 0x10) +#define WEEKEVENTREG_04_20 PACK_WEEKEVENTREG_FLAG(4, 0x20) +#define WEEKEVENTREG_04_40 PACK_WEEKEVENTREG_FLAG(4, 0x40) +#define WEEKEVENTREG_04_80 PACK_WEEKEVENTREG_FLAG(4, 0x80) +#define WEEKEVENTREG_05_01 PACK_WEEKEVENTREG_FLAG(5, 0x01) +#define WEEKEVENTREG_05_02 PACK_WEEKEVENTREG_FLAG(5, 0x02) +#define WEEKEVENTREG_05_04 PACK_WEEKEVENTREG_FLAG(5, 0x04) +#define WEEKEVENTREG_05_08 PACK_WEEKEVENTREG_FLAG(5, 0x08) +#define WEEKEVENTREG_05_10 PACK_WEEKEVENTREG_FLAG(5, 0x10) +#define WEEKEVENTREG_05_20 PACK_WEEKEVENTREG_FLAG(5, 0x20) +#define WEEKEVENTREG_05_40 PACK_WEEKEVENTREG_FLAG(5, 0x40) +#define WEEKEVENTREG_05_80 PACK_WEEKEVENTREG_FLAG(5, 0x80) +#define WEEKEVENTREG_06_01 PACK_WEEKEVENTREG_FLAG(6, 0x01) +#define WEEKEVENTREG_06_02 PACK_WEEKEVENTREG_FLAG(6, 0x02) +#define WEEKEVENTREG_06_04 PACK_WEEKEVENTREG_FLAG(6, 0x04) +#define WEEKEVENTREG_06_08 PACK_WEEKEVENTREG_FLAG(6, 0x08) +#define WEEKEVENTREG_06_10 PACK_WEEKEVENTREG_FLAG(6, 0x10) +#define WEEKEVENTREG_06_20 PACK_WEEKEVENTREG_FLAG(6, 0x20) +#define WEEKEVENTREG_06_40 PACK_WEEKEVENTREG_FLAG(6, 0x40) +#define WEEKEVENTREG_06_80 PACK_WEEKEVENTREG_FLAG(6, 0x80) +#define WEEKEVENTREG_07_01 PACK_WEEKEVENTREG_FLAG(7, 0x01) +#define WEEKEVENTREG_07_02 PACK_WEEKEVENTREG_FLAG(7, 0x02) +#define WEEKEVENTREG_07_04 PACK_WEEKEVENTREG_FLAG(7, 0x04) +#define WEEKEVENTREG_07_08 PACK_WEEKEVENTREG_FLAG(7, 0x08) +#define WEEKEVENTREG_07_10 PACK_WEEKEVENTREG_FLAG(7, 0x10) +#define WEEKEVENTREG_07_20 PACK_WEEKEVENTREG_FLAG(7, 0x20) +#define WEEKEVENTREG_07_40 PACK_WEEKEVENTREG_FLAG(7, 0x40) +#define WEEKEVENTREG_07_80 PACK_WEEKEVENTREG_FLAG(7, 0x80) +#define WEEKEVENTREG_08_01 PACK_WEEKEVENTREG_FLAG(8, 0x01) +#define WEEKEVENTREG_08_02 PACK_WEEKEVENTREG_FLAG(8, 0x02) +#define WEEKEVENTREG_08_04 PACK_WEEKEVENTREG_FLAG(8, 0x04) +#define WEEKEVENTREG_08_08 PACK_WEEKEVENTREG_FLAG(8, 0x08) +#define WEEKEVENTREG_08_10 PACK_WEEKEVENTREG_FLAG(8, 0x10) +#define WEEKEVENTREG_08_20 PACK_WEEKEVENTREG_FLAG(8, 0x20) +#define WEEKEVENTREG_08_40 PACK_WEEKEVENTREG_FLAG(8, 0x40) +#define WEEKEVENTREG_08_80 PACK_WEEKEVENTREG_FLAG(8, 0x80) +#define WEEKEVENTREG_09_01 PACK_WEEKEVENTREG_FLAG(9, 0x01) +#define WEEKEVENTREG_09_02 PACK_WEEKEVENTREG_FLAG(9, 0x02) +#define WEEKEVENTREG_09_04 PACK_WEEKEVENTREG_FLAG(9, 0x04) +#define WEEKEVENTREG_09_08 PACK_WEEKEVENTREG_FLAG(9, 0x08) +#define WEEKEVENTREG_09_10 PACK_WEEKEVENTREG_FLAG(9, 0x10) +#define WEEKEVENTREG_09_20 PACK_WEEKEVENTREG_FLAG(9, 0x20) +#define WEEKEVENTREG_09_40 PACK_WEEKEVENTREG_FLAG(9, 0x40) +#define WEEKEVENTREG_09_80 PACK_WEEKEVENTREG_FLAG(9, 0x80) +#define WEEKEVENTREG_10_01 PACK_WEEKEVENTREG_FLAG(10, 0x01) +#define WEEKEVENTREG_10_02 PACK_WEEKEVENTREG_FLAG(10, 0x02) +#define WEEKEVENTREG_10_04 PACK_WEEKEVENTREG_FLAG(10, 0x04) +#define WEEKEVENTREG_10_08 PACK_WEEKEVENTREG_FLAG(10, 0x08) +#define WEEKEVENTREG_10_10 PACK_WEEKEVENTREG_FLAG(10, 0x10) +#define WEEKEVENTREG_10_20 PACK_WEEKEVENTREG_FLAG(10, 0x20) +#define WEEKEVENTREG_10_40 PACK_WEEKEVENTREG_FLAG(10, 0x40) +#define WEEKEVENTREG_10_80 PACK_WEEKEVENTREG_FLAG(10, 0x80) +#define WEEKEVENTREG_11_01 PACK_WEEKEVENTREG_FLAG(11, 0x01) +#define WEEKEVENTREG_11_02 PACK_WEEKEVENTREG_FLAG(11, 0x02) +#define WEEKEVENTREG_11_04 PACK_WEEKEVENTREG_FLAG(11, 0x04) +#define WEEKEVENTREG_11_08 PACK_WEEKEVENTREG_FLAG(11, 0x08) +#define WEEKEVENTREG_11_10 PACK_WEEKEVENTREG_FLAG(11, 0x10) +#define WEEKEVENTREG_11_20 PACK_WEEKEVENTREG_FLAG(11, 0x20) +#define WEEKEVENTREG_11_40 PACK_WEEKEVENTREG_FLAG(11, 0x40) +#define WEEKEVENTREG_11_80 PACK_WEEKEVENTREG_FLAG(11, 0x80) + +// woodfall temple wood flower opened +#define WEEKEVENTREG_12_01 PACK_WEEKEVENTREG_FLAG(12, 0x01) + +#define WEEKEVENTREG_12_02 PACK_WEEKEVENTREG_FLAG(12, 0x02) +#define WEEKEVENTREG_12_04 PACK_WEEKEVENTREG_FLAG(12, 0x04) +#define WEEKEVENTREG_12_08 PACK_WEEKEVENTREG_FLAG(12, 0x08) +#define WEEKEVENTREG_12_10 PACK_WEEKEVENTREG_FLAG(12, 0x10) +#define WEEKEVENTREG_12_20 PACK_WEEKEVENTREG_FLAG(12, 0x20) +#define WEEKEVENTREG_12_40 PACK_WEEKEVENTREG_FLAG(12, 0x40) +#define WEEKEVENTREG_12_80 PACK_WEEKEVENTREG_FLAG(12, 0x80) +#define WEEKEVENTREG_13_01 PACK_WEEKEVENTREG_FLAG(13, 0x01) +#define WEEKEVENTREG_13_02 PACK_WEEKEVENTREG_FLAG(13, 0x02) +#define WEEKEVENTREG_13_04 PACK_WEEKEVENTREG_FLAG(13, 0x04) +#define WEEKEVENTREG_13_08 PACK_WEEKEVENTREG_FLAG(13, 0x08) +#define WEEKEVENTREG_13_10 PACK_WEEKEVENTREG_FLAG(13, 0x10) +#define WEEKEVENTREG_13_20 PACK_WEEKEVENTREG_FLAG(13, 0x20) +#define WEEKEVENTREG_13_40 PACK_WEEKEVENTREG_FLAG(13, 0x40) +#define WEEKEVENTREG_13_80 PACK_WEEKEVENTREG_FLAG(13, 0x80) + +// PlayedMilkMinigame +// Attempted Cremia Cart Ride +#define WEEKEVENTREG_14_01 PACK_WEEKEVENTREG_FLAG(14, 0x01) + +#define WEEKEVENTREG_14_02 PACK_WEEKEVENTREG_FLAG(14, 0x02) +#define WEEKEVENTREG_14_04 PACK_WEEKEVENTREG_FLAG(14, 0x04) +#define WEEKEVENTREG_DRANK_CHATEAU_ROMANI PACK_WEEKEVENTREG_FLAG(14, 0x08) +#define WEEKEVENTREG_14_10 PACK_WEEKEVENTREG_FLAG(14, 0x10) +#define WEEKEVENTREG_14_20 PACK_WEEKEVENTREG_FLAG(14, 0x20) +#define WEEKEVENTREG_14_40 PACK_WEEKEVENTREG_FLAG(14, 0x40) +#define WEEKEVENTREG_14_80 PACK_WEEKEVENTREG_FLAG(14, 0x80) +#define WEEKEVENTREG_15_01 PACK_WEEKEVENTREG_FLAG(15, 0x01) +#define WEEKEVENTREG_15_02 PACK_WEEKEVENTREG_FLAG(15, 0x02) +#define WEEKEVENTREG_15_04 PACK_WEEKEVENTREG_FLAG(15, 0x04) +#define WEEKEVENTREG_15_08 PACK_WEEKEVENTREG_FLAG(15, 0x08) +#define WEEKEVENTREG_15_10 PACK_WEEKEVENTREG_FLAG(15, 0x10) +#define WEEKEVENTREG_15_20 PACK_WEEKEVENTREG_FLAG(15, 0x20) +#define WEEKEVENTREG_15_40 PACK_WEEKEVENTREG_FLAG(15, 0x40) +#define WEEKEVENTREG_15_80 PACK_WEEKEVENTREG_FLAG(15, 0x80) +#define WEEKEVENTREG_16_01 PACK_WEEKEVENTREG_FLAG(16, 0x01) +#define WEEKEVENTREG_16_02 PACK_WEEKEVENTREG_FLAG(16, 0x02) +#define WEEKEVENTREG_16_04 PACK_WEEKEVENTREG_FLAG(16, 0x04) +#define WEEKEVENTREG_16_08 PACK_WEEKEVENTREG_FLAG(16, 0x08) +#define WEEKEVENTREG_16_10 PACK_WEEKEVENTREG_FLAG(16, 0x10) +#define WEEKEVENTREG_16_20 PACK_WEEKEVENTREG_FLAG(16, 0x20) +#define WEEKEVENTREG_16_40 PACK_WEEKEVENTREG_FLAG(16, 0x40) +#define WEEKEVENTREG_16_80 PACK_WEEKEVENTREG_FLAG(16, 0x80) +#define WEEKEVENTREG_17_01 PACK_WEEKEVENTREG_FLAG(17, 0x01) +#define WEEKEVENTREG_17_02 PACK_WEEKEVENTREG_FLAG(17, 0x02) +#define WEEKEVENTREG_17_04 PACK_WEEKEVENTREG_FLAG(17, 0x04) +#define WEEKEVENTREG_17_08 PACK_WEEKEVENTREG_FLAG(17, 0x08) +#define WEEKEVENTREG_17_10 PACK_WEEKEVENTREG_FLAG(17, 0x10) +#define WEEKEVENTREG_17_20 PACK_WEEKEVENTREG_FLAG(17, 0x20) +#define WEEKEVENTREG_17_40 PACK_WEEKEVENTREG_FLAG(17, 0x40) +#define WEEKEVENTREG_17_80 PACK_WEEKEVENTREG_FLAG(17, 0x80) +#define WEEKEVENTREG_18_01 PACK_WEEKEVENTREG_FLAG(18, 0x01) +#define WEEKEVENTREG_18_02 PACK_WEEKEVENTREG_FLAG(18, 0x02) +#define WEEKEVENTREG_18_04 PACK_WEEKEVENTREG_FLAG(18, 0x04) +#define WEEKEVENTREG_18_08 PACK_WEEKEVENTREG_FLAG(18, 0x08) +#define WEEKEVENTREG_18_10 PACK_WEEKEVENTREG_FLAG(18, 0x10) +#define WEEKEVENTREG_18_20 PACK_WEEKEVENTREG_FLAG(18, 0x20) +#define WEEKEVENTREG_18_40 PACK_WEEKEVENTREG_FLAG(18, 0x40) +#define WEEKEVENTREG_18_80 PACK_WEEKEVENTREG_FLAG(18, 0x80) +#define WEEKEVENTREG_19_01 PACK_WEEKEVENTREG_FLAG(19, 0x01) +#define WEEKEVENTREG_19_02 PACK_WEEKEVENTREG_FLAG(19, 0x02) +#define WEEKEVENTREG_19_04 PACK_WEEKEVENTREG_FLAG(19, 0x04) +#define WEEKEVENTREG_19_08 PACK_WEEKEVENTREG_FLAG(19, 0x08) +#define WEEKEVENTREG_19_10 PACK_WEEKEVENTREG_FLAG(19, 0x10) +#define WEEKEVENTREG_19_20 PACK_WEEKEVENTREG_FLAG(19, 0x20) +#define WEEKEVENTREG_19_40 PACK_WEEKEVENTREG_FLAG(19, 0x40) +#define WEEKEVENTREG_19_80 PACK_WEEKEVENTREG_FLAG(19, 0x80) +#define WEEKEVENTREG_20_01 PACK_WEEKEVENTREG_FLAG(20, 0x01) + +// woodfall temple purification cutscene watched +#define WEEKEVENTREG_20_02 PACK_WEEKEVENTREG_FLAG(20, 0x02) + +#define WEEKEVENTREG_20_04 PACK_WEEKEVENTREG_FLAG(20, 0x04) +#define WEEKEVENTREG_20_08 PACK_WEEKEVENTREG_FLAG(20, 0x08) +#define WEEKEVENTREG_20_10 PACK_WEEKEVENTREG_FLAG(20, 0x10) +#define WEEKEVENTREG_20_20 PACK_WEEKEVENTREG_FLAG(20, 0x20) +#define WEEKEVENTREG_20_40 PACK_WEEKEVENTREG_FLAG(20, 0x40) +#define WEEKEVENTREG_20_80 PACK_WEEKEVENTREG_FLAG(20, 0x80) +#define WEEKEVENTREG_21_01 PACK_WEEKEVENTREG_FLAG(21, 0x01) +#define WEEKEVENTREG_21_02 PACK_WEEKEVENTREG_FLAG(21, 0x02) +#define WEEKEVENTREG_21_04 PACK_WEEKEVENTREG_FLAG(21, 0x04) +#define WEEKEVENTREG_21_08 PACK_WEEKEVENTREG_FLAG(21, 0x08) +#define WEEKEVENTREG_21_10 PACK_WEEKEVENTREG_FLAG(21, 0x10) +#define WEEKEVENTREG_21_20 PACK_WEEKEVENTREG_FLAG(21, 0x20) +#define WEEKEVENTREG_21_40 PACK_WEEKEVENTREG_FLAG(21, 0x40) +#define WEEKEVENTREG_21_80 PACK_WEEKEVENTREG_FLAG(21, 0x80) + +// Aliens defeated +// "Winning" the alien invasion +#define WEEKEVENTREG_22_01 PACK_WEEKEVENTREG_FLAG(22, 0x01) + +#define WEEKEVENTREG_22_02 PACK_WEEKEVENTREG_FLAG(22, 0x02) +#define WEEKEVENTREG_22_04 PACK_WEEKEVENTREG_FLAG(22, 0x04) +#define WEEKEVENTREG_22_08 PACK_WEEKEVENTREG_FLAG(22, 0x08) +#define WEEKEVENTREG_22_10 PACK_WEEKEVENTREG_FLAG(22, 0x10) +#define WEEKEVENTREG_22_20 PACK_WEEKEVENTREG_FLAG(22, 0x20) +#define WEEKEVENTREG_22_40 PACK_WEEKEVENTREG_FLAG(22, 0x40) +#define WEEKEVENTREG_22_80 PACK_WEEKEVENTREG_FLAG(22, 0x80) +#define WEEKEVENTREG_23_01 PACK_WEEKEVENTREG_FLAG(23, 0x01) +#define WEEKEVENTREG_23_02 PACK_WEEKEVENTREG_FLAG(23, 0x02) +#define WEEKEVENTREG_23_04 PACK_WEEKEVENTREG_FLAG(23, 0x04) +#define WEEKEVENTREG_23_08 PACK_WEEKEVENTREG_FLAG(23, 0x08) +#define WEEKEVENTREG_23_10 PACK_WEEKEVENTREG_FLAG(23, 0x10) +#define WEEKEVENTREG_23_20 PACK_WEEKEVENTREG_FLAG(23, 0x20) +#define WEEKEVENTREG_23_40 PACK_WEEKEVENTREG_FLAG(23, 0x40) +#define WEEKEVENTREG_23_80 PACK_WEEKEVENTREG_FLAG(23, 0x80) +#define WEEKEVENTREG_24_01 PACK_WEEKEVENTREG_FLAG(24, 0x01) +#define WEEKEVENTREG_24_02 PACK_WEEKEVENTREG_FLAG(24, 0x02) +#define WEEKEVENTREG_24_04 PACK_WEEKEVENTREG_FLAG(24, 0x04) +#define WEEKEVENTREG_24_08 PACK_WEEKEVENTREG_FLAG(24, 0x08) + +// The player has already talked as a Goron at least once to Goron elder +#define WEEKEVENTREG_24_10 PACK_WEEKEVENTREG_FLAG(24, 0x10) + +// The player has already talked as a non-Goron at least once +#define WEEKEVENTREG_24_20 PACK_WEEKEVENTREG_FLAG(24, 0x20) + +#define WEEKEVENTREG_24_40 PACK_WEEKEVENTREG_FLAG(24, 0x40) + +// The player has talked to the Goron Child at least once +#define WEEKEVENTREG_24_80 PACK_WEEKEVENTREG_FLAG(24, 0x80) + +#define WEEKEVENTREG_25_01 PACK_WEEKEVENTREG_FLAG(25, 0x01) +#define WEEKEVENTREG_25_02 PACK_WEEKEVENTREG_FLAG(25, 0x02) +#define WEEKEVENTREG_25_04 PACK_WEEKEVENTREG_FLAG(25, 0x04) + +// breman mask was already used +#define WEEKEVENTREG_25_08 PACK_WEEKEVENTREG_FLAG(25, 0x08) + +#define WEEKEVENTREG_25_10 PACK_WEEKEVENTREG_FLAG(25, 0x10) +#define WEEKEVENTREG_25_20 PACK_WEEKEVENTREG_FLAG(25, 0x20) +#define WEEKEVENTREG_25_40 PACK_WEEKEVENTREG_FLAG(25, 0x40) +#define WEEKEVENTREG_25_80 PACK_WEEKEVENTREG_FLAG(25, 0x80) +#define WEEKEVENTREG_26_01 PACK_WEEKEVENTREG_FLAG(26, 0x01) +#define WEEKEVENTREG_26_02 PACK_WEEKEVENTREG_FLAG(26, 0x02) +#define WEEKEVENTREG_26_04 PACK_WEEKEVENTREG_FLAG(26, 0x04) +#define WEEKEVENTREG_26_08 PACK_WEEKEVENTREG_FLAG(26, 0x08) +#define WEEKEVENTREG_26_10 PACK_WEEKEVENTREG_FLAG(26, 0x10) +#define WEEKEVENTREG_26_20 PACK_WEEKEVENTREG_FLAG(26, 0x20) +#define WEEKEVENTREG_26_40 PACK_WEEKEVENTREG_FLAG(26, 0x40) +#define WEEKEVENTREG_26_80 PACK_WEEKEVENTREG_FLAG(26, 0x80) +#define WEEKEVENTREG_27_01 PACK_WEEKEVENTREG_FLAG(27, 0x01) +#define WEEKEVENTREG_27_02 PACK_WEEKEVENTREG_FLAG(27, 0x02) +#define WEEKEVENTREG_27_04 PACK_WEEKEVENTREG_FLAG(27, 0x04) +#define WEEKEVENTREG_27_08 PACK_WEEKEVENTREG_FLAG(27, 0x08) +#define WEEKEVENTREG_27_10 PACK_WEEKEVENTREG_FLAG(27, 0x10) +#define WEEKEVENTREG_27_20 PACK_WEEKEVENTREG_FLAG(27, 0x20) +#define WEEKEVENTREG_27_40 PACK_WEEKEVENTREG_FLAG(27, 0x40) +#define WEEKEVENTREG_27_80 PACK_WEEKEVENTREG_FLAG(27, 0x80) +#define WEEKEVENTREG_28_01 PACK_WEEKEVENTREG_FLAG(28, 0x01) +#define WEEKEVENTREG_28_02 PACK_WEEKEVENTREG_FLAG(28, 0x02) +#define WEEKEVENTREG_28_04 PACK_WEEKEVENTREG_FLAG(28, 0x04) +#define WEEKEVENTREG_28_08 PACK_WEEKEVENTREG_FLAG(28, 0x08) +#define WEEKEVENTREG_28_10 PACK_WEEKEVENTREG_FLAG(28, 0x10) +#define WEEKEVENTREG_28_20 PACK_WEEKEVENTREG_FLAG(28, 0x20) +#define WEEKEVENTREG_28_40 PACK_WEEKEVENTREG_FLAG(28, 0x40) +#define WEEKEVENTREG_28_80 PACK_WEEKEVENTREG_FLAG(28, 0x80) +#define WEEKEVENTREG_29_01 PACK_WEEKEVENTREG_FLAG(29, 0x01) +#define WEEKEVENTREG_29_02 PACK_WEEKEVENTREG_FLAG(29, 0x02) +#define WEEKEVENTREG_29_04 PACK_WEEKEVENTREG_FLAG(29, 0x04) +#define WEEKEVENTREG_29_08 PACK_WEEKEVENTREG_FLAG(29, 0x08) +#define WEEKEVENTREG_29_10 PACK_WEEKEVENTREG_FLAG(29, 0x10) +#define WEEKEVENTREG_29_20 PACK_WEEKEVENTREG_FLAG(29, 0x20) +#define WEEKEVENTREG_29_40 PACK_WEEKEVENTREG_FLAG(29, 0x40) +#define WEEKEVENTREG_29_80 PACK_WEEKEVENTREG_FLAG(29, 0x80) +#define WEEKEVENTREG_30_01 PACK_WEEKEVENTREG_FLAG(30, 0x01) +#define WEEKEVENTREG_30_02 PACK_WEEKEVENTREG_FLAG(30, 0x02) +#define WEEKEVENTREG_30_04 PACK_WEEKEVENTREG_FLAG(30, 0x04) +#define WEEKEVENTREG_30_08 PACK_WEEKEVENTREG_FLAG(30, 0x08) +#define WEEKEVENTREG_30_10 PACK_WEEKEVENTREG_FLAG(30, 0x10) +#define WEEKEVENTREG_30_20 PACK_WEEKEVENTREG_FLAG(30, 0x20) +#define WEEKEVENTREG_30_40 PACK_WEEKEVENTREG_FLAG(30, 0x40) +#define WEEKEVENTREG_30_80 PACK_WEEKEVENTREG_FLAG(30, 0x80) +#define WEEKEVENTREG_31_01 PACK_WEEKEVENTREG_FLAG(31, 0x01) +#define WEEKEVENTREG_31_02 PACK_WEEKEVENTREG_FLAG(31, 0x02) + +// Unconfirmed: "Tatl's Second Cycle Text?" +#define WEEKEVENTREG_31_04 PACK_WEEKEVENTREG_FLAG(31, 0x04) + +#define WEEKEVENTREG_31_08 PACK_WEEKEVENTREG_FLAG(31, 0x08) +#define WEEKEVENTREG_31_10 PACK_WEEKEVENTREG_FLAG(31, 0x10) +#define WEEKEVENTREG_31_20 PACK_WEEKEVENTREG_FLAG(31, 0x20) + +// Cremia asked the player to accompany her to town +#define WEEKEVENTREG_31_40 PACK_WEEKEVENTREG_FLAG(31, 0x40) +// Player is playing the Milk Run +#define WEEKEVENTREG_31_80 PACK_WEEKEVENTREG_FLAG(31, 0x80) + +#define WEEKEVENTREG_32_01 PACK_WEEKEVENTREG_FLAG(32, 0x01) +#define WEEKEVENTREG_32_02 PACK_WEEKEVENTREG_FLAG(32, 0x02) +#define WEEKEVENTREG_32_04 PACK_WEEKEVENTREG_FLAG(32, 0x04) +#define WEEKEVENTREG_32_08 PACK_WEEKEVENTREG_FLAG(32, 0x08) +#define WEEKEVENTREG_32_10 PACK_WEEKEVENTREG_FLAG(32, 0x10) +#define WEEKEVENTREG_32_20 PACK_WEEKEVENTREG_FLAG(32, 0x20) + +// Woodfall Temple Frog Returned +#define WEEKEVENTREG_32_40 PACK_WEEKEVENTREG_FLAG(32, 0x40) +// Great Bay Temple Frog Returned +#define WEEKEVENTREG_32_80 PACK_WEEKEVENTREG_FLAG(32, 0x80) +// Southern Swamp Frog Returned +#define WEEKEVENTREG_33_01 PACK_WEEKEVENTREG_FLAG(33, 0x01) +// Laundry Pool Frog Returned +#define WEEKEVENTREG_33_02 PACK_WEEKEVENTREG_FLAG(33, 0x02) + +#define WEEKEVENTREG_33_04 PACK_WEEKEVENTREG_FLAG(33, 0x04) +#define WEEKEVENTREG_33_08 PACK_WEEKEVENTREG_FLAG(33, 0x08) +#define WEEKEVENTREG_33_10 PACK_WEEKEVENTREG_FLAG(33, 0x10) +#define WEEKEVENTREG_33_20 PACK_WEEKEVENTREG_FLAG(33, 0x20) +#define WEEKEVENTREG_33_40 PACK_WEEKEVENTREG_FLAG(33, 0x40) + +// Mountain village is unfrozen +#define WEEKEVENTREG_33_80 PACK_WEEKEVENTREG_FLAG(33, 0x80) +// Spoken to MINIFROG_YELLOW +#define WEEKEVENTREG_34_01 PACK_WEEKEVENTREG_FLAG(34, 0x01) + +#define WEEKEVENTREG_34_02 PACK_WEEKEVENTREG_FLAG(34, 0x02) +#define WEEKEVENTREG_34_04 PACK_WEEKEVENTREG_FLAG(34, 0x04) +#define WEEKEVENTREG_34_08 PACK_WEEKEVENTREG_FLAG(34, 0x08) +#define WEEKEVENTREG_34_10 PACK_WEEKEVENTREG_FLAG(34, 0x10) +#define WEEKEVENTREG_34_20 PACK_WEEKEVENTREG_FLAG(34, 0x20) +#define WEEKEVENTREG_34_40 PACK_WEEKEVENTREG_FLAG(34, 0x40) + +// Cremia did Milk Run alone. Player didn't interact or didn't accept the ride +#define WEEKEVENTREG_34_80 PACK_WEEKEVENTREG_FLAG(34, 0x80) + +#define WEEKEVENTREG_35_01 PACK_WEEKEVENTREG_FLAG(35, 0x01) +#define WEEKEVENTREG_35_02 PACK_WEEKEVENTREG_FLAG(35, 0x02) +#define WEEKEVENTREG_35_04 PACK_WEEKEVENTREG_FLAG(35, 0x04) +#define WEEKEVENTREG_35_08 PACK_WEEKEVENTREG_FLAG(35, 0x08) +#define WEEKEVENTREG_35_10 PACK_WEEKEVENTREG_FLAG(35, 0x10) +#define WEEKEVENTREG_35_20 PACK_WEEKEVENTREG_FLAG(35, 0x20) +#define WEEKEVENTREG_35_40 PACK_WEEKEVENTREG_FLAG(35, 0x40) + +// Obtained Heart Piece from Five Frogs of the Frog Choir +#define WEEKEVENTREG_35_80 PACK_WEEKEVENTREG_FLAG(35, 0x80) + +#define WEEKEVENTREG_36_01 PACK_WEEKEVENTREG_FLAG(36, 0x01) +#define WEEKEVENTREG_36_02 PACK_WEEKEVENTREG_FLAG(36, 0x02) +#define WEEKEVENTREG_36_04 PACK_WEEKEVENTREG_FLAG(36, 0x04) +#define WEEKEVENTREG_36_08 PACK_WEEKEVENTREG_FLAG(36, 0x08) +#define WEEKEVENTREG_36_10 PACK_WEEKEVENTREG_FLAG(36, 0x10) +#define WEEKEVENTREG_36_20 PACK_WEEKEVENTREG_FLAG(36, 0x20) +#define WEEKEVENTREG_36_40 PACK_WEEKEVENTREG_FLAG(36, 0x40) +#define WEEKEVENTREG_36_80 PACK_WEEKEVENTREG_FLAG(36, 0x80) +#define WEEKEVENTREG_37_01 PACK_WEEKEVENTREG_FLAG(37, 0x01) +#define WEEKEVENTREG_37_02 PACK_WEEKEVENTREG_FLAG(37, 0x02) +#define WEEKEVENTREG_37_04 PACK_WEEKEVENTREG_FLAG(37, 0x04) +#define WEEKEVENTREG_37_08 PACK_WEEKEVENTREG_FLAG(37, 0x08) +#define WEEKEVENTREG_37_10 PACK_WEEKEVENTREG_FLAG(37, 0x10) +#define WEEKEVENTREG_37_20 PACK_WEEKEVENTREG_FLAG(37, 0x20) +#define WEEKEVENTREG_37_40 PACK_WEEKEVENTREG_FLAG(37, 0x40) +#define WEEKEVENTREG_37_80 PACK_WEEKEVENTREG_FLAG(37, 0x80) +#define WEEKEVENTREG_38_01 PACK_WEEKEVENTREG_FLAG(38, 0x01) +#define WEEKEVENTREG_38_02 PACK_WEEKEVENTREG_FLAG(38, 0x02) +#define WEEKEVENTREG_38_04 PACK_WEEKEVENTREG_FLAG(38, 0x04) +#define WEEKEVENTREG_38_08 PACK_WEEKEVENTREG_FLAG(38, 0x08) +#define WEEKEVENTREG_38_10 PACK_WEEKEVENTREG_FLAG(38, 0x10) +#define WEEKEVENTREG_38_20 PACK_WEEKEVENTREG_FLAG(38, 0x20) +#define WEEKEVENTREG_38_40 PACK_WEEKEVENTREG_FLAG(38, 0x40) +#define WEEKEVENTREG_38_80 PACK_WEEKEVENTREG_FLAG(38, 0x80) +#define WEEKEVENTREG_39_01 PACK_WEEKEVENTREG_FLAG(39, 0x01) +#define WEEKEVENTREG_39_02 PACK_WEEKEVENTREG_FLAG(39, 0x02) +#define WEEKEVENTREG_39_04 PACK_WEEKEVENTREG_FLAG(39, 0x04) +#define WEEKEVENTREG_39_08 PACK_WEEKEVENTREG_FLAG(39, 0x08) +#define WEEKEVENTREG_39_10 PACK_WEEKEVENTREG_FLAG(39, 0x10) +#define WEEKEVENTREG_39_20 PACK_WEEKEVENTREG_FLAG(39, 0x20) +#define WEEKEVENTREG_39_40 PACK_WEEKEVENTREG_FLAG(39, 0x40) +#define WEEKEVENTREG_39_80 PACK_WEEKEVENTREG_FLAG(39, 0x80) +#define WEEKEVENTREG_40_01 PACK_WEEKEVENTREG_FLAG(40, 0x01) +#define WEEKEVENTREG_40_02 PACK_WEEKEVENTREG_FLAG(40, 0x02) +#define WEEKEVENTREG_40_04 PACK_WEEKEVENTREG_FLAG(40, 0x04) +#define WEEKEVENTREG_40_08 PACK_WEEKEVENTREG_FLAG(40, 0x08) +#define WEEKEVENTREG_40_10 PACK_WEEKEVENTREG_FLAG(40, 0x10) +#define WEEKEVENTREG_40_20 PACK_WEEKEVENTREG_FLAG(40, 0x20) +#define WEEKEVENTREG_40_40 PACK_WEEKEVENTREG_FLAG(40, 0x40) +#define WEEKEVENTREG_40_80 PACK_WEEKEVENTREG_FLAG(40, 0x80) +#define WEEKEVENTREG_41_01 PACK_WEEKEVENTREG_FLAG(41, 0x01) +#define WEEKEVENTREG_41_02 PACK_WEEKEVENTREG_FLAG(41, 0x02) +#define WEEKEVENTREG_41_04 PACK_WEEKEVENTREG_FLAG(41, 0x04) +#define WEEKEVENTREG_41_08 PACK_WEEKEVENTREG_FLAG(41, 0x08) +#define WEEKEVENTREG_41_10 PACK_WEEKEVENTREG_FLAG(41, 0x10) +#define WEEKEVENTREG_41_20 PACK_WEEKEVENTREG_FLAG(41, 0x20) +#define WEEKEVENTREG_41_40 PACK_WEEKEVENTREG_FLAG(41, 0x40) +#define WEEKEVENTREG_41_80 PACK_WEEKEVENTREG_FLAG(41, 0x80) +#define WEEKEVENTREG_42_01 PACK_WEEKEVENTREG_FLAG(42, 0x01) +#define WEEKEVENTREG_42_02 PACK_WEEKEVENTREG_FLAG(42, 0x02) +#define WEEKEVENTREG_42_04 PACK_WEEKEVENTREG_FLAG(42, 0x04) +#define WEEKEVENTREG_42_08 PACK_WEEKEVENTREG_FLAG(42, 0x08) +#define WEEKEVENTREG_42_10 PACK_WEEKEVENTREG_FLAG(42, 0x10) +#define WEEKEVENTREG_42_20 PACK_WEEKEVENTREG_FLAG(42, 0x20) +#define WEEKEVENTREG_42_40 PACK_WEEKEVENTREG_FLAG(42, 0x40) +#define WEEKEVENTREG_42_80 PACK_WEEKEVENTREG_FLAG(42, 0x80) +#define WEEKEVENTREG_43_01 PACK_WEEKEVENTREG_FLAG(43, 0x01) +#define WEEKEVENTREG_43_02 PACK_WEEKEVENTREG_FLAG(43, 0x02) +#define WEEKEVENTREG_43_04 PACK_WEEKEVENTREG_FLAG(43, 0x04) +#define WEEKEVENTREG_43_08 PACK_WEEKEVENTREG_FLAG(43, 0x08) +#define WEEKEVENTREG_43_10 PACK_WEEKEVENTREG_FLAG(43, 0x10) +#define WEEKEVENTREG_43_20 PACK_WEEKEVENTREG_FLAG(43, 0x20) +#define WEEKEVENTREG_43_40 PACK_WEEKEVENTREG_FLAG(43, 0x40) +#define WEEKEVENTREG_43_80 PACK_WEEKEVENTREG_FLAG(43, 0x80) +#define WEEKEVENTREG_44_01 PACK_WEEKEVENTREG_FLAG(44, 0x01) +#define WEEKEVENTREG_44_02 PACK_WEEKEVENTREG_FLAG(44, 0x02) +#define WEEKEVENTREG_44_04 PACK_WEEKEVENTREG_FLAG(44, 0x04) +#define WEEKEVENTREG_44_08 PACK_WEEKEVENTREG_FLAG(44, 0x08) +#define WEEKEVENTREG_44_10 PACK_WEEKEVENTREG_FLAG(44, 0x10) +#define WEEKEVENTREG_44_20 PACK_WEEKEVENTREG_FLAG(44, 0x20) +#define WEEKEVENTREG_44_40 PACK_WEEKEVENTREG_FLAG(44, 0x40) +#define WEEKEVENTREG_44_80 PACK_WEEKEVENTREG_FLAG(44, 0x80) +#define WEEKEVENTREG_45_01 PACK_WEEKEVENTREG_FLAG(45, 0x01) +#define WEEKEVENTREG_45_02 PACK_WEEKEVENTREG_FLAG(45, 0x02) +#define WEEKEVENTREG_45_04 PACK_WEEKEVENTREG_FLAG(45, 0x04) +#define WEEKEVENTREG_45_08 PACK_WEEKEVENTREG_FLAG(45, 0x08) +#define WEEKEVENTREG_45_10 PACK_WEEKEVENTREG_FLAG(45, 0x10) +#define WEEKEVENTREG_45_20 PACK_WEEKEVENTREG_FLAG(45, 0x20) +#define WEEKEVENTREG_45_40 PACK_WEEKEVENTREG_FLAG(45, 0x40) +#define WEEKEVENTREG_45_80 PACK_WEEKEVENTREG_FLAG(45, 0x80) +#define WEEKEVENTREG_46_01 PACK_WEEKEVENTREG_FLAG(46, 0x01) +#define WEEKEVENTREG_46_02 PACK_WEEKEVENTREG_FLAG(46, 0x02) +#define WEEKEVENTREG_46_04 PACK_WEEKEVENTREG_FLAG(46, 0x04) +#define WEEKEVENTREG_46_08 PACK_WEEKEVENTREG_FLAG(46, 0x08) +#define WEEKEVENTREG_46_10 PACK_WEEKEVENTREG_FLAG(46, 0x10) +#define WEEKEVENTREG_46_20 PACK_WEEKEVENTREG_FLAG(46, 0x20) +#define WEEKEVENTREG_46_40 PACK_WEEKEVENTREG_FLAG(46, 0x40) +#define WEEKEVENTREG_46_80 PACK_WEEKEVENTREG_FLAG(46, 0x80) +#define WEEKEVENTREG_47_01 PACK_WEEKEVENTREG_FLAG(47, 0x01) +#define WEEKEVENTREG_47_02 PACK_WEEKEVENTREG_FLAG(47, 0x02) +#define WEEKEVENTREG_47_04 PACK_WEEKEVENTREG_FLAG(47, 0x04) +#define WEEKEVENTREG_47_08 PACK_WEEKEVENTREG_FLAG(47, 0x08) +#define WEEKEVENTREG_47_10 PACK_WEEKEVENTREG_FLAG(47, 0x10) +#define WEEKEVENTREG_47_20 PACK_WEEKEVENTREG_FLAG(47, 0x20) +#define WEEKEVENTREG_47_40 PACK_WEEKEVENTREG_FLAG(47, 0x40) +#define WEEKEVENTREG_47_80 PACK_WEEKEVENTREG_FLAG(47, 0x80) +#define WEEKEVENTREG_48_01 PACK_WEEKEVENTREG_FLAG(48, 0x01) +#define WEEKEVENTREG_48_02 PACK_WEEKEVENTREG_FLAG(48, 0x02) +#define WEEKEVENTREG_48_04 PACK_WEEKEVENTREG_FLAG(48, 0x04) +#define WEEKEVENTREG_48_08 PACK_WEEKEVENTREG_FLAG(48, 0x08) +#define WEEKEVENTREG_48_10 PACK_WEEKEVENTREG_FLAG(48, 0x10) +#define WEEKEVENTREG_48_20 PACK_WEEKEVENTREG_FLAG(48, 0x20) +#define WEEKEVENTREG_48_40 PACK_WEEKEVENTREG_FLAG(48, 0x40) +#define WEEKEVENTREG_48_80 PACK_WEEKEVENTREG_FLAG(48, 0x80) +#define WEEKEVENTREG_49_01 PACK_WEEKEVENTREG_FLAG(49, 0x01) +#define WEEKEVENTREG_49_02 PACK_WEEKEVENTREG_FLAG(49, 0x02) +#define WEEKEVENTREG_49_04 PACK_WEEKEVENTREG_FLAG(49, 0x04) +#define WEEKEVENTREG_49_08 PACK_WEEKEVENTREG_FLAG(49, 0x08) +#define WEEKEVENTREG_49_10 PACK_WEEKEVENTREG_FLAG(49, 0x10) +#define WEEKEVENTREG_49_20 PACK_WEEKEVENTREG_FLAG(49, 0x20) +#define WEEKEVENTREG_49_40 PACK_WEEKEVENTREG_FLAG(49, 0x40) +#define WEEKEVENTREG_49_80 PACK_WEEKEVENTREG_FLAG(49, 0x80) +#define WEEKEVENTREG_50_01 PACK_WEEKEVENTREG_FLAG(50, 0x01) +#define WEEKEVENTREG_50_02 PACK_WEEKEVENTREG_FLAG(50, 0x02) +#define WEEKEVENTREG_50_04 PACK_WEEKEVENTREG_FLAG(50, 0x04) +#define WEEKEVENTREG_50_08 PACK_WEEKEVENTREG_FLAG(50, 0x08) +#define WEEKEVENTREG_50_10 PACK_WEEKEVENTREG_FLAG(50, 0x10) +#define WEEKEVENTREG_50_20 PACK_WEEKEVENTREG_FLAG(50, 0x20) +#define WEEKEVENTREG_50_40 PACK_WEEKEVENTREG_FLAG(50, 0x40) +#define WEEKEVENTREG_50_80 PACK_WEEKEVENTREG_FLAG(50, 0x80) +#define WEEKEVENTREG_51_01 PACK_WEEKEVENTREG_FLAG(51, 0x01) +#define WEEKEVENTREG_51_02 PACK_WEEKEVENTREG_FLAG(51, 0x02) +#define WEEKEVENTREG_51_04 PACK_WEEKEVENTREG_FLAG(51, 0x04) +#define WEEKEVENTREG_51_08 PACK_WEEKEVENTREG_FLAG(51, 0x08) +#define WEEKEVENTREG_51_10 PACK_WEEKEVENTREG_FLAG(51, 0x10) +#define WEEKEVENTREG_51_20 PACK_WEEKEVENTREG_FLAG(51, 0x20) +#define WEEKEVENTREG_51_40 PACK_WEEKEVENTREG_FLAG(51, 0x40) +#define WEEKEVENTREG_51_80 PACK_WEEKEVENTREG_FLAG(51, 0x80) + +// ProtectedCremia +#define WEEKEVENTREG_52_01 PACK_WEEKEVENTREG_FLAG(52, 0x01) +// Lose Milk Run minigame +#define WEEKEVENTREG_52_02 PACK_WEEKEVENTREG_FLAG(52, 0x02) + +#define WEEKEVENTREG_52_04 PACK_WEEKEVENTREG_FLAG(52, 0x04) +#define WEEKEVENTREG_52_08 PACK_WEEKEVENTREG_FLAG(52, 0x08) +#define WEEKEVENTREG_52_10 PACK_WEEKEVENTREG_FLAG(52, 0x10) + +// cleared Stone Tower Temple +#define WEEKEVENTREG_52_20 PACK_WEEKEVENTREG_FLAG(52, 0x20) + +#define WEEKEVENTREG_52_40 PACK_WEEKEVENTREG_FLAG(52, 0x40) +#define WEEKEVENTREG_52_80 PACK_WEEKEVENTREG_FLAG(52, 0x80) +#define WEEKEVENTREG_53_01 PACK_WEEKEVENTREG_FLAG(53, 0x01) +#define WEEKEVENTREG_53_02 PACK_WEEKEVENTREG_FLAG(53, 0x02) +#define WEEKEVENTREG_53_04 PACK_WEEKEVENTREG_FLAG(53, 0x04) +#define WEEKEVENTREG_53_08 PACK_WEEKEVENTREG_FLAG(53, 0x08) +#define WEEKEVENTREG_53_10 PACK_WEEKEVENTREG_FLAG(53, 0x10) +#define WEEKEVENTREG_53_20 PACK_WEEKEVENTREG_FLAG(53, 0x20) +#define WEEKEVENTREG_53_40 PACK_WEEKEVENTREG_FLAG(53, 0x40) +#define WEEKEVENTREG_53_80 PACK_WEEKEVENTREG_FLAG(53, 0x80) +#define WEEKEVENTREG_54_01 PACK_WEEKEVENTREG_FLAG(54, 0x01) +#define WEEKEVENTREG_54_02 PACK_WEEKEVENTREG_FLAG(54, 0x02) +#define WEEKEVENTREG_54_04 PACK_WEEKEVENTREG_FLAG(54, 0x04) +#define WEEKEVENTREG_54_08 PACK_WEEKEVENTREG_FLAG(54, 0x08) +#define WEEKEVENTREG_54_10 PACK_WEEKEVENTREG_FLAG(54, 0x10) +#define WEEKEVENTREG_54_20 PACK_WEEKEVENTREG_FLAG(54, 0x20) +#define WEEKEVENTREG_54_40 PACK_WEEKEVENTREG_FLAG(54, 0x40) +#define WEEKEVENTREG_54_80 PACK_WEEKEVENTREG_FLAG(54, 0x80) +#define WEEKEVENTREG_55_01 PACK_WEEKEVENTREG_FLAG(55, 0x01) + +// Unconfirmed: "Link the Goron Claims His Reservation: 4:30 PM" +#define WEEKEVENTREG_55_02 PACK_WEEKEVENTREG_FLAG(55, 0x02) + +#define WEEKEVENTREG_55_04 PACK_WEEKEVENTREG_FLAG(55, 0x04) +#define WEEKEVENTREG_55_08 PACK_WEEKEVENTREG_FLAG(55, 0x08) +#define WEEKEVENTREG_55_10 PACK_WEEKEVENTREG_FLAG(55, 0x10) +#define WEEKEVENTREG_55_20 PACK_WEEKEVENTREG_FLAG(55, 0x20) +#define WEEKEVENTREG_55_40 PACK_WEEKEVENTREG_FLAG(55, 0x40) + +// Gyorg has been defeated +#define WEEKEVENTREG_55_80 PACK_WEEKEVENTREG_FLAG(55, 0x80) + +#define WEEKEVENTREG_56_01 PACK_WEEKEVENTREG_FLAG(56, 0x01) +#define WEEKEVENTREG_56_02 PACK_WEEKEVENTREG_FLAG(56, 0x02) +#define WEEKEVENTREG_56_04 PACK_WEEKEVENTREG_FLAG(56, 0x04) +#define WEEKEVENTREG_56_08 PACK_WEEKEVENTREG_FLAG(56, 0x08) +#define WEEKEVENTREG_56_10 PACK_WEEKEVENTREG_FLAG(56, 0x10) +#define WEEKEVENTREG_56_20 PACK_WEEKEVENTREG_FLAG(56, 0x20) +#define WEEKEVENTREG_56_40 PACK_WEEKEVENTREG_FLAG(56, 0x40) +#define WEEKEVENTREG_56_80 PACK_WEEKEVENTREG_FLAG(56, 0x80) +#define WEEKEVENTREG_57_01 PACK_WEEKEVENTREG_FLAG(57, 0x01) +#define WEEKEVENTREG_57_02 PACK_WEEKEVENTREG_FLAG(57, 0x02) +#define WEEKEVENTREG_57_04 PACK_WEEKEVENTREG_FLAG(57, 0x04) +#define WEEKEVENTREG_57_08 PACK_WEEKEVENTREG_FLAG(57, 0x08) +#define WEEKEVENTREG_57_10 PACK_WEEKEVENTREG_FLAG(57, 0x10) +#define WEEKEVENTREG_57_20 PACK_WEEKEVENTREG_FLAG(57, 0x20) +#define WEEKEVENTREG_57_40 PACK_WEEKEVENTREG_FLAG(57, 0x40) +#define WEEKEVENTREG_57_80 PACK_WEEKEVENTREG_FLAG(57, 0x80) +#define WEEKEVENTREG_58_01 PACK_WEEKEVENTREG_FLAG(58, 0x01) +#define WEEKEVENTREG_58_02 PACK_WEEKEVENTREG_FLAG(58, 0x02) +#define WEEKEVENTREG_58_04 PACK_WEEKEVENTREG_FLAG(58, 0x04) +#define WEEKEVENTREG_58_08 PACK_WEEKEVENTREG_FLAG(58, 0x08) +#define WEEKEVENTREG_58_10 PACK_WEEKEVENTREG_FLAG(58, 0x10) +#define WEEKEVENTREG_58_20 PACK_WEEKEVENTREG_FLAG(58, 0x20) +#define WEEKEVENTREG_58_40 PACK_WEEKEVENTREG_FLAG(58, 0x40) +#define WEEKEVENTREG_58_80 PACK_WEEKEVENTREG_FLAG(58, 0x80) +#define WEEKEVENTREG_59_01 PACK_WEEKEVENTREG_FLAG(59, 0x01) +#define WEEKEVENTREG_59_02 PACK_WEEKEVENTREG_FLAG(59, 0x02) + +// Unconfirmed: "Entered South Clock Town" +#define WEEKEVENTREG_59_04 PACK_WEEKEVENTREG_FLAG(59, 0x04) + +#define WEEKEVENTREG_59_08 PACK_WEEKEVENTREG_FLAG(59, 0x08) +#define WEEKEVENTREG_59_10 PACK_WEEKEVENTREG_FLAG(59, 0x10) +#define WEEKEVENTREG_59_20 PACK_WEEKEVENTREG_FLAG(59, 0x20) +#define WEEKEVENTREG_59_40 PACK_WEEKEVENTREG_FLAG(59, 0x40) +#define WEEKEVENTREG_59_80 PACK_WEEKEVENTREG_FLAG(59, 0x80) +#define WEEKEVENTREG_60_01 PACK_WEEKEVENTREG_FLAG(60, 0x01) +#define WEEKEVENTREG_60_02 PACK_WEEKEVENTREG_FLAG(60, 0x02) +#define WEEKEVENTREG_60_04 PACK_WEEKEVENTREG_FLAG(60, 0x04) +#define WEEKEVENTREG_60_08 PACK_WEEKEVENTREG_FLAG(60, 0x08) +#define WEEKEVENTREG_60_10 PACK_WEEKEVENTREG_FLAG(60, 0x10) +#define WEEKEVENTREG_60_20 PACK_WEEKEVENTREG_FLAG(60, 0x20) +#define WEEKEVENTREG_60_40 PACK_WEEKEVENTREG_FLAG(60, 0x40) +#define WEEKEVENTREG_60_80 PACK_WEEKEVENTREG_FLAG(60, 0x80) +#define WEEKEVENTREG_61_01 PACK_WEEKEVENTREG_FLAG(61, 0x01) +#define WEEKEVENTREG_61_02 PACK_WEEKEVENTREG_FLAG(61, 0x02) +#define WEEKEVENTREG_61_04 PACK_WEEKEVENTREG_FLAG(61, 0x04) +#define WEEKEVENTREG_61_08 PACK_WEEKEVENTREG_FLAG(61, 0x08) +#define WEEKEVENTREG_61_10 PACK_WEEKEVENTREG_FLAG(61, 0x10) +#define WEEKEVENTREG_61_20 PACK_WEEKEVENTREG_FLAG(61, 0x20) +#define WEEKEVENTREG_61_40 PACK_WEEKEVENTREG_FLAG(61, 0x40) +#define WEEKEVENTREG_61_80 PACK_WEEKEVENTREG_FLAG(61, 0x80) +#define WEEKEVENTREG_62_01 PACK_WEEKEVENTREG_FLAG(62, 0x01) +#define WEEKEVENTREG_62_02 PACK_WEEKEVENTREG_FLAG(62, 0x02) +#define WEEKEVENTREG_62_04 PACK_WEEKEVENTREG_FLAG(62, 0x04) +#define WEEKEVENTREG_62_08 PACK_WEEKEVENTREG_FLAG(62, 0x08) +#define WEEKEVENTREG_62_10 PACK_WEEKEVENTREG_FLAG(62, 0x10) +#define WEEKEVENTREG_62_20 PACK_WEEKEVENTREG_FLAG(62, 0x20) +#define WEEKEVENTREG_62_40 PACK_WEEKEVENTREG_FLAG(62, 0x40) +#define WEEKEVENTREG_62_80 PACK_WEEKEVENTREG_FLAG(62, 0x80) +#define WEEKEVENTREG_63_01 PACK_WEEKEVENTREG_FLAG(63, 0x01) +#define WEEKEVENTREG_63_02 PACK_WEEKEVENTREG_FLAG(63, 0x02) +#define WEEKEVENTREG_63_04 PACK_WEEKEVENTREG_FLAG(63, 0x04) +#define WEEKEVENTREG_63_08 PACK_WEEKEVENTREG_FLAG(63, 0x08) +#define WEEKEVENTREG_63_10 PACK_WEEKEVENTREG_FLAG(63, 0x10) +#define WEEKEVENTREG_63_20 PACK_WEEKEVENTREG_FLAG(63, 0x20) +#define WEEKEVENTREG_63_40 PACK_WEEKEVENTREG_FLAG(63, 0x40) + +// showed Couple's Mask to meeting +#define WEEKEVENTREG_63_80 PACK_WEEKEVENTREG_FLAG(63, 0x80) + +#define WEEKEVENTREG_64_01 PACK_WEEKEVENTREG_FLAG(64, 0x01) +#define WEEKEVENTREG_64_02 PACK_WEEKEVENTREG_FLAG(64, 0x02) +#define WEEKEVENTREG_64_04 PACK_WEEKEVENTREG_FLAG(64, 0x04) +#define WEEKEVENTREG_64_08 PACK_WEEKEVENTREG_FLAG(64, 0x08) +#define WEEKEVENTREG_64_10 PACK_WEEKEVENTREG_FLAG(64, 0x10) +#define WEEKEVENTREG_64_20 PACK_WEEKEVENTREG_FLAG(64, 0x20) +#define WEEKEVENTREG_64_40 PACK_WEEKEVENTREG_FLAG(64, 0x40) +#define WEEKEVENTREG_64_80 PACK_WEEKEVENTREG_FLAG(64, 0x80) +#define WEEKEVENTREG_65_01 PACK_WEEKEVENTREG_FLAG(65, 0x01) +#define WEEKEVENTREG_65_02 PACK_WEEKEVENTREG_FLAG(65, 0x02) +#define WEEKEVENTREG_65_04 PACK_WEEKEVENTREG_FLAG(65, 0x04) +#define WEEKEVENTREG_65_08 PACK_WEEKEVENTREG_FLAG(65, 0x08) +#define WEEKEVENTREG_65_10 PACK_WEEKEVENTREG_FLAG(65, 0x10) +#define WEEKEVENTREG_65_20 PACK_WEEKEVENTREG_FLAG(65, 0x20) +#define WEEKEVENTREG_65_40 PACK_WEEKEVENTREG_FLAG(65, 0x40) +#define WEEKEVENTREG_65_80 PACK_WEEKEVENTREG_FLAG(65, 0x80) +#define WEEKEVENTREG_66_01 PACK_WEEKEVENTREG_FLAG(66, 0x01) +#define WEEKEVENTREG_66_02 PACK_WEEKEVENTREG_FLAG(66, 0x02) +#define WEEKEVENTREG_66_04 PACK_WEEKEVENTREG_FLAG(66, 0x04) +#define WEEKEVENTREG_66_08 PACK_WEEKEVENTREG_FLAG(66, 0x08) +#define WEEKEVENTREG_66_10 PACK_WEEKEVENTREG_FLAG(66, 0x10) +#define WEEKEVENTREG_66_20 PACK_WEEKEVENTREG_FLAG(66, 0x20) +#define WEEKEVENTREG_66_40 PACK_WEEKEVENTREG_FLAG(66, 0x40) +#define WEEKEVENTREG_66_80 PACK_WEEKEVENTREG_FLAG(66, 0x80) +#define WEEKEVENTREG_67_01 PACK_WEEKEVENTREG_FLAG(67, 0x01) +#define WEEKEVENTREG_67_02 PACK_WEEKEVENTREG_FLAG(67, 0x02) +#define WEEKEVENTREG_67_04 PACK_WEEKEVENTREG_FLAG(67, 0x04) +#define WEEKEVENTREG_67_08 PACK_WEEKEVENTREG_FLAG(67, 0x08) +#define WEEKEVENTREG_67_10 PACK_WEEKEVENTREG_FLAG(67, 0x10) +#define WEEKEVENTREG_67_20 PACK_WEEKEVENTREG_FLAG(67, 0x20) +#define WEEKEVENTREG_67_40 PACK_WEEKEVENTREG_FLAG(67, 0x40) +#define WEEKEVENTREG_67_80 PACK_WEEKEVENTREG_FLAG(67, 0x80) +#define WEEKEVENTREG_68_01 PACK_WEEKEVENTREG_FLAG(68, 0x01) +#define WEEKEVENTREG_68_02 PACK_WEEKEVENTREG_FLAG(68, 0x02) +#define WEEKEVENTREG_68_04 PACK_WEEKEVENTREG_FLAG(68, 0x04) +#define WEEKEVENTREG_68_08 PACK_WEEKEVENTREG_FLAG(68, 0x08) +#define WEEKEVENTREG_68_10 PACK_WEEKEVENTREG_FLAG(68, 0x10) +#define WEEKEVENTREG_68_20 PACK_WEEKEVENTREG_FLAG(68, 0x20) +#define WEEKEVENTREG_68_40 PACK_WEEKEVENTREG_FLAG(68, 0x40) +#define WEEKEVENTREG_68_80 PACK_WEEKEVENTREG_FLAG(68, 0x80) +#define WEEKEVENTREG_69_01 PACK_WEEKEVENTREG_FLAG(69, 0x01) +#define WEEKEVENTREG_69_02 PACK_WEEKEVENTREG_FLAG(69, 0x02) +#define WEEKEVENTREG_69_04 PACK_WEEKEVENTREG_FLAG(69, 0x04) +#define WEEKEVENTREG_69_08 PACK_WEEKEVENTREG_FLAG(69, 0x08) +#define WEEKEVENTREG_69_10 PACK_WEEKEVENTREG_FLAG(69, 0x10) +#define WEEKEVENTREG_69_20 PACK_WEEKEVENTREG_FLAG(69, 0x20) +#define WEEKEVENTREG_69_40 PACK_WEEKEVENTREG_FLAG(69, 0x40) +#define WEEKEVENTREG_69_80 PACK_WEEKEVENTREG_FLAG(69, 0x80) +#define WEEKEVENTREG_70_01 PACK_WEEKEVENTREG_FLAG(70, 0x01) +#define WEEKEVENTREG_70_02 PACK_WEEKEVENTREG_FLAG(70, 0x02) +#define WEEKEVENTREG_70_04 PACK_WEEKEVENTREG_FLAG(70, 0x04) +#define WEEKEVENTREG_70_08 PACK_WEEKEVENTREG_FLAG(70, 0x08) +#define WEEKEVENTREG_70_10 PACK_WEEKEVENTREG_FLAG(70, 0x10) +#define WEEKEVENTREG_70_20 PACK_WEEKEVENTREG_FLAG(70, 0x20) +#define WEEKEVENTREG_70_40 PACK_WEEKEVENTREG_FLAG(70, 0x40) +#define WEEKEVENTREG_70_80 PACK_WEEKEVENTREG_FLAG(70, 0x80) +#define WEEKEVENTREG_71_01 PACK_WEEKEVENTREG_FLAG(71, 0x01) +#define WEEKEVENTREG_71_02 PACK_WEEKEVENTREG_FLAG(71, 0x02) +#define WEEKEVENTREG_71_04 PACK_WEEKEVENTREG_FLAG(71, 0x04) +#define WEEKEVENTREG_71_08 PACK_WEEKEVENTREG_FLAG(71, 0x08) +#define WEEKEVENTREG_71_10 PACK_WEEKEVENTREG_FLAG(71, 0x10) +#define WEEKEVENTREG_71_20 PACK_WEEKEVENTREG_FLAG(71, 0x20) +#define WEEKEVENTREG_71_40 PACK_WEEKEVENTREG_FLAG(71, 0x40) +#define WEEKEVENTREG_71_80 PACK_WEEKEVENTREG_FLAG(71, 0x80) +#define WEEKEVENTREG_72_01 PACK_WEEKEVENTREG_FLAG(72, 0x01) +#define WEEKEVENTREG_72_02 PACK_WEEKEVENTREG_FLAG(72, 0x02) +#define WEEKEVENTREG_72_04 PACK_WEEKEVENTREG_FLAG(72, 0x04) +#define WEEKEVENTREG_72_08 PACK_WEEKEVENTREG_FLAG(72, 0x08) +#define WEEKEVENTREG_72_10 PACK_WEEKEVENTREG_FLAG(72, 0x10) +#define WEEKEVENTREG_72_20 PACK_WEEKEVENTREG_FLAG(72, 0x20) +#define WEEKEVENTREG_72_40 PACK_WEEKEVENTREG_FLAG(72, 0x40) +#define WEEKEVENTREG_72_80 PACK_WEEKEVENTREG_FLAG(72, 0x80) +#define WEEKEVENTREG_73_01 PACK_WEEKEVENTREG_FLAG(73, 0x01) +#define WEEKEVENTREG_73_02 PACK_WEEKEVENTREG_FLAG(73, 0x02) +#define WEEKEVENTREG_73_04 PACK_WEEKEVENTREG_FLAG(73, 0x04) +#define WEEKEVENTREG_73_08 PACK_WEEKEVENTREG_FLAG(73, 0x08) + +// Unconfirmed: "Bombers Hide & Seek started on Day 1?" +#define WEEKEVENTREG_73_10 PACK_WEEKEVENTREG_FLAG(73, 0x10) + +#define WEEKEVENTREG_73_20 PACK_WEEKEVENTREG_FLAG(73, 0x20) +#define WEEKEVENTREG_73_40 PACK_WEEKEVENTREG_FLAG(73, 0x40) +#define WEEKEVENTREG_73_80 PACK_WEEKEVENTREG_FLAG(73, 0x80) +#define WEEKEVENTREG_74_01 PACK_WEEKEVENTREG_FLAG(74, 0x01) +#define WEEKEVENTREG_74_02 PACK_WEEKEVENTREG_FLAG(74, 0x02) +#define WEEKEVENTREG_74_04 PACK_WEEKEVENTREG_FLAG(74, 0x04) +#define WEEKEVENTREG_74_08 PACK_WEEKEVENTREG_FLAG(74, 0x08) +#define WEEKEVENTREG_74_10 PACK_WEEKEVENTREG_FLAG(74, 0x10) +#define WEEKEVENTREG_74_20 PACK_WEEKEVENTREG_FLAG(74, 0x20) +#define WEEKEVENTREG_74_40 PACK_WEEKEVENTREG_FLAG(74, 0x40) +#define WEEKEVENTREG_74_80 PACK_WEEKEVENTREG_FLAG(74, 0x80) +#define WEEKEVENTREG_75_01 PACK_WEEKEVENTREG_FLAG(75, 0x01) +#define WEEKEVENTREG_75_02 PACK_WEEKEVENTREG_FLAG(75, 0x02) +#define WEEKEVENTREG_75_04 PACK_WEEKEVENTREG_FLAG(75, 0x04) +#define WEEKEVENTREG_75_08 PACK_WEEKEVENTREG_FLAG(75, 0x08) +#define WEEKEVENTREG_75_10 PACK_WEEKEVENTREG_FLAG(75, 0x10) +#define WEEKEVENTREG_75_20 PACK_WEEKEVENTREG_FLAG(75, 0x20) +#define WEEKEVENTREG_75_40 PACK_WEEKEVENTREG_FLAG(75, 0x40) +#define WEEKEVENTREG_75_80 PACK_WEEKEVENTREG_FLAG(75, 0x80) +#define WEEKEVENTREG_76_01 PACK_WEEKEVENTREG_FLAG(76, 0x01) +#define WEEKEVENTREG_76_02 PACK_WEEKEVENTREG_FLAG(76, 0x02) +#define WEEKEVENTREG_76_04 PACK_WEEKEVENTREG_FLAG(76, 0x04) +#define WEEKEVENTREG_76_08 PACK_WEEKEVENTREG_FLAG(76, 0x08) +#define WEEKEVENTREG_76_10 PACK_WEEKEVENTREG_FLAG(76, 0x10) +#define WEEKEVENTREG_76_20 PACK_WEEKEVENTREG_FLAG(76, 0x20) +#define WEEKEVENTREG_76_40 PACK_WEEKEVENTREG_FLAG(76, 0x40) +#define WEEKEVENTREG_76_80 PACK_WEEKEVENTREG_FLAG(76, 0x80) +#define WEEKEVENTREG_77_01 PACK_WEEKEVENTREG_FLAG(77, 0x01) +#define WEEKEVENTREG_77_02 PACK_WEEKEVENTREG_FLAG(77, 0x02) +#define WEEKEVENTREG_77_04 PACK_WEEKEVENTREG_FLAG(77, 0x04) +#define WEEKEVENTREG_77_08 PACK_WEEKEVENTREG_FLAG(77, 0x08) +#define WEEKEVENTREG_77_10 PACK_WEEKEVENTREG_FLAG(77, 0x10) +#define WEEKEVENTREG_77_20 PACK_WEEKEVENTREG_FLAG(77, 0x20) +#define WEEKEVENTREG_77_40 PACK_WEEKEVENTREG_FLAG(77, 0x40) + +// The player has heard the Goron Shrine cheer as a Goron at least once. +#define WEEKEVENTREG_77_80 PACK_WEEKEVENTREG_FLAG(77, 0x80) + +#define WEEKEVENTREG_78_01 PACK_WEEKEVENTREG_FLAG(78, 0x01) +#define WEEKEVENTREG_78_02 PACK_WEEKEVENTREG_FLAG(78, 0x02) +#define WEEKEVENTREG_78_04 PACK_WEEKEVENTREG_FLAG(78, 0x04) +#define WEEKEVENTREG_78_08 PACK_WEEKEVENTREG_FLAG(78, 0x08) +#define WEEKEVENTREG_78_10 PACK_WEEKEVENTREG_FLAG(78, 0x10) +#define WEEKEVENTREG_78_20 PACK_WEEKEVENTREG_FLAG(78, 0x20) +#define WEEKEVENTREG_78_40 PACK_WEEKEVENTREG_FLAG(78, 0x40) +#define WEEKEVENTREG_78_80 PACK_WEEKEVENTREG_FLAG(78, 0x80) +#define WEEKEVENTREG_79_01 PACK_WEEKEVENTREG_FLAG(79, 0x01) +#define WEEKEVENTREG_79_02 PACK_WEEKEVENTREG_FLAG(79, 0x02) +#define WEEKEVENTREG_79_04 PACK_WEEKEVENTREG_FLAG(79, 0x04) +#define WEEKEVENTREG_79_08 PACK_WEEKEVENTREG_FLAG(79, 0x08) +#define WEEKEVENTREG_79_10 PACK_WEEKEVENTREG_FLAG(79, 0x10) +#define WEEKEVENTREG_79_20 PACK_WEEKEVENTREG_FLAG(79, 0x20) +#define WEEKEVENTREG_79_40 PACK_WEEKEVENTREG_FLAG(79, 0x40) +#define WEEKEVENTREG_79_80 PACK_WEEKEVENTREG_FLAG(79, 0x80) +#define WEEKEVENTREG_80_01 PACK_WEEKEVENTREG_FLAG(80, 0x01) +#define WEEKEVENTREG_80_02 PACK_WEEKEVENTREG_FLAG(80, 0x02) +#define WEEKEVENTREG_80_04 PACK_WEEKEVENTREG_FLAG(80, 0x04) +#define WEEKEVENTREG_80_08 PACK_WEEKEVENTREG_FLAG(80, 0x08) +#define WEEKEVENTREG_80_10 PACK_WEEKEVENTREG_FLAG(80, 0x10) +#define WEEKEVENTREG_80_20 PACK_WEEKEVENTREG_FLAG(80, 0x20) +#define WEEKEVENTREG_80_40 PACK_WEEKEVENTREG_FLAG(80, 0x40) +#define WEEKEVENTREG_80_80 PACK_WEEKEVENTREG_FLAG(80, 0x80) +#define WEEKEVENTREG_81_01 PACK_WEEKEVENTREG_FLAG(81, 0x01) +#define WEEKEVENTREG_81_02 PACK_WEEKEVENTREG_FLAG(81, 0x02) +#define WEEKEVENTREG_81_04 PACK_WEEKEVENTREG_FLAG(81, 0x04) +#define WEEKEVENTREG_81_08 PACK_WEEKEVENTREG_FLAG(81, 0x08) +#define WEEKEVENTREG_81_10 PACK_WEEKEVENTREG_FLAG(81, 0x10) +#define WEEKEVENTREG_81_20 PACK_WEEKEVENTREG_FLAG(81, 0x20) +#define WEEKEVENTREG_81_40 PACK_WEEKEVENTREG_FLAG(81, 0x40) +#define WEEKEVENTREG_81_80 PACK_WEEKEVENTREG_FLAG(81, 0x80) +#define WEEKEVENTREG_82_01 PACK_WEEKEVENTREG_FLAG(82, 0x01) +#define WEEKEVENTREG_82_02 PACK_WEEKEVENTREG_FLAG(82, 0x02) + +// check if already healed Kamaro the Dancing Ghost +#define WEEKEVENTREG_82_04 PACK_WEEKEVENTREG_FLAG(82, 0x04) + +#define WEEKEVENTREG_82_08 PACK_WEEKEVENTREG_FLAG(82, 0x08) +#define WEEKEVENTREG_82_10 PACK_WEEKEVENTREG_FLAG(82, 0x10) +#define WEEKEVENTREG_82_20 PACK_WEEKEVENTREG_FLAG(82, 0x20) +#define WEEKEVENTREG_82_40 PACK_WEEKEVENTREG_FLAG(82, 0x40) +#define WEEKEVENTREG_82_80 PACK_WEEKEVENTREG_FLAG(82, 0x80) +#define WEEKEVENTREG_83_01 PACK_WEEKEVENTREG_FLAG(83, 0x01) +#define WEEKEVENTREG_83_02 PACK_WEEKEVENTREG_FLAG(83, 0x02) +#define WEEKEVENTREG_83_04 PACK_WEEKEVENTREG_FLAG(83, 0x04) +#define WEEKEVENTREG_83_08 PACK_WEEKEVENTREG_FLAG(83, 0x08) +#define WEEKEVENTREG_83_10 PACK_WEEKEVENTREG_FLAG(83, 0x10) +#define WEEKEVENTREG_83_20 PACK_WEEKEVENTREG_FLAG(83, 0x20) +#define WEEKEVENTREG_83_40 PACK_WEEKEVENTREG_FLAG(83, 0x40) +#define WEEKEVENTREG_83_80 PACK_WEEKEVENTREG_FLAG(83, 0x80) +#define WEEKEVENTREG_84_01 PACK_WEEKEVENTREG_FLAG(84, 0x01) +#define WEEKEVENTREG_84_02 PACK_WEEKEVENTREG_FLAG(84, 0x02) +#define WEEKEVENTREG_84_04 PACK_WEEKEVENTREG_FLAG(84, 0x04) +#define WEEKEVENTREG_84_08 PACK_WEEKEVENTREG_FLAG(84, 0x08) +#define WEEKEVENTREG_84_10 PACK_WEEKEVENTREG_FLAG(84, 0x10) + +// Unconfirmed: "Obtained Fierce Deity's Mask?" +#define WEEKEVENTREG_84_20 PACK_WEEKEVENTREG_FLAG(84, 0x20) + +#define WEEKEVENTREG_84_40 PACK_WEEKEVENTREG_FLAG(84, 0x40) +#define WEEKEVENTREG_84_80 PACK_WEEKEVENTREG_FLAG(84, 0x80) +#define WEEKEVENTREG_85_01 PACK_WEEKEVENTREG_FLAG(85, 0x01) + +// Unconfirmed: "Bombers Hide & Seek in Progress" +#define WEEKEVENTREG_85_02 PACK_WEEKEVENTREG_FLAG(85, 0x02) + +#define WEEKEVENTREG_85_04 PACK_WEEKEVENTREG_FLAG(85, 0x04) +#define WEEKEVENTREG_85_08 PACK_WEEKEVENTREG_FLAG(85, 0x08) +#define WEEKEVENTREG_85_10 PACK_WEEKEVENTREG_FLAG(85, 0x10) +#define WEEKEVENTREG_85_20 PACK_WEEKEVENTREG_FLAG(85, 0x20) +#define WEEKEVENTREG_85_40 PACK_WEEKEVENTREG_FLAG(85, 0x40) + +// Unconfirmed: "Postman showing priority mail to Madame" +#define WEEKEVENTREG_85_80 PACK_WEEKEVENTREG_FLAG(85, 0x80) + +#define WEEKEVENTREG_86_01 PACK_WEEKEVENTREG_FLAG(86, 0x01) +#define WEEKEVENTREG_86_02 PACK_WEEKEVENTREG_FLAG(86, 0x02) +#define WEEKEVENTREG_86_04 PACK_WEEKEVENTREG_FLAG(86, 0x04) +#define WEEKEVENTREG_86_08 PACK_WEEKEVENTREG_FLAG(86, 0x08) +#define WEEKEVENTREG_86_10 PACK_WEEKEVENTREG_FLAG(86, 0x10) +#define WEEKEVENTREG_86_20 PACK_WEEKEVENTREG_FLAG(86, 0x20) +#define WEEKEVENTREG_86_40 PACK_WEEKEVENTREG_FLAG(86, 0x40) +#define WEEKEVENTREG_86_80 PACK_WEEKEVENTREG_FLAG(86, 0x80) +#define WEEKEVENTREG_87_01 PACK_WEEKEVENTREG_FLAG(87, 0x01) +#define WEEKEVENTREG_87_02 PACK_WEEKEVENTREG_FLAG(87, 0x02) +#define WEEKEVENTREG_87_04 PACK_WEEKEVENTREG_FLAG(87, 0x04) +#define WEEKEVENTREG_87_08 PACK_WEEKEVENTREG_FLAG(87, 0x08) +#define WEEKEVENTREG_87_10 PACK_WEEKEVENTREG_FLAG(87, 0x10) +#define WEEKEVENTREG_87_20 PACK_WEEKEVENTREG_FLAG(87, 0x20) +#define WEEKEVENTREG_87_40 PACK_WEEKEVENTREG_FLAG(87, 0x40) +#define WEEKEVENTREG_87_80 PACK_WEEKEVENTREG_FLAG(87, 0x80) +#define WEEKEVENTREG_88_01 PACK_WEEKEVENTREG_FLAG(88, 0x01) +#define WEEKEVENTREG_88_02 PACK_WEEKEVENTREG_FLAG(88, 0x02) +#define WEEKEVENTREG_88_04 PACK_WEEKEVENTREG_FLAG(88, 0x04) +#define WEEKEVENTREG_88_08 PACK_WEEKEVENTREG_FLAG(88, 0x08) +#define WEEKEVENTREG_88_10 PACK_WEEKEVENTREG_FLAG(88, 0x10) +#define WEEKEVENTREG_88_20 PACK_WEEKEVENTREG_FLAG(88, 0x20) +#define WEEKEVENTREG_88_40 PACK_WEEKEVENTREG_FLAG(88, 0x40) +#define WEEKEVENTREG_88_80 PACK_WEEKEVENTREG_FLAG(88, 0x80) +#define WEEKEVENTREG_89_01 PACK_WEEKEVENTREG_FLAG(89, 0x01) +#define WEEKEVENTREG_89_02 PACK_WEEKEVENTREG_FLAG(89, 0x02) +#define WEEKEVENTREG_89_04 PACK_WEEKEVENTREG_FLAG(89, 0x04) + +// Unconfirmed: "Postman has delivered priority mail" +#define WEEKEVENTREG_89_08 PACK_WEEKEVENTREG_FLAG(89, 0x08) + +#define WEEKEVENTREG_89_10 PACK_WEEKEVENTREG_FLAG(89, 0x10) +#define WEEKEVENTREG_89_20 PACK_WEEKEVENTREG_FLAG(89, 0x20) + +// Unconfirmed: "Postman is about to flee" +#define WEEKEVENTREG_89_40 PACK_WEEKEVENTREG_FLAG(89, 0x40) + +#define WEEKEVENTREG_89_80 PACK_WEEKEVENTREG_FLAG(89, 0x80) + +// Unconfirmed: "Postman fleeing town" +#define WEEKEVENTREG_90_01 PACK_WEEKEVENTREG_FLAG(90, 0x01) + +#define WEEKEVENTREG_90_02 PACK_WEEKEVENTREG_FLAG(90, 0x02) +#define WEEKEVENTREG_90_04 PACK_WEEKEVENTREG_FLAG(90, 0x04) +#define WEEKEVENTREG_90_08 PACK_WEEKEVENTREG_FLAG(90, 0x08) +#define WEEKEVENTREG_90_10 PACK_WEEKEVENTREG_FLAG(90, 0x10) +#define WEEKEVENTREG_90_20 PACK_WEEKEVENTREG_FLAG(90, 0x20) +#define WEEKEVENTREG_90_40 PACK_WEEKEVENTREG_FLAG(90, 0x40) +#define WEEKEVENTREG_90_80 PACK_WEEKEVENTREG_FLAG(90, 0x80) +#define WEEKEVENTREG_91_01 PACK_WEEKEVENTREG_FLAG(91, 0x01) +#define WEEKEVENTREG_91_02 PACK_WEEKEVENTREG_FLAG(91, 0x02) +#define WEEKEVENTREG_91_04 PACK_WEEKEVENTREG_FLAG(91, 0x04) +#define WEEKEVENTREG_91_08 PACK_WEEKEVENTREG_FLAG(91, 0x08) +#define WEEKEVENTREG_91_10 PACK_WEEKEVENTREG_FLAG(91, 0x10) +#define WEEKEVENTREG_91_20 PACK_WEEKEVENTREG_FLAG(91, 0x20) +#define WEEKEVENTREG_91_40 PACK_WEEKEVENTREG_FLAG(91, 0x40) +#define WEEKEVENTREG_91_80 PACK_WEEKEVENTREG_FLAG(91, 0x80) + +// RACE_FLAGS +//#define WEEKEVENTREG_92_01 PACK_WEEKEVENTREG_FLAG(92, 0x01) +//#define WEEKEVENTREG_92_02 PACK_WEEKEVENTREG_FLAG(92, 0x02) +//#define WEEKEVENTREG_92_04 PACK_WEEKEVENTREG_FLAG(92, 0x04) + +#define WEEKEVENTREG_92_08 PACK_WEEKEVENTREG_FLAG(92, 0x08) +#define WEEKEVENTREG_92_10 PACK_WEEKEVENTREG_FLAG(92, 0x10) +#define WEEKEVENTREG_92_20 PACK_WEEKEVENTREG_FLAG(92, 0x20) +#define WEEKEVENTREG_92_40 PACK_WEEKEVENTREG_FLAG(92, 0x40) +#define WEEKEVENTREG_92_80 PACK_WEEKEVENTREG_FLAG(92, 0x80) +#define WEEKEVENTREG_93_01 PACK_WEEKEVENTREG_FLAG(93, 0x01) +#define WEEKEVENTREG_93_02 PACK_WEEKEVENTREG_FLAG(93, 0x02) +#define WEEKEVENTREG_93_04 PACK_WEEKEVENTREG_FLAG(93, 0x04) +#define WEEKEVENTREG_93_08 PACK_WEEKEVENTREG_FLAG(93, 0x08) +#define WEEKEVENTREG_93_10 PACK_WEEKEVENTREG_FLAG(93, 0x10) +#define WEEKEVENTREG_93_20 PACK_WEEKEVENTREG_FLAG(93, 0x20) +#define WEEKEVENTREG_93_40 PACK_WEEKEVENTREG_FLAG(93, 0x40) +#define WEEKEVENTREG_93_80 PACK_WEEKEVENTREG_FLAG(93, 0x80) +#define WEEKEVENTREG_94_01 PACK_WEEKEVENTREG_FLAG(94, 0x01) +#define WEEKEVENTREG_94_02 PACK_WEEKEVENTREG_FLAG(94, 0x02) +#define WEEKEVENTREG_94_04 PACK_WEEKEVENTREG_FLAG(94, 0x04) +#define WEEKEVENTREG_94_08 PACK_WEEKEVENTREG_FLAG(94, 0x08) +#define WEEKEVENTREG_94_10 PACK_WEEKEVENTREG_FLAG(94, 0x10) +#define WEEKEVENTREG_94_20 PACK_WEEKEVENTREG_FLAG(94, 0x20) +#define WEEKEVENTREG_94_40 PACK_WEEKEVENTREG_FLAG(94, 0x40) +#define WEEKEVENTREG_94_80 PACK_WEEKEVENTREG_FLAG(94, 0x80) +#define WEEKEVENTREG_95_01 PACK_WEEKEVENTREG_FLAG(95, 0x01) +#define WEEKEVENTREG_95_02 PACK_WEEKEVENTREG_FLAG(95, 0x02) +#define WEEKEVENTREG_95_04 PACK_WEEKEVENTREG_FLAG(95, 0x04) +#define WEEKEVENTREG_95_08 PACK_WEEKEVENTREG_FLAG(95, 0x08) +#define WEEKEVENTREG_95_10 PACK_WEEKEVENTREG_FLAG(95, 0x10) +#define WEEKEVENTREG_95_20 PACK_WEEKEVENTREG_FLAG(95, 0x20) +#define WEEKEVENTREG_95_40 PACK_WEEKEVENTREG_FLAG(95, 0x40) +#define WEEKEVENTREG_95_80 PACK_WEEKEVENTREG_FLAG(95, 0x80) +#define WEEKEVENTREG_96_01 PACK_WEEKEVENTREG_FLAG(96, 0x01) +#define WEEKEVENTREG_96_02 PACK_WEEKEVENTREG_FLAG(96, 0x02) +#define WEEKEVENTREG_96_04 PACK_WEEKEVENTREG_FLAG(96, 0x04) +#define WEEKEVENTREG_96_08 PACK_WEEKEVENTREG_FLAG(96, 0x08) +#define WEEKEVENTREG_96_10 PACK_WEEKEVENTREG_FLAG(96, 0x10) +#define WEEKEVENTREG_96_20 PACK_WEEKEVENTREG_FLAG(96, 0x20) +#define WEEKEVENTREG_96_40 PACK_WEEKEVENTREG_FLAG(96, 0x40) +#define WEEKEVENTREG_96_80 PACK_WEEKEVENTREG_FLAG(96, 0x80) +#define WEEKEVENTREG_97_01 PACK_WEEKEVENTREG_FLAG(97, 0x01) +#define WEEKEVENTREG_97_02 PACK_WEEKEVENTREG_FLAG(97, 0x02) +#define WEEKEVENTREG_97_04 PACK_WEEKEVENTREG_FLAG(97, 0x04) +#define WEEKEVENTREG_97_08 PACK_WEEKEVENTREG_FLAG(97, 0x08) +#define WEEKEVENTREG_97_10 PACK_WEEKEVENTREG_FLAG(97, 0x10) +#define WEEKEVENTREG_97_20 PACK_WEEKEVENTREG_FLAG(97, 0x20) +#define WEEKEVENTREG_97_40 PACK_WEEKEVENTREG_FLAG(97, 0x40) +#define WEEKEVENTREG_97_80 PACK_WEEKEVENTREG_FLAG(97, 0x80) +#define WEEKEVENTREG_98_01 PACK_WEEKEVENTREG_FLAG(98, 0x01) +#define WEEKEVENTREG_98_02 PACK_WEEKEVENTREG_FLAG(98, 0x02) +#define WEEKEVENTREG_98_04 PACK_WEEKEVENTREG_FLAG(98, 0x04) +#define WEEKEVENTREG_98_08 PACK_WEEKEVENTREG_FLAG(98, 0x08) +#define WEEKEVENTREG_98_10 PACK_WEEKEVENTREG_FLAG(98, 0x10) +#define WEEKEVENTREG_98_20 PACK_WEEKEVENTREG_FLAG(98, 0x20) +#define WEEKEVENTREG_98_40 PACK_WEEKEVENTREG_FLAG(98, 0x40) +#define WEEKEVENTREG_98_80 PACK_WEEKEVENTREG_FLAG(98, 0x80) +#define WEEKEVENTREG_99_01 PACK_WEEKEVENTREG_FLAG(99, 0x01) +#define WEEKEVENTREG_99_02 PACK_WEEKEVENTREG_FLAG(99, 0x02) +#define WEEKEVENTREG_99_04 PACK_WEEKEVENTREG_FLAG(99, 0x04) +#define WEEKEVENTREG_99_08 PACK_WEEKEVENTREG_FLAG(99, 0x08) +#define WEEKEVENTREG_99_10 PACK_WEEKEVENTREG_FLAG(99, 0x10) +#define WEEKEVENTREG_99_20 PACK_WEEKEVENTREG_FLAG(99, 0x20) +#define WEEKEVENTREG_99_40 PACK_WEEKEVENTREG_FLAG(99, 0x40) +#define WEEKEVENTREG_99_80 PACK_WEEKEVENTREG_FLAG(99, 0x80) + +#define WEEKEVENTREG(index) (gSaveContext.save.weekEventReg[(index)]) +#define GET_WEEKEVENTREG(index) ((void)0, WEEKEVENTREG(index)) + +#define CHECK_WEEKEVENTREG(flag) (WEEKEVENTREG((flag) >> 8) & ((flag) & 0xFF)) +#define CHECK_WEEKEVENTREG_ALT(flag) (GET_WEEKEVENTREG((flag) >> 8) & ((flag) & 0xFF)) +#define SET_WEEKEVENTREG(flag) (WEEKEVENTREG((flag) >> 8) = GET_WEEKEVENTREG((flag) >> 8) | ((flag) & 0xFF)) +#define CLEAR_WEEKEVENTREG(flag) (WEEKEVENTREG((flag) >> 8) = GET_WEEKEVENTREG((flag) >> 8) & (u8)~((flag) & 0xFF)) + +#define WEEKEVENTREG_RACE_FLAG_END 0 +#define WEEKEVENTREG_RACE_FLAG_START 1 +#define WEEKEVENTREG_RACE_FLAG_2 2 +#define WEEKEVENTREG_RACE_FLAG_3 3 +#define WEEKEVENTREG_RACE_FLAG_4 4 +#define WEEKEVENTREG_RACE_FLAGS 7 + +#define GET_WEEKEVENTREG_RACE_FLAGS (WEEKEVENTREG(92) & WEEKEVENTREG_RACE_FLAGS) + +#define SET_WEEKEVENTREG_RACE_FLAGS(flag) \ + WEEKEVENTREG(92) &= (u8)~WEEKEVENTREG_RACE_FLAGS; \ + WEEKEVENTREG(92) = WEEKEVENTREG(92) | (u8)((WEEKEVENTREG(92) & ~WEEKEVENTREG_RACE_FLAGS) | (flag)) + +/** + * gSaveContext.eventInf + */ + +#define EVENTINF_00 0x00 +#define EVENTINF_01 0x01 +#define EVENTINF_02 0x02 +#define EVENTINF_03 0x03 +#define EVENTINF_04 0x04 +#define EVENTINF_05 0x05 +#define EVENTINF_06 0x06 +#define EVENTINF_07 0x07 +#define EVENTINF_10 0x10 +#define EVENTINF_11 0x11 +#define EVENTINF_12 0x12 +#define EVENTINF_13 0x13 +#define EVENTINF_14 0x14 +#define EVENTINF_15 0x15 +#define EVENTINF_16 0x16 +#define EVENTINF_17 0x17 +#define EVENTINF_20 0x20 +#define EVENTINF_21 0x21 +#define EVENTINF_22 0x22 +#define EVENTINF_23 0x23 +#define EVENTINF_24 0x24 +#define EVENTINF_25 0x25 +#define EVENTINF_26 0x26 +#define EVENTINF_27 0x27 +#define EVENTINF_30 0x30 + +// EVENTINF_31 is used to track if Player is within range of EnGakufu (2D Song Buttons Appearing on Wall) +#define EVENTINF_31 0x31 +// EVENTINF_32 is used to track if Player has played the notes of EnGakufu (2D Song Buttons Appearing on Wall) +#define EVENTINF_32 0x32 + +#define EVENTINF_33 0x33 +#define EVENTINF_34 0x34 +#define EVENTINF_35 0x35 +#define EVENTINF_36 0x36 +#define EVENTINF_37 0x37 +#define EVENTINF_40 0x40 +#define EVENTINF_41 0x41 +#define EVENTINF_42 0x42 +#define EVENTINF_43 0x43 +#define EVENTINF_44 0x44 +#define EVENTINF_45 0x45 +#define EVENTINF_46 0x46 +#define EVENTINF_47 0x47 +#define EVENTINF_50 0x50 +#define EVENTINF_51 0x51 +#define EVENTINF_52 0x52 +#define EVENTINF_53 0x53 +#define EVENTINF_54 0x54 +#define EVENTINF_55 0x55 + +// Enabled when Gyorg's intro cutscene has been watched +#define EVENTINF_56 0x56 + +#define EVENTINF_57 0x57 +#define EVENTINF_60 0x60 +#define EVENTINF_61 0x61 +#define EVENTINF_62 0x62 +#define EVENTINF_63 0x63 +#define EVENTINF_64 0x64 +#define EVENTINF_65 0x65 +#define EVENTINF_66 0x66 +#define EVENTINF_67 0x67 +#define EVENTINF_70 0x70 +#define EVENTINF_71 0x71 +#define EVENTINF_72 0x72 +#define EVENTINF_73 0x73 +#define EVENTINF_74 0x74 +#define EVENTINF_75 0x75 +#define EVENTINF_76 0x76 +#define EVENTINF_77 0x77 + +#define CHECK_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] & (1 << ((flag) & 0xF))) +#define SET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) +#define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] &= (u8)~(1 << ((flag) & 0xF))) +#define CLEAR_EVENTINF_ALT(flag) (gSaveContext.eventInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) + + +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); void Sram_InitDebugSave(void); void func_80144A94(SramContext* sramCtx); -void Sram_OpenSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void Sram_OpenSave(struct FileSelectState* fileSelect, SramContext* sramCtx); void func_8014546C(SramContext* sramCtx); -void func_801457CC(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); -void func_80146580(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx, s32 fileNum); -void func_80146628(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); -void Sram_InitSave(struct FileChooseContext* fileChooseCtx, SramContext* sramCtx); +void func_801457CC(struct FileSelectState* fileSelect, SramContext* sramCtx); +void func_80146580(struct FileSelectState* fileSelect2, SramContext* sramCtx, s32 fileNum); +void func_80146628(struct FileSelectState* fileSelect2, SramContext* sramCtx); +void Sram_InitSave(struct FileSelectState* fileSelect2, 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_Alloc(struct GameState* gameState, SramContext* sramCtx); +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,12 +1537,10 @@ 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[]; extern s32 D_801C6818[]; -extern s32 D_801C6838[]; extern s32 D_801C6840[]; extern s32 D_801C6850[]; diff --git a/include/z64scene.h b/include/z64scene.h index 5a1c39e16..025726ed0 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -9,211 +9,209 @@ #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 naviQuestHintFileId; + /* 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 timeSpeed; +} 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 specId; + /* 0x2 */ UNK_TYPE1 unk_02[4]; + /* 0x6 */ u8 ambienceId; + /* 0x7 */ u8 seqId; +} 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 unk_02[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 sceneCsCount; + /* 0x4 */ void* segment; +} SCmdCutsceneList; // 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 */ UNK_TYPE1 pad[7]; +} SCmdRegionVisited; // 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 +258,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; @@ -272,7 +270,7 @@ typedef struct { } Room; // size = 0x14 typedef struct { - /* 0x00 */ Room currRoom; + /* 0x00 */ Room curRoom; /* 0x14 */ Room prevRoom; /* 0x28 */ void* roomMemPages[2]; // In a scene with transitions, roomMemory is split between two pages that toggle each transition. This is one continuous range, as the second page allocates from the end /* 0x30 */ u8 activeMemPage; // 0 - First page in memory, 1 - Second page @@ -291,18 +289,18 @@ typedef struct { 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; + s8 bgCamIndex; // How the camera reacts during the transition. -2 for spiral staircase. -1 for generic door. 0+ will index scene CamData + } /* 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; @@ -317,7 +315,7 @@ typedef struct { } EntranceEntry; // size = 0x2 typedef struct { - /* 0x0 */ s8 sceneNum; + /* 0x0 */ s8 sceneId; /* 0x1 */ s8 spawnNum; /* 0x2 */ u16 flags; } EntranceTableEntry; // size = 0x4 @@ -343,7 +341,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 +375,7 @@ typedef struct { typedef struct { /* 0x0 */ u16 keyFrameLength; - /* 0x4 */ void* textureList; + /* 0x4 */ TexturePtr* textureList; /* 0x8 */ u8* textureIndexList; } AnimatedMatTexCycleParams; // size = 0xC @@ -392,116 +390,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 */ s16 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; @@ -522,9 +522,9 @@ typedef union { /* Command: 0x14 */ SCmdEndMarker endMarker; /* Command: 0x15 */ SCmdSoundSettings soundSettings; /* Command: 0x16 */ SCmdEchoSettings echoSettings; - /* Command: 0x17 */ SCmdMiscSettings miscSettings; + /* Command: 0x17 */ SCmdCutsceneList cutsceneList; /* Command: 0x18 */ SCmdAltHeaders altHeaders; - /* Command: 0x19 */ SCmdWorldMapVisited worldMapVisited; + /* Command: 0x19 */ SCmdRegionVisited regionVisited; /* Command: 0x1A */ SCmdTextureAnimations textureAnimations; /* Command: 0x1B */ SCmdCutsceneActorList cutsceneActorList; /* Command: 0x1C */ SCmdMinimapSettings minimapSettings; @@ -532,122 +532,286 @@ typedef union { /* Command: 0x1E */ SCmdMinimapChests minimapChests; } SceneCmd; // size = 0x8 +// Sets cursor point options on the world map typedef enum { - /* 0x00 */ SCENE_20SICHITAI2, + /* 0x0 */ REGION_GREAT_BAY, + /* 0x1 */ REGION_ZORA_HALL, + /* 0x2 */ REGION_ROMANI_RANCH, + /* 0x3 */ REGION_DEKU_PALACE, + /* 0x4 */ REGION_WOODFALL, + /* 0x5 */ REGION_CLOCK_TOWN, + /* 0x6 */ REGION_SNOWHEAD, + /* 0x7 */ REGION_IKANA_GRAVEYARD, + /* 0x8 */ REGION_IKANA_CANYON, + /* 0x9 */ REGION_GORON_VILLAGE, + /* 0xA */ REGION_STONE_TOWER, + /* 0xB */ REGION_MAX +} RegionId; + +// Sets warp points for owl statues +typedef enum { + /* 0x0 */ OWL_WARP_GREAT_BAY_COAST, + /* 0x1 */ OWL_WARP_ZORA_CAPE, + /* 0x2 */ OWL_WARP_SNOWHEAD, + /* 0x3 */ OWL_WARP_MOUNTAIN_VILLAGE, + /* 0x4 */ OWL_WARP_CLOCK_TOWN, + /* 0x5 */ OWL_WARP_MILK_ROAD, + /* 0x6 */ OWL_WARP_WOODFALL, + /* 0x7 */ OWL_WARP_SOUTHERN_SWAMP, + /* 0x8 */ OWL_WARP_IKANA_CANYON, + /* 0x9 */ OWL_WARP_STONE_TOWER, + /* 0xA */ OWL_WARP_ENTRANCE, // Special index for warping to the entrance of a scene + /* 0xB */ OWL_WARP_MAX +} OwlWarpId; + +// Sets cloud visibility on the world map +typedef enum { + /* 0 */ TINGLE_MAP_CLOCK_TOWN, + /* 1 */ TINGLE_MAP_WOODFALL, + /* 2 */ TINGLE_MAP_SNOWHEAD, + /* 3 */ TINGLE_MAP_ROMANI_RANCH, + /* 4 */ TINGLE_MAP_GREAT_BAY, + /* 5 */ TINGLE_MAP_STONE_TOWER, + /* 6 */ TINGLE_MAP_MAX +} TingleMapId; + +typedef enum { + /* 0x00 */ SCENE_20SICHITAI2, // Southern Swamp (Clear) /* 0x01 */ SCENE_UNSET_1, /* 0x02 */ SCENE_UNSET_2, /* 0x03 */ SCENE_UNSET_3, /* 0x04 */ SCENE_UNSET_4, /* 0x05 */ SCENE_UNSET_5, /* 0x06 */ SCENE_UNSET_6, - /* 0x07 */ SCENE_KAKUSIANA, - /* 0x08 */ SCENE_SPOT00, + /* 0x07 */ SCENE_KAKUSIANA, // Lone Peak Shrine & Grottos + /* 0x08 */ SCENE_SPOT00, // Cutscene Scene /* 0x09 */ SCENE_UNSET_9, - /* 0x0A */ SCENE_WITCH_SHOP, - /* 0x0B */ SCENE_LAST_BS, - /* 0x0C */ SCENE_HAKASHITA, - /* 0x0D */ SCENE_AYASHIISHOP, + /* 0x0A */ SCENE_WITCH_SHOP, // Magic Hags' Potion Shop + /* 0x0B */ SCENE_LAST_BS, // Majora's Lair + /* 0x0C */ SCENE_HAKASHITA, // Beneath the Graveyard + /* 0x0D */ SCENE_AYASHIISHOP, // Curiosity Shop /* 0x0E */ SCENE_UNSET_E, /* 0x0F */ SCENE_UNSET_F, - /* 0x10 */ SCENE_OMOYA, - /* 0x11 */ SCENE_BOWLING, - /* 0x12 */ SCENE_SONCHONOIE, - /* 0x13 */ SCENE_IKANA, - /* 0x14 */ SCENE_KAIZOKU, - /* 0x15 */ SCENE_MILK_BAR, - /* 0x16 */ SCENE_INISIE_N, - /* 0x17 */ SCENE_TAKARAYA, - /* 0x18 */ SCENE_INISIE_R, - /* 0x19 */ SCENE_OKUJOU, - /* 0x1A */ SCENE_OPENINGDAN, - /* 0x1B */ SCENE_MITURIN, - /* 0x1C */ SCENE_13HUBUKINOMITI, - /* 0x1D */ SCENE_CASTLE, - /* 0x1E */ SCENE_DEKUTES, - /* 0x1F */ SCENE_MITURIN_BS, - /* 0x20 */ SCENE_SYATEKI_MIZU, - /* 0x21 */ SCENE_HAKUGIN, - /* 0x22 */ SCENE_ROMANYMAE, - /* 0x23 */ SCENE_PIRATE, - /* 0x24 */ SCENE_SYATEKI_MORI, - /* 0x25 */ SCENE_SINKAI, - /* 0x26 */ SCENE_YOUSEI_IZUMI, - /* 0x27 */ SCENE_KINSTA1, - /* 0x28 */ SCENE_KINDAN2, - /* 0x29 */ SCENE_TENMON_DAI, - /* 0x2A */ SCENE_LAST_DEKU, - /* 0x2B */ SCENE_22DEKUCITY, - /* 0x2C */ SCENE_KAJIYA, - /* 0x2D */ SCENE_00KEIKOKU, - /* 0x2E */ SCENE_POSTHOUSE, - /* 0x2F */ SCENE_LABO, - /* 0x30 */ SCENE_DANPEI2TEST, + /* 0x10 */ SCENE_OMOYA, // Mama's House (Ranch House in PAL) & Barn + /* 0x11 */ SCENE_BOWLING, // Honey & Darling's Shop + /* 0x12 */ SCENE_SONCHONOIE, // The Mayor's Residence + /* 0x13 */ SCENE_IKANA, // Ikana Canyon + /* 0x14 */ SCENE_KAIZOKU, // Pirates' Fortress + /* 0x15 */ SCENE_MILK_BAR, // Milk Bar + /* 0x16 */ SCENE_INISIE_N, // Stone Tower Temple + /* 0x17 */ SCENE_TAKARAYA, // Treasure Chest Shop + /* 0x18 */ SCENE_INISIE_R, // Inverted Stone Tower Temple + /* 0x19 */ SCENE_OKUJOU, // Clock Tower Rooftop + /* 0x1A */ SCENE_OPENINGDAN, // Before Clock Town + /* 0x1B */ SCENE_MITURIN, // Woodfall Temple + /* 0x1C */ SCENE_13HUBUKINOMITI, // Path to Mountain Village + /* 0x1D */ SCENE_CASTLE, // Ancient Castle of Ikana + /* 0x1E */ SCENE_DEKUTES, // Deku Scrub Playground + /* 0x1F */ SCENE_MITURIN_BS, // Odolwa's Lair + /* 0x20 */ SCENE_SYATEKI_MIZU, // Town Shooting Gallery + /* 0x21 */ SCENE_HAKUGIN, // Snowhead Temple + /* 0x22 */ SCENE_ROMANYMAE, // Milk Road + /* 0x23 */ SCENE_PIRATE, // Pirates' Fortress Interior + /* 0x24 */ SCENE_SYATEKI_MORI, // Swamp Shooting Gallery + /* 0x25 */ SCENE_SINKAI, // Pinnacle Rock + /* 0x26 */ SCENE_YOUSEI_IZUMI, // Fairy's Fountain + /* 0x27 */ SCENE_KINSTA1, // Swamp Spider House + /* 0x28 */ SCENE_KINDAN2, // Oceanside Spider House + /* 0x29 */ SCENE_TENMON_DAI, // Astral Observatory + /* 0x2A */ SCENE_LAST_DEKU, // Moon Deku Trial + /* 0x2B */ SCENE_22DEKUCITY, // Deku Palace + /* 0x2C */ SCENE_KAJIYA, // Mountain Smithy + /* 0x2D */ SCENE_00KEIKOKU, // Termina Field + /* 0x2E */ SCENE_POSTHOUSE, // Post Office + /* 0x2F */ SCENE_LABO, // Marine Research Lab + /* 0x30 */ SCENE_DANPEI2TEST, // Beneath the Graveyard (Day 3) and Dampe's House /* 0x31 */ SCENE_UNSET_31, - /* 0x32 */ SCENE_16GORON_HOUSE, - /* 0x33 */ SCENE_33ZORACITY, - /* 0x34 */ SCENE_8ITEMSHOP, - /* 0x35 */ SCENE_F01, - /* 0x36 */ SCENE_INISIE_BS, - /* 0x37 */ SCENE_30GYOSON, - /* 0x38 */ SCENE_31MISAKI, - /* 0x39 */ SCENE_TAKARAKUJI, + /* 0x32 */ SCENE_16GORON_HOUSE, // Goron Shrine + /* 0x33 */ SCENE_33ZORACITY, // Zora Hall + /* 0x34 */ SCENE_8ITEMSHOP, // Trading Post + /* 0x35 */ SCENE_F01, // Romani Ranch + /* 0x36 */ SCENE_INISIE_BS, // Twinmold's Lair + /* 0x37 */ SCENE_30GYOSON, // Great Bay Coast + /* 0x38 */ SCENE_31MISAKI, // Zora Cape + /* 0x39 */ SCENE_TAKARAKUJI, // Lottery Shop /* 0x3A */ SCENE_UNSET_3A, - /* 0x3B */ SCENE_TORIDE, - /* 0x3C */ SCENE_FISHERMAN, - /* 0x3D */ SCENE_GORONSHOP, - /* 0x3E */ SCENE_DEKU_KING, - /* 0x3F */ SCENE_LAST_GORON, - /* 0x40 */ SCENE_24KEMONOMITI, - /* 0x41 */ SCENE_F01_B, - /* 0x42 */ SCENE_F01C, - /* 0x43 */ SCENE_BOTI, - /* 0x44 */ SCENE_HAKUGIN_BS, - /* 0x45 */ SCENE_20SICHITAI, - /* 0x46 */ SCENE_21MITURINMAE, - /* 0x47 */ SCENE_LAST_ZORA, - /* 0x48 */ SCENE_11GORONNOSATO2, - /* 0x49 */ SCENE_SEA, - /* 0x4A */ SCENE_35TAKI, - /* 0x4B */ SCENE_REDEAD, - /* 0x4C */ SCENE_BANDROOM, - /* 0x4D */ SCENE_11GORONNOSATO, - /* 0x4E */ SCENE_GORON_HAKA, - /* 0x4F */ SCENE_SECOM, - /* 0x50 */ SCENE_10YUKIYAMANOMURA, - /* 0x51 */ SCENE_TOUGITES, - /* 0x52 */ SCENE_DANPEI, - /* 0x53 */ SCENE_IKANAMAE, - /* 0x54 */ SCENE_DOUJOU, - /* 0x55 */ SCENE_MUSICHOUSE, - /* 0x56 */ SCENE_IKNINSIDE, - /* 0x57 */ SCENE_MAP_SHOP, - /* 0x58 */ SCENE_F40, - /* 0x59 */ SCENE_F41, - /* 0x5A */ SCENE_10YUKIYAMANOMURA2, - /* 0x5B */ SCENE_14YUKIDAMANOMITI, - /* 0x5C */ SCENE_12HAKUGINMAE, - /* 0x5D */ SCENE_17SETUGEN, - /* 0x5E */ SCENE_17SETUGEN2, - /* 0x5F */ SCENE_SEA_BS, - /* 0x60 */ SCENE_RANDOM, - /* 0x61 */ SCENE_YADOYA, - /* 0x62 */ SCENE_KONPEKI_ENT, - /* 0x63 */ SCENE_INSIDETOWER, - /* 0x64 */ SCENE_26SARUNOMORI, - /* 0x65 */ SCENE_LOST_WOODS, - /* 0x66 */ SCENE_LAST_LINK, - /* 0x67 */ SCENE_SOUGEN, - /* 0x68 */ SCENE_BOMYA, - /* 0x69 */ SCENE_KYOJINNOMA, - /* 0x6A */ SCENE_KOEPONARACE, - /* 0x6B */ SCENE_GORONRACE, - /* 0x6C */ SCENE_TOWN, - /* 0x6D */ SCENE_ICHIBA, - /* 0x6E */ SCENE_BACKTOWN, - /* 0x6F */ SCENE_CLOCKTOWER, - /* 0x70 */ SCENE_ALLEY, + /* 0x3B */ SCENE_TORIDE, // Pirates' Fortress Moat + /* 0x3C */ SCENE_FISHERMAN, // Fisherman's Hut + /* 0x3D */ SCENE_GORONSHOP, // Goron Shop + /* 0x3E */ SCENE_DEKU_KING, // Deku King's Chamber + /* 0x3F */ SCENE_LAST_GORON, // Moon Goron Trial + /* 0x40 */ SCENE_24KEMONOMITI, // Road to Southern Swamp + /* 0x41 */ SCENE_F01_B, // Doggy Racetrack + /* 0x42 */ SCENE_F01C, // Cucco Shack + /* 0x43 */ SCENE_BOTI, // Ikana Graveyard + /* 0x44 */ SCENE_HAKUGIN_BS, // Goht's Lair + /* 0x45 */ SCENE_20SICHITAI, // Southern Swamp (poison) + /* 0x46 */ SCENE_21MITURINMAE, // Woodfall + /* 0x47 */ SCENE_LAST_ZORA, // Moon Zora Trial + /* 0x48 */ SCENE_11GORONNOSATO2, // Goron Village (spring) + /* 0x49 */ SCENE_SEA, // Great Bay Temple + /* 0x4A */ SCENE_35TAKI, // Waterfall Rapids + /* 0x4B */ SCENE_REDEAD, // Beneath the Well + /* 0x4C */ SCENE_BANDROOM, // Zora Hall Rooms + /* 0x4D */ SCENE_11GORONNOSATO, // Goron Village (winter) + /* 0x4E */ SCENE_GORON_HAKA, // Goron Graveyard + /* 0x4F */ SCENE_SECOM, // Sakon's Hideout + /* 0x50 */ SCENE_10YUKIYAMANOMURA, // Mountain Village (winter) + /* 0x51 */ SCENE_TOUGITES, // Ghost Hut + /* 0x52 */ SCENE_DANPEI, // Deku Shrine + /* 0x53 */ SCENE_IKANAMAE, // Road to Ikana + /* 0x54 */ SCENE_DOUJOU, // Swordsman's School + /* 0x55 */ SCENE_MUSICHOUSE, // Music Box House + /* 0x56 */ SCENE_IKNINSIDE, // Igos du Ikana's Lair + /* 0x57 */ SCENE_MAP_SHOP, // Tourist Information + /* 0x58 */ SCENE_F40, // Stone Tower + /* 0x59 */ SCENE_F41, // Inverted Stone Tower + /* 0x5A */ SCENE_10YUKIYAMANOMURA2, // Mountain Village (spring) + /* 0x5B */ SCENE_14YUKIDAMANOMITI, // Path to Snowhead + /* 0x5C */ SCENE_12HAKUGINMAE, // Snowhead + /* 0x5D */ SCENE_17SETUGEN, // Path to Goron Village (winter) + /* 0x5E */ SCENE_17SETUGEN2, // Path to Goron Village (spring) + /* 0x5F */ SCENE_SEA_BS, // Gyorg's Lair + /* 0x60 */ SCENE_RANDOM, // Secret Shrine + /* 0x61 */ SCENE_YADOYA, // Stock Pot Inn + /* 0x62 */ SCENE_KONPEKI_ENT, // Great Bay Cutscene + /* 0x63 */ SCENE_INSIDETOWER, // Clock Tower Interior + /* 0x64 */ SCENE_26SARUNOMORI, // Woods of Mystery + /* 0x65 */ SCENE_LOST_WOODS, // Lost Woods (Intro) + /* 0x66 */ SCENE_LAST_LINK, // Moon Link Trial + /* 0x67 */ SCENE_SOUGEN, // The Moon + /* 0x68 */ SCENE_BOMYA, // Bomb Shop + /* 0x69 */ SCENE_KYOJINNOMA, // Giants' Chamber + /* 0x6A */ SCENE_KOEPONARACE, // Gorman Track + /* 0x6B */ SCENE_GORONRACE, // Goron Racetrack + /* 0x6C */ SCENE_TOWN, // East Clock Town + /* 0x6D */ SCENE_ICHIBA, // West Clock Town + /* 0x6E */ SCENE_BACKTOWN, // North Clock Town + /* 0x6F */ SCENE_CLOCKTOWER, // South Clock Town + /* 0x70 */ SCENE_ALLEY, // Laundry Pool /* 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 sceneLayer +*/ +#define ENTRANCE(scene, spawn) ((((ENTR_SCENE_##scene) & 0x7F) << 9) | (((spawn) & 0x1F) << 4)) // SceneTableEntry draw configs typedef enum { @@ -661,6 +825,14 @@ typedef enum { /* 7 */ SCENE_DRAW_CFG_MAT_ANIM_MANUAL_STEP } SceneDrawConfigIds; +// TODO: make ZAPD use this enum for `SCENE_CMD_SPECIAL_FILES` +// Leftover from OoT +typedef enum { + /* 0 */ NAVI_QUEST_HINTS_NONE, + /* 1 */ NAVI_QUEST_HINTS_OVERWORLD, + /* 2 */ NAVI_QUEST_HINTS_DUNGEON +} NaviQuestHintFileId; + // SceneTableEntry commands typedef enum { /* 0x00 */ SCENE_CMD_ID_SPAWN_LIST, @@ -688,14 +860,14 @@ typedef enum { /* 0x16 */ SCENE_CMD_ID_ECHO_SETTINGS, /* 0x17 */ SCENE_CMD_ID_CUTSCENE_LIST, /* 0x18 */ SCENE_CMD_ID_ALTERNATE_HEADER_LIST, - /* 0x19 */ SCENE_CMD_ID_MISC_SETTINGS, + /* 0x19 */ SCENE_CMD_ID_SET_REGION_VISITED, /* 0x1A */ SCENE_CMD_ID_ANIMATED_MATERIAL_LIST, /* 0x1B */ SCENE_CMD_ID_ACTOR_CUTSCENE_LIST, /* 0x1C */ SCENE_CMD_ID_MINIMAP_INFO, /* 0x1D */ SCENE_CMD_ID_UNUSED_1D, /* 0x1E */ SCENE_CMD_ID_MINIMAP_COMPASS_ICON_INFO, /* 0x1F */ SCENE_CMD_MAX -} SceneCommandTypeID; +} SceneCommandTypeId; #define SCENE_CMD_SPAWN_LIST(numSpawns, spawnList) \ { SCENE_CMD_ID_SPAWN_LIST, numSpawns, CMD_PTR(spawnList) } @@ -718,14 +890,14 @@ typedef enum { #define SCENE_CMD_ENTRANCE_LIST(entranceList) \ { SCENE_CMD_ID_ENTRANCE_LIST, 0, CMD_PTR(entranceList) } -#define SCENE_CMD_SPECIAL_FILES(elfMessageFile, keepObjectId) \ - { SCENE_CMD_ID_SPECIAL_FILES, elfMessageFile, CMD_W(keepObjectId) } +#define SCENE_CMD_SPECIAL_FILES(naviQuestHintFileId, keepObjectId) \ + { SCENE_CMD_ID_SPECIAL_FILES, naviQuestHintFileId, CMD_W(keepObjectId) } -#define SCENE_CMD_ROOM_BEHAVIOR(currRoomUnk3, currRoomUnk2, currRoomUnk5, msgCtxunk12044, enablePosLights, \ +#define SCENE_CMD_ROOM_BEHAVIOR(curRoomUnk3, curRoomUnk2, curRoomUnk5, msgCtxunk12044, enablePosLights, \ kankyoContextUnkE2) \ { \ - SCENE_CMD_ID_ROOM_BEHAVIOR, currRoomUnk3, \ - currRoomUnk2 | _SHIFTL(currRoomUnk5, 8, 1) | _SHIFTL(msgCtxunk12044, 10, 1) | \ + SCENE_CMD_ID_ROOM_BEHAVIOR, curRoomUnk3, \ + curRoomUnk2 | _SHIFTL(curRoomUnk5, 8, 1) | _SHIFTL(msgCtxunk12044, 10, 1) | \ _SHIFTL(enablePosLights, 11, 1) | _SHIFTL(kankyoContextUnkE2, 12, 1) \ } @@ -765,8 +937,8 @@ typedef enum { #define SCENE_CMD_END() \ { SCENE_CMD_ID_END, 0, CMD_W(0) } -#define SCENE_CMD_SOUND_SETTINGS(audioSessionId, nighttimeSfx, bgmId) \ - { SCENE_CMD_ID_SOUND_SETTINGS, audioSessionId, CMD_BBBB(0, 0, nighttimeSfx, bgmId) } +#define SCENE_CMD_SOUND_SETTINGS(specId, ambienceId, seqId) \ + { SCENE_CMD_ID_SOUND_SETTINGS, specId, CMD_BBBB(0, 0, ambienceId, seqId) } #define SCENE_CMD_ECHO_SETTINGS(echo) \ { SCENE_CMD_ID_ECHO_SETTINGS, 0, CMD_BBBB(0, 0, 0, echo) } @@ -777,8 +949,9 @@ typedef enum { #define SCENE_CMD_ALTERNATE_HEADER_LIST(alternateHeaderList) \ { SCENE_CMD_ID_ALTERNATE_HEADER_LIST, 0, CMD_PTR(alternateHeaderList) } -#define SCENE_CMD_MISC_SETTINGS() \ - { SCENE_CMD_ID_MISC_SETTINGS, 0, CMD_W(0) } +#define SCENE_CMD_MISC_SETTINGS SCENE_CMD_SET_REGION_VISITED // TODO: ZAPD Capatability +#define SCENE_CMD_SET_REGION_VISITED() \ + { SCENE_CMD_ID_SET_REGION_VISITED, 0, CMD_W(0) } #define SCENE_CMD_ANIMATED_MATERIAL_LIST(matAnimList) \ { SCENE_CMD_ID_ANIMATED_MATERIAL_LIST, 0, CMD_PTR(matAnimList) } diff --git a/include/z64schedule.h b/include/z64schedule.h index f5dfb2be8..f3a703f3c 100644 --- a/include/z64schedule.h +++ b/include/z64schedule.h @@ -3,46 +3,54 @@ #include "ultra64.h" -/* - Schedule is a subsystem that acts as a way to make decisions based on the - time and scene (and a limited selection of items). It is utilized by writing - a script that is encoded into bytecode and ran, returning the result in a - struct. The returned result can be a value or a encoded time value. +/** + * Schedule is a subsystem that acts as a way to make decisions based on the + * time and scene (and a limited selection of items). It is utilized by writing + * a script that is encoded into bytecode and run, returning the result in a + * struct. The returned result can be a value or a encoded time value. + * + * The scripts contain 2 kinds of instructions: + * - Checks with branches (relative offsets, either 1-byte offsets (short, *_S), + * or 2-byte offsets (long, *_L)) + * - Returns + * + * Scripts are stored as u8[]. They are built using the macros are the bottom of + * this file. The scheduledis.py script can be used to convert any scripts in + * actor data into the macros. + */ - The scripts contain 2 kinds of instructions: - - Checks with branches (relative offsets, either 1-byte offsets (short, *_S), - or 2-byte offsets (long, *_L)) - - Returns - - Scripts are stored as u8[]. They are built using the macros are the bottom of - this file. The scheduledis.py script can be used to convert any scripts in - actor data into the macros. -*/ +/** + * Actors that use this system generally create 3 functions to interact with it. + * + * - FollowSchedule: The action function an actor sets to follow the schedule. + * - ProcessScheduleOutput: Holds the logic of processing the output received by running the schedule script, called by FollowSchedule + * - HandleSchedule: Holds the actual logic of how to actually follow the schedule based on the processed output, called by FollowSchedule + */ // Macro to convert the time format used in the save struct into the format used in Schedule -#define SCHEDULE_CONVERT_TIME(time) ((time) - 0x10000 / 360 * 90) +#define SCHEDULE_CONVERT_TIME(time) ((u16)((time) - 0x10000 / 360 * 90)) #define SCHEDULE_TIME_NOW SCHEDULE_CONVERT_TIME(gSaveContext.save.time) typedef enum { - /* 00 */ SCHEDULE_CMD_ID_CHECK_FLAG_S, // Checks if a weekEventReg flag is set and branches if so, short range branch - /* 01 */ SCHEDULE_CMD_ID_CHECK_FLAG_L, // Checks if a weekEventReg flag is set and branches if so, long range branch - /* 02 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, // Checks if the current time is within the range of the two provided times and branches if so, short range branch - /* 03 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, // Checks if the current time is within the range of the two provided times and branches if so, long range branch - /* 04 */ SCHEDULE_CMD_ID_RET_VAL_L, // Ends script and returns 2-byte value (Note: bugged as the return value size is only 1 byte in the struct) - /* 05 */ SCHEDULE_CMD_ID_RET_NONE, // Ends script without returning anything - /* 06 */ SCHEDULE_CMD_ID_RET_EMPTY, // Ends script and indicates return without changing existing value - /* 07 */ SCHEDULE_CMD_ID_NOP, // No-Op - /* 08 */ SCHEDULE_CMD_ID_CHECK_MISC_S, // Special check based on items or masks and branches if check passes, short range branch - /* 09 */ SCHEDULE_CMD_ID_RET_VAL_S, // Ends script and returns byte value - /* 10 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, // Checks if the current scene is not SceneNum and branches if so, short range branch - /* 11 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneNum and branches if so, long range branch - /* 12 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, // Checks if the current day is not Day and branches if so, short range branch - /* 13 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, // Checks if the current day is not Day and branches if so, long range branch - /* 14 */ SCHEDULE_CMD_ID_RET_TIME, // Returns 2 time values - /* 15 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, // Branches if the current time is less than the command time, short range branch - /* 16 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, // Branches if the current time is less than the command time, long range branch - /* 17 */ SCHEDULE_CMD_ID_BRANCH_S, // Always branch, short range branch - /* 18 */ SCHEDULE_CMD_ID_BRANCH_L, // Always branch, long range branch + /* 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 SceneId and branches if so, short range branch + /* 0x0B */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneId 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 { @@ -56,7 +64,7 @@ typedef struct { /* 0x4 */ s32 time0; /* 0x8 */ s32 time1; /* 0xC */ s32 hasResult; -} ScheduleResult; // size = 0x10 +} ScheduleOutput; // size = 0x10 typedef struct { /* 0x0 */ u8 cmd; @@ -122,15 +130,15 @@ typedef struct { typedef struct { /* 0x0 */ ScheduleCmdBase base; - /* 0x1 */ u8 sceneH; - /* 0x2 */ u8 sceneL; + /* 0x1 */ u8 sceneIdH; + /* 0x2 */ u8 sceneIdL; /* 0x3 */ s8 offset; } ScheduleCmdCheckNotInSceneS; // size = 0x4 typedef struct { /* 0x0 */ ScheduleCmdBase base; - /* 0x1 */ u8 sceneH; - /* 0x2 */ u8 sceneL; + /* 0x1 */ u8 sceneIdH; + /* 0x2 */ u8 sceneIdL; /* 0x3 */ u8 offsetH; /* 0x4 */ u8 offsetL; } ScheduleCmdCheckNotInSceneL; // size = 0x5 @@ -188,11 +196,11 @@ typedef struct { #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_S(flag, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_S, SCHEDULE_PACK_S16(flag), (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_FLAG_L(flag, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_L, SCHEDULE_PACK_S16(flag), 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) diff --git a/include/z64shrink_window.h b/include/z64shrink_window.h new file mode 100644 index 000000000..2742fb602 --- /dev/null +++ b/include/z64shrink_window.h @@ -0,0 +1,23 @@ +#ifndef Z64SHRINK_WINDOW_H +#define Z64SHRINK_WINDOW_H + +#include "PR/ultratypes.h" + +struct GraphicsContext; + +void ShrinkWindow_Letterbox_SetSizeTarget(s32 target); +s32 ShrinkWindow_Letterbox_GetSizeTarget(void); +void ShrinkWindow_Letterbox_SetSize(s32 size); +s32 ShrinkWindow_Letterbox_GetSize(void); + +void ShrinkWindow_Pillarbox_SetSizeTarget(s32 target); +s32 ShrinkWindow_Pillarbox_GetSizeTarget(void); +void ShrinkWindow_Pillarbox_SetSize(s32 size); +s32 ShrinkWindow_Pillarbox_GetSize(void); + +void ShrinkWindow_Init(void); +void ShrinkWindow_Destroy(void); +void ShrinkWindow_Update(s32 framerateDivisor); +void ShrinkWindow_Draw(GraphicsContext* gfxCtx); + +#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 3b13d2add..ca90cb232 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -8,6 +8,8 @@ extern Vec3f gOneVec3f; +#define SUBS_TIME_PATHING_ORDER 3 + typedef enum { /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, /* 1 */ SUBS_CUTSCENE_NORMAL, @@ -15,14 +17,28 @@ typedef enum { } SubSCutsceneType; //! @TODO: rename based on func_8013E748 and func_800B8500 -typedef s32 (*func_8013E748_VerifyFunc)(struct GlobalContext*, Actor*, void*); +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) #define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) @@ -38,23 +54,9 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define ACTOR_PATHING_REACHED_END \ (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) -typedef struct TurnOptions { - /* 0x0 */ u16 rotMax; // binary angles - /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 - /* 0x4 */ u16 rotStepMin; // degrees - /* 0x6 */ u16 rotStepMax; // degrees -} TurnOptions; // size = 0x8 - -typedef struct TurnOptionsSet { - /* 0x00 */ TurnOptions headRotX; - /* 0x08 */ TurnOptions headRotY; - /* 0x10 */ TurnOptions torsoRotX; - /* 0x18 */ TurnOptions torsoRotY; -} TurnOptionsSet; // size = 0x20 - 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; @@ -80,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 limit); + +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* target, 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 pointIndex, 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..45178ba8e 100644 --- a/include/z64transition.h +++ b/include/z64transition.h @@ -3,6 +3,8 @@ #include "ultra64.h" +#define TC_SET_PARAMS (1 << 7) + typedef struct { /* 0x00 */ void* (*init)(void* transition); /* 0x04 */ void (*destroy)(void* transition); @@ -13,18 +15,65 @@ 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]; + union { + struct { + /* 0x00 */ u32 count : 8; + /* 0x00 */ uintptr_t addr : 24; + }; + /* 0x00 */ u32 word; + } loadInfo; + /* 0x04 */ void* vramStart; + /* 0x08 */ void* vramEnd; + /* 0x0C */ uintptr_t vromStart; + /* 0x10 */ uintptr_t vromEnd; + /* 0x14 */ TransitionInit* initInfo; + /* 0x18 */ size_t size; +} TransitionOverlay; + +typedef struct { + /* 0x000 */ s16 transitionType; + /* 0x002 */ s8 fbdemoType; + /* 0x003 */ char unk_003[0x22B]; + /* 0x230 */ void* (*init)(void* transition); + /* 0x234 */ void (*destroy)(void* transition); + /* 0x238 */ void (*update)(void* transition, s32 updateRate); + /* 0x23C */ void (*draw)(void* transition, Gfx** gfxP); + /* 0x240 */ void (*start)(void* transition); + /* 0x244 */ void (*setType)(void* transition, s32 type); + /* 0x248 */ void (*setColor)(void* transition, u32 color); + /* 0x24C */ void (*setEnvColor)(void* transition, u32 color); + /* 0x250 */ s32 (*isDone)(void* transition); + /* 0x254 */ char unk_254[0x4]; +} TransitionContext; // size = 0x258 + +typedef struct { + /* 0x0 */ char unk_0[0xC]; } TransitionFade; // size = 0xC -extern const TransitionInit TransitionFade_InitVars; +typedef enum { + /* 0 */ TRANSITION_CIRCLE_IN, + /* 1 */ TRANSITION_CIRCLE_OUT, +} TransitionCircleDirection; + +#define FBDEMO_CIRCLE_GET_MASK_TYPE(type) (type & 1) typedef struct { - /* 0x000 */ char unk_0[0x20]; + /* 0x00 */ Color_RGBA8_u32 color; + /* 0x04 */ f32 referenceRadius; // Reference for where to transition to + /* 0x08 */ f32 stepValue; // How fast the Transition is + /* 0x0C */ f32 startingRadius; // Radius value where transition will begin + /* 0x10 */ f32 targetRadius; // Final radius of transition circle + /* 0x14 */ u8 direction; // Direction the circle is transitioning ( In / Out ) + /* 0x15 */ u8 maskType; // Positive / Negative mask type. Value of 0 will create a black circle + /* 0x16 */ u8 isDone; // Signals when Transition is done updating + /* 0x18 */ TexturePtr texture; + /* 0x1C */ u8 masks; + /* 0x1D */ u8 maskt; + /* 0x1E */ s8 unk_1E; // Set to 4 and never used + /* 0x1F */ s8 unk_1F; // Set to 0 and never used } TransitionCircle; // size = 0x20 -extern const TransitionInit TransitionCircle_InitVars; - #endif diff --git a/include/z64view.h b/include/z64view.h new file mode 100644 index 000000000..f0661d947 --- /dev/null +++ b/include/z64view.h @@ -0,0 +1,92 @@ +#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 distortionOrientation; + /* 0x134 */ Vec3f distortionScale; + /* 0x140 */ f32 distortionSpeed; + /* 0x144 */ Vec3f curDistortionOrientation; + /* 0x150 */ Vec3f curDistortionScale; + /* 0x15C */ u16 perspNorm; // used to normalize the projection matrix + /* 0x160 */ u32 flags; // bit 3: Render to an orthographic perspective + /* 0x164 */ s32 unk164; +} View; // size = 0x168 + +#define VIEW_VIEWING (1 << 0) +#define VIEW_VIEWPORT (1 << 1) +#define VIEW_PROJECTION_PERSPECTIVE (1 << 2) +#define VIEW_PROJECTION_ORTHO (1 << 3) +#define VIEW_ALL (VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE | VIEW_PROJECTION_ORTHO) + +#define VIEW_FORCE_VIEWING (VIEW_VIEWING << 4) +#define VIEW_FORCE_VIEWPORT (VIEW_VIEWPORT << 4) +#define VIEW_FORCE_PROJECTION_PERSPECTIVE (VIEW_PROJECTION_PERSPECTIVE << 4) +#define VIEW_FORCE_PROJECTION_ORTHO (VIEW_PROJECTION_ORTHO << 4) + +#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 + +void View_Init(View* view, struct GraphicsContext* gfxCtx); +void View_LookAt(View* view, Vec3f* eye, Vec3f* at, Vec3f* up); +void View_SetScale(View* view, f32 scale); +void View_GetScale(View* view, f32* scale); +void View_SetPerspective(View* view, f32 fovy, f32 zNear, f32 zFar); +void View_GetPerspective(View* view, f32* fovy, f32* zNear, f32* zFar); +void View_SetOrtho(View* view, f32 fovy, f32 zNear, f32 zFar); +void View_GetOrtho(View* view, f32* fovy, f32* zNear, f32* zFar); +void View_SetViewport(View* view, Viewport* viewport); +void View_GetViewport(View* view, Viewport* viewport); + +s32 View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ); +s32 View_SetDistortionScale(View* view, f32 scaleX, f32 scaleY, f32 scaleZ); +s32 View_SetDistortionSpeed(View* view, f32 speed); +s32 View_InitDistortion(View* view); +s32 View_ClearDistortion(View* view); +s32 View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed); + +void View_Apply(View* view, s32 mask); +s32 View_ApplyOrthoToOverlay(View* view); +s32 View_ApplyPerspectiveToOverlay(View* view); +s32 View_UpdateViewingMatrix(View* view); +s32 View_ApplyTo(View* view, Gfx** gfxp); + +#endif diff --git a/include/z_en_hy_code.h b/include/z_en_hy_code.h index a0f9bcdd4..0620d35a0 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 turnTarget; + /* 0x2C6 */ Vec3s trackTarget; /* 0x2CC */ Vec3s headRot; /* 0x2D2 */ Vec3s torsoRot; - /* 0x2D8 */ Vec3s tmpTurnTarget; - /* 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]; @@ -76,19 +76,19 @@ extern s8 gEnHyParentBodyParts[]; extern u8 gEnHyShadowSizes[]; s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex); -EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx); -void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); -s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx); -void EnHy_Blink(EnHy* enHy, s32 arg1); -s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex); -void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4); -s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5); -s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3); -s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex); -s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex); +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 eyeTexMaxIndex); +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/include/z_prenmi.h b/include/z_prenmi.h new file mode 100644 index 000000000..1aa1e6f99 --- /dev/null +++ b/include/z_prenmi.h @@ -0,0 +1,15 @@ +#ifndef Z64_PRENMI_H +#define Z64_PRENMI_H + +#include "global.h" + +void PreNMI_Destroy(GameState* thisx); +void PreNMI_Init(GameState* thisx); + +typedef struct { + /* 0x00 */ GameState state; + /* 0xA4 */ u32 timer; + /* 0xA8 */ UNK_TYPE4 unkA8; +} PreNMIState; // size = 0xAC + +#endif diff --git a/include/z_title_setup.h b/include/z_title_setup.h new file mode 100644 index 000000000..41e3f52f8 --- /dev/null +++ b/include/z_title_setup.h @@ -0,0 +1,13 @@ +#ifndef Z64_TITLE_SETUP_H +#define Z64_TITLE_SETUP_H + +#include "global.h" + +void Setup_Destroy(GameState* gameState); +void Setup_Init(GameState* thisx); + +typedef struct { + /* 0x00 */ GameState state; +} SetupState; // size = 0xA4 + +#endif diff --git a/requirements.txt b/requirements.txt index d76027c1c..6b391b170 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,15 @@ +# 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 + +# Compression +pyelftools>=0.26 + +# diff watchdog>=0.10.2 -GitPython>=3.1.14 +argcomplete +python-Levenshtein +cxxfilt diff --git a/spec b/spec index 273170579..ba217e15b 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" @@ -274,7 +273,8 @@ endseg beginseg name "link_animetion" romalign 0x1000 - include "build/baserom/link_animetion.o" + include "build/assets/misc/link_animetion/link_animetion.o" + number 7 endseg beginseg @@ -293,14 +293,16 @@ beginseg name "icon_item_field_static" compress romalign 0x1000 - include "build/baserom/icon_item_field_static.o" + include "build/assets/interface/icon_item_field_static/icon_item_field_static.o" + number 12 endseg beginseg name "icon_item_dungeon_static" compress romalign 0x1000 - include "build/baserom/icon_item_dungeon_static.o" + include "build/assets/interface/icon_item_dungeon_static/icon_item_dungeon_static.o" + number 12 endseg beginseg @@ -315,7 +317,8 @@ beginseg name "icon_item_jpn_static" compress romalign 0x1000 - include "build/baserom/icon_item_jpn_static.o" + include "build/assets/interface/icon_item_jpn_static/icon_item_jpn_static.o" + number 13 endseg beginseg @@ -421,11 +424,10 @@ beginseg name "code" compress after "dmadata" - include "build/src/code/z_en_a_keep.o" include "build/data/code/aspMain.data.o" include "build/data/code/gspS2DEX2.fifo.data.o" include "build/data/code/njpgdspMain.data.o" - include "build/data/code/code_801ADE60.data.o" + include "build/src/code/z_en_a_keep.o" include "build/data/code/code_801E3FA0.bss.o" include "build/src/code/z_en_item00.o" include "build/src/code/z_eff_blure.o" @@ -448,8 +450,6 @@ beginseg include "build/src/code/z_bg_collect.o" include "build/src/code/z_bg_item.o" include "build/src/code/z_camera.o" - include "build/data/code/z_camera.data.o" - include "build/data/code/z_camera.bss.o" include "build/src/code/z_collision_btltbls.o" pad_text include "build/src/code/z_collision_check.o" @@ -462,7 +462,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" @@ -494,7 +493,6 @@ beginseg include "build/data/code/z_map_disp.bss.o" include "build/src/code/z_map_data.o" include "build/src/code/z_map_exp.o" - include "build/data/code/z_map_exp.data.o" include "build/src/code/z_msgevent.o" include "build/data/code/z_msgevent.data.o" include "build/src/code/z_nmi_buff.o" @@ -502,13 +500,9 @@ 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" - include "build/data/code/z_player_lib.data.o" - include "build/data/code/z_player_lib.bss.o" include "build/src/code/z_prenmi.o" include "build/src/code/z_quake.o" include "build/src/code/z_rcp.o" @@ -530,11 +524,11 @@ 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" + include "build/src/code/code_80140CE0.o" + include "build/data/code/code_80140CE0.data.o" include "build/src/code/code_80140E80.o" include "build/src/code/z_vismono.o" include "build/src/code/code_801420C0.o" @@ -554,12 +548,10 @@ beginseg include "build/src/code/z_kaleido_manager.o" include "build/src/code/z_kaleido_scope_call.o" include "build/src/code/z_fbdemo_dlftbls.o" - include "build/data/code/code_801D0BB0.data.o" include "build/src/code/z_fbdemo.o" include "build/data/code/z_fbdemo.data.o" include "build/src/code/z_fbdemo_fade.o" include "build/src/code/z_fbdemo_circle.o" - include "build/data/code/z_fbdemo_circle.data.o" include "build/src/code/z_overlay.o" include "build/src/code/z_play.o" include "build/data/code/z_play.data.o" @@ -588,6 +580,7 @@ beginseg include "build/src/code/speed_meter.o" include "build/data/code/speed_meter.data.o" include "build/data/code/speed_meter.bss.o" + include "build/src/code/su_mtx.o" include "build/data/code/sys_cfb.bss.o" include "build/src/code/sys_cmpdma.o" include "build/data/code/sys_cmpdma.bss.o" @@ -599,8 +592,8 @@ beginseg include "build/src/code/sys_math_atan.o" include "build/src/code/sys_matrix.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" @@ -613,19 +606,15 @@ beginseg pad_text include "build/src/code/audio/audio_data.o" include "build/src/code/audio/audio_synthesis.o" - include "build/data/code/audio_synthesis.data.o" include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" include "build/src/code/audio/audio_load.o" - include "build/src/code/audio/code_80192BE0.o" - include "build/data/code/code_80192BE0.data.o" + include "build/src/code/audio/audio_thread.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 @@ -639,15 +628,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" @@ -713,8 +700,8 @@ beginseg include "build/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_item.o" 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_prompt.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 @@ -746,8 +733,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 @@ -768,8 +754,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 @@ -826,11 +811,7 @@ 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 @@ -879,8 +860,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 @@ -894,17 +874,14 @@ 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 name "ovl_En_Bubble" compress include "build/src/overlays/actors/ovl_En_Bubble/z_en_bubble.o" - include "build/data/ovl_En_Bubble/ovl_En_Bubble.data.o" - include "build/data/ovl_En_Bubble/ovl_En_Bubble.reloc.o" + include "build/src/overlays/actors/ovl_En_Bubble/ovl_En_Bubble_reloc.o" endseg beginseg @@ -1003,8 +980,7 @@ beginseg name "ovl_En_M_Thunder" compress include "build/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.o" - include "build/data/ovl_En_M_Thunder/ovl_En_M_Thunder.data.o" - include "build/data/ovl_En_M_Thunder/ovl_En_M_Thunder.reloc.o" + include "build/src/overlays/actors/ovl_En_M_Thunder/ovl_En_M_Thunder_reloc.o" endseg beginseg @@ -1133,8 +1109,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 @@ -1170,8 +1145,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 @@ -1185,16 +1159,14 @@ beginseg name "ovl_En_Encount1" compress include "build/src/overlays/actors/ovl_En_Encount1/z_en_encount1.o" - include "build/data/ovl_En_Encount1/ovl_En_Encount1.data.o" - include "build/data/ovl_En_Encount1/ovl_En_Encount1.reloc.o" + include "build/src/overlays/actors/ovl_En_Encount1/ovl_En_Encount1_reloc.o" endseg 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 @@ -1222,11 +1194,7 @@ beginseg name "ovl_Mir_Ray" compress include "build/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Mir_Ray/ovl_Mir_Ray_reloc.o" -#else - include "build/data/ovl_Mir_Ray/ovl_Mir_Ray.reloc.o" -#endif endseg beginseg @@ -1310,8 +1278,7 @@ beginseg name "ovl_Bg_Umajump" compress include "build/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.o" - include "build/data/ovl_Bg_Umajump/ovl_Bg_Umajump.data.o" - include "build/data/ovl_Bg_Umajump/ovl_Bg_Umajump.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Umajump/ovl_Bg_Umajump_reloc.o" endseg beginseg @@ -1339,8 +1306,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 @@ -1375,16 +1341,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 @@ -1405,8 +1369,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 @@ -1470,24 +1433,21 @@ 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 @@ -1522,8 +1482,7 @@ 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 @@ -1675,8 +1634,7 @@ beginseg name "ovl_En_Js" compress include "build/src/overlays/actors/ovl_En_Js/z_en_js.o" - include "build/data/ovl_En_Js/ovl_En_Js.data.o" - include "build/data/ovl_En_Js/ovl_En_Js.reloc.o" + include "build/src/overlays/actors/ovl_En_Js/ovl_En_Js_reloc.o" endseg beginseg @@ -1697,8 +1655,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 @@ -1728,8 +1685,7 @@ beginseg name "ovl_Oceff_Spot" compress include "build/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.o" - include "build/data/ovl_Oceff_Spot/ovl_Oceff_Spot.data.o" - include "build/data/ovl_Oceff_Spot/ovl_Oceff_Spot.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Spot/ovl_Oceff_Spot_reloc.o" endseg beginseg @@ -1743,8 +1699,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 @@ -1765,17 +1720,14 @@ beginseg name "ovl_Oceff_Wipe" compress include "build/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.data.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.bss.o" - include "build/data/ovl_Oceff_Wipe/ovl_Oceff_Wipe.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe/ovl_Oceff_Wipe_reloc.o" endseg beginseg name "ovl_Effect_Ss_Dust" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.o" - include "build/data/ovl_Effect_Ss_Dust/ovl_Effect_Ss_Dust.data.o" - include "build/data/ovl_Effect_Ss_Dust/ovl_Effect_Ss_Dust.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dust/ovl_Effect_Ss_Dust_reloc.o" endseg beginseg @@ -1789,32 +1741,28 @@ beginseg name "ovl_Effect_Ss_Bomb2" compress include "build/src/overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.o" - include "build/data/ovl_Effect_Ss_Bomb2/ovl_Effect_Ss_Bomb2.data.o" - include "build/data/ovl_Effect_Ss_Bomb2/ovl_Effect_Ss_Bomb2.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Bomb2/ovl_Effect_Ss_Bomb2_reloc.o" endseg beginseg name "ovl_Effect_Ss_Blast" compress include "build/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.o" - include "build/data/ovl_Effect_Ss_Blast/ovl_Effect_Ss_Blast.data.o" - include "build/data/ovl_Effect_Ss_Blast/ovl_Effect_Ss_Blast.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Blast/ovl_Effect_Ss_Blast_reloc.o" endseg 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 name "ovl_Effect_Ss_D_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.o" - include "build/data/ovl_Effect_Ss_D_Fire/ovl_Effect_Ss_D_Fire.data.o" - include "build/data/ovl_Effect_Ss_D_Fire/ovl_Effect_Ss_D_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_D_Fire/ovl_Effect_Ss_D_Fire_reloc.o" endseg beginseg @@ -1828,24 +1776,21 @@ beginseg name "ovl_Effect_Ss_G_Ripple" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Ripple/z_eff_ss_g_ripple.o" - include "build/data/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple.data.o" - include "build/data/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Ripple/ovl_Effect_Ss_G_Ripple_reloc.o" endseg beginseg name "ovl_Effect_Ss_G_Splash" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.o" - include "build/data/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash.data.o" - include "build/data/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Splash/ovl_Effect_Ss_G_Splash_reloc.o" endseg beginseg name "ovl_Effect_Ss_G_Fire" compress include "build/src/overlays/effects/ovl_Effect_Ss_G_Fire/z_eff_ss_g_fire.o" - include "build/data/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire.data.o" - include "build/data/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_G_Fire/ovl_Effect_Ss_G_Fire_reloc.o" endseg beginseg @@ -1859,16 +1804,14 @@ beginseg name "ovl_Effect_Ss_Dt_Bubble" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.o" - include "build/data/ovl_Effect_Ss_Dt_Bubble/ovl_Effect_Ss_Dt_Bubble.data.o" - include "build/data/ovl_Effect_Ss_Dt_Bubble/ovl_Effect_Ss_Dt_Bubble.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/ovl_Effect_Ss_Dt_Bubble_reloc.o" endseg 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 @@ -1896,32 +1839,28 @@ 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 name "ovl_Effect_Ss_Solder_Srch_Ball" compress include "build/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.o" - include "build/data/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball.data.o" - include "build/data/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/ovl_Effect_Ss_Solder_Srch_Ball_reloc.o" endseg beginseg @@ -1935,80 +1874,70 @@ 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 name "ovl_Effect_Ss_Dead_Db" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.o" - include "build/data/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db.data.o" - include "build/data/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Db/ovl_Effect_Ss_Dead_Db_reloc.o" endseg 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 name "ovl_Effect_Ss_Dead_Ds" compress include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/z_eff_ss_dead_ds.o" - include "build/data/ovl_Effect_Ss_Dead_Ds/ovl_Effect_Ss_Dead_Ds.data.o" - include "build/data/ovl_Effect_Ss_Dead_Ds/ovl_Effect_Ss_Dead_Ds.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/ovl_Effect_Ss_Dead_Ds_reloc.o" endseg beginseg name "ovl_Oceff_Storm" compress include "build/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.o" - include "build/data/ovl_Oceff_Storm/ovl_Oceff_Storm.data.o" - include "build/data/ovl_Oceff_Storm/ovl_Oceff_Storm.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Storm/ovl_Oceff_Storm_reloc.o" endseg 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 @@ -2029,18 +1958,14 @@ beginseg name "ovl_Oceff_Wipe2" compress include "build/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.o" - include "build/data/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.data.o" - include "build/data/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.bss.o" - include "build/data/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2_reloc.o" endseg beginseg name "ovl_Oceff_Wipe3" compress include "build/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.o" - include "build/data/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.data.o" - include "build/data/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.bss.o" - include "build/data/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3_reloc.o" endseg beginseg @@ -2083,16 +2008,14 @@ 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 name "ovl_En_Tg" compress include "build/src/overlays/actors/ovl_En_Tg/z_en_tg.o" - include "build/data/ovl_En_Tg/ovl_En_Tg.data.o" - include "build/data/ovl_En_Tg/ovl_En_Tg.reloc.o" + include "build/src/overlays/actors/ovl_En_Tg/ovl_En_Tg_reloc.o" endseg beginseg @@ -2142,9 +2065,7 @@ beginseg name "ovl_Oceff_Wipe4" compress include "build/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.o" - include "build/data/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.data.o" - include "build/data/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.bss.o" - include "build/data/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4_reloc.o" endseg beginseg @@ -2158,16 +2079,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 @@ -2218,8 +2137,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 @@ -2240,8 +2158,7 @@ beginseg name "ovl_En_Grasshopper" compress include "build/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.o" - include "build/data/ovl_En_Grasshopper/ovl_En_Grasshopper.data.o" - include "build/data/ovl_En_Grasshopper/ovl_En_Grasshopper.reloc.o" + include "build/src/overlays/actors/ovl_En_Grasshopper/ovl_En_Grasshopper_reloc.o" endseg beginseg @@ -2270,8 +2187,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 @@ -2301,8 +2217,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 @@ -2353,8 +2268,7 @@ beginseg name "ovl_En_Encount4" compress include "build/src/overlays/actors/ovl_En_Encount4/z_en_encount4.o" - include "build/data/ovl_En_Encount4/ovl_En_Encount4.data.o" - include "build/data/ovl_En_Encount4/ovl_En_Encount4.reloc.o" + include "build/src/overlays/actors/ovl_En_Encount4/ovl_En_Encount4_reloc.o" endseg beginseg @@ -2417,11 +2331,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 @@ -2562,11 +2472,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 @@ -2609,8 +2515,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 @@ -2631,8 +2536,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 @@ -2676,8 +2580,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 @@ -2705,24 +2608,21 @@ 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 name "ovl_En_Ru" compress include "build/src/overlays/actors/ovl_En_Ru/z_en_ru.o" - include "build/data/ovl_En_Ru/ovl_En_Ru.data.o" - include "build/data/ovl_En_Ru/ovl_En_Ru.reloc.o" + include "build/src/overlays/actors/ovl_En_Ru/ovl_En_Ru_reloc.o" endseg beginseg @@ -2765,17 +2665,14 @@ 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 name "ovl_En_Test3" compress include "build/src/overlays/actors/ovl_En_Test3/z_en_test3.o" - include "build/data/ovl_En_Test3/ovl_En_Test3.data.o" - include "build/data/ovl_En_Test3/ovl_En_Test3.bss.o" - include "build/data/ovl_En_Test3/ovl_En_Test3.reloc.o" + include "build/src/overlays/actors/ovl_En_Test3/ovl_En_Test3_reloc.o" endseg beginseg @@ -2789,25 +2686,21 @@ 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 name "ovl_En_Wiz" compress include "build/src/overlays/actors/ovl_En_Wiz/z_en_wiz.o" - include "build/data/ovl_En_Wiz/ovl_En_Wiz.data.o" - include "build/data/ovl_En_Wiz/ovl_En_Wiz.reloc.o" + include "build/src/overlays/actors/ovl_En_Wiz/ovl_En_Wiz_reloc.o" endseg beginseg @@ -2828,8 +2721,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 @@ -2857,16 +2749,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 @@ -2902,8 +2792,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 @@ -2924,8 +2813,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 @@ -2946,8 +2834,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 @@ -3018,9 +2905,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 @@ -3063,8 +2948,7 @@ beginseg name "ovl_En_Egol" compress include "build/src/overlays/actors/ovl_En_Egol/z_en_egol.o" - include "build/data/ovl_En_Egol/ovl_En_Egol.data.o" - include "build/data/ovl_En_Egol/ovl_En_Egol.reloc.o" + include "build/src/overlays/actors/ovl_En_Egol/ovl_En_Egol_reloc.o" endseg beginseg @@ -3080,8 +2964,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 @@ -3120,17 +3003,14 @@ beginseg name "ovl_En_Az" compress include "build/src/overlays/actors/ovl_En_Az/z_en_az.o" - include "build/data/ovl_En_Az/ovl_En_Az.data.o" - include "build/data/ovl_En_Az/ovl_En_Az.bss.o" - include "build/data/ovl_En_Az/ovl_En_Az.reloc.o" + include "build/src/overlays/actors/ovl_En_Az/ovl_En_Az_reloc.o" endseg beginseg name "ovl_En_Estone" compress include "build/src/overlays/actors/ovl_En_Estone/z_en_estone.o" - include "build/data/ovl_En_Estone/ovl_En_Estone.data.o" - include "build/data/ovl_En_Estone/ovl_En_Estone.reloc.o" + include "build/src/overlays/actors/ovl_En_Estone/ovl_En_Estone_reloc.o" endseg beginseg @@ -3144,8 +3024,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 @@ -3173,24 +3052,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 @@ -3204,8 +3080,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 @@ -3219,16 +3094,14 @@ beginseg name "ovl_Dm_Char08" compress include "build/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.o" - include "build/data/ovl_Dm_Char08/ovl_Dm_Char08.data.o" - include "build/data/ovl_Dm_Char08/ovl_Dm_Char08.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Char08/ovl_Dm_Char08_reloc.o" endseg 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 @@ -3250,8 +3123,7 @@ beginseg name "ovl_En_Egblock" compress include "build/src/overlays/actors/ovl_En_Egblock/z_en_egblock.o" - include "build/data/ovl_En_Egblock/ovl_En_Egblock.data.o" - include "build/data/ovl_En_Egblock/ovl_En_Egblock.reloc.o" + include "build/src/overlays/actors/ovl_En_Egblock/ovl_En_Egblock_reloc.o" endseg beginseg @@ -3280,8 +3152,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 @@ -3295,9 +3166,7 @@ beginseg name "ovl_En_Twig" compress include "build/src/overlays/actors/ovl_En_Twig/z_en_twig.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.data.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.bss.o" - include "build/data/ovl_En_Twig/ovl_En_Twig.reloc.o" + include "build/src/overlays/actors/ovl_En_Twig/ovl_En_Twig_reloc.o" endseg beginseg @@ -3311,8 +3180,7 @@ beginseg name "ovl_En_Door_Etc" compress include "build/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.o" - include "build/data/ovl_En_Door_Etc/ovl_En_Door_Etc.data.o" - include "build/data/ovl_En_Door_Etc/ovl_En_Door_Etc.reloc.o" + include "build/src/overlays/actors/ovl_En_Door_Etc/ovl_En_Door_Etc_reloc.o" endseg beginseg @@ -3326,17 +3194,14 @@ 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 name "ovl_fbdemo_triforce" compress include "build/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.o" - include "build/data/ovl_fbdemo_triforce/ovl_fbdemo_triforce.data.o" - include "build/data/ovl_fbdemo_triforce/ovl_fbdemo_triforce.reloc.o" + include "build/src/overlays/fbdemos/ovl_fbdemo_triforce/ovl_fbdemo_triforce_reloc.o" endseg beginseg @@ -3367,8 +3232,7 @@ beginseg name "ovl_fbdemo_wipe5" compress include "build/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.o" - include "build/data/ovl_fbdemo_wipe5/ovl_fbdemo_wipe5.data.o" - include "build/data/ovl_fbdemo_wipe5/ovl_fbdemo_wipe5.reloc.o" + include "build/src/overlays/fbdemos/ovl_fbdemo_wipe5/ovl_fbdemo_wipe5_reloc.o" endseg beginseg @@ -3382,24 +3246,21 @@ 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 @@ -3506,8 +3367,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 @@ -3521,8 +3381,7 @@ beginseg name "ovl_Bg_Dkjail_Ivy" compress include "build/src/overlays/actors/ovl_Bg_Dkjail_Ivy/z_bg_dkjail_ivy.o" - include "build/data/ovl_Bg_Dkjail_Ivy/ovl_Bg_Dkjail_Ivy.data.o" - include "build/data/ovl_Bg_Dkjail_Ivy/ovl_Bg_Dkjail_Ivy.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Dkjail_Ivy/ovl_Bg_Dkjail_Ivy_reloc.o" endseg beginseg @@ -3551,8 +3410,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 @@ -3588,8 +3446,7 @@ beginseg name "ovl_En_Lift_Nuts" compress include "build/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.o" - include "build/data/ovl_En_Lift_Nuts/ovl_En_Lift_Nuts.data.o" - include "build/data/ovl_En_Lift_Nuts/ovl_En_Lift_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Lift_Nuts/ovl_En_Lift_Nuts_reloc.o" endseg beginseg @@ -3610,8 +3467,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 @@ -3632,8 +3488,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 @@ -3648,8 +3503,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 @@ -3686,16 +3540,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 @@ -3745,8 +3597,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 @@ -3809,8 +3660,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 @@ -3860,8 +3710,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 @@ -3875,8 +3724,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 @@ -3890,11 +3738,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 @@ -4000,8 +3844,7 @@ beginseg name "ovl_En_Bee" compress include "build/src/overlays/actors/ovl_En_Bee/z_en_bee.o" - include "build/data/ovl_En_Bee/ovl_En_Bee.data.o" - include "build/data/ovl_En_Bee/ovl_En_Bee.reloc.o" + include "build/src/overlays/actors/ovl_En_Bee/ovl_En_Bee_reloc.o" endseg beginseg @@ -4036,11 +3879,7 @@ beginseg name "ovl_Obj_Kendo_Kanban" compress include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban_reloc.o" -#else - include "build/data/ovl_Obj_Kendo_Kanban/ovl_Obj_Kendo_Kanban.reloc.o" -#endif endseg beginseg @@ -4075,8 +3914,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 @@ -4090,8 +3928,7 @@ beginseg name "ovl_Bg_Kin2_Picture" compress include "build/src/overlays/actors/ovl_Bg_Kin2_Picture/z_bg_kin2_picture.o" - include "build/data/ovl_Bg_Kin2_Picture/ovl_Bg_Kin2_Picture.data.o" - include "build/data/ovl_Bg_Kin2_Picture/ovl_Bg_Kin2_Picture.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Kin2_Picture/ovl_Bg_Kin2_Picture_reloc.o" endseg beginseg @@ -4126,8 +3963,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 @@ -4155,8 +3991,7 @@ beginseg name "ovl_Bg_Ikana_Mirror" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Mirror/z_bg_ikana_mirror.o" - include "build/data/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror.data.o" - include "build/data/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ikana_Mirror/ovl_Bg_Ikana_Mirror_reloc.o" endseg beginseg @@ -4184,8 +4019,7 @@ beginseg name "ovl_En_Kaizoku" compress include "build/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.o" - include "build/data/ovl_En_Kaizoku/ovl_En_Kaizoku.data.o" - include "build/data/ovl_En_Kaizoku/ovl_En_Kaizoku.reloc.o" + include "build/src/overlays/actors/ovl_En_Kaizoku/ovl_En_Kaizoku_reloc.o" endseg beginseg @@ -4214,8 +4048,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 @@ -4244,8 +4077,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 @@ -4280,32 +4112,28 @@ 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 name "ovl_Obj_Y2shutter" compress include "build/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.o" - include "build/data/ovl_Obj_Y2shutter/ovl_Obj_Y2shutter.data.o" - include "build/data/ovl_Obj_Y2shutter/ovl_Obj_Y2shutter.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Y2shutter/ovl_Obj_Y2shutter_reloc.o" endseg 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 @@ -4326,11 +4154,7 @@ beginseg name "ovl_Mir_Ray3" compress include "build/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.o" -#ifdef NON_MATCHING include "build/src/overlays/actors/ovl_Mir_Ray3/ovl_Mir_Ray3_reloc.o" -#else - include "build/data/ovl_Mir_Ray3/ovl_Mir_Ray3.reloc.o" -#endif endseg beginseg @@ -4386,8 +4210,7 @@ beginseg name "ovl_En_Zod" compress include "build/src/overlays/actors/ovl_En_Zod/z_en_zod.o" - include "build/data/ovl_En_Zod/ovl_En_Zod.data.o" - include "build/data/ovl_En_Zod/ovl_En_Zod.reloc.o" + include "build/src/overlays/actors/ovl_En_Zod/ovl_En_Zod_reloc.o" endseg beginseg @@ -4457,16 +4280,14 @@ 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 name "ovl_En_Nb" compress include "build/src/overlays/actors/ovl_En_Nb/z_en_nb.o" - include "build/data/ovl_En_Nb/ovl_En_Nb.data.o" - include "build/data/ovl_En_Nb/ovl_En_Nb.reloc.o" + include "build/src/overlays/actors/ovl_En_Nb/ovl_En_Nb_reloc.o" endseg beginseg @@ -4509,17 +4330,14 @@ beginseg name "ovl_Oceff_Wipe5" compress include "build/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.data.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.bss.o" - include "build/data/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.reloc.o" + include "build/src/overlays/actors/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5_reloc.o" endseg beginseg name "ovl_En_Stone_heishi" compress include "build/src/overlays/actors/ovl_En_Stone_heishi/z_en_stone_heishi.o" - include "build/data/ovl_En_Stone_heishi/ovl_En_Stone_heishi.data.o" - include "build/data/ovl_En_Stone_heishi/ovl_En_Stone_heishi.reloc.o" + include "build/src/overlays/actors/ovl_En_Stone_heishi/ovl_En_Stone_heishi_reloc.o" endseg beginseg @@ -4547,18 +4365,14 @@ 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 @@ -4600,11 +4414,7 @@ beginseg name "ovl_Bg_Ikana_Bombwall" compress include "build/src/overlays/actors/ovl_Bg_Ikana_Bombwall/z_bg_ikana_bombwall.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 @@ -4625,8 +4435,7 @@ 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" + include "build/src/overlays/actors/ovl_Bg_Haka_Bombwall/ovl_Bg_Haka_Bombwall_reloc.o" endseg beginseg @@ -4640,16 +4449,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 @@ -4712,8 +4519,7 @@ beginseg name "ovl_En_Nimotsu" compress include "build/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.o" - include "build/data/ovl_En_Nimotsu/ovl_En_Nimotsu.data.o" - include "build/data/ovl_En_Nimotsu/ovl_En_Nimotsu.reloc.o" + include "build/src/overlays/actors/ovl_En_Nimotsu/ovl_En_Nimotsu_reloc.o" endseg beginseg @@ -4812,17 +4618,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 @@ -4865,8 +4668,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 @@ -4880,8 +4682,7 @@ beginseg name "ovl_En_Rz" compress include "build/src/overlays/actors/ovl_En_Rz/z_en_rz.o" - include "build/data/ovl_En_Rz/ovl_En_Rz.data.o" - include "build/data/ovl_En_Rz/ovl_En_Rz.reloc.o" + include "build/src/overlays/actors/ovl_En_Rz/ovl_En_Rz_reloc.o" endseg beginseg @@ -4895,8 +4696,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 @@ -4931,8 +4731,7 @@ beginseg name "ovl_En_Bombal" compress include "build/src/overlays/actors/ovl_En_Bombal/z_en_bombal.o" - include "build/data/ovl_En_Bombal/ovl_En_Bombal.data.o" - include "build/data/ovl_En_Bombal/ovl_En_Bombal.reloc.o" + include "build/src/overlays/actors/ovl_En_Bombal/ovl_En_Bombal_reloc.o" endseg beginseg @@ -4953,16 +4752,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 @@ -4976,8 +4773,7 @@ beginseg name "ovl_Obj_Usiyane" compress include "build/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.o" - include "build/data/ovl_Obj_Usiyane/ovl_Obj_Usiyane.data.o" - include "build/data/ovl_Obj_Usiyane/ovl_Obj_Usiyane.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Usiyane/ovl_Obj_Usiyane_reloc.o" endseg beginseg @@ -5013,8 +4809,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 @@ -5057,8 +4852,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 @@ -5094,8 +4888,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 @@ -5119,24 +4912,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 @@ -5150,8 +4940,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 @@ -5179,16 +4968,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 @@ -5202,16 +4989,14 @@ beginseg name "ovl_Dm_Tag" compress include "build/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.o" - include "build/data/ovl_Dm_Tag/ovl_Dm_Tag.data.o" - include "build/data/ovl_Dm_Tag/ovl_Dm_Tag.reloc.o" + include "build/src/overlays/actors/ovl_Dm_Tag/ovl_Dm_Tag_reloc.o" endseg 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 @@ -5260,8 +5045,7 @@ beginseg name "ovl_Obj_Swprize" compress include "build/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.o" - include "build/data/ovl_Obj_Swprize/ovl_Obj_Swprize.data.o" - include "build/data/ovl_Obj_Swprize/ovl_Obj_Swprize.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Swprize/ovl_Obj_Swprize_reloc.o" endseg beginseg @@ -7173,11 +6957,11 @@ beginseg endseg beginseg - name "object_dnq" + name "object_dno" compress romalign 0x1000 number 6 - include "build/assets/objects/object_dnq/object_dnq.o" + include "build/assets/objects/object_dno/object_dno.o" endseg beginseg @@ -7741,11 +7525,11 @@ beginseg endseg beginseg - name "object_dnp" + name "object_dnq" compress romalign 0x1000 number 6 - include "build/assets/objects/object_dnp/object_dnp.o" + include "build/assets/objects/object_dnq/object_dnq.o" endseg beginseg @@ -7909,11 +7693,11 @@ beginseg endseg beginseg - name "object_dno" + name "object_dnj" compress romalign 0x1000 number 6 - include "build/assets/objects/object_dno/object_dno.o" + include "build/assets/objects/object_dnj/object_dnj.o" endseg beginseg 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/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 da93f13fd..942435fa7 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/boot_O2_g3/irqmgr.c b/src/boot_O2_g3/irqmgr.c index f605dc327..b100f209d 100644 --- a/src/boot_O2_g3/irqmgr.c +++ b/src/boot_O2_g3/irqmgr.c @@ -5,22 +5,22 @@ volatile OSTime sIrqMgrResetTime = 0; volatile OSTime sIrqMgrRetraceTime = 0; s32 sIrqMgrRetraceCount = 0; -void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* param_2, OSMesgQueue* param_3) { +void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* client, OSMesgQueue* msgQueue) { u32 saveMask; saveMask = osSetIntMask(1); - param_2->queue = param_3; - param_2->next = irqmgr->callbacks; - irqmgr->callbacks = param_2; + client->queue = msgQueue; + client->next = irqmgr->callbacks; + irqmgr->callbacks = client; osSetIntMask(saveMask); if (irqmgr->prenmiStage > 0) { - osSendMesg(param_2->queue, &irqmgr->prenmiMsg.type, OS_MESG_NOBLOCK); + osSendMesg(client->queue, &irqmgr->prenmiMsg.type, OS_MESG_NOBLOCK); } if (irqmgr->prenmiStage > 1) { - osSendMesg(param_2->queue, &irqmgr->nmiMsg.type, OS_MESG_NOBLOCK); + osSendMesg(client->queue, &irqmgr->nmiMsg.type, OS_MESG_NOBLOCK); } } diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 80d819acc..63260e885 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,8 +1,9 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; u8* sYaz0CurDataEnd; -u32 sYaz0CurRomStart; +uintptr_t sYaz0CurRomStart; u32 sYaz0CurSize; u8* sYaz0MaxPtr; u8* D_8009BE20; @@ -122,7 +123,7 @@ s32 Yaz0_DecompressImpl(u8* src, u8* dst) { return 0; } -void Yaz0_Decompress(u32 romStart, void* dst, size_t size) { +void Yaz0_Decompress(uintptr_t romStart, void* dst, size_t size) { s32 status; u32 pad; char sp80[0x50]; diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index d9c7fb221..8e9d83872 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u32 sDmaMgrDmaBuffSize = 0x2000; @@ -59,7 +60,7 @@ s32 DmaMgr_DmaHandler(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { return osEPiStartDma(pihandle, mb, direction); } -DmaEntry* DmaMgr_FindDmaEntry(u32 vrom) { +DmaEntry* DmaMgr_FindDmaEntry(uintptr_t vrom) { DmaEntry* curr; for (curr = dmadata; curr->vromEnd != 0; curr++) { @@ -76,7 +77,7 @@ DmaEntry* DmaMgr_FindDmaEntry(u32 vrom) { return NULL; } -u32 DmaMgr_TranslateVromToRom(u32 vrom) { +u32 DmaMgr_TranslateVromToRom(uintptr_t vrom) { DmaEntry* entry = DmaMgr_FindDmaEntry(vrom); if (entry != NULL) { @@ -94,7 +95,7 @@ u32 DmaMgr_TranslateVromToRom(u32 vrom) { return -1; } -s32 DmaMgr_FindDmaIndex(u32 vrom) { +s32 DmaMgr_FindDmaIndex(uintptr_t vrom) { DmaEntry* entry = DmaMgr_FindDmaEntry(vrom); if (entry != NULL) { diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 0afb1df68..599f4c8d3 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; @@ -231,10 +229,11 @@ void func_80170798(PreRender* this, Gfx** gfxp) { gDPLoadMultiTile(gfx++, this->fbufSave, 0x0000, G_TX_RENDERTILE, G_IM_FMT_RGBA, G_IM_SIZ_16b, 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); - if (1) {} 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) {} 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 +246,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..eb931262b 100644 --- a/src/code/audio/audio_data.c +++ b/src/code/audio/audio_data.c @@ -850,29 +850,106 @@ 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 }; +NoteSampleState gZeroedSampleState = { 0 }; -NoteSubEu gDefaultNoteSub = { - { 1, 1, 0, 0, 0, 0, 0, 0 }, { 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +NoteSampleState gDefaultSampleState = { + { true, true, false, false, false, false, false, false }, + { 0 }, + 0, // gain + 0, // haasEffectLeftDelaySize + 0, // haasEffectRightDelaySize + 0, // targetReverbVol + 0, // harmonicIndexCurAndPrev + 0, // combFilterSize + 0, // targetVolLeft + 0, // targetVolRight + 0, // frequencyFixedPoint + 0, // combFilterGain + NULL, // tunedSample + NULL, // filter + 0, // unk_18 + 0, // surroundEffectIndex + 0, // unk_1A }; -u16 gHeadsetPanQuantization[64] = { - 60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, - 16, 14, 12, 10, 8, 6, 4, 2, 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, +u16 gHaasEffectDelaySize[64] = { + 30 * SAMPLE_SIZE, + 29 * SAMPLE_SIZE, + 28 * SAMPLE_SIZE, + 27 * SAMPLE_SIZE, + 26 * SAMPLE_SIZE, + 25 * SAMPLE_SIZE, + 24 * SAMPLE_SIZE, + 23 * SAMPLE_SIZE, + 22 * SAMPLE_SIZE, + 21 * SAMPLE_SIZE, + 20 * SAMPLE_SIZE, + 19 * SAMPLE_SIZE, + 18 * SAMPLE_SIZE, + 17 * SAMPLE_SIZE, + 16 * SAMPLE_SIZE, + 15 * SAMPLE_SIZE, + 14 * SAMPLE_SIZE, + 13 * SAMPLE_SIZE, + 12 * SAMPLE_SIZE, + 11 * SAMPLE_SIZE, + 10 * SAMPLE_SIZE, + 9 * SAMPLE_SIZE, + 8 * SAMPLE_SIZE, + 7 * SAMPLE_SIZE, + 6 * SAMPLE_SIZE, + 5 * SAMPLE_SIZE, + 4 * SAMPLE_SIZE, + 3 * SAMPLE_SIZE, + 2 * SAMPLE_SIZE, + 1 * SAMPLE_SIZE, + 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, }; s32 D_801D58A4 = 0; // clang-format off -s16 D_801D58A8[] = { +s16 gInvalidAdpcmCodeBook[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/code/audio/audio_effects.c b/src/code/audio/audio_effects.c index 2dcef2237..0dcdcda88 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; @@ -63,7 +63,7 @@ void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer) { } seqPlayer->fadeTimer--; - if (seqPlayer->fadeTimer == 0 && seqPlayer->state == 2) { + if ((seqPlayer->fadeTimer == 0) && (seqPlayer->state == SEQPLAYER_STATE_FADE_OUT)) { AudioSeq_SequencePlayerDisable(seqPlayer); return; } @@ -112,10 +112,10 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) { static f32 activeVibratoFreqScaleSum = 0.0f; static s32 activeVibratoCount = 0; f32 pitchChange; - f32 extent; - f32 invExtent; + f32 depth; + f32 invDepth; f32 result; - f32 scaledExtent; + f32 scaledDepth; VibratoSubStruct* subVib = vib->vibSubStruct; if (vib->delay != 0) { @@ -124,17 +124,17 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) { } if (subVib != NULL) { - if (vib->extentChangeTimer) { - if (vib->extentChangeTimer == 1) { - vib->extent = (s32)subVib->vibratoExtentTarget; + if (vib->depthChangeTimer) { + if (vib->depthChangeTimer == 1) { + vib->depth = (s32)subVib->vibratoDepthTarget; } else { - vib->extent += ((s32)subVib->vibratoExtentTarget - vib->extent) / (s32)vib->extentChangeTimer; + vib->depth += ((s32)subVib->vibratoDepthTarget - vib->depth) / (s32)vib->depthChangeTimer; } - vib->extentChangeTimer--; - } else if (subVib->vibratoExtentTarget != (s32)vib->extent) { - if ((vib->extentChangeTimer = subVib->vibratoExtentChangeDelay) == 0) { - vib->extent = (s32)subVib->vibratoExtentTarget; + vib->depthChangeTimer--; + } else if (subVib->vibratoDepthTarget != (s32)vib->depth) { + if ((vib->depthChangeTimer = subVib->vibratoDepthChangeDelay) == 0) { + vib->depth = (s32)subVib->vibratoDepthTarget; } } @@ -153,17 +153,17 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) { } } - if (vib->extent == 0.0f) { + if (vib->depth == 0.0f) { return 1.0f; } pitchChange = AudioEffects_GetVibratoPitchChange(vib) + 32768.0f; - scaledExtent = vib->extent / 4096.0f; - extent = scaledExtent + 1.0f; - invExtent = 1.0f / extent; + scaledDepth = vib->depth / 4096.0f; + depth = scaledDepth + 1.0f; + invDepth = 1.0f / depth; // inverse linear interpolation - result = 1.0f / ((extent - invExtent) * pitchChange / 65536.0f + invExtent); + result = 1.0f / ((depth - invDepth) * pitchChange / 65536.0f + invDepth); activeVibratoFreqScaleSum += result; activeVibratoCount++; @@ -196,10 +196,10 @@ void AudioEffects_NoteVibratoInit(Note* note) { subVib = vib->vibSubStruct; - if ((vib->extentChangeTimer = subVib->vibratoExtentChangeDelay) == 0) { - vib->extent = (s32)subVib->vibratoExtentTarget; + if ((vib->depthChangeTimer = subVib->vibratoDepthChangeDelay) == 0) { + vib->depth = (s32)subVib->vibratoDepthTarget; } else { - vib->extent = (s32)subVib->vibratoExtentStart; + vib->depth = (s32)subVib->vibratoDepthStart; } if ((vib->rateChangeTimer = subVib->vibratoRateChangeDelay) == 0) { @@ -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; @@ -243,12 +243,10 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) { break; } // fallthrough - case ADSR_STATE_START_LOOP: adsr->envIndex = 0; adsr->action.s.state = ADSR_STATE_LOOP; // fallthrough - retry: case ADSR_STATE_LOOP: adsr->delay = adsr->envelope[adsr->envIndex].delay; @@ -256,18 +254,21 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) { case ADSR_DISABLE: adsr->action.s.state = ADSR_STATE_DISABLED; break; + case ADSR_HANG: adsr->action.s.state = ADSR_STATE_HANG; break; + case ADSR_GOTO: adsr->envIndex = adsr->envelope[adsr->envIndex].arg; goto retry; + case ADSR_RESTART: adsr->action.s.state = ADSR_STATE_INITIAL; break; default: - adsr->delay *= gAudioContext.audioBufferParameters.unk_24; + adsr->delay *= gAudioCtx.audioBufferParameters.updatesPerFrameScaled; if (adsr->delay == 0) { adsr->delay = 1; } @@ -282,14 +283,13 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) { break; } // fallthrough - case ADSR_STATE_FADE: adsr->current += adsr->velocity; - if (--adsr->delay <= 0) { + adsr->delay--; + if (adsr->delay <= 0) { adsr->action.s.state = ADSR_STATE_LOOP; } // fallthrough - case ADSR_STATE_HANG: break; diff --git a/src/code/audio/audio_heap.c b/src/code/audio/audio_heap.c index b06f6a577..d767f7de3 100644 --- a/src/code/audio/audio_heap.c +++ b/src/code/audio/audio_heap.c @@ -4,62 +4,70 @@ void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id); void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize); SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size); void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry); -void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample); +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, Sample* sample); SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size); void AudioHeap_DiscardSampleCaches(void); void AudioHeap_DiscardSampleBank(s32 sampleBankId); void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId); void AudioHeap_DiscardSampleBanks(void); -void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags); +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 isFirstInit); #define gTatumsPerBeat (gAudioTatumInit[1]) -f32 func_8018B0F0(f32 arg0) { - return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0; +/** + * Effectively scales `updatesPerFrameInv` by the reciprocal of `scaleInv` + * `updatesPerFrameInvScaled` is just `updatesPerFrameInv` scaled down by a factor of 256.0f + * i.e. (256.0f * `updatesPerFrameInvScaled`) is just `updatesPerFrameInv` + */ +f32 AudioHeap_CalculateAdsrDecay(f32 scaleInv) { + return 256.0f * gAudioCtx.audioBufferParameters.updatesPerFrameInvScaled / scaleInv; } -void func_8018B10C(void) { +/** + * Initialize the decay rate table used for decaying notes as part of adsr + */ +void AudioHeap_InitAdsrDecayTable(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); + gAudioCtx.adsrDecayTable[255] = AudioHeap_CalculateAdsrDecay(0.25f); + gAudioCtx.adsrDecayTable[254] = AudioHeap_CalculateAdsrDecay(0.33f); + gAudioCtx.adsrDecayTable[253] = AudioHeap_CalculateAdsrDecay(0.5f); + gAudioCtx.adsrDecayTable[252] = AudioHeap_CalculateAdsrDecay(0.66f); + gAudioCtx.adsrDecayTable[251] = AudioHeap_CalculateAdsrDecay(0.75f); for (i = 128; i < 251; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(251 - i); + gAudioCtx.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(251 - i); } for (i = 16; i < 128; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(4 * (143 - i)); + gAudioCtx.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(4 * (143 - i)); } for (i = 1; i < 16; i++) { - gAudioContext.unk_3520[i] = func_8018B0F0(60 * (23 - i)); + gAudioCtx.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(60 * (23 - i)); } - gAudioContext.unk_3520[0] = 0.0f; + gAudioCtx.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; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.fontLoadStatus); i++) { + if (gAudioCtx.fontLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioCtx.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; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.sampleFontLoadStatus); i++) { + if (gAudioCtx.sampleFontLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioCtx.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; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.seqLoadStatus); i++) { + if (gAudioCtx.seqLoadStatus[i] != LOAD_STATUS_PERMANENT) { + gAudioCtx.seqLoadStatus[i] = LOAD_STATUS_NOT_LOADED; } } } @@ -67,18 +75,18 @@ void AudioHeap_ResetLoadStatus(void) { void AudioHeap_DiscardFont(s32 fontId) { s32 i; - for (i = 0; i < gAudioContext.numNotes; i++) { - Note* note = &gAudioContext.notes[i]; + for (i = 0; i < gAudioCtx.numNotes; i++) { + Note* note = &gAudioCtx.notes[i]; if (note->playbackState.fontId == fontId) { - if ((note->playbackState.unk_04 == 0) && (note->playbackState.priority != 0)) { + if ((note->playbackState.status == PLAYBACK_STATUS_0) && (note->playbackState.priority != 0)) { note->playbackState.parentLayer->enabled = false; note->playbackState.parentLayer->finished = true; } AudioPlayback_NoteDisable(note); AudioPlayback_AudioListRemove(¬e->listItem); - AudioSeq_AudioListPushBack(&gAudioContext.noteFreeLists.disabled, ¬e->listItem); + AudioSeq_AudioListPushBack(&gAudioCtx.noteFreeLists.disabled, ¬e->listItem); } } } @@ -86,14 +94,14 @@ void AudioHeap_DiscardFont(s32 fontId) { void AudioHeap_ReleaseNotesForFont(s32 fontId) { s32 i; - for (i = 0; i < gAudioContext.numNotes; i++) { - Note* note = &gAudioContext.notes[i]; + for (i = 0; i < gAudioCtx.numNotes; i++) { + Note* note = &gAudioCtx.notes[i]; NotePlaybackState* playbackState = ¬e->playbackState; if (playbackState->fontId == fontId) { if (playbackState->priority != 0) { playbackState->priority = 1; - playbackState->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv; playbackState->adsr.action.s.release = true; } } @@ -103,9 +111,9 @@ void AudioHeap_ReleaseNotesForFont(s32 fontId) { void AudioHeap_DiscardSequence(s32 seqId) { s32 i; - for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { - if (gAudioContext.seqPlayers[i].enabled && gAudioContext.seqPlayers[i].seqId == seqId) { - AudioSeq_SequencePlayerDisable(&gAudioContext.seqPlayers[i]); + for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioCtx.seqPlayers[i].enabled && gAudioCtx.seqPlayers[i].seqId == seqId) { + AudioSeq_SequencePlayerDisable(&gAudioCtx.seqPlayers[i]); } } } @@ -129,8 +137,8 @@ void* AudioHeap_WritebackDCache(void* addr, size_t size) { void* AudioHeap_AllocZeroedAttemptExternal(AudioAllocPool* pool, size_t size) { void* addr = NULL; - if (gAudioContext.externalPool.startAddr != NULL) { - addr = AudioHeap_AllocZeroed(&gAudioContext.externalPool, size); + if (gAudioCtx.externalPool.startAddr != NULL) { + addr = AudioHeap_AllocZeroed(&gAudioCtx.externalPool, size); } if (addr == NULL) { @@ -147,8 +155,8 @@ void* AudioHeap_AllocZeroedAttemptExternal(AudioAllocPool* pool, size_t size) { void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size) { void* addr = NULL; - if (gAudioContext.externalPool.startAddr != NULL) { - addr = AudioHeap_Alloc(&gAudioContext.externalPool, size); + if (gAudioCtx.externalPool.startAddr != NULL) { + addr = AudioHeap_Alloc(&gAudioCtx.externalPool, size); } if (addr == NULL) { @@ -233,19 +241,19 @@ void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size) { * Initialize a pool at the requested address with the requested size. * Store the metadata of this pool in AudioAllocPool* pool */ -void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size) { +void AudioHeap_InitPool(AudioAllocPool* pool, void* addr, size_t size) { pool->curAddr = pool->startAddr = (u8*)ALIGN16((uintptr_t)addr); pool->size = size - ((uintptr_t)addr & 0xF); pool->count = 0; } -void AudioHeap_ClearPersistentCache(AudioPersistentCache* persistent) { +void AudioHeap_InitPersistentCache(AudioPersistentCache* persistent) { persistent->pool.count = 0; persistent->numEntries = 0; persistent->pool.curAddr = persistent->pool.startAddr; } -void AudioHeap_ClearTemporaryCache(AudioTemporaryCache* temporary) { +void AudioHeap_InitTemporaryCache(AudioTemporaryCache* temporary) { temporary->pool.count = 0; temporary->pool.curAddr = temporary->pool.startAddr; temporary->nextSide = 0; @@ -260,7 +268,7 @@ void AudioHeap_ResetPool(AudioAllocPool* pool) { pool->curAddr = pool->startAddr; } -void AudioHeap_PopCache(s32 tableType) { +void AudioHeap_PopPersistentCache(s32 tableType) { AudioCache* loadedCache; AudioAllocPool* persistentHeap; AudioPersistentCache* persistent; @@ -269,18 +277,18 @@ void AudioHeap_PopCache(s32 tableType) { switch (tableType) { case SEQUENCE_TABLE: - loadedCache = &gAudioContext.seqCache; - loadStatus = gAudioContext.seqLoadStatus; + loadedCache = &gAudioCtx.seqCache; + loadStatus = gAudioCtx.seqLoadStatus; break; case FONT_TABLE: - loadedCache = &gAudioContext.fontCache; - loadStatus = gAudioContext.fontLoadStatus; + loadedCache = &gAudioCtx.fontCache; + loadStatus = gAudioCtx.fontLoadStatus; break; case SAMPLE_TABLE: - loadedCache = &gAudioContext.sampleBankCache; - loadStatus = gAudioContext.sampleFontLoadStatus; + loadedCache = &gAudioCtx.sampleBankCache; + loadStatus = gAudioCtx.sampleFontLoadStatus; break; } @@ -302,73 +310,68 @@ 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--; } -void AudioHeap_InitMainPool(size_t mainPoolSplitSize) { - AudioHeap_AllocPoolInit(&gAudioContext.audioInitPool, gAudioContext.audioHeap, mainPoolSplitSize); - AudioHeap_AllocPoolInit(&gAudioContext.audioSessionPool, gAudioContext.audioHeap + mainPoolSplitSize, - gAudioContext.audioHeapSize - mainPoolSplitSize); +void AudioHeap_InitMainPool(size_t initPoolSize) { + AudioHeap_InitPool(&gAudioCtx.initPool, gAudioCtx.audioHeap, initPoolSize); + AudioHeap_InitPool(&gAudioCtx.sessionPool, gAudioCtx.audioHeap + initPoolSize, + gAudioCtx.audioHeapSize - initPoolSize); - gAudioContext.externalPool.startAddr = NULL; + gAudioCtx.externalPool.startAddr = NULL; } void AudioHeap_InitSessionPool(AudioSessionPoolSplit* split) { - gAudioContext.audioSessionPool.curAddr = gAudioContext.audioSessionPool.startAddr; + gAudioCtx.sessionPool.curAddr = gAudioCtx.sessionPool.startAddr; - AudioHeap_AllocPoolInit(&gAudioContext.miscPool, - AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->miscPoolSize), split->miscPoolSize); - AudioHeap_AllocPoolInit(&gAudioContext.cachePool, - AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->cachePoolSize), - split->cachePoolSize); + AudioHeap_InitPool(&gAudioCtx.miscPool, AudioHeap_Alloc(&gAudioCtx.sessionPool, split->miscPoolSize), + split->miscPoolSize); + AudioHeap_InitPool(&gAudioCtx.cachePool, AudioHeap_Alloc(&gAudioCtx.sessionPool, split->cachePoolSize), + split->cachePoolSize); } void AudioHeap_InitCachePool(AudioCachePoolSplit* split) { - gAudioContext.cachePool.curAddr = gAudioContext.cachePool.startAddr; + gAudioCtx.cachePool.curAddr = gAudioCtx.cachePool.startAddr; - AudioHeap_AllocPoolInit(&gAudioContext.persistentCommonPool, - AudioHeap_Alloc(&gAudioContext.cachePool, split->persistentCommonPoolSize), - split->persistentCommonPoolSize); - AudioHeap_AllocPoolInit(&gAudioContext.temporaryCommonPool, - AudioHeap_Alloc(&gAudioContext.cachePool, split->temporaryCommonPoolSize), - split->temporaryCommonPoolSize); + AudioHeap_InitPool(&gAudioCtx.persistentCommonPool, + AudioHeap_Alloc(&gAudioCtx.cachePool, split->persistentCommonPoolSize), + split->persistentCommonPoolSize); + AudioHeap_InitPool(&gAudioCtx.temporaryCommonPool, + AudioHeap_Alloc(&gAudioCtx.cachePool, split->temporaryCommonPoolSize), + split->temporaryCommonPoolSize); } -void AudioHeap_InitPersistentCache(AudioCommonPoolSplit* split) { - gAudioContext.persistentCommonPool.curAddr = gAudioContext.persistentCommonPool.startAddr; +void AudioHeap_InitPersistentPoolsAndCaches(AudioCommonPoolSplit* split) { + gAudioCtx.persistentCommonPool.curAddr = gAudioCtx.persistentCommonPool.startAddr; - AudioHeap_AllocPoolInit(&gAudioContext.seqCache.persistent.pool, - AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->seqCacheSize), - split->seqCacheSize); - AudioHeap_AllocPoolInit(&gAudioContext.fontCache.persistent.pool, - AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->fontCacheSize), - split->fontCacheSize); - AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.persistent.pool, - AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->sampleBankCacheSize), - split->sampleBankCacheSize); + AudioHeap_InitPool(&gAudioCtx.seqCache.persistent.pool, + AudioHeap_Alloc(&gAudioCtx.persistentCommonPool, split->seqCacheSize), split->seqCacheSize); + AudioHeap_InitPool(&gAudioCtx.fontCache.persistent.pool, + AudioHeap_Alloc(&gAudioCtx.persistentCommonPool, split->fontCacheSize), split->fontCacheSize); + AudioHeap_InitPool(&gAudioCtx.sampleBankCache.persistent.pool, + AudioHeap_Alloc(&gAudioCtx.persistentCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); - AudioHeap_ClearPersistentCache(&gAudioContext.seqCache.persistent); - AudioHeap_ClearPersistentCache(&gAudioContext.fontCache.persistent); - AudioHeap_ClearPersistentCache(&gAudioContext.sampleBankCache.persistent); + AudioHeap_InitPersistentCache(&gAudioCtx.seqCache.persistent); + AudioHeap_InitPersistentCache(&gAudioCtx.fontCache.persistent); + AudioHeap_InitPersistentCache(&gAudioCtx.sampleBankCache.persistent); } -void AudioHeap_InitTemporaryCache(AudioCommonPoolSplit* split) { - gAudioContext.temporaryCommonPool.curAddr = gAudioContext.temporaryCommonPool.startAddr; +void AudioHeap_InitTemporaryPoolsAndCaches(AudioCommonPoolSplit* split) { + gAudioCtx.temporaryCommonPool.curAddr = gAudioCtx.temporaryCommonPool.startAddr; - AudioHeap_AllocPoolInit(&gAudioContext.seqCache.temporary.pool, - AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->seqCacheSize), - split->seqCacheSize); - AudioHeap_AllocPoolInit(&gAudioContext.fontCache.temporary.pool, - AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->fontCacheSize), - split->fontCacheSize); - AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.temporary.pool, - AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->sampleBankCacheSize), - split->sampleBankCacheSize); + AudioHeap_InitPool(&gAudioCtx.seqCache.temporary.pool, + AudioHeap_Alloc(&gAudioCtx.temporaryCommonPool, split->seqCacheSize), split->seqCacheSize); + AudioHeap_InitPool(&gAudioCtx.fontCache.temporary.pool, + AudioHeap_Alloc(&gAudioCtx.temporaryCommonPool, split->fontCacheSize), split->fontCacheSize); + AudioHeap_InitPool(&gAudioCtx.sampleBankCache.temporary.pool, + AudioHeap_Alloc(&gAudioCtx.temporaryCommonPool, split->sampleBankCacheSize), + split->sampleBankCacheSize); - AudioHeap_ClearTemporaryCache(&gAudioContext.seqCache.temporary); - AudioHeap_ClearTemporaryCache(&gAudioContext.fontCache.temporary); - AudioHeap_ClearTemporaryCache(&gAudioContext.sampleBankCache.temporary); + AudioHeap_InitTemporaryCache(&gAudioCtx.seqCache.temporary); + AudioHeap_InitTemporaryCache(&gAudioCtx.fontCache.temporary); + AudioHeap_InitTemporaryCache(&gAudioCtx.sampleBankCache.temporary); } void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { @@ -385,18 +388,18 @@ void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) { switch (tableType) { case SEQUENCE_TABLE: - loadedCache = &gAudioContext.seqCache; - loadStatus = gAudioContext.seqLoadStatus; + loadedCache = &gAudioCtx.seqCache; + loadStatus = gAudioCtx.seqLoadStatus; break; case FONT_TABLE: - loadedCache = &gAudioContext.fontCache; - loadStatus = gAudioContext.fontLoadStatus; + loadedCache = &gAudioCtx.fontCache; + loadStatus = gAudioCtx.fontLoadStatus; break; case SAMPLE_TABLE: - loadedCache = &gAudioContext.sampleBankCache; - loadStatus = gAudioContext.sampleFontLoadStatus; + loadedCache = &gAudioCtx.sampleBankCache; + loadStatus = gAudioCtx.sampleFontLoadStatus; break; } @@ -409,102 +412,102 @@ 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) { - for (i = 0; i < gAudioContext.numNotes; i++) { - if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + if (loadStatusEntry0 == LOAD_STATUS_MAYBE_DISCARDABLE) { + for (i = 0; i < gAudioCtx.numNotes; i++) { + if ((gAudioCtx.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioCtx.notes[i].sampleState.bitField0.enabled) { break; } } - if (i == gAudioContext.numNotes) { - AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_3); - loadStatusEntry0 = LOAD_STATUS_3; + if (i == gAudioCtx.numNotes) { + AudioLoad_SetFontLoadStatus(temporaryCache->entries[0].id, LOAD_STATUS_DISCARDABLE); + loadStatusEntry0 = LOAD_STATUS_DISCARDABLE; } } - if (loadStatusEntry1 == LOAD_STATUS_4) { - for (i = 0; i < gAudioContext.numNotes; i++) { - if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + if (loadStatusEntry1 == LOAD_STATUS_MAYBE_DISCARDABLE) { + for (i = 0; i < gAudioCtx.numNotes; i++) { + if ((gAudioCtx.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioCtx.notes[i].sampleState.bitField0.enabled) { break; } } - if (i == gAudioContext.numNotes) { - AudioLoad_SetFontLoadStatus(temporaryCache->entries[1].id, LOAD_STATUS_3); - loadStatusEntry1 = LOAD_STATUS_3; + if (i == gAudioCtx.numNotes) { + 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) { - for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { - if (gAudioContext.seqPlayers[i].enabled && - gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[0].id) { + if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) { + for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioCtx.seqPlayers[i].enabled && + gAudioCtx.seqPlayers[i].seqId == temporaryCache->entries[0].id) { break; } } - if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + if (i == gAudioCtx.audioBufferParameters.numSequencePlayers) { temporaryCache->nextSide = 0; goto done; } } - if (loadStatusEntry1 == LOAD_STATUS_2) { - for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { - if (gAudioContext.seqPlayers[i].enabled && - gAudioContext.seqPlayers[i].seqId == temporaryCache->entries[1].id) { + if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) { + for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioCtx.seqPlayers[i].enabled && + gAudioCtx.seqPlayers[i].seqId == temporaryCache->entries[1].id) { break; } } - if (i == gAudioContext.audioBufferParameters.numSequencePlayers) { + if (i == gAudioCtx.audioBufferParameters.numSequencePlayers) { temporaryCache->nextSide = 1; goto done; } } } else if (tableType == FONT_TABLE) { - if (loadStatusEntry0 == LOAD_STATUS_2) { - for (i = 0; i < gAudioContext.numNotes; i++) { - if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) { + for (i = 0; i < gAudioCtx.numNotes; i++) { + if ((gAudioCtx.notes[i].playbackState.fontId == temporaryCache->entries[0].id) && + gAudioCtx.notes[i].sampleState.bitField0.enabled) { break; } } - if (i == gAudioContext.numNotes) { + if (i == gAudioCtx.numNotes) { temporaryCache->nextSide = 0; goto done; } } - if (loadStatusEntry1 == LOAD_STATUS_2) { - for (i = 0; i < gAudioContext.numNotes; i++) { - if ((gAudioContext.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && - gAudioContext.notes[i].noteSubEu.bitField0.enabled) { + if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) { + for (i = 0; i < gAudioCtx.numNotes; i++) { + if ((gAudioCtx.notes[i].playbackState.fontId == temporaryCache->entries[1].id) && + gAudioCtx.notes[i].sampleState.bitField0.enabled) { break; } } - if (i == gAudioContext.numNotes) { + if (i == gAudioCtx.numNotes) { temporaryCache->nextSide = 1; goto done; } @@ -514,15 +517,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 +547,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 +567,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 +597,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: @@ -663,15 +666,15 @@ void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id) { switch (tableType) { case SEQUENCE_TABLE: - loadedCache = &gAudioContext.seqCache; + loadedCache = &gAudioCtx.seqCache; break; case FONT_TABLE: - loadedCache = &gAudioContext.fontCache; + loadedCache = &gAudioCtx.fontCache; break; case SAMPLE_TABLE: - loadedCache = &gAudioContext.sampleBankCache; + loadedCache = &gAudioCtx.sampleBankCache; break; } @@ -764,7 +767,7 @@ void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff) { s32 cutOff; //! @bug filter is never set if (lowPassCutoff == highPassCutoff) and does not equal 0 - if (lowPassCutoff == 0 && highPassCutoff == 0) { + if ((lowPassCutoff == 0) && (highPassCutoff == 0)) { // Identity filter AudioHeap_LoadLowPassFilter(filter, 0); } else if (highPassCutoff == 0) { @@ -810,18 +813,18 @@ void AudioHeap_UpdateReverb(SynthesisReverb* reverb) { void AudioHeap_UpdateReverbs(void) { s32 count; - s32 i; + s32 reverbIndex; s32 j; - if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + if (gAudioCtx.audioBufferParameters.specUnk4 == 2) { count = 2; } else { count = 1; } - for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { + for (reverbIndex = 0; reverbIndex < gAudioCtx.numSynthesisReverbs; reverbIndex++) { for (j = 0; j < count; j++) { - AudioHeap_UpdateReverb(&gAudioContext.synthesisReverbs[i]); + AudioHeap_UpdateReverb(&gAudioCtx.synthesisReverbs[reverbIndex]); } } } @@ -830,13 +833,13 @@ void AudioHeap_UpdateReverbs(void) { * Clear the Audio Interface Buffers */ void AudioHeap_ClearAiBuffers(void) { - s32 curAiBuffferIndex = gAudioContext.curAiBuffferIndex; + s32 curAiBufferIndex = gAudioCtx.curAiBufferIndex; s32 i; - gAudioContext.aiBufLengths[curAiBuffferIndex] = gAudioContext.audioBufferParameters.minAiBufferLength; + gAudioCtx.numSamplesPerFrame[curAiBufferIndex] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMin; for (i = 0; i < AIBUF_LEN; i++) { - gAudioContext.aiBuffers[curAiBuffferIndex][i] = 0; + gAudioCtx.aiBuffers[curAiBufferIndex][i] = 0; } } @@ -845,55 +848,55 @@ s32 AudioHeap_ResetStep(void) { s32 j; s32 count; - if (gAudioContext.audioBufferParameters.specUnk4 == 2) { + if (gAudioCtx.audioBufferParameters.specUnk4 == 2) { count = 2; } else { count = 1; } - switch (gAudioContext.resetStatus) { + switch (gAudioCtx.resetStatus) { case 5: - for (i = 0; i < gAudioContext.audioBufferParameters.numSequencePlayers; i++) { - AudioSeq_SequencePlayerDisableAsFinished(&gAudioContext.seqPlayers[i]); + for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[i]); } - gAudioContext.audioResetFadeOutFramesLeft = 2 / count; - gAudioContext.resetStatus--; + gAudioCtx.audioResetFadeOutFramesLeft = 2 / count; + gAudioCtx.resetStatus--; break; case 4: - if (gAudioContext.audioResetFadeOutFramesLeft != 0) { - gAudioContext.audioResetFadeOutFramesLeft--; + if (gAudioCtx.audioResetFadeOutFramesLeft != 0) { + gAudioCtx.audioResetFadeOutFramesLeft--; AudioHeap_UpdateReverbs(); } else { - for (i = 0; i < gAudioContext.numNotes; i++) { - if (gAudioContext.notes[i].noteSubEu.bitField0.enabled && - gAudioContext.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) { - gAudioContext.notes[i].playbackState.adsr.fadeOutVel = - gAudioContext.audioBufferParameters.updatesPerFrameInv; - gAudioContext.notes[i].playbackState.adsr.action.s.release = true; + for (i = 0; i < gAudioCtx.numNotes; i++) { + if (gAudioCtx.notes[i].sampleState.bitField0.enabled && + gAudioCtx.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) { + gAudioCtx.notes[i].playbackState.adsr.fadeOutVel = + gAudioCtx.audioBufferParameters.updatesPerFrameInv; + gAudioCtx.notes[i].playbackState.adsr.action.s.release = true; } } - gAudioContext.audioResetFadeOutFramesLeft = 8 / count; - gAudioContext.resetStatus--; + gAudioCtx.audioResetFadeOutFramesLeft = 8 / count; + gAudioCtx.resetStatus--; } break; case 3: - if (gAudioContext.audioResetFadeOutFramesLeft != 0) { - gAudioContext.audioResetFadeOutFramesLeft--; + if (gAudioCtx.audioResetFadeOutFramesLeft != 0) { + gAudioCtx.audioResetFadeOutFramesLeft--; AudioHeap_UpdateReverbs(); } else { - gAudioContext.audioResetFadeOutFramesLeft = 2 / count; - gAudioContext.resetStatus--; + gAudioCtx.audioResetFadeOutFramesLeft = 2 / count; + gAudioCtx.resetStatus--; } break; case 2: AudioHeap_ClearAiBuffers(); - if (gAudioContext.audioResetFadeOutFramesLeft != 0) { - gAudioContext.audioResetFadeOutFramesLeft--; + if (gAudioCtx.audioResetFadeOutFramesLeft != 0) { + gAudioCtx.audioResetFadeOutFramesLeft--; } else { - gAudioContext.resetStatus--; + gAudioCtx.resetStatus--; AudioHeap_DiscardSampleCaches(); AudioHeap_DiscardSampleBanks(); } @@ -901,17 +904,17 @@ s32 AudioHeap_ResetStep(void) { case 1: AudioHeap_Init(); - gAudioContext.resetStatus = 0; - for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { - gAudioContext.aiBufLengths[i] = gAudioContext.audioBufferParameters.maxAiBufferLength; + gAudioCtx.resetStatus = 0; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.numSamplesPerFrame); i++) { + gAudioCtx.numSamplesPerFrame[i] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMax; for (j = 0; j < AIBUF_LEN; j++) { - gAudioContext.aiBuffers[i][j] = 0; + gAudioCtx.aiBuffers[i][j] = 0; } } break; } - if (gAudioContext.resetStatus < 3) { + if (gAudioCtx.resetStatus < 3) { return false; } @@ -926,71 +929,70 @@ void AudioHeap_Init(void) { size_t cachePoolSize; size_t miscPoolSize; u32 intMask; + s32 reverbIndex; s32 i; - s32 j; s32 pad2; - AudioSpec* spec = &gAudioSpecs[gAudioContext.audioResetSpecIdToLoad]; // Audio Specifications + AudioSpec* spec = &gAudioSpecs[gAudioCtx.specId]; // Audio Specifications - gAudioContext.sampleDmaCount = 0; + gAudioCtx.sampleDmaCount = 0; // audio buffer parameters - gAudioContext.audioBufferParameters.samplingFreq = spec->samplingFreq; - gAudioContext.audioBufferParameters.aiSamplingFreq = - osAiSetFrequency(gAudioContext.audioBufferParameters.samplingFreq); + gAudioCtx.audioBufferParameters.samplingFreq = spec->samplingFreq; + gAudioCtx.audioBufferParameters.aiSamplingFreq = osAiSetFrequency(gAudioCtx.audioBufferParameters.samplingFreq); - gAudioContext.audioBufferParameters.samplesPerFrameTarget = - ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate); - gAudioContext.audioBufferParameters.minAiBufferLength = - gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10; - gAudioContext.audioBufferParameters.maxAiBufferLength = - gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10; - gAudioContext.audioBufferParameters.updatesPerFrame = - ((gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1; - gAudioContext.audioBufferParameters.samplesPerUpdate = (gAudioContext.audioBufferParameters.samplesPerFrameTarget / - gAudioContext.audioBufferParameters.updatesPerFrame) & - ~7; - gAudioContext.audioBufferParameters.samplesPerUpdateMax = gAudioContext.audioBufferParameters.samplesPerUpdate + 8; - gAudioContext.audioBufferParameters.samplesPerUpdateMin = gAudioContext.audioBufferParameters.samplesPerUpdate - 8; - gAudioContext.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioContext.audioBufferParameters.samplingFreq; - gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled = - (1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame; - gAudioContext.audioBufferParameters.unk_24 = gAudioContext.audioBufferParameters.updatesPerFrame * 0.25f; - gAudioContext.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioContext.audioBufferParameters.updatesPerFrame; + gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget = + ALIGN16(gAudioCtx.audioBufferParameters.samplingFreq / gAudioCtx.refreshRate); + gAudioCtx.audioBufferParameters.numSamplesPerFrameMin = + gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget - 0x10; + gAudioCtx.audioBufferParameters.numSamplesPerFrameMax = + gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget + 0x10; + gAudioCtx.audioBufferParameters.updatesPerFrame = + ((gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget + 0x10) / 0xD0) + 1; + gAudioCtx.audioBufferParameters.numSamplesPerUpdate = + (gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget / gAudioCtx.audioBufferParameters.updatesPerFrame) & + ~7; + gAudioCtx.audioBufferParameters.numSamplesPerUpdateMax = gAudioCtx.audioBufferParameters.numSamplesPerUpdate + 8; + gAudioCtx.audioBufferParameters.numSamplesPerUpdateMin = gAudioCtx.audioBufferParameters.numSamplesPerUpdate - 8; + gAudioCtx.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioCtx.audioBufferParameters.samplingFreq; + gAudioCtx.audioBufferParameters.updatesPerFrameInvScaled = + (1.0f / 256.0f) / gAudioCtx.audioBufferParameters.updatesPerFrame; + gAudioCtx.audioBufferParameters.updatesPerFrameScaled = gAudioCtx.audioBufferParameters.updatesPerFrame / 4.0f; + gAudioCtx.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioCtx.audioBufferParameters.updatesPerFrame; // sample dma size - gAudioContext.sampleDmaBufSize1 = spec->sampleDmaBufSize1; - gAudioContext.sampleDmaBufSize2 = spec->sampleDmaBufSize2; + gAudioCtx.sampleDmaBufSize1 = spec->sampleDmaBufSize1; + gAudioCtx.sampleDmaBufSize2 = spec->sampleDmaBufSize2; - gAudioContext.numNotes = spec->numNotes; - gAudioContext.audioBufferParameters.numSequencePlayers = spec->numSequencePlayers; + gAudioCtx.numNotes = spec->numNotes; + gAudioCtx.audioBufferParameters.numSequencePlayers = spec->numSequencePlayers; - if (gAudioContext.audioBufferParameters.numSequencePlayers > 5) { - gAudioContext.audioBufferParameters.numSequencePlayers = 5; + if (gAudioCtx.audioBufferParameters.numSequencePlayers > 5) { + gAudioCtx.audioBufferParameters.numSequencePlayers = 5; } - gAudioContext.unk_29BC = 8; - gAudioContext.unk_2 = spec->unk_14; - gAudioContext.tempoInternalToExternal = (u32)(gAudioContext.audioBufferParameters.updatesPerFrame * 2880000.0f / - gTatumsPerBeat / gAudioContext.unk_2960); + gAudioCtx.numAbiCmdsMax = 8; + gAudioCtx.unk_2 = spec->unk_14; + gAudioCtx.maxTempo = + (u32)(gAudioCtx.audioBufferParameters.updatesPerFrame * 2880000.0f / gTatumsPerBeat / gAudioCtx.unk_2960); - gAudioContext.unk_2870 = gAudioContext.refreshRate; - gAudioContext.unk_2870 *= gAudioContext.audioBufferParameters.updatesPerFrame; - gAudioContext.unk_2870 /= gAudioContext.audioBufferParameters.aiSamplingFreq; - gAudioContext.unk_2870 /= gAudioContext.tempoInternalToExternal; + gAudioCtx.unk_2870 = gAudioCtx.refreshRate; + gAudioCtx.unk_2870 *= gAudioCtx.audioBufferParameters.updatesPerFrame; + gAudioCtx.unk_2870 /= gAudioCtx.audioBufferParameters.aiSamplingFreq; + gAudioCtx.unk_2870 /= gAudioCtx.maxTempo; - gAudioContext.audioBufferParameters.specUnk4 = spec->unk_04; - gAudioContext.audioBufferParameters.samplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4; - gAudioContext.audioBufferParameters.maxAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; - gAudioContext.audioBufferParameters.minAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4; - gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4; + gAudioCtx.audioBufferParameters.specUnk4 = spec->unk_04; + gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget *= gAudioCtx.audioBufferParameters.specUnk4; + gAudioCtx.audioBufferParameters.numSamplesPerFrameMax *= gAudioCtx.audioBufferParameters.specUnk4; + gAudioCtx.audioBufferParameters.numSamplesPerFrameMin *= gAudioCtx.audioBufferParameters.specUnk4; + gAudioCtx.audioBufferParameters.updatesPerFrame *= gAudioCtx.audioBufferParameters.specUnk4; - if (gAudioContext.audioBufferParameters.specUnk4 >= 2) { - gAudioContext.audioBufferParameters.maxAiBufferLength -= 0x10; + if (gAudioCtx.audioBufferParameters.specUnk4 >= 2) { + gAudioCtx.audioBufferParameters.numSamplesPerFrameMax -= 0x10; } // Determine the maximum allowable number of audio command list entries for the rsp microcode - gAudioContext.maxAudioCmds = - gAudioContext.numNotes * 20 * gAudioContext.audioBufferParameters.updatesPerFrame + spec->numReverbs * 30 + 800; + gAudioCtx.maxAudioCmds = + gAudioCtx.numNotes * 20 * gAudioCtx.audioBufferParameters.updatesPerFrame + spec->numReverbs * 30 + 800; // Calculate sizes for various caches on the audio heap persistentSize = @@ -998,81 +1000,81 @@ void AudioHeap_Init(void) { temporarySize = spec->temporarySeqCacheSize + spec->temporaryFontCacheSize + spec->temporarySampleBankCacheSize + 0x10; cachePoolSize = persistentSize + temporarySize; - miscPoolSize = gAudioContext.audioSessionPool.size - cachePoolSize - 0x100; + miscPoolSize = gAudioCtx.sessionPool.size - cachePoolSize - 0x100; - if (gAudioContext.externalPool.startAddr != NULL) { - gAudioContext.externalPool.curAddr = gAudioContext.externalPool.startAddr; + if (gAudioCtx.externalPool.startAddr != NULL) { + gAudioCtx.externalPool.curAddr = gAudioCtx.externalPool.startAddr; } // Session Pool Split (split into Cache and Misc heaps) - gAudioContext.sessionPoolSplit.miscPoolSize = miscPoolSize; - gAudioContext.sessionPoolSplit.cachePoolSize = cachePoolSize; - AudioHeap_InitSessionPool(&gAudioContext.sessionPoolSplit); + gAudioCtx.sessionPoolSplit.miscPoolSize = miscPoolSize; + gAudioCtx.sessionPoolSplit.cachePoolSize = cachePoolSize; + AudioHeap_InitSessionPool(&gAudioCtx.sessionPoolSplit); // Cache Pool Split (Split into Persistent and Temporary heaps) - gAudioContext.cachePoolSplit.persistentCommonPoolSize = persistentSize; - gAudioContext.cachePoolSplit.temporaryCommonPoolSize = temporarySize; - AudioHeap_InitCachePool(&gAudioContext.cachePoolSplit); + gAudioCtx.cachePoolSplit.persistentCommonPoolSize = persistentSize; + gAudioCtx.cachePoolSplit.temporaryCommonPoolSize = temporarySize; + AudioHeap_InitCachePool(&gAudioCtx.cachePoolSplit); // Persistent Pool Split (Split into Sequences, SoundFonts, Samples) - gAudioContext.persistentCommonPoolSplit.seqCacheSize = spec->persistentSeqCacheSize; - gAudioContext.persistentCommonPoolSplit.fontCacheSize = spec->persistentFontCacheSize; - gAudioContext.persistentCommonPoolSplit.sampleBankCacheSize = spec->persistentSampleBankCacheSize; - AudioHeap_InitPersistentCache(&gAudioContext.persistentCommonPoolSplit); + gAudioCtx.persistentCommonPoolSplit.seqCacheSize = spec->persistentSeqCacheSize; + gAudioCtx.persistentCommonPoolSplit.fontCacheSize = spec->persistentFontCacheSize; + gAudioCtx.persistentCommonPoolSplit.sampleBankCacheSize = spec->persistentSampleBankCacheSize; + AudioHeap_InitPersistentPoolsAndCaches(&gAudioCtx.persistentCommonPoolSplit); // Temporary Pool Split (Split into Sequences, SoundFonts, Samples) - gAudioContext.temporaryCommonPoolSplit.seqCacheSize = spec->temporarySeqCacheSize; - gAudioContext.temporaryCommonPoolSplit.fontCacheSize = spec->temporaryFontCacheSize; - gAudioContext.temporaryCommonPoolSplit.sampleBankCacheSize = spec->temporarySampleBankCacheSize; - AudioHeap_InitTemporaryCache(&gAudioContext.temporaryCommonPoolSplit); + gAudioCtx.temporaryCommonPoolSplit.seqCacheSize = spec->temporarySeqCacheSize; + gAudioCtx.temporaryCommonPoolSplit.fontCacheSize = spec->temporaryFontCacheSize; + gAudioCtx.temporaryCommonPoolSplit.sampleBankCacheSize = spec->temporarySampleBankCacheSize; + AudioHeap_InitTemporaryPoolsAndCaches(&gAudioCtx.temporaryCommonPoolSplit); AudioHeap_ResetLoadStatus(); // Initialize notes - gAudioContext.notes = AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.numNotes * sizeof(Note)); + gAudioCtx.notes = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, gAudioCtx.numNotes * sizeof(Note)); AudioPlayback_NoteInitAll(); AudioPlayback_InitNoteFreeList(); - gAudioContext.noteSubsEu = - AudioHeap_AllocZeroed(&gAudioContext.miscPool, gAudioContext.audioBufferParameters.updatesPerFrame * - gAudioContext.numNotes * sizeof(NoteSubEu)); + gAudioCtx.sampleStateList = + AudioHeap_AllocZeroed(&gAudioCtx.miscPool, gAudioCtx.audioBufferParameters.updatesPerFrame * + gAudioCtx.numNotes * sizeof(NoteSampleState)); // Initialize audio binary interface command list buffer - for (j = 0; j < ARRAY_COUNT(gAudioContext.abiCmdBufs); j++) { - gAudioContext.abiCmdBufs[j] = - AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64)); + for (i = 0; i < ARRAY_COUNT(gAudioCtx.abiCmdBufs); i++) { + gAudioCtx.abiCmdBufs[i] = + AudioHeap_AllocDmaMemoryZeroed(&gAudioCtx.miscPool, gAudioCtx.maxAudioCmds * sizeof(Acmd)); } - // Initialize unk_3520 (fadeOutVelocities for ADSR) - gAudioContext.unk_3520 = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32)); - func_8018B10C(); + // Initialize the decay rate table for ADSR + gAudioCtx.adsrDecayTable = AudioHeap_Alloc(&gAudioCtx.miscPool, 0x100 * sizeof(f32)); + AudioHeap_InitAdsrDecayTable(); // Initialize reverbs - for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) { - gAudioContext.synthesisReverbs[i].useReverb = 0; + for (reverbIndex = 0; reverbIndex < ARRAY_COUNT(gAudioCtx.synthesisReverbs); reverbIndex++) { + gAudioCtx.synthesisReverbs[reverbIndex].useReverb = 0; } - gAudioContext.numSynthesisReverbs = spec->numReverbs; - for (i = 0; i < gAudioContext.numSynthesisReverbs; i++) { - AudioHeap_InitReverb(i, &spec->reverbSettings[i], 1); + gAudioCtx.numSynthesisReverbs = spec->numReverbs; + for (reverbIndex = 0; reverbIndex < gAudioCtx.numSynthesisReverbs; reverbIndex++) { + AudioHeap_InitReverb(reverbIndex, &spec->reverbSettings[reverbIndex], true); } // Initialize sequence players AudioSeq_InitSequencePlayers(); - for (j = 0; j < gAudioContext.audioBufferParameters.numSequencePlayers; j++) { - AudioSeq_InitSequencePlayerChannels(j); - AudioSeq_ResetSequencePlayer(&gAudioContext.seqPlayers[j]); + for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + AudioSeq_InitSequencePlayerChannels(i); + AudioSeq_ResetSequencePlayer(&gAudioCtx.seqPlayers[i]); } // Initialize two additional caches on the audio heap to store individual audio samples AudioHeap_InitSampleCaches(spec->persistentSampleCacheSize, spec->temporarySampleCacheSize); - AudioLoad_InitSampleDmaBuffers(gAudioContext.numNotes); + AudioLoad_InitSampleDmaBuffers(gAudioCtx.numNotes); // Initalize Loads - gAudioContext.preloadSampleStackTop = 0; + gAudioCtx.preloadSampleStackTop = 0; AudioLoad_InitSlowLoads(); AudioLoad_InitScriptLoads(); AudioLoad_InitAsyncLoads(); - gAudioContext.unk_4 = 0x1000; + gAudioCtx.unk_4 = 0x1000; AudioLoad_LoadPermanentSamples(); intMask = osSetIntMask(1); @@ -1083,9 +1085,9 @@ void AudioHeap_Init(void) { void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id) { s32 i; - for (i = 0; i < gAudioContext.permanentPool.count; i++) { - if (gAudioContext.permanentEntries[i].tableType == tableType && gAudioContext.permanentEntries[i].id == id) { - return gAudioContext.permanentEntries[i].addr; + for (i = 0; i < gAudioCtx.permanentPool.count; i++) { + if (gAudioCtx.permanentEntries[i].tableType == tableType && gAudioCtx.permanentEntries[i].id == id) { + return gAudioCtx.permanentEntries[i].addr; } } return NULL; @@ -1093,18 +1095,18 @@ void* AudioHeap_SearchPermanentCache(s32 tableType, s32 id) { void* AudioHeap_AllocPermanent(s32 tableType, s32 id, size_t size) { void* addr; - s32 index = gAudioContext.permanentPool.count; + s32 index = gAudioCtx.permanentPool.count; - addr = AudioHeap_Alloc(&gAudioContext.permanentPool, size); - gAudioContext.permanentEntries[index].addr = addr; + addr = AudioHeap_Alloc(&gAudioCtx.permanentPool, size); + gAudioCtx.permanentEntries[index].addr = addr; if (addr == NULL) { return NULL; } - gAudioContext.permanentEntries[index].tableType = tableType; - gAudioContext.permanentEntries[index].id = id; - gAudioContext.permanentEntries[index].size = size; + gAudioCtx.permanentEntries[index].tableType = tableType; + gAudioCtx.permanentEntries[index].id = id; + gAudioCtx.permanentEntries[index].size = size; //! @bug UB: missing return. "addr" is in v0 at this point, but doing an // explicit return uses an additional register. // return addr; @@ -1135,22 +1137,22 @@ void* AudioHeap_AllocSampleCache(size_t size, s32 sampleBankId, void* sampleAddr void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize) { void* addr; - addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, persistentSampleCacheSize); + addr = AudioHeap_AllocAttemptExternal(&gAudioCtx.miscPool, persistentSampleCacheSize); if (addr == NULL) { - gAudioContext.persistentSampleCache.pool.size = 0; + gAudioCtx.persistentSampleCache.pool.size = 0; } else { - AudioHeap_AllocPoolInit(&gAudioContext.persistentSampleCache.pool, addr, persistentSampleCacheSize); + AudioHeap_InitPool(&gAudioCtx.persistentSampleCache.pool, addr, persistentSampleCacheSize); } - addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, temporarySampleCacheSize); + addr = AudioHeap_AllocAttemptExternal(&gAudioCtx.miscPool, temporarySampleCacheSize); if (addr == NULL) { - gAudioContext.temporarySampleCache.pool.size = 0; + gAudioCtx.temporarySampleCache.pool.size = 0; } else { - AudioHeap_AllocPoolInit(&gAudioContext.temporarySampleCache.pool, addr, temporarySampleCacheSize); + AudioHeap_InitPool(&gAudioCtx.temporarySampleCache.pool, addr, temporarySampleCacheSize); } - gAudioContext.persistentSampleCache.numEntries = 0; - gAudioContext.temporarySampleCache.numEntries = 0; + gAudioCtx.persistentSampleCache.numEntries = 0; + gAudioCtx.temporarySampleCache.numEntries = 0; } SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { @@ -1168,7 +1170,7 @@ SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { u8* startAddr; u8* endAddr; - cache = &gAudioContext.temporarySampleCache; + cache = &gAudioCtx.temporarySampleCache; allocBefore = cache->pool.curAddr; addr = AudioHeap_Alloc(&cache->pool, size); if (addr == NULL) { @@ -1189,8 +1191,8 @@ SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { allocAfter = cache->pool.curAddr; index = -1; - for (i = 0; i < gAudioContext.preloadSampleStackTop; i++) { - preload = &gAudioContext.preloadSampleStack[i]; + for (i = 0; i < gAudioCtx.preloadSampleStackTop; i++) { + preload = &gAudioCtx.preloadSampleStack[i]; if (preload->isFree == false) { startAddr = preload->ramAddr; endAddr = preload->ramAddr + preload->sample->size - 1; @@ -1257,35 +1259,35 @@ SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) { void AudioHeap_UnapplySampleCacheForFont(SampleCacheEntry* entry, s32 fontId) { Drum* drum; Instrument* inst; - SoundFontSound* sfx; + SoundEffect* soundEffect; s32 instId; s32 drumId; s32 sfxId; - for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + for (instId = 0; instId < gAudioCtx.soundFontList[fontId].numInstruments; instId++) { inst = AudioPlayback_GetInstrumentInner(fontId, instId); if (inst != NULL) { if (inst->normalRangeLo != 0) { - AudioHeap_UnapplySampleCache(entry, inst->lowNotesSound.sample); + AudioHeap_UnapplySampleCache(entry, inst->lowPitchTunedSample.sample); } if (inst->normalRangeHi != 0x7F) { - AudioHeap_UnapplySampleCache(entry, inst->highNotesSound.sample); + AudioHeap_UnapplySampleCache(entry, inst->highPitchTunedSample.sample); } - AudioHeap_UnapplySampleCache(entry, inst->normalNotesSound.sample); + AudioHeap_UnapplySampleCache(entry, inst->normalPitchTunedSample.sample); } } - for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + for (drumId = 0; drumId < gAudioCtx.soundFontList[fontId].numDrums; drumId++) { drum = AudioPlayback_GetDrum(fontId, drumId); if (drum != NULL) { - AudioHeap_UnapplySampleCache(entry, drum->sound.sample); + AudioHeap_UnapplySampleCache(entry, drum->tunedSample.sample); } } - for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { - sfx = AudioPlayback_GetSfx(fontId, sfxId); - if (sfx != NULL) { - AudioHeap_UnapplySampleCache(entry, sfx->sample); + for (sfxId = 0; sfxId < gAudioCtx.soundFontList[fontId].numSfx; sfxId++) { + soundEffect = AudioPlayback_GetSoundEffect(fontId, sfxId); + if (soundEffect != NULL) { + AudioHeap_UnapplySampleCache(entry, soundEffect->tunedSample.sample); } } } @@ -1296,10 +1298,10 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { s32 sampleBankId2; s32 fontId; - numFonts = gAudioContext.soundFontTable->numEntries; + numFonts = gAudioCtx.soundFontTable->numEntries; for (fontId = 0; fontId < numFonts; fontId++) { - sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + sampleBankId1 = gAudioCtx.soundFontList[fontId].sampleBankId1; + sampleBankId2 = gAudioCtx.soundFontList[fontId].sampleBankId2; if (((sampleBankId1 != 0xFF) && (entry->sampleBankId == sampleBankId1)) || ((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || entry->sampleBankId == 0 || entry->sampleBankId == 0xFE) { @@ -1313,7 +1315,7 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) { } } -void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) { +void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, Sample* sample) { if (sample != NULL) { if (sample->sampleAddr == entry->allocatedAddr) { sample->sampleAddr = entry->sampleAddr; @@ -1327,7 +1329,7 @@ SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size) { SampleCacheEntry* entry; void* addr; - cache = &gAudioContext.persistentSampleCache; + cache = &gAudioCtx.persistentSampleCache; addr = AudioHeap_Alloc(&cache->pool, size); if (addr == NULL) { return NULL; @@ -1360,10 +1362,10 @@ void AudioHeap_DiscardSampleCaches(void) { s32 fontId; s32 j; - numFonts = gAudioContext.soundFontTable->numEntries; + numFonts = gAudioCtx.soundFontTable->numEntries; for (fontId = 0; fontId < numFonts; fontId++) { - sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + sampleBankId1 = gAudioCtx.soundFontList[fontId].sampleBankId1; + sampleBankId2 = gAudioCtx.soundFontList[fontId].sampleBankId2; if ((sampleBankId1 == 0xFF) && (sampleBankId2 == 0xFF)) { continue; } @@ -1372,12 +1374,12 @@ void AudioHeap_DiscardSampleCaches(void) { continue; } - for (j = 0; j < gAudioContext.persistentSampleCache.numEntries; j++) { - AudioHeap_DiscardSampleCacheForFont(&gAudioContext.persistentSampleCache.entries[j], sampleBankId1, + for (j = 0; j < gAudioCtx.persistentSampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioCtx.persistentSampleCache.entries[j], sampleBankId1, sampleBankId2, fontId); } - for (j = 0; j < gAudioContext.temporarySampleCache.numEntries; j++) { - AudioHeap_DiscardSampleCacheForFont(&gAudioContext.temporarySampleCache.entries[j], sampleBankId1, + for (j = 0; j < gAudioCtx.temporarySampleCache.numEntries; j++) { + AudioHeap_DiscardSampleCacheForFont(&gAudioCtx.temporarySampleCache.entries[j], sampleBankId1, sampleBankId2, fontId); } } @@ -1390,7 +1392,7 @@ typedef struct { u8 newMedium; } StorageChange; -void AudioHeap_ChangeStorage(StorageChange* change, SoundFontSample* sample) { +void AudioHeap_ChangeStorage(StorageChange* change, Sample* sample) { if (sample != NULL && ((sample->medium == change->newMedium) || (D_801FD120 != 1)) && ((sample->medium == MEDIUM_RAM) || (D_801FD120 != 0))) { uintptr_t startAddr = change->oldAddr; @@ -1430,12 +1432,12 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { s32 fontId; Drum* drum; Instrument* inst; - SoundFontSound* sfx; + SoundEffect* soundEffect; uintptr_t* newAddr; s32 pad[4]; - sampleBankTable = gAudioContext.sampleBankTable; - numFonts = gAudioContext.soundFontTable->numEntries; + sampleBankTable = gAudioCtx.sampleBankTable; + numFonts = gAudioCtx.soundFontTable->numEntries; change.oldAddr = AudioHeap_SearchCaches(SAMPLE_TABLE, CACHE_EITHER, sampleBankId); if (change.oldAddr == 0) { return; @@ -1457,8 +1459,8 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { } for (fontId = 0; fontId < numFonts; fontId++) { - sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + sampleBankId1 = gAudioCtx.soundFontList[fontId].sampleBankId1; + sampleBankId2 = gAudioCtx.soundFontList[fontId].sampleBankId2; if ((sampleBankId1 != 0xFF) || (sampleBankId2 != 0xFF)) { if (!AudioLoad_IsFontLoadComplete(fontId) || AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) == NULL) { @@ -1471,30 +1473,30 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) { continue; } - for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) { + for (instId = 0; instId < gAudioCtx.soundFontList[fontId].numInstruments; instId++) { inst = AudioPlayback_GetInstrumentInner(fontId, instId); if (inst != NULL) { if (inst->normalRangeLo != 0) { - AudioHeap_ChangeStorage(&change, inst->lowNotesSound.sample); + AudioHeap_ChangeStorage(&change, inst->lowPitchTunedSample.sample); } if (inst->normalRangeHi != 0x7F) { - AudioHeap_ChangeStorage(&change, inst->highNotesSound.sample); + AudioHeap_ChangeStorage(&change, inst->highPitchTunedSample.sample); } - AudioHeap_ChangeStorage(&change, inst->normalNotesSound.sample); + AudioHeap_ChangeStorage(&change, inst->normalPitchTunedSample.sample); } } - for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) { + for (drumId = 0; drumId < gAudioCtx.soundFontList[fontId].numDrums; drumId++) { drum = AudioPlayback_GetDrum(fontId, drumId); if (drum != NULL) { - AudioHeap_ChangeStorage(&change, drum->sound.sample); + AudioHeap_ChangeStorage(&change, drum->tunedSample.sample); } } - for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) { - sfx = AudioPlayback_GetSfx(fontId, sfxId); - if (sfx != NULL) { - AudioHeap_ChangeStorage(&change, sfx->sample); + for (sfxId = 0; sfxId < gAudioCtx.soundFontList[fontId].numSfx; sfxId++) { + soundEffect = AudioPlayback_GetSoundEffect(fontId, sfxId); + if (soundEffect != NULL) { + AudioHeap_ChangeStorage(&change, soundEffect->tunedSample.sample); } } } @@ -1507,7 +1509,7 @@ void AudioHeap_DiscardSampleBanks(void) { AudioTemporaryCache* temporary; u32 i; - cache = &gAudioContext.sampleBankCache; + cache = &gAudioCtx.sampleBankCache; temporary = &cache->temporary; if (temporary->entries[0].id != -1) { @@ -1524,164 +1526,175 @@ void AudioHeap_DiscardSampleBanks(void) { } } -void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 flags) { - s32 windowSize; - SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; +void AudioHeap_SetReverbData(s32 reverbIndex, u32 dataType, s32 data, s32 isFirstInit) { + s32 delayNumSamples; + SynthesisReverb* reverb = &gAudioCtx.synthesisReverbs[reverbIndex]; switch (dataType) { - case 0: - AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, 0); + case REVERB_DATA_TYPE_SETTINGS: + AudioHeap_InitReverb(reverbIndex, (ReverbSettings*)data, false); break; - case 1: + + case REVERB_DATA_TYPE_DELAY: if (data < 4) { data = 4; } - windowSize = data * 64; - if (windowSize < 0x100) { - windowSize = 0x100; + delayNumSamples = data * 64; + if (delayNumSamples < (16 * SAMPLES_PER_FRAME)) { + delayNumSamples = 16 * SAMPLES_PER_FRAME; } - windowSize /= reverb->downsampleRate; + delayNumSamples /= reverb->downsampleRate; - if (flags == 0) { - if (reverb->unk_1E >= (data / reverb->downsampleRate)) { - if ((reverb->nextRingBufPos >= windowSize) || (reverb->unk_24 >= windowSize)) { - reverb->nextRingBufPos = 0; - reverb->unk_24 = 0; - } - } else { + if (!isFirstInit) { + if (reverb->delayNumSamplesAfterDownsampling < (data / reverb->downsampleRate)) { break; } + if ((reverb->nextReverbBufPos >= delayNumSamples) || (reverb->delayNumSamplesUnk >= delayNumSamples)) { + reverb->nextReverbBufPos = 0; + reverb->delayNumSamplesUnk = 0; + } } - reverb->windowSize = windowSize; + reverb->delayNumSamples = delayNumSamples; - if ((reverb->downsampleRate != 1) || reverb->unk_18) { - reverb->unk_0E = 0x8000 / reverb->downsampleRate; - if (reverb->unk_30 == NULL) { - reverb->unk_30 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); - reverb->unk_34 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); - reverb->unk_38 = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); - reverb->unk_3C = AudioHeap_AllocZeroed(&gAudioContext.miscPool, 0x20); - if (reverb->unk_3C == NULL) { + if ((reverb->downsampleRate != 1) || reverb->resampleEffectOn) { + reverb->downsamplePitch = 0x8000 / reverb->downsampleRate; + if (reverb->leftLoadResampleBuf == NULL) { + reverb->leftLoadResampleBuf = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(RESAMPLE_STATE)); + reverb->rightLoadResampleBuf = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(RESAMPLE_STATE)); + reverb->leftSaveResampleBuf = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(RESAMPLE_STATE)); + reverb->rightSaveResampleBuf = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(RESAMPLE_STATE)); + if (reverb->rightSaveResampleBuf == NULL) { reverb->downsampleRate = 1; } } } break; - case 2: - gAudioContext.synthesisReverbs[reverbIndex].unk_0C = data; + + case REVERB_DATA_TYPE_DECAY: + gAudioCtx.synthesisReverbs[reverbIndex].decayRatio = data; break; - case 3: - gAudioContext.synthesisReverbs[reverbIndex].unk_16 = data; + + case REVERB_DATA_TYPE_SUB_VOLUME: + gAudioCtx.synthesisReverbs[reverbIndex].subVolume = data; break; - case 4: - gAudioContext.synthesisReverbs[reverbIndex].unk_0A = data; + + case REVERB_DATA_TYPE_VOLUME: + gAudioCtx.synthesisReverbs[reverbIndex].volume = data; break; - case 5: - gAudioContext.synthesisReverbs[reverbIndex].leakRtl = data; + + case REVERB_DATA_TYPE_LEAK_RIGHT: + gAudioCtx.synthesisReverbs[reverbIndex].leakRtl = data; break; - case 6: - gAudioContext.synthesisReverbs[reverbIndex].leakLtr = data; + + case REVERB_DATA_TYPE_LEAK_LEFT: + gAudioCtx.synthesisReverbs[reverbIndex].leakLtr = data; break; - case 7: + + case REVERB_DATA_TYPE_FILTER_LEFT: if (data != 0) { - if ((flags != 0) || (reverb->unk_278 == 0)) { - reverb->filterLeftState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); - reverb->unk_278 = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + if (isFirstInit || (reverb->filterLeftInit == NULL)) { + reverb->filterLeftState = + AudioHeap_AllocDmaMemoryZeroed(&gAudioCtx.miscPool, 2 * (FILTER_BUF_PART1 + FILTER_BUF_PART2)); + reverb->filterLeftInit = AudioHeap_AllocDmaMemory(&gAudioCtx.miscPool, FILTER_SIZE); } - reverb->filterLeft = reverb->unk_278; - if (reverb->filterLeft != 0) { + reverb->filterLeft = reverb->filterLeftInit; + if (reverb->filterLeft != NULL) { AudioHeap_LoadLowPassFilter(reverb->filterLeft, data); } } else { - reverb->filterLeft = 0; + reverb->filterLeft = NULL; - if (flags != 0) { - reverb->unk_278 = 0; + if (isFirstInit) { + reverb->filterLeftInit = NULL; } } - break; - case 8: + + case REVERB_DATA_TYPE_FILTER_RIGHT: if (data != 0) { - if ((flags != 0) || (reverb->unk_27C == 0)) { - reverb->filterRightState = AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, 0x40); - reverb->unk_27C = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + if (isFirstInit || (reverb->filterRightInit == NULL)) { + reverb->filterRightState = + AudioHeap_AllocDmaMemoryZeroed(&gAudioCtx.miscPool, 2 * (FILTER_BUF_PART1 + FILTER_BUF_PART2)); + reverb->filterRightInit = AudioHeap_AllocDmaMemory(&gAudioCtx.miscPool, FILTER_SIZE); } - reverb->filterRight = reverb->unk_27C; - if (reverb->unk_27C != 0) { - AudioHeap_LoadLowPassFilter(reverb->unk_27C, data); + reverb->filterRight = reverb->filterRightInit; + if (reverb->filterRight != NULL) { + AudioHeap_LoadLowPassFilter(reverb->filterRight, data); } } else { - reverb->filterRight = 0; - if (flags != 0) { - reverb->unk_27C = 0; + reverb->filterRight = NULL; + if (isFirstInit) { + reverb->filterRightInit = NULL; } } break; - case 9: - reverb->unk_19 = data; + + case REVERB_DATA_TYPE_9: + reverb->resampleEffectExtraSamples = data; if (data == 0) { - reverb->unk_18 = false; + reverb->resampleEffectOn = false; } else { - reverb->unk_18 = true; + reverb->resampleEffectOn = true; } break; + default: break; } } -void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags) { - SynthesisReverb* reverb = &gAudioContext.synthesisReverbs[reverbIndex]; +void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 isFirstInit) { + SynthesisReverb* reverb = &gAudioCtx.synthesisReverbs[reverbIndex]; - if (flags != 0) { - reverb->unk_1E = settings->windowSize / settings->downsampleRate; - reverb->unk_30 = 0; - } else if (reverb->unk_1E < (settings->windowSize / settings->downsampleRate)) { + if (isFirstInit) { + reverb->delayNumSamplesAfterDownsampling = settings->delayNumSamples / settings->downsampleRate; + reverb->leftLoadResampleBuf = NULL; + } else if (reverb->delayNumSamplesAfterDownsampling < (settings->delayNumSamples / settings->downsampleRate)) { return; } reverb->downsampleRate = settings->downsampleRate; - reverb->unk_18 = false; - reverb->unk_19 = 0; - reverb->unk_1A = 0; - reverb->unk_1C = 0; - AudioHeap_SetReverbData(reverbIndex, 1, settings->windowSize, flags); - reverb->unk_0C = settings->unk_4; - reverb->unk_0A = settings->unk_A; - reverb->unk_14 = settings->unk_6 << 6; - reverb->unk_16 = settings->unk_8; + reverb->resampleEffectOn = false; + reverb->resampleEffectExtraSamples = 0; + reverb->resampleEffectLoadUnk = 0; + reverb->resampleEffectSaveUnk = 0; + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_DELAY, settings->delayNumSamples, isFirstInit); + reverb->decayRatio = settings->decayRatio; + reverb->volume = settings->volume; + reverb->subDelay = settings->subDelay * 64; + reverb->subVolume = settings->subVolume; reverb->leakRtl = settings->leakRtl; reverb->leakLtr = settings->leakLtr; - reverb->unk_05 = settings->unk_10; - reverb->unk_08 = settings->unk_12; - reverb->useReverb = 8; + reverb->mixReverbIndex = settings->mixReverbIndex; + reverb->mixReverbStrength = settings->mixReverbStrength; + reverb->useReverb = 8; // used as a boolean - if (flags != 0) { - reverb->leftRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); - reverb->rightRingBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioContext.miscPool, reverb->windowSize * 2); + if (isFirstInit) { + reverb->leftReverbBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioCtx.miscPool, reverb->delayNumSamples * 2); + reverb->rightReverbBuf = AudioHeap_AllocZeroedAttemptExternal(&gAudioCtx.miscPool, reverb->delayNumSamples * 2); reverb->resampleFlags = 1; - reverb->nextRingBufPos = 0; - reverb->unk_24 = 0; + reverb->nextReverbBufPos = 0; + reverb->delayNumSamplesUnk = 0; reverb->curFrame = 0; reverb->framesToIgnore = 2; } - reverb->sound.sample = &reverb->sample; + reverb->tunedSample.sample = &reverb->sample; reverb->sample.loop = &reverb->loop; - reverb->sound.tuning = 1.0f; + reverb->tunedSample.tuning = 1.0f; reverb->sample.codec = CODEC_REVERB; reverb->sample.medium = MEDIUM_RAM; - reverb->sample.size = reverb->windowSize * 2; - reverb->sample.sampleAddr = (u8*)reverb->leftRingBuf; + reverb->sample.size = reverb->delayNumSamples * SAMPLE_SIZE; + reverb->sample.sampleAddr = (u8*)reverb->leftReverbBuf; reverb->loop.start = 0; reverb->loop.count = 1; - reverb->loop.end = reverb->windowSize; + reverb->loop.loopEnd = reverb->delayNumSamples; - AudioHeap_SetReverbData(reverbIndex, 7, settings->lowPassFilterCutoffLeft, flags); - AudioHeap_SetReverbData(reverbIndex, 8, settings->lowPassFilterCutoffRight, flags); + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_LEFT, settings->lowPassFilterCutoffLeft, isFirstInit); + AudioHeap_SetReverbData(reverbIndex, REVERB_DATA_TYPE_FILTER_RIGHT, settings->lowPassFilterCutoffRight, + isFirstInit); } diff --git a/src/code/audio/audio_init_params.c b/src/code/audio/audio_init_params.c index b407ef7c9..6bba865e9 100644 --- a/src/code/audio/audio_init_params.c +++ b/src/code/audio/audio_init_params.c @@ -1,12 +1,184 @@ #include "global.h" const s16 gAudioTatumInit[] = { - 0x1C00, // unused - 0x30, // gTatumsPerBeat + 0x1C00, // unused + TATUMS_PER_BEAT, // gTatumsPerBeat }; -const AudioContextInitSizes gAudioContextInitSizes = { - 0x137F00, // heapSize - 0x1C480, // mainPoolSplitSize - 0x1A000, // permanentPoolSize +// TODO: Extract from table? +#define NUM_SOUNDFONTS 41 +#define SFX_SEQ_SIZE 0xC6A0 +#define AMBIENCE_SEQ_SIZE 0xFC0 +#define SOUNDFONT_0_SIZE 0x81C0 +#define SOUNDFONT_1_SIZE 0x36D0 +#define SOUNDFONT_2_SIZE 0xCE0 + +// Sizes of everything on the init pool +#define AI_BUFFERS_SIZE (AIBUF_SIZE * ARRAY_COUNT(gAudioCtx.aiBuffers)) +#define SOUNDFONT_LIST_SIZE (NUM_SOUNDFONTS * sizeof(SoundFont)) + +// 0x19BD0 +#define PERMANENT_POOL_SIZE \ + (SFX_SEQ_SIZE + AMBIENCE_SEQ_SIZE + SOUNDFONT_0_SIZE + SOUNDFONT_1_SIZE + SOUNDFONT_2_SIZE + 0x430) + +const AudioHeapInitSizes gAudioHeapInitSizes = { + ALIGN16(sizeof(gAudioHeap) - 0x100), // audio heap size + ALIGN16(PERMANENT_POOL_SIZE + AI_BUFFERS_SIZE + SOUNDFONT_LIST_SIZE + 0x40), // init pool size + ALIGN16(PERMANENT_POOL_SIZE), // permanent pool size +}; + +#define REVERB_INDEX_0_SETTINGS \ + { 1, 0x30, 0x3000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x3000, 0, 0 } + +ReverbSettings reverbSettings0[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x20, 0x0800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 0, 0 }, +}; + +ReverbSettings reverbSettings1[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings reverbSettings2[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x38, 0x2800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 7, 7 }, +}; + +ReverbSettings reverbSettings3[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, + { 2, 0x50, 0x6000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettings4[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x1800, 0x1800, REVERB_INDEX_NONE, 0x3000, 7, 7 }, +}; + +ReverbSettings reverbSettings5[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5C00, 0, 0, 0x7FFF, 0x2000, 0x2000, REVERB_INDEX_NONE, 0x3000, 4, 4 }, +}; + +ReverbSettings reverbSettings6[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6000, 0, 0, 0x7FFF, 0x1000, 0x1000, REVERB_INDEX_NONE, 0x3000, 10, 10 }, +}; + +ReverbSettings reverbSettings7[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, +}; + +ReverbSettings reverbSettings8[2] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x50, 0x5000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettings9[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x20, 0x0000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 0, 0 }, +}; + +ReverbSettings reverbSettingsA[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings reverbSettingsB[3] = { + REVERB_INDEX_0_SETTINGS, +}; + +ReverbSettings reverbSettingsC[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettingsD[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x6800, 0, 0, 0x7FFF, 0x1400, 0x1400, REVERB_INDEX_NONE, 0x3000, 6, 6 }, + { 2, 0x50, 0x6000, 0, 0, 0x7FFF, 0xD000, 0x3000, REVERB_INDEX_NONE, 0x3000, 0, 0 }, +}; + +ReverbSettings reverbSettingsE[3] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x30, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, + { 1, 0x40, 0x5000, 0, 0, 0x7FFF, 0x1800, 0x1800, REVERB_INDEX_NONE, 0x3000, 7, 7 }, +}; + +ReverbSettings reverbSettingsF[2] = { + REVERB_INDEX_0_SETTINGS, + { 1, 0x50, 0x1800, 0, 0, 0x7FFF, 0x0000, 0x0000, REVERB_INDEX_NONE, 0x0000, 11, 11 }, +}; + +ReverbSettings* gReverbSettingsTable[] = { + reverbSettings0, reverbSettings1, reverbSettings2, reverbSettings4, reverbSettings5, + reverbSettings6, reverbSettings7, reverbSettings8, reverbSettings9, reverbSettings3, +}; + +AudioSpec gAudioSpecs[21] = { + /* 0x0 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x1 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x2 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x3 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x4 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x5 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x6 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x7 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x8 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x9 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xA */ + { 32000, 1, 28, 3, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x2800, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xB */ + { 32000, 1, 28, 3, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xC */ + { 32000, 1, 28, 5, 0, 0, 2, reverbSettingsA, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xCC800 }, + /* 0xD */ + { 32000, 1, 24, 5, 0, 0, 3, reverbSettingsD, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xE */ + { 32000, 1, 24, 5, 0, 0, 3, reverbSettingsE, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0xF */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettingsF, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4000, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x10 */ + { 32000, 1, 22, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x11 */ + { 32000, 1, 22, 5, 0, 0, 2, reverbSettings8, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x12 */ + { 32000, 1, 16, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x13 */ + { 22050, 1, 24, 5, 0, 0, 2, reverbSettings0, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x4100, 0x2D00, 0, 0, + 0xDC800 }, + /* 0x14 */ + { 32000, 1, 24, 5, 0, 0, 2, reverbSettings2, 0x500, 0x200, 0x7FFF, 0xAF0, 0x2D80, 0, 0x3600, 0x2600, 0, 0, + 0xDC800 }, }; diff --git a/src/code/audio/audio_load.c b/src/code/audio/audio_load.c index 8faf565ea..28c27d2cc 100644 --- a/src/code/audio/audio_load.c +++ b/src/code/audio/audio_load.c @@ -16,7 +16,7 @@ * SoundFont Notes: * */ -// opaque type for unpatched sound font data (should maybe get rid of this?) +// opaque type for soundfont data loaded into ram (should maybe get rid of this?) typedef void SoundFontData; typedef struct { @@ -26,10 +26,10 @@ typedef struct { /* 0x0C */ uintptr_t baseAddr2; /* 0x10 */ u32 medium1; /* 0x14 */ u32 medium2; -} AudioRelocInfo; // size = 0x18 +} SampleBankRelocInfo; // 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); @@ -37,12 +37,12 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate); u32 AudioLoad_GetRealTableIndex(s32 tableType, u32 id); void* AudioLoad_SearchCaches(s32 tableType, s32 id); AudioTable* AudioLoad_GetLoadTable(s32 tableType); -void AudioLoad_SyncDma(uintptr_t devAddr, u8* addr, size_t size, s32 medium); +void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium); void AudioLoad_SyncDmaUnkMedium(uintptr_t devAddr, u8* addr, size_t size, s32 unkMediumParam); s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr, void* ramAddr, size_t size, OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType); void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, OSMesgQueue* retQueue); -SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId); +Sample* AudioLoad_GetFontSample(s32 fontId, s32 instId); void AudioLoad_ProcessSlowLoads(s32 resetStatus); void AudioLoad_DmaSlowCopy(AudioSlowLoad* slowLoad, size_t size); void AudioLoad_DmaSlowCopyUnkMedium(intptr_t devAddr, intptr_t ramAddr, size_t size, s32 arg3); @@ -56,8 +56,9 @@ void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus); void AudioLoad_AsyncDma(AudioAsyncLoad* asyncLoad, size_t size); void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size); void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3); -void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* fontData, AudioRelocInfo* relocInfo); -void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo, s32 async); +void AudioLoad_RelocateSample(TunedSample* tunedSample, SoundFontData* fontData, SampleBankRelocInfo* sampleBankReloc); +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, SampleBankRelocInfo* sampleBankReloc, + s32 isAsync); s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus); #define MK_ASYNC_MSG(retData, tableType, id, loadStatus) \ @@ -91,38 +92,38 @@ s32 D_801FD1E0; DmaHandler sDmaHandler = osEPiStartDma; void* sUnusedHandler = NULL; -s32 gAudioContextInitalized = false; +s32 gAudioCtxInitalized = false; void AudioLoad_DecreaseSampleDmaTtls(void) { u32 i; - for (i = 0; i < gAudioContext.sampleDmaListSize1; i++) { - SampleDma* dma = &gAudioContext.sampleDmas[i]; + for (i = 0; i < gAudioCtx.sampleDmaListSize1; i++) { + SampleDma* dma = &gAudioCtx.sampleDmas[i]; if (dma->ttl != 0) { dma->ttl--; if (dma->ttl == 0) { - dma->reuseIndex = gAudioContext.sampleDmaReuseQueue1WrPos; - gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1WrPos] = i; - gAudioContext.sampleDmaReuseQueue1WrPos++; + dma->reuseIndex = gAudioCtx.sampleDmaReuseQueue1WrPos; + gAudioCtx.sampleDmaReuseQueue1[gAudioCtx.sampleDmaReuseQueue1WrPos] = i; + gAudioCtx.sampleDmaReuseQueue1WrPos++; } } } - for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { - SampleDma* dma = &gAudioContext.sampleDmas[i]; + for (i = gAudioCtx.sampleDmaListSize1; i < gAudioCtx.sampleDmaCount; i++) { + SampleDma* dma = &gAudioCtx.sampleDmas[i]; if (dma->ttl != 0) { dma->ttl--; if (dma->ttl == 0) { - dma->reuseIndex = gAudioContext.sampleDmaReuseQueue2WrPos; - gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2WrPos] = i; - gAudioContext.sampleDmaReuseQueue2WrPos++; + dma->reuseIndex = gAudioCtx.sampleDmaReuseQueue2WrPos; + gAudioCtx.sampleDmaReuseQueue2[gAudioCtx.sampleDmaReuseQueue2WrPos] = i; + gAudioCtx.sampleDmaReuseQueue2WrPos++; } } } - gAudioContext.unused2648 = 0; + gAudioCtx.unused2648 = 0; } void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaIndexRef, s32 medium) { @@ -136,24 +137,22 @@ void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaI s32 bufferPos; u32 i; - if (arg2 != 0 || *dmaIndexRef >= gAudioContext.sampleDmaListSize1) { - for (i = gAudioContext.sampleDmaListSize1; i < gAudioContext.sampleDmaCount; i++) { - dma = &gAudioContext.sampleDmas[i]; + if (arg2 != 0 || *dmaIndexRef >= gAudioCtx.sampleDmaListSize1) { + for (i = gAudioCtx.sampleDmaListSize1; i < gAudioCtx.sampleDmaCount; i++) { + dma = &gAudioCtx.sampleDmas[i]; bufferPos = devAddr - dma->devAddr; if (0 <= bufferPos && ((u32)bufferPos <= dma->size - size)) { // We already have a DMA request for this memory range. - if (dma->ttl == 0 && - gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos) { + if (dma->ttl == 0 && gAudioCtx.sampleDmaReuseQueue2RdPos != gAudioCtx.sampleDmaReuseQueue2WrPos) { // Move the DMA out of the reuse queue, by swapping it with the // read pos, and then incrementing the read pos. - if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue2RdPos) { - gAudioContext.sampleDmaReuseQueue2[dma->reuseIndex] = - gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; - gAudioContext - .sampleDmas[gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]] + if (dma->reuseIndex != gAudioCtx.sampleDmaReuseQueue2RdPos) { + gAudioCtx.sampleDmaReuseQueue2[dma->reuseIndex] = + gAudioCtx.sampleDmaReuseQueue2[gAudioCtx.sampleDmaReuseQueue2RdPos]; + gAudioCtx.sampleDmas[gAudioCtx.sampleDmaReuseQueue2[gAudioCtx.sampleDmaReuseQueue2RdPos]] .reuseIndex = dma->reuseIndex; } - gAudioContext.sampleDmaReuseQueue2RdPos++; + gAudioCtx.sampleDmaReuseQueue2RdPos++; } dma->ttl = 32; *dmaIndexRef = (u8)i; @@ -165,16 +164,16 @@ void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaI goto search_short_lived; } - if (gAudioContext.sampleDmaReuseQueue2RdPos != gAudioContext.sampleDmaReuseQueue2WrPos && arg2 != 0) { + if (gAudioCtx.sampleDmaReuseQueue2RdPos != gAudioCtx.sampleDmaReuseQueue2WrPos && arg2 != 0) { // Allocate a DMA from reuse queue 2, unless full. - dmaIndex = gAudioContext.sampleDmaReuseQueue2[gAudioContext.sampleDmaReuseQueue2RdPos]; - gAudioContext.sampleDmaReuseQueue2RdPos++; - dma = gAudioContext.sampleDmas + dmaIndex; + dmaIndex = gAudioCtx.sampleDmaReuseQueue2[gAudioCtx.sampleDmaReuseQueue2RdPos]; + gAudioCtx.sampleDmaReuseQueue2RdPos++; + dma = gAudioCtx.sampleDmas + dmaIndex; hasDma = true; } } else { search_short_lived: - dma = gAudioContext.sampleDmas + *dmaIndexRef; + dma = gAudioCtx.sampleDmas + *dmaIndexRef; i = 0; again: bufferPos = devAddr - dma->devAddr; @@ -183,31 +182,30 @@ void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaI if (dma->ttl == 0) { // Move the DMA out of the reuse queue, by swapping it with the // read pos, and then incrementing the read pos. - if (dma->reuseIndex != gAudioContext.sampleDmaReuseQueue1RdPos) { - gAudioContext.sampleDmaReuseQueue1[dma->reuseIndex] = - gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]; - gAudioContext - .sampleDmas[gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos]] + if (dma->reuseIndex != gAudioCtx.sampleDmaReuseQueue1RdPos) { + gAudioCtx.sampleDmaReuseQueue1[dma->reuseIndex] = + gAudioCtx.sampleDmaReuseQueue1[gAudioCtx.sampleDmaReuseQueue1RdPos]; + gAudioCtx.sampleDmas[gAudioCtx.sampleDmaReuseQueue1[gAudioCtx.sampleDmaReuseQueue1RdPos]] .reuseIndex = dma->reuseIndex; } - gAudioContext.sampleDmaReuseQueue1RdPos++; + gAudioCtx.sampleDmaReuseQueue1RdPos++; } dma->ttl = 2; return dma->ramAddr + (devAddr - dma->devAddr); } - dma = gAudioContext.sampleDmas + i++; - if (i <= gAudioContext.sampleDmaListSize1) { + dma = gAudioCtx.sampleDmas + i++; + if (i <= gAudioCtx.sampleDmaListSize1) { goto again; } } if (!hasDma) { - if (gAudioContext.sampleDmaReuseQueue1RdPos == gAudioContext.sampleDmaReuseQueue1WrPos) { + if (gAudioCtx.sampleDmaReuseQueue1RdPos == gAudioCtx.sampleDmaReuseQueue1WrPos) { return NULL; } // Allocate a DMA from reuse queue 1. - dmaIndex = gAudioContext.sampleDmaReuseQueue1[gAudioContext.sampleDmaReuseQueue1RdPos++]; - dma = gAudioContext.sampleDmas + dmaIndex; + dmaIndex = gAudioCtx.sampleDmaReuseQueue1[gAudioCtx.sampleDmaReuseQueue1RdPos++]; + dma = gAudioCtx.sampleDmas + dmaIndex; hasDma = true; } @@ -216,9 +214,8 @@ void* AudioLoad_DmaSampleData(uintptr_t devAddr, size_t size, s32 arg2, u8* dmaI dma->ttl = 3; dma->devAddr = dmaDevAddr; dma->sizeUnused = transfer; - AudioLoad_Dma(&gAudioContext.currAudioFrameDmaIoMesgBuf[gAudioContext.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, - OS_READ, dmaDevAddr, dma->ramAddr, transfer, &gAudioContext.currAudioFrameDmaQueue, medium, - "SUPERDMA"); + AudioLoad_Dma(&gAudioCtx.currAudioFrameDmaIoMesgBuf[gAudioCtx.curAudioFrameDmaCount++], OS_MESG_PRI_NORMAL, OS_READ, + dmaDevAddr, dma->ramAddr, transfer, &gAudioCtx.curAudioFrameDmaQueue, medium, "SUPERDMA"); *dmaIndexRef = dmaIndex; return (devAddr - dmaDevAddr) + dma->ramAddr; } @@ -232,78 +229,77 @@ void AudioLoad_InitSampleDmaBuffers(s32 numNotes) { s32 t2; s32 j; - gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize1; - gAudioContext.sampleDmas = - AudioHeap_Alloc(&gAudioContext.miscPool, - 4 * gAudioContext.numNotes * sizeof(SampleDma) * gAudioContext.audioBufferParameters.specUnk4); - t2 = 3 * gAudioContext.numNotes * gAudioContext.audioBufferParameters.specUnk4; + gAudioCtx.sampleDmaBufSize = gAudioCtx.sampleDmaBufSize1; + gAudioCtx.sampleDmas = AudioHeap_Alloc(&gAudioCtx.miscPool, 4 * gAudioCtx.numNotes * sizeof(SampleDma) * + gAudioCtx.audioBufferParameters.specUnk4); + t2 = 3 * gAudioCtx.numNotes * gAudioCtx.audioBufferParameters.specUnk4; // First 3/4 sampleDmas for (i = 0; i < t2; i++) { - dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; - dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + dma = &gAudioCtx.sampleDmas[gAudioCtx.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioCtx.miscPool, gAudioCtx.sampleDmaBufSize); if (dma->ramAddr == NULL) { break; } else { - AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); - dma->size = gAudioContext.sampleDmaBufSize; + AudioHeap_WritebackDCache(dma->ramAddr, gAudioCtx.sampleDmaBufSize); + dma->size = gAudioCtx.sampleDmaBufSize; dma->devAddr = 0; dma->sizeUnused = 0; dma->unused = 0; dma->ttl = 0; - gAudioContext.sampleDmaCount++; + gAudioCtx.sampleDmaCount++; } } - for (i = 0; (u32)i < gAudioContext.sampleDmaCount; i++) { - gAudioContext.sampleDmaReuseQueue1[i] = i; - gAudioContext.sampleDmas[i].reuseIndex = i; + for (i = 0; (u32)i < gAudioCtx.sampleDmaCount; i++) { + gAudioCtx.sampleDmaReuseQueue1[i] = i; + gAudioCtx.sampleDmas[i].reuseIndex = i; } - for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { - gAudioContext.sampleDmaReuseQueue1[i] = 0; + for (i = gAudioCtx.sampleDmaCount; i < 0x100; i++) { + gAudioCtx.sampleDmaReuseQueue1[i] = 0; } - gAudioContext.sampleDmaReuseQueue1RdPos = 0; - gAudioContext.sampleDmaReuseQueue1WrPos = gAudioContext.sampleDmaCount; - gAudioContext.sampleDmaListSize1 = gAudioContext.sampleDmaCount; - gAudioContext.sampleDmaBufSize = gAudioContext.sampleDmaBufSize2; + gAudioCtx.sampleDmaReuseQueue1RdPos = 0; + gAudioCtx.sampleDmaReuseQueue1WrPos = gAudioCtx.sampleDmaCount; + gAudioCtx.sampleDmaListSize1 = gAudioCtx.sampleDmaCount; + gAudioCtx.sampleDmaBufSize = gAudioCtx.sampleDmaBufSize2; - for (j = 0; j < gAudioContext.numNotes; j++) { - dma = &gAudioContext.sampleDmas[gAudioContext.sampleDmaCount]; - dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, gAudioContext.sampleDmaBufSize); + for (j = 0; j < gAudioCtx.numNotes; j++) { + dma = &gAudioCtx.sampleDmas[gAudioCtx.sampleDmaCount]; + dma->ramAddr = AudioHeap_AllocAttemptExternal(&gAudioCtx.miscPool, gAudioCtx.sampleDmaBufSize); if (dma->ramAddr == NULL) { break; } else { - AudioHeap_WritebackDCache(dma->ramAddr, gAudioContext.sampleDmaBufSize); - dma->size = gAudioContext.sampleDmaBufSize; - dma->devAddr = 0U; + AudioHeap_WritebackDCache(dma->ramAddr, gAudioCtx.sampleDmaBufSize); + dma->size = gAudioCtx.sampleDmaBufSize; + dma->devAddr = 0; dma->sizeUnused = 0; dma->unused = 0; dma->ttl = 0; - gAudioContext.sampleDmaCount++; + gAudioCtx.sampleDmaCount++; } } - for (i = gAudioContext.sampleDmaListSize1; (u32)i < gAudioContext.sampleDmaCount; i++) { - gAudioContext.sampleDmaReuseQueue2[i - gAudioContext.sampleDmaListSize1] = i; - gAudioContext.sampleDmas[i].reuseIndex = i - gAudioContext.sampleDmaListSize1; + for (i = gAudioCtx.sampleDmaListSize1; (u32)i < gAudioCtx.sampleDmaCount; i++) { + gAudioCtx.sampleDmaReuseQueue2[i - gAudioCtx.sampleDmaListSize1] = i; + gAudioCtx.sampleDmas[i].reuseIndex = i - gAudioCtx.sampleDmaListSize1; } - for (i = gAudioContext.sampleDmaCount; i < 0x100; i++) { - gAudioContext.sampleDmaReuseQueue2[i] = gAudioContext.sampleDmaListSize1; + for (i = gAudioCtx.sampleDmaCount; i < 0x100; i++) { + gAudioCtx.sampleDmaReuseQueue2[i] = gAudioCtx.sampleDmaListSize1; } - gAudioContext.sampleDmaReuseQueue2RdPos = 0; - gAudioContext.sampleDmaReuseQueue2WrPos = gAudioContext.sampleDmaCount - gAudioContext.sampleDmaListSize1; + gAudioCtx.sampleDmaReuseQueue2RdPos = 0; + gAudioCtx.sampleDmaReuseQueue2WrPos = gAudioCtx.sampleDmaCount - gAudioCtx.sampleDmaListSize1; } s32 AudioLoad_IsFontLoadComplete(s32 fontId) { if (fontId == 0xFF) { return true; - } else if (gAudioContext.fontLoadStatus[fontId] >= LOAD_STATUS_2) { + } else if (gAudioCtx.fontLoadStatus[fontId] >= LOAD_STATUS_COMPLETE) { return true; - } else if (gAudioContext.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_2) { + } else if (gAudioCtx.fontLoadStatus[AudioLoad_GetRealTableIndex(FONT_TABLE, fontId)] >= LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -313,9 +309,9 @@ 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 (gAudioCtx.seqLoadStatus[seqId] >= LOAD_STATUS_COMPLETE) { return true; - } else if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_2) { + } else if (gAudioCtx.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] >= LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -325,10 +321,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 (gAudioCtx.sampleFontLoadStatus[sampleBankId] >= LOAD_STATUS_COMPLETE) { return true; - } else if (gAudioContext.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >= - LOAD_STATUS_2) { + } else if (gAudioCtx.sampleFontLoadStatus[AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankId)] >= + LOAD_STATUS_COMPLETE) { return true; } else { return false; @@ -336,33 +332,33 @@ s32 AudioLoad_IsSampleLoadComplete(s32 sampleBankId) { } void AudioLoad_SetFontLoadStatus(s32 fontId, s32 loadStatus) { - if ((fontId != 0xFF) && (gAudioContext.fontLoadStatus[fontId] != LOAD_STATUS_5)) { - gAudioContext.fontLoadStatus[fontId] = loadStatus; + if ((fontId != 0xFF) && (gAudioCtx.fontLoadStatus[fontId] != LOAD_STATUS_PERMANENT)) { + gAudioCtx.fontLoadStatus[fontId] = loadStatus; } } void AudioLoad_SetSeqLoadStatus(s32 seqId, s32 loadStatus) { - if ((seqId != 0xFF) && (gAudioContext.seqLoadStatus[seqId] != LOAD_STATUS_5)) { - gAudioContext.seqLoadStatus[seqId] = loadStatus; + if ((seqId != 0xFF) && (gAudioCtx.seqLoadStatus[seqId] != LOAD_STATUS_PERMANENT)) { + gAudioCtx.seqLoadStatus[seqId] = loadStatus; } } void AudioLoad_SetSampleFontLoadStatusAndApplyCaches(s32 sampleBankId, s32 loadStatus) { if (sampleBankId != 0xFF) { - if (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5) { - gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + if (gAudioCtx.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_PERMANENT) { + gAudioCtx.sampleFontLoadStatus[sampleBankId] = loadStatus; } - if ((gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_5) || - (gAudioContext.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_2)) { + if ((gAudioCtx.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_PERMANENT) || + (gAudioCtx.sampleFontLoadStatus[sampleBankId] == LOAD_STATUS_COMPLETE)) { AudioHeap_ApplySampleBankCache(sampleBankId); } } } void AudioLoad_SetSampleFontLoadStatus(s32 sampleBankId, s32 loadStatus) { - if ((sampleBankId != 0xFF) && (gAudioContext.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_5)) { - gAudioContext.sampleFontLoadStatus[sampleBankId] = loadStatus; + if ((sampleBankId != 0xFF) && (gAudioCtx.sampleFontLoadStatus[sampleBankId] != LOAD_STATUS_PERMANENT)) { + gAudioCtx.sampleFontLoadStatus[sampleBankId] = loadStatus; } } @@ -387,16 +383,16 @@ SoundFontData* AudioLoad_SyncLoadSeqFonts(s32 seqId, u32* outDefaultFontId) { s32 fontId; s32 i; - if (seqId >= gAudioContext.numSequences) { + if (seqId >= gAudioCtx.numSequences) { return NULL; } fontId = 0xFF; - index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; - numFonts = gAudioContext.sequenceFontTable[index++]; + index = ((u16*)gAudioCtx.sequenceFontTable)[seqId]; + numFonts = gAudioCtx.sequenceFontTable[index++]; while (numFonts > 0) { - fontId = gAudioContext.sequenceFontTable[index++]; + fontId = gAudioCtx.sequenceFontTable[index++]; fontData = AudioLoad_SyncLoadFont(fontId); numFonts--; } @@ -409,7 +405,7 @@ void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3 s32 pad; u32 defaultFontId; - if (seqId < gAudioContext.numSequences) { + if (seqId < gAudioCtx.numSequences) { if (arg1 & 2) { AudioLoad_SyncLoadSeqFonts(seqId, &defaultFontId); } @@ -422,10 +418,10 @@ void AudioLoad_SyncLoadSeqParts(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue* arg3 } } -s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { +s32 AudioLoad_SyncLoadSample(Sample* sample, s32 fontId) { void* sampleAddr; - if (sample->unk_bit25 == true) { + if (sample->isRelocated == true) { if (sample->medium != MEDIUM_RAM) { sampleAddr = AudioHeap_AllocSampleCache(sample->size, fontId, (void*)sample->sampleAddr, sample->medium, CACHE_PERSISTENT); @@ -435,7 +431,7 @@ s32 AudioLoad_SyncLoadSample(SoundFontSample* sample, s32 fontId) { if (sample->medium == MEDIUM_UNK) { AudioLoad_SyncDmaUnkMedium(sample->sampleAddr, sampleAddr, sample->size, - gAudioContext.sampleBankTable->unkMediumParam); + gAudioCtx.sampleBankTable->unkMediumParam); } else { AudioLoad_SyncDma(sample->sampleAddr, sampleAddr, sample->size, sample->medium); } @@ -453,11 +449,11 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { return -1; } if (instrument->normalRangeLo != 0) { - AudioLoad_SyncLoadSample(instrument->lowNotesSound.sample, fontId); + AudioLoad_SyncLoadSample(instrument->lowPitchTunedSample.sample, fontId); } - AudioLoad_SyncLoadSample(instrument->normalNotesSound.sample, fontId); + AudioLoad_SyncLoadSample(instrument->normalPitchTunedSample.sample, fontId); if (instrument->normalRangeHi != 0x7F) { - return AudioLoad_SyncLoadSample(instrument->highNotesSound.sample, fontId); + return AudioLoad_SyncLoadSample(instrument->highPitchTunedSample.sample, fontId); } // TODO: is this missing return UB? } else if (instId == 0x7F) { @@ -466,7 +462,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { if (drum == NULL) { return -1; } - AudioLoad_SyncLoadSample(drum->sound.sample, fontId); + AudioLoad_SyncLoadSample(drum->tunedSample.sample, fontId); return 0; } // TODO: is this missing return UB? @@ -491,33 +487,33 @@ void AudioLoad_AsyncLoadFont(s32 fontId, s32 arg1, s32 retData, OSMesgQueue* ret } u8* AudioLoad_GetFontsForSequence(s32 seqId, u32* outNumFonts) { - s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; + s32 index = ((u16*)gAudioCtx.sequenceFontTable)[seqId]; - *outNumFonts = gAudioContext.sequenceFontTable[index++]; + *outNumFonts = gAudioCtx.sequenceFontTable[index++]; if (*outNumFonts == 0) { return NULL; } - return &gAudioContext.sequenceFontTable[index]; + return &gAudioCtx.sequenceFontTable[index]; } void AudioLoad_DiscardSeqFonts(s32 seqId) { s32 fontId; - s32 index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; - s32 numFonts = gAudioContext.sequenceFontTable[index++]; + s32 index = ((u16*)gAudioCtx.sequenceFontTable)[seqId]; + s32 numFonts = gAudioCtx.sequenceFontTable[index++]; while (numFonts > 0) { numFonts--; - fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.sequenceFontTable[index++]); + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioCtx.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); } } } void AudioLoad_DiscardFont(s32 fontId) { u32 i; - AudioCache* pool = &gAudioContext.fontCache; + AudioCache* pool = &gAudioCtx.fontCache; AudioPersistentCache* persistent; if (fontId == pool->temporary.entries[0].id) { @@ -553,37 +549,37 @@ void func_8018FA60(u32 tableType, u32 id, s32 type, s32 data) { } } -s32 AudioLoad_SyncInitSeqPlayer(s32 playerIdx, s32 seqId, s32 arg2) { - if (gAudioContext.resetTimer != 0) { +s32 AudioLoad_SyncInitSeqPlayer(s32 playerIndex, s32 seqId, s32 arg2) { + if (gAudioCtx.resetTimer != 0) { return 0; } - gAudioContext.seqPlayers[playerIdx].skipTicks = 0; - AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, arg2); + gAudioCtx.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) { - if (gAudioContext.resetTimer != 0) { +s32 AudioLoad_SyncInitSeqPlayerSkipTicks(s32 playerIndex, s32 seqId, s32 skipTicks) { + if (gAudioCtx.resetTimer != 0) { return 0; } - gAudioContext.seqPlayers[playerIdx].skipTicks = skipTicks; - AudioLoad_SyncInitSeqPlayerInternal(playerIdx, seqId, 0); + gAudioCtx.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 = &gAudioCtx.seqPlayers[playerIndex]; u8* seqData; s32 index; s32 numFonts; s32 fontId; - if (seqId >= gAudioContext.numSequences) { + if (seqId >= gAudioCtx.numSequences) { return 0; } @@ -591,11 +587,11 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { if (1) {} fontId = 0xFF; - index = ((u16*)gAudioContext.sequenceFontTable)[seqId]; - numFonts = gAudioContext.sequenceFontTable[index++]; + index = ((u16*)gAudioCtx.sequenceFontTable)[seqId]; + numFonts = gAudioCtx.sequenceFontTable[index++]; while (numFonts > 0) { - fontId = gAudioContext.sequenceFontTable[index++]; + fontId = gAudioCtx.sequenceFontTable[index++]; AudioLoad_SyncLoadFont(fontId); numFonts--; } @@ -620,7 +616,7 @@ s32 AudioLoad_SyncInitSeqPlayerInternal(s32 playerIdx, s32 seqId, s32 arg2) { seqPlayer->scriptState.depth = 0; seqPlayer->delay = 0; seqPlayer->finished = false; - seqPlayer->playerIdx = playerIdx; + seqPlayer->playerIndex = playerIndex; //! @bug missing return (but the return value is not used so it's not UB) } @@ -628,7 +624,7 @@ u8* AudioLoad_SyncLoadSeq(s32 seqId) { s32 pad; s32 didAllocate; - if (gAudioContext.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_1) { + if (gAudioCtx.seqLoadStatus[AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId)] == LOAD_STATUS_IN_PROGRESS) { return NULL; } @@ -649,8 +645,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 (gAudioCtx.sampleFontLoadStatus[realTableId] != LOAD_STATUS_IN_PROGRESS) { + AudioLoad_SetSampleFontLoadStatus(realTableId, LOAD_STATUS_COMPLETE); } *outMedium = MEDIUM_RAM; @@ -679,28 +675,29 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { s32 sampleBankId1; s32 sampleBankId2; s32 didAllocate; - AudioRelocInfo relocInfo; + SampleBankRelocInfo sampleBankReloc; s32 realFontId = AudioLoad_GetRealTableIndex(FONT_TABLE, fontId); - if (gAudioContext.fontLoadStatus[realFontId] == LOAD_STATUS_1) { + if (gAudioCtx.fontLoadStatus[realFontId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } - sampleBankId1 = gAudioContext.soundFonts[realFontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[realFontId].sampleBankId2; + sampleBankId1 = gAudioCtx.soundFontList[realFontId].sampleBankId1; + sampleBankId2 = gAudioCtx.soundFontList[realFontId].sampleBankId2; - relocInfo.sampleBankId1 = sampleBankId1; - relocInfo.sampleBankId2 = sampleBankId2; - if (relocInfo.sampleBankId1 != 0xFF) { - relocInfo.baseAddr1 = AudioLoad_TrySyncLoadSampleBank(relocInfo.sampleBankId1, &relocInfo.medium1, false); + sampleBankReloc.sampleBankId1 = sampleBankId1; + sampleBankReloc.sampleBankId2 = sampleBankId2; + if (sampleBankReloc.sampleBankId1 != 0xFF) { + sampleBankReloc.baseAddr1 = + AudioLoad_TrySyncLoadSampleBank(sampleBankReloc.sampleBankId1, &sampleBankReloc.medium1, false); } else { - relocInfo.baseAddr1 = 0; + sampleBankReloc.baseAddr1 = 0; } if (sampleBankId2 != 0xFF) { - relocInfo.baseAddr2 = AudioLoad_TrySyncLoadSampleBank(sampleBankId2, &relocInfo.medium2, false); + sampleBankReloc.baseAddr2 = AudioLoad_TrySyncLoadSampleBank(sampleBankId2, &sampleBankReloc.medium2, false); } else { - relocInfo.baseAddr2 = 0; + sampleBankReloc.baseAddr2 = 0; } fontData = AudioLoad_SyncLoad(FONT_TABLE, fontId, &didAllocate); @@ -708,7 +705,7 @@ SoundFontData* AudioLoad_SyncLoadFont(u32 fontId) { return NULL; } if (didAllocate == true) { - AudioLoad_RelocateFontAndPreloadSamples(realFontId, fontData, &relocInfo, false); + AudioLoad_RelocateFontAndPreloadSamples(realFontId, fontData, &sampleBankReloc, false); } return fontData; @@ -730,7 +727,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; @@ -777,7 +774,7 @@ void* AudioLoad_SyncLoad(s32 tableType, u32 id, s32* didAllocate) { } if (tableType == FONT_TABLE) { - SoundFont* soundFont = &gAudioContext.soundFonts[realId]; + SoundFont* soundFont = &gAudioCtx.soundFontList[realId]; soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; @@ -793,7 +790,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) { @@ -844,110 +841,152 @@ AudioTable* AudioLoad_GetLoadTable(s32 tableType) { switch (tableType) { case SEQUENCE_TABLE: - table = gAudioContext.sequenceTable; + table = gAudioCtx.sequenceTable; break; case FONT_TABLE: - table = gAudioContext.soundFontTable; + table = gAudioCtx.soundFontTable; break; default: table = NULL; break; case SAMPLE_TABLE: - table = gAudioContext.sampleBankTable; + table = gAudioCtx.sampleBankTable; break; } return table; } /** + * Read and extract information from soundFont binary loaded into ram. + * Also relocate offsets into pointers within this loaded soundFont * - * SoundFontData* mem -> the address of the soundFont as stored in memory + * @param fontId index of font being processed + * @param fontDataStartAddr ram address of raw soundfont binary loaded into cache + * @param sampleBankReloc information on the sampleBank containing raw audio samples */ -void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontData, AudioRelocInfo* relocInfo) { - uintptr_t reloc; - uintptr_t reloc2; +void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, SampleBankRelocInfo* sampleBankReloc) { + uintptr_t soundOffset; + uintptr_t soundListOffset; Instrument* inst; Drum* drum; - SoundFontSound* sfx; + SoundEffect* soundEffect; s32 i; - s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; - s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; - s32 numSfx = gAudioContext.soundFonts[fontId].numSfx; - void** ptrs = (void**)fontData; + s32 numDrums = gAudioCtx.soundFontList[fontId].numDrums; + s32 numInstruments = gAudioCtx.soundFontList[fontId].numInstruments; + s32 numSfx = gAudioCtx.soundFontList[fontId].numSfx; + u32* fontData = (u32*)fontDataStartAddr; -#define BASE_OFFSET(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontData)) + // Relocate an offset (relative to the start of the font data) to a pointer (a ram address) +#define RELOC_TO_RAM(x) (void*)((uintptr_t)(x) + (uintptr_t)(fontDataStartAddr)) - // relocate drums - reloc2 = ptrs[0]; + // Drums relocation + + // The first u32 in fontData is an offset to a list of offsets to the drums + soundListOffset = fontData[0]; if (1) {} - if ((reloc2 != 0) && (numDrums != 0)) { - ptrs[0] = BASE_OFFSET(reloc2); + + // If the soundFont has drums + if ((soundListOffset != 0) && (numDrums != 0)) { + + fontData[0] = RELOC_TO_RAM(soundListOffset); + + // Loop through the drum offsets for (i = 0; i < numDrums; i++) { - reloc = ((Drum**)ptrs[0])[i]; - if (reloc != 0) { - reloc = BASE_OFFSET(reloc); - ((Drum**)ptrs[0])[i] = drum = reloc; - if (!drum->loaded) { - AudioLoad_RelocateSample(&drum->sound, fontData, relocInfo); - reloc = drum->envelope; - drum->envelope = BASE_OFFSET(reloc); - drum->loaded = true; + // Get the i'th drum offset + soundOffset = ((Drum**)fontData[0])[i]; + + // Some drum data entries are empty, represented by an offset of 0 in the list of drum offsets + if (soundOffset != 0) { + soundOffset = RELOC_TO_RAM(soundOffset); + ((Drum**)fontData[0])[i] = drum = soundOffset; + + // The drum may be in the list multiple times and already relocated + if (!drum->isRelocated) { + AudioLoad_RelocateSample(&drum->tunedSample, fontDataStartAddr, sampleBankReloc); + + soundOffset = drum->envelope; + drum->envelope = RELOC_TO_RAM(soundOffset); + + drum->isRelocated = true; } } } } - // relocate sfxs - reloc2 = ptrs[1]; + // Sound effects relocation + + // The second u32 in fontData is an offset to the first sound effect entry + soundListOffset = fontData[1]; if (1) {} - if ((reloc2 != 0) && (numSfx != 0)) { - ptrs[1] = BASE_OFFSET(reloc2); + + // If the soundFont has sound effects + if ((soundListOffset != 0) && (numSfx != 0)) { + + fontData[1] = RELOC_TO_RAM(soundListOffset); + + // Loop through the sound effects for (i = 0; i < numSfx; i++) { - reloc = (SoundFontSound*)ptrs[1] + i; - if (reloc != 0) { - sfx = reloc; - if (sfx->sample != NULL) { - AudioLoad_RelocateSample(sfx, fontData, relocInfo); - } + // Get a pointer to the i'th sound effect + soundOffset = (TunedSample*)fontData[1] + i; + soundEffect = (SoundEffect*)soundOffset; + + // Check for NULL (note: the pointer is guaranteed to be in fontData and can never be NULL) + if ((soundEffect != NULL) && (soundEffect->tunedSample.sample != NULL)) { + AudioLoad_RelocateSample(&soundEffect->tunedSample, fontDataStartAddr, sampleBankReloc); } } } - if (numInstruments > 0x7E) { - numInstruments = 0x7E; + // Instruments relocation + + // Instrument Id 126 and above is reserved. + // There can only be 126 instruments, indexed from 0 to 125 + if (numInstruments > 126) { + numInstruments = 126; } - // relocate instruments + // Starting from the 3rd u32 in fontData is the list of offsets to the instruments + // Loop through the instruments for (i = 2; i <= 2 + numInstruments - 1; i++) { - if (ptrs[i] != NULL) { - ptrs[i] = BASE_OFFSET(ptrs[i]); - inst = ptrs[i]; - if (!inst->loaded) { + // Some instrument data entries are empty, represented by an offset of 0 in the list of instrument offsets + if (fontData[i] != 0) { + fontData[i] = RELOC_TO_RAM(fontData[i]); + inst = (Instrument*)fontData[i]; + + // The instrument may be in the list multiple times and already relocated + if (!inst->isRelocated) { + // Some instruments have a different sample for low pitches if (inst->normalRangeLo != 0) { - AudioLoad_RelocateSample(&inst->lowNotesSound, fontData, relocInfo); - } - AudioLoad_RelocateSample(&inst->normalNotesSound, fontData, relocInfo); - if (inst->normalRangeHi != 0x7F) { - AudioLoad_RelocateSample(&inst->highNotesSound, fontData, relocInfo); + AudioLoad_RelocateSample(&inst->lowPitchTunedSample, fontDataStartAddr, sampleBankReloc); } - reloc = inst->envelope; - inst->envelope = BASE_OFFSET(reloc); - inst->loaded = true; + // Every instrument has a sample for the default range + AudioLoad_RelocateSample(&inst->normalPitchTunedSample, fontDataStartAddr, sampleBankReloc); + + // Some instruments have a different sample for high pitches + if (inst->normalRangeHi != 0x7F) { + AudioLoad_RelocateSample(&inst->highPitchTunedSample, fontDataStartAddr, sampleBankReloc); + } + + soundOffset = inst->envelope; + inst->envelope = (EnvelopePoint*)RELOC_TO_RAM(soundOffset); + + inst->isRelocated = true; } } } -#undef BASE_OFFSET +#undef RELOC_TO_RAM - gAudioContext.soundFonts[fontId].drums = ptrs[0]; - gAudioContext.soundFonts[fontId].soundEffects = ptrs[1]; - gAudioContext.soundFonts[fontId].instruments = (Instrument**)(&ptrs[2]); + // Store the relocated pointers + gAudioCtx.soundFontList[fontId].drums = (Drum**)fontData[0]; + gAudioCtx.soundFontList[fontId].soundEffects = (SoundEffect*)fontData[1]; + gAudioCtx.soundFontList[fontId].instruments = (Instrument**)(&fontData[2]); } void AudioLoad_SyncDma(uintptr_t devAddr, u8* ramAddr, size_t size, s32 medium) { - OSMesgQueue* msgQueue = &gAudioContext.syncDmaQueue; - OSIoMesg* ioMesg = &gAudioContext.syncDmaIoMesg; + OSMesgQueue* msgQueue = &gAudioCtx.syncDmaQueue; + OSIoMesg* ioMesg = &gAudioCtx.syncDmaIoMesg; size = ALIGN16(size); Audio_InvalDCache(ramAddr, size); @@ -976,19 +1015,19 @@ s32 AudioLoad_Dma(OSIoMesg* mesg, u32 priority, s32 direction, uintptr_t devAddr OSMesgQueue* reqQueue, s32 medium, const char* dmaFuncType) { OSPiHandle* handle; - if (gAudioContext.resetTimer > 16) { + if (gAudioCtx.resetTimer > 16) { return -1; } switch (medium) { case MEDIUM_CART: - handle = gAudioContext.cartHandle; + handle = gAudioCtx.cartHandle; break; case MEDIUM_DISK_DRIVE: // driveHandle is uninitialized and corresponds to stubbed-out disk drive support. // SM64 Shindou called osDriveRomInit here. - handle = gAudioContext.driveHandle; + handle = gAudioCtx.driveHandle; break; default: @@ -1032,19 +1071,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 (gAudioCtx.seqLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; case FONT_TABLE: - if (gAudioContext.fontLoadStatus[realId] == LOAD_STATUS_1) { + if (gAudioCtx.fontLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; case SAMPLE_TABLE: - if (gAudioContext.sampleFontLoadStatus[realId] == LOAD_STATUS_1) { + if (gAudioCtx.sampleFontLoadStatus[realId] == LOAD_STATUS_IN_PROGRESS) { return NULL; } break; @@ -1052,8 +1091,8 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, ramAddr = AudioLoad_SearchCaches(tableType, realId); if (ramAddr != NULL) { - loadStatus = LOAD_STATUS_2; - osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_0), OS_MESG_NOBLOCK); + loadStatus = LOAD_STATUS_COMPLETE; + osSendMesg(retQueue, MK_ASYNC_MSG(retData, 0, 0, LOAD_STATUS_NOT_LOADED), OS_MESG_NOBLOCK); } else { table = AudioLoad_GetLoadTable(tableType); size = table->entries[realId].size; @@ -1061,7 +1100,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, medium = table->entries[id].medium; cachePolicy = table->entries[id].cachePolicy; romAddr = table->entries[realId].romAddr; - loadStatus = LOAD_STATUS_2; + loadStatus = LOAD_STATUS_COMPLETE; switch (cachePolicy) { case CACHE_LOAD_PERMANENT: @@ -1069,7 +1108,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: @@ -1101,7 +1140,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, } if (tableType == FONT_TABLE) { - soundFont = &gAudioContext.soundFonts[realId]; + soundFont = &gAudioCtx.soundFontList[realId]; soundFont->numInstruments = ((UnloadedFonts*)romAddr)->numInstruments; soundFont->numDrums = ((UnloadedFonts*)romAddr)->numDrums; @@ -1119,7 +1158,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) { @@ -1153,9 +1192,9 @@ void AudioLoad_SetUnusedHandler(void* callback) { sUnusedHandler = callback; } -void AudioLoad_InitSoundFontMeta(s32 fontId) { - SoundFont* font = &gAudioContext.soundFonts[fontId]; - AudioTableEntry* entry = &gAudioContext.soundFontTable->entries[fontId]; +void AudioLoad_InitSoundFont(s32 fontId) { + SoundFont* font = &gAudioCtx.soundFontList[fontId]; + AudioTableEntry* entry = &gAudioCtx.soundFontTable->entries[fontId]; font->sampleBankId1 = (entry->shortData1 >> 8) & 0xFF; font->sampleBankId2 = (entry->shortData1) & 0xFF; @@ -1168,132 +1207,133 @@ void AudioLoad_Init(void* heap, size_t heapSize) { s32 pad1[9]; s32 numFonts; s32 pad2[2]; - u8* audioContextPtr; + u8* audioCtxPtr; void* addr; s32 i; s32 j; - D_80208E68 = NULL; - D_80208E70 = NULL; - D_80208E74 = NULL; + gAudioCustomUpdateFunction = NULL; + gAudioCustomReverbFunction = NULL; + gAudioCustomSynthFunction = NULL; - for (i = 0; i < ARRAY_COUNT(gAudioContext.unk_29A8); i++) { - gAudioContext.unk_29A8[i] = NULL; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.customSeqFunctions); i++) { + gAudioCtx.customSeqFunctions[i] = NULL; } - gAudioContext.resetTimer = 0; - gAudioContext.unk_29B8 = false; + gAudioCtx.resetTimer = 0; + gAudioCtx.unk_29B8 = false; - // Set all of gAudioContext to 0 - audioContextPtr = (u8*)&gAudioContext; - for (j = sizeof(gAudioContext); j >= 0; j--) { - *audioContextPtr++ = 0; + // Set all of gAudioCtx to 0 + audioCtxPtr = (u8*)&gAudioCtx; + for (j = sizeof(gAudioCtx); j >= 0; j--) { + *audioCtxPtr++ = 0; } switch (osTvType) { case OS_TV_PAL: - gAudioContext.unk_2960 = 20.03042f; - gAudioContext.refreshRate = 50; + gAudioCtx.unk_2960 = 20.03042f; + gAudioCtx.refreshRate = 50; break; case OS_TV_MPAL: - gAudioContext.unk_2960 = 16.546f; - gAudioContext.refreshRate = 60; + gAudioCtx.unk_2960 = 16.546f; + gAudioCtx.refreshRate = 60; break; case OS_TV_NTSC: default: - gAudioContext.unk_2960 = 16.713f; - gAudioContext.refreshRate = 60; + gAudioCtx.unk_2960 = 16.713f; + gAudioCtx.refreshRate = 60; } - Audio_InitMesgQueues(); + AudioThread_InitMesgQueues(); - for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) { - gAudioContext.aiBufLengths[i] = 0xA0; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.numSamplesPerFrame); i++) { + gAudioCtx.numSamplesPerFrame[i] = 0xA0; } - gAudioContext.totalTaskCount = 0; - gAudioContext.rspTaskIndex = 0; - gAudioContext.curAiBuffferIndex = 0; - gAudioContext.soundMode = AUDIO_MODE_STEREO; - gAudioContext.curTask = NULL; - gAudioContext.rspTask[0].task.t.dataSize = 0; - gAudioContext.rspTask[1].task.t.dataSize = 0; + gAudioCtx.totalTaskCount = 0; + gAudioCtx.rspTaskIndex = 0; + gAudioCtx.curAiBufferIndex = 0; + gAudioCtx.soundMode = SOUNDMODE_STEREO; + gAudioCtx.curTask = NULL; + gAudioCtx.rspTask[0].task.t.dataSize = 0; + gAudioCtx.rspTask[1].task.t.dataSize = 0; - osCreateMesgQueue(&gAudioContext.syncDmaQueue, &gAudioContext.syncDmaMesg, 1); - osCreateMesgQueue(&gAudioContext.currAudioFrameDmaQueue, gAudioContext.currAudioFrameDmaMesgBuf, - ARRAY_COUNT(gAudioContext.currAudioFrameDmaMesgBuf)); - osCreateMesgQueue(&gAudioContext.externalLoadQueue, gAudioContext.externalLoadMesgBuf, - ARRAY_COUNT(gAudioContext.externalLoadMesgBuf)); - osCreateMesgQueue(&gAudioContext.preloadSampleQueue, gAudioContext.preloadSampleMesgBuf, - ARRAY_COUNT(gAudioContext.preloadSampleMesgBuf)); - gAudioContext.curAudioFrameDmaCount = 0; - gAudioContext.sampleDmaCount = 0; - gAudioContext.cartHandle = osCartRomInit(); + osCreateMesgQueue(&gAudioCtx.syncDmaQueue, &gAudioCtx.syncDmaMesg, 1); + osCreateMesgQueue(&gAudioCtx.curAudioFrameDmaQueue, gAudioCtx.currAudioFrameDmaMesgBuf, + ARRAY_COUNT(gAudioCtx.currAudioFrameDmaMesgBuf)); + osCreateMesgQueue(&gAudioCtx.externalLoadQueue, gAudioCtx.externalLoadMesgBuf, + ARRAY_COUNT(gAudioCtx.externalLoadMesgBuf)); + osCreateMesgQueue(&gAudioCtx.preloadSampleQueue, gAudioCtx.preloadSampleMesgBuf, + ARRAY_COUNT(gAudioCtx.preloadSampleMesgBuf)); + gAudioCtx.curAudioFrameDmaCount = 0; + gAudioCtx.sampleDmaCount = 0; + gAudioCtx.cartHandle = osCartRomInit(); if (heap == NULL) { - gAudioContext.audioHeap = gAudioHeap; - gAudioContext.audioHeapSize = gAudioContextInitSizes.heapSize; + gAudioCtx.audioHeap = gAudioHeap; + gAudioCtx.audioHeapSize = gAudioHeapInitSizes.heapSize; } else { void** hp = &heap; - gAudioContext.audioHeap = *hp; - gAudioContext.audioHeapSize = heapSize; + + gAudioCtx.audioHeap = *hp; + gAudioCtx.audioHeapSize = heapSize; } - for (i = 0; i < (s32)gAudioContext.audioHeapSize / 8; i++) { - ((u64*)gAudioContext.audioHeap)[i] = 0; + for (i = 0; i < ((s32)gAudioCtx.audioHeapSize / (s32)sizeof(u64)); i++) { + ((u64*)gAudioCtx.audioHeap)[i] = 0; } // Main Pool Split (split entirety of audio heap into initPool and sessionPool) - AudioHeap_InitMainPool(gAudioContextInitSizes.mainPoolSplitSize); + AudioHeap_InitMainPool(gAudioHeapInitSizes.initPoolSize); - // Initialize the audio interface buffer - for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBuffers); i++) { - gAudioContext.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioContext.audioInitPool, AIBUF_LEN * sizeof(s16)); + // Initialize the audio interface buffers + for (i = 0; i < ARRAY_COUNT(gAudioCtx.aiBuffers); i++) { + gAudioCtx.aiBuffers[i] = AudioHeap_AllocZeroed(&gAudioCtx.initPool, AIBUF_LEN * sizeof(s16)); } // Connect audio tables to their tables in memory - gAudioContext.sequenceTable = (AudioTable*)gSequenceTable; - gAudioContext.soundFontTable = (AudioTable*)gSoundFontTable; - gAudioContext.sampleBankTable = (AudioTable*)gSampleBankTable; - gAudioContext.sequenceFontTable = gSequenceFontTable; + gAudioCtx.sequenceTable = (AudioTable*)gSequenceTable; + gAudioCtx.soundFontTable = (AudioTable*)gSoundFontTable; + gAudioCtx.sampleBankTable = (AudioTable*)gSampleBankTable; + gAudioCtx.sequenceFontTable = gSequenceFontTable; - gAudioContext.numSequences = gAudioContext.sequenceTable->numEntries; + gAudioCtx.numSequences = gAudioCtx.sequenceTable->numEntries; - gAudioContext.audioResetSpecIdToLoad = 0; - gAudioContext.resetStatus = 1; // Set reset to immediately initialize the audio heap + gAudioCtx.specId = 0; + gAudioCtx.resetStatus = 1; // Set reset to immediately initialize the audio heap AudioHeap_ResetStep(); // Initialize audio tables - AudioLoad_InitTable(gAudioContext.sequenceTable, SEGMENT_ROM_START(Audioseq), 0); - AudioLoad_InitTable(gAudioContext.soundFontTable, SEGMENT_ROM_START(Audiobank), 0); - AudioLoad_InitTable(gAudioContext.sampleBankTable, SEGMENT_ROM_START(Audiotable), 0); + AudioLoad_InitTable(gAudioCtx.sequenceTable, SEGMENT_ROM_START(Audioseq), 0); + AudioLoad_InitTable(gAudioCtx.soundFontTable, SEGMENT_ROM_START(Audiobank), 0); + AudioLoad_InitTable(gAudioCtx.sampleBankTable, SEGMENT_ROM_START(Audiotable), 0); - numFonts = gAudioContext.soundFontTable->numEntries; - gAudioContext.soundFonts = AudioHeap_Alloc(&gAudioContext.audioInitPool, numFonts * sizeof(SoundFont)); + numFonts = gAudioCtx.soundFontTable->numEntries; + gAudioCtx.soundFontList = AudioHeap_Alloc(&gAudioCtx.initPool, numFonts * sizeof(SoundFont)); for (i = 0; i < numFonts; i++) { - AudioLoad_InitSoundFontMeta(i); + AudioLoad_InitSoundFont(i); } - if (addr = AudioHeap_Alloc(&gAudioContext.audioInitPool, gAudioContextInitSizes.permanentPoolSize), addr == NULL) { - // cast away const from D_8014A6C4 - *((u32*)&gAudioContextInitSizes.permanentPoolSize) = 0; + if (addr = AudioHeap_Alloc(&gAudioCtx.initPool, gAudioHeapInitSizes.permanentPoolSize), addr == NULL) { + // cast away const from gAudioHeapInitSizes + *((u32*)&gAudioHeapInitSizes.permanentPoolSize) = 0; } - AudioHeap_AllocPoolInit(&gAudioContext.permanentPool, addr, gAudioContextInitSizes.permanentPoolSize); - gAudioContextInitalized = true; - osSendMesg(gAudioContext.taskStartQueueP, (void*)gAudioContext.totalTaskCount, OS_MESG_NOBLOCK); + AudioHeap_InitPool(&gAudioCtx.permanentPool, addr, gAudioHeapInitSizes.permanentPoolSize); + gAudioCtxInitalized = true; + osSendMesg(gAudioCtx.taskStartQueueP, (void*)gAudioCtx.totalTaskCount, OS_MESG_NOBLOCK); } void AudioLoad_InitSlowLoads(void) { - gAudioContext.slowLoads[0].status = 0; - gAudioContext.slowLoads[1].status = 0; + gAudioCtx.slowLoads[0].status = 0; + gAudioCtx.slowLoads[1].status = 0; } s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { - SoundFontSample* sample; + Sample* sample; AudioSlowLoad* slowLoad; sample = AudioLoad_GetFontSample(fontId, instId); @@ -1307,7 +1347,7 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { return 0; } - slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + slowLoad = &gAudioCtx.slowLoads[gAudioCtx.slowLoadPos]; if (slowLoad->status == LOAD_STATUS_DONE) { slowLoad->status = LOAD_STATUS_WAITING; } @@ -1336,15 +1376,15 @@ s32 AudioLoad_SlowLoadSample(s32 fontId, s32 instId, s8* isDone) { slowLoad->instId = instId; if (slowLoad->medium == MEDIUM_UNK) { - slowLoad->unkMediumParam = gAudioContext.sampleBankTable->unkMediumParam; + slowLoad->unkMediumParam = gAudioCtx.sampleBankTable->unkMediumParam; } - gAudioContext.slowLoadPos ^= 1; + gAudioCtx.slowLoadPos ^= 1; return 0; } -SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { - SoundFontSample* sample; +Sample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { + Sample* sample; if (instId < 0x80) { Instrument* instrument = AudioPlayback_GetInstrumentInner(fontId, instId); @@ -1352,21 +1392,21 @@ SoundFontSample* AudioLoad_GetFontSample(s32 fontId, s32 instId) { if (instrument == NULL) { return NULL; } - sample = instrument->normalNotesSound.sample; + sample = instrument->normalPitchTunedSample.sample; } else if (instId < 0x100) { Drum* drum = AudioPlayback_GetDrum(fontId, instId - 0x80); if (drum == NULL) { return NULL; } - sample = drum->sound.sample; + sample = drum->tunedSample.sample; } else { - SoundFontSound* sound = AudioPlayback_GetSfx(fontId, instId - 0x100); + SoundEffect* soundEffect = AudioPlayback_GetSoundEffect(fontId, instId - 0x100); - if (sound == NULL) { + if (soundEffect == NULL) { return NULL; } - sample = sound->sample; + sample = soundEffect->tunedSample.sample; } return sample; @@ -1376,7 +1416,7 @@ void AudioLoad_Unused2(void) { } void AudioLoad_FinishSlowLoad(AudioSlowLoad* slowLoad) { - SoundFontSample* sample; + Sample* sample; if (slowLoad->sample.sampleAddr == NULL) { return; @@ -1396,9 +1436,9 @@ void AudioLoad_ProcessSlowLoads(s32 resetStatus) { AudioSlowLoad* slowLoad; s32 i; - for (i = 0; i < ARRAY_COUNT(gAudioContext.slowLoads); i++) { - slowLoad = &gAudioContext.slowLoads[i]; - switch (gAudioContext.slowLoads[i].status) { + for (i = 0; i < ARRAY_COUNT(gAudioCtx.slowLoads); i++) { + slowLoad = &gAudioCtx.slowLoads[i]; + switch (gAudioCtx.slowLoads[i].status) { case LOAD_STATUS_LOADING: if (slowLoad->medium != MEDIUM_UNK) { osRecvMesg(&slowLoad->msgqueue, NULL, OS_MESG_BLOCK); @@ -1455,14 +1495,14 @@ s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) { AudioTable* seqTable; size_t size; - if (seqId >= gAudioContext.numSequences) { + if (seqId >= gAudioCtx.numSequences) { *isDone = 0; return -1; } seqId = AudioLoad_GetRealTableIndex(SEQUENCE_TABLE, seqId); seqTable = AudioLoad_GetLoadTable(SEQUENCE_TABLE); - slowLoad = &gAudioContext.slowLoads[gAudioContext.slowLoadPos]; + slowLoad = &gAudioCtx.slowLoads[gAudioCtx.slowLoadPos]; if (slowLoad->status == LOAD_STATUS_DONE) { slowLoad->status = LOAD_STATUS_WAITING; } @@ -1483,15 +1523,15 @@ s32 AudioLoad_SlowLoadSeq(s32 seqId, u8* ramAddr, s8* isDone) { slowLoad->unkMediumParam = seqTable->unkMediumParam; } - gAudioContext.slowLoadPos ^= 1; + gAudioCtx.slowLoadPos ^= 1; return 0; } void AudioLoad_InitAsyncLoads(void) { s32 i; - for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { - gAudioContext.asyncLoads[i].status = 0; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.asyncLoads); i++) { + gAudioCtx.asyncLoads[i].status = 0; } } @@ -1504,7 +1544,7 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoadUnkMedium(s32 unkMediumParam, uintptr_t return NULL; } - osSendMesg(&gAudioContext.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); + osSendMesg(&gAudioCtx.asyncLoadUnkMediumQueue, asyncLoad, OS_MESG_NOBLOCK); asyncLoad->unkMediumParam = unkMediumParam; return asyncLoad; } @@ -1514,15 +1554,15 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoad(uintptr_t devAddr, void* ramAddr, size_ AudioAsyncLoad* asyncLoad; s32 i; - for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { - if (gAudioContext.asyncLoads[i].status == 0) { - asyncLoad = &gAudioContext.asyncLoads[i]; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.asyncLoads); i++) { + if (gAudioCtx.asyncLoads[i].status == 0) { + asyncLoad = &gAudioCtx.asyncLoads[i]; break; } } // no more available async loads - if (i == ARRAY_COUNT(gAudioContext.asyncLoads)) { + if (i == ARRAY_COUNT(gAudioCtx.asyncLoads)) { return NULL; } @@ -1555,29 +1595,29 @@ void AudioLoad_ProcessAsyncLoads(s32 resetStatus) { AudioAsyncLoad* asyncLoad; s32 i; - if (gAudioContext.resetTimer == 1) { + if (gAudioCtx.resetTimer == 1) { return; } - if (gAudioContext.curUnkMediumLoad == NULL) { + if (gAudioCtx.curUnkMediumLoad == NULL) { if (resetStatus != 0) { // Clear and ignore queue if resetting. do { - } while (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) != -1); - } else if (osRecvMesg(&gAudioContext.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) == -1) { - gAudioContext.curUnkMediumLoad = NULL; + } while (osRecvMesg(&gAudioCtx.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) != -1); + } else if (osRecvMesg(&gAudioCtx.asyncLoadUnkMediumQueue, (OSMesg*)&asyncLoad, OS_MESG_NOBLOCK) == -1) { + gAudioCtx.curUnkMediumLoad = NULL; } else { - gAudioContext.curUnkMediumLoad = asyncLoad; + gAudioCtx.curUnkMediumLoad = asyncLoad; } } - if (gAudioContext.curUnkMediumLoad != NULL) { - AudioLoad_ProcessAsyncLoadUnkMedium(gAudioContext.curUnkMediumLoad, resetStatus); + if (gAudioCtx.curUnkMediumLoad != NULL) { + AudioLoad_ProcessAsyncLoadUnkMedium(gAudioCtx.curUnkMediumLoad, resetStatus); } - for (i = 0; i < ARRAY_COUNT(gAudioContext.asyncLoads); i++) { - if (gAudioContext.asyncLoads[i].status == 1) { - asyncLoad = &gAudioContext.asyncLoads[i]; + for (i = 0; i < ARRAY_COUNT(gAudioCtx.asyncLoads); i++) { + if (gAudioCtx.asyncLoads[i].status == 1) { + asyncLoad = &gAudioCtx.asyncLoads[i]; if (asyncLoad->medium != MEDIUM_UNK) { AudioLoad_ProcessAsyncLoad(asyncLoad, resetStatus); } @@ -1595,7 +1635,7 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { OSMesg doneMsg; u32 sampleBankId1; u32 sampleBankId2; - AudioRelocInfo relocInfo; + SampleBankRelocInfo sampleBankReloc; if (1) {} switch (ASYNC_TBLTYPE(retMsg)) { @@ -1607,16 +1647,16 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { break; case FONT_TABLE: fontId = ASYNC_ID(retMsg); - sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; - sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; - relocInfo.sampleBankId1 = sampleBankId1; - relocInfo.sampleBankId2 = sampleBankId2; - relocInfo.baseAddr1 = - sampleBankId1 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId1, &relocInfo.medium1) : 0; - relocInfo.baseAddr2 = - sampleBankId2 != 0xFF ? AudioLoad_GetSampleBank(sampleBankId2, &relocInfo.medium2) : 0; + sampleBankId1 = gAudioCtx.soundFontList[fontId].sampleBankId1; + sampleBankId2 = gAudioCtx.soundFontList[fontId].sampleBankId2; + sampleBankReloc.sampleBankId1 = sampleBankId1; + sampleBankReloc.sampleBankId2 = sampleBankId2; + sampleBankReloc.baseAddr1 = + (sampleBankId1 != 0xFF) ? AudioLoad_GetSampleBank(sampleBankId1, &sampleBankReloc.medium1) : 0; + sampleBankReloc.baseAddr2 = + (sampleBankId2 != 0xFF) ? AudioLoad_GetSampleBank(sampleBankId2, &sampleBankReloc.medium2) : 0; AudioLoad_SetFontLoadStatus(fontId, ASYNC_STATUS(retMsg)); - AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &relocInfo, true); + AudioLoad_RelocateFontAndPreloadSamples(fontId, asyncLoad->ramAddr, &sampleBankReloc, true); break; } @@ -1627,7 +1667,7 @@ void AudioLoad_FinishAsyncLoad(AudioAsyncLoad* asyncLoad) { } void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus) { - AudioTable* sampleBankTable = gAudioContext.sampleBankTable; + AudioTable* sampleBankTable = gAudioCtx.sampleBankTable; if (asyncLoad->delay >= 2) { asyncLoad->delay--; @@ -1699,28 +1739,48 @@ void AudioLoad_AsyncDmaRamUnloaded(AudioAsyncLoad* asyncLoad, size_t size) { void AudioLoad_AsyncDmaUnkMedium(uintptr_t devAddr, void* ramAddr, size_t size, s16 arg3) { } -#define RELOC(v, base) (reloc = (void*)((uintptr_t)(v) + (uintptr_t)(base))) - -void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, AudioRelocInfo* relocInfo) { - SoundFontSample* sample; +/** + * Read and extract information from TunedSample and its Sample + * contained in the soundFont binary loaded into ram + * TunedSample contains metadata on a sample used by a particular instrument/drum/sfx + * Also relocate offsets into pointers within this loaded TunedSample + * + * @param fontId index of font being processed + * @param fontData ram address of raw soundfont binary loaded into cache + * @param sampleBankReloc information on the sampleBank containing raw audio samples + */ +void AudioLoad_RelocateSample(TunedSample* tunedSample, SoundFontData* fontData, SampleBankRelocInfo* sampleBankReloc) { + Sample* sample; void* reloc; - if ((uintptr_t)sound->sample <= 0x80000000) { - sample = sound->sample = RELOC(sound->sample, mem); - if (sample->size != 0 && sample->unk_bit25 != true) { - sample->loop = RELOC(sample->loop, mem); - sample->book = RELOC(sample->book, mem); + // Relocate an offset (relative to data loaded in ram at `base`) to a pointer (a ram address) +#define AUDIO_RELOC(v, base) (reloc = (void*)((uintptr_t)(v) + (uintptr_t)(base))) - // Resolve the sample medium 2-bit bitfield into a real value based on relocInfo. + if ((uintptr_t)tunedSample->sample <= AUDIO_RELOCATED_ADDRESS_START) { + + sample = tunedSample->sample = AUDIO_RELOC(tunedSample->sample, fontData); + + // If the sample exists and has not already been relocated + // Note: this is important, as the same sample can be used by different drums, sound effects, instruments + if ((sample->size != 0) && (sample->isRelocated != true)) { + sample->loop = AUDIO_RELOC(sample->loop, fontData); + sample->book = AUDIO_RELOC(sample->book, fontData); + + // Resolve the sample medium 2-bit bitfield into a real value based on sampleBankReloc. + // Then relocate the offset sample within the sampleBank (not the fontData) into absolute address. + // sampleAddr can be either rom or ram depending on sampleBank cache policy + // in practice, this is always in rom switch (sample->medium) { case 0: - sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr1); - sample->medium = relocInfo->medium1; + sample->sampleAddr = AUDIO_RELOC(sample->sampleAddr, sampleBankReloc->baseAddr1); + sample->medium = sampleBankReloc->medium1; break; + case 1: - sample->sampleAddr = RELOC(sample->sampleAddr, relocInfo->baseAddr2); - sample->medium = relocInfo->medium2; + sample->sampleAddr = AUDIO_RELOC(sample->sampleAddr, sampleBankReloc->baseAddr2); + sample->medium = sampleBankReloc->medium2; break; + case 2: case 3: // Invalid? This leaves sample->medium as MEDIUM_CART and MEDIUM_DISK_DRIVE @@ -1728,20 +1788,28 @@ void AudioLoad_RelocateSample(SoundFontSound* sound, SoundFontData* mem, AudioRe break; } - sample->unk_bit25 = true; + sample->isRelocated = true; + if (sample->unk_bit26 && (sample->medium != MEDIUM_RAM)) { - gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + gAudioCtx.usedSamples[gAudioCtx.numUsedSamples++] = sample; } } } } -#undef RELOC +#undef AUDIO_RELOC -void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, AudioRelocInfo* relocInfo, s32 async) { +/** + * @param fontId index of font being processed + * @param fontData ram address of raw soundfont binary loaded into cache + * @param sampleBankReloc information on the sampleBank containing raw audio samples + * @param isAsync bool for whether this is an asynchronous load or not + */ +void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* fontData, SampleBankRelocInfo* sampleBankReloc, + s32 isAsync) { AudioPreloadReq* preload; AudioPreloadReq* topPreload; - SoundFontSample* sample; + Sample* sample; size_t size; s32 nChunks; u8* sampleRamAddr; @@ -1749,35 +1817,35 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Aud s32 i; preloadInProgress = false; - if (gAudioContext.preloadSampleStackTop != 0) { + if (gAudioCtx.preloadSampleStackTop != 0) { preloadInProgress = true; } else { D_801FD1E0 = 0; } - gAudioContext.numUsedSamples = 0; - AudioLoad_RelocateFont(fontId, mem, relocInfo); + gAudioCtx.numUsedSamples = 0; + AudioLoad_RelocateFont(fontId, fontData, sampleBankReloc); size = 0; - for (i = 0; i < gAudioContext.numUsedSamples; i++) { - size += ALIGN16(gAudioContext.usedSamples[i]->size); + for (i = 0; i < gAudioCtx.numUsedSamples; i++) { + size += ALIGN16(gAudioCtx.usedSamples[i]->size); } if (size && size) {} - for (i = 0; i < gAudioContext.numUsedSamples; i++) { - if (gAudioContext.preloadSampleStackTop == 120) { + for (i = 0; i < gAudioCtx.numUsedSamples; i++) { + if (gAudioCtx.preloadSampleStackTop == 120) { break; } - sample = gAudioContext.usedSamples[i]; + sample = gAudioCtx.usedSamples[i]; sampleRamAddr = NULL; - switch (async) { + switch (isAsync) { case false: - if (sample->medium == relocInfo->medium1) { - sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + if (sample->medium == sampleBankReloc->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); - } else if (sample->medium == relocInfo->medium2) { - sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + } else if (sample->medium == sampleBankReloc->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } else if (sample->medium == MEDIUM_DISK_DRIVE) { sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, @@ -1786,27 +1854,30 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Aud break; case true: - if (sample->medium == relocInfo->medium1) { - sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, + if (sample->medium == sampleBankReloc->medium1) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); - } else if (sample->medium == relocInfo->medium2) { - sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, + } else if (sample->medium == sampleBankReloc->medium2) { + sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } else if (sample->medium == MEDIUM_DISK_DRIVE) { sampleRamAddr = AudioHeap_AllocSampleCache(sample->size, 0xFE, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } break; + + default: + break; } if (sampleRamAddr == NULL) { continue; } - switch (async) { + switch (isAsync) { case false: if (sample->medium == MEDIUM_UNK) { AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, sampleRamAddr, sample->size, - gAudioContext.sampleBankTable->unkMediumParam); + gAudioCtx.sampleBankTable->unkMediumParam); sample->sampleAddr = sampleRamAddr; sample->medium = MEDIUM_RAM; } else { @@ -1818,49 +1889,52 @@ void AudioLoad_RelocateFontAndPreloadSamples(s32 fontId, SoundFontData* mem, Aud break; case true: - preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload = &gAudioCtx.preloadSampleStack[gAudioCtx.preloadSampleStackTop]; preload->sample = sample; preload->ramAddr = sampleRamAddr; - preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->encodedInfo = (gAudioCtx.preloadSampleStackTop << 24) | 0xFFFFFF; preload->isFree = false; preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; - gAudioContext.preloadSampleStackTop++; + gAudioCtx.preloadSampleStackTop++; + break; + + default: break; } } - gAudioContext.numUsedSamples = 0; + gAudioCtx.numUsedSamples = 0; - if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { - topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + if (gAudioCtx.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioCtx.preloadSampleStack[gAudioCtx.preloadSampleStackTop - 1]; sample = topPreload->sample; nChunks = (sample->size >> 12) + 1; AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, - nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + nChunks, &gAudioCtx.preloadSampleQueue, topPreload->encodedInfo); } } s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { - SoundFontSample* sample; + Sample* sample; AudioPreloadReq* preload; u32 preloadIndex; u32 key; u32 nChunks; s32 pad; - if (gAudioContext.preloadSampleStackTop > 0) { + if (gAudioCtx.preloadSampleStackTop > 0) { if (resetStatus != 0) { // Clear result queue and preload stack and return. - osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK); - gAudioContext.preloadSampleStackTop = 0; + osRecvMesg(&gAudioCtx.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK); + gAudioCtx.preloadSampleStackTop = 0; return false; } - if (osRecvMesg(&gAudioContext.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK) == -1) { + if (osRecvMesg(&gAudioCtx.preloadSampleQueue, (OSMesg*)&preloadIndex, OS_MESG_NOBLOCK) == -1) { // Previous preload is not done yet. return false; } preloadIndex >>= 24; - preload = &gAudioContext.preloadSampleStack[preloadIndex]; + preload = &gAudioCtx.preloadSampleStack[preloadIndex]; if (preload->isFree == false) { sample = preload->sample; @@ -1876,12 +1950,12 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { // Pop requests with isFree = true off the stack, as far as possible, // and dispatch the next DMA. for (;;) { - if (gAudioContext.preloadSampleStackTop <= 0) { + if (gAudioCtx.preloadSampleStackTop <= 0) { break; } - preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + preload = &gAudioCtx.preloadSampleStack[gAudioCtx.preloadSampleStackTop - 1]; if (preload->isFree == true) { - gAudioContext.preloadSampleStackTop--; + gAudioCtx.preloadSampleStackTop--; continue; } @@ -1890,10 +1964,10 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { key = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; if (key != preload->endAndMediumKey) { preload->isFree = true; - gAudioContext.preloadSampleStackTop--; + gAudioCtx.preloadSampleStackTop--; } else { AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, preload->ramAddr, sample->size, sample->medium, - nChunks, &gAudioContext.preloadSampleQueue, preload->encodedInfo); + nChunks, &gAudioCtx.preloadSampleQueue, preload->encodedInfo); break; } } @@ -1901,7 +1975,7 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { return true; } -s32 AudioLoad_AddToSampleSet(SoundFontSample* sample, s32 numSamples, SoundFontSample** sampleSet) { +s32 AudioLoad_AddToSampleSet(Sample* sample, s32 numSamples, Sample** sampleSet) { s32 i; for (i = 0; i < numSamples; i++) { @@ -1918,18 +1992,18 @@ s32 AudioLoad_AddToSampleSet(SoundFontSample* sample, s32 numSamples, SoundFontS return numSamples; } -s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { +s32 AudioLoad_GetSamplesForFont(s32 fontId, Sample** sampleSet) { s32 i; s32 numSamples = 0; - s32 numDrums = gAudioContext.soundFonts[fontId].numDrums; - s32 numInstruments = gAudioContext.soundFonts[fontId].numInstruments; + s32 numDrums = gAudioCtx.soundFontList[fontId].numDrums; + s32 numInstruments = gAudioCtx.soundFontList[fontId].numInstruments; for (i = 0; i < numDrums; i++) { Drum* drum = AudioPlayback_GetDrum(fontId, i); if (1) {} if (drum != NULL) { - numSamples = AudioLoad_AddToSampleSet(drum->sound.sample, numSamples, sampleSet); + numSamples = AudioLoad_AddToSampleSet(drum->tunedSample.sample, numSamples, sampleSet); } } @@ -1938,12 +2012,12 @@ s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { if (instrument != NULL) { if (instrument->normalRangeLo != 0) { - numSamples = AudioLoad_AddToSampleSet(instrument->lowNotesSound.sample, numSamples, sampleSet); + numSamples = AudioLoad_AddToSampleSet(instrument->lowPitchTunedSample.sample, numSamples, sampleSet); } if (instrument->normalRangeHi != 0x7F) { - numSamples = AudioLoad_AddToSampleSet(instrument->highNotesSound.sample, numSamples, sampleSet); + numSamples = AudioLoad_AddToSampleSet(instrument->highPitchTunedSample.sample, numSamples, sampleSet); } - numSamples = AudioLoad_AddToSampleSet(instrument->normalNotesSound.sample, numSamples, sampleSet); + numSamples = AudioLoad_AddToSampleSet(instrument->normalPitchTunedSample.sample, numSamples, sampleSet); } } @@ -1951,105 +2025,105 @@ s32 AudioLoad_GetSamplesForFont(s32 fontId, SoundFontSample** sampleSet) { return numSamples; } -void AudioLoad_AddUsedSample(SoundFontSound* sound) { - SoundFontSample* sample = sound->sample; +void AudioLoad_AddUsedSample(TunedSample* tunedSample) { + Sample* sample = tunedSample->sample; if ((sample->size != 0) && (sample->unk_bit26) && (sample->medium != MEDIUM_RAM)) { - gAudioContext.usedSamples[gAudioContext.numUsedSamples++] = sample; + gAudioCtx.usedSamples[gAudioCtx.numUsedSamples++] = sample; } } -void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relocInfo) { +void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, SampleBankRelocInfo* sampleBankReloc) { s32 numDrums; s32 numInstruments; s32 numSfx; Drum* drum; Instrument* instrument; - SoundFontSound* sound; + SoundEffect* soundEffect; AudioPreloadReq* preload; AudioPreloadReq* topPreload; u8* addr; size_t size; s32 i; - SoundFontSample* sample; + Sample* sample; s32 preloadInProgress; s32 nChunks; preloadInProgress = false; - if (gAudioContext.preloadSampleStackTop != 0) { + if (gAudioCtx.preloadSampleStackTop != 0) { preloadInProgress = true; } - gAudioContext.numUsedSamples = 0; + gAudioCtx.numUsedSamples = 0; - numDrums = gAudioContext.soundFonts[fontId].numDrums; - numInstruments = gAudioContext.soundFonts[fontId].numInstruments; - numSfx = gAudioContext.soundFonts[fontId].numSfx; + numDrums = gAudioCtx.soundFontList[fontId].numDrums; + numInstruments = gAudioCtx.soundFontList[fontId].numInstruments; + numSfx = gAudioCtx.soundFontList[fontId].numSfx; for (i = 0; i < numInstruments; i++) { instrument = AudioPlayback_GetInstrumentInner(fontId, i); if (instrument != NULL) { if (instrument->normalRangeLo != 0) { - AudioLoad_AddUsedSample(&instrument->lowNotesSound); + AudioLoad_AddUsedSample(&instrument->lowPitchTunedSample); } if (instrument->normalRangeHi != 0x7F) { - AudioLoad_AddUsedSample(&instrument->highNotesSound); + AudioLoad_AddUsedSample(&instrument->highPitchTunedSample); } - AudioLoad_AddUsedSample(&instrument->normalNotesSound); + AudioLoad_AddUsedSample(&instrument->normalPitchTunedSample); } } for (i = 0; i < numDrums; i++) { drum = AudioPlayback_GetDrum(fontId, i); if (drum != NULL) { - AudioLoad_AddUsedSample(&drum->sound); + AudioLoad_AddUsedSample(&drum->tunedSample); } } for (i = 0; i < numSfx; i++) { - sound = AudioPlayback_GetSfx(fontId, i); - if (sound != NULL) { - AudioLoad_AddUsedSample(sound); + soundEffect = AudioPlayback_GetSoundEffect(fontId, i); + if (soundEffect != NULL) { + AudioLoad_AddUsedSample(&soundEffect->tunedSample); } } - if (gAudioContext.numUsedSamples == 0) { + if (gAudioCtx.numUsedSamples == 0) { return; } size = 0; - for (i = 0; i < gAudioContext.numUsedSamples; i++) { - size += ALIGN16(gAudioContext.usedSamples[i]->size); + for (i = 0; i < gAudioCtx.numUsedSamples; i++) { + size += ALIGN16(gAudioCtx.usedSamples[i]->size); } if (size) {} - for (i = 0; i < gAudioContext.numUsedSamples; i++) { - if (gAudioContext.preloadSampleStackTop == 120) { + for (i = 0; i < gAudioCtx.numUsedSamples; i++) { + if (gAudioCtx.preloadSampleStackTop == 120) { break; } - sample = gAudioContext.usedSamples[i]; + sample = gAudioCtx.usedSamples[i]; if (sample->medium == MEDIUM_RAM) { continue; } switch (async) { case false: - if (sample->medium == relocInfo->medium1) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + if (sample->medium == sampleBankReloc->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); - } else if (sample->medium == relocInfo->medium2) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + } else if (sample->medium == sampleBankReloc->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_PERSISTENT); } break; case true: - if (sample->medium == relocInfo->medium1) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId1, sample->sampleAddr, + if (sample->medium == sampleBankReloc->medium1) { + addr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId1, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); - } else if (sample->medium == relocInfo->medium2) { - addr = AudioHeap_AllocSampleCache(sample->size, relocInfo->sampleBankId2, sample->sampleAddr, + } else if (sample->medium == sampleBankReloc->medium2) { + addr = AudioHeap_AllocSampleCache(sample->size, sampleBankReloc->sampleBankId2, sample->sampleAddr, sample->medium, CACHE_TEMPORARY); } break; @@ -2062,7 +2136,7 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relo case false: if (sample->medium == MEDIUM_UNK) { AudioLoad_SyncDmaUnkMedium((uintptr_t)sample->sampleAddr, addr, sample->size, - gAudioContext.sampleBankTable->unkMediumParam); + gAudioCtx.sampleBankTable->unkMediumParam); sample->sampleAddr = addr; sample->medium = MEDIUM_RAM; } else { @@ -2073,24 +2147,24 @@ void AudioLoad_PreloadSamplesForFont(s32 fontId, s32 async, AudioRelocInfo* relo break; case true: - preload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop]; + preload = &gAudioCtx.preloadSampleStack[gAudioCtx.preloadSampleStackTop]; preload->sample = sample; preload->ramAddr = addr; - preload->encodedInfo = (gAudioContext.preloadSampleStackTop << 24) | 0xFFFFFF; + preload->encodedInfo = (gAudioCtx.preloadSampleStackTop << 24) | 0xFFFFFF; preload->isFree = false; preload->endAndMediumKey = (uintptr_t)sample->sampleAddr + sample->size + sample->medium; - gAudioContext.preloadSampleStackTop++; + gAudioCtx.preloadSampleStackTop++; break; } } - gAudioContext.numUsedSamples = 0; + gAudioCtx.numUsedSamples = 0; - if (gAudioContext.preloadSampleStackTop != 0 && !preloadInProgress) { - topPreload = &gAudioContext.preloadSampleStack[gAudioContext.preloadSampleStackTop - 1]; + if (gAudioCtx.preloadSampleStackTop != 0 && !preloadInProgress) { + topPreload = &gAudioCtx.preloadSampleStack[gAudioCtx.preloadSampleStackTop - 1]; sample = topPreload->sample; nChunks = (sample->size >> 12) + 1; AudioLoad_StartAsyncLoad((uintptr_t)sample->sampleAddr, topPreload->ramAddr, sample->size, sample->medium, - nChunks, &gAudioContext.preloadSampleQueue, topPreload->encodedInfo); + nChunks, &gAudioCtx.preloadSampleQueue, topPreload->encodedInfo); } } @@ -2102,24 +2176,26 @@ void AudioLoad_LoadPermanentSamples(void) { s32 i; sampleBankTable = AudioLoad_GetLoadTable(SAMPLE_TABLE); - for (i = 0; i < gAudioContext.permanentPool.count; i++) { - AudioRelocInfo relocInfo; + for (i = 0; i < gAudioCtx.permanentPool.count; i++) { + SampleBankRelocInfo sampleBankReloc; - if (gAudioContext.permanentEntries[i].tableType == FONT_TABLE) { - fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioContext.permanentEntries[i].id); - relocInfo.sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1; - relocInfo.sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2; + if (gAudioCtx.permanentEntries[i].tableType == FONT_TABLE) { + fontId = AudioLoad_GetRealTableIndex(FONT_TABLE, gAudioCtx.permanentEntries[i].id); + sampleBankReloc.sampleBankId1 = gAudioCtx.soundFontList[fontId].sampleBankId1; + sampleBankReloc.sampleBankId2 = gAudioCtx.soundFontList[fontId].sampleBankId2; - if (relocInfo.sampleBankId1 != 0xFF) { - relocInfo.sampleBankId1 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId1); - relocInfo.medium1 = sampleBankTable->entries[relocInfo.sampleBankId1].medium; + if (sampleBankReloc.sampleBankId1 != 0xFF) { + sampleBankReloc.sampleBankId1 = + AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankReloc.sampleBankId1); + sampleBankReloc.medium1 = sampleBankTable->entries[sampleBankReloc.sampleBankId1].medium; } - if (relocInfo.sampleBankId2 != 0xFF) { - relocInfo.sampleBankId2 = AudioLoad_GetRealTableIndex(SAMPLE_TABLE, relocInfo.sampleBankId2); - relocInfo.medium2 = sampleBankTable->entries[relocInfo.sampleBankId2].medium; + if (sampleBankReloc.sampleBankId2 != 0xFF) { + sampleBankReloc.sampleBankId2 = + AudioLoad_GetRealTableIndex(SAMPLE_TABLE, sampleBankReloc.sampleBankId2); + sampleBankReloc.medium2 = sampleBankTable->entries[sampleBankReloc.sampleBankId2].medium; } - AudioLoad_PreloadSamplesForFont(fontId, false, &relocInfo); + AudioLoad_PreloadSamplesForFont(fontId, false, &sampleBankReloc); } } } diff --git a/src/code/audio/audio_playback.c b/src/code/audio/audio_playback.c index 6ae5696f1..9f3c6f8ed 100644 --- a/src/code/audio/audio_playback.c +++ b/src/code/audio/audio_playback.c @@ -1,56 +1,57 @@ #include "global.h" -void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput); +void AudioPlayback_NoteSetResamplingRate(NoteSampleState* sampleState, f32 resamplingRateInput); void AudioPlayback_AudioListPushFront(AudioListItem* list, AudioListItem* item); void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer); -void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) { - f32 volRight, volLeft; - s32 smallPanIndex; +void AudioPlayback_InitSampleState(Note* note, NoteSampleState* sampleState, NoteSubAttributes* subAttrs) { + f32 volLeft; + f32 volRight; + s32 halfPanIndex; u64 pad; u8 strongLeft; u8 strongRight; f32 vel; u8 pan; - u8 reverbVol; + u8 targetReverbVol; StereoData stereoData; s32 stereoHeadsetEffects = note->playbackState.stereoHeadsetEffects; - vel = attrs->velocity; - pan = attrs->pan; - reverbVol = attrs->reverbVol; - stereoData = attrs->stereo.s; + vel = subAttrs->velocity; + pan = subAttrs->pan; + targetReverbVol = subAttrs->targetReverbVol; + stereoData = subAttrs->stereoData; - sub->bitField0 = note->noteSubEu.bitField0; - sub->bitField1 = note->noteSubEu.bitField1; - sub->sound.samples = note->noteSubEu.sound.samples; - sub->unk_06 = note->noteSubEu.unk_06; + sampleState->bitField0 = note->sampleState.bitField0; + sampleState->bitField1 = note->sampleState.bitField1; + sampleState->waveSampleAddr = note->sampleState.waveSampleAddr; + sampleState->harmonicIndexCurAndPrev = note->sampleState.harmonicIndexCurAndPrev; - AudioPlayback_NoteSetResamplingRate(sub, attrs->frequency); + AudioPlayback_NoteSetResamplingRate(sampleState, subAttrs->frequency); pan &= 0x7F; - sub->bitField0.stereoStrongRight = false; - sub->bitField0.stereoStrongLeft = false; - sub->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects; - sub->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects; - if (stereoHeadsetEffects && gAudioContext.soundMode == AUDIO_MODE_HEADSET) { - smallPanIndex = pan >> 1; - if (smallPanIndex > 0x3F) { - smallPanIndex = 0x3F; + sampleState->bitField0.strongRight = false; + sampleState->bitField0.strongLeft = false; + sampleState->bitField0.strongReverbRight = stereoData.strongReverbRight; + sampleState->bitField0.strongReverbLeft = stereoData.strongReverbLeft; + if (stereoHeadsetEffects && (gAudioCtx.soundMode == SOUNDMODE_HEADSET)) { + halfPanIndex = pan >> 1; + if (halfPanIndex > 0x3F) { + halfPanIndex = 0x3F; } - sub->headsetPanLeft = gHeadsetPanQuantization[smallPanIndex]; - sub->headsetPanRight = gHeadsetPanQuantization[0x3F - smallPanIndex]; - sub->bitField1.usesHeadsetPanEffects2 = true; + sampleState->haasEffectRightDelaySize = gHaasEffectDelaySize[halfPanIndex]; + sampleState->haasEffectLeftDelaySize = gHaasEffectDelaySize[0x3F - halfPanIndex]; + sampleState->bitField1.useHaasEffect = true; volLeft = gHeadsetPanVolume[pan]; volRight = gHeadsetPanVolume[0x7F - pan]; - } else if (stereoHeadsetEffects && gAudioContext.soundMode == AUDIO_MODE_STEREO) { + } else if (stereoHeadsetEffects && (gAudioCtx.soundMode == SOUNDMODE_STEREO)) { strongLeft = strongRight = false; - sub->headsetPanRight = 0; - sub->headsetPanLeft = 0; - sub->bitField1.usesHeadsetPanEffects2 = false; + sampleState->haasEffectLeftDelaySize = 0; + sampleState->haasEffectRightDelaySize = 0; + sampleState->bitField1.useHaasEffect = false; volLeft = gStereoPanVolume[pan]; volRight = gStereoPanVolume[0x7F - pan]; @@ -60,34 +61,38 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at strongRight = true; } - sub->bitField0.stereoStrongRight = strongRight; - sub->bitField0.stereoStrongLeft = strongLeft; + // case 0: + sampleState->bitField0.strongRight = strongRight; + sampleState->bitField0.strongLeft = strongLeft; - switch (stereoData.bit2) { + switch (stereoData.type) { case 0: break; + case 1: - sub->bitField0.stereoStrongRight = stereoData.strongRight; - sub->bitField0.stereoStrongLeft = stereoData.strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft; break; + case 2: - sub->bitField0.stereoStrongRight = stereoData.strongRight | strongRight; - sub->bitField0.stereoStrongLeft = stereoData.strongLeft | strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight | strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft | strongLeft; break; + case 3: - sub->bitField0.stereoStrongRight = stereoData.strongRight ^ strongRight; - sub->bitField0.stereoStrongLeft = stereoData.strongLeft ^ strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight ^ strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft ^ strongLeft; break; } - } else if (gAudioContext.soundMode == AUDIO_MODE_MONO) { - sub->bitField0.stereoHeadsetEffects = false; - sub->bitField0.usesHeadsetPanEffects = false; + } else if (gAudioCtx.soundMode == SOUNDMODE_MONO) { + sampleState->bitField0.strongReverbRight = false; + sampleState->bitField0.strongReverbLeft = false; volLeft = 0.707f; // approx 1/sqrt(2) volRight = 0.707f; } else { - sub->bitField0.stereoStrongRight = stereoData.strongRight; - sub->bitField0.stereoStrongLeft = stereoData.strongLeft; + sampleState->bitField0.strongRight = stereoData.strongRight; + sampleState->bitField0.strongLeft = stereoData.strongLeft; volLeft = gDefaultPanVolume[pan]; volRight = gDefaultPanVolume[0x7F - pan]; } @@ -95,37 +100,37 @@ void AudioPlayback_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* at vel = 0.0f > vel ? 0.0f : vel; vel = 1.0f < vel ? 1.0f : vel; - sub->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); - sub->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); + sampleState->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f)); + sampleState->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f)); - sub->unk_2 = attrs->unk_1; - sub->filter = attrs->filter; - sub->unk_07 = attrs->unk_14; - sub->unk_0E = attrs->unk_16; - sub->reverbVol = reverbVol; - sub->unk_19 = attrs->unk_3; + sampleState->gain = subAttrs->gain; + sampleState->filter = subAttrs->filter; + sampleState->combFilterSize = subAttrs->combFilterSize; + sampleState->combFilterGain = subAttrs->combFilterGain; + sampleState->targetReverbVol = targetReverbVol; + sampleState->surroundEffectIndex = subAttrs->surroundEffectIndex; } -void AudioPlayback_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput) { +void AudioPlayback_NoteSetResamplingRate(NoteSampleState* sampleState, f32 resamplingRateInput) { f32 resamplingRate = 0.0f; if (resamplingRateInput < 2.0f) { - noteSubEu->bitField1.hasTwoParts = false; + sampleState->bitField1.hasTwoParts = false; resamplingRate = CLAMP_MAX(resamplingRateInput, 1.99998f); } else { - noteSubEu->bitField1.hasTwoParts = true; + sampleState->bitField1.hasTwoParts = true; if (resamplingRateInput > 3.99996f) { resamplingRate = 1.99998f; } else { resamplingRate = resamplingRateInput * 0.5f; } } - noteSubEu->resamplingRateFixedPoint = (s32)(resamplingRate * 32768.0f); + sampleState->frequencyFixedPoint = (s32)(resamplingRate * 32768.0f); } 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 { @@ -133,19 +138,19 @@ void AudioPlayback_NoteInit(Note* note) { ¬e->playbackState.adsrVolScaleUnused); } - note->playbackState.unk_04 = 0; + note->playbackState.status = PLAYBACK_STATUS_0; note->playbackState.adsr.action.s.state = ADSR_STATE_INITIAL; - note->noteSubEu = gDefaultNoteSub; + note->sampleState = gDefaultSampleState; } void AudioPlayback_NoteDisable(Note* note) { - if (note->noteSubEu.bitField0.needsInit == true) { - note->noteSubEu.bitField0.needsInit = false; + if (note->sampleState.bitField0.needsInit == true) { + note->sampleState.bitField0.needsInit = false; } note->playbackState.priority = 0; - note->noteSubEu.bitField0.enabled = false; - note->playbackState.unk_04 = 0; - note->noteSubEu.bitField0.finished = false; + note->sampleState.bitField0.enabled = false; + note->playbackState.status = PLAYBACK_STATUS_0; + note->sampleState.bitField0.finished = false; note->playbackState.parentLayer = NO_LAYER; note->playbackState.prevParentLayer = NO_LAYER; note->playbackState.adsr.action.s.state = ADSR_STATE_DISABLED; @@ -154,10 +159,10 @@ void AudioPlayback_NoteDisable(Note* note) { void AudioPlayback_ProcessNotes(void) { s32 pad; - s32 unk_04; + s32 playbackStatus; NoteAttributes* attrs; - NoteSubEu* noteSubEu2; - NoteSubEu* noteSubEu; + NoteSampleState* sampleState; + NoteSampleState* noteSampleState; Note* note; NotePlaybackState* playbackState; NoteSubAttributes subAttrs; @@ -165,31 +170,31 @@ void AudioPlayback_ProcessNotes(void) { f32 scale; s32 i; - for (i = 0; i < gAudioContext.numNotes; i++) { - note = &gAudioContext.notes[i]; - noteSubEu2 = &gAudioContext.noteSubsEu[gAudioContext.noteSubEuOffset + i]; + for (i = 0; i < gAudioCtx.numNotes; i++) { + note = &gAudioCtx.notes[i]; + sampleState = &gAudioCtx.sampleStateList[gAudioCtx.sampleStateOffset + i]; playbackState = ¬e->playbackState; if (playbackState->parentLayer != NO_LAYER) { if ((u32)playbackState->parentLayer < 0x7FFFFFFF) { continue; } - if (note != playbackState->parentLayer->note && playbackState->unk_04 == 0) { + if ((note != playbackState->parentLayer->note) && (playbackState->status == PLAYBACK_STATUS_0)) { playbackState->adsr.action.s.release = true; - playbackState->adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv; playbackState->priority = 1; - playbackState->unk_04 = 2; + playbackState->status = PLAYBACK_STATUS_2; goto out; - } else if (!playbackState->parentLayer->enabled && playbackState->unk_04 == 0 && - playbackState->priority >= 1) { + } else if (!playbackState->parentLayer->enabled && (playbackState->status == PLAYBACK_STATUS_0) && + (playbackState->priority >= 1)) { // do nothing } else if (playbackState->parentLayer->channel->seqPlayer == NULL) { AudioSeq_SequenceChannelDisable(playbackState->parentLayer->channel); playbackState->priority = 1; - playbackState->unk_04 = 1; + playbackState->status = PLAYBACK_STATUS_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; @@ -199,17 +204,19 @@ void AudioPlayback_ProcessNotes(void) { AudioPlayback_AudioListRemove(¬e->listItem); AudioPlayback_AudioListPushFront(¬e->listItem.pool->decaying, ¬e->listItem); playbackState->priority = 1; - playbackState->unk_04 = 2; - } else if (playbackState->unk_04 == 0 && playbackState->priority >= 1) { + playbackState->status = PLAYBACK_STATUS_2; + } else if ((playbackState->status == PLAYBACK_STATUS_0) && (playbackState->priority >= 1)) { continue; } out: if (playbackState->priority != 0) { + //! FAKE: if (1) {} - noteSubEu = ¬e->noteSubEu; - if (playbackState->unk_04 >= 1 || noteSubEu->bitField0.finished) { - if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED || noteSubEu->bitField0.finished) { + noteSampleState = ¬e->sampleState; + if ((playbackState->status >= 1) || noteSampleState->bitField0.finished) { + if ((playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) || + noteSampleState->bitField0.finished) { if (playbackState->wantedParentLayer != NO_LAYER) { AudioPlayback_NoteDisable(note); if (playbackState->wantedParentLayer->channel != NULL) { @@ -249,20 +256,20 @@ void AudioPlayback_ProcessNotes(void) { scale = AudioEffects_AdsrUpdate(&playbackState->adsr); AudioEffects_NoteVibratoUpdate(note); - unk_04 = playbackState->unk_04; + playbackStatus = playbackState->status; attrs = &playbackState->attributes; - if (unk_04 == 1 || unk_04 == 2) { + if ((playbackStatus == PLAYBACK_STATUS_1) || (playbackStatus == PLAYBACK_STATUS_2)) { subAttrs.frequency = attrs->freqScale; subAttrs.velocity = attrs->velocity; subAttrs.pan = attrs->pan; - subAttrs.reverbVol = attrs->reverb; - subAttrs.stereo = attrs->stereo; - subAttrs.unk_1 = attrs->unk_1; + subAttrs.targetReverbVol = attrs->targetReverbVol; + subAttrs.stereoData = attrs->stereoData; + subAttrs.gain = attrs->gain; subAttrs.filter = attrs->filter; - subAttrs.unk_14 = attrs->unk_4; - subAttrs.unk_16 = attrs->unk_6; - subAttrs.unk_3 = attrs->unk_3; - bookOffset = noteSubEu->bitField1.bookOffset; + subAttrs.combFilterSize = attrs->combFilterSize; + subAttrs.combFilterGain = attrs->combFilterGain; + subAttrs.surroundEffectIndex = attrs->surroundEffectIndex; + bookOffset = noteSampleState->bitField1.bookOffset; } else { SequenceLayer* layer = playbackState->parentLayer; SequenceChannel* channel = playbackState->parentLayer->channel; @@ -271,63 +278,65 @@ void AudioPlayback_ProcessNotes(void) { subAttrs.velocity = layer->noteVelocity; subAttrs.pan = layer->notePan; - if (layer->unk_08 == 0x80) { - subAttrs.unk_3 = channel->unk_10; + if (layer->surroundEffectIndex == 0x80) { + subAttrs.surroundEffectIndex = channel->surroundEffectIndex; } else { - subAttrs.unk_3 = layer->unk_08; + subAttrs.surroundEffectIndex = layer->surroundEffectIndex; } - if (layer->stereo.s.bit2 == 0) { - subAttrs.stereo = channel->stereo; + if (layer->stereoData.type == 0) { + subAttrs.stereoData = channel->stereoData; } else { - subAttrs.stereo = layer->stereo; + subAttrs.stereoData = layer->stereoData; } if (layer->unk_0A.s.bit_2 == 1) { - subAttrs.reverbVol = channel->reverb; + subAttrs.targetReverbVol = channel->targetReverbVol; } else { - subAttrs.reverbVol = layer->unk_09; + subAttrs.targetReverbVol = layer->targetReverbVol; } 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; + //! FAKE: if (1) {} } subAttrs.filter = channel->filter; - subAttrs.unk_14 = channel->unk_0F; - subAttrs.unk_16 = channel->unk_20; + subAttrs.combFilterSize = channel->combFilterSize; + subAttrs.combFilterGain = channel->combFilterGain; bookOffset = channel->bookOffset & 0x7; - if (channel->seqPlayer->muted && (channel->muteBehavior & 8)) { + if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_STOP_SAMPLES)) { subAttrs.frequency = 0.0f; subAttrs.velocity = 0.0f; } } subAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale; - subAttrs.frequency *= gAudioContext.audioBufferParameters.resampleRate; + subAttrs.frequency *= gAudioCtx.audioBufferParameters.resampleRate; subAttrs.velocity *= scale; - AudioPlayback_InitNoteSub(note, noteSubEu2, &subAttrs); - noteSubEu->bitField1.bookOffset = bookOffset; + AudioPlayback_InitSampleState(note, sampleState, &subAttrs); + noteSampleState->bitField1.bookOffset = bookOffset; skip:; } } } -SoundFontSound* AudioPlayback_InstrumentGetSound(Instrument* instrument, s32 semitone) { - SoundFontSound* sound; +TunedSample* AudioPlayback_GetInstrumentTunedSample(Instrument* instrument, s32 semitone) { + TunedSample* tunedSample; if (semitone < instrument->normalRangeLo) { - sound = &instrument->lowNotesSound; + tunedSample = &instrument->lowPitchTunedSample; } else if (semitone <= instrument->normalRangeHi) { - sound = &instrument->normalNotesSound; + tunedSample = &instrument->normalPitchTunedSample; } else { - sound = &instrument->highNotesSound; + tunedSample = &instrument->highPitchTunedSample; } - return sound; + + return tunedSample; } Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId) { @@ -338,18 +347,18 @@ Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId) { } if (!AudioLoad_IsFontLoadComplete(fontId)) { - gAudioContext.audioErrorFlags = fontId + 0x10000000; + gAudioCtx.audioErrorFlags = AUDIO_ERROR(0, fontId, AUDIO_ERROR_FONT_NOT_LOADED); return NULL; } - if (instId >= gAudioContext.soundFonts[fontId].numInstruments) { - gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x3000000; + if (instId >= gAudioCtx.soundFontList[fontId].numInstruments) { + gAudioCtx.audioErrorFlags = AUDIO_ERROR(fontId, instId, AUDIO_ERROR_INVALID_INST_ID); return NULL; } - inst = gAudioContext.soundFonts[fontId].instruments[instId]; + inst = gAudioCtx.soundFontList[fontId].instruments[instId]; if (inst == NULL) { - gAudioContext.audioErrorFlags = ((fontId << 8) + instId) + 0x1000000; + gAudioCtx.audioErrorFlags = AUDIO_ERROR(fontId, instId, AUDIO_ERROR_NO_INST); return inst; } @@ -364,58 +373,58 @@ Drum* AudioPlayback_GetDrum(s32 fontId, s32 drumId) { } if (!AudioLoad_IsFontLoadComplete(fontId)) { - gAudioContext.audioErrorFlags = fontId + 0x10000000; + gAudioCtx.audioErrorFlags = AUDIO_ERROR(0, fontId, AUDIO_ERROR_FONT_NOT_LOADED); return NULL; } - if (drumId >= gAudioContext.soundFonts[fontId].numDrums) { - gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x4000000; + if (drumId >= gAudioCtx.soundFontList[fontId].numDrums) { + gAudioCtx.audioErrorFlags = AUDIO_ERROR(fontId, drumId, AUDIO_ERROR_INVALID_DRUM_SFX_ID); return NULL; } - if ((u32)gAudioContext.soundFonts[fontId].drums < 0x80000000) { + if ((u32)gAudioCtx.soundFontList[fontId].drums < AUDIO_RELOCATED_ADDRESS_START) { return NULL; } - drum = gAudioContext.soundFonts[fontId].drums[drumId]; + drum = gAudioCtx.soundFontList[fontId].drums[drumId]; if (drum == NULL) { - gAudioContext.audioErrorFlags = ((fontId << 8) + drumId) + 0x5000000; + gAudioCtx.audioErrorFlags = AUDIO_ERROR(fontId, drumId, AUDIO_ERROR_NO_DRUM_SFX); } return drum; } -SoundFontSound* AudioPlayback_GetSfx(s32 fontId, s32 sfxId) { - SoundFontSound* sfx; +SoundEffect* AudioPlayback_GetSoundEffect(s32 fontId, s32 sfxId) { + SoundEffect* soundEffect; if (fontId == 0xFF) { return NULL; } if (!AudioLoad_IsFontLoadComplete(fontId)) { - gAudioContext.audioErrorFlags = fontId + 0x10000000; + gAudioCtx.audioErrorFlags = AUDIO_ERROR(0, fontId, AUDIO_ERROR_FONT_NOT_LOADED); return NULL; } - if (sfxId >= gAudioContext.soundFonts[fontId].numSfx) { - gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x4000000; + if (sfxId >= gAudioCtx.soundFontList[fontId].numSfx) { + gAudioCtx.audioErrorFlags = AUDIO_ERROR(fontId, sfxId, AUDIO_ERROR_INVALID_DRUM_SFX_ID); return NULL; } - if ((u32)gAudioContext.soundFonts[fontId].soundEffects < 0x80000000) { + if ((u32)gAudioCtx.soundFontList[fontId].soundEffects < AUDIO_RELOCATED_ADDRESS_START) { return NULL; } - sfx = &gAudioContext.soundFonts[fontId].soundEffects[sfxId]; + soundEffect = &gAudioCtx.soundFontList[fontId].soundEffects[sfxId]; - if (sfx == NULL) { - gAudioContext.audioErrorFlags = ((fontId << 8) + sfxId) + 0x5000000; + if (soundEffect == NULL) { + gAudioCtx.audioErrorFlags = AUDIO_ERROR(fontId, sfxId, AUDIO_ERROR_NO_DRUM_SFX); } - if (sfx->sample == NULL) { + if (soundEffect->tunedSample.sample == NULL) { return NULL; } - return sfx; + return soundEffect; } s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value) { @@ -429,24 +438,24 @@ s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, v switch (instrumentType) { case 0: - if (index >= gAudioContext.soundFonts[fontId].numDrums) { + if (index >= gAudioCtx.soundFontList[fontId].numDrums) { return -3; } - gAudioContext.soundFonts[fontId].drums[index] = value; + gAudioCtx.soundFontList[fontId].drums[index] = value; break; case 1: - if (index >= gAudioContext.soundFonts[fontId].numSfx) { + if (index >= gAudioCtx.soundFontList[fontId].numSfx) { return -3; } - gAudioContext.soundFonts[fontId].soundEffects[index] = *(SoundFontSound*)value; + gAudioCtx.soundFontList[fontId].soundEffects[index] = *(SoundEffect*)value; break; default: - if (index >= gAudioContext.soundFonts[fontId].numInstruments) { + if (index >= gAudioCtx.soundFontList[fontId].numInstruments) { return -3; } - gAudioContext.soundFonts[fontId].instruments[index] = value; + gAudioCtx.soundFontList[fontId].instruments[index] = value; break; } @@ -456,7 +465,7 @@ s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, v void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { Note* note; NoteAttributes* attrs; - SequenceChannel* chan; + SequenceChannel* channel; s32 i; if (layer == NO_LAYER) { @@ -479,7 +488,7 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { if (note->playbackState.parentLayer != layer) { if (note->playbackState.parentLayer == NO_LAYER && note->playbackState.wantedParentLayer == NO_LAYER && note->playbackState.prevParentLayer == layer && target != ADSR_STATE_DECAY) { - note->playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv; note->playbackState.adsr.action.s.release = true; } return; @@ -491,27 +500,27 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { attrs->pan = layer->notePan; if (layer->channel != NULL) { - chan = layer->channel; + channel = layer->channel; if (layer->unk_0A.s.bit_2 == 1) { - attrs->reverb = chan->reverb; + attrs->targetReverbVol = channel->targetReverbVol; } else { - attrs->reverb = layer->unk_09; + attrs->targetReverbVol = layer->targetReverbVol; } - if (layer->unk_08 == 0x80) { - attrs->unk_3 = chan->unk_10; + if (layer->surroundEffectIndex == 0x80) { + attrs->surroundEffectIndex = channel->surroundEffectIndex; } else { - attrs->unk_3 = layer->unk_08; + attrs->surroundEffectIndex = layer->surroundEffectIndex; } if (layer->unk_0A.s.bit_9 == 1) { - attrs->unk_1 = chan->unk_0C; + attrs->gain = channel->gain; } else { - attrs->unk_1 = 0; + attrs->gain = 0; } - attrs->filter = chan->filter; + attrs->filter = channel->filter; if (attrs->filter != NULL) { for (i = 0; i < 8; i++) { @@ -520,36 +529,36 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) { attrs->filter = attrs->filterBuf; } - attrs->unk_6 = chan->unk_20; - attrs->unk_4 = chan->unk_0F; - if (chan->seqPlayer->muted && (chan->muteBehavior & 8)) { - note->noteSubEu.bitField0.finished = true; + attrs->combFilterGain = channel->combFilterGain; + attrs->combFilterSize = channel->combFilterSize; + if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_STOP_SAMPLES)) { + note->sampleState.bitField0.finished = true; } - if (layer->stereo.asByte == 0) { - attrs->stereo = chan->stereo; + if (layer->stereoData.asByte == 0) { + attrs->stereoData = channel->stereoData; } else { - attrs->stereo = layer->stereo; + attrs->stereoData = layer->stereoData; } - note->playbackState.priority = chan->someOtherPriority; + note->playbackState.priority = channel->someOtherPriority; } else { - attrs->stereo = layer->stereo; + attrs->stereoData = layer->stereoData; note->playbackState.priority = 1; } note->playbackState.prevParentLayer = note->playbackState.parentLayer; note->playbackState.parentLayer = NO_LAYER; if (target == ADSR_STATE_RELEASE) { - note->playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv; note->playbackState.adsr.action.s.release = true; - note->playbackState.unk_04 = 2; + note->playbackState.status = PLAYBACK_STATUS_2; } else { - note->playbackState.unk_04 = 1; + note->playbackState.status = PLAYBACK_STATUS_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 = gAudioCtx.adsrDecayTable[layer->channel->adsr.decayIndex]; } else { - note->playbackState.adsr.fadeOutVel = gAudioContext.unk_3520[layer->adsr.releaseRate]; + note->playbackState.adsr.fadeOutVel = gAudioCtx.adsrDecayTable[layer->adsr.decayIndex]; } note->playbackState.adsr.sustain = ((f32)(s32)(layer->channel->adsr.sustain) * note->playbackState.adsr.current) / 256.0f; @@ -570,10 +579,18 @@ void AudioPlayback_SeqLayerNoteRelease(SequenceLayer* layer) { AudioPlayback_SeqLayerDecayRelease(layer, ADSR_STATE_RELEASE); } +/** + * Extract the synthetic wave to use from gWaveSamples and update corresponding frequencies + * + * @param note + * @param layer + * @param waveId the index of the type of synthetic wave to use, offset by 128 + * @return harmonicIndex, the index of the harmonic for the synthetic wave contained in gWaveSamples + */ s32 AudioPlayback_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveId) { f32 freqScale; - f32 ratio; - u8 sampleCountIndex; + f32 freqRatio; + u8 harmonicIndex; if (waveId < 128) { waveId = 128; @@ -583,42 +600,48 @@ s32 AudioPlayback_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveI if (layer->portamento.mode != 0 && 0.0f < layer->portamento.extent) { freqScale *= (layer->portamento.extent + 1.0f); } + + // Map frequency to the harmonic to use from gWaveSamples if (freqScale < 0.99999f) { - sampleCountIndex = 0; - ratio = 1.0465f; + harmonicIndex = 0; + freqRatio = 1.0465f; } else if (freqScale < 1.99999f) { - sampleCountIndex = 1; - ratio = 0.52325f; + harmonicIndex = 1; + freqRatio = 1.0465f / 2; } else if (freqScale < 3.99999f) { - sampleCountIndex = 2; - ratio = 0.26263f; + harmonicIndex = 2; + freqRatio = 1.0465f / 4 + 1.005E-3; } else { - sampleCountIndex = 3; - ratio = 0.13081f; + harmonicIndex = 3; + freqRatio = 1.0465f / 8 - 2.5E-6; } - layer->freqScale *= ratio; + + // Update results + layer->freqScale *= freqRatio; note->playbackState.waveId = waveId; - note->playbackState.sampleCountIndex = sampleCountIndex; + note->playbackState.harmonicIndex = harmonicIndex; - note->noteSubEu.sound.samples = &gWaveSamples[waveId - 128][sampleCountIndex * 64]; + // Save the pointer to the synthethic wave + // waveId index starts at 128, there are WAVE_SAMPLE_COUNT samples to read from + note->sampleState.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * WAVE_SAMPLE_COUNT]; - return sampleCountIndex; + return harmonicIndex; } void AudioPlayback_InitSyntheticWave(Note* note, SequenceLayer* layer) { - s32 sampleCountIndex; - s32 waveSampleCountIndex; + s32 prevHarmonicIndex; + s32 curHarmonicIndex; s32 waveId = layer->instOrWave; if (waveId == 0xFF) { waveId = layer->channel->instOrWave; } - sampleCountIndex = note->playbackState.sampleCountIndex; - waveSampleCountIndex = AudioPlayback_BuildSyntheticWave(note, layer, waveId); + prevHarmonicIndex = note->playbackState.harmonicIndex; + curHarmonicIndex = AudioPlayback_BuildSyntheticWave(note, layer, waveId); - if (waveSampleCountIndex != sampleCountIndex) { - note->noteSubEu.unk_06 = waveSampleCountIndex * 4 + sampleCountIndex; + if (curHarmonicIndex != prevHarmonicIndex) { + note->sampleState.harmonicIndexCurAndPrev = (curHarmonicIndex << 2) + prevHarmonicIndex; } } @@ -642,11 +665,11 @@ void AudioPlayback_InitNoteLists(NotePool* pool) { void AudioPlayback_InitNoteFreeList(void) { s32 i; - AudioPlayback_InitNoteLists(&gAudioContext.noteFreeLists); - for (i = 0; i < gAudioContext.numNotes; i++) { - gAudioContext.notes[i].listItem.u.value = &gAudioContext.notes[i]; - gAudioContext.notes[i].listItem.prev = NULL; - AudioSeq_AudioListPushBack(&gAudioContext.noteFreeLists.disabled, &gAudioContext.notes[i].listItem); + AudioPlayback_InitNoteLists(&gAudioCtx.noteFreeLists); + for (i = 0; i < gAudioCtx.numNotes; i++) { + gAudioCtx.notes[i].listItem.u.value = &gAudioCtx.notes[i]; + gAudioCtx.notes[i].listItem.prev = NULL; + AudioSeq_AudioListPushBack(&gAudioCtx.noteFreeLists.disabled, &gAudioCtx.notes[i].listItem); } } @@ -660,22 +683,22 @@ void AudioPlayback_NotePoolClear(NotePool* pool) { switch (i) { case 0: source = &pool->disabled; - dest = &gAudioContext.noteFreeLists.disabled; + dest = &gAudioCtx.noteFreeLists.disabled; break; case 1: source = &pool->decaying; - dest = &gAudioContext.noteFreeLists.decaying; + dest = &gAudioCtx.noteFreeLists.decaying; break; case 2: source = &pool->releasing; - dest = &gAudioContext.noteFreeLists.releasing; + dest = &gAudioCtx.noteFreeLists.releasing; break; case 3: source = &pool->active; - dest = &gAudioContext.noteFreeLists.active; + dest = &gAudioCtx.noteFreeLists.active; break; } @@ -706,22 +729,22 @@ void AudioPlayback_NotePoolFill(NotePool* pool, s32 count) { switch (i) { case 0: - source = &gAudioContext.noteFreeLists.disabled; + source = &gAudioCtx.noteFreeLists.disabled; dest = &pool->disabled; break; case 1: - source = &gAudioContext.noteFreeLists.decaying; + source = &gAudioCtx.noteFreeLists.decaying; dest = &pool->decaying; break; case 2: - source = &gAudioContext.noteFreeLists.releasing; + source = &gAudioCtx.noteFreeLists.releasing; dest = &pool->releasing; break; case 3: - source = &gAudioContext.noteFreeLists.active; + source = &gAudioCtx.noteFreeLists.active; dest = &pool->active; break; } @@ -788,7 +811,7 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { s16 instId; SequenceChannel* channel = layer->channel; NotePlaybackState* playbackState = ¬e->playbackState; - NoteSubEu* noteSubEu = ¬e->noteSubEu; + NoteSampleState* noteSampleState = ¬e->sampleState; playbackState->prevParentLayer = NO_LAYER; playbackState->parentLayer = layer; @@ -805,28 +828,28 @@ void AudioPlayback_NoteInitForLayer(Note* note, SequenceLayer* layer) { if (instId == 0xFF) { instId = channel->instOrWave; } - noteSubEu->sound.soundFontSound = layer->sound; + noteSampleState->tunedSample = layer->tunedSample; if (instId >= 0x80 && instId < 0xC0) { - noteSubEu->bitField1.isSyntheticWave = true; + noteSampleState->bitField1.isSyntheticWave = true; } else { - noteSubEu->bitField1.isSyntheticWave = false; + noteSampleState->bitField1.isSyntheticWave = false; } - if (noteSubEu->bitField1.isSyntheticWave) { + if (noteSampleState->bitField1.isSyntheticWave) { AudioPlayback_BuildSyntheticWave(note, layer, instId); - } else if (channel->unk_DC == 1) { - playbackState->unk_84 = noteSubEu->sound.soundFontSound->sample->loop->start; + } else if (channel->startSamplePos == 1) { + playbackState->startSamplePos = noteSampleState->tunedSample->sample->loop->start; } else { - playbackState->unk_84 = channel->unk_DC; - if (playbackState->unk_84 >= noteSubEu->sound.soundFontSound->sample->loop->end) { - playbackState->unk_84 = 0; + playbackState->startSamplePos = channel->startSamplePos; + if (playbackState->startSamplePos >= noteSampleState->tunedSample->sample->loop->loopEnd) { + playbackState->startSamplePos = 0; } } playbackState->fontId = channel->fontId; playbackState->stereoHeadsetEffects = channel->stereoHeadsetEffects; - noteSubEu->bitField1.reverbIndex = channel->reverbIndex & 3; + noteSampleState->bitField1.reverbIndex = channel->reverbIndex & 3; } void func_801963E8(Note* note, SequenceLayer* layer) { @@ -839,7 +862,7 @@ void AudioPlayback_NoteReleaseAndTakeOwnership(Note* note, SequenceLayer* layer) note->playbackState.wantedParentLayer = layer; note->playbackState.priority = layer->channel->notePriority; - note->playbackState.adsr.fadeOutVel = gAudioContext.audioBufferParameters.updatesPerFrameInv; + note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv; note->playbackState.adsr.action.s.release = true; } @@ -935,9 +958,9 @@ Note* AudioPlayback_AllocNote(SequenceLayer* layer) { } if (policy & 8) { - if (!(note = AudioPlayback_AllocNoteFromDisabled(&gAudioContext.noteFreeLists, layer)) && - !(note = AudioPlayback_AllocNoteFromDecaying(&gAudioContext.noteFreeLists, layer)) && - !(note = AudioPlayback_AllocNoteFromActive(&gAudioContext.noteFreeLists, layer))) { + if (!(note = AudioPlayback_AllocNoteFromDisabled(&gAudioCtx.noteFreeLists, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&gAudioCtx.noteFreeLists, layer)) && + !(note = AudioPlayback_AllocNoteFromActive(&gAudioCtx.noteFreeLists, layer))) { goto null_return; } return note; @@ -945,13 +968,13 @@ Note* AudioPlayback_AllocNote(SequenceLayer* layer) { if (!(note = AudioPlayback_AllocNoteFromDisabled(&layer->channel->notePool, layer)) && !(note = AudioPlayback_AllocNoteFromDisabled(&layer->channel->seqPlayer->notePool, layer)) && - !(note = AudioPlayback_AllocNoteFromDisabled(&gAudioContext.noteFreeLists, layer)) && + !(note = AudioPlayback_AllocNoteFromDisabled(&gAudioCtx.noteFreeLists, layer)) && !(note = AudioPlayback_AllocNoteFromDecaying(&layer->channel->notePool, layer)) && !(note = AudioPlayback_AllocNoteFromDecaying(&layer->channel->seqPlayer->notePool, layer)) && - !(note = AudioPlayback_AllocNoteFromDecaying(&gAudioContext.noteFreeLists, layer)) && + !(note = AudioPlayback_AllocNoteFromDecaying(&gAudioCtx.noteFreeLists, layer)) && !(note = AudioPlayback_AllocNoteFromActive(&layer->channel->notePool, layer)) && !(note = AudioPlayback_AllocNoteFromActive(&layer->channel->seqPlayer->notePool, layer)) && - !(note = AudioPlayback_AllocNoteFromActive(&gAudioContext.noteFreeLists, layer))) { + !(note = AudioPlayback_AllocNoteFromActive(&gAudioCtx.noteFreeLists, layer))) { goto null_return; } return note; @@ -965,11 +988,11 @@ void AudioPlayback_NoteInitAll(void) { Note* note; s32 i; - for (i = 0; i < gAudioContext.numNotes; i++) { - note = &gAudioContext.notes[i]; - note->noteSubEu = gZeroNoteSub; + for (i = 0; i < gAudioCtx.numNotes; i++) { + note = &gAudioCtx.notes[i]; + note->sampleState = gZeroedSampleState; note->playbackState.priority = 0; - note->playbackState.unk_04 = 0; + note->playbackState.status = PLAYBACK_STATUS_0; note->playbackState.parentLayer = NO_LAYER; note->playbackState.wantedParentLayer = NO_LAYER; note->playbackState.prevParentLayer = NO_LAYER; @@ -981,8 +1004,9 @@ void AudioPlayback_NoteInitAll(void) { note->playbackState.portamento.cur = 0; note->playbackState.portamento.speed = 0; note->playbackState.stereoHeadsetEffects = false; - note->playbackState.unk_84 = 0; - note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x2E0); - note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x10); + note->playbackState.startSamplePos = 0; + note->synthesisState.synthesisBuffers = + AudioHeap_AllocDmaMemory(&gAudioCtx.miscPool, sizeof(NoteSynthesisBuffers)); + note->playbackState.attributes.filterBuf = AudioHeap_AllocDmaMemory(&gAudioCtx.miscPool, FILTER_SIZE); } } diff --git a/src/code/audio/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c index e57ad19b5..a8c54420a 100644 --- a/src/code/audio/audio_seqplayer.c +++ b/src/code/audio/audio_seqplayer.c @@ -1,73 +1,2313 @@ +/** + * @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 sameTunedSample); +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 depth) + 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 depth 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 == &gAudioCtx.sequenceChannelNone) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80198CE0.s") + channel->enabled = false; + channel->finished = false; + channel->stopScript = false; + channel->muted = false; + channel->hasInstrument = false; + channel->stereoHeadsetEffects = false; + channel->transposition = 0; + channel->largeNotes = false; + channel->bookOffset = 0; + channel->stereoData.asByte = 0; + channel->changes.asByte = 0xFF; + channel->scriptState.depth = 0; + channel->newPan = 0x40; + channel->panChannelWeight = 0x80; + channel->surroundEffectIndex = 0xFF; + channel->velocityRandomVariance = 0; + channel->gateTimeRandomVariance = 0; + channel->noteUnused = NULL; + channel->reverbIndex = 0; + channel->targetReverbVol = 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.vibratoDepthTarget = 0; + channel->vibrato.vibratoDepthStart = 0; + channel->vibrato.vibratoRateChangeDelay = 0; + channel->vibrato.vibratoDepthChangeDelay = 0; + channel->vibrato.vibratoDelay = 0; + channel->filter = NULL; + channel->combFilterGain = 0; + channel->combFilterSize = 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->seqScriptIO); i++) { + channel->seqScriptIO[i] = SEQ_IO_VAL_NONE; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_80199124.s") + channel->unused = false; + AudioPlayback_InitNoteLists(&channel->notePool); + channel->startSamplePos = 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(&gAudioCtx.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->targetReverbVol = channel->targetReverbVol; + layer->enabled = true; + layer->finished = false; + layer->muted = false; + layer->continuousNotes = false; + layer->bit3 = false; + layer->ignoreDrumPan = false; + layer->bit1 = false; + layer->notePropertiesNeedInit = false; + layer->gateTime = 0x80; + layer->surroundEffectIndex = 0x80; + layer->stereoData.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.vibratoDepthTarget = 0; + layer->vibrato.vibratoDepthStart = 0; + layer->vibrato.vibratoRateChangeDelay = 0; + layer->vibrato.vibratoDepthChangeDelay = 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 != &gAudioCtx.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(&gAudioCtx.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 == gAudioCtx.fontCache.temporary.entries[0].id) { + gAudioCtx.fontCache.temporary.nextSide = 1; + } else if (seqPlayer->defaultFont == gAudioCtx.fontCache.temporary.entries[1].id) { + gAudioCtx.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; + + gAudioCtx.layerFreeList.prev = &gAudioCtx.layerFreeList; + gAudioCtx.layerFreeList.next = &gAudioCtx.layerFreeList; + gAudioCtx.layerFreeList.u.count = 0; + gAudioCtx.layerFreeList.pool = NULL; + + for (i = 0; i < ARRAY_COUNT(gAudioCtx.sequenceLayers); i++) { + gAudioCtx.sequenceLayers[i].listItem.u.value = &gAudioCtx.sequenceLayers[i]; + gAudioCtx.sequenceLayers[i].listItem.prev = NULL; + AudioSeq_AudioListPushBack(&gAudioCtx.layerFreeList, &gAudioCtx.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->muted && (layer->delay <= layer->gateDelay)) { + AudioPlayback_SeqLayerNoteDecay(layer); + layer->muted = 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 `sameTunedSample` instead of a command + cmd = AudioSeq_SeqLayerProcessScriptStep4(layer, cmd); + } + + if (cmd != PROCESS_SCRIPT_END) { + AudioSeq_SeqLayerProcessScriptStep5(layer, cmd); + } + + if (layer->muted == 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 sameTunedSample) { + Note* note; + + if ((layer->continuousNotes == true) && (layer->bit1 == true)) { + return 0; + } + + if ((layer->continuousNotes == true) && (layer->note != NULL) && layer->bit3 && (sameTunedSample == true) && + (layer->note->playbackState.parentLayer == layer)) { + if (layer->tunedSample == NULL) { + AudioPlayback_InitSyntheticWave(layer->note, layer); + } + } else { + if (!sameTunedSample) { + 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->stereoData.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->surroundEffectIndex = 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 sameTunedSample = true; + s32 instOrWave; + s32 speed; + f32 temp_f14; + f32 temp_f2; + Portamento* portamento; + f32 freqScale; + f32 freqScale2; + TunedSample* tunedSample; + Instrument* instrument; + Drum* drum; + SoundEffect* soundEffect; + 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->muted = true; + layer->delay2 = layer->delay; + return PROCESS_SCRIPT_END; + } + + tunedSample = &drum->tunedSample; + layer->adsr.envelope = drum->envelope; + layer->adsr.decayIndex = drum->adsrDecayIndex; + if (!layer->ignoreDrumPan) { + layer->pan = drum->pan; + } + + layer->tunedSample = tunedSample; + layer->freqScale = tunedSample->tuning; + break; + + case 1: + // Sfxs + layer->semitone = semitone; + sfxId = (layer->transposition << 6) + semitone; + + soundEffect = AudioPlayback_GetSoundEffect(channel->fontId, sfxId); + if (soundEffect == NULL) { + layer->muted = true; + layer->delay2 = layer->delay + 1; + return PROCESS_SCRIPT_END; + } + + tunedSample = &soundEffect->tunedSample; + layer->tunedSample = tunedSample; + layer->freqScale = tunedSample->tuning; + break; + + default: + semitone += seqPlayer->transposition + channel->transposition + layer->transposition; + semitone2 = semitone; + + layer->semitone = semitone; + if (semitone >= 0x80) { + layer->muted = 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) { + tunedSample = AudioPlayback_GetInstrumentTunedSample(instrument, vel); + sameTunedSample = (layer->tunedSample == tunedSample); + layer->tunedSample = tunedSample; + tuning = tunedSample->tuning; + } else { + layer->tunedSample = NULL; + tuning = 1.0f; + if (instOrWave >= 0xC0) { + layer->tunedSample = &gAudioCtx.synthesisReverbs[instOrWave - 0xC0].tunedSample; + } + } + + 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 / gAudioCtx.maxTempo; + if (layer->delay != 0) { + speed = speed * 0x100 / (layer->delay * layer->portamentoTime); + } + } else { + speed = 0x20000 / (layer->portamentoTime * gAudioCtx.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) { + tunedSample = AudioPlayback_GetInstrumentTunedSample(instrument, semitone); + sameTunedSample = (tunedSample == layer->tunedSample); + layer->tunedSample = tunedSample; + layer->freqScale = gPitchFrequencies[semitone2] * tunedSample->tuning; + } else { + layer->tunedSample = NULL; + layer->freqScale = gPitchFrequencies[semitone2]; + if (instOrWave >= 0xC0) { + layer->tunedSample = &gAudioCtx.synthesisReverbs[instOrWave - 0xC0].tunedSample; + } + } + break; + } + + layer->delay2 = layer->delay; + layer->freqScale *= layer->bend; + + if (layer->delay == 0) { + if (layer->tunedSample != NULL) { + time = layer->tunedSample->sample->loop->loopEnd; + } else { + time = 0.0f; + } + time *= seqPlayer->tempo; + time *= gAudioCtx.unk_2870; + time /= layer->freqScale; + //! FAKE: + 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 / gAudioCtx.maxTempo; + speed2 = speed2 * 0x100 / (layer->delay * layer->portamentoTime); + if (speed2 >= 0x7FFF) { + speed2 = 0x7FFF; + } else if (speed2 < 1) { + speed2 = 1; + } + portamento->speed = speed2; + } + } + } + return sameTunedSample; +} + +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->muted = true; + layer->bit1 = false; + return PROCESS_SCRIPT_END; + } + + layer->muted = 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 * (gAudioCtx.audioRandom % channel->velocityRandomVariance) / 100.0f; + if ((gAudioCtx.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 * (gAudioCtx.audioRandom % channel->velocityRandomVariance)) / 100; + if ((gAudioCtx.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_STOP_LAYER))) || + channel->muted) { + layer->muted = true; + return PROCESS_SCRIPT_END; + } + + if (seqPlayer->skipTicks != 0) { + layer->muted = 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*)gAudioCtx.sequenceFontTable)[seqPlayer->seqId]; + lowBits = gAudioCtx.sequenceFontTable[cmdArgU16]; + cmd = gAudioCtx.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 depth + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoDepthTarget = cmd * 8; + channel->vibrato.vibratoDepthStart = 0; + channel->vibrato.vibratoDepthChangeDelay = 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 depth linear + cmd = (u8)cmdArgs[0]; + channel->vibrato.vibratoDepthStart = cmd * 8; + cmd = (u8)cmdArgs[1]; + channel->vibrato.vibratoDepthTarget = cmd * 8; + cmd = (u8)cmdArgs[2]; + channel->vibrato.vibratoDepthChangeDelay = 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 volume + cmd = (u8)cmdArgs[0]; + channel->targetReverbVol = cmd; + break; + + case 0xC6: // channel: set soundFont + cmd = (u8)cmdArgs[0]; + + if (seqPlayer->defaultFont != 0xFF) { + cmdArgU16 = ((u16*)gAudioCtx.sequenceFontTable)[seqPlayer->seqId]; + lowBits = gAudioCtx.sequenceFontTable[cmdArgU16]; + cmd = gAudioCtx.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->stereoData.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->targetReverbVol = 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->targetReverbVol = 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.vibratoDepthTarget = 0; + channel->vibrato.vibratoDepthStart = 0; + channel->vibrato.vibratoDepthChangeDelay = 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->combFilterSize = 0; + channel->combFilterGain = 0; + channel->bookOffset = 0; + channel->startSamplePos = 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) ? (gAudioCtx.audioRandom & 0xFFFF) : (gAudioCtx.audioRandom % cmdArgs[0]); + break; + + case 0xB8: // channel: random value + scriptState->value = + (cmdArgs[0] == 0) ? (gAudioCtx.audioRandom & 0xFFFF) : (gAudioCtx.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->combFilterSize = cmdArgs[0]; + channel->combFilterGain = cmdArgs[1]; + break; + + case 0xBC: // channel: add large + channel->unk_22 += cmdArgs[0]; + break; + + case 0xBD: // channel: + channel->startSamplePos = cmdArgs[0]; + break; + + case 0xBE: // channel: + if (cmdArgs[0] < 5) { + if (1) {} + if (gAudioCtx.customSeqFunctions[cmdArgs[0]] != NULL) { + gAudioCustomSeqFunction = gAudioCtx.customSeqFunctions[cmdArgs[0]]; + scriptState->value = gAudioCustomSeqFunction(scriptState->value, channel); + } + } + break; + + case 0xA0: // channel: read from SfxChannelState using arg + case 0xA1: // channel: read from SfxChannelState using unk_22 + case 0xA2: // channel: write to SfxChannelState using arg + case 0xA3: // channel: write to SfxChannelState using unk_22 + 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->surroundEffectIndex = cmdArgs[0]; + break; + + case 0xA5: // channel: + scriptState->value += channel->channelIndex; + break; + + case 0xA6: // channel: + cmd = (u8)cmdArgs[0]; + cmdArgU16 = (u16)cmdArgs[1]; + seqData = seqPlayer->seqData + (u32)(cmdArgU16 + channel->channelIndex); + 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->seqScriptIO[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->seqScriptIO[lowBits] = SEQ_IO_VAL_NONE; + if (AudioLoad_SlowLoadSample(channel->fontId, scriptState->value, &channel->seqScriptIO[lowBits]) == + -1) {} + } else { + lowBits -= 8; + channel->seqScriptIO[lowBits] = SEQ_IO_VAL_NONE; + if (AudioLoad_SlowLoadSample(channel->fontId, channel->unk_22 + 0x100, + &channel->seqScriptIO[lowBits]) == -1) {} + } + break; + + case 0x60: // channel: io read value + scriptState->value = channel->seqScriptIO[lowBits]; + if (lowBits < 2) { + channel->seqScriptIO[lowBits] = SEQ_IO_VAL_NONE; + } + break; + + case 0x50: // channel: io read value subtract + scriptState->value -= channel->seqScriptIO[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]->seqScriptIO[cmd] = scriptState->value; + break; + + case 0x40: // channel: io read value 2 + cmd = AudioSeq_ScriptReadU8(scriptState); + scriptState->value = seqPlayer->channels[lowBits]->seqScriptIO[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->tempoChange; + if (tempoChange > gAudioCtx.maxTempo) { + tempoChange = gAudioCtx.maxTempo; + } + + seqPlayer->tempoAcc += tempoChange; + + if (seqPlayer->tempoAcc < gAudioCtx.maxTempo) { + return; + } + + seqPlayer->tempoAcc -= (u16)gAudioCtx.maxTempo; + 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 > gAudioCtx.maxTempo) { + seqPlayer->tempo = gAudioCtx.maxTempo; + } + + if ((s16)seqPlayer->tempo <= 0) { + seqPlayer->tempo = 1; + } + break; + + case 0xDC: // seqPlayer: add tempo + seqPlayer->tempoChange = (s8)AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT; + break; + + case 0xDA: // seqPlayer: change volume + cmd = AudioSeq_ScriptReadU8(seqScript); + temp = AudioSeq_ScriptReadS16(seqScript); + switch (cmd) { + case SEQPLAYER_STATE_0: + case SEQPLAYER_STATE_FADE_IN: + if (seqPlayer->state != SEQPLAYER_STATE_FADE_OUT) { + seqPlayer->storedFadeTimer = temp; + seqPlayer->state = cmd; + } + break; + + case SEQPLAYER_STATE_FADE_OUT: + 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 SEQPLAYER_STATE_FADE_IN: + seqPlayer->state = SEQPLAYER_STATE_0; + seqPlayer->fadeVolume = 0.0f; + // fallthrough + case SEQPLAYER_STATE_0: + seqPlayer->fadeTimer = seqPlayer->storedFadeTimer; + if (seqPlayer->storedFadeTimer != 0) { + seqPlayer->fadeVelocity = + ((value / 127.0f) - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer; + } else { + seqPlayer->fadeVolume = value / 127.0f; + } + break; + + case SEQPLAYER_STATE_FADE_OUT: + 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 = (gAudioCtx.audioRandom >> 2) & 0xFF; + } else { + seqScript->value = (gAudioCtx.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 == SEQPLAYER_STATE_FADE_OUT) { + 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]->muted = 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->seqScriptIO[cmdLowBits]; + break; + + case 0x70: // seqPlayer: io write value + seqPlayer->seqScriptIO[cmdLowBits] = seqScript->value; + break; + + case 0x80: // seqPlayer: io read value + seqScript->value = seqPlayer->seqScriptIO[cmdLowBits]; + if (cmdLowBits < 2) { + seqPlayer->seqScriptIO[cmdLowBits] = SEQ_IO_VAL_NONE; + } + 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->seqScriptIO[cmdLowBits]); + break; + + case 0x60: // seqPlayer: async load + cmd = AudioSeq_ScriptReadU8(seqScript); + value = cmd; + temp = AudioSeq_ScriptReadU8(seqScript); + AudioLoad_ScriptLoad(value, temp, &seqPlayer->seqScriptIO[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; + + gAudioCtx.sampleStateOffset = (gAudioCtx.audioBufferParameters.updatesPerFrame - arg0 - 1) * gAudioCtx.numNotes; + + for (i = 0; i < (u32)gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + seqPlayer = &gAudioCtx.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 channelIndex; + + AudioSeq_SequencePlayerDisable(seqPlayer); + seqPlayer->stopScript = false; + seqPlayer->delay = 0; + seqPlayer->state = SEQPLAYER_STATE_FADE_IN; + seqPlayer->fadeTimer = 0; + seqPlayer->storedFadeTimer = 0; + seqPlayer->tempoAcc = 0; + seqPlayer->tempo = 120 * TATUMS_PER_BEAT; // 120 BPM + seqPlayer->tempoChange = 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 (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + AudioSeq_InitSequenceChannel(seqPlayer->channels[channelIndex]); + } +} + +void AudioSeq_InitSequencePlayerChannels(s32 seqPlayerIndex) { + SequenceChannel* channel; + SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex]; + s32 channelIndex; + s32 layerIndex; + + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + seqPlayer->channels[channelIndex] = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(SequenceChannel)); + if (seqPlayer->channels[channelIndex] == NULL) { + seqPlayer->channels[channelIndex] = &gAudioCtx.sequenceChannelNone; + } else { + channel = seqPlayer->channels[channelIndex]; + channel->seqPlayer = seqPlayer; + channel->enabled = false; + channel->channelIndex = channelIndex; + for (layerIndex = 0; layerIndex < ARRAY_COUNT(channel->layers); layerIndex++) { + channel->layers[layerIndex] = NULL; + } + } + + AudioSeq_InitSequenceChannel(seqPlayer->channels[channelIndex]); + } +} + +void AudioSeq_InitSequencePlayer(SequencePlayer* seqPlayer) { + s32 i; + s32 j; + + for (i = 0; i < SEQ_NUM_CHANNELS; i++) { + seqPlayer->channels[i] = &gAudioCtx.sequenceChannelNone; + } + + seqPlayer->enabled = false; + seqPlayer->muted = false; + seqPlayer->fontDmaInProgress = false; + seqPlayer->seqDmaInProgress = false; + seqPlayer->applyBend = false; + + for (j = 0; j < ARRAY_COUNT(seqPlayer->seqScriptIO); j++) { + seqPlayer->seqScriptIO[j] = SEQ_IO_VAL_NONE; + } + + 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(gAudioCtx.sequenceLayers); i++) { + gAudioCtx.sequenceLayers[i].channel = NULL; + gAudioCtx.sequenceLayers[i].enabled = false; + } + + for (i = 0; i < ARRAY_COUNT(gAudioCtx.seqPlayers); i++) { + AudioSeq_InitSequencePlayer(&gAudioCtx.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/audio_synthesis.c b/src/code/audio/audio_synthesis.c index 51842a33f..057668f37 100644 --- a/src/code/audio/audio_synthesis.c +++ b/src/code/audio/audio_synthesis.c @@ -1,137 +1,1697 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801877D0.s") +// DMEM Addresses for the RSP +#define DMEM_TEMP 0x3B0 +#define DMEM_TEMP2 0x3C0 +#define DMEM_SURROUND_TEMP 0x4B0 +#define DMEM_UNCOMPRESSED_NOTE 0x570 +#define DMEM_HAAS_TEMP 0x5B0 +#define DMEM_COMB_TEMP 0x750 // = DMEM_TEMP + DMEM_2CH_SIZE + a bit more +#define DMEM_COMPRESSED_ADPCM_DATA 0x930 // = DMEM_LEFT_CH +#define DMEM_LEFT_CH 0x930 +#define DMEM_RIGHT_CH 0xAD0 +#define DMEM_WET_TEMP 0x3D0 +#define DMEM_WET_SCRATCH 0x710 // = DMEM_WET_TEMP + DMEM_2CH_SIZE +#define DMEM_WET_LEFT_CH 0xC70 +#define DMEM_WET_RIGHT_CH 0xE10 // = DMEM_WET_LEFT_CH + DMEM_1CH_SIZE + +typedef enum { + /* 0 */ HAAS_EFFECT_DELAY_NONE, + /* 1 */ HAAS_EFFECT_DELAY_LEFT, // Delay left channel so that right channel is heard first + /* 2 */ HAAS_EFFECT_DELAY_RIGHT // Delay right channel so that left channel is heard first +} HaasEffectDelaySide; + +Acmd* AudioSynth_SaveResampledReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 size, uintptr_t startAddr); +Acmd* AudioSynth_LoadReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb); +Acmd* AudioSynth_SaveReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb); +Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex); +Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf, + s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex); +Acmd* AudioSynth_ApplySurroundEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, s32 haasDmem, s32 flags); +Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem, + s32 resampleFlags); +Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, u16 dmemSrc, s32 haasEffectDelaySide, s32 flags); +Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesToLoad); +Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, + s32 flags, s32 haasEffectDelaySide); + +s32 D_801D5FB0 = 0; + +u32 sEnvMixerOp = _SHIFTL(A_ENVMIXER, 24, 8); + +// Store the left dry channel in a temp space to be delayed to produce the haas effect +u32 sEnvMixerLeftHaasDmemDests = + AUDIO_MK_CMD(DMEM_HAAS_TEMP >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +// Store the right dry channel in a temp space to be delayed to produce the haas effect +u32 sEnvMixerRightHaasDmemDests = + AUDIO_MK_CMD(DMEM_LEFT_CH >> 4, DMEM_HAAS_TEMP >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +u32 sEnvMixerDefaultDmemDests = + AUDIO_MK_CMD(DMEM_LEFT_CH >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4); + +// Unused Data +u16 D_801D5FC4[] = { + 0x7FFF, 0xD001, 0x3FFF, 0xF001, 0x5FFF, 0x9001, 0x7FFF, 0x8001, +}; + +u8 sNumSamplesPerWavePeriod[] = { + WAVE_SAMPLE_COUNT / 1, // 1st harmonic + WAVE_SAMPLE_COUNT / 2, // 2nd harmonic + WAVE_SAMPLE_COUNT / 4, // 4th harmonic + WAVE_SAMPLE_COUNT / 8, // 8th harmonic +}; + +/** + * Add a collection of s16-samples as a single entry to the reverb buffer + */ +void AudioSynth_AddReverbBufferEntry(s32 numSamples, s32 updateIndex, s32 reverbIndex) { + SynthesisReverb* reverb; + ReverbBufferEntry* entry; + s32 extraSamples; + s32 numSamplesAfterDownsampling; + s32 reverbBufPos; + s32 temp_t2; + s32 temp_t4; + s32 count1; + s32 count2; + s32 nextReverbSubBufPos; + + reverb = &gAudioCtx.synthesisReverbs[reverbIndex]; + entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + numSamplesAfterDownsampling = numSamples / gAudioCtx.synthesisReverbs[reverbIndex].downsampleRate; + + // Apply resampling effect + if (gAudioCtx.synthesisReverbs[reverbIndex].resampleEffectOn) { + if (reverb->downsampleRate == 1) { + count1 = 0; + count2 = 0; + + numSamplesAfterDownsampling += reverb->resampleEffectExtraSamples; + + entry->saveResampleNumSamples = numSamplesAfterDownsampling; + entry->loadResamplePitch = ((u16)numSamplesAfterDownsampling << 0xF) / numSamples; + entry->saveResamplePitch = (numSamples << 0xF) / (u16)numSamplesAfterDownsampling; + + while (true) { + temp_t2 = (entry->loadResamplePitch * numSamples * 2) + reverb->resampleEffectLoadUnk; + temp_t4 = temp_t2 >> 0x10; + + if ((temp_t4 != numSamplesAfterDownsampling) && (count1 == 0)) { + entry->loadResamplePitch = + ((numSamplesAfterDownsampling << 0x10) - reverb->resampleEffectLoadUnk) / (numSamples * 2); + count1++; + } else { + count1++; + if (temp_t4 > numSamplesAfterDownsampling) { + entry->loadResamplePitch--; + } else if (temp_t4 < numSamplesAfterDownsampling) { + entry->loadResamplePitch++; + } else { + break; + } + } + } + + reverb->resampleEffectLoadUnk = temp_t2 & 0xFFFF; + + while (true) { + temp_t2 = (entry->saveResamplePitch * numSamplesAfterDownsampling * 2) + reverb->resampleEffectSaveUnk; + temp_t4 = temp_t2 >> 0x10; + + if ((temp_t4 != numSamples) && (count2 == 0)) { + entry->saveResamplePitch = + ((numSamples << 0x10) - reverb->resampleEffectSaveUnk) / (numSamplesAfterDownsampling * 2); + count2++; + } else { + count2++; + if (temp_t4 > numSamples) { + entry->saveResamplePitch--; + } else if (temp_t4 < numSamples) { + entry->saveResamplePitch++; + } else { + break; + } + } + } + + reverb->resampleEffectSaveUnk = temp_t2 & 0xFFFF; + } + } + + extraSamples = (reverb->nextReverbBufPos + numSamplesAfterDownsampling) - reverb->delayNumSamples; + reverbBufPos = reverb->nextReverbBufPos; + + // Add a reverb entry + if (extraSamples < 0) { + entry->size = numSamplesAfterDownsampling * SAMPLE_SIZE; + entry->wrappedSize = 0; + entry->startPos = reverb->nextReverbBufPos; + reverb->nextReverbBufPos += numSamplesAfterDownsampling; + } else { + // End of the buffer is reached. Loop back around + entry->size = (numSamplesAfterDownsampling - extraSamples) * SAMPLE_SIZE; + entry->wrappedSize = extraSamples * SAMPLE_SIZE; + entry->startPos = reverb->nextReverbBufPos; + reverb->nextReverbBufPos = extraSamples; + } + + entry->numSamplesAfterDownsampling = numSamplesAfterDownsampling; + entry->numSamples = numSamples; + + // Add a sub-reverb entry + if (reverb->subDelay != 0) { + nextReverbSubBufPos = reverb->subDelay + reverbBufPos; + if (nextReverbSubBufPos >= reverb->delayNumSamples) { + nextReverbSubBufPos -= reverb->delayNumSamples; + } + + entry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + numSamplesAfterDownsampling = numSamples / reverb->downsampleRate; + extraSamples = (nextReverbSubBufPos + numSamplesAfterDownsampling) - reverb->delayNumSamples; + + if (extraSamples < 0) { + entry->size = numSamplesAfterDownsampling * SAMPLE_SIZE; + entry->wrappedSize = 0; + entry->startPos = nextReverbSubBufPos; + } else { + // End of the buffer is reached. Loop back around + entry->size = (numSamplesAfterDownsampling - extraSamples) * SAMPLE_SIZE; + entry->wrappedSize = extraSamples * SAMPLE_SIZE; + entry->startPos = nextReverbSubBufPos; + } + + entry->numSamplesAfterDownsampling = numSamplesAfterDownsampling; + entry->numSamples = numSamples; + } +} + +/** + * Sync the sample states between the notes and the list + */ +void AudioSynth_SyncSampleStates(s32 updateIndex) { + NoteSampleState* noteSampleState; + NoteSampleState* sampleState; + s32 sampleStateBaseIndex; + s32 i; + + sampleStateBaseIndex = gAudioCtx.numNotes * updateIndex; + for (i = 0; i < gAudioCtx.numNotes; i++) { + noteSampleState = &gAudioCtx.notes[i].sampleState; + sampleState = &gAudioCtx.sampleStateList[sampleStateBaseIndex + i]; + if (noteSampleState->bitField0.enabled) { + noteSampleState->bitField0.needsInit = false; + } else { + sampleState->bitField0.enabled = false; + } + + noteSampleState->harmonicIndexCurAndPrev = 0; + } +} + +Acmd* AudioSynth_Update(Acmd* abiCmdStart, s32* numAbiCmds, s16* aiBufStart, s32 numSamplesPerFrame) { + s32 numSamplesPerUpdate; + s16* curAiBufPos; + Acmd* curCmd = abiCmdStart; + s32 reverseUpdateIndex; + s32 reverbIndex; + SynthesisReverb* reverb; + + for (reverseUpdateIndex = gAudioCtx.audioBufferParameters.updatesPerFrame; reverseUpdateIndex > 0; + reverseUpdateIndex--) { + AudioSeq_ProcessSequences(reverseUpdateIndex - 1); + AudioSynth_SyncSampleStates(gAudioCtx.audioBufferParameters.updatesPerFrame - reverseUpdateIndex); + } + + curAiBufPos = aiBufStart; + gAudioCtx.adpcmCodeBook = NULL; + + // Process/Update all samples multiple times in a single frame + for (reverseUpdateIndex = gAudioCtx.audioBufferParameters.updatesPerFrame; reverseUpdateIndex > 0; + reverseUpdateIndex--) { + if (reverseUpdateIndex == 1) { + // Final Update + numSamplesPerUpdate = numSamplesPerFrame; + } else if ((numSamplesPerFrame / reverseUpdateIndex) >= + gAudioCtx.audioBufferParameters.numSamplesPerUpdateMax) { + numSamplesPerUpdate = gAudioCtx.audioBufferParameters.numSamplesPerUpdateMax; + } else if ((numSamplesPerFrame / reverseUpdateIndex) <= + gAudioCtx.audioBufferParameters.numSamplesPerUpdateMin) { + numSamplesPerUpdate = gAudioCtx.audioBufferParameters.numSamplesPerUpdateMin; + } else { + numSamplesPerUpdate = gAudioCtx.audioBufferParameters.numSamplesPerUpdate; + } + + for (reverbIndex = 0; reverbIndex < gAudioCtx.numSynthesisReverbs; reverbIndex++) { + if (gAudioCtx.synthesisReverbs[reverbIndex].useReverb) { + AudioSynth_AddReverbBufferEntry(numSamplesPerUpdate, + gAudioCtx.audioBufferParameters.updatesPerFrame - reverseUpdateIndex, + reverbIndex); + } + } + + curCmd = AudioSynth_ProcessSamples(curAiBufPos, numSamplesPerUpdate, curCmd, + gAudioCtx.audioBufferParameters.updatesPerFrame - reverseUpdateIndex); + numSamplesPerFrame -= numSamplesPerUpdate; + curAiBufPos += numSamplesPerUpdate * SAMPLE_SIZE; + } + + // Update reverb frame info + for (reverbIndex = 0; reverbIndex < gAudioCtx.numSynthesisReverbs; reverbIndex++) { + if (gAudioCtx.synthesisReverbs[reverbIndex].framesToIgnore != 0) { + gAudioCtx.synthesisReverbs[reverbIndex].framesToIgnore--; + } + gAudioCtx.synthesisReverbs[reverbIndex].curFrame ^= 1; + } + + *numAbiCmds = curCmd - abiCmdStart; + return curCmd; +} + +void AudioSynth_DisableSampleStates(s32 updateIndex, s32 noteIndex) { + NoteSampleState* sampleState; + s32 i; + + for (i = updateIndex + 1; i < gAudioCtx.audioBufferParameters.updatesPerFrame; i++) { + sampleState = &gAudioCtx.sampleStateList[(gAudioCtx.numNotes * i) + noteIndex]; + if (sampleState->bitField0.needsInit) { + break; + } + sampleState->bitField0.enabled = false; + } +} + +/** + * Load reverb samples from a different reverb index + */ +Acmd* AudioSynth_LoadMixedReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP + entry->size, 0, entry->wrappedSize, reverb); + } + return cmd; +} + +/** + * Save reverb samples from a different reverb index + */ +Acmd* AudioSynth_SaveMixedReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_TEMP + entry->size, 0, entry->wrappedSize, reverb); + } + return cmd; +} + +void AudioSynth_Noop1(void) { +} + +void AudioSynth_ClearBuffer(Acmd* cmd, s32 dmem, s32 size) { + aClearBuffer(cmd, dmem, size); +} + +void AudioSynth_Noop2(void) { +} + +void AudioSynth_Noop3(void) { +} + +void AudioSynth_Noop4(void) { +} + +void AudioSynth_Mix(Acmd* cmd, size_t size, s32 gain, s32 dmemIn, s32 dmemOut) { + aMix(cmd, size, gain, dmemIn, dmemOut); +} + +void AudioSynth_Noop5(void) { +} + +void AudioSynth_Noop6(void) { +} + +void AudioSynth_Noop7(void) { +} + +void AudioSynth_SetBuffer(Acmd* cmd, s32 flags, s32 dmemIn, s32 dmemOut, size_t size) { + aSetBuffer(cmd, flags, dmemIn, dmemOut, size); +} + +void AudioSynth_Noop8(void) { +} + +void AudioSynth_Noop9(void) { +} + +void AudioSynth_DMemMove(Acmd* cmd, s32 dmemIn, s32 dmemOut, size_t size) { + // aDMEMMove(cmd, dmemIn, dmemOut, size); + cmd->words.w0 = _SHIFTL(A_DMEMMOVE, 24, 8) | _SHIFTL(dmemIn, 0, 24); + cmd->words.w1 = _SHIFTL(dmemOut, 16, 16) | _SHIFTL(size, 0, 16); +} + +void AudioSynth_Noop10(void) { +} + +void AudioSynth_Noop11(void) { +} + +void AudioSynth_Noop12(void) { +} + +void AudioSynth_Noop13(void) { +} + +void AudioSynth_InterL(Acmd* cmd, s32 dmemIn, s32 dmemOut, s32 numSamples) { + // aInterl(cmd, dmemIn, dmemOut, numSamples); + cmd->words.w0 = _SHIFTL(A_INTERL, 24, 8) | _SHIFTL(numSamples, 0, 16); + cmd->words.w1 = _SHIFTL(dmemIn, 16, 16) | _SHIFTL(dmemOut, 0, 16); +} + +void AudioSynth_EnvSetup1(Acmd* cmd, s32 reverbVol, s32 rampReverb, s32 rampLeft, s32 rampRight) { + aEnvSetup1(cmd, reverbVol, rampReverb, rampLeft, rampRight); +} + +void AudioSynth_Noop14(void) { +} + +void AudioSynth_LoadBuffer(Acmd* cmd, s32 dmemDest, s32 size, void* addrSrc) { + aLoadBuffer(cmd, addrSrc, dmemDest, size); +} + +void AudioSynth_SaveBuffer(Acmd* cmd, s32 dmemSrc, s32 size, void* addrDest) { + aSaveBuffer(cmd, dmemSrc, addrDest, size); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187B64.s") +void AudioSynth_EnvSetup2(Acmd* cmd, s32 volLeft, s32 volRight) { + // aEnvSetup2(cmd, volLeft, volRight); + cmd->words.w0 = _SHIFTL(A_ENVSETUP2, 24, 8); + cmd->words.w1 = _SHIFTL(volLeft, 16, 16) | _SHIFTL(volRight, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187BEC.s") +void AudioSynth_Noop15(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187DE8.s") +void AudioSynth_Noop16(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187E58.s") +void AudioSynth_Noop17(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187F00.s") +void AudioSynth_S8Dec(Acmd* cmd, s32 flags, s16* state) { + aS8Dec(cmd, flags, state); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FA8.s") +void AudioSynth_HiLoGain(Acmd* cmd, s32 gain, s32 dmemIn, s32 dmemOut, s32 size) { + // aHiLoGain(cmd, gain, size, dmemIn, dmemOut); + cmd->words.w0 = _SHIFTL(A_HILOGAIN, 24, 8) | _SHIFTL(gain, 16, 8) | _SHIFTL(size, 0, 16); + cmd->words.w1 = _SHIFTL(dmemIn, 16, 16) | _SHIFTL(dmemOut, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FB0.s") +// Remnant of OoT +void AudioSynth_UnkCmd19(Acmd* cmd, s32 dmem1, s32 dmem2, s32 size, s32 arg4) { + cmd->words.w0 = _SHIFTL(A_SPNOOP, 24, 8) | _SHIFTL(arg4, 16, 8) | _SHIFTL(size, 0, 16); + cmd->words.w1 = _SHIFTL(dmem1, 16, 16) | _SHIFTL(dmem2, 0, 16); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FD0.s") +void AudioSynth_Noop18(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FD8.s") +void AudioSynth_Noop19(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FE0.s") +void AudioSynth_Noop20(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80187FE8.s") +void AudioSynth_Noop21(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018801C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188024.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018802C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188034.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188068.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188070.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801880E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018811C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188124.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018814C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188174.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188190.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188198.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801881F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188224.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018822C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188234.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018823C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188244.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018824C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188254.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018825C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188264.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801882A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188304.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801884A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188698.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018883C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801888E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_801889A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188A50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188AFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188C48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188CB4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188D68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188DDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80188FBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80189064.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_80189620.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A4B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A768.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018A808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018ACC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/audio_synthesis/func_8018AE34.s") +void AudioSynth_Noop22(void) { +} + +void AudioSynth_Noop23(void) { +} + +void AudioSynth_Noop24(void) { +} + +void AudioSynth_Noop25(void) { +} + +void AudioSynth_LoadFilterBuffer(Acmd* cmd, s32 flags, s32 buf, s16* addr) { + aFilter(cmd, flags, buf, addr); +} + +void AudioSynth_LoadFilterSize(Acmd* cmd, size_t size, s16* addr) { + aFilter(cmd, 2, size, addr); +} + +/** + * Leak some audio from the left reverb channel into the right reverb channel and vice versa (pan) + */ +Acmd* AudioSynth_LeakReverb(Acmd* cmd, SynthesisReverb* reverb) { + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_SCRATCH, DMEM_1CH_SIZE); + aMix(cmd++, DMEM_1CH_SIZE >> 4, reverb->leakRtl, DMEM_WET_RIGHT_CH, DMEM_WET_LEFT_CH); + aMix(cmd++, DMEM_1CH_SIZE >> 4, reverb->leakLtr, DMEM_WET_SCRATCH, DMEM_WET_RIGHT_CH); + + return cmd; +} + +Acmd* AudioSynth_LoadDownsampledReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 offsetSize = (entry->startPos & 7) * SAMPLE_SIZE; + s16 wrappedOffsetSize = ALIGN16(offsetSize + entry->size); + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos - (offsetSize / (s32)SAMPLE_SIZE), + DMEM_1CH_SIZE, reverb); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP + wrappedOffsetSize, 0, + DMEM_1CH_SIZE - wrappedOffsetSize, reverb); + } + + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + offsetSize, DMEM_WET_LEFT_CH, numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, reverb->downsamplePitch, reverb->leftLoadResampleBuf); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + DMEM_1CH_SIZE + offsetSize, DMEM_WET_RIGHT_CH, + numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, reverb->downsamplePitch, reverb->rightLoadResampleBuf); + + return cmd; +} + +Acmd* AudioSynth_SaveResampledReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 numSamples = entry->numSamples; + u32 size = numSamples * SAMPLE_SIZE; + + // Left Resample + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_TEMP, size); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP, DMEM_WET_SCRATCH, entry->saveResampleNumSamples * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->saveResamplePitch, reverb->leftSaveResampleBuf); + + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_SCRATCH, entry->size, + &reverb->leftReverbBuf[entry->startPos]); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_SCRATCH, entry->wrappedSize, + reverb->leftReverbBuf); + } + + // Right Resample + aDMEMMove(cmd++, DMEM_WET_RIGHT_CH, DMEM_WET_TEMP, size); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP, DMEM_WET_SCRATCH, entry->saveResampleNumSamples * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->saveResamplePitch, reverb->rightSaveResampleBuf); + + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_SCRATCH, entry->size, + &reverb->rightReverbBuf[entry->startPos]); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_SCRATCH, entry->wrappedSize, + reverb->rightReverbBuf); + } + + return cmd; +} + +Acmd* AudioSynth_LoadResampledReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s16 offsetSize = (entry->startPos & 7) * SAMPLE_SIZE; + s16 wrappedOffsetSize = ALIGN16(offsetSize + entry->size); + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_TEMP, entry->startPos - (offsetSize / (s32)SAMPLE_SIZE), + DMEM_1CH_SIZE, reverb); + + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, wrappedOffsetSize + DMEM_WET_TEMP, 0, + DMEM_1CH_SIZE - wrappedOffsetSize, reverb); + } + + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + offsetSize, DMEM_WET_LEFT_CH, numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->loadResamplePitch, reverb->leftLoadResampleBuf); + aSetBuffer(cmd++, 0, DMEM_WET_TEMP + DMEM_1CH_SIZE + offsetSize, DMEM_WET_RIGHT_CH, + numSamplesPerUpdate * SAMPLE_SIZE); + aResample(cmd++, reverb->resampleFlags, entry->loadResamplePitch, reverb->rightLoadResampleBuf); + + return cmd; +} + +/** + * Apply a filter (convolution) to each reverb channel. + */ +Acmd* AudioSynth_FilterReverb(Acmd* cmd, s32 size, SynthesisReverb* reverb) { + if (reverb->filterLeft != NULL) { + aFilter(cmd++, 2, size, reverb->filterLeft); + aFilter(cmd++, reverb->resampleFlags, DMEM_WET_LEFT_CH, reverb->filterLeftState); + } + + if (reverb->filterRight != NULL) { + aFilter(cmd++, 2, size, reverb->filterRight); + aFilter(cmd++, reverb->resampleFlags, DMEM_WET_RIGHT_CH, reverb->filterRightState); + } + + return cmd; +} + +/** + * Mix in reverb from a different reverb index + */ +Acmd* AudioSynth_MixOtherReverbIndex(Acmd* cmd, SynthesisReverb* reverb, s32 updateIndex) { + SynthesisReverb* mixReverb; + + if (reverb->mixReverbIndex >= gAudioCtx.numSynthesisReverbs) { + return cmd; + } + + mixReverb = &gAudioCtx.synthesisReverbs[reverb->mixReverbIndex]; + if (mixReverb->downsampleRate == 1) { + cmd = AudioSynth_LoadMixedReverbSamples(cmd, mixReverb, updateIndex); + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->mixReverbStrength, DMEM_WET_LEFT_CH, DMEM_WET_TEMP); + cmd = AudioSynth_SaveMixedReverbSamples(cmd, mixReverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_LoadDefaultReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + entry->size, 0, entry->wrappedSize, reverb); + } + + return cmd; +} + +Acmd* AudioSynth_LoadSubReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* subEntry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, subEntry->startPos, subEntry->size, reverb); + if (subEntry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = + AudioSynth_LoadReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + subEntry->size, 0, subEntry->wrappedSize, reverb); + } + + return cmd; +} + +Acmd* AudioSynth_SaveResampledReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 size, uintptr_t startAddr) { + s32 startAddrAlignDropped; + u32 endAddr; + s32 endAddrAlignDropped; + + endAddr = startAddr + size; + + endAddrAlignDropped = endAddr & 0xF; + if (endAddrAlignDropped != 0) { + aLoadBuffer(cmd++, (endAddr - endAddrAlignDropped), DMEM_TEMP, 0x10); + aDMEMMove(cmd++, dmem, DMEM_TEMP2, size); + aDMEMMove(cmd++, DMEM_TEMP + endAddrAlignDropped, size + DMEM_TEMP2, 0x10 - endAddrAlignDropped); + + size += (0x10 - endAddrAlignDropped); + dmem = DMEM_TEMP2; + } + + startAddrAlignDropped = startAddr & 0xF; + if (startAddrAlignDropped != 0) { + aLoadBuffer(cmd++, startAddr - startAddrAlignDropped, DMEM_TEMP, 0x10); + aDMEMMove(cmd++, dmem, startAddrAlignDropped + DMEM_TEMP, size); + + size += startAddrAlignDropped; + dmem = DMEM_TEMP; + } + + aSaveBuffer(cmd++, dmem, startAddr - startAddrAlignDropped, size); + + return cmd; +} + +Acmd* AudioSynth_LoadReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb) { + aLoadBuffer(cmd++, &reverb->leftReverbBuf[startPos], dmem, size); + aLoadBuffer(cmd++, &reverb->rightReverbBuf[startPos], dmem + DMEM_1CH_SIZE, size); + + return cmd; +} + +Acmd* AudioSynth_SaveReverbSamplesImpl(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb) { + aSaveBuffer(cmd++, dmem, &reverb->leftReverbBuf[startPos], size); + aSaveBuffer(cmd++, dmem + DMEM_1CH_SIZE, &reverb->rightReverbBuf[startPos], size); + + return cmd; +} + +void AudioSynth_Noop26(void) { +} + +Acmd* AudioSynth_LoadSubReverbSamplesWithoutDownsample(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, + s16 updateIndex) { + if (reverb->downsampleRate == 1) { + cmd = AudioSynth_LoadSubReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_LoadReverbSamples(Acmd* cmd, s32 numSamplesPerUpdate, SynthesisReverb* reverb, s16 updateIndex) { + if (reverb->downsampleRate == 1) { + if (reverb->resampleEffectOn) { + cmd = AudioSynth_LoadResampledReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } else { + cmd = AudioSynth_LoadDefaultReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + } else { + cmd = AudioSynth_LoadDownsampledReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + } + + return cmd; +} + +Acmd* AudioSynth_SaveReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* entry = &reverb->bufEntry[reverb->curFrame][updateIndex]; + s32 downsampleRate; + s32 numSamples; + + if (reverb->downsampleRate == 1) { + if (reverb->resampleEffectOn) { + cmd = AudioSynth_SaveResampledReverbSamples(cmd, reverb, updateIndex); + } else { + // Put the oldest samples in the ring buffer into the wet channels + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->startPos, entry->size, reverb); + if (entry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + entry->size, 0, entry->wrappedSize, + reverb); + } + } + } else { + //! FAKE: + if (1) {} + + downsampleRate = reverb->downsampleRate; + numSamples = 13 * SAMPLES_PER_FRAME; + + while (downsampleRate >= 2) { + aInterl(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_LEFT_CH, numSamples); + aInterl(cmd++, DMEM_WET_RIGHT_CH, DMEM_WET_RIGHT_CH, numSamples); + downsampleRate >>= 1; + numSamples >>= 1; + } + + if (entry->size != 0) { + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, entry->size, + &reverb->leftReverbBuf[entry->startPos]); + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, DMEM_WET_RIGHT_CH, entry->size, + &reverb->rightReverbBuf[entry->startPos]); + } + + if (entry->wrappedSize != 0) { + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_LEFT_CH, entry->wrappedSize, + reverb->leftReverbBuf); + cmd = AudioSynth_SaveResampledReverbSamplesImpl(cmd, entry->size + DMEM_WET_RIGHT_CH, entry->wrappedSize, + reverb->rightReverbBuf); + } + } + + reverb->resampleFlags = 0; + + return cmd; +} + +Acmd* AudioSynth_SaveSubReverbSamples(Acmd* cmd, SynthesisReverb* reverb, s16 updateIndex) { + ReverbBufferEntry* subEntry = &reverb->subBufEntry[reverb->curFrame][updateIndex]; + + cmd = AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH, subEntry->startPos, subEntry->size, reverb); + if (subEntry->wrappedSize != 0) { + // Ring buffer wrapped + cmd = + AudioSynth_SaveReverbSamplesImpl(cmd, DMEM_WET_LEFT_CH + subEntry->size, 0, subEntry->wrappedSize, reverb); + } + + return cmd; +} + +/** + * Process all samples embedded in a note. Every sample has numSamplesPerUpdate processed, + * and each of those are mixed together into both DMEM_LEFT_CH and DMEM_RIGHT_CH + */ +Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex) { + s32 size; + u8 noteIndices[0x58]; + s16 noteCount = 0; + s16 reverbIndex; + SynthesisReverb* reverb; + s32 useReverb; + s32 sampleStateOffset = gAudioCtx.numNotes * updateIndex; + s32 i; + + if (gAudioCtx.numSynthesisReverbs == 0) { + for (i = 0; i < gAudioCtx.numNotes; i++) { + if (gAudioCtx.sampleStateList[sampleStateOffset + i].bitField0.enabled) { + noteIndices[noteCount++] = i; + } + } + } else { + NoteSampleState* sampleState; + + for (reverbIndex = 0; reverbIndex < gAudioCtx.numSynthesisReverbs; reverbIndex++) { + for (i = 0; i < gAudioCtx.numNotes; i++) { + sampleState = &gAudioCtx.sampleStateList[sampleStateOffset + i]; + if (sampleState->bitField0.enabled && (sampleState->bitField1.reverbIndex == reverbIndex)) { + noteIndices[noteCount++] = i; + } + } + } + + for (i = 0; i < gAudioCtx.numNotes; i++) { + sampleState = &gAudioCtx.sampleStateList[sampleStateOffset + i]; + if (sampleState->bitField0.enabled && + (sampleState->bitField1.reverbIndex >= gAudioCtx.numSynthesisReverbs)) { + noteIndices[noteCount++] = i; + } + } + } + + aClearBuffer(cmd++, DMEM_LEFT_CH, DMEM_2CH_SIZE); + + i = 0; + for (reverbIndex = 0; reverbIndex < gAudioCtx.numSynthesisReverbs; reverbIndex++) { + s32 subDelay; + NoteSampleState* sampleState; + + reverb = &gAudioCtx.synthesisReverbs[reverbIndex]; + useReverb = reverb->useReverb; + if (useReverb) { + + // Loads reverb samples from DRAM (ringBuffer) into DMEM (DMEM_WET_LEFT_CH) + cmd = AudioSynth_LoadReverbSamples(cmd, numSamplesPerUpdate, reverb, updateIndex); + + // Mixes reverb sample into the main dry channel + // reverb->volume is always set to 0x7FFF (audio spec), and DMEM_LEFT_CH is cleared before reverbs. + // So this is essentially a DMEMmove from DMEM_WET_LEFT_CH to DMEM_LEFT_CH + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->volume, DMEM_WET_LEFT_CH, DMEM_LEFT_CH); + + subDelay = reverb->subDelay; + if (subDelay != 0) { + aDMEMMove(cmd++, DMEM_WET_LEFT_CH, DMEM_WET_TEMP, DMEM_2CH_SIZE); + } + + // Decays reverb over time. The (+ 0x8000) here is -100% + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->decayRatio + 0x8000, DMEM_WET_LEFT_CH, DMEM_WET_LEFT_CH); + + if (((reverb->leakRtl != 0) || (reverb->leakLtr != 0)) && (gAudioCtx.soundMode != SOUNDMODE_MONO)) { + cmd = AudioSynth_LeakReverb(cmd, reverb); + } + + if (subDelay != 0) { + if (reverb->mixReverbIndex != REVERB_INDEX_NONE) { + cmd = AudioSynth_MixOtherReverbIndex(cmd, reverb, updateIndex); + } + cmd = AudioSynth_SaveReverbSamples(cmd, reverb, updateIndex); + cmd = AudioSynth_LoadSubReverbSamplesWithoutDownsample(cmd, numSamplesPerUpdate, reverb, updateIndex); + aMix(cmd++, DMEM_2CH_SIZE >> 4, reverb->subVolume, DMEM_WET_TEMP, DMEM_WET_LEFT_CH); + } + } + + while (i < noteCount) { + sampleState = &gAudioCtx.sampleStateList[sampleStateOffset + noteIndices[i]]; + if (sampleState->bitField1.reverbIndex != reverbIndex) { + break; + } + cmd = AudioSynth_ProcessSample(noteIndices[i], sampleState, &gAudioCtx.notes[noteIndices[i]].synthesisState, + aiBuf, numSamplesPerUpdate, cmd, updateIndex); + i++; + } + + if (useReverb) { + if ((reverb->filterLeft != NULL) || (reverb->filterRight != NULL)) { + cmd = AudioSynth_FilterReverb(cmd, numSamplesPerUpdate * SAMPLE_SIZE, reverb); + } + + // Saves the wet channel sample from DMEM (DMEM_WET_LEFT_CH) into (ringBuffer) DRAM for future use + if (subDelay != 0) { + cmd = AudioSynth_SaveSubReverbSamples(cmd, reverb, updateIndex); + } else { + if (reverb->mixReverbIndex != REVERB_INDEX_NONE) { + cmd = AudioSynth_MixOtherReverbIndex(cmd, reverb, updateIndex); + } + cmd = AudioSynth_SaveReverbSamples(cmd, reverb, updateIndex); + } + } + } + + while (i < noteCount) { + cmd = AudioSynth_ProcessSample(noteIndices[i], &gAudioCtx.sampleStateList[sampleStateOffset + noteIndices[i]], + &gAudioCtx.notes[noteIndices[i]].synthesisState, aiBuf, numSamplesPerUpdate, cmd, + updateIndex); + i++; + } + + size = numSamplesPerUpdate * SAMPLE_SIZE; + aInterleave(cmd++, DMEM_TEMP, DMEM_LEFT_CH, DMEM_RIGHT_CH, size); + + if (gAudioCustomSynthFunction != NULL) { + cmd = gAudioCustomSynthFunction(cmd, 2 * size, updateIndex); + } + aSaveBuffer(cmd++, DMEM_TEMP, aiBuf, 2 * size); + + return cmd; +} + +Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf, + s32 numSamplesPerUpdate, Acmd* cmd, s32 updateIndex) { + s32 pad1[2]; + void* reverbAddrSrc; + Sample* sample; + AdpcmLoop* loopInfo; + s32 numSamplesUntilEnd; + s32 numSamplesInThisIteration; + s32 sampleFinished; + s32 loopToPoint; + s32 flags; + u16 frequencyFixedPoint; + s32 gain; + s32 frameIndex; + s32 skipBytes; + void* combFilterState; + s32 numSamplesToDecode; + s32 numFirstFrameSamplesToIgnore; + u8* sampleAddr; + u32 numSamplesToLoadFixedPoint; + s32 numSamplesToLoadAdj; + s32 numSamplesProcessed; + s32 sampleEndPos; + s32 numSamplesToProcess; + s32 dmemUncompressedAddrOffset2; + s32 pad2[3]; + s32 numSamplesInFirstFrame; + s32 numTrailingSamplesToIgnore; + s32 pad3[3]; + s32 frameSize; + s32 numFramesToDecode; + s32 skipInitialSamples; + s32 zeroOffset; + u8* samplesToLoadAddr; + s32 numParts; + s32 curPart; + s32 sampleDataChunkAlignPad; + s32 haasEffectDelaySide; + s32 numSamplesToLoadFirstPart; + u16 sampleDmemBeforeResampling; + s32 sampleAddrOffset; + s32 combFilterDmem; + s32 dmemUncompressedAddrOffset1; + Note* note; + u32 numSamplesToLoad; + u16 combFilterSize; + u16 combFilterGain; + s16* filter; + s32 bookOffset = sampleState->bitField1.bookOffset; + s32 finished = sampleState->bitField0.finished; + s32 sampleDataChunkSize; + s16 sampleDataDmemAddr; + + note = &gAudioCtx.notes[noteIndex]; + flags = A_CONTINUE; + + // Initialize the synthesis state + if (sampleState->bitField0.needsInit == true) { + flags = A_INIT; + synthState->atLoopPoint = false; + synthState->stopLoop = false; + synthState->samplePosInt = note->playbackState.startSamplePos; + synthState->samplePosFrac = 0; + synthState->curVolLeft = 0; + synthState->curVolRight = 0; + synthState->prevHaasEffectLeftDelaySize = 0; + synthState->prevHaasEffectRightDelaySize = 0; + synthState->curReverbVol = sampleState->targetReverbVol; + synthState->numParts = 0; + synthState->combFilterNeedsInit = true; + note->sampleState.bitField0.finished = false; + synthState->unk_1F = note->playbackState.unk_80; // Never set, never used + finished = false; + } + + // Process the sample in either one or two parts + numParts = sampleState->bitField1.hasTwoParts + 1; + + // Determine number of samples to load based on numSamplesPerUpdate and relative frequency + frequencyFixedPoint = sampleState->frequencyFixedPoint; + numSamplesToLoadFixedPoint = (frequencyFixedPoint * numSamplesPerUpdate * 2) + synthState->samplePosFrac; + numSamplesToLoad = numSamplesToLoadFixedPoint >> 16; + + if (numSamplesToLoad == 0) { + skipBytes = false; + } + + synthState->samplePosFrac = numSamplesToLoadFixedPoint & 0xFFFF; + + // Partially-optimized out no-op ifs required for matching. SM64 decomp + // makes it clear that this is how it should look. + if ((synthState->numParts == 1) && (numParts == 2)) { + } else if ((synthState->numParts == 2) && (numParts == 1)) { + } else { + } + + synthState->numParts = numParts; + + if (sampleState->bitField1.isSyntheticWave) { + cmd = AudioSynth_LoadWaveSamples(cmd, sampleState, synthState, numSamplesToLoad); + sampleDmemBeforeResampling = DMEM_UNCOMPRESSED_NOTE + (synthState->samplePosInt * 2); + synthState->samplePosInt += numSamplesToLoad; + } else { + sample = sampleState->tunedSample->sample; + loopInfo = sample->loop; + + if (note->playbackState.status != PLAYBACK_STATUS_0) { + synthState->stopLoop = true; + } + + if ((loopInfo->count == 2) && synthState->stopLoop) { + sampleEndPos = loopInfo->sampleEnd; + } else { + sampleEndPos = loopInfo->loopEnd; + } + + sampleAddr = sample->sampleAddr; + numSamplesToLoadFirstPart = 0; + + // If the frequency requested is more than double that of the raw sample, + // then the sample processing is split into two parts. + for (curPart = 0; curPart < numParts; curPart++) { + numSamplesProcessed = 0; + dmemUncompressedAddrOffset1 = 0; + + // Adjust the number of samples to load only if there are two parts and an odd number of samples + if (numParts == 1) { + numSamplesToLoadAdj = numSamplesToLoad; + } else if (numSamplesToLoad & 1) { + // round down for the first part + // round up for the second part + numSamplesToLoadAdj = (numSamplesToLoad & ~1) + (curPart * 2); + } else { + numSamplesToLoadAdj = numSamplesToLoad; + } + + // Load the ADPCM codeBook + if ((sample->codec == CODEC_ADPCM) || (sample->codec == CODEC_SMALL_ADPCM)) { + if (gAudioCtx.adpcmCodeBook != sample->book->codeBook) { + u32 numEntries; + + switch (bookOffset) { + case 1: + gAudioCtx.adpcmCodeBook = &gInvalidAdpcmCodeBook[1]; + break; + + case 2: + case 3: + default: + gAudioCtx.adpcmCodeBook = sample->book->codeBook; + break; + } + + numEntries = SAMPLES_PER_FRAME * sample->book->order * sample->book->numPredictors; + aLoadADPCM(cmd++, numEntries, gAudioCtx.adpcmCodeBook); + } + } + + // Continue processing samples until the number of samples needed to load is reached + while (numSamplesProcessed != numSamplesToLoadAdj) { + sampleFinished = false; + loopToPoint = false; + dmemUncompressedAddrOffset2 = 0; + + numFirstFrameSamplesToIgnore = synthState->samplePosInt & 0xF; + numSamplesUntilEnd = sampleEndPos - synthState->samplePosInt; + + // Calculate number of samples to process this loop + numSamplesToProcess = numSamplesToLoadAdj - numSamplesProcessed; + + if ((numFirstFrameSamplesToIgnore == 0) && !synthState->atLoopPoint) { + numFirstFrameSamplesToIgnore = SAMPLES_PER_FRAME; + } + numSamplesInFirstFrame = SAMPLES_PER_FRAME - numFirstFrameSamplesToIgnore; + + // Determine the number of samples to decode based on whether the end will be reached or not. + if (numSamplesToProcess < numSamplesUntilEnd) { + // The end will not be reached. + numFramesToDecode = + (s32)(numSamplesToProcess - numSamplesInFirstFrame + SAMPLES_PER_FRAME - 1) / SAMPLES_PER_FRAME; + numSamplesToDecode = numFramesToDecode * SAMPLES_PER_FRAME; + numTrailingSamplesToIgnore = numSamplesInFirstFrame + numSamplesToDecode - numSamplesToProcess; + } else { + // The end will be reached. + numSamplesToDecode = numSamplesUntilEnd - numSamplesInFirstFrame; + numTrailingSamplesToIgnore = 0; + if (numSamplesToDecode <= 0) { + numSamplesToDecode = 0; + numSamplesInFirstFrame = numSamplesUntilEnd; + } + numFramesToDecode = (numSamplesToDecode + SAMPLES_PER_FRAME - 1) / SAMPLES_PER_FRAME; + if (loopInfo->count != 0) { + if ((loopInfo->count == 2) && synthState->stopLoop) { + sampleFinished = true; + } else { + // Loop around and restart + loopToPoint = true; + } + } else { + sampleFinished = true; + } + } + + // Set parameters based on compression type + switch (sample->codec) { + case CODEC_ADPCM: + // 16 2-byte samples (32 bytes) compressed into 4-bit samples (8 bytes) + 1 header byte + frameSize = 9; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_SMALL_ADPCM: + // 16 2-byte samples (32 bytes) compressed into 2-bit samples (4 bytes) + 1 header byte + frameSize = 5; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_UNK7: + // 2 2-byte samples (4 bytes) processed without decompression + frameSize = 4; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_S8: + // 16 2-byte samples (32 bytes) compressed into 8-bit samples (16 bytes) + frameSize = 16; + skipInitialSamples = SAMPLES_PER_FRAME; + zeroOffset = 0; + break; + + case CODEC_REVERB: + reverbAddrSrc = (void*)0xFFFFFFFF; + if (gAudioCustomReverbFunction != NULL) { + reverbAddrSrc = gAudioCustomReverbFunction(sample, numSamplesToLoadAdj, flags, noteIndex); + } + + if (reverbAddrSrc == (void*)0xFFFFFFFF) { + sampleFinished = true; + } else if (reverbAddrSrc == NULL) { + return cmd; + } else { + AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE, + reverbAddrSrc); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + } + goto skip; + + case CODEC_S16_INMEMORY: + case CODEC_UNK6: + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + goto skip; + + case CODEC_S16: + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, + (numSamplesToLoadAdj + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + flags = A_CONTINUE; + skipBytes = 0; + numSamplesProcessed = numSamplesToLoadAdj; + dmemUncompressedAddrOffset1 = numSamplesToLoadAdj; + goto skip; + + default: + break; + } + + // Move the compressed raw sample data from ram into the rsp (DMEM) + if (numFramesToDecode != 0) { + // Get the offset from the start of the sample to where the sample is currently playing from + frameIndex = (synthState->samplePosInt + skipInitialSamples - numFirstFrameSamplesToIgnore) / + SAMPLES_PER_FRAME; + sampleAddrOffset = frameIndex * frameSize; + + // Get the ram address of the requested sample chunk + if (sample->medium == MEDIUM_RAM) { + // Sample is already loaded into ram + samplesToLoadAddr = sampleAddr + (zeroOffset + sampleAddrOffset); + } else if (gAudioCtx.unk_29B8) { // always false + return cmd; + } else if (sample->medium == MEDIUM_UNK) { + // This medium is unsupported so terminate processing this note + return cmd; + } else { + // This medium is not in ram, so dma the requested sample into ram + samplesToLoadAddr = + AudioLoad_DmaSampleData(sampleAddr + (zeroOffset + sampleAddrOffset), + ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME), flags, + &synthState->sampleDmaIndex, sample->medium); + } + + if (samplesToLoadAddr == NULL) { + // The ram address was unsuccessfully allocated + return cmd; + } + + // Move the raw sample chunk from ram to the rsp + // DMEM at the addresses before DMEM_COMPRESSED_ADPCM_DATA + sampleDataChunkAlignPad = (u32)samplesToLoadAddr & 0xF; + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aLoadBuffer(cmd++, samplesToLoadAddr - sampleDataChunkAlignPad, sampleDataDmemAddr, + sampleDataChunkSize); + } else { + numSamplesToDecode = 0; + sampleDataChunkAlignPad = 0; + } + + if (synthState->atLoopPoint) { + aSetLoop(cmd++, sample->loop->predictorState); + flags = A_LOOP; + synthState->atLoopPoint = false; + } + + numSamplesInThisIteration = numSamplesToDecode + numSamplesInFirstFrame - numTrailingSamplesToIgnore; + + if (numSamplesProcessed == 0) { + //! FAKE: + if (1) {} + skipBytes = numFirstFrameSamplesToIgnore * SAMPLE_SIZE; + } else { + dmemUncompressedAddrOffset2 = ALIGN16(dmemUncompressedAddrOffset1 + 8 * SAMPLE_SIZE); + } + + // Decompress the raw sample chunks in the rsp + // Goes from adpcm (compressed) sample data to pcm (uncompressed) sample data + switch (sample->codec) { + case CODEC_ADPCM: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aSetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + aADPCMdec(cmd++, flags, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_SMALL_ADPCM: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + aSetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + aADPCMdec(cmd++, flags | A_ADPCM_SHORT, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_S8: + sampleDataChunkSize = ALIGN16((numFramesToDecode * frameSize) + SAMPLES_PER_FRAME); + sampleDataDmemAddr = DMEM_COMPRESSED_ADPCM_DATA - sampleDataChunkSize; + AudioSynth_SetBuffer(cmd++, 0, sampleDataDmemAddr + sampleDataChunkAlignPad, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2, + numSamplesToDecode * SAMPLE_SIZE); + AudioSynth_S8Dec(cmd++, flags, synthState->synthesisBuffers->adpcmState); + break; + + case CODEC_UNK7: + default: + // No decompression + break; + } + + if (numSamplesProcessed != 0) { + aDMEMMove(cmd++, + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset2 + + (numFirstFrameSamplesToIgnore * SAMPLE_SIZE), + DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset1, + numSamplesInThisIteration * SAMPLE_SIZE); + } + + numSamplesProcessed += numSamplesInThisIteration; + + switch (flags) { + case A_INIT: + skipBytes = SAMPLES_PER_FRAME * SAMPLE_SIZE; + dmemUncompressedAddrOffset1 = (numSamplesToDecode + SAMPLES_PER_FRAME) * SAMPLE_SIZE; + break; + + case A_LOOP: + dmemUncompressedAddrOffset1 = + numSamplesInThisIteration * SAMPLE_SIZE + dmemUncompressedAddrOffset1; + break; + + default: + if (dmemUncompressedAddrOffset1 != 0) { + dmemUncompressedAddrOffset1 = + numSamplesInThisIteration * SAMPLE_SIZE + dmemUncompressedAddrOffset1; + } else { + dmemUncompressedAddrOffset1 = + (numFirstFrameSamplesToIgnore + numSamplesInThisIteration) * SAMPLE_SIZE; + } + break; + } + + flags = A_CONTINUE; + + skip: + + // Update what to do with the samples next + if (sampleFinished) { + if ((numSamplesToLoadAdj - numSamplesProcessed) != 0) { + AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE + dmemUncompressedAddrOffset1, + (numSamplesToLoadAdj - numSamplesProcessed) * SAMPLE_SIZE); + } + finished = true; + note->sampleState.bitField0.finished = true; + AudioSynth_DisableSampleStates(updateIndex, noteIndex); + break; // break out of the for-loop + } else if (loopToPoint) { + synthState->atLoopPoint = true; + synthState->samplePosInt = loopInfo->start; + } else { + synthState->samplePosInt += numSamplesToProcess; + } + } + + switch (numParts) { + case 1: + sampleDmemBeforeResampling = DMEM_UNCOMPRESSED_NOTE + skipBytes; + break; + + case 2: + switch (curPart) { + case 0: + AudioSynth_InterL(cmd++, DMEM_UNCOMPRESSED_NOTE + skipBytes, + DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE), + ALIGN8(numSamplesToLoadAdj / 2)); + numSamplesToLoadFirstPart = numSamplesToLoadAdj; + sampleDmemBeforeResampling = DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE); + if (finished) { + AudioSynth_ClearBuffer(cmd++, sampleDmemBeforeResampling + numSamplesToLoadFirstPart, + numSamplesToLoadAdj + SAMPLES_PER_FRAME); + } + break; + + case 1: + AudioSynth_InterL(cmd++, DMEM_UNCOMPRESSED_NOTE + skipBytes, + DMEM_TEMP + (SAMPLES_PER_FRAME * SAMPLE_SIZE) + numSamplesToLoadFirstPart, + ALIGN8(numSamplesToLoadAdj / 2)); + break; + + default: + break; + } + break; + + default: + break; + } + if (finished) { + break; + } + } + } + + // Update the flags for the signal processing below + flags = A_CONTINUE; + if (sampleState->bitField0.needsInit == true) { + sampleState->bitField0.needsInit = false; + flags = A_INIT; + } + + // Resample the decompressed mono-signal to the correct pitch + cmd = AudioSynth_FinalResample(cmd, synthState, numSamplesPerUpdate * SAMPLE_SIZE, frequencyFixedPoint, + sampleDmemBeforeResampling, flags); + + // UnkCmd19 was removed from the audio microcode + // This block performs no operation + if (bookOffset == 3) { + AudioSynth_UnkCmd19(cmd++, DMEM_TEMP, DMEM_TEMP, numSamplesPerUpdate * (s32)SAMPLE_SIZE, 0); + } + + // Apply the gain to the mono-signal to adjust the volume + gain = sampleState->gain; + if (gain != 0) { + // A gain of 0x10 (a UQ4.4 number) is equivalent to 1.0 and represents no volume change + if (gain < 0x10) { + gain = 0x10; + } + AudioSynth_HiLoGain(cmd++, gain, DMEM_TEMP, 0, (numSamplesPerUpdate + SAMPLES_PER_FRAME) * SAMPLE_SIZE); + } + + // Apply the filter to the mono-signal + filter = sampleState->filter; + if (filter != 0) { + AudioSynth_LoadFilterSize(cmd++, numSamplesPerUpdate * SAMPLE_SIZE, filter); + AudioSynth_LoadFilterBuffer(cmd++, flags, DMEM_TEMP, synthState->synthesisBuffers->filterState); + } + + // Apply the comb filter to the mono-signal by taking the signal with a small temporal offset, + // and adding it back to itself + combFilterSize = sampleState->combFilterSize; + combFilterGain = sampleState->combFilterGain; + combFilterState = synthState->synthesisBuffers->combFilterState; + if ((combFilterSize != 0) && (sampleState->combFilterGain != 0)) { + AudioSynth_DMemMove(cmd++, DMEM_TEMP, DMEM_COMB_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + combFilterDmem = DMEM_COMB_TEMP - combFilterSize; + if (synthState->combFilterNeedsInit) { + AudioSynth_ClearBuffer(cmd++, combFilterDmem, combFilterSize); + synthState->combFilterNeedsInit = false; + } else { + AudioSynth_LoadBuffer(cmd++, combFilterDmem, combFilterSize, combFilterState); + } + AudioSynth_SaveBuffer(cmd++, DMEM_TEMP + (numSamplesPerUpdate * SAMPLE_SIZE) - combFilterSize, combFilterSize, + combFilterState); + AudioSynth_Mix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, combFilterGain, DMEM_COMB_TEMP, + combFilterDmem); + AudioSynth_DMemMove(cmd++, combFilterDmem, DMEM_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + } else { + synthState->combFilterNeedsInit = true; + } + + // Determine the behavior of the audio processing that leads to the haas effect + if ((sampleState->haasEffectLeftDelaySize != 0) || (synthState->prevHaasEffectLeftDelaySize != 0)) { + haasEffectDelaySide = HAAS_EFFECT_DELAY_LEFT; + } else if ((sampleState->haasEffectRightDelaySize != 0) || (synthState->prevHaasEffectRightDelaySize != 0)) { + haasEffectDelaySide = HAAS_EFFECT_DELAY_RIGHT; + } else { + haasEffectDelaySide = HAAS_EFFECT_DELAY_NONE; + } + + // Apply an unknown effect based on the surround sound-mode + if (gAudioCtx.soundMode == SOUNDMODE_SURROUND) { + sampleState->targetVolLeft = sampleState->targetVolLeft >> 1; + sampleState->targetVolRight = sampleState->targetVolRight >> 1; + if (sampleState->surroundEffectIndex != 0xFF) { + cmd = AudioSynth_ApplySurroundEffect(cmd, sampleState, synthState, numSamplesPerUpdate, DMEM_TEMP, flags); + } + } + + // Split the mono-signal into left and right channels: + // Both for dry signal (to go to the speakers now) + // and for wet signal (to go to a reverb buffer to be stored, and brought back later to produce an echo) + cmd = AudioSynth_ProcessEnvelope(cmd, sampleState, synthState, numSamplesPerUpdate, DMEM_TEMP, haasEffectDelaySide, + flags); + + // Apply the haas effect by delaying either the left or the right channel by a small amount + if (sampleState->bitField1.useHaasEffect) { + if (!(flags & A_INIT)) { + flags = A_CONTINUE; + } + cmd = AudioSynth_ApplyHaasEffect(cmd, sampleState, synthState, numSamplesPerUpdate * (s32)SAMPLE_SIZE, flags, + haasEffectDelaySide); + } + + return cmd; +} + +Acmd* AudioSynth_ApplySurroundEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, s32 haasDmem, s32 flags) { + s32 wetGain; + u16 dryGain; + s64 dmem = DMEM_SURROUND_TEMP; + f32 decayGain; + + AudioSynth_DMemMove(cmd++, haasDmem, DMEM_HAAS_TEMP, numSamplesPerUpdate * SAMPLE_SIZE); + dryGain = synthState->surroundEffectGain; + + if (flags == A_INIT) { + aClearBuffer(cmd++, dmem, sizeof(synthState->synthesisBuffers->surroundEffectState)); + synthState->surroundEffectGain = 0; + } else { + aLoadBuffer(cmd++, synthState->synthesisBuffers->surroundEffectState, dmem, + sizeof(synthState->synthesisBuffers->surroundEffectState)); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, dryGain, dmem, DMEM_LEFT_CH); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, (dryGain ^ 0xFFFF), dmem, DMEM_RIGHT_CH); + + wetGain = (dryGain * synthState->curReverbVol) >> 7; + + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, wetGain, dmem, DMEM_WET_LEFT_CH); + aMix(cmd++, (numSamplesPerUpdate * (s32)SAMPLE_SIZE) >> 4, (wetGain ^ 0xFFFF), dmem, DMEM_WET_RIGHT_CH); + } + + aSaveBuffer(cmd++, DMEM_SURROUND_TEMP + (numSamplesPerUpdate * SAMPLE_SIZE), + synthState->synthesisBuffers->surroundEffectState, + sizeof(synthState->synthesisBuffers->surroundEffectState)); + + decayGain = (sampleState->targetVolLeft + sampleState->targetVolRight) * (1.0f / 0x2000); + + if (decayGain > 1.0f) { + decayGain = 1.0f; + } + + decayGain = decayGain * gDefaultPanVolume[127 - sampleState->surroundEffectIndex]; + synthState->surroundEffectGain = ((decayGain * 0x7FFF) + synthState->surroundEffectGain) / 2; + + AudioSynth_DMemMove(cmd++, DMEM_HAAS_TEMP, haasDmem, numSamplesPerUpdate * SAMPLE_SIZE); + + return cmd; +} + +Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem, + s32 resampleFlags) { + if (pitch == 0) { + AudioSynth_ClearBuffer(cmd++, DMEM_TEMP, size); + } else { + aSetBuffer(cmd++, 0, inpDmem, DMEM_TEMP, size); + aResample(cmd++, resampleFlags, pitch, synthState->synthesisBuffers->finalResampleState); + } + + return cmd; +} + +Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesPerUpdate, u16 dmemSrc, s32 haasEffectDelaySide, s32 flags) { + u32 dmemDests; + u16 curVolLeft; + u16 targetVolLeft; + s32 curReverbVol; + u16 curVolRight; + s16 targetReverbVol; + s16 rampLeft; + s16 rampRight; + s16 rampReverb; + s16 curReverbVolAndFlags; + u16 targetVolRight; + f32 defaultPanVolume; + s32 pad; + + targetReverbVol = sampleState->targetReverbVol; + + curVolLeft = synthState->curVolLeft; + curVolRight = synthState->curVolRight; + + targetVolLeft = sampleState->targetVolLeft; + targetVolLeft <<= 4; + targetVolRight = sampleState->targetVolRight; + targetVolRight <<= 4; + + if ((gAudioCtx.soundMode == SOUNDMODE_SURROUND) && (sampleState->surroundEffectIndex != 0xFF)) { + defaultPanVolume = gDefaultPanVolume[sampleState->surroundEffectIndex]; + targetVolLeft *= defaultPanVolume; + targetVolRight *= defaultPanVolume; + } + + if (targetVolLeft != curVolLeft) { + rampLeft = (targetVolLeft - curVolLeft) / (numSamplesPerUpdate >> 3); + } else { + rampLeft = 0; + } + + if (targetVolRight != curVolRight) { + rampRight = (targetVolRight - curVolRight) / (numSamplesPerUpdate >> 3); + } else { + rampRight = 0; + } + + curReverbVolAndFlags = synthState->curReverbVol; + curReverbVol = curReverbVolAndFlags & 0x7F; + + if (curReverbVolAndFlags != targetReverbVol) { + rampReverb = (((targetReverbVol & 0x7F) - curReverbVol) << 9) / (numSamplesPerUpdate >> 3); + synthState->curReverbVol = targetReverbVol; + } else { + rampReverb = 0; + } + + synthState->curVolLeft = curVolLeft + (rampLeft * (numSamplesPerUpdate >> 3)); + synthState->curVolRight = curVolRight + (rampRight * (numSamplesPerUpdate >> 3)); + + if (sampleState->bitField1.useHaasEffect) { + AudioSynth_ClearBuffer(cmd++, DMEM_HAAS_TEMP, DMEM_1CH_SIZE); + AudioSynth_EnvSetup1(cmd++, curReverbVol * 2, rampReverb, rampLeft, rampRight); + AudioSynth_EnvSetup2(cmd++, curVolLeft, curVolRight); + + switch (haasEffectDelaySide) { + case HAAS_EFFECT_DELAY_LEFT: + // Store the left dry channel in a temp space to be delayed to produce the haas effect + dmemDests = sEnvMixerLeftHaasDmemDests; + break; + + case HAAS_EFFECT_DELAY_RIGHT: + // Store the right dry channel in a temp space to be delayed to produce the haas effect + dmemDests = sEnvMixerRightHaasDmemDests; + break; + + default: // HAAS_EFFECT_DELAY_NONE + dmemDests = sEnvMixerDefaultDmemDests; + break; + } + } else { + aEnvSetup1(cmd++, curReverbVol * 2, rampReverb, rampLeft, rampRight); + aEnvSetup2(cmd++, curVolLeft, curVolRight); + dmemDests = sEnvMixerDefaultDmemDests; + } + + aEnvMixer(cmd++, dmemSrc, numSamplesPerUpdate, (curReverbVolAndFlags & 0x80) >> 7, + sampleState->bitField0.strongReverbRight, sampleState->bitField0.strongReverbLeft, + sampleState->bitField0.strongRight, sampleState->bitField0.strongLeft, dmemDests, sEnvMixerOp); + + return cmd; +} + +Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, + s32 numSamplesToLoad) { + s32 numSamplesAvailable; + s32 harmonicIndexCurAndPrev = sampleState->harmonicIndexCurAndPrev; + s32 samplePosInt = synthState->samplePosInt; + s32 numDuplicates; + + if (sampleState->bitField1.bookOffset != 0) { + // Move the noise wave (that reads compiled assembly as samples) from ram to dmem + AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, ALIGN16(numSamplesToLoad * SAMPLE_SIZE), gWaveSamples[8]); + // Offset the address for the samples read by gWaveSamples[8] to the next set of samples + gWaveSamples[8] += numSamplesToLoad * SAMPLE_SIZE; + + return cmd; + } else { + // Move the synthetic wave from ram to dmem + aLoadBuffer(cmd++, sampleState->waveSampleAddr, DMEM_UNCOMPRESSED_NOTE, WAVE_SAMPLE_COUNT * SAMPLE_SIZE); + + // If the harmonic changes, map the offset in the wave from one harmonic to another for continuity + if (harmonicIndexCurAndPrev != 0) { + samplePosInt = (samplePosInt * sNumSamplesPerWavePeriod[harmonicIndexCurAndPrev >> 2]) / + sNumSamplesPerWavePeriod[harmonicIndexCurAndPrev & 3]; + } + + // Offset in the WAVE_SAMPLE_COUNT samples of gWaveSamples to start processing the wave for continuity + samplePosInt = (u32)samplePosInt % WAVE_SAMPLE_COUNT; + // Number of samples in the initial WAVE_SAMPLE_COUNT samples available to be used to process + numSamplesAvailable = WAVE_SAMPLE_COUNT - samplePosInt; + + // Require duplicates if there are more samples to load than available + if (numSamplesToLoad > numSamplesAvailable) { + // Duplicate (copy) the WAVE_SAMPLE_COUNT samples as many times as needed to reach numSamplesToLoad. + // (numSamplesToLoad - numSamplesAvailable) is the number of samples missing. + // Divide by WAVE_SAMPLE_COUNT, rounding up, to get the amount of duplicates + numDuplicates = ((numSamplesToLoad - numSamplesAvailable + WAVE_SAMPLE_COUNT - 1) / WAVE_SAMPLE_COUNT); + if (numDuplicates != 0) { + aDuplicate(cmd++, numDuplicates, DMEM_UNCOMPRESSED_NOTE, + DMEM_UNCOMPRESSED_NOTE + (WAVE_SAMPLE_COUNT * SAMPLE_SIZE)); + } + } + synthState->samplePosInt = samplePosInt; + } + + return cmd; +} + +/** + * The Haas Effect gives directionality to sound by applying a small (< 35ms) delay to either the left or right channel. + * The delay is small enough that the sound is still perceived as one sound, but the channel that is not delayed will + * reach our ear first and give a sense of directionality. The sound is directed towards the opposite side of the delay. + */ +Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size, + s32 flags, s32 haasEffectDelaySide) { + u16 dmemDest; + u16 pitch; + u8 prevHaasEffectDelaySize; + u8 haasEffectDelaySize; + + switch (haasEffectDelaySide) { + case HAAS_EFFECT_DELAY_LEFT: + // Delay the sample on the left channel + // This allows the right channel to be heard first + dmemDest = DMEM_LEFT_CH; + haasEffectDelaySize = sampleState->haasEffectLeftDelaySize; + prevHaasEffectDelaySize = synthState->prevHaasEffectLeftDelaySize; + synthState->prevHaasEffectRightDelaySize = 0; + synthState->prevHaasEffectLeftDelaySize = haasEffectDelaySize; + break; + + case HAAS_EFFECT_DELAY_RIGHT: + // Delay the sample on the right channel + // This allows the left channel to be heard first + dmemDest = DMEM_RIGHT_CH; + haasEffectDelaySize = sampleState->haasEffectRightDelaySize; + prevHaasEffectDelaySize = synthState->prevHaasEffectRightDelaySize; + synthState->prevHaasEffectRightDelaySize = haasEffectDelaySize; + synthState->prevHaasEffectLeftDelaySize = 0; + break; + + default: // HAAS_EFFECT_DELAY_NONE + return cmd; + } + + if (flags != A_INIT) { + // Slightly adjust the sample rate in order to fit a change in sample delay + if (haasEffectDelaySize != prevHaasEffectDelaySize) { + pitch = (((size << 0xF) / 2) - 1) / ((size + haasEffectDelaySize - prevHaasEffectDelaySize - 2) / 2); + aSetBuffer(cmd++, 0, DMEM_HAAS_TEMP, DMEM_TEMP, size + haasEffectDelaySize - prevHaasEffectDelaySize); + aResampleZoh(cmd++, pitch, 0); + } else { + aDMEMMove(cmd++, DMEM_HAAS_TEMP, DMEM_TEMP, size); + } + + if (prevHaasEffectDelaySize != 0) { + aLoadBuffer(cmd++, synthState->synthesisBuffers->haasEffectDelayState, DMEM_HAAS_TEMP, + ALIGN16(prevHaasEffectDelaySize)); + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP + prevHaasEffectDelaySize, + size + haasEffectDelaySize - prevHaasEffectDelaySize); + } else { + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP, size + haasEffectDelaySize); + } + } else { + // Just apply a delay directly + aDMEMMove(cmd++, DMEM_HAAS_TEMP, DMEM_TEMP, size); + if (haasEffectDelaySize) { // != 0 + aClearBuffer(cmd++, DMEM_HAAS_TEMP, haasEffectDelaySize); + } + aDMEMMove(cmd++, DMEM_TEMP, DMEM_HAAS_TEMP + haasEffectDelaySize, size); + } + + if (haasEffectDelaySize) { // != 0 + // Save excessive samples for next iteration + aSaveBuffer(cmd++, DMEM_HAAS_TEMP + size, synthState->synthesisBuffers->haasEffectDelayState, + ALIGN16(haasEffectDelaySize)); + } + + aAddMixer(cmd++, ALIGN64(size), DMEM_HAAS_TEMP, dmemDest, 0x7FFF); + + return cmd; +} diff --git a/src/code/audio/audio_thread.c b/src/code/audio/audio_thread.c new file mode 100644 index 000000000..2b06281cc --- /dev/null +++ b/src/code/audio/audio_thread.c @@ -0,0 +1,977 @@ +/** + * @file audio_thread.c + * + * Top-level file that coordinates all audio code on the audio thread. + */ +#include "global.h" + +AudioTask* AudioThread_UpdateImpl(void); +void AudioThread_SetFadeOutTimer(s32 seqPlayerIndex, s32 fadeTimer); +void AudioThread_SetFadeInTimer(s32 seqPlayerIndex, s32 fadeTimer); +void AudioThread_ProcessCmds(u32 msg); +void AudioThread_ProcessSeqPlayerCmd(SequencePlayer* seqPlayer, AudioCmd* cmd); +void AudioThread_ProcessChannelCmd(SequenceChannel* channel, AudioCmd* cmd); +s32 AudioThread_GetSamplePos(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex, s32* loopEnd, s32* samplePosInt); +s32 AudioThread_CountAndReleaseNotes(s32 flags); + +AudioTask* AudioThread_Update(void) { + return AudioThread_UpdateImpl(); +} + +AudioTask* AudioThread_UpdateImpl(void) { + static AudioTask* sWaitingAudioTask = NULL; + u32 numSamplesRemainingInAi; + s32 numAbiCmds; + s32 pad; + s32 j; + s32 dmaCount; + s16* curAiBuffer; + OSTask_t* task; + s32 index; + u32 msg; + s32 validCount; + s32 i; + + gAudioCtx.totalTaskCount++; + if ((gAudioCtx.totalTaskCount % gAudioCtx.audioBufferParameters.specUnk4) != 0) { + if (gAudioCustomUpdateFunction != NULL) { + gAudioCustomUpdateFunction(); + } + + if (((gAudioCtx.totalTaskCount % gAudioCtx.audioBufferParameters.specUnk4) + 1) == + gAudioCtx.audioBufferParameters.specUnk4) { + return sWaitingAudioTask; + } + + return NULL; + } + + osSendMesg(gAudioCtx.taskStartQueueP, gAudioCtx.totalTaskCount, OS_MESG_NOBLOCK); + gAudioCtx.rspTaskIndex ^= 1; + gAudioCtx.curAiBufferIndex++; + gAudioCtx.curAiBufferIndex %= 3; + index = (gAudioCtx.curAiBufferIndex + 1) % 3; + + // Division converts size to numSamples: 2 channels (left/right) * 2 bytes per sample + numSamplesRemainingInAi = osAiGetLength() / (2 * SAMPLE_SIZE); + + if (gAudioCtx.resetTimer < 16) { + if (gAudioCtx.numSamplesPerFrame[index] != 0) { + osAiSetNextBuffer(gAudioCtx.aiBuffers[index], 2 * gAudioCtx.numSamplesPerFrame[index] * (s32)SAMPLE_SIZE); + if (gAudioCtx.aiBuffers[index]) {} + if (gAudioCtx.numSamplesPerFrame[index]) {} + } + } + + if (gAudioCustomUpdateFunction != NULL) { + gAudioCustomUpdateFunction(); + } + + dmaCount = gAudioCtx.curAudioFrameDmaCount; + for (i = 0; i < gAudioCtx.curAudioFrameDmaCount; i++) { + if (osRecvMesg(&gAudioCtx.curAudioFrameDmaQueue, NULL, OS_MESG_NOBLOCK) == 0) { + dmaCount--; + } + } + + if (dmaCount != 0) { + for (i = 0; i < dmaCount; i++) { + osRecvMesg(&gAudioCtx.curAudioFrameDmaQueue, NULL, OS_MESG_BLOCK); + } + } + + validCount = gAudioCtx.curAudioFrameDmaQueue.validCount; + if (validCount != 0) { + for (i = 0; i < validCount; i++) { + osRecvMesg(&gAudioCtx.curAudioFrameDmaQueue, NULL, OS_MESG_NOBLOCK); + } + } + + gAudioCtx.curAudioFrameDmaCount = 0; + AudioLoad_DecreaseSampleDmaTtls(); + AudioLoad_ProcessLoads(gAudioCtx.resetStatus); + AudioLoad_ProcessScriptLoads(); + + if (gAudioCtx.resetStatus != 0) { + if (AudioHeap_ResetStep() == 0) { + if (gAudioCtx.resetStatus == 0) { + osSendMesg(gAudioCtx.audioResetQueueP, gAudioCtx.specId, OS_MESG_NOBLOCK); + } + + sWaitingAudioTask = NULL; + return NULL; + } + } + + if (gAudioCtx.resetTimer > 16) { + return NULL; + } + if (gAudioCtx.resetTimer != 0) { + gAudioCtx.resetTimer++; + } + + gAudioCtx.curTask = &gAudioCtx.rspTask[gAudioCtx.rspTaskIndex]; + gAudioCtx.curAbiCmdBuf = gAudioCtx.abiCmdBufs[gAudioCtx.rspTaskIndex]; + + index = gAudioCtx.curAiBufferIndex; + curAiBuffer = gAudioCtx.aiBuffers[index]; + + gAudioCtx.numSamplesPerFrame[index] = + (s16)((((gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget - numSamplesRemainingInAi) + + (8 * SAMPLES_PER_FRAME)) & + ~0xF) + + (1 * SAMPLES_PER_FRAME)); + + // Clamp numSamplesPerFrame between numSamplesPerFrameMin and numSamplesPerFrameMax + if (gAudioCtx.numSamplesPerFrame[index] < gAudioCtx.audioBufferParameters.numSamplesPerFrameMin) { + gAudioCtx.numSamplesPerFrame[index] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMin; + } + if (gAudioCtx.numSamplesPerFrame[index] > gAudioCtx.audioBufferParameters.numSamplesPerFrameMax) { + gAudioCtx.numSamplesPerFrame[index] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMax; + } + + j = 0; + if (gAudioCtx.resetStatus == 0) { + // msg = 0000RREE R = read pos, E = End Pos + while (osRecvMesg(gAudioCtx.threadCmdProcQueueP, (OSMesg*)&msg, OS_MESG_NOBLOCK) != -1) { + //! FAKE: + if (1) {} + AudioThread_ProcessCmds(msg); + j++; + } + if ((j == 0) && gAudioCtx.threadCmdQueueFinished) { + AudioThread_ScheduleProcessCmds(); + } + } + + if (gAudioSPDataPtr == (u64*)gAudioCtx.curAbiCmdBuf) { + return -1; + } + + gAudioCtx.curAbiCmdBuf = + AudioSynth_Update(gAudioCtx.curAbiCmdBuf, &numAbiCmds, curAiBuffer, gAudioCtx.numSamplesPerFrame[index]); + + // Update audioRandom to the next random number + gAudioCtx.audioRandom = (gAudioCtx.audioRandom + gAudioCtx.totalTaskCount) * osGetCount(); + gAudioCtx.audioRandom = gAudioCtx.audioRandom + gAudioCtx.aiBuffers[index][gAudioCtx.totalTaskCount & 0xFF]; + + // gWaveSamples[8] interprets compiled assembly code as s16 samples as a way to generate sound with noise. + // Start with the address of AudioThread_Update(), and offset it by a random number between 0 - 0xFFF0 + // Use the resulting address as the starting address to interpret an array of samples i.e. `s16 samples[]` + gWaveSamples[8] = (s16*)((u8*)AudioThread_Update + (gAudioCtx.audioRandom & 0xFFF0)); + + index = gAudioCtx.rspTaskIndex; + gAudioCtx.curTask->taskQueue = NULL; + gAudioCtx.curTask->unk_44 = NULL; + + task = &gAudioCtx.curTask->task.t; + task->type = M_AUDTASK; + task->flags = 0; + task->ucodeBoot = aspMainTextStart; + task->ucodeBootSize = SP_UCODE_SIZE; + task->ucodeDataSize = ((aspMainDataEnd - aspMainDataStart) * sizeof(u64)) - 1; + task->ucode = aspMainTextStart; + task->ucodeData = aspMainDataStart; + task->ucodeSize = SP_UCODE_SIZE; + task->dramStack = (u64*)D_801D6200; + task->dramStackSize = 0; + task->outputBuff = NULL; + task->outputBuffSize = NULL; + if (1) {} + task->dataPtr = (u64*)gAudioCtx.abiCmdBufs[index]; + task->dataSize = numAbiCmds * sizeof(Acmd); + task->yieldDataPtr = NULL; + task->yieldDataSize = 0; + + if (gAudioCtx.numAbiCmdsMax < numAbiCmds) { + gAudioCtx.numAbiCmdsMax = numAbiCmds; + } + + if (gAudioCtx.audioBufferParameters.specUnk4 == 1) { + return gAudioCtx.curTask; + } else { + sWaitingAudioTask = gAudioCtx.curTask; + return NULL; + } +} + +void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) { + s32 i; + s32 pad; + + switch (cmd->op) { + case AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS: + AudioLoad_SyncLoadSeqParts(cmd->arg1, cmd->arg2, cmd->asInt, &gAudioCtx.externalLoadQueue); + break; + + case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER: + AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->arg1, cmd->arg2); + AudioThread_SetFadeInTimer(cmd->arg0, cmd->asInt); + break; + + case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS: + AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->arg1, cmd->asInt); + AudioThread_SetFadeInTimer(cmd->arg0, 500); + AudioSeq_SkipForwardSequence(&gAudioCtx.seqPlayers[cmd->arg0]); + break; + + case AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER: + if (gAudioCtx.seqPlayers[cmd->arg0].enabled) { + if (cmd->asInt == 0) { + AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[cmd->arg0]); + } else { + AudioThread_SetFadeOutTimer(cmd->arg0, cmd->asInt); + } + } + break; + + case AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE: + gAudioCtx.soundMode = cmd->asInt; + break; + + case AUDIOCMD_OP_GLOBAL_MUTE: + if (cmd->arg0 == AUDIOCMD_ALL_SEQPLAYERS) { + for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + gAudioCtx.seqPlayers[i].muted = true; + gAudioCtx.seqPlayers[i].recalculateVolume = true; + } + } else { + gAudioCtx.seqPlayers[cmd->arg0].muted = true; + gAudioCtx.seqPlayers[cmd->arg0].recalculateVolume = true; + } + break; + + case AUDIOCMD_OP_GLOBAL_UNMUTE: + if (cmd->asInt == true) { + for (i = 0; i < gAudioCtx.numNotes; i++) { + Note* note = &gAudioCtx.notes[i]; + NoteSampleState* noteSampleState = ¬e->sampleState; + + if (noteSampleState->bitField0.enabled && (note->playbackState.status == PLAYBACK_STATUS_0) && + (note->playbackState.parentLayer->channel->muteFlags & MUTE_FLAGS_STOP_SAMPLES)) { + noteSampleState->bitField0.finished = true; + } + } + } + + if (cmd->arg0 == AUDIOCMD_ALL_SEQPLAYERS) { + for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + gAudioCtx.seqPlayers[i].muted = false; + gAudioCtx.seqPlayers[i].recalculateVolume = true; + } + } else { + gAudioCtx.seqPlayers[cmd->arg0].muted = false; + gAudioCtx.seqPlayers[cmd->arg0].recalculateVolume = true; + } + + break; + + case AUDIOCMD_OP_GLOBAL_SYNC_LOAD_INSTRUMENT: + AudioLoad_SyncLoadInstrument(cmd->arg0, cmd->arg1, cmd->arg2); + break; + + case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK: + AudioLoad_AsyncLoadSampleBank(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue); + break; + + case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT: + AudioLoad_AsyncLoadFont(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue); + break; + + case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SEQ: + AudioLoad_AsyncLoadSeq(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue); + break; + + case AUDIOCMD_OP_GLOBAL_DISCARD_SEQ_FONTS: + AudioLoad_DiscardSeqFonts(cmd->arg1); + break; + + case AUDIOCMD_OP_GLOBAL_SET_CHANNEL_MASK: + gAudioCtx.threadCmdChannelMask[cmd->arg0] = cmd->asUShort; + break; + + case AUDIOCMD_OP_GLOBAL_RESET_AUDIO_HEAP: + gAudioCtx.resetStatus = 5; + gAudioCtx.specId = cmd->asUInt; + break; + + case AUDIOCMD_OP_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION: + gAudioCustomUpdateFunction = cmd->asUInt; + break; + + case AUDIOCMD_OP_GLOBAL_SET_CUSTOM_FUNCTION: + if (cmd->arg2 == AUDIO_CUSTOM_FUNCTION_REVERB) { + gAudioCustomReverbFunction = cmd->asUInt; + } else if (cmd->arg2 == AUDIO_CUSTOM_FUNCTION_SYNTH) { + gAudioCustomSynthFunction = cmd->asUInt; + } else { + gAudioCtx.customSeqFunctions[cmd->arg2] = cmd->asUInt; + } + break; + + case AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT: + case AUDIOCMD_OP_GLOBAL_SET_SFX_FONT: + case AUDIOCMD_OP_GLOBAL_SET_INSTRUMENT_FONT: + if (AudioPlayback_SetFontInstrument(cmd->op - AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT, cmd->arg1, cmd->arg2, + cmd->asInt)) {} + break; + + case AUDIOCMD_OP_GLOBAL_DISABLE_ALL_SEQPLAYERS: { + u32 flags = cmd->asUInt; + + if (flags == AUDIO_NOTE_RELEASE) { + for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) { + if (gAudioCtx.seqPlayers[i].enabled) { + AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[i]); + } + } + } + AudioThread_CountAndReleaseNotes(flags); + break; + } + + case AUDIOCMD_OP_GLOBAL_POP_PERSISTENT_CACHE: + AudioHeap_PopPersistentCache(cmd->asInt); + break; + + case AUDIOCMD_OP_GLOBAL_E5: + func_8018FA60(cmd->arg0, cmd->arg1, cmd->arg2, cmd->asInt); + break; + + case AUDIOCMD_OP_GLOBAL_SET_REVERB_DATA: + AudioHeap_SetReverbData(cmd->arg1, cmd->arg0, cmd->asInt, false); + break; + + default: + break; + } +} + +void AudioThread_SetFadeOutTimer(s32 seqPlayerIndex, s32 fadeTimer) { + SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex]; + + if (fadeTimer == 0) { + fadeTimer = 1; + } + + seqPlayer->fadeVelocity = -(seqPlayer->fadeVolume / fadeTimer); + seqPlayer->state = SEQPLAYER_STATE_FADE_OUT; + seqPlayer->fadeTimer = fadeTimer; +} + +void AudioThread_SetFadeInTimer(s32 seqPlayerIndex, s32 fadeTimer) { + SequencePlayer* seqPlayer; + + if (fadeTimer != 0) { + seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex]; + seqPlayer->state = SEQPLAYER_STATE_FADE_IN; + seqPlayer->storedFadeTimer = fadeTimer; + seqPlayer->fadeTimer = fadeTimer; + seqPlayer->fadeVolume = 0.0f; + seqPlayer->fadeVelocity = 0.0f; + } +} + +void AudioThread_InitMesgQueuesInternal(void) { + gAudioCtx.threadCmdWritePos = 0; + gAudioCtx.threadCmdReadPos = 0; + gAudioCtx.threadCmdQueueFinished = false; + + gAudioCtx.taskStartQueueP = &gAudioCtx.taskStartQueue; + gAudioCtx.threadCmdProcQueueP = &gAudioCtx.threadCmdProcQueue; + gAudioCtx.audioResetQueueP = &gAudioCtx.audioResetQueue; + + osCreateMesgQueue(gAudioCtx.taskStartQueueP, gAudioCtx.taskStartMsgs, ARRAY_COUNT(gAudioCtx.taskStartMsgs)); + osCreateMesgQueue(gAudioCtx.threadCmdProcQueueP, gAudioCtx.threadCmdProcMsgBuf, + ARRAY_COUNT(gAudioCtx.threadCmdProcMsgBuf)); + osCreateMesgQueue(gAudioCtx.audioResetQueueP, gAudioCtx.audioResetMesgs, ARRAY_COUNT(gAudioCtx.audioResetMesgs)); +} + +void AudioThread_QueueCmd(u32 opArgs, void** data) { + AudioCmd* cmd = &gAudioCtx.threadCmdBuf[gAudioCtx.threadCmdWritePos & 0xFF]; + + cmd->opArgs = opArgs; + cmd->data = *data; + + gAudioCtx.threadCmdWritePos++; + + if (gAudioCtx.threadCmdWritePos == gAudioCtx.threadCmdReadPos) { + gAudioCtx.threadCmdWritePos--; + } +} + +void AudioThread_QueueCmdF32(u32 opArgs, f32 data) { + AudioThread_QueueCmd(opArgs, (void**)&data); +} + +void AudioThread_QueueCmdS32(u32 opArgs, s32 data) { + AudioThread_QueueCmd(opArgs, (void**)&data); +} + +void AudioThread_QueueCmdS8(u32 opArgs, s8 data) { + u32 uData = data << 0x18; + + AudioThread_QueueCmd(opArgs, (void**)&uData); +} + +void AudioThread_QueueCmdU16(u32 opArgs, u16 data) { + u32 uData = data << 0x10; + + AudioThread_QueueCmd(opArgs, (void**)&uData); +} + +s32 AudioThread_ScheduleProcessCmds(void) { + static s32 sMaxWriteReadDiff = 0; + s32 ret; + + if (sMaxWriteReadDiff < (u8)((gAudioCtx.threadCmdWritePos - gAudioCtx.threadCmdReadPos) + 0x100)) { + sMaxWriteReadDiff = (u8)((gAudioCtx.threadCmdWritePos - gAudioCtx.threadCmdReadPos) + 0x100); + } + + ret = osSendMesg(gAudioCtx.threadCmdProcQueueP, + (void*)(((gAudioCtx.threadCmdReadPos & 0xFF) << 8) | (gAudioCtx.threadCmdWritePos & 0xFF)), + OS_MESG_NOBLOCK); + if (ret != -1) { + gAudioCtx.threadCmdReadPos = gAudioCtx.threadCmdWritePos; + ret = 0; + } else { + return -1; + } + + return ret; +} + +void AudioThread_ResetCmdQueue(void) { + gAudioCtx.threadCmdQueueFinished = false; + gAudioCtx.threadCmdReadPos = gAudioCtx.threadCmdWritePos; +} + +void AudioThread_ProcessCmd(AudioCmd* cmd) { + SequencePlayer* seqPlayer; + u16 threadCmdChannelMask; + s32 channelIndex; + + if ((cmd->op & 0xF0) >= 0xE0) { + AudioThread_ProcessGlobalCmd(cmd); + return; + } + + if (cmd->arg0 < gAudioCtx.audioBufferParameters.numSequencePlayers) { + seqPlayer = &gAudioCtx.seqPlayers[cmd->arg0]; + if (cmd->op & 0x80) { + AudioThread_ProcessGlobalCmd(cmd); + return; + } + + if (cmd->op & 0x40) { + AudioThread_ProcessSeqPlayerCmd(seqPlayer, cmd); + return; + } + + if (cmd->arg1 < SEQ_NUM_CHANNELS) { + AudioThread_ProcessChannelCmd(seqPlayer->channels[cmd->arg1], cmd); + return; + } + + if (cmd->arg1 == AUDIOCMD_ALL_CHANNELS) { + threadCmdChannelMask = gAudioCtx.threadCmdChannelMask[cmd->arg0]; + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + if (threadCmdChannelMask & 1) { + AudioThread_ProcessChannelCmd(seqPlayer->channels[channelIndex], cmd); + } + threadCmdChannelMask = threadCmdChannelMask >> 1; + } + } + } +} + +void AudioThread_ProcessCmds(u32 msg) { + static u8 sCurCmdRdPos = 0; + AudioCmd* cmd; + u8 endPos; + + if (!gAudioCtx.threadCmdQueueFinished) { + sCurCmdRdPos = msg >> 8; + } + + while (true) { + endPos = msg & 0xFF; + if (sCurCmdRdPos == endPos) { + gAudioCtx.threadCmdQueueFinished = false; + break; + } + + cmd = &gAudioCtx.threadCmdBuf[sCurCmdRdPos++ & 0xFF]; + if (cmd->op == AUDIOCMD_OP_GLOBAL_STOP_AUDIOCMDS) { + gAudioCtx.threadCmdQueueFinished = true; + break; + } + + AudioThread_ProcessCmd(cmd); + cmd->op = AUDIOCMD_OP_NOOP; + } +} + +u32 AudioThread_GetExternalLoadQueueMsg(u32* retMsg) { + u32 msg; + + if (osRecvMesg(&gAudioCtx.externalLoadQueue, (OSMesg*)&msg, OS_MESG_NOBLOCK) == -1) { + *retMsg = 0; + return 0; + } + + *retMsg = msg & 0xFFFFFF; + return msg >> 0x18; +} + +u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts) { + return AudioLoad_GetFontsForSequence(seqId, outNumFonts); +} + +void AudioThread_GetSampleBankIdsOfFont(s32 fontId, u32* sampleBankId1, u32* sampleBankId2) { + *sampleBankId1 = gAudioCtx.soundFontList[fontId].sampleBankId1; + *sampleBankId2 = gAudioCtx.soundFontList[fontId].sampleBankId2; +} + +s32 func_80193C5C(void) { + s32 pad; + s32 specId; + + if (osRecvMesg(gAudioCtx.audioResetQueueP, (OSMesg*)&specId, OS_MESG_NOBLOCK) == -1) { + return 0; + } else if (gAudioCtx.specId != specId) { + return -1; + } else { + return 1; + } +} + +void AudioThread_WaitForAudioResetQueueP(void) { + // macro? + // clang-format off + s32 chk = -1; s32 msg; do {} while (osRecvMesg(gAudioCtx.audioResetQueueP, (OSMesg*)&msg, OS_MESG_NOBLOCK) != chk); + // clang-format on +} + +s32 AudioThread_ResetAudioHeap(s32 specId) { + s32 resetStatus; + OSMesg msg; + s32 pad; + + AudioThread_WaitForAudioResetQueueP(); + resetStatus = gAudioCtx.resetStatus; + if (resetStatus != 0) { + AudioThread_ResetCmdQueue(); + if (gAudioCtx.specId == specId) { + return -2; + } else if (resetStatus > 2) { + gAudioCtx.specId = specId; + return -3; + } else { + osRecvMesg(gAudioCtx.audioResetQueueP, &msg, OS_MESG_BLOCK); + } + } + + AudioThread_WaitForAudioResetQueueP(); + AUDIOCMD_GLOBAL_RESET_AUDIO_HEAP(specId); + + return AudioThread_ScheduleProcessCmds(); +} + +void AudioThread_PreNMIInternal(void) { + gAudioCtx.resetTimer = 1; + if (gAudioCtxInitalized) { + AudioThread_ResetAudioHeap(0); + gAudioCtx.resetStatus = 0; + } +} + +// Unused +s8 AudioThread_GetChannelIO(s32 seqPlayerIndex, s32 channelIndex, s32 ioPort) { + SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex]; + SequenceChannel* channel; + + if (seqPlayer->enabled) { + channel = seqPlayer->channels[channelIndex]; + return channel->seqScriptIO[ioPort]; + } else { + return SEQ_IO_VAL_NONE; + } +} + +// Unused +s8 AudioThread_GetSeqPlayerIO(s32 seqPlayerIndex, s32 ioPort) { + return gAudioCtx.seqPlayers[seqPlayerIndex].seqScriptIO[ioPort]; +} + +// Unused +void AudioThread_InitExternalPool(void* addr, size_t size) { + AudioHeap_InitPool(&gAudioCtx.externalPool, addr, size); +} + +// Unused +void AudioThread_ResetExternalPool(void) { + gAudioCtx.externalPool.startAddr = NULL; +} + +void AudioThread_ProcessSeqPlayerCmd(SequencePlayer* seqPlayer, AudioCmd* cmd) { + f32 fadeVolume; + + switch (cmd->op) { + case AUDIOCMD_OP_SEQPLAYER_FADE_VOLUME_SCALE: + if (seqPlayer->fadeVolumeScale != cmd->asFloat) { + seqPlayer->fadeVolumeScale = cmd->asFloat; + seqPlayer->recalculateVolume = true; + } + break; + + case AUDIOCMD_OP_SEQPLAYER_SET_TEMPO: + seqPlayer->tempo = cmd->asInt * TATUMS_PER_BEAT; + break; + + case AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO: + seqPlayer->tempoChange = cmd->asInt * TATUMS_PER_BEAT; + break; + + case AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO_TICKS: + seqPlayer->tempoChange = cmd->asInt; + break; + + case AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION: + seqPlayer->transposition = cmd->asSbyte; + break; + + case AUDIOCMD_OP_SEQPLAYER_SET_IO: + seqPlayer->seqScriptIO[cmd->arg2] = cmd->asSbyte; + break; + + case AUDIOCMD_OP_SEQPLAYER_FADE_TO_SET_VOLUME: + fadeVolume = (s32)cmd->arg1 / 127.0f; + goto apply_fade; + + case AUDIOCMD_OP_SEQPLAYER_FADE_TO_SCALED_VOLUME: + fadeVolume = ((s32)cmd->arg1 / 100.0f) * seqPlayer->fadeVolume; + apply_fade: + if (seqPlayer->state != SEQPLAYER_STATE_FADE_OUT) { + seqPlayer->volume = seqPlayer->fadeVolume; + if (cmd->asInt == 0) { + seqPlayer->fadeVolume = fadeVolume; + } else { + s32 fadeTimer = cmd->asInt; + + seqPlayer->state = SEQPLAYER_STATE_0; + seqPlayer->fadeTimer = fadeTimer; + seqPlayer->fadeVelocity = (fadeVolume - seqPlayer->fadeVolume) / fadeTimer; + } + } + break; + + case AUDIOCMD_OP_SEQPLAYER_RESET_VOLUME: + if (seqPlayer->state != SEQPLAYER_STATE_FADE_OUT) { + if (cmd->asInt == 0) { + seqPlayer->fadeVolume = seqPlayer->volume; + } else { + s32 fadeTimer = cmd->asInt; + + seqPlayer->state = SEQPLAYER_STATE_0; + seqPlayer->fadeTimer = fadeTimer; + seqPlayer->fadeVelocity = (seqPlayer->volume - seqPlayer->fadeVolume) / fadeTimer; + } + } + break; + + case AUDIOCMD_OP_SEQPLAYER_SET_BEND: + seqPlayer->bend = cmd->asFloat; + if (seqPlayer->bend == 1.0f) { + seqPlayer->applyBend = false; + } else { + seqPlayer->applyBend = true; + } + break; + + default: + break; + } +} + +void AudioThread_ProcessChannelCmd(SequenceChannel* channel, AudioCmd* cmd) { + u8 filterCutoff; + + switch (cmd->op) { + case AUDIOCMD_OP_CHANNEL_SET_VOL_SCALE: + if (channel->volumeScale != cmd->asFloat) { + channel->volumeScale = cmd->asFloat; + channel->changes.s.volume = true; + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_VOL: + if (channel->volume != cmd->asFloat) { + channel->volume = cmd->asFloat; + channel->changes.s.volume = true; + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_PAN: + if (channel->newPan != cmd->asSbyte) { + channel->newPan = cmd->asSbyte; + channel->changes.s.pan = true; + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_PAN_WEIGHT: + if (channel->newPan != cmd->asSbyte) { + channel->panChannelWeight = cmd->asSbyte; + channel->changes.s.pan = true; + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_FREQ_SCALE: + if (channel->freqScale != cmd->asFloat) { + channel->freqScale = cmd->asFloat; + channel->changes.s.freqScale = true; + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_REVERB_VOLUME: + if (channel->targetReverbVol != cmd->asSbyte) { + channel->targetReverbVol = cmd->asSbyte; + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_REVERB_INDEX: + if (channel->reverbIndex != cmd->asSbyte) { + channel->reverbIndex = cmd->asSbyte; + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_SURROUND_EFFECT_INDEX: + channel->surroundEffectIndex = cmd->asSbyte; + break; + + case AUDIOCMD_OP_CHANNEL_SET_IO: + if (cmd->arg2 < ARRAY_COUNT(channel->seqScriptIO)) { + channel->seqScriptIO[cmd->arg2] = cmd->asSbyte; + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_MUTE: + channel->muted = cmd->asSbyte; + break; + + case AUDIOCMD_OP_CHANNEL_SET_MUTE_FLAGS: + channel->muteFlags = cmd->asSbyte; + break; + + case AUDIOCMD_OP_CHANNEL_SET_VIBRATO_DEPTH: + channel->vibrato.vibratoDepthTarget = cmd->asUbyte * 8; + channel->vibrato.vibratoDepthChangeDelay = 1; + break; + + case AUDIOCMD_OP_CHANNEL_SET_VIBRATO_RATE: + channel->vibrato.vibratoRateTarget = cmd->asUbyte * 32; + channel->vibrato.vibratoRateChangeDelay = 1; + break; + + case AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_SIZE: + channel->combFilterSize = cmd->asUbyte; + break; + + case AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_GAIN: + channel->combFilterGain = cmd->asUShort; + break; + + case AUDIOCMD_OP_CHANNEL_SET_STEREO: + channel->stereoData.asByte = cmd->asUbyte; + break; + + case AUDIOCMD_OP_CHANNEL_SET_SET_START_POS: + channel->startSamplePos = cmd->asInt; + break; + + case AUDIOCMD_OP_CHANNEL_SET_SFX_STATE: + channel->sfxState = cmd->asUInt; + break; + + case AUDIOCMD_OP_CHANNEL_SET_FILTER: + filterCutoff = cmd->arg2; + if (cmd->asUInt != 0) { + channel->filter = cmd->asUInt; + } + if (channel->filter != NULL) { + AudioHeap_LoadFilter(channel->filter, filterCutoff >> 4, filterCutoff & 0xF); + } + break; + + case AUDIOCMD_OP_CHANNEL_SET_GAIN: + channel->gain = cmd->asUbyte; + break; + + default: + break; + } +} + +/** + * Call an audio-thread command that has no code to process it. Unused. + */ +void AudioThread_Noop1Cmd(s32 arg0, s32 arg1, s32 arg2) { + AUDIOCMD_GLOBAL_NOOP_1(arg0, arg1, arg2, 1); +} + +/** + * Call an audio-thread command that has no code to process it. Unused. + */ +void AudioThread_Noop1CmdZeroed(void) { + AUDIOCMD_GLOBAL_NOOP_1(0, 0, 0, 0); +} + +/** + * Call an audio-thread command that has no code to process it. Unused. + */ +void AudioThread_Noop2Cmd(u32 arg0, s32 arg1) { + AUDIOCMD_GLOBAL_NOOP_2(0, 0, arg1, arg0); +} + +// Unused +void AudioThread_WaitForAudioTask(void) { + osRecvMesg(gAudioCtx.taskStartQueueP, NULL, OS_MESG_NOBLOCK); + osRecvMesg(gAudioCtx.taskStartQueueP, NULL, OS_MESG_BLOCK); +} + +/** + * Get the number of s16-samples from the start of the sample to the current sample position. + * Unused + */ +s32 AudioThread_GetSamplePosFromStart(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex) { + s32 pad; + s32 loopEnd; + s32 samplePosInt; + + if (!AudioThread_GetSamplePos(seqPlayerIndex, channelIndex, layerIndex, &loopEnd, &samplePosInt)) { + return 0; + } + return samplePosInt; +} + +/** + * Get the number of s16-samples from the current sample position to the end of the sample. + * Unused + */ +s32 AudioThread_GetSamplePosUntilEnd(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex) { + s32 pad; + s32 loopEnd; + s32 samplePosInt; + + if (!AudioThread_GetSamplePos(seqPlayerIndex, channelIndex, layerIndex, &loopEnd, &samplePosInt)) { + return 0; + } + return loopEnd - samplePosInt; +} + +// Only used in unused functions +s32 AudioThread_GetSamplePos(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex, s32* loopEnd, s32* samplePosInt) { + SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex]; + SequenceLayer* layer; + Note* note; + TunedSample* tunedSample; + + if (seqPlayer->enabled && seqPlayer->channels[channelIndex]->enabled) { + layer = seqPlayer->channels[channelIndex]->layers[layerIndex]; + if (layer == NULL) { + return false; + } + + if (layer->enabled) { + if (layer->note == NULL) { + return false; + } + + if (!layer->bit3) { + return false; + } + + note = layer->note; + if (layer == note->playbackState.parentLayer) { + + if (note->sampleState.bitField1.isSyntheticWave == true) { + return false; + } + + tunedSample = note->sampleState.tunedSample; + if (tunedSample == NULL) { + return false; + } + *loopEnd = tunedSample->sample->loop->loopEnd; + *samplePosInt = note->synthesisState.samplePosInt; + return true; + } + return false; + } + } + return false; +} + +s32 AudioThread_GetEnabledNotesCount(void) { + return AudioThread_CountAndReleaseNotes(0); +} + +s32 AudioThread_GetEnabledSampledNotesCount(void) { + return AudioThread_CountAndReleaseNotes(AUDIO_NOTE_SAMPLE_NOTES); +} + +/** + * @param flags 0: count notes. 1: release all notes. 2: count sample notes 3: release sample notes + * @return s32 number of notes + */ +s32 AudioThread_CountAndReleaseNotes(s32 flags) { + s32 noteCount; + NotePlaybackState* playbackState; + NoteSampleState* noteSampleState; + s32 i; + Note* note; + TunedSample* tunedSample; + + noteCount = 0; + for (i = 0; i < gAudioCtx.numNotes; i++) { + note = &gAudioCtx.notes[i]; + playbackState = ¬e->playbackState; + if (note->sampleState.bitField0.enabled) { + noteSampleState = ¬e->sampleState; + if (playbackState->adsr.action.s.state != ADSR_STATE_DISABLED) { + if (flags >= AUDIO_NOTE_SAMPLE_NOTES) { + tunedSample = noteSampleState->tunedSample; + if ((tunedSample == NULL) || noteSampleState->bitField1.isSyntheticWave) { + continue; + } + if (tunedSample->sample->medium == MEDIUM_RAM) { + continue; + } + } + + noteCount++; + if ((flags & AUDIO_NOTE_RELEASE) == AUDIO_NOTE_RELEASE) { + playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv; + playbackState->adsr.action.s.release = true; + } + } + } + } + return noteCount; +} + +u32 AudioThread_NextRandom(void) { + static u32 sAudioRandom = 0x12345678; + static u32 sAudioOsCount = 0x11111111; + u32 count = osGetCount(); + + sAudioRandom = (gAudioCtx.totalTaskCount + sAudioRandom + count) * (gAudioCtx.audioRandom + 0x1234567); + sAudioRandom = (sAudioRandom & 1) + (sAudioRandom * 2) + sAudioOsCount; + sAudioOsCount = count; + + return sAudioRandom; +} + +void AudioThread_InitMesgQueues(void) { + AudioThread_InitMesgQueuesInternal(); +} diff --git a/src/code/audio/code_80192BE0.c b/src/code/audio/code_80192BE0.c deleted file mode 100644 index 20b4239da..000000000 --- a/src/code/audio/code_80192BE0.c +++ /dev/null @@ -1,81 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80192BE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80192C00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019319C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801936D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019372C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193774.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019380C.s") - -#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/Audio_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/func_80193990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801939A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193AEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193BA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193CB4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193D08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193DA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193DF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E6C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193EA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801942BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194304.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194328.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019435C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019439C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801943D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019440C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194528.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194548.s") - -#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/Audio_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..801e2b076 100644 --- a/src/code/audio/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -5,12 +5,6 @@ typedef struct { /* 0x1 */ s8 y; } OcarinaControlStick; // size = 0x2 -typedef struct { - /* 0x0 */ u16 playerIO; - /* 0x2 */ u16 channelMask; - /* 0x4 */ u8 channelIO[3 * 33 + 1]; -} NatureAmbienceDataIO; // size = 0x68 - typedef struct { /* 0x0 */ Vec3f* pos; /* 0x4 */ f32 freqScale; @@ -18,15 +12,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,9 +60,31 @@ typedef struct { /* 0xC */ s32 remainingFrames; } FreqLerp; // size = 0x10 -s32 AudioOcarina_MemoryGameGenerateNotes(void); +s32 AudioOcarina_MemoryGameNextNote(void); + +void AudioSfx_ProcessSfxSettings(void); +void func_8019FEDC(void); +void Audio_StepFreqLerp(FreqLerp* lerp); + s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume); -void func_801A3238(s8 playerIndex, u16 seqId, u8 fadeTimer, s8 arg3, u8 arg4); + +void Audio_StartMorningSceneSequence(u16 seqId); +void Audio_StartSceneSequence(u16 seqId); +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData); +void func_801A4428(u8 reverbIndex); +void func_801A3038(void); +void Audio_PlayAmbience(u8 ambienceId); +void Audio_SetSfxVolumeExceptSystemAndOcarinaBanks(u8 volume); + +void Audio_UpdateRiverSoundVolumes(void); +void func_801A1290(void); +void func_801A1904(void); +void func_801A1E0C(void); +void func_801A2090(void); +void Audio_UpdateSceneSequenceResumePoint(void); +void func_801A312C(void); +void func_801A3AC0(void); +void Audio_ResetRequestedSceneSeqId(void); // Sfx bss SfxSettings sSfxSettings[8]; @@ -90,8 +106,8 @@ u8 sGanonsTowerVol; f32* sSfxVolumeCur; f32 sSfxVolumeTarget; f32 sSfxVolumeRate; -u16 sSceneSeqId1; -SfxPlayerState sSfxChannelState[16]; +u16 sRequestedSceneSeqId; +SfxChannelState sSfxChannelState[16]; // Sequence bss u8 D_801FD3A8; @@ -99,7 +115,7 @@ u8 D_801FD3A9; u8 sRiverSoundBgmTimer; u8 sFanfareState; u16 sFanfareSeqId; -u8 sMuteOnlySfxAndNatureSeq; +u8 sMuteOnlySfxAndAmbienceSeq; u8 sAllPlayersMutedExceptOcaAndSys; u8 sAudioPauseState; u8 sSpatialSeqIsActive[4]; @@ -125,24 +141,24 @@ u8 sSpatialSubBgmFadeTimer; u8 D_801FD434; u8 sSpatialSeqPlayerIndex; u8 sSpatialSeqFadeTimer; -u16 D_801FD438; +u16 sPrevAmbienceSeqId; // AudioOcarina bss 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 +166,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 +209,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; @@ -201,11 +218,14 @@ s8 sAudioCodeReverb = 0; // Sequence Data u8 sPrevSeqMode = 0; -f32 sAudioEnemyDist = 0.0f; -s8 sAudioEnemyVol = 127; +f32 sBgmEnemyDist = 0.0f; +s8 sBgmEnemyVolume = 127; u16 sPrevMainBgmSeqId = NA_BGM_DISABLED; -u8 sBgmPlayerIOPort7 = 0; -u8 sSceneSeqId2 = NA_BGM_GENERAL_SFX; + +#define SEQ_RESUME_POINT_NONE 0xC0 +u8 sSeqResumePoint = 0; +u8 sPrevSceneSeqId = NA_BGM_GENERAL_SFX; + u32 sNumFramesStill = 0; u32 sNumFramesMoving = 0; u8 sAudioBaseFilter = 0; @@ -216,768 +236,893 @@ s8 gUnderwaterSfxReverbAdd = 0; Vec3f* sRiverSoundBgmPos = NULL; f32 sRiverSoundXZDistToPlayer = 2000.0f; u8 sObjSoundMainBgmSeqId = NA_BGM_GENERAL_SFX; + +// Allows enemy bgm +#define SEQ_FLAG_ENEMY (1 << 0) + +#define SEQ_FLAG_FANFARE (1 << 1) +#define SEQ_FLAG_FANFARE_KAMARO (1 << 2) + +// required for Audio_RestorePrevBgm to restore a sequence after Audio_PlayBgm_StorePrevBgm +#define SEQ_FLAG_RESTORE (1 << 3) + +/** + * These two sequence flags work together to implement a “resume playing from where you left off” system for scene + * sequences when leaving and returning to a scene. For a scene to resume playing from the point where it left off, it + * must have `SEQ_FLAG_RESUME` attached to it. Then, if the scene changes and the new scene sequence contain + * `SEQ_FLAG_RESUME_PREV`, the point from the previous scene sequence will be stored. Then, when returning to the + * scene with the sequence `SEQ_FLAG_RESUME`, then the sequence will resume playing from where it left off. + * + * TODO: Confirm which sequences properly implement this system after sequence extraction + */ +#define SEQ_FLAG_RESUME (1 << 4) +#define SEQ_FLAG_RESUME_PREV (1 << 5) + +/** + * Will write a value of 1 to ioPort 7 when called through the scene. How it's used depends on the sequence: + * NA_BGM_FILE_SELECT - ioPort 7 skips the harp intro when a value of 1 is written to it. + */ +#define SEQ_FLAG_SKIP_HARP_INTRO (1 << 6) + +// Unused, repurposed for SubBgm +#define SEQ_FLAG_NO_AMBIENCE (1 << 7) + u8 sSeqFlags[] = { - 0x3, // NA_BGM_GENERAL_SFX - 0x1, // NA_BGM_NATURE_AMBIENCE - 0x1, // NA_BGM_TERMINA_FIELD - 0x8, // NA_BGM_CHASE - 0, // NA_BGM_MAJORAS_THEME - 0, // NA_BGM_CLOCK_TOWER - 0x1, // NA_BGM_STONE_TOWER_TEMPLE - 0x1, // NA_BGM_INV_STONE_TOWER_TEMPLE - 0x2, // NA_BGM_FAILURE_0 - 0x2, // NA_BGM_FAILURE_1 - 0, // NA_BGM_HAPPY_MASK_SALESMAN - 0, // NA_BGM_SONG_OF_HEALING - 0x1, // NA_BGM_SWAMP_REGION - 0, // NA_BGM_ALIEN_INVASION - 0x2, // NA_BGM_SWAMP_CRUISE - 0, // NA_BGM_SHARPS_CURSE - 0x1, // NA_BGM_GREAT_BAY_REGION - 0x1, // NA_BGM_IKANA_REGION - 0, // NA_BGM_DEKU_KING - 0x1, // NA_BGM_MOUNTAIN_REGION - 0, // NA_BGM_PIRATES_FORTRESS - 0, // NA_BGM_CLOCK_TOWN_DAY_1 - 0, // NA_BGM_CLOCK_TOWN_DAY_2 - 0, // NA_BGM_CLOCK_TOWN_DAY_3 - 0x40, // NA_BGM_FILE_SELECT - 0x10, // NA_BGM_CLEAR_EVENT - 0, // NA_BGM_ENEMY - 0x8, // NA_BGM_BOSS - 0x1, // NA_BGM_WOODFALL_TEMPLE - 0, // NA_BGM_MARKET - 0, // NA_BGM_OPENING - 0x20, // NA_BGM_INSIDE_A_HOUSE - 0x2, // NA_BGM_GAME_OVER - 0, // NA_BGM_CLEAR_BOSS - 0x2, // NA_BGM_GET_ITEM - 0x2, // NA_BGM_GATE_OPEN - 0x2, // NA_BGM_GET_HEART - 0x8, // NA_BGM_TIMED_MINI_GAME - 0, // NA_BGM_GORON_RACE - 0, // NA_BGM_MUSIC_BOX_HOUSE - 0, // NA_BGM_FAIRY_FOUNTAIN - 0, // NA_BGM_ZELDAS_LULLABY - 0, // NA_BGM_ROSA_SISTERS - 0x2, // NA_BGM_OPEN_CHEST - 0, // NA_BGM_MARINE_RESEARCH_LAB - 0x40, // NA_BGM_GIANTS_THEME - 0, // NA_BGM_SONG_OF_STORMS - 0, // NA_BGM_ROMANI_RANCH - 0, // NA_BGM_GORON_VILLAGE - 0, // NA_BGM_MAYORS_OFFICE - 0x2, // NA_BGM_OCA_EPONA - 0x2, // NA_BGM_OCA_SUNS - 0x2, // NA_BGM_OCA_TIME - 0x2, // NA_BGM_OCA_STORM - 0x10, // NA_BGM_ZORA_HALL - 0x2, // NA_BGM_GET_NEW_MASK - 0x8, // NA_BGM_MINI_BOSS - 0x2, // NA_BGM_GET_SMALL_ITEM - 0, // NA_BGM_ASTRAL_OBSERVATORY - 0x1, // NA_BGM_CAVERN - 0x11, // NA_BGM_MILK_BAR - 0x2, // NA_BGM_ZELDA_APPEAR - 0, // NA_BGM_SARIAS_SONG - 0, // NA_BGM_GORON_GOAL - 0, // NA_BGM_HORSE - 0, // NA_BGM_HORSE_GOAL - 0, // NA_BGM_INGO - 0, // NA_BGM_KOTAKE_POTION_SHOP - 0x20, // NA_BGM_SHOP - 0x2, // NA_BGM_OWL - 0x20, // NA_BGM_MINI_GAME - 0x2, // NA_BGM_OCA_SOARING - 0x2, // NA_BGM_OCA_HEALING - 0x2, // NA_BGM_INVERTED_SONG_OF_TIME - 0x2, // NA_BGM_SONG_OF_DOUBLE_TIME - 0x2, // NA_BGM_SONATA_OF_AWAKENING - 0x2, // NA_BGM_GORON_LULLABY - 0x2, // NA_BGM_NEW_WAVE_BOSSA_NOVA - 0x2, // NA_BGM_ELEGY_OF_EMPTINESS - 0x2, // NA_BGM_OATH_TO_ORDER - 0, // NA_BGM_SWORD_TRAINING_HALL - 0x2, // NA_BGM_GORON_LULLABY_INTRO - 0x2, // NA_BGM_OCA_FAIRY - 0x2, // NA_BGM_BREMEN_MARCH - 0x2, // NA_BGM_BALLAD_OF_THE_WIND_FISH - 0x8, // NA_BGM_SONG_OF_SOARING - 0, // NA_BGM_MILK_BAR_DUPLICATE - 0, // NA_BGM_FINAL_HOURS - 0x2, // NA_BGM_MIKAU_RIFF - 0x2, // NA_BGM_MIKAU_FINALE - 0, // NA_BGM_FROG_SONG - 0x2, // NA_BGM_OCA_SONATA - 0x2, // NA_BGM_OCA_LULLABY - 0x2, // NA_BGM_OCA_NEW_WAVE - 0x2, // NA_BGM_OCA_ELEGY - 0x2, // NA_BGM_OCA_OATH - 0, // NA_BGM_MAJORAS_LAIR - 0x2, // NA_BGM_OCA_LULLABY_INTRO - 0x2, // NA_BGM_OCA_GUITAR_BASS_SESSION - 0x2, // NA_BGM_PIANO_SESSION - 0x2, // NA_BGM_INDIGO_GO_SESSION - 0x1, // NA_BGM_SNOWHEAD_TEMPLE - 0x1, // NA_BGM_GREAT_BAY_TEMPLE - 0x2, // NA_BGM_NEW_WAVE_SAXOPHONE - 0x2, // NA_BGM_NEW_WAVE_VOCAL - 0, // NA_BGM_MAJORAS_WRATH - 0, // NA_BGM_MAJORAS_INCARNATION - 0, // NA_BGM_MAJORAS_MASK - 0x2, // NA_BGM_BASS_PLAY - 0x2, // NA_BGM_DRUMS_PLAY - 0x2, // NA_BGM_PIANO_PLAY - 0x1, // NA_BGM_IKANA_CASTLE - 0, // NA_BGM_GATHERING_GIANTS - 0x4, // NA_BGM_KAMARO_DANCE - 0, // NA_BGM_CREMIA_CARRIAGE - 0x2, // NA_BGM_KEATON_QUIZ - 0, // NA_BGM_END_CREDITS_1 - 0, // NA_BGM_OPENING_LOOP - 0, // NA_BGM_TITLE_THEME - 0x2, // NA_BGM_DUNGEON_APPEAR - 0x2, // NA_BGM_WOODFALL_CLEAR - 0x2, // NA_BGM_SNOWHEAD_CLEAR - 0, // - 0, // NA_BGM_INTO_THE_MOON - 0, // NA_BGM_GOODBYE_GIANT - 0, // NA_BGM_TATL_AND_TAEL - 0, // NA_BGM_MOONS_DESTRUCTION - 0, // NA_BGM_END_CREDITS_2 + SEQ_FLAG_FANFARE | SEQ_FLAG_ENEMY, // NA_BGM_GENERAL_SFX + SEQ_FLAG_ENEMY, // NA_BGM_AMBIENCE + SEQ_FLAG_ENEMY, // NA_BGM_TERMINA_FIELD + SEQ_FLAG_RESTORE, // NA_BGM_CHASE + 0, // NA_BGM_MAJORAS_THEME + 0, // NA_BGM_CLOCK_TOWER + SEQ_FLAG_ENEMY, // NA_BGM_STONE_TOWER_TEMPLE + SEQ_FLAG_ENEMY, // NA_BGM_INV_STONE_TOWER_TEMPLE + SEQ_FLAG_FANFARE, // NA_BGM_FAILURE_0 + SEQ_FLAG_FANFARE, // NA_BGM_FAILURE_1 + 0, // NA_BGM_HAPPY_MASK_SALESMAN + 0, // NA_BGM_SONG_OF_HEALING + SEQ_FLAG_ENEMY, // NA_BGM_SWAMP_REGION + 0, // NA_BGM_ALIEN_INVASION + SEQ_FLAG_FANFARE, // NA_BGM_SWAMP_CRUISE + 0, // NA_BGM_SHARPS_CURSE + SEQ_FLAG_ENEMY, // NA_BGM_GREAT_BAY_REGION + SEQ_FLAG_ENEMY, // NA_BGM_IKANA_REGION + 0, // NA_BGM_DEKU_KING + SEQ_FLAG_ENEMY, // NA_BGM_MOUNTAIN_REGION + 0, // NA_BGM_PIRATES_FORTRESS + 0, // NA_BGM_CLOCK_TOWN_DAY_1 + 0, // NA_BGM_CLOCK_TOWN_DAY_2 + 0, // NA_BGM_CLOCK_TOWN_DAY_3 + SEQ_FLAG_SKIP_HARP_INTRO, // NA_BGM_FILE_SELECT + SEQ_FLAG_RESUME, // NA_BGM_CLEAR_EVENT + 0, // NA_BGM_ENEMY + SEQ_FLAG_RESTORE, // NA_BGM_BOSS + SEQ_FLAG_ENEMY, // NA_BGM_WOODFALL_TEMPLE + 0, // NA_BGM_MARKET + 0, // NA_BGM_OPENING + SEQ_FLAG_RESUME_PREV, // NA_BGM_INSIDE_A_HOUSE + SEQ_FLAG_FANFARE, // NA_BGM_GAME_OVER + 0, // NA_BGM_CLEAR_BOSS + SEQ_FLAG_FANFARE, // NA_BGM_GET_ITEM + SEQ_FLAG_FANFARE, // NA_BGM_GATE_OPEN + SEQ_FLAG_FANFARE, // NA_BGM_GET_HEART + SEQ_FLAG_RESTORE, // NA_BGM_TIMED_MINI_GAME + 0, // NA_BGM_GORON_RACE + 0, // NA_BGM_MUSIC_BOX_HOUSE + 0, // NA_BGM_FAIRY_FOUNTAIN + 0, // NA_BGM_ZELDAS_LULLABY + 0, // NA_BGM_ROSA_SISTERS + SEQ_FLAG_FANFARE, // NA_BGM_OPEN_CHEST + 0, // NA_BGM_MARINE_RESEARCH_LAB + SEQ_FLAG_SKIP_HARP_INTRO, // NA_BGM_GIANTS_THEME + 0, // NA_BGM_SONG_OF_STORMS + 0, // NA_BGM_ROMANI_RANCH + 0, // NA_BGM_GORON_VILLAGE + 0, // NA_BGM_MAYORS_OFFICE + SEQ_FLAG_FANFARE, // NA_BGM_OCA_EPONA + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SUNS + SEQ_FLAG_FANFARE, // NA_BGM_OCA_TIME + SEQ_FLAG_FANFARE, // NA_BGM_OCA_STORM + SEQ_FLAG_RESUME, // NA_BGM_ZORA_HALL + SEQ_FLAG_FANFARE, // NA_BGM_GET_NEW_MASK + SEQ_FLAG_RESTORE, // NA_BGM_MINI_BOSS + SEQ_FLAG_FANFARE, // NA_BGM_GET_SMALL_ITEM + 0, // NA_BGM_ASTRAL_OBSERVATORY + SEQ_FLAG_ENEMY, // NA_BGM_CAVERN + SEQ_FLAG_RESUME | SEQ_FLAG_ENEMY, // NA_BGM_MILK_BAR + SEQ_FLAG_FANFARE, // NA_BGM_ZELDA_APPEAR + 0, // NA_BGM_SARIAS_SONG + 0, // NA_BGM_GORON_GOAL + 0, // NA_BGM_HORSE + 0, // NA_BGM_HORSE_GOAL + 0, // NA_BGM_INGO + 0, // NA_BGM_KOTAKE_POTION_SHOP + SEQ_FLAG_RESUME_PREV, // NA_BGM_SHOP + SEQ_FLAG_FANFARE, // NA_BGM_OWL + SEQ_FLAG_RESUME_PREV, // NA_BGM_MINI_GAME + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SOARING + SEQ_FLAG_FANFARE, // NA_BGM_OCA_HEALING + SEQ_FLAG_FANFARE, // NA_BGM_INVERTED_SONG_OF_TIME + SEQ_FLAG_FANFARE, // NA_BGM_SONG_OF_DOUBLE_TIME + SEQ_FLAG_FANFARE, // NA_BGM_SONATA_OF_AWAKENING + SEQ_FLAG_FANFARE, // NA_BGM_GORON_LULLABY + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_BOSSA_NOVA + SEQ_FLAG_FANFARE, // NA_BGM_ELEGY_OF_EMPTINESS + SEQ_FLAG_FANFARE, // NA_BGM_OATH_TO_ORDER + 0, // NA_BGM_SWORD_TRAINING_HALL + SEQ_FLAG_FANFARE, // NA_BGM_GORON_LULLABY_INTRO + SEQ_FLAG_FANFARE, // NA_BGM_OCA_FAIRY + SEQ_FLAG_FANFARE, // NA_BGM_BREMEN_MARCH + SEQ_FLAG_FANFARE, // NA_BGM_BALLAD_OF_THE_WIND_FISH + SEQ_FLAG_RESTORE, // NA_BGM_SONG_OF_SOARING + 0, // NA_BGM_MILK_BAR_DUPLICATE + 0, // NA_BGM_FINAL_HOURS + SEQ_FLAG_FANFARE, // NA_BGM_MIKAU_RIFF + SEQ_FLAG_FANFARE, // NA_BGM_MIKAU_FINALE + 0, // NA_BGM_FROG_SONG + SEQ_FLAG_FANFARE, // NA_BGM_OCA_SONATA + SEQ_FLAG_FANFARE, // NA_BGM_OCA_LULLABY + SEQ_FLAG_FANFARE, // NA_BGM_OCA_NEW_WAVE + SEQ_FLAG_FANFARE, // NA_BGM_OCA_ELEGY + SEQ_FLAG_FANFARE, // NA_BGM_OCA_OATH + 0, // NA_BGM_MAJORAS_LAIR + SEQ_FLAG_FANFARE, // NA_BGM_OCA_LULLABY_INTRO + SEQ_FLAG_FANFARE, // NA_BGM_OCA_GUITAR_BASS_SESSION + SEQ_FLAG_FANFARE, // NA_BGM_PIANO_SESSION + SEQ_FLAG_FANFARE, // NA_BGM_INDIGO_GO_SESSION + SEQ_FLAG_ENEMY, // NA_BGM_SNOWHEAD_TEMPLE + SEQ_FLAG_ENEMY, // NA_BGM_GREAT_BAY_TEMPLE + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_SAXOPHONE + SEQ_FLAG_FANFARE, // NA_BGM_NEW_WAVE_VOCAL + 0, // NA_BGM_MAJORAS_WRATH + 0, // NA_BGM_MAJORAS_INCARNATION + 0, // NA_BGM_MAJORAS_MASK + SEQ_FLAG_FANFARE, // NA_BGM_BASS_PLAY + SEQ_FLAG_FANFARE, // NA_BGM_DRUMS_PLAY + SEQ_FLAG_FANFARE, // NA_BGM_PIANO_PLAY + SEQ_FLAG_ENEMY, // NA_BGM_IKANA_CASTLE + 0, // NA_BGM_GATHERING_GIANTS + SEQ_FLAG_FANFARE_KAMARO, // NA_BGM_KAMARO_DANCE + 0, // NA_BGM_CREMIA_CARRIAGE + SEQ_FLAG_FANFARE, // NA_BGM_KEATON_QUIZ + 0, // NA_BGM_END_CREDITS_1 + 0, // NA_BGM_OPENING_LOOP + 0, // NA_BGM_TITLE_THEME + SEQ_FLAG_FANFARE, // NA_BGM_DUNGEON_APPEAR + SEQ_FLAG_FANFARE, // NA_BGM_WOODFALL_CLEAR + SEQ_FLAG_FANFARE, // NA_BGM_SNOWHEAD_CLEAR + 0, // + 0, // NA_BGM_INTO_THE_MOON + 0, // NA_BGM_GOODBYE_GIANT + 0, // NA_BGM_TATL_AND_TAEL + 0, // NA_BGM_MOONS_DESTRUCTION + 0, // NA_BGM_END_CREDITS_2 }; -s8 sSpecReverbs[20] = { +s8 sSpecReverbs[] = { 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -NatureAmbienceDataIO sNatureAmbienceData[20] = { - // natureSeqId: 0 +#define AMBIENCE_CHANNEL_PROPERTIES_ENTRIES_MAX 33 + +typedef struct { + /* 0x0 */ u16 initChannelMask; // bitwise flag for 16 channels, channels to initialize + /* 0x2 */ u16 initMuteChannelMask; // bitwise flag for 16 channels, channels to mute upon initialization + /* 0x4 */ u8 channelProperties[3 * AMBIENCE_CHANNEL_PROPERTIES_ENTRIES_MAX + 1]; +} AmbienceDataIO; // size = 0x68 + +AmbienceDataIO sAmbienceData[20] = { + // AMBIENCE_ID_00 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_1_BEND_PITCH(0), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), - NATURE_IO_CRITTER_2_BEND_PITCH(112), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(48), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(48), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), - NATURE_IO_CRITTER_3_BEND_PITCH(127), - NATURE_IO_CRITTER_3_NUM_LAYERS(0), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_03), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(3), - NATURE_IO_CRITTER_5_PORT5(16), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 1 + // AMBIENCE_ID_01 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_16), - NATURE_IO_CRITTER_1_BEND_PITCH(0), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_16), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), - NATURE_IO_CRITTER_2_BEND_PITCH(112), - NATURE_IO_CRITTER_2_NUM_LAYERS(0), - NATURE_IO_CRITTER_2_PORT5(48), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_2_PORT5(48), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_15), - NATURE_IO_CRITTER_3_BEND_PITCH(127), - NATURE_IO_CRITTER_3_NUM_LAYERS(1), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_06), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_06), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(3), - NATURE_IO_CRITTER_5_PORT5(16), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 2 + // AMBIENCE_ID_02 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(48), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(48), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_10), - NATURE_IO_CRITTER_1_BEND_PITCH(0), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_2_BEND_PITCH(48), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(32), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(32), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_03), - NATURE_IO_CRITTER_3_BEND_PITCH(127), - NATURE_IO_CRITTER_3_NUM_LAYERS(0), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_03), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_4_BEND_PITCH(64), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(0), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(0), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(0), - NATURE_IO_CRITTER_5_PORT5(63), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(63), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 3 + // AMBIENCE_ID_03 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_1_BEND_PITCH(64), - NATURE_IO_CRITTER_1_NUM_LAYERS(0), - NATURE_IO_CRITTER_1_PORT5(48), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_1_PORT5(48), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), - NATURE_IO_CRITTER_2_BEND_PITCH(32), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(32), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(32), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(32), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), - NATURE_IO_CRITTER_3_BEND_PITCH(64), - NATURE_IO_CRITTER_3_NUM_LAYERS(1), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_14), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(3), - NATURE_IO_CRITTER_5_PORT5(16), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 4 + // AMBIENCE_ID_04 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_02), - NATURE_IO_CRITTER_1_BEND_PITCH(64), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_12), - NATURE_IO_CRITTER_2_BEND_PITCH(112), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(48), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(48), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), - NATURE_IO_CRITTER_3_BEND_PITCH(64), - NATURE_IO_CRITTER_3_NUM_LAYERS(1), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_13), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_4_BEND_PITCH(64), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), - NATURE_IO_CRITTER_5_BEND_PITCH(112), - NATURE_IO_CRITTER_5_NUM_LAYERS(0), - NATURE_IO_CRITTER_5_PORT5(48), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(48), // Channel 14 - NATURE_IO_RAIN_PORT4(63), + AMBIENCE_IO_RAIN_PORT4(63), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 5 + // AMBIENCE_ID_05 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_09), - NATURE_IO_CRITTER_0_BEND_PITCH(64), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(32), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_09), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(64), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(32), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_1_BEND_PITCH(0), - NATURE_IO_CRITTER_1_NUM_LAYERS(1), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_10), - NATURE_IO_CRITTER_2_BEND_PITCH(112), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(48), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_10), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(48), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_13), - NATURE_IO_CRITTER_3_BEND_PITCH(127), - NATURE_IO_CRITTER_3_NUM_LAYERS(0), - NATURE_IO_CRITTER_3_PORT5(63), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_13), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_3_PORT5(63), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(1), - NATURE_IO_CRITTER_4_PORT5(16), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_4_PORT5(16), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(3), - NATURE_IO_CRITTER_5_PORT5(16), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_5_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 6 + // AMBIENCE_ID_06 { - 0xC0FF, // PlayerIO Data - 0xC0FE, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | + (1 << AMBIENCE_CHANNEL_CRITTER_5) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | (1 << AMBIENCE_CHANNEL_CRITTER_2) | + (1 << AMBIENCE_CHANNEL_CRITTER_3) | (1 << AMBIENCE_CHANNEL_CRITTER_4) | (1 << AMBIENCE_CHANNEL_CRITTER_5) | + (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_11), - NATURE_IO_CRITTER_0_BEND_PITCH(112), - NATURE_IO_CRITTER_0_NUM_LAYERS(0), - NATURE_IO_CRITTER_0_PORT5(48), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_0_PORT5(48), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_15), - NATURE_IO_CRITTER_1_BEND_PITCH(112), - NATURE_IO_CRITTER_1_NUM_LAYERS(0), - NATURE_IO_CRITTER_1_PORT5(63), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_1_PORT5(63), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_11), - NATURE_IO_CRITTER_2_BEND_PITCH(48), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(16), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(16), // Channel 4 - NATURE_IO_CRITTER_3_TYPE(NATURE_CRITTER_14), - NATURE_IO_CRITTER_3_BEND_PITCH(48), - NATURE_IO_CRITTER_3_NUM_LAYERS(1), - NATURE_IO_CRITTER_3_PORT5(16), + AMBIENCE_IO_CRITTER_3_TYPE(AMBIENCE_CRITTER_14), + AMBIENCE_IO_CRITTER_3_BEND_PITCH(48), + AMBIENCE_IO_CRITTER_3_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_3_PORT5(16), // Channel 5 - NATURE_IO_CRITTER_4_TYPE(NATURE_CRITTER_11), - NATURE_IO_CRITTER_4_BEND_PITCH(127), - NATURE_IO_CRITTER_4_NUM_LAYERS(0), - NATURE_IO_CRITTER_4_PORT5(32), + AMBIENCE_IO_CRITTER_4_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_4_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_4_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_4_PORT5(32), // Channel 6 - NATURE_IO_CRITTER_5_TYPE(NATURE_CRITTER_02), - NATURE_IO_CRITTER_5_BEND_PITCH(127), - NATURE_IO_CRITTER_5_NUM_LAYERS(0), - NATURE_IO_CRITTER_5_PORT5(48), + AMBIENCE_IO_CRITTER_5_TYPE(AMBIENCE_CRITTER_02), + AMBIENCE_IO_CRITTER_5_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_5_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_5_PORT5(48), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 7 + // AMBIENCE_ID_07 { - 0xC001, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 8 + // AMBIENCE_ID_08 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_0_BEND_PITCH(127), - NATURE_IO_CRITTER_0_NUM_LAYERS(3), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 9 + // AMBIENCE_ID_09 { - 0xC00F, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_16), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(2), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_16), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(2), + AMBIENCE_IO_CRITTER_0_PORT5(16), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_12), - NATURE_IO_CRITTER_1_BEND_PITCH(112), - NATURE_IO_CRITTER_1_NUM_LAYERS(0), - NATURE_IO_CRITTER_1_PORT5(48), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_12), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(0), + AMBIENCE_IO_CRITTER_1_PORT5(48), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_15), - NATURE_IO_CRITTER_2_BEND_PITCH(127), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(16), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_15), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 10 + // AMBIENCE_ID_0A { - 0xC081, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_6) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_1), - NATURE_IO_STREAM_0_PORT3(8), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_1), + AMBIENCE_IO_STREAM_0_PORT3(8), // Channel 7 - NATURE_IO_CRITTER_6_TYPE(NATURE_CRITTER_11), - NATURE_IO_CRITTER_6_BEND_PITCH(112), - NATURE_IO_CRITTER_6_NUM_LAYERS(2), - NATURE_IO_CRITTER_6_PORT5(32), + AMBIENCE_IO_CRITTER_6_TYPE(AMBIENCE_CRITTER_11), + AMBIENCE_IO_CRITTER_6_BEND_PITCH(112), + AMBIENCE_IO_CRITTER_6_NUM_LAYERS(2), + AMBIENCE_IO_CRITTER_6_PORT5(32), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 11 + // AMBIENCE_ID_0B { - 0xC00F, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_CRITTER_2) | (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_3), - NATURE_IO_STREAM_0_PORT3(8), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_3), + AMBIENCE_IO_STREAM_0_PORT3(8), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_0_BEND_PITCH(127), - NATURE_IO_CRITTER_0_NUM_LAYERS(3), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_0_PORT5(16), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_1_BEND_PITCH(127), - NATURE_IO_CRITTER_1_NUM_LAYERS(2), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(2), + AMBIENCE_IO_CRITTER_1_PORT5(16), // Channel 3 - NATURE_IO_CRITTER_2_TYPE(NATURE_CRITTER_06), - NATURE_IO_CRITTER_2_BEND_PITCH(127), - NATURE_IO_CRITTER_2_NUM_LAYERS(1), - NATURE_IO_CRITTER_2_PORT5(16), + AMBIENCE_IO_CRITTER_2_TYPE(AMBIENCE_CRITTER_06), + AMBIENCE_IO_CRITTER_2_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_2_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_2_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 12 + // AMBIENCE_ID_0C { - 0xC007, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_CRITTER_1) | + (1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_00), - NATURE_IO_CRITTER_0_BEND_PITCH(127), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_00), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // Channel 2 - NATURE_IO_CRITTER_1_TYPE(NATURE_CRITTER_01), - NATURE_IO_CRITTER_1_BEND_PITCH(127), - NATURE_IO_CRITTER_1_NUM_LAYERS(3), - NATURE_IO_CRITTER_1_PORT5(16), + AMBIENCE_IO_CRITTER_1_TYPE(AMBIENCE_CRITTER_01), + AMBIENCE_IO_CRITTER_1_BEND_PITCH(127), + AMBIENCE_IO_CRITTER_1_NUM_LAYERS(3), + AMBIENCE_IO_CRITTER_1_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 13 + // AMBIENCE_ID_0D { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 14 + // AMBIENCE_ID_0E { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 15 + // AMBIENCE_ID_0F { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 16 + // AMBIENCE_ID_10 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 17 + // AMBIENCE_ID_11 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 18 + // AMBIENCE_ID_12 { - 0xC000, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { // Channel 0 - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, - // natureSeqId: 19 + // AMBIENCE_ID_13 { - 0xC003, // PlayerIO Data - 0xC000, // Channel Mask + // Init channel mask + ((1 << AMBIENCE_CHANNEL_STREAM_0) | (1 << AMBIENCE_CHANNEL_CRITTER_0) | (1 << AMBIENCE_CHANNEL_RAIN) | + (1 << AMBIENCE_CHANNEL_LIGHTNING)), + // Init mute channel mask + ((1 << AMBIENCE_CHANNEL_RAIN) | (1 << AMBIENCE_CHANNEL_LIGHTNING)), { - NATURE_IO_STREAM_0_TYPE(NATURE_STREAM_0), - NATURE_IO_STREAM_0_PORT3(0), + AMBIENCE_IO_STREAM_0_TYPE(AMBIENCE_STREAM_0), + AMBIENCE_IO_STREAM_0_PORT3(0), // Channel 1 - NATURE_IO_CRITTER_0_TYPE(NATURE_CRITTER_04), - NATURE_IO_CRITTER_0_BEND_PITCH(0), - NATURE_IO_CRITTER_0_NUM_LAYERS(1), - NATURE_IO_CRITTER_0_PORT5(16), + AMBIENCE_IO_CRITTER_0_TYPE(AMBIENCE_CRITTER_04), + AMBIENCE_IO_CRITTER_0_BEND_PITCH(0), + AMBIENCE_IO_CRITTER_0_NUM_LAYERS(1), + AMBIENCE_IO_CRITTER_0_PORT5(16), // End - NATURE_IO_ENTRIES_END, + AMBIENCE_IO_ENTRIES_END, }, }, @@ -987,35 +1132,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 +1172,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 +1187,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 +1201,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 +1213,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 +1225,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 +1237,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 +1248,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 +1259,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 +1271,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 +1282,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 +1293,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 +1304,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 +1316,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 +1327,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 +1343,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 +1354,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 +1364,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 +1383,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 +1396,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 +1406,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 +1421,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 +1436,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 +1447,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 +1579,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 +1598,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 +1606,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 +1694,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 1: Goron Lullaby + // OCARINA_SONG_GORON_LULLABY { 8, { @@ -1521,7 +1709,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 2: New Wave Bossa Nova + // OCARINA_SONG_NEW_WAVE { 7, { @@ -1535,7 +1723,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 3: Elegy of Emptyness + // OCARINA_SONG_ELEGY { 7, { @@ -1549,7 +1737,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 4: Oath to Order + // OCARINA_SONG_OATH { 6, { @@ -1562,7 +1750,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 5; Sarias Song + // OCARINA_SONG_SARIAS { 6, { @@ -1575,7 +1763,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 6: Song of Time + // OCARINA_SONG_TIME { 6, { @@ -1588,7 +1776,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 7: Song of Healing + // OCARINA_SONG_HEALING { 6, { @@ -1601,7 +1789,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 8: Eponas Song + // OCARINA_SONG_EPONAS { 6, { @@ -1614,7 +1802,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 9: Song of Soaring + // OCARINA_SONG_SOARING { 6, { @@ -1627,7 +1815,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 10: Song of Storms + // OCARINA_SONG_STORMS { 6, { @@ -1640,7 +1828,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 11: Suns Song + // OCARINA_SONG_SUNS { 6, { @@ -1653,7 +1841,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 12: Inverted Song of Time + // OCARINA_SONG_INVERTED_TIME { 6, { @@ -1666,7 +1854,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 13; Song of Double Time + // OCARINA_SONG_DOUBLE_TIME { 6, { @@ -1679,7 +1867,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 14: Goron Lullaby Intro + // OCARINA_SONG_GORON_LULLABY_INTRO { 6, { @@ -1692,7 +1880,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 15: Milk Bar Jam "Ballad of the Wind Fish" Human + // OCARINA_SONG_WIND_FISH_HUMAN { 4, { @@ -1703,7 +1891,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 16: Milk Bar Jam "Ballad of the Wind Fish" Goron + // OCARINA_SONG_WIND_FISH_GORON { 8, { @@ -1718,7 +1906,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 17: Milk Bar Jam "Ballad of the Wind Fish" Zora + // OCARINA_SONG_WIND_FISH_ZORA { 8, { @@ -1733,7 +1921,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 18: Milk Bar Jam "Ballad of the Wind Fish" Deku + // OCARINA_SONG_WIND_FISH_DEKU { 5, { @@ -1745,7 +1933,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 19: Evan HP (Zora Band Leader) Song Part 1 + // OCARINA_SONG_EVAN_PART1 { 8, { @@ -1760,7 +1948,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 20: Evan HP (Zora Band Leader) Song Part 2 + // OCARINA_SONG_EVAN_PART2 { 8, { @@ -1775,7 +1963,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 21: Zeldas Lullaby + // OCARINA_SONG_ZELDAS_LULLABY { 6, { @@ -1788,7 +1976,7 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = { }, }, - // 22: Scarecrow + // OCARINA_SONG_SCARECROW_SPAWN { 8, { @@ -1803,7 +1991,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 +2007,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 +2021,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 +2044,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 +2057,1111 @@ 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 + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 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 + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 7, sOcarinaInstrumentId - 1); + // Sets pitch to io port 5 + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 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; +} + +void 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 + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 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 + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 7, sOcarinaInstrumentId - 1); + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 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 +3207,7 @@ s32 AudioOcarina_TerminaWallValidateNotes(u8 songIndex, u8 maxSongIndex) { */ void AudioOcarina_TerminaWallGenerateNotes(void) { OcarinaNote* ocarinaNote; - u8 randButtonIndex; + u8 randomButtonIndex; u8 i; u8 j; @@ -2017,8 +3217,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 +3236,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 +3247,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 +3256,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 +3264,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,84 +3275,834 @@ 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 = gAudioCtx.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; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019DFF8.s") + if (sOcarinaDisableTimer != 0) { + sOcarinaDisableTimer--; + if (sOcarinaDisableTimer == 0) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E000.s") + AudioOcarina_UpdatePlayingStaff(); + AudioOcarina_UpdatePlaybackStaff(); + AudioOcarina_UpdateRecordingStaff(); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E00C.s") +#define OCARINA_INSTRUMENT_OOT_MAX 7 -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E014.s") +void AudioOcarina_PlayLongScarecrowAfterCredits(void) { + static u8 sScarecrowAfterCreditsState = 0; + static u8 sScarecrowAfterCreditsIntrumentId = OCARINA_INSTRUMENT_DEFAULT; + static u16 sScarecrowAfterCreditsTimer = 1200; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E0FC.s") + 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; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_8019E104.s") + 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 && gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].enabled && + ((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].seqScriptIO[0] == (u8)SEQ_IO_VAL_NONE)) { + gAudioCtx.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; +} + +void Audio_Noop1(s32 arg0) { +} + +void Audio_Noop2(s32 arg0, s32 arg1) { +} + +void Audio_Noop3(void) { +} + +void Audio_Update(void) { + if ((func_801A9768() == 0) && (func_801A982C() == 0)) { + AudioOcarina_SetCustomSequence(); + AudioOcarina_Update(); + func_801A5118(); + Audio_StepFreqLerp(&sRiverFreqScaleLerp); + Audio_StepFreqLerp(&sWaterfallFreqScaleLerp); + Audio_UpdateRiverSoundVolumes(); + Audio_UpdateSceneSequenceResumePoint(); + func_801A312C(); + func_8019FEDC(); + func_801A1E0C(); + func_801A1904(); + func_801A2090(); + func_801A3AC0(); + func_801A1290(); + Audio_ResetRequestedSceneSeqId(); + AudioSfx_ProcessRequests(); + func_801A89D0(); + AudioSfx_ProcessActiveSfx(); + func_801A8D5C(); + AudioSfx_ProcessSfxSettings(); + AudioThread_ScheduleProcessCmds(); + } +} + +void Audio_Noop4(s32 arg0) { +} + +void Audio_Noop5(s32 arg0, s32 arg1) { +} #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(gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex])) { + scriptAdd = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->seqScriptIO[1]; + if (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->seqScriptIO[1] <= SEQ_IO_VAL_NONE) { + 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 - ((gAudioCtx.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 - ((gAudioCtx.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_EXTERNAL) { + 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_EXTERNAL) { + 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_EXTERNAL) && !(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) {} + + // ioPort 2, sets volume + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 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->stereoData.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 +4116,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 +4192,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 +4244,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 +4260,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 +4285,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") @@ -2276,16 +4305,16 @@ void Audio_StepFreqLerp(FreqLerp* lerp) { */ void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) { u8 channelIndex; - s8 pan = 0; + s8 panChannelWeight = 0; // Ganondorfs's Lair if (ganonsTowerLevel == 0) { - pan = 0x7F; + // Pan comes entirely from the SequenceChannel + panChannelWeight = 0x7F; } - for (channelIndex = 0; channelIndex < 16; channelIndex++) { - // CHAN_UPD_PAN_UNSIGNED - Audio_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan); + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + AUDIOCMD_CHANNEL_SET_PAN_WEIGHT(SEQ_PLAYER_BGM_MAIN, channelIndex, panChannelWeight); } // Lowest room in Ganon's Tower (Entrance Room) @@ -2325,27 +4354,23 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) { (u8)(lowPassFilterCutoff)); // Sets the reverb - for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels); + for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels); channelIndex++) { - if (&gAudioContext.sequenceChannelNone != - gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) { - // soundScriptIO[5] was set to 0x40 in channels 0, 1, and 4 (BGM no longer in OoT) - if ((u8)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] != - 0xFF) { + if (&gAudioCtx.sequenceChannelNone != gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) { + // seqScriptIO[5] was originally set to 0x40 in channels 0, 1, and 4 by OoT's Ganon's Tower BGM, + // which was removed in MM + if ((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->seqScriptIO[5] != + (u8)SEQ_IO_VAL_NONE) { // Higher volume leads to lower reverb - reverb = - (((u16)gAudioContext.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] - - targetVolume) + - 0x7F); + reverb = (((u16)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->seqScriptIO[5] - + targetVolume) + + 0x7F); if (reverb > 0x7F) { reverb = 0x7F; } - // CHAN_UPD_REVERB - Audio_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) | - _SHIFTL(channelIndex, 8, 8), - (u8)reverb); + AUDIOCMD_CHANNEL_SET_REVERB_VOLUME(SEQ_PLAYER_BGM_MAIN, channelIndex, (u8)reverb); } } } @@ -2401,7 +4426,27 @@ 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)) { + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 6, ioData); + } + } + channelIndex++; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0810.s") @@ -2447,7 +4492,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); + AUDIOCMD_CHANNEL_SET_PAN(SEQ_PLAYER_BGM_MAIN, channelIndex, pan); } } } @@ -2470,8 +4515,51 @@ void Audio_ClearSariaBgmAtPos(Vec3f* pos) { } } -void Audio_SplitBgmChannels(s8 volumeSplit); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SplitBgmChannels.s") +/** + * Turns on and off channels from both bgm players in a way that splits + * equally between the two bgm channels. Split based on note priority + */ +void Audio_SplitBgmChannels(s8 volumeSplit) { + u8 volume; + u8 notePriority; + u16 channelBits; + u8 sBgmPlayers[2] = { SEQ_PLAYER_BGM_MAIN, SEQ_PLAYER_BGM_SUB }; + u8 i; + u8 channelIndex; + + if ((Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) == NA_BGM_DISABLED) && + (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { + for (i = 0; i < ARRAY_COUNT(sBgmPlayers); i++) { + if (i == 0) { + // Main Bgm SeqPlayer + volume = volumeSplit; + } else { + // Sub Bgm SeqPlayer + volume = 0x7F - volumeSplit; + } + + if (volume > 100) { + notePriority = 11; + } else if (volume < 20) { + notePriority = 2; + } else { + notePriority = ((volume - 20) / 10) + 2; + } + + channelBits = 0; + for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) { + if (gAudioCtx.seqPlayers[sBgmPlayers[i]].channels[channelIndex]->notePriority < notePriority) { + // If the note currently playing in the channel is a high enough priority, + // then keep the channel on by setting a channelBit + // If this condition fails, then the channel will be shut off + channelBits += (1 << channelIndex); + } + } + + Audio_QueueSeqCmd(0xA0000000 | ((u32)(sBgmPlayers[i]) << 24) | ((u32)(channelBits))); + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A0E44.s") @@ -2523,7 +4611,7 @@ void Audio_PlaySariaBgm(Vec3f* pos, u16 seqId, u16 distMax) { if (sRiverSoundBgmPos == NULL) { sRiverSoundBgmPos = pos; - func_801A3238(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_SUB, seqId, 0, 7, 2); } else { prevDist = sqrtf(SQ(sRiverSoundBgmPos->z) + SQ(sRiverSoundBgmPos->x)); if (dist < prevDist) { @@ -2560,15 +4648,80 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A246C.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2544.s") +void Audio_PlayMorningSceneSequence(u16 seqId, u8 dayMinusOne) { + Audio_StartMorningSceneSequence(seqId); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | (u32)(dayMinusOne)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A257C.s") +void Audio_StartMorningSceneSequence(u16 seqId) { + if (seqId != NA_BGM_AMBIENCE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_AMBIENCE) << 24) | ((0) << 16)); + Audio_StartSceneSequence(seqId); + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 0, 1); + } else { + Audio_PlayAmbience(AMBIENCE_ID_08); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A25E4.s") +void Audio_PlaySceneSequence(u16 seqId, u8 dayMinusOne) { + if (sRequestedSceneSeqId != seqId) { + if (seqId == NA_BGM_AMBIENCE) { + Audio_PlayAmbience(AMBIENCE_ID_08); + } else if ((seqId != NA_BGM_FINAL_HOURS) || (sPrevMainBgmSeqId == NA_BGM_DISABLED)) { + Audio_StartSceneSequence(seqId); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(4) << 0x10) | + (u32)(dayMinusOne)); + } + sRequestedSceneSeqId = seqId; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2670.s") +void Audio_StartSceneSequence(u16 seqId) { + u8 fadeInDuration = 0; + u8 skipHarpIntro; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2778.s") + if ((sSeqFlags[sPrevSceneSeqId] & SEQ_FLAG_RESUME_PREV) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) { + // Resume the sequence from the point where it left off last time it was played in the scene + if ((sSeqResumePoint & 0x3F) != 0) { + fadeInDuration = 30; + } + + // Write the sequence resumePoint to resume from into ioPort 7 + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, fadeInDuration, 7, sSeqResumePoint); + + sSeqResumePoint = 0; + } else { + // Start the sequence from the beginning + + // Writes to ioPort 7. See `SEQ_FLAG_SKIP_HARP_INTRO` for writing a value of 1 to ioPort 7. + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_SKIP_HARP_INTRO) { + skipHarpIntro = 1; + } else { + skipHarpIntro = (u8)SEQ_IO_VAL_NONE; + } + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, skipHarpIntro); + + if (!(sSeqFlags[seqId] & SEQ_FLAG_RESUME_PREV)) { + // Reset the sequence resumePoint + sSeqResumePoint = SEQ_RESUME_POINT_NONE; + } + } + sPrevSceneSeqId = seqId & 0xFF; +} + +void Audio_UpdateSceneSequenceResumePoint(void) { + u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + + if ((seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) { + if (sSeqResumePoint != SEQ_RESUME_POINT_NONE) { + // Get the current point to resume from + sSeqResumePoint = gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[3]; + } else { + // Initialize the point to resume from to the start of the sequence + sSeqResumePoint = 0; + } + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A27E8.s") @@ -2582,35 +4735,238 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C44.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2C88.s") +void Audio_PlaySequenceInCutscene(u16 seqId) { + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) { + Audio_PlayFanfare(seqId); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_FANFARE) << 24) | ((u32)(0) << 0x10) | (u32)(seqId)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(0) << 0x10) | (u32)(seqId)); + } else { + Audio_PlaySequenceWithSeqPlayerIO(SEQ_PLAYER_BGM_MAIN, seqId, 0, 7, SEQ_IO_VAL_NONE); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 1, 0x7F, 0); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 0); + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2D54.s") +void Audio_StopSequenceInCutscene(u16 seqId) { + if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_FANFARE) << 24) | ((0) << 16)); + } else if (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((0) << 16)); + } else { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s") +s32 Audio_IsSequencePlaying(u8 seqId) { + u8 playerIndex = SEQ_PLAYER_BGM_MAIN; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2E54.s") + if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE) { + playerIndex = SEQ_PLAYER_FANFARE; + } else if (sSeqFlags[seqId & 0xFF] & SEQ_FLAG_FANFARE_KAMARO) { + playerIndex = SEQ_PLAYER_FANFARE; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2ED8.s") + if (seqId == (Audio_GetActiveSequence(playerIndex) & 0xFF)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2F88.s") +void Audio_PlayBgm_StorePrevBgm(u16 seqId) { + u16 curSeqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2FC4.s") + if (curSeqId == NA_BGM_DISABLED) { + curSeqId = NA_BGM_GENERAL_SFX; + } + + if (curSeqId != seqId) { + Audio_SetSequenceMode(SEQ_MODE_IGNORE); + + // Ensure the sequence about to be stored isn't also storing a separate sequence + if (!(sSeqFlags[curSeqId] & SEQ_FLAG_RESTORE)) { + sPrevMainBgmSeqId = curSeqId; + } + + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | (u32)(seqId + 0x8000)); + } +} + +/** + * To be used in conjunction with Audio_PlayBgm_StorePrevBgm + */ +void Audio_RestorePrevBgm(void) { + if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_DISABLED) && + (sSeqFlags[Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) & 0xFF] & SEQ_FLAG_RESTORE)) { + if ((sPrevMainBgmSeqId == NA_BGM_DISABLED) || (sPrevMainBgmSeqId == NA_BGM_GENERAL_SFX)) { + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_MAIN) << 24) | ((0) << 16)); + } else { + if (sPrevMainBgmSeqId == NA_BGM_AMBIENCE) { + sPrevMainBgmSeqId = sPrevAmbienceSeqId; + } + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | + (u32)(sPrevMainBgmSeqId + 0x8000)); + } + sPrevMainBgmSeqId = NA_BGM_DISABLED; + } +} + +// Unused +void Audio_PlayAmbience_StorePrevBgm(u8 ambienceId) { + u16 seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); + + if (seqId != NA_BGM_AMBIENCE) { + sPrevMainBgmSeqId = seqId; + } + + Audio_PlayAmbience(ambienceId); +} + +// Unused +void Audio_ForceRestorePreviousBgm(void) { + if (sPrevMainBgmSeqId != NA_BGM_DISABLED) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(0) << 0x10) | + (u32)(sPrevMainBgmSeqId + 0x8000)); + } + + sPrevMainBgmSeqId = NA_BGM_DISABLED; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3000.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3038.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3098.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PlayFanfare.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A312C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A31EC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3238.s") +void Audio_PlaySequenceWithSeqPlayerIO(s8 playerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, u8 ioData) { + u16 flaggedSeqId; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A32CC.s") + Audio_QueueSeqCmd(0x70000000 | ((u32)(playerIndex) << 24) | ((u32)(ioPort) << 0x10) | (u32)(ioData)); + if ((seqId & 0xFF) < 2) { + flaggedSeqId = seqId; + } else { + flaggedSeqId = seqId | 0x8000; + } + Audio_QueueSeqCmd(0x00000000 | ((u32)(playerIndex) << 24) | ((u32)(fadeInDuration) << 0x10) | (u32)(flaggedSeqId)); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3590.s") +void Audio_SetSequenceMode(u8 seqMode) { + s32 volumeFadeInTimer; + u16 seqId; + u8 volumeFadeOutTimer; + + if ((sPrevMainBgmSeqId == NA_BGM_DISABLED) && (sPrevMainBgmSeqId == NA_BGM_DISABLED)) { + // clang-format off + if (sAudioCutsceneFlag || sSpatialSeqIsActive[SEQ_PLAYER_BGM_SUB]) { \ + seqMode = SEQ_MODE_IGNORE; + } + // clang-format on + + seqId = gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId; + + if ((seqId == NA_BGM_DISABLED) || (sSeqFlags[(u8)(seqId & 0xFF)] & SEQ_FLAG_ENEMY) || + ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY)) { + if (seqMode != (sPrevSeqMode & 0x7F)) { + if (seqMode == SEQ_MODE_ENEMY) { + // If only seqMode = SEQ_MODE_ENEMY (Start) + if (gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume < 0) { + volumeFadeInTimer = -(gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume); + } else { + volumeFadeInTimer = gActiveSeqs[SEQ_PLAYER_BGM_SUB].volScales[1] - sBgmEnemyVolume; + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, volumeFadeInTimer); + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) | + (u32)(NA_BGM_ENEMY | 0x800)); + + if (seqId >= NA_BGM_TERMINA_FIELD) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F - sBgmEnemyVolume, 10); + Audio_SplitBgmChannels(sBgmEnemyVolume); + } + } else if ((sPrevSeqMode & 0x7F) == SEQ_MODE_ENEMY) { + // If only sPrevSeqMode = SEQ_MODE_ENEMY (End) + Audio_QueueSeqCmd(0x100000FF | ((u8)(SEQ_PLAYER_BGM_SUB) << 24) | ((10) << 16)); + + if (seqMode == SEQ_MODE_IGNORE) { + volumeFadeOutTimer = 0; + } else { + volumeFadeOutTimer = 10; + } + + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, volumeFadeOutTimer); + Audio_SplitBgmChannels(0); + } + + sPrevSeqMode = seqMode + 0x80; + } else { + if (seqMode == SEQ_MODE_ENEMY) { + // If both seqMode = sPrevSeqMode = SEQ_MODE_ENEMY + if ((Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == NA_BGM_DISABLED) && + (seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_ENEMY)) { + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_BGM_SUB) << 24) | ((u32)(10) << 0x10) | + (u32)(NA_BGM_ENEMY | 0x800)); + sPrevSeqMode = seqMode + 0x80; + } + } + } + } else { + // Remnant of OoT's Hyrule Field Sequence + if (seqMode == SEQ_MODE_DEFAULT) { + if (sPrevSeqMode == SEQ_MODE_STILL) { + sNumFramesMoving = 0; + } + sNumFramesStill = 0; + sNumFramesMoving++; + } else { + sNumFramesStill++; + } + + if ((seqMode == SEQ_MODE_STILL) && (sNumFramesStill < 30) && (sNumFramesMoving > 20)) { + seqMode = SEQ_MODE_DEFAULT; + } + + sPrevSeqMode = seqMode; + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 0x10) | (u32)(seqMode)); + } + } +} + +void Audio_UpdateEnemyBgmVolume(f32 dist) { + f32 adjDist; + u16 seqId = gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId; + + if (sPrevSeqMode == (SEQ_MODE_ENEMY | 0x80)) { + if (dist != sBgmEnemyDist) { + // clamp (dist - 150.0f) between 0 and 350 + if (dist < 150.0f) { + adjDist = 0.0f; + } else if (dist > 500.0f) { + adjDist = 350.0f; + } else { + adjDist = dist - 150.0f; + } + + sBgmEnemyVolume = ((350.0f - adjDist) * 127.0f) / 350.0f; + Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, 3, sBgmEnemyVolume, 10); + + if ((seqId >= NA_BGM_TERMINA_FIELD) && !(sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_FANFARE_KAMARO)) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, (0x7F - sBgmEnemyVolume), 10); + } + } + + Audio_SplitBgmChannels(sBgmEnemyVolume); + } + sBgmEnemyDist = dist; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A36F0.s") @@ -2640,7 +4996,9 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3EC0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s") +void Audio_SetCutsceneFlag(s8 flag) { + sAudioCutsceneFlag = flag; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3F6C.s") @@ -2648,7 +5006,7 @@ void Audio_ClearSariaBgm2(void) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A3FFC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/audio_setBGM.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_SetSpec.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4058.s") @@ -2664,33 +5022,148 @@ 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") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_PreNMI.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A44C4.s") +void Audio_ResetRequestedSceneSeqId(void) { + sRequestedSceneSeqId = NA_BGM_DISABLED; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A44D4.s") #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") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A47DC.s") +void Audio_SetAmbienceChannelIO(u8 channelIndexRange, u8 ioPort, u8 ioData) { + u8 firstChannelIndex; + u8 lastChannelIndex; + u8 channelIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A48E0.s") + if ((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) && func_801A8ABC(NA_BGM_AMBIENCE, 0xF00000FF)) { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4A28.s") + // channelIndexRange = 01 on ioPort 1 + if ((((channelIndexRange << 8) + (u32)ioPort) == ((1 << 8) | (u32)1)) && + (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) != NA_BGM_ROMANI_RANCH)) { + D_801FD3A8 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4B80.s") + firstChannelIndex = channelIndexRange >> 4; + lastChannelIndex = channelIndexRange & 0xF; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4C30.s") + if (firstChannelIndex == 0) { + firstChannelIndex = channelIndexRange & 0xF; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4C54.s") + for (channelIndex = firstChannelIndex; channelIndex <= lastChannelIndex; channelIndex++) { + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) | + ((u32)(channelIndex) << 8) | (u32)(ioData)); + } +} + +void Audio_StartAmbience(u16 initChannelMask, u16 initMuteChannelMask) { + u8 channelIndex; + + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_0) << 0x10) | + (u32)(1)); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_4) << 0x10) | + (u32)((u8)(initChannelMask >> 8))); + Audio_QueueSeqCmd(0x70000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(SEQ_PLAYER_IO_PORT_5) << 0x10) | + (u32)((u8)(initChannelMask & 0xFF))); + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 0, 0x7F, 1); + + if ((Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) && + (Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) { + Audio_StopSequence(SEQ_PLAYER_AMBIENCE, 0); + AUDIOCMD_GLOBAL_STOP_AUDIOCMDS(); + } + + if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) { + Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, 3, 0x7F, 1); + } + + Audio_QueueSeqCmd(0x00000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(0) << 0x10) | (u32)(NA_BGM_AMBIENCE)); + + for (channelIndex = 0; channelIndex < 16; channelIndex++) { + if (!(initMuteChannelMask & (1 << channelIndex)) && (initChannelMask & (1 << channelIndex))) { + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_1) << 16) | + ((u32)(channelIndex) << 8) | (u32)(1)); + } + } +} + +void Audio_PlayAmbience(u8 ambienceId) { + u8 i = 0; + u8 channelIndex; + u8 ioPort; + u8 ioData; + + if (!((gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_DISABLED) && + (sSeqFlags[gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId & 0xFF & 0xFF] & SEQ_FLAG_NO_AMBIENCE))) { + if (gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId != NA_BGM_AMBIENCE) { + sPrevAmbienceSeqId = gActiveSeqs[SEQ_PLAYER_AMBIENCE].seqId; + } + + Audio_StartAmbience(sAmbienceData[ambienceId].initChannelMask, sAmbienceData[ambienceId].initMuteChannelMask); + + while ((sAmbienceData[ambienceId].channelProperties[i] != 0xFF) && + (i < ARRAY_COUNT(sAmbienceData[ambienceId].channelProperties))) { + channelIndex = sAmbienceData[ambienceId].channelProperties[i++]; + ioPort = sAmbienceData[ambienceId].channelProperties[i++]; + ioData = sAmbienceData[ambienceId].channelProperties[i++]; + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(ioPort) << 16) | + ((u32)(channelIndex) << 8) | (u32)(ioData)); + } + + Audio_QueueSeqCmd(0x80000000 | ((u32)(SEQ_PLAYER_AMBIENCE) << 24) | ((u32)(CHANNEL_IO_PORT_7) << 16) | + ((u32)(AMBIENCE_CHANNEL_SOUND_MODE) << 8) | (u32)(sSoundMode)); + } +} + +u32 Audio_SetAmbienceRandomBend(u8 seqScriptValIn, SequenceChannel* channel) { + u32 seqScriptValOut = seqScriptValIn; + + gAudioCtx.seqPlayers[SEQ_PLAYER_AMBIENCE].applyBend = true; + + if ((seqScriptValIn == 0) || (seqScriptValIn == 0xFF)) { + gAudioCtx.seqPlayers[SEQ_PLAYER_AMBIENCE].bend = 1.0f; + } else { + seqScriptValOut = AudioThread_NextRandom(); + gAudioCtx.seqPlayers[SEQ_PLAYER_AMBIENCE].bend = 1.0293 - ((gAudioCtx.audioRandom & 0xF) / 144.0f); + + return seqScriptValOut; + } + +#ifdef AVOID_UB + return seqScriptValOut; +#endif +} + +void Audio_Init(void) { + AudioLoad_Init(NULL, 0); +} + +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++) { + AUDIOCMD_CHANNEL_SET_SFX_STATE(SEQ_PLAYER_SFX, channelIndex, &sSfxChannelState[channelIndex]); + } + + AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(AUDIO_CUSTOM_FUNCTION_SEQ_0, AudioSfx_SetFreqAndStereoBits); + AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(AUDIO_CUSTOM_FUNCTION_SEQ_1, Audio_SetAmbienceRandomBend); +} #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..76597f5f3 100644 --- a/src/code/audio/code_801A5BD0.c +++ b/src/code/audio/code_801A5BD0.c @@ -1,45 +1,944 @@ #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)) { + // ioPort 0, force stop sfx in seq 0 + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, gSfxBanks[bankId][entryIndex].channelIndex, 0, 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) { + // ioPort 0, force stop sfx in seq 0 + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 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 = gAudioCtx.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); + + // ioPort 0, enable the sfx to play in `NA_BGM_GENERAL_SFX` + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 0, 1); + + // ioPort 4, write the lower bits sfx index for `NA_BGM_GENERAL_SFX` to find the right code to execute + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 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]) { + // ioPort 5, write the upper bits sfx index and a flag for `NA_BGM_GENERAL_SFX`, + // for banks with > 0xFF entries + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 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->seqScriptIO[1] == (u8)SEQ_IO_VAL_NONE) { + // 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) { + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 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) { + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 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) { + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 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) { + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 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) { + AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 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 (gAudioCtx.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 (gAudioCtx.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..3f8446036 100644 --- a/src/code/audio/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -1,8 +1,8 @@ #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") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_StopSequence.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A7D84.s") @@ -10,7 +10,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A89D0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8A50.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/Audio_GetActiveSequence.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A8ABC.s") diff --git a/src/code/audioMgr.c b/src/code/audioMgr.c index ee6014137..eca7ddd83 100644 --- a/src/code/audioMgr.c +++ b/src/code/audioMgr.c @@ -39,7 +39,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) { if (SREG(20) >= 2) { rspTask = NULL; } else { - rspTask = func_80192BE0(); + rspTask = AudioThread_Update(); } if (audioMgr->rspTask != NULL) { @@ -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..fb6f0743d 100644 --- a/src/code/code_8012EC80.c +++ b/src/code/code_8012EC80.c @@ -96,7 +96,7 @@ u32 gGsFlagsShift[] = { }; // TODO: use symbols for these icon textures once textures are properly in C -void* gItemIcons[] = { +TexturePtr gItemIcons[] = { 0x08000000, // ITEM_OCARINA 0x08001000, // ITEM_BOW 0x08002000, // ITEM_ARROW_FIRE @@ -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 @@ -249,7 +249,7 @@ u8 gItemSlots[] = { SLOT_LENS, // ITEM_LENS SLOT_HOOKSHOT, // ITEM_HOOKSHOT SLOT_SWORD_GREAT_FAIRY, // ITEM_SWORD_GREAT_FAIRY - SLOT_BOTTLE_1, // + SLOT_BOTTLE_1, // ITEM_LONGSHOT SLOT_BOTTLE_1, // ITEM_BOTTLE SLOT_BOTTLE_1, // ITEM_POTION_RED SLOT_BOTTLE_1, // ITEM_POTION_GREEN @@ -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,13 +360,13 @@ 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 }; // Used to map scene indexes to their region in Termina -u16 gScenesPerRegion[11][27] = { - // Great Bay +u16 gSceneIdsPerRegion[REGION_MAX][27] = { + // REGION_GREAT_BAY { SCENE_30GYOSON, SCENE_LABO, @@ -378,15 +378,15 @@ u16 gScenesPerRegion[11][27] = { SCENE_PIRATE, SCENE_35TAKI, SCENE_KINDAN2, - -1, + 0xFFFF, }, - // Zora Hall + // REGION_ZORA_HALL { SCENE_33ZORACITY, SCENE_BANDROOM, - -1, + 0xFFFF, }, - // Romani Ranch + // REGION_ROMANI_RANCH { SCENE_F01, SCENE_ROMANYMAE, @@ -394,17 +394,17 @@ u16 gScenesPerRegion[11][27] = { SCENE_F01C, SCENE_F01_B, SCENE_KOEPONARACE, - -1, + 0xFFFF, }, - // Deku Palace + // REGION_DEKU_PALACE { SCENE_22DEKUCITY, SCENE_DEKU_KING, SCENE_26SARUNOMORI, SCENE_DANPEI, - -1, + 0xFFFF, }, - // Southern Swamp + // REGION_WOODFALL { SCENE_20SICHITAI, SCENE_20SICHITAI2, @@ -412,21 +412,18 @@ u16 gScenesPerRegion[11][27] = { SCENE_WITCH_SHOP, SCENE_21MITURINMAE, SCENE_KINSTA1, - -1, + 0xFFFF, }, - // Clock Town + // REGION_CLOCK_TOWN { - SCENE_00KEIKOKU, SCENE_TENMON_DAI, SCENE_13HUBUKINOMITI, - SCENE_24KEMONOMITI, SCENE_SYATEKI_MORI, SCENE_IKANAMAE, - SCENE_TOWN, SCENE_SYATEKI_MIZU, SCENE_BOWLING, - SCENE_TAKARAYA, SCENE_YADOYA, SCENE_SONCHONOIE, - SCENE_MILK_BAR, SCENE_ICHIBA, SCENE_BOMYA, - SCENE_AYASHIISHOP, SCENE_8ITEMSHOP, SCENE_DOUJOU, - SCENE_POSTHOUSE, SCENE_TAKARAKUJI, SCENE_BACKTOWN, - SCENE_CLOCKTOWER, SCENE_INSIDETOWER, SCENE_OKUJOU, - SCENE_ALLEY, SCENE_DEKUTES, -1, + SCENE_00KEIKOKU, SCENE_TENMON_DAI, SCENE_13HUBUKINOMITI, SCENE_24KEMONOMITI, SCENE_SYATEKI_MORI, + SCENE_IKANAMAE, SCENE_TOWN, SCENE_SYATEKI_MIZU, SCENE_BOWLING, SCENE_TAKARAYA, + SCENE_YADOYA, SCENE_SONCHONOIE, SCENE_MILK_BAR, SCENE_ICHIBA, SCENE_BOMYA, + SCENE_AYASHIISHOP, SCENE_8ITEMSHOP, SCENE_DOUJOU, SCENE_POSTHOUSE, SCENE_TAKARAKUJI, + SCENE_BACKTOWN, SCENE_CLOCKTOWER, SCENE_INSIDETOWER, SCENE_OKUJOU, SCENE_ALLEY, + SCENE_DEKUTES, 0xFFFF, }, - // Snowhead + // REGION_SNOWHEAD { SCENE_10YUKIYAMANOMURA, SCENE_10YUKIYAMANOMURA2, @@ -437,15 +434,15 @@ u16 gScenesPerRegion[11][27] = { SCENE_GORON_HAKA, SCENE_17SETUGEN, SCENE_17SETUGEN2, - -1, + 0xFFFF, }, - // Ikana Graveyard + // REGION_IKANA_GRAVEYARD { SCENE_BOTI, SCENE_DANPEI2TEST, - -1, + 0xFFFF, }, - // Ikana Canyon + // REGION_IKANA_CANYON { SCENE_CASTLE, SCENE_IKNINSIDE, @@ -456,33 +453,33 @@ u16 gScenesPerRegion[11][27] = { SCENE_REDEAD, SCENE_TOUGITES, SCENE_HAKASHITA, - -1, + 0xFFFF, }, - // Goron Village + // REGION_GORON_VILLAGE { SCENE_11GORONNOSATO, SCENE_11GORONNOSATO2, SCENE_16GORON_HOUSE, SCENE_GORONSHOP, - -1, + 0xFFFF, }, - // Stone Tower + // REGION_STONE_TOWER { SCENE_F40, SCENE_F41, - -1, + 0xFFFF, }, }; -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 +492,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; } @@ -522,7 +519,7 @@ void Inventory_ChangeUpgrade(s16 upgrade, u32 value) { gSaveContext.save.inventory.upgrades = upgrades; } -s32 Inventory_IsMapVisible(s16 sceneNum) { +s32 Inventory_IsMapVisible(s16 sceneId) { s16 index = 0; /** @@ -530,32 +527,32 @@ s32 Inventory_IsMapVisible(s16 sceneNum) { * increment to the next index of scenesVisible so that every scene gets a unique flag in scenesVisible, * 224 bits were allocated to this although there are only 112 scenes */ - if (sceneNum >= 0x20) { - if (sceneNum < 0x40) { + if (sceneId >= 0x20) { + if (sceneId < 0x40) { index = 1; - } else if (sceneNum < 0x60) { + } else if (sceneId < 0x60) { index = 2; - } else if (sceneNum < 0x80) { + } else if (sceneId < 0x80) { index = 3; - } else if (sceneNum < 0xA0) { + } else if (sceneId < 0xA0) { index = 4; - } else if (sceneNum < 0xC0) { + } else if (sceneId < 0xC0) { index = 5; - } else if (sceneNum < 0xE0) { + } else if (sceneId < 0xE0) { index = 6; } } - if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneNum - (index << 5)]) { + if (gSaveContext.save.scenesVisible[index] & gBitFlags[sceneId - (index << 5)]) { return true; } return false; } -static u16 sScenesPerTingleMap[6][12] = { +static u16 sSceneIdsPerTingleMap[TINGLE_MAP_MAX][12] = { { - // Clock Town Tingle Map + // TINGLE_MAP_CLOCK_TOWN SCENE_00KEIKOKU, SCENE_BOTI, SCENE_13HUBUKINOMITI, @@ -566,20 +563,20 @@ static u16 sScenesPerTingleMap[6][12] = { SCENE_BACKTOWN, SCENE_CLOCKTOWER, SCENE_ALLEY, - -1, + 0xFFFF, }, { - // Woodfall Tingle Map + // TINGLE_MAP_WOODFALL SCENE_20SICHITAI, SCENE_20SICHITAI2, SCENE_21MITURINMAE, SCENE_22DEKUCITY, SCENE_DEKU_KING, SCENE_KINSTA1, - -1, + 0xFFFF, }, { - // Snowhead Tingle Map + // TINGLE_MAP_SNOWHEAD SCENE_10YUKIYAMANOMURA, SCENE_10YUKIYAMANOMURA2, SCENE_11GORONNOSATO, @@ -590,20 +587,20 @@ static u16 sScenesPerTingleMap[6][12] = { SCENE_GORONRACE, SCENE_17SETUGEN, SCENE_17SETUGEN2, - -1, + 0xFFFF, }, { - // Romani Ranch Tingle Map + // TINGLE_MAP_ROMANI_RANCH SCENE_F01, SCENE_ROMANYMAE, SCENE_OMOYA, SCENE_F01C, SCENE_F01_B, SCENE_KOEPONARACE, - -1, + 0xFFFF, }, { - // Great Bay Tingle Map + // TINGLE_MAP_GREAT_BAY SCENE_30GYOSON, SCENE_SINKAI, SCENE_31MISAKI, @@ -611,30 +608,30 @@ static u16 sScenesPerTingleMap[6][12] = { SCENE_KAIZOKU, SCENE_33ZORACITY, SCENE_35TAKI, - -1, + 0xFFFF, }, { - // Stone Tower Tingle Map + // TINGLE_MAP_STONE_TOWER SCENE_F40, SCENE_F41, SCENE_CASTLE, SCENE_IKANA, SCENE_REDEAD, - -1, + 0xFFFF, }, }; /** - * Map visibility is achieved by purchasing a tingle map + * Removing clouds from the World Map is achieved by purchasing a tingle map */ -void Inventory_SetMapVisibility(s16 tingleIndex) { +void Inventory_SetWorldMapCloudVisibility(s16 tingleIndex) { s16 i = 0; s16 index = 0; - u16(*tingleMapSceneIndices)[] = &sScenesPerTingleMap[tingleIndex]; + u16(*tingleMapSceneIds)[] = &sSceneIdsPerTingleMap[tingleIndex]; - if ((tingleIndex >= 0) && (tingleIndex < 6)) { + if ((tingleIndex >= 0) && (tingleIndex < TINGLE_MAP_MAX)) { while (true) { - if ((*tingleMapSceneIndices)[i] == 0xFFFF) { + if ((*tingleMapSceneIds)[i] == 0xFFFF) { break; } @@ -643,43 +640,43 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { * increment to the next index of scenesVisible so that every scene gets a unique flag in scenesVisible, * 224 bits were allocated to this although there are only 112 scenes */ - if (((s16)(*tingleMapSceneIndices)[i]) < 0x20) { + if (((s16)(*tingleMapSceneIds)[i]) < 0x20) { index = 0; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0x40) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0x40) { index = 1; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0x60) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0x60) { index = 2; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0x80) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0x80) { index = 3; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0xA0) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0xA0) { index = 4; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0xC0) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0xC0) { index = 5; - } else if (((s16)(*tingleMapSceneIndices)[i]) < 0xE0) { + } else if (((s16)(*tingleMapSceneIds)[i]) < 0xE0) { index = 6; } gSaveContext.save.scenesVisible[index] = - gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIndices)[i] - (index << 5)]; + gSaveContext.save.scenesVisible[index] | gBitFlags[(s16)(*tingleMapSceneIds)[i] - (index << 5)]; i++; } - if ((*tingleMapSceneIndices) == sScenesPerTingleMap[0]) { - gSaveContext.save.mapsVisible |= 3; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[1]) { - gSaveContext.save.mapsVisible |= 0x1C; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[2]) { - gSaveContext.save.mapsVisible |= 0xE0; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[3]) { - gSaveContext.save.mapsVisible |= 0x100; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[4]) { - gSaveContext.save.mapsVisible |= 0x1E00; - } else if ((*tingleMapSceneIndices) == sScenesPerTingleMap[5]) { - gSaveContext.save.mapsVisible |= 0x6000; + if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_CLOCK_TOWN]) { + gSaveContext.save.worldMapCloudVisibility |= 3; + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_WOODFALL]) { + gSaveContext.save.worldMapCloudVisibility |= 0x1C; + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_SNOWHEAD]) { + gSaveContext.save.worldMapCloudVisibility |= 0xE0; + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_ROMANI_RANCH]) { + gSaveContext.save.worldMapCloudVisibility |= 0x100; + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_GREAT_BAY]) { + gSaveContext.save.worldMapCloudVisibility |= 0x1E00; + } else if (*tingleMapSceneIds == sSceneIdsPerTingleMap[TINGLE_MAP_STONE_TOWER]) { + gSaveContext.save.worldMapCloudVisibility |= 0x6000; } } - XREG(95) = 0; + R_MINIMAP_DISABLED = false; } /** @@ -688,7 +685,7 @@ void Inventory_SetMapVisibility(s16 tingleIndex) { void Inventory_SaveDekuPlaygroundHighScore(s16 timerId) { s16 i; - gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.unk_3DE0[timerId]; + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] = gSaveContext.timerCurTimes[timerId]; for (i = 0; i < 8; i++) { gSaveContext.save.inventory.dekuPlaygroundPlayerName[CURRENT_DAY - 1][i] = @@ -719,12 +716,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_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_80140CE0.c b/src/code/code_80140CE0.c new file mode 100644 index 000000000..f3d487fab --- /dev/null +++ b/src/code/code_80140CE0.c @@ -0,0 +1,7 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80140CE0/func_80140CE0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80140CE0/func_80140D04.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80140CE0/func_80140D10.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..a22b62a0e 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -1,6 +1,6 @@ /** * File: flg_set.c - * Description: Event Editor, used to view and edit weekEventReg, eventInf and maskMaskBit flags. + * Description: Event Editor, used to view and edit weekEventReg, eventInf and masksGivenOnMoon flags. * Controls: * + Left and Right: select different flags/bits in array element * + Up and Down: select array element (byte) 1 up/down @@ -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]" }, @@ -122,9 +123,9 @@ static FlagSetEntry sFlagEntries[] = { { &gSaveContext.eventInf[6], "event_inf[6]" }, { &gSaveContext.eventInf[7], "event_inf[7]" }, - { &gSaveContext.maskMaskBit[0], "mask_mask_bit[0]" }, - { &gSaveContext.maskMaskBit[1], "mask_mask_bit[1]" }, - { &gSaveContext.maskMaskBit[2], "mask_mask_bit[2]" }, + { &gSaveContext.masksGivenOnMoon[0], "mask_mask_bit[0]" }, + { &gSaveContext.masksGivenOnMoon[1], "mask_mask_bit[1]" }, + { &gSaveContext.masksGivenOnMoon[2], "mask_mask_bit[2]" }, { NULL, NULL }, // used in the code to detect array end }; @@ -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..b7069d312 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -1,5 +1,7 @@ #include "global.h" #include "system_malloc.h" +#include "z64rumble.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" s32 gFramerateDivisor = 1; f32 gFramerateDivisorF = 1.0f; @@ -52,7 +54,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); } } } @@ -139,7 +141,7 @@ void Game_Update(GameState* gameState) { gameState->main(gameState); - if (R_PAUSE_MENU_MODE != 2) { + if (R_PAUSE_BG_PRERENDER_STATE != PAUSE_BG_PRERENDER_PROCESS) { GameState_Draw(gameState, gfxCtx); func_801736DC(gfxCtx); } @@ -191,7 +193,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; @@ -199,8 +201,8 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g gfxCtx->viConfigFeatures = gViConfigFeatures; gfxCtx->xScale = gViConfigXScale; gfxCtx->yScale = gViConfigYScale; - gameState->nextGameStateInit = NULL; - gameState->nextGameStateSize = 0U; + gameState->init = NULL; + gameState->size = 0; { s32 requiredScopeTemp; @@ -213,40 +215,40 @@ 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(); - func_8019E014(); + AudioMgr_StopAllSfxExceptSystem(); + Audio_Update(); osRecvMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK); if (gameState->destroy != NULL) { 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); } -GameStateFunc GameState_GetNextStateInit(GameState* gameState) { - return gameState->nextGameStateInit; +GameStateFunc GameState_GetInit(GameState* gameState) { + return gameState->init; } -size_t GameState_GetNextStateSize(GameState* gameState) { - return gameState->nextGameStateSize; +size_t GameState_GetSize(GameState* gameState) { + return gameState->size; } u32 GameState_IsRunning(GameState* gameState) { diff --git a/src/code/graph.c b/src/code/graph.c index 28327c35f..8edc979d4 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "system_malloc.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" @@ -5,6 +6,7 @@ #include "overlays/gamestates/ovl_opening/z_opening.h" #include "overlays/gamestates/ovl_select/z_select.h" #include "overlays/gamestates/ovl_title/z_title.h" +#include "z_title_setup.h" FaultAddrConvClient sGraphFaultAddrConvClient; FaultClient sGraphFaultClient; @@ -62,44 +64,45 @@ void Graph_SetNextGfxPool(GraphicsContext* gfxCtx) { } GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { - GameStateFunc gameStateInit = GameState_GetNextStateInit(gameState); + GameStateFunc gameStateInit = GameState_GetInit(gameState); - if (gameStateInit == (GameStateFunc)TitleSetup_Init) { + if (gameStateInit == Setup_Init) { return &gGameStateOverlayTable[0]; } - if (gameStateInit == (GameStateFunc)Select_Init) { + if (gameStateInit == MapSelect_Init) { return &gGameStateOverlayTable[1]; } - if (gameStateInit == (GameStateFunc)Title_Init) { + if (gameStateInit == ConsoleLogo_Init) { return &gGameStateOverlayTable[2]; } - if (gameStateInit == (GameStateFunc)Play_Init) { + if (gameStateInit == Play_Init) { return &gGameStateOverlayTable[3]; } - if (gameStateInit == (GameStateFunc)Opening_Init) { + if (gameStateInit == TitleSetup_Init) { return &gGameStateOverlayTable[4]; } - if (gameStateInit == (GameStateFunc)FileChoose_Init) { + if (gameStateInit == FileSelect_Init) { return &gGameStateOverlayTable[5]; } - if (gameStateInit == (GameStateFunc)Daytelop_Init) { + if (gameStateInit == DayTelop_Init) { return &gGameStateOverlayTable[6]; } + return NULL; } void* Graph_FaultAddrConvFunc(void* address, void* param) { uintptr_t addr = address; - GameStateOverlay* gamestateOvl = &gGameStateOverlayTable[0]; + GameStateOverlay* gameStateOvl = &gGameStateOverlayTable[0]; uintptr_t ramConv; void* ramStart; uintptr_t diff; s32 i; - for (i = 0; i < graphNumGameStates; i++, gamestateOvl++) { - diff = VRAM_PTR_SIZE(gamestateOvl); - ramStart = gamestateOvl->loadedRamAddr; - ramConv = (uintptr_t)gamestateOvl->vramStart - (uintptr_t)ramStart; + for (i = 0; i < graphNumGameStates; i++, gameStateOvl++) { + diff = VRAM_PTR_SIZE(gameStateOvl); + ramStart = gameStateOvl->loadedRamAddr; + ramConv = (uintptr_t)gameStateOvl->vramStart - (uintptr_t)ramStart; if (ramStart != NULL) { if (addr >= (uintptr_t)ramStart && addr < (uintptr_t)ramStart + diff) { @@ -171,8 +174,8 @@ retry: task->ucodeBootSize = SysUcode_GetUCodeBootSize(); task->ucode = SysUcode_GetUCode(); task->ucodeData = SysUcode_GetUCodeData(); - task->ucodeSize = 0x1000; - task->ucodeDataSize = 0x800; + task->ucodeSize = SP_UCODE_SIZE; + task->ucodeDataSize = SP_UCODE_DATA_SIZE; task->dramStack = (u64*)gGfxSPTaskStack; task->dramStackSize = sizeof(gGfxSPTaskStack); task->outputBuff = gGfxSPTaskOutputBufferPtr; @@ -229,12 +232,12 @@ void Graph_UpdateGame(GameState* gameState) { Game_UpdateInput(gameState); Game_IncrementFrameCount(gameState); if (SREG(20) < 3) { - func_8019E014(); + Audio_Update(); } } /** - * Run the gamestate logic, then finalize the gfx buffer + * Run the game state logic, then finalize the gfx buffer * and run the graphics task for this frame. */ void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState) { 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/speed_meter.c b/src/code/speed_meter.c index 9f04de110..780a02c62 100644 --- a/src/code/speed_meter.c +++ b/src/code/speed_meter.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64view.h" #include "system_malloc.h" #pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177390.s") @@ -14,9 +15,3 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177AC8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/SpeedMeter_DrawAllocEntries.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_801780F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_801781EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_8017842C.s") diff --git a/src/code/su_mtx.c b/src/code/su_mtx.c new file mode 100644 index 000000000..09cbda90e --- /dev/null +++ b/src/code/su_mtx.c @@ -0,0 +1,361 @@ +/** + * @file su_mtx.c + * @brief "Fast" functions for constructing RSP-compatible matrices directly + * + * The three functions in this file construct scaling, rotation, and translation matrices, and combinations thereof. The + * intention appears to be to exploit the peculiar structure of the RSP's fixed-point matrix format, which we recall is + * + * 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 + * + * This means it can be written to as either words or two sets of shorts; the latter is the correct format for + * interpreting it the way the RSP does, but the first is likely faster to access and write to. The functions save + * writing halves by + * + * - writing a word 0 if two adjacent elements are 0 in a convenient place, or 1 if they are 0 and 1, + * - writing a word using a shift and overwriting the dirty half afterwards. + * + * Examples of both of these are seen in Mtx_SetTranslateScaleMtx(); we explain there in full detail due to the + * function's relative simplicity. The other two functions we merely point out the interesting parts rather than + * explaining the whole process. + * + * We use the following notation throughout: round brackets denote the word-sized elements, square the pairs they cover. + * The integer and fractional parts of a fixed-point number are denoted by i and f respectively, and these letters are + * also used to represent which half each of the pairs belongs to. + * + * (00) [i00,i01], (01) [i02,i03] + * (02) [i10,i11], (03) [i12,i13] + * (10) [i20,i21], (11) [i22,i23] + * (12) [i30,i31], (13) [i32,i33] + * (20) [f00,f01], (21) [f02,f03] + * (22) [f10,f11], (23) [f12,f13] + * (30) [f20,f21], (31) [f22,f23] + * (32) [f30,f31], (33) [f32,f33] + * + * We keep the RSP's column-major convention; this file is confusing enough without attempting to transpose everything. + * Bear in mind therefore that we are acting on *row vectors* on the *right*. + * + * @warning The behaviour of the output of the functions in this file is undefined in C89, since both members of the + * union are used to set the mtxs. (C99+ allow type-punning, but the behaviour is still implementation-defined because + * it relies on the storage being big-endian.) + * + * @remark Name inferred from shared Animal Forest functions, meaning of "su" is unclear. + */ + +#include "global.h" + +/** + * Constructs a matrix \$f ST \$f, i.e. a scaling \$f S \$f followed by a translation \$f T \$f. + * + * The final result is + * + * \f[ + * \begin{bmatrix} + * s_x & 0 & 0 & 0 \\ + * 0 & s_y & 0 & 0 \\ + * 0 & 0 & s_z & 0 \\ + * t_x & t_y & t_z & 1 + * \end{bmatrix} + * \f] + * + * @param[out] mtx Fixed-point matrix pointer to output to + * @param[in] scaleX Scale in the X direction + * @param[in] scaleY Scale in the Y direction + * @param[in] scaleZ Scale in the Z direction + * @param[in] translateX X component of translation + * @param[in] translateY Y component of translation + * @param[in] translateZ Z component of translation + * + * @remark Original name: "suMtxMakeTS" + */ +void Mtx_SetTranslateScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, + f32 translateZ) { + Mtx* m = mtx; + s32 fixedPoint; + + m->m[0][1] = 0; // [i02, i03] == [0, 0] + m->m[2][1] = 0; // [f02, f03] == [0, 0] + m->m[0][3] = 0; // [i12, i13] == [0, 0] + m->m[2][3] = 0; // [f22, f23] == [0, 0] + m->m[1][0] = 0; // [i20, i21] == [0, 0] + // + fixedPoint = scaleX * 0x10000; // + m->m[0][0] = fixedPoint; // [i00, i01] == [scaleX.i, scaleX.f]; i01 is now "dirty" + m->intPart[0][1] = 0; // Clean i01 by zeroing it: [i00, i01] == [scaleX.i, 0] + m->m[2][0] = (u32)fixedPoint << 16; // [f00, f01] == [scaleX.f, 0] + // + fixedPoint = scaleY * 0x10000; // + m->m[0][2] = (u32)fixedPoint >> 16; // [i10, i11] == [0, scaleY.i] + m->m[2][2] = fixedPoint & 0xFFFF; // [f10, f11] == [0, scaleY.f] + // + fixedPoint = scaleZ * 0x10000; // + m->m[1][1] = fixedPoint; // [i22, i23] == [scaleZ.i, scaleZ.f] + m->intPart[2][3] = 0; // [i22, i23] == [scaleZ.i, 0] + m->m[3][1] = (u32)fixedPoint << 16; // [f22, f23] == [scaleZ.f, 0] + // + m->m[3][0] = 0; // [f20, f21] == [0, 0] + // + fixedPoint = translateX * 0x10000; // + m->intPart[3][0] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateX.i, ?] + m->fracPart[3][0] = fixedPoint & 0xFFFF; // [f30, f31] == [translateX.f, ?] + // + fixedPoint = translateY * 0x10000; // + m->intPart[3][1] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateX.i, translateY.i] + m->fracPart[3][1] = fixedPoint & 0xFFFF; // [f30, f31] == [translateX.f, translateY.f] + // + fixedPoint = translateZ * 0x10000; // + m->intPart[3][2] = ((u32)fixedPoint >> 16) & 0xFFFF; // [i30, i31] == [translateZ.i, ?] + m->intPart[3][3] = 1; // [i32, i33] == [translateZ.i, 1] + m->m[3][3] = (u32)fixedPoint << 16; // [f32, f33] == [translateZ.f, 0] + + // So we end up with + // [scaleX.i, 0], [0, 0], + // [0, scaleY.i], [0, 0], + // [0, 0], [scaleZ.i, 0], + // [translateX.i, translateY.i], [translateZ.i, 1] + // + // [scaleX.f, 0], [0, 0], + // [0, scaleY.f], [0, 0], + // [0, 0], [scaleZ.f, 0] + // [translateX.f, translateY.f], [translateZ.f, 0] +} + +// Unused +/** + * Should create an axis-angle rotation matrix. + * + * @note The axis vector is expected to be normalised. + * + * The result should be: + * + * \f[ + * \begin{bmatrix} + * (1-a_x^2) \cos \theta + a_x^2 & a_x a_y (1 - \cos \theta) + a_z \sin \theta & a_z a_x (1 - \cos \theta) - a_y + * \sin \theta & 0 \\ + * a_x a_y (1 - \cos \theta) - a_z \sin \theta & (1-a_y^2) \cos \theta + a_y^2 & a_y a_z (1 - \cos \theta) + a_x + * \sin \theta & 0 \\ + * a_z a_x (1 - \cos \theta) + a_y \sin \theta & a_y a_z (1 - \cos \theta) - a_x \sin \theta & (1-a_z^2) \cos + * \theta + * + a_z^2 & 0 \\ + * t_x & t_y & t_z & 1 + * \end{bmatrix} + * \f] + * + * @warning There is a significant bug in this function, which means it does not actually produce this correct rotation + * matrix; see inline for details. + * + * @param[out] mtx Fixed-point matrix pointer to output to + * @param[in] angle angle to rotate about axis + * @param[in] axisX X component of axis to rotate about + * @param[in] axisY Y component of axis to rotate about + * @param[in] axisZ Z component of axis to rotate about + * + * @remark Original name: probably something like "suMtxMakeR" or "suMtxMakeRotateVector" + */ +void Mtx_SetRotationMtx(Mtx* mtx, s32 angle, f32 axisX, f32 axisY, f32 axisZ) { + //! FAKE? The somewhat peculiar distribution of temps in this function seems necessary to match? + f32 tempX; + f32 tempZ; + f32 tempY; + f32 sin = Math_SinS(angle); + f32 cos = Math_CosS(angle); + f32 tempXX; + f32 tempYY; + f32 tempZZ; + + s32 fixedPoint; + + mtx->m[1][2] = 0; // [i30, i31] == [0, 0] + mtx->m[1][3] = 1; // [i32, i33] == [0, 1] + mtx->m[3][2] = 0; // [f30, f31] == [0, 0] + mtx->m[3][3] = 0; // [f31, f32] == [0, 0] + + tempXX = axisX * axisX; + tempX = (axisY * axisZ) * (1.0f - cos); + + // i00 and f00 + fixedPoint = (((1.0f - tempXX) * cos) + tempXX) * 0x10000; + mtx->intPart[0][0] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[0][0] = fixedPoint & 0xFFFF; + + tempZ = ((axisX * axisY) * (1.0f - cos)); + tempZZ = axisZ * axisZ; + + // i21 and f21 + fixedPoint = (tempX - (axisX * sin)) * 0x10000; + mtx->intPart[2][1] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[2][1] = fixedPoint & 0xFFFF; + + tempY = (axisZ * axisX) * (1.0f - cos); + tempYY = axisY * axisY; + + // [i12, i13] and [f12, f13] + fixedPoint = (tempX + (axisX * sin)) * 0x10000; + mtx->m[0][3] = fixedPoint; // i13 dirty + mtx->intPart[1][3] = 0; // clean i13 + mtx->m[2][3] = fixedPoint << 0x10; + + // i11 and f11 + fixedPoint = ((((1.0f - tempYY) * cos) + tempYY) * 0x10000); + mtx->intPart[1][1] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[1][1] = fixedPoint & 0xFFFF; + + //! @bug The sign of the `axisY * sin` term is wrong on the next two elements (i/f20 and i/f02), which causes the + //! matrix to not be a rotation matrix (and indeed not even necessarily invertible). + // i20 and f20 + fixedPoint = (tempY - (axisY * sin)) * 0x10000; + mtx->intPart[2][0] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[2][0] = fixedPoint & 0xFFFF; + + // [i02, i03] and [f02, f03] + fixedPoint = (tempY + (axisY * sin)) * 0x10000; + mtx->m[0][1] = fixedPoint; // i03 dirty + mtx->intPart[0][3] = 0; // clean i03 + mtx->m[2][1] = fixedPoint << 0x10; + + // [i22, i23] and [f22, f23] + fixedPoint = ((((1.0f - tempZZ) * cos) + tempZZ) * 0x10000); + mtx->m[1][1] = fixedPoint; // i23 dirty + mtx->intPart[2][3] = 0; // clean i23 + mtx->m[3][1] = fixedPoint << 0x10; + + // i10 and f10 + fixedPoint = (tempZ - axisZ * sin) * 0x10000; + mtx->intPart[1][0] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[1][0] = fixedPoint & 0xFFFF; + + // i01 and f01 + fixedPoint = (tempZ + axisZ * sin) * 0x10000; + mtx->intPart[0][1] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[0][1] = fixedPoint & 0xFFFF; +} + +/** + * Creates a general scale, rotation, translation matrix. + * + * @note The axis vector is expected to be normalised. + * + * The transformations are applied in the order scale, rotate, translate: \$f SRT \$f + * + * The result should be + * \f[ + * \begin{bmatrix} + * s_x((1-a_x^2) \cos \theta + a_x^2) & s_x(a_x a_y (1 - \cos \theta) + a_z \sin \theta) & s_x(a_z a_x (1 - \cos + * \theta) - a_y \sin \theta & 0) \\ + * s_y(a_x a_y (1 - \cos \theta) - a_z \sin \theta) & s_y((1-a_y^2) \cos \theta + a_y^2) & s_z(a_y a_z (1 - \cos + * \theta) + a_x \sin \theta) & 0 \\ + * s_z(a_z a_x (1 - \cos \theta) + a_y \sin \theta) & s_z(a_y a_z (1 - \cos \theta) - a_x \sin \theta) & + * s_z((1-a_z^2) \cos \theta + a_z^2) & 0 \\ + * 0 & 0 & 0 & 1 + * \end{bmatrix} . + * \f] + * + * @warning There is a significant bug in this function, which means it does not actually produce a proper rotation + * matrix; see inline for details. + * + * @param[out] mtx Fixed-point matrix pointer to output to + * @param[in] scaleX Scale in the X direction + * @param[in] scaleY Scale in the Y direction + * @param[in] scaleZ Scale in the Z direction + * @param[in] angle angle to rotate about axis + * @param[in] axisX X component of axis to rotate about + * @param[in] axisY Y component of axis to rotate about + * @param[in] axisZ Z component of axis to rotate about + * @param[in] translateX X component of translation + * @param[in] translateY Y component of translation + * @param[in] translateZ Z component of translation + * + * @remark Original name: probably something like "suMtxMakeSRT", although Animal Forest function is a Tait-Bryan + * rotation rather than axis-angle. + */ +void Mtx_SetTranslationRotationScaleMtx(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, s32 angle, f32 axisX, f32 axisY, + f32 axisZ, f32 translateX, f32 translateY, f32 translateZ) { + f32 tempX; + f32 tempY; + f32 tempZ; + f32 sin = Math_SinS(angle); + f32 cos = Math_CosS(angle); + f32 tempXX = axisX * axisX; + f32 tempYY = axisY * axisY; + f32 tempZZ = axisZ * axisZ; + s32 fixedPoint; + + tempX = axisY * axisZ * (1.0f - cos); + + // i00 and f00 + fixedPoint = (tempXX + (1.0f - tempXX) * cos) * scaleX * 0x10000; + mtx->intPart[0][0] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[0][0] = fixedPoint & 0xFFFF; + + tempY = axisZ * axisX * (1.0f - cos); + + // i21 and f21 + fixedPoint = (tempX - axisX * sin) * scaleZ * 0x10000; + mtx->intPart[2][1] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[2][1] = fixedPoint & 0xFFFF; + + tempZ = axisX * axisY * (1.0f - cos); + + // [i12, i13] and [f12, f13] + fixedPoint = (tempX + axisX * sin) * scaleY * 0x10000; + mtx->m[0][3] = fixedPoint; // i13 dirty + mtx->intPart[1][3] = 0; // clean i13 + mtx->m[2][3] = fixedPoint << 0x10; + + // i11 and f11 + fixedPoint = (tempYY + (1.0f - tempYY) * cos) * scaleY * 0x10000; + mtx->intPart[1][1] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[1][1] = fixedPoint & 0xFFFF; + + //! @bug The sign of the `axisY * sin` term is wrong on the next two elements (i/f20 and i/f02), which causes the + //! matrix to not be a rotation matrix (and indeed not even necessarily invertible). + // i20, f20 + fixedPoint = (tempY - axisY * sin) * scaleZ * 0x10000; + mtx->intPart[2][0] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[2][0] = fixedPoint & 0xFFFF; + + // [i02, i03] and [f02, f03] + fixedPoint = (tempY + axisY * sin) * scaleX * 0x10000; + mtx->m[0][1] = fixedPoint; // [i03, i03], i03 dirty + mtx->intPart[0][3] = 0; // clean i03 + mtx->m[2][1] = fixedPoint << 0x10; // [f02, f03] + + // [i22, i23] and [f22, f23] + fixedPoint = (tempZZ + (1.0f - tempZZ) * cos) * scaleZ * 0x10000; + mtx->m[1][1] = fixedPoint; + mtx->intPart[2][3] = 0; + mtx->m[3][1] = fixedPoint << 0x10; + + // i10 and f10 + fixedPoint = (tempZ - axisZ * sin) * scaleY * 0x10000; + mtx->intPart[1][0] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[1][0] = fixedPoint & 0xFFFF; + + // i01 and f01 + fixedPoint = (tempZ + axisZ * sin) * scaleX * 0x10000; + mtx->intPart[0][1] = ((u32)fixedPoint >> 0x10) & 0xFFFF; + mtx->fracPart[0][1] = fixedPoint & 0xFFFF; + + // [i30, i31] and f30 + fixedPoint = translateX * 0x10000; + mtx->m[1][2] = fixedPoint; // [i30, i31], i31 dirty + mtx->fracPart[3][0] = fixedPoint & 0xFFFF; // f30 + + // i31 and f31 + fixedPoint = translateY * 0x10000; + mtx->intPart[3][1] = ((u32)fixedPoint >> 0x10) & 0xFFFF; // overwrite i31 + mtx->fracPart[3][1] = fixedPoint & 0xFFFF; // overwrite f31 + + // [i32, i33] and [f32, f33] + fixedPoint = translateZ * 0x10000; + mtx->m[1][3] = fixedPoint; // [i32, i33] + mtx->intPart[3][3] = 1; // clean i33 + mtx->m[3][3] = (fixedPoint << 0x10); // [f32, f33] +} diff --git a/src/code/sys_math_atan.c b/src/code/sys_math_atan.c index 09f355d64..72383b6b9 100644 --- a/src/code/sys_math_atan.c +++ b/src/code/sys_math_atan.c @@ -77,63 +77,65 @@ 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) { - return Math_Atan2S(opposite, adjacent); +// Match the OoT implementation of Math_Atan2S +s16 Math_Atan2S_XY(f32 x, f32 y) { + return Math_Atan2S(y, x); } -f32 Math_Acot2F(f32 adjacent, f32 opposite) { - return Math_Atan2F(opposite, adjacent); +// Match the OoT implementation of Math_Atan2F +f32 Math_Atan2F_XY(f32 x, f32 y) { + return Math_Atan2F(y, x); } 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/title_setup.c b/src/code/title_setup.c index 69790b60c..4e9293ce7 100644 --- a/src/code/title_setup.c +++ b/src/code/title_setup.c @@ -1,18 +1,19 @@ -#include "global.h" +#include "z_title_setup.h" #include "overlays/gamestates/ovl_title/z_title.h" -void TitleSetup_GameStateResetContext(void) { +void Setup_SetRegs(void) { XREG(2) = 0; XREG(10) = 0x1A; XREG(11) = 0x14; XREG(12) = 0xE; XREG(13) = 0; - XREG(31) = 0; - XREG(41) = 0x50; - XREG(43) = 0xFC54; + R_A_BTN_Y_OFFSET = 0; + R_MAGIC_CONSUME_TIMER_GIANTS_MASK = 80; + + R_THREE_DAY_CLOCK_Y_POS = 64596; + R_THREE_DAY_CLOCK_SUN_MOON_CUTOFF = 215; + R_THREE_DAY_CLOCK_HOUR_DIGIT_CUTOFF = 218; - XREG(44) = 0xD7; - XREG(45) = 0xDA; XREG(68) = 0x61; XREG(69) = 0x93; XREG(70) = 0x28; @@ -23,45 +24,44 @@ void TitleSetup_GameStateResetContext(void) { XREG(77) = 0x3C; XREG(78) = 0x2F; XREG(79) = 0x62; - XREG(87) = 0; + R_PAUSE_OWLWARP_ALPHA = 0; XREG(88) = 0x56; XREG(89) = 0x258; XREG(90) = 0x1C2; - XREG(91) = 0; - XREG(94) = 0; - XREG(95) = 0; - YREG(32) = 0x50; - YREG(33) = 0x3C; - YREG(34) = 0xDC; - YREG(35) = 0x3C; - YREG(36) = 0x50; - YREG(37) = 0xA0; - YREG(38) = 0xDC; - YREG(39) = 0xA0; - YREG(40) = 0x8E; - YREG(41) = 0x6C; - YREG(42) = 0xCC; - YREG(43) = 0xB1; + R_STORY_FILL_SCREEN_ALPHA = 0; + R_REVERSE_FLOOR_INDEX = 0; + R_MINIMAP_DISABLED = false; + + R_PICTO_FOCUS_BORDER_TOPLEFT_X = 80; + R_PICTO_FOCUS_BORDER_TOPLEFT_Y = 60; + R_PICTO_FOCUS_BORDER_TOPRIGHT_X = 220; + R_PICTO_FOCUS_BORDER_TOPRIGHT_Y = 60; + R_PICTO_FOCUS_BORDER_BOTTOMLEFT_X = 80; + R_PICTO_FOCUS_BORDER_BOTTOMLEFT_Y = 160; + R_PICTO_FOCUS_BORDER_BOTTOMRIGHT_X = 220; + R_PICTO_FOCUS_BORDER_BOTTOMRIGHT_Y = 160; + R_PICTO_FOCUS_ICON_X = 142; + R_PICTO_FOCUS_ICON_Y = 108; + R_PICTO_FOCUS_TEXT_X = 204; + R_PICTO_FOCUS_TEXT_Y = 177; } -void TitleSetup_InitImpl(GameState* gameState) { +void Setup_InitImpl(SetupState* this) { func_80185908(); SaveContext_Init(); - TitleSetup_GameStateResetContext(); + Setup_SetRegs(); - gameState->running = 0; - -setNextGamestate - :; // This label is probably a leftover of a debug ifdef, it's essential to not have gameState->running reordered! - SET_NEXT_GAMESTATE(gameState, Title_Init, TitleContext); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, ConsoleLogo_Init, sizeof(ConsoleLogoState)); } -void TitleSetup_Destroy(GameState* gameState) { - ; +void Setup_Destroy(GameState* thisx) { } -void TitleSetup_Init(GameState* gameState) { - gameState->destroy = TitleSetup_Destroy; - TitleSetup_InitImpl(gameState); +void Setup_Init(GameState* thisx) { + SetupState* this = (SetupState*)thisx; + + this->state.destroy = Setup_Destroy; + Setup_InitImpl(this); } 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 6d0b9573d..919752d74 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -4,6 +4,9 @@ */ #include "global.h" +#include "z64load.h" +#include "z64quake.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 +32,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 +66,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 +74,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); @@ -101,67 +104,67 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf 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)); dir0 = light->l.dir[0]; dir2 = light->l.dir[2]; - sp58 = Math_FAtan2F(dir2, dir0); + sp58 = Math_Atan2S_XY(dir2, dir0); shadowScaleZ *= (4.5f - (light->l.dir[1] * 0.035f)); shadowScaleZ = CLAMP_MIN(shadowScaleZ, 1.0f); 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) { @@ -169,20 +172,20 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx u8 shadowAlpha = actor->shape.shadowAlpha; f32 alphaRatio; - if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & 0x8000)) { - f32 tmpScaleZ = actor->scale.z; + if ((actor->id == ACTOR_PLAYER) && (((Player*)actor)->stateFlags3 & PLAYER_STATE3_8000)) { + 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; @@ -213,7 +216,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 +224,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,10 +235,10 @@ 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; @@ -258,7 +261,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx if (lightNum > 0) { lightNumMax += lightNum; - ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, + ActorShadow_DrawFoot(play, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX, shadowScaleZ); } } @@ -271,7 +274,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx 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); } } @@ -294,7 +297,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -307,18 +310,18 @@ void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* lef } } -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; @@ -334,7 +337,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) { @@ -348,13 +351,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); @@ -370,7 +373,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); } } } @@ -380,22 +383,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) { @@ -417,15 +416,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; @@ -440,7 +439,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; @@ -455,7 +454,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; @@ -463,24 +462,25 @@ 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)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | + PLAYER_STATE1_400 | PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000))) { 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; @@ -503,24 +503,24 @@ 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)) { + if ((!(player->stateFlags1 & PLAYER_STATE1_40)) || (actor != player->targetedActor)) { OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 0x39); for (spB0 = 0, spAC = targetCtx->unk4C; spB0 < spB8; spB0++, spAC = (spAC + 1) % 3) { @@ -545,8 +545,7 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { Matrix_RotateZS(0x4000, MTXMODE_APPLY); Matrix_Push(); Matrix_Translate(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); Matrix_Pop(); } @@ -569,31 +568,31 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) { Matrix_Translate(actor->focus.pos.x, actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, actor->focus.pos.z, MTXMODE_NEW); - Matrix_RotateYS((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY); + Matrix_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)) { + if ((player->targetedActor != NULL) && (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; } @@ -636,12 +635,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; } } @@ -650,7 +650,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; @@ -692,9 +692,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.sceneFlags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); } return 0; } @@ -702,97 +702,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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.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.sceneFlags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F)); } return 0; } @@ -800,9 +800,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.sceneFlags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F); } } @@ -862,10 +862,11 @@ void TitleCard_Draw(GameState* gameState, TitleCardContext* titleCtx) { OPEN_DISPS(gameState->gfxCtx); - height = (width * height > TMEM_SIZE) ? TMEM_SIZE / width : height; - spB4 = spB8 + (height * 4); + if (width * height > TMEM_SIZE) { + height = TMEM_SIZE / width; + } - if (1) {} + spB4 = spB8 + (height * 4); OVERLAY_DISP = func_8012C014(OVERLAY_DISP); @@ -897,8 +898,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; @@ -906,57 +907,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); @@ -978,18 +979,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) { @@ -1011,11 +1012,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; } @@ -1026,7 +1027,7 @@ void* func_800B6680(GlobalContext* globalCtx, s16 id) { return NULL; } -void Actor_MarkForDeath(Actor* actor) { +void Actor_Kill(Actor* actor) { actor->draw = NULL; actor->update = NULL; actor->flags &= ~ACTOR_FLAG_1; @@ -1060,11 +1061,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] = VIRTUAL_TO_PHYSICAL(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); @@ -1078,23 +1079,23 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) { actor->uncullZoneScale = 350.0f; actor->uncullZoneDownward = 700.0f; - actor->hintId = 255; + actor->hintId = TATL_HINT_ID_NONE; CollisionCheck_InitInfo(&actor->colChkInfo); actor->floorBgId = BGCHECK_SCENE; ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); - if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { - Actor_SetObjectDependency(globalCtx, actor); - actor->init(actor, globalCtx); + 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; } } @@ -1279,8 +1280,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; @@ -1291,7 +1292,7 @@ void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 magnitude, s16 ba f32 Player_GetHeight(Player* player) { f32 extraHeight; - if (player->stateFlags1 & 0x800000) { + if (player->stateFlags1 & PLAYER_STATE1_800000) { extraHeight = 32.0f; } else { extraHeight = 0.0f; @@ -1302,8 +1303,7 @@ f32 Player_GetHeight(Player* player) { case PLAYER_FORM_FIERCE_DEITY: return extraHeight + 124.0f; case PLAYER_FORM_GORON: - // (player->stateFlags3 & 0x1000): being curled? - return extraHeight + ((player->stateFlags3 & 0x1000) ? 34.0f : 80.0f); + return extraHeight + ((player->stateFlags3 & PLAYER_STATE3_1000) ? 34.0f : 80.0f); case PLAYER_FORM_ZORA: return extraHeight + 68.0f; case PLAYER_FORM_DEKU: @@ -1314,9 +1314,9 @@ f32 Player_GetHeight(Player* player) { } f32 Player_GetRunSpeedLimit(Player* player) { - if (player->stateFlags1 & 0x800000) { + if (player->stateFlags1 & PLAYER_STATE1_800000) { return 15.0f; - } else if (player->stateFlags1 & 0x8000000) { + } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { return (R_RUN_SPEED_LIMIT / 100.0f) * 0.6f; } else { return R_RUN_SPEED_LIMIT / 100.0f; @@ -1324,47 +1324,47 @@ f32 Player_GetRunSpeedLimit(Player* player) { } s32 func_800B7118(Player* player) { - return player->stateFlags1 & 0x8; + return player->stateFlags1 & PLAYER_STATE1_8; } s32 func_800B7128(Player* player) { - return func_800B7118(player) && player->unk_ACC; + return func_800B7118(player) && (player->unk_ACC != 0); } -s32 func_800B715C(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_800B715C(PlayState* play) { + Player* player = GET_PLAYER(play); - return player->stateFlags2 & 0x8; + return player->stateFlags2 & PLAYER_STATE2_8; } -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.curRoom.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; + player->stateFlags1 |= PLAYER_STATE1_800000; horse->child = &player->actor; } s32 func_800B7200(Player* player) { - return (player->stateFlags1 & 0x20000080) || (player->csMode != 0); + return (player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_20000000)) || (player->csMode != PLAYER_CSMODE_0); } 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))) { + if ((player->csMode == PLAYER_CSMODE_5) || ((csMode == PLAYER_CSMODE_6) && (player->csMode == PLAYER_CSMODE_0))) { return false; } @@ -1374,10 +1374,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); +s32 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; } @@ -1399,8 +1399,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) { @@ -1489,11 +1489,11 @@ s32 Actor_ActorAIsFacingAndNearActorB(Actor* actorA, Actor* actorB, f32 range, s /* Start of BgCheck related section */ -void func_800B75A0(CollisionPoly* poly, Vec3f* normal, s16* azimuth) { - normal->x = COLPOLY_GET_NORMAL(poly->normal.x); - normal->y = COLPOLY_GET_NORMAL(poly->normal.y); - normal->z = COLPOLY_GET_NORMAL(poly->normal.z); - *azimuth = Math_FAtan2F(normal->z, normal->x); +void Actor_GetSlopeDirection(CollisionPoly* floorPoly, Vec3f* slopeNormal, s16* downwardSlopeYaw) { + slopeNormal->x = COLPOLY_GET_NORMAL(floorPoly->normal.x); + slopeNormal->y = COLPOLY_GET_NORMAL(floorPoly->normal.y); + slopeNormal->z = COLPOLY_GET_NORMAL(floorPoly->normal.z); + *downwardSlopeYaw = Math_Atan2S_XY(slopeNormal->z, slopeNormal->x); } s32 func_800B761C(Actor* actor, f32 arg1, s32 arg2) { @@ -1510,14 +1510,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); @@ -1552,7 +1551,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); @@ -1561,14 +1560,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) { @@ -1576,10 +1575,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; @@ -1591,7 +1590,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe Math_Vec3f_Copy(&actor->world.pos, &pos); } - actor->wallYaw = Math_FAtan2F(sp7C->normal.z, sp7C->normal.x); + actor->wallYaw = Math_Atan2S_XY(sp7C->normal.z, sp7C->normal.x); actor->wallBgId = bgId; } else { actor->bgCheckFlags &= ~8; @@ -1604,7 +1603,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; @@ -1617,11 +1616,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); @@ -1634,9 +1632,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; @@ -1651,8 +1649,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) { @@ -1666,9 +1663,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; @@ -1720,41 +1717,37 @@ 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* gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; - displayListHead = displayList; + OPEN_DISPS(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + gDPSetHilite1Tile(gfx++, 1, hilite, 0x10, 0x10); + gSPEndDisplayList(gfx++); + gSPSegment(POLY_OPA_DISP++, 0x07, gfxHead); - 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* gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; - displayListHead = displayList; + OPEN_DISPS(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + gDPSetHilite1Tile(gfx++, 1, hilite, 0x10, 0x10); + gSPEndDisplayList(gfx++); + gSPSegment(POLY_XLU_DISP++, 0x07, gfxHead); - gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); - gSPEndDisplayList(displayListHead); - gSPSegment(POLY_XLU_DISP++, 0x07, displayList); - - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -1790,7 +1783,7 @@ f32 func_800B82EC(Actor* actor, Player* player, s16 angle) { s16 temp_v0 = BINANG_SUB(BINANG_SUB(actor->yawTowardsPlayer, 0x8000), angle); s16 yaw = ABS_ALT(temp_v0); - if (player->unk_730 != NULL) { + if (player->targetedActor != NULL) { if ((yaw > 0x4000) || ((actor->flags & ACTOR_FLAG_8000000))) { return FLT_MAX; } @@ -1828,7 +1821,7 @@ s32 func_800B83F8(Actor* actor, Player* player, s32 flag) { s16 phi_v1 = ABS_ALT(yaw); f32 dist; - if ((player->unk_730 == NULL) && (phi_v1 >= 0x2AAB)) { + if ((player->targetedActor == NULL) && (phi_v1 >= 0x2AAB)) { dist = FLT_MAX; } else { dist = actor->xyzDistToPlayerSq; @@ -1855,41 +1848,40 @@ 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, PlayerItemAction 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_IA_NONE) && Player_InCsMode(play)) || (!actor->isTargeted && - ((fabsf(actor->playerHeightRel) > fabsf(yRange)) || ((actor->xzDistToPlayer > player->targetActorDistance)) || + ((fabsf(actor->playerHeightRel) > fabsf(yRange)) || (actor->xzDistToPlayer > player->talkActorDistance) || (xzRange < actor->xzDistToPlayer)))) { return false; } - player->targetActor = actor; - player->targetActorDistance = actor->xzDistToPlayer; + player->talkActor = actor; + player->talkActorDistance = actor->xzDistToPlayer; player->exchangeItemId = exchangeItemId; ActorCutscene_SetIntentToPlay(0x7C); return true; } -s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 radius, s32 exchangeItemId) { - return func_800B8500(actor, globalCtx, radius, radius, exchangeItemId); +s32 func_800B85E0(Actor* actor, PlayState* play, f32 radius, PlayerItemAction 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_IA_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; } @@ -1901,23 +1893,23 @@ 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) { - Actor* targetActor; - Player* player = GET_PLAYER(globalCtx); +s32 Actor_ChangeFocus(Actor* actor1, PlayState* play, Actor* actor2) { + Actor* talkActor; + Player* player = GET_PLAYER(play); - targetActor = player->targetActor; + talkActor = player->talkActor; - if ((player->actor.flags & ACTOR_FLAG_100) && (targetActor != NULL)) { - player->targetActor = actor2; - player->unk_730 = actor2; + if ((player->actor.flags & ACTOR_FLAG_100) && (talkActor != NULL)) { + player->talkActor = actor2; + player->targetedActor = actor2; return true; } return false; } -s32 Player_GetExchangeItemId(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +PlayerItemAction Player_GetExchangeItemId(PlayState* play) { + Player* player = GET_PLAYER(play); return player->exchangeItemId; } @@ -1932,10 +1924,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; @@ -1946,44 +1938,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 { @@ -1998,16 +1992,19 @@ 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, GetItemId getItemId, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_80 | PLAYER_STATE1_1000 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_80000 | PLAYER_STATE1_100000 | PLAYER_STATE1_200000)) && + 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->talkActor) && (getItemId > GI_NONE && getItemId < GI_MAX))) || - (!(player->stateFlags1 & 0x20000800))) { + !(player->stateFlags1 & (PLAYER_STATE1_800 | PLAYER_STATE1_20000000))) { s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; s32 absYawDiff = ABS_ALT(yawDiff); @@ -2017,7 +2014,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; @@ -2029,19 +2026,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, GetItemId 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, GetItemId 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; } @@ -2049,7 +2046,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) { @@ -2064,15 +2061,19 @@ void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) { actorA->parent = NULL; } -void func_800B8C50(Actor* actor, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +/** + * Sets closest secret distance to the distance to the actor. Calling this function on `actor` is the way to make it a + * 'secret' for that update cycle, i.e. something that the controller will rumble for. + */ +void func_800B8C50(Actor* actor, PlayState* play) { + Player* player = GET_PLAYER(play); - if (actor->xyzDistToPlayerSq < player->unk_AA0) { - player->unk_AA0 = actor->xyzDistToPlayerSq; + if (actor->xyzDistToPlayerSq < player->closestSecretDistSq) { + player->closestSecretDistSq = actor->xyzDistToPlayerSq; } } -s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse) { +s32 Actor_HasRider(PlayState* play, Actor* horse) { if (horse->child != NULL) { return true; } @@ -2080,10 +2081,12 @@ 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)) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_80 | PLAYER_STATE1_800 | PLAYER_STATE1_1000 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | + PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_100000 | PLAYER_STATE1_200000))) { player->rideActor = horse; player->mountSide = mountSide; ActorCutscene_SetIntentToPlay(0x7C); @@ -2093,7 +2096,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; } @@ -2101,8 +2104,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; @@ -2111,27 +2114,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); } } @@ -2142,7 +2146,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) { @@ -2152,7 +2156,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); @@ -2207,18 +2211,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, Vec3f* 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 Actor_DeactivateLens(PlayState* play) { + if (play->actorCtx.lensActive) { + play->actorCtx.lensActive = false; + Magic_Reset(play); } } @@ -2232,18 +2236,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)]; + SET_WEEKEVENTREG(WEEKEVENTREG_92_80); + cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneId(play->sceneId)]; 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++) { @@ -2252,64 +2256,64 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn overlayEntry++; } - 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]; + actorCtx->sceneFlags.chest = cycleFlags->chest; + actorCtx->sceneFlags.switches[0] = cycleFlags->switch0; + actorCtx->sceneFlags.switches[1] = cycleFlags->switch1; + if (play->sceneId == SCENE_INISIE_R) { + cycleFlags = &gSaveContext.cycleSceneFlags[play->sceneId]; } - actorCtx->flags.collectible[0] = cycleFlags->collectible; - actorCtx->flags.clearedRoom = cycleFlags->clearedRoom; + actorCtx->sceneFlags.collectible[0] = cycleFlags->collectible; + actorCtx->sceneFlags.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; } 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); + (!CHECK_EVENTINF(EVENTINF_17) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) { + 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; @@ -2320,7 +2324,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; @@ -2332,29 +2336,27 @@ 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)) { - Actor_MarkForDeath(actor); + if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + Actor_Kill(actor); } else { - s32 tmp = (params->unk_08 == 0); - if (((params->unk_08) && !(actor->flags & params->unk_08)) || - ((tmp = (params->unk_08 == 0)) && + ((((!params->unk_08) != 0)) && (!(actor->flags & ACTOR_FLAG_100000) || - ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & 0x200))) && + ((actor->category == ACTORCAT_EXPLOSIVES) && (params->player->stateFlags1 & PLAYER_STATE1_200))) && (params->unkC != 0) && (actor != params->unk10) && ((actor != params->player->heldActor)) && (actor->parent != ¶ms->player->actor))) { CollisionCheck_ResetDamage(&actor->colChkInfo); @@ -2368,24 +2370,24 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { actor->flags &= ~ACTOR_FLAG_1000000; if ((DECR(actor->freezeTimer) == 0) && (actor->flags & params->unk_18)) { - if (actor == params->player->unk_730) { + if (actor == params->player->targetedActor) { actor->isTargeted = true; } else { actor->isTargeted = false; } - if ((actor->targetPriority != 0) && (params->player->unk_730 == 0)) { + if ((actor->targetPriority != 0) && (params->player->targetedActor == NULL)) { 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); @@ -2396,15 +2398,41 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) { return nextActor; } -u32 D_801AED58[] = { - 0x100002C2, 0x100002C2, 0x00000200, 0x100006C2, 0x00000282, 0x300002C2, - 0x10000282, 0x00000002, 0x300002C2, 0x100006C2, 0x00000002, 0x100002C2, +u32 D_801AED58[ACTORCAT_MAX] = { + /* ACTORCAT_SWITCH */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, + /* ACTORCAT_BG */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, + /* ACTORCAT_PLAYER */ + PLAYER_STATE1_200, + /* ACTORCAT_EXPLOSIVES */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_400 | + PLAYER_STATE1_10000000, + /* ACTORCAT_NPC */ + PLAYER_STATE1_2 | PLAYER_STATE1_80 | PLAYER_STATE1_200, + /* ACTORCAT_ENEMY */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000 | + PLAYER_STATE1_20000000, + /* ACTORCAT_PROP */ + PLAYER_STATE1_2 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, + /* ACTORCAT_ITEMACTION */ + PLAYER_STATE1_2, + /* ACTORCAT_MISC */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000 | + PLAYER_STATE1_20000000, + /* ACTORCAT_BOSS */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_400 | + PLAYER_STATE1_10000000, + /* ACTORCAT_DOOR */ + PLAYER_STATE1_2, + /* ACTORCAT_CHEST */ + PLAYER_STATE1_2 | PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000, }; -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; @@ -2412,15 +2440,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--; @@ -2428,14 +2456,14 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { tmp = D_801AED58; - if (player->stateFlags2 & 0x8000000) { + if (player->stateFlags2 & PLAYER_STATE2_8000000) { params.unk_08 = 0x2000000; } else { params.unk_08 = 0; } - if ((player->stateFlags1 & 0x40) && ((player->actor.textId & 0xFF00) != 0x1900)) { - params.unk10 = player->targetActor; + if ((player->stateFlags1 & PLAYER_STATE1_40) && ((player->actor.textId & 0xFF00) != 0x1900)) { + params.unk10 = player->talkActor; } else { params.unk10 = NULL; } @@ -2449,7 +2477,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } if (i == ACTORCAT_BG) { - DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna); + DynaPoly_Setup(play, &play->colCtx.dyna); } } @@ -2464,7 +2492,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; } @@ -2473,7 +2501,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } } - actor = player->unk_730; + actor = player->targetedActor; if ((actor != NULL) && (actor->update == NULL)) { actor = NULL; func_80123DA4(player); @@ -2487,44 +2515,44 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } } - if (!(player->stateFlags1 & 2)) { - func_800B5814(&actorCtx->targetContext, player, actor, &globalCtx->state); + if (!(player->stateFlags1 & PLAYER_STATE1_2)) { + 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.curRoom.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_SetTranslateRotateYXZ( - actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x, - actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y), - actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot); + 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_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 +2570,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 +2599,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,227 +2623,154 @@ 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.lensActorsDrawn = false; } -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; } -void func_800B9E84(Gfx** arg0, s32 arg1) { - func_80164C14(arg0, D_801DE890, 4, 0, 6, 6, ((100 - arg1) * 0.003f) + 1.0f); +void Actor_DrawLensOverlay(Gfx** gfxP, s32 lensMaskSize) { + TransitionCircle_LoadAndSetTexture(gfxP, gCircleTex, 4, 0, 6, 6, + ((LENS_MASK_ACTIVE_SIZE - lensMaskSize) * 0.003f) + 1.0f); } -#ifdef NON_EQUIVALENT -// Related to draw actors with lens -void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) { +void Actor_DrawLensActors(PlayState* play, s32 numInvisibleActors, Actor** invisibleActors) { + s32 dbgVar1; + s32 dbgVar2; s32 spB4; + Actor** invisibleActor; Gfx* spAC; - void* spA8; // pad - s32 spA4; - // void* sp34; - // Gfx* temp_s1_11; - // Gfx** temp_a0_2; - // Gfx** temp_a1; - // GraphicsContext* temp_s2; - // void* temp_s1_10; - // void* temp_s1_7; - // void* temp_s1_8; - // void* temp_s1_9; - // Gfx* phi_s1; - Gfx* phi_s1_2; - // void* phi_s1_4; + void* spA8; + void* spA4; + GraphicsContext* gfxCtx = play->state.gfxCtx; + Gfx* tmp; + s32 pad[2]; - OPEN_DISPS(globalCtx->state.gfxCtx); - // temp_s2 = globalCtx->state.gfxCtx; + dbgVar1 = true; + dbgVar2 = true; - if (numActors > 0) { - spAC = POLY_XLU_DISP; - // sp34 = globalCtx + 0x18000; - spA4 = globalCtx->unk_18E68; + if (dbgVar1) { + dbgVar1 = numInvisibleActors > 0; + } - PreRender_SetValues(&globalCtx->pauseBgPreRender, D_801FBBCC, D_801FBBCE, __gfxCtx->curFrameBuffer, - __gfxCtx->zbuffer); + OPEN_DISPS(gfxCtx); - func_80170200(&globalCtx->pauseBgPreRender, &spAC, __gfxCtx->zbuffer, (void*)spA4); + if (dbgVar1) { + tmp = POLY_XLU_DISP; + spA8 = gfxCtx->zbuffer; + spA4 = play->unk_18E68; - // spAC->words.w0 = 0xE7000000; - // spAC->words.w1 = 0; - // temp_s1_2 = spAC + 8; - gDPPipeSync(spAC++); + if (dbgVar2) { + PreRender_SetValues(&play->pauseBgPreRender, D_801FBBCC, D_801FBBCE, gfxCtx->curFrameBuffer, spA8); - // temp_s1_2->words.w0 = 0xEE000000; - // temp_s1_2->words.w1 = 0; - // temp_s1_3 = temp_s1_2 + 8; - gDPSetPrimDepth(spAC++, 0, 0); + spAC = tmp; + func_80170200(&play->pauseBgPreRender, &spAC, spA8, spA4); + tmp = spAC; + } - // temp_s1_3->words.w0 = 0xEF002C30; - // temp_s1_3->words.w1 = 0xAF504365; - // temp_s1_4 = temp_s1_3 + 8; - gDPSetOtherMode(spAC++, + gDPPipeSync(tmp++); + gDPSetPrimDepth(tmp++, 0, 0); + + gDPSetOtherMode(tmp++, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PRIM | Z_UPD | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c1(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA) | GBL_c2(G_BL_CLR_BL, G_BL_0, G_BL_CLR_MEM, G_BL_1MA)); - // temp_s1_4->words.w1 = 0xFF; - // temp_s1_4->words.w0 = 0xFA000000; - // temp_s1_5 = temp_s1_4 + 8; - gDPSetPrimColor(spAC++, 0, 0, 0, 0, 0, 255); - // temp_s1_5 = spAC; + gDPSetPrimColor(tmp++, 0, 0, 0, 0, 0, 255); - if (globalCtx->roomCtx.currRoom.unk5 == 0) { - // temp_s1_5->words.w0 = 0xFC61E6C3; - // temp_s1_5->words.w1 = 0x11CF9FCF; - // phi_s1 = temp_s1_5 + 8; - gDPSetCombineLERP(spAC++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + if (play->roomCtx.curRoom.unk5 == 0) { + gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0); } else { - // temp_s1_5->words.w0 = 0xFC119623; - // temp_s1_5->words.w1 = 0xFF2FFFFF; - // phi_s1 = temp_s1_5 + 8; - gDPSetCombineMode(spAC++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetCombineMode(tmp++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); } - // spAC = phi_s1; - func_800B9E84(&spAC, globalCtx->actorCtx.unk4); - phi_s1_2 = func_801660B8(globalCtx, spAC); + spAC = tmp; + Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); + tmp = func_801660B8(play, spAC); - for (spB4 = 0; spB4 < numActors; spB4++, actors++) { - Actor_Draw(globalCtx, *actors); + for (spB4 = 0, invisibleActor = invisibleActors; spB4 < numInvisibleActors; spB4++, invisibleActor++) { + POLY_XLU_DISP = tmp; + Actor_Draw(play, *invisibleActor); + tmp = POLY_XLU_DISP; } - // temp_s0_2 = &globalCtx->pauseBgPreRender; + if (dbgVar2) { + gDPPipeSync(tmp++); - // phi_s1_2->words.w0 = 0xE7000000; - // phi_s1_2->words.w1 = 0; - // temp_s1_7 = phi_s1_2 + 8; - gDPPipeSync(phi_s1_2++); + gDPSetOtherMode(tmp++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_WRAP | ZMODE_OPA | CVG_X_ALPHA | + ALPHA_CVG_SEL | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1) | + GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1)); - // temp_s1_7->unk_0 = 0xEF002CF0; - // temp_s1_7->unk_4 = 0xF5A714D; - // temp_s1_8 = temp_s1_7 + 8; - gDPSetOtherMode(phi_s1_2++, - G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | - G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, - G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_WRAP | ZMODE_OPA | CVG_X_ALPHA | - ALPHA_CVG_SEL | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1) | - GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_MEM, G_BL_1)); + gDPSetBlendColor(tmp++, 255, 255, 255, 0); + gDPSetPrimColor(tmp++, 0, 0xFF, 0, 0, 0, 32); - // temp_s1_8->unk_4 = -0x100; - // temp_s1_8->unk_0 = 0xF9000000; - // temp_s1_9 = temp_s1_8 + 8; - gDPSetBlendColor(phi_s1_2++, 255, 255, 255, 0); + if (play->roomCtx.curRoom.unk5 == 0) { + gDPSetCombineMode(tmp++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + } else { + gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, + TEXEL0, PRIMITIVE, 0); + } - // temp_s1_9->unk_4 = 0x20; - // temp_s1_9->unk_0 = 0xFA0000FF; - // temp_s1_10 = temp_s1_9 + 8; - gDPSetPrimColor(phi_s1_2++, 0, 0xFF, 0, 0, 0, 32); + gDPSetColorImage(tmp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, play->pauseBgPreRender.width, spA4); - // temp_a0_2 = &spAC; - // if (sp34->unk_6E5 == 0) { - if (globalCtx->roomCtx.currRoom.unk5 == 0) { - // temp_s1_10->unk_0 = 0xFC119623; - // temp_s1_10->unk_4 = 0xFF2FFFFF; - // phi_s1_4 = temp_s1_10 + 8; - gDPSetCombineMode(phi_s1_2++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); - //} else { - } else { - // temp_s1_10->unk_4 = 0x11CF9FCF; - // temp_s1_10->unk_0 = 0xFC61E6C3; - // phi_s1_4 = temp_s1_10 + 8; - gDPSetCombineLERP(phi_s1_2++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, - TEXEL0, PRIMITIVE, 0); + spAC = tmp; + Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); + tmp = spAC; - //} + gDPPipeSync(tmp++); + gDPSetBlendColor(tmp++, 255, 255, 255, 8); + + gDPSetColorImage(tmp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, play->pauseBgPreRender.width, + play->pauseBgPreRender.fbuf); + + spAC = tmp; + func_8016FDB8(&play->pauseBgPreRender, &spAC, (void*)spA4, spA8, 1); + tmp = spAC; } - // phi_s1_4->unk_0 = (s32) (((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000); - // temp_s1_11 = phi_s1_4 + 8; - // phi_s1_4->unk_4 = spA4; - gDPSetColorImage(phi_s1_2++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF), - spA4); - // temp_s1_11 = phi_s1_2; - spAC = phi_s1_2; - - // spAC = temp_s1_11; - func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4); - // temp_s1_11->words.w0 = 0xE7000000; - // temp_s1_11->words.w1 = 0; - // temp_s1_12 = temp_s1_11 + 8; - gDPPipeSync(spAC++); - - // temp_s1_12->words.w1 = -0xF8; - // temp_s1_12->words.w0 = 0xF9000000; - // temp_s1_13 = temp_s1_12 + 8; - gDPSetBlendColor(spAC++, 255, 255, 255, 8); - - // temp_s1_14 = temp_s1_13 + 8; - // temp_s1_13->words.w0 = ((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000; - // temp_s1_13->words.w1 = sp34->unk_B5C; - gDPSetColorImage(spAC++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF), - globalCtx->pauseBgPreRender.fbuf); - - // temp_a1 = &spAC; - // spAC = temp_s1_14; - // func_8016FDB8(&globalCtx->pauseBgPreRender, temp_a1, (void* ) spA4, spA8, 1U); - func_8016FDB8(&globalCtx->pauseBgPreRender, &spAC, (void*)spA4, __gfxCtx->zbuffer, 1U); - // - // POLY_OPA_DISP = temp_s1_14; - POLY_OPA_DISP = spAC; + POLY_XLU_DISP = tmp; } - // temp_s1_15 = OVERLAY_DISP; - // temp_s1_15->words.w0 = 0xE7000000; - // temp_s1_15->words.w1 = 0; - // temp_s1_16 = temp_s1_15 + 8; - spAC = OVERLAY_DISP; - gDPPipeSync(spAC++); + tmp = OVERLAY_DISP; - // temp_s1_16->words.w0 = 0xEF002C30; - // temp_s1_16->words.w1 = 0x00504345; - // temp_s1_17 = temp_s1_16 + 8; - gDPSetOtherMode(spAC++, + gDPPipeSync(tmp++); + + gDPSetOtherMode(tmp++, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, G_AC_THRESHOLD | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); - // temp_s1_17->words.w0 = 0xFC61E6C3; - // temp_s1_17->words.w1 = 0x11CF9FCF; - // temp_s1_18 = temp_s1_17 + 8; - gDPSetCombineLERP(spAC++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, + gDPSetCombineLERP(tmp++, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0, 1, TEXEL0, PRIMITIVE, 0); + gDPSetPrimColor(tmp++, 0, 0, 74, 0, 0, 74); - // temp_s1_18->words.w0 = 0xFA000000; - // temp_s1_18->words.w1 = 0x4A00004A; - // spAC = temp_s1_18 + 8; - gDPSetPrimColor(spAC++, 0, 0, 74, 0, 0, 74); - - func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4); - + spAC = tmp; + Actor_DrawLensOverlay(&spAC, play->actorCtx.lensMaskSize); OVERLAY_DISP = spAC; - CLOSE_DISPS(globalCtx->state.gfxCtx); -} -#else -void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9EF4.s") -#endif - -s32 func_800BA2D8(GlobalContext* globalCtx, Actor* actor) { - return func_800BA2FC(globalCtx, actor, &actor->projectedPos, actor->projectedW); + CLOSE_DISPS(gfxCtx); } -s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW) { +s32 func_800BA2D8(PlayState* play, Actor* actor) { + return func_800BA2FC(play, actor, &actor->projectedPos, actor->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 +2778,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 +2798,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 +2809,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 +2826,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 +2842,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.curRoom.unk5 == 0) || (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) || + (actor->room != play->roomCtx.curRoom.num))) { + if (Actor_RecordUndrawnActor(play, actor)) {} } else { - Actor_Draw(globalCtx, actor); + Actor_Draw(play, actor); } } @@ -2898,25 +2854,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.lensActive) { + Math_StepToC(&play->actorCtx.lensMaskSize, LENS_MASK_ACTIVE_SIZE, 20); + if (GET_PLAYER(play)->stateFlags2 & PLAYER_STATE2_8000000) { + Actor_DeactivateLens(play); } } else { - Math_StepToC(&globalCtx->actorCtx.unk4, 0, 10); + Math_StepToC(&play->actorCtx.lensMaskSize, 0, 10); } - if (globalCtx->actorCtx.unk4 != 0) { - globalCtx->actorCtx.unkB = 1; - func_800B9EF4(globalCtx, globalCtx->actorCtx.undrawnActorCount, globalCtx->actorCtx.undrawnActors); + if (play->actorCtx.lensMaskSize != 0) { + play->actorCtx.lensActorsDrawn = true; + Actor_DrawLensActors(play, play->actorCtx.undrawnActorCount, play->actorCtx.undrawnActors); } tmp2 = POLY_XLU_DISP; @@ -2924,19 +2880,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,8 +2900,8 @@ void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) { actor = actorCtx->actorLists[i].first; while (actor != NULL) { - if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { - Actor_MarkForDeath(actor); + if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + Actor_Kill(actor); } actor = actor->next; @@ -2956,7 +2912,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 +2920,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.curRoom.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_Kill(actor); + Actor_Destroy(actor, play); actor = actor->next; } } else { @@ -2979,14 +2935,14 @@ void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) { } } - CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); - actorCtx->flags.clearedRoomTemp = 0; - actorCtx->flags.switches[3] = 0; - actorCtx->flags.collectible[3] = 0; - globalCtx->msgCtx.unk_12030 = 0; + CollisionCheck_ClearContext(play, &play->colChkCtx); + actorCtx->sceneFlags.clearedRoomTemp = 0; + actorCtx->sceneFlags.switches[3] = 0; + actorCtx->sceneFlags.collectible[3] = 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 +2950,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_Kill(actor); + Actor_Destroy(actor, play); actor = actor->next; } } else { @@ -3008,11 +2964,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 +2978,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 +2993,7 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) { actorCtx->absoluteSpace = NULL; } - Play_SaveCycleSceneFlags(&globalCtx->state); + Play_SaveCycleSceneFlags(&play->state); ActorOverlayTable_Cleanup(); } @@ -3074,7 +3030,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 +3051,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.curRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && (actorCtx->actorLists[ACTORCAT_ENEMY].length == 0)) { - Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + Flags_SetClearTemp(play, play->roomCtx.curRoom.num); } return newHead; @@ -3120,10 +3076,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 +3113,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 +3139,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.curRoom.num) && + (actorInit->id != ACTOR_BOSS_05))) { Actor_FreeOverlay(&gActorOverlayTable[index]); return NULL; } @@ -3224,7 +3179,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.curRoom.num; } actor->home.pos.x = x; @@ -3251,48 +3206,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.curRoom.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.curRoom.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 +3270,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)) { + if ((player != NULL) && (actor == player->targetedActor)) { func_80123DA4(player); - Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCamId(globalCtx)), 0); + Camera_ChangeMode(Play_GetCamera(play, Play_GetActiveCamId(play)), CAM_MODE_NORMAL); } if (actor == actorCtx->targetContext.arrowPointedActor) { @@ -3344,10 +3299,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,19 +3313,19 @@ 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* targetedActor; Actor* actor; s32 phi_s2; CollisionPoly* sp80; @@ -3379,7 +3334,7 @@ void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, s32 phi_s2_2; actor = actorCtx->actorLists[actorCategory].first; - sp8C = player->unk_730; + targetedActor = player->targetedActor; while (actor != NULL) { if ((actor->update != NULL) && ((Player*)actor != player)) { if (actor->flags & (ACTOR_FLAG_40000000 | ACTOR_FLAG_1)) { @@ -3390,7 +3345,7 @@ void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, } } - if ((actor != sp8C) || (actor->flags & ACTOR_FLAG_80000)) { + if ((actor != targetedActor) || (actor->flags & ACTOR_FLAG_80000)) { temp_f0_2 = func_800B82EC(actor, player, D_801ED8DC); phi_s2_2 = (actor->flags & 1) != 0; if (phi_s2_2) { @@ -3403,11 +3358,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 +3439,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,7 +3490,7 @@ 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; @@ -3544,19 +3498,19 @@ void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx* if (*dList != NULL) { 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; Matrix_MtxFToYXZRot(currentMatrix, &part->actor.shape.rot, false); - part->unk_150 = *dList; + 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 +3529,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 +3555,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 +3592,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 +3601,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 +3632,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 +3654,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 +3671,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,10 +3684,10 @@ 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) { + if ((player->stateFlags3 & PLAYER_STATE3_80000000) && actor->isTargeted) { return true; } @@ -3743,23 +3697,23 @@ 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) { + if ((player->stateFlags3 & PLAYER_STATE3_80000000) && !actor->isTargeted) { return true; } 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,7 +3722,7 @@ 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_Put(&sp58); @@ -3777,35 +3731,36 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) } 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 Actor_AddQuake(PlayState* play, s16 verticalMag, s16 countdown) { + s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3); - Quake_SetSpeed(idx, 20000); - Quake_SetQuakeValues(idx, y, 0, 0, 0); - Quake_SetCountdown(idx, countdown); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); } -void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) { - s16 idx = Quake_Add(&globalCtx->mainCamera, 3); +void Actor_AddQuakeWithSpeed(PlayState* play, s16 verticalMag, s16 countdown, s16 speed) { + s16 quakeIndex = Quake_Add(&play->mainCamera, QUAKE_TYPE_3); - Quake_SetSpeed(idx, speed); - Quake_SetQuakeValues(idx, y, 0, 0, 0); - Quake_SetCountdown(idx, countdown); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 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); + Actor_AddQuake(play, y, countdown); } typedef struct { @@ -3819,16 +3774,16 @@ typedef struct { } DoorLockInfo; // size = 0x1C DoorLockInfo sDoorLocksInfo[DOORLOCK_MAX] = { - /* DOORLOCK_NORMAL */ { 0.54f, 6000.0f, 5000.0, 1.0f, 0.0f, gDoorChainsDL, gDoorLockDL }, - /* DOORLOCK_BOSS */ { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, object_bdoor_DL_000530, object_bdoor_DL_000400 }, - /* DOORLOCK_2 */ { 0.6400000453f, 8500.0f, 8000.0f, 1.75f, 0.1f, gDoorChainsDL, gDoorLockDL }, + /* DOORLOCK_NORMAL */ { 0.54f, 6000.0f, 5000.0, 1.0f, 0.0f, gDoorChainDL, gDoorLockDL }, + /* DOORLOCK_BOSS */ { 0.644f, 12000.0f, 8000.0f, 1.0f, 0.0f, gBossDoorChainDL, gBossDoorLockDL }, + /* DOORLOCK_2 */ { 0.6400000453f, 8500.0f, 8000.0f, 1.75f, 0.1f, gDoorChainDL, gDoorLockDL }, }; /** * Draws chains and lock of a locked door, of the specified `type` (see `DoorLockType`). * `frame` can be 0 to 10, where 0 is "open" and 10 is "closed", the chains slide accordingly. */ -void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { +void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) { s32 pad[2]; MtxF baseMtxF; s32 i; @@ -3838,7 +3793,7 @@ 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_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); Matrix_Get(&baseMtxF); @@ -3854,7 +3809,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { 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) { @@ -3869,14 +3824,14 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { 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 +3843,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 +4009,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; } } @@ -4233,55 +4188,52 @@ Gfx D_801AEFA0[] = { }; Gfx* func_800BD9A0(GraphicsContext* gfxCtx) { - Gfx* displayListHead; - Gfx* displayList; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; - displayListHead = displayList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + gDPSetRenderMode( + gfx++, 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(gfx++); - gDPSetRenderMode(displayListHead++, - AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | - G_RM_FOG_SHADE_A, - AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); - gSPEndDisplayList(displayListHead++); - - return displayList; + return gfxHead; } // 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 != CS_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 +4249,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 +4274,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 +4284,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 +4303,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; } @@ -4425,8 +4377,8 @@ void func_800BE33C(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { f32 zDiff = arg1->z - arg0->z; f32 yDiff = arg3 ? (arg1->y - arg0->y) : (arg0->y - arg1->y); - arg2->y = Math_FAtan2F(zDiff, xDiff); - arg2->x = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff); + arg2->y = Math_Atan2S_XY(zDiff, xDiff); + arg2->x = Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), yDiff); } void func_800BE3D0(Actor* actor, s16 angle, Vec3s* arg2) { @@ -4482,9 +4434,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 +4453,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 +4465,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_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 +4483,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; @@ -4575,10 +4528,10 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP 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 @@ -4587,7 +4540,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetColorDither(POLY_XLU_DISP++, G_CD_BAYER); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_PATTERN); - gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamMaterialDL); alpha = effectAlpha * 100.0f; if (alpha > 100.0f) { @@ -4600,17 +4553,17 @@ 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_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamModelDL); } break; @@ -4624,7 +4577,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP type = 255; } - Matrix_Put(&globalCtx->billboardMtxF); + Matrix_Put(&play->billboardMtxF); Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f, MTXMODE_APPLY); @@ -4647,7 +4600,7 @@ 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_RotateYF(M_PI, MTXMODE_APPLY); @@ -4655,10 +4608,10 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP 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; @@ -4669,7 +4622,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP lightOrbsScale = ((KREG(19) * 0.01f) + 4.0f) * effectScale; - gSPDisplayList(POLY_XLU_DISP++, gLightOrb1DL); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbMaterial1DL); alpha = effectAlpha * 255.0f; if (alpha > 255.0f) { @@ -4687,7 +4640,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128); } - Matrix_Put(&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 @@ -4697,10 +4650,10 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP 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); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbModelDL); } break; @@ -4716,16 +4669,16 @@ 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); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkMaterialDL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, (u8)(sREG(16) + 255), (u8)(sREG(17) + 255), (u8)(sREG(18) + 150), (u8)(sREG(19) + 255)); gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23)); - Matrix_Put(&globalCtx->billboardMtxF); + Matrix_Put(&play->billboardMtxF); Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY); // Every limb draws two electric sparks at random orientations @@ -4737,10 +4690,10 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP 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); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkModelDL); // second electric spark Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI)); @@ -4749,21 +4702,21 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP 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); + gSPDisplayList(POLY_XLU_DISP++, gElectricSparkModelDL); } 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 +4727,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 +4741,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_actor_dlftbls.c b/src/code/z_actor_dlftbls.c index 77b6546ff..5d7f30ea8 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.c @@ -1,712 +1,42 @@ #include "global.h" -#include "initvars.h" -#define ACTOR_OVERLAY(name, allocType) \ - { \ - SEGMENT_ROM_START(ovl_##name), SEGMENT_ROM_END(ovl_##name), SEGMENT_START(ovl_##name), \ - SEGMENT_END(ovl_##name), NULL, &name##_InitVars, NULL, allocType, 0 \ - } +// Init Vars declarations (also used in the table below) +#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName) extern ActorInit name##_InitVars; +#define DEFINE_ACTOR_INTERNAL(name, _enumValue, _allocType, _debugName) extern ActorInit name##_InitVars; +#define DEFINE_ACTOR_UNSET(_enumValue) -#define ACTOR_OVERLAY_INTERNAL(name, allocType) \ - { 0, 0, NULL, NULL, NULL, &name##_InitVars, NULL, allocType, 0 } +#include "tables/actor_table.h" -#define ACTOR_OVERLAY_UNSET \ - { 0 } +#undef DEFINE_ACTOR +#undef DEFINE_ACTOR_INTERNAL +#undef DEFINE_ACTOR_UNSET + +// Actor Overlay Table definition +#define DEFINE_ACTOR(name, _enumValue, allocType, _debugName) \ + { SEGMENT_ROM_START(ovl_##name), \ + SEGMENT_ROM_END(ovl_##name), \ + SEGMENT_START(ovl_##name), \ + SEGMENT_END(ovl_##name), \ + NULL, \ + &name##_InitVars, \ + NULL, \ + allocType, \ + 0 }, + +#define DEFINE_ACTOR_INTERNAL(name, _enumValue, allocType, _debugName) \ + { 0, 0, NULL, NULL, NULL, &name##_InitVars, NULL, allocType, 0 }, + +#define DEFINE_ACTOR_UNSET(_enumValue) { 0 }, ActorOverlay gActorOverlayTable[] = { - ACTOR_OVERLAY_INTERNAL(Player, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_GirlA, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Part, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Light, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Door, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Box, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pametfrog, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Okuta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bom, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Wallmas, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dodongo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Firefly, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Horse, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_INTERNAL(En_Item00, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Arrow, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Elf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Niw, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tite, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Peehat, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Butte, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Insect, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fish, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Holl, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Dinofos, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hata, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zl1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Viewer, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bubble, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Door_Shutter, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Boom, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Torch2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Minifrog, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_St, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_INTERNAL(En_A_Obj, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Wturn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_River_Sound, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Ossan, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Famos, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Bombf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Am, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dekubaba, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_M_Fire1, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_M_Thunder, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(Bg_Breakwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Door_Warp1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Syokudai, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Item_B_Heart, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dekunuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bbfall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Arms_Hook, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Bb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Keikoku_Spr, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Wood02, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Death, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Minideath, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Vm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Effect, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Kankyo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Floormas, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Rd, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_F40_Flift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Mure, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sw, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Object_Kankyo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Horse_Link_Child, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Door_Ana, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Encount1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Tre_Lgt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Encount2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fire_Rock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ctower_Rot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Mir_Ray, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Sb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bigslime, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Karebaba, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_In, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Ru, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bom_Chu, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY(En_Horse_Game_Check, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rr, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Fr, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Fishing, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Oshihiki, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Dust, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Umajump, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Arrow_Fire, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Arrow_Ice, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Arrow_Light, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Item_Etcetera, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kibako, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tsubo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Ik, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Demo_Shd, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dns, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Honotrap, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tubo_Trap, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Ice_Poly, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fz, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kusa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Bean, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Bombiwa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Switch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Lift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hsblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Okarina_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Goroiwa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Daiku, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nwc, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Item_Inbox, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ge1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Blockstop, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sda, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Clear_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Gm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ms, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hs, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ingate, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kanban, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Attack_Niw, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Mk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Owl, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hana, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Lightswitch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Mure2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Fu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Stream, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Weather_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ani, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Js, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Okarina_Effect, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_F40_Swlift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Kakasi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Makeoshihiki, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Oceff_Spot, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Torch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Shot_Sun, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Roomtimer, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ssh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Oceff_Wipe, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Oceff_Storm, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Obj_Demo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Minislime, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nutsball, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Oceff_Wipe2, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Oceff_Wipe3, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Dg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Si, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Comb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kibako2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Hs2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Mure3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Wf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Skb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Gs, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Sound, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Crow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Cow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Oceff_Wipe4, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Zo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Makekinsuta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ge3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Hamishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zl4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mm2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Door_Spiral, ALLOCTYPE_PERMANENT), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Pzlblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Toge, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Armos, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Boyo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Grasshopper, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Grass, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Grass_Carry, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Grass_Unit, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Fire_Wall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Encount3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jso, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Chikuwa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Knight, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Warp_tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Aob_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Boj_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Boj_02, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Boj_03, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Encount4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bom_Bowl_Man, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Man, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Icicle, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Crow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Boj_04, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Cne_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bba_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bji_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Spdweb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Mt_tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_02, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_03, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_04, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_05, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_06, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_07, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dy_Yoseizo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Boj_05, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Sob1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Go, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Raf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Funen, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Raillift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Numa_Hana, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Flowerpot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Spinyroll, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Hina, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Wf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Skateblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Iceblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bigpamet, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Dekunuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Ravine, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Sa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Slime, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pr, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Toudai, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Entotu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Bell, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Syateki_Okuta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Shutter, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Zl, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Elfgrp, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Tsg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Baguo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Vspinyroll, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Smork, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bat, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sekihi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Wiz, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Wiz_Brock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Wiz_Fire, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Change, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Statue, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Fireshield, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ladder, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mkk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Getitem, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Dnb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dnh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dnk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dnq, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Keikoku_Saku, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hugebombiwa, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Firefly2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rat, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Water_Effect, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kusa2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Spout_Fire, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Dblue_Movebg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dy_Extra, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bal, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ginko_Man, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Warp_Uzu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Driftice, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Look_Nuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mushi2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Mm3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Crace_Movebg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dno, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pr2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Prz, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jso2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Etcetera, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Egol, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Mine, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Purify, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tru, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Trt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Test5, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test6, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Az, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Estone, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Hakugin_Post, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Opstage, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Stk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char00, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char02, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char03, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char04, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char05, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char06, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char07, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char08, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Char09, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tokeidai, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Mnk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Egblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Guard_Nuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Hakugin_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tokei_Tobira, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Hakugin_Elvpole, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ma4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Twig, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Po_Fusen, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Door_Etc, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bigokuta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Icefloe, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Ocarinalift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Time_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Open_Shutter, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Open_Spot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Fu_Kaiten, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Aqua, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Elforg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Elfbub, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Fu_Mato, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fu_Kago, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Osn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ctower_Gear, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Trt2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tokei_Step, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Lotus, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kame, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Takaraya_Wall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Fu_Mizu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sellnuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dkjail_Ivy, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Obj_Visiblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Takaraya, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tsn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ds2n, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fsn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Shn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Stop_heishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Bigicicle, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Lift_Nuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(Bg_Market_Step, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Lupygamelift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Test7, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Lightblock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Mir_Ray2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Wdhand, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gamelupy, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Danpei_Movebg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Snowwd, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gakufu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg5, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Col_Man, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Talk_Gibud, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Giant, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Snowball, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Boss_Hakugin, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gb2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Onpuman, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Tobira01, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tag_Obj, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Dhouse, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hakaisi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Hakugin_Switch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Snowman, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(TG_Sw, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Po_Sisters, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pp, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hakurock, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hanabi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Dowsing, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Wind, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Racedog, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kendo_Js, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Botihasira, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fish2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pst, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Poh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Spidertent, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zoraegg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kbt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Maruta, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Snowball2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gg2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Ghaka, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dnp, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dai, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Goron_Oyu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kgy, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Invadepoh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Gk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_An, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY_UNSET, - ACTOR_OVERLAY(En_Bee, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dragon, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Dora, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bigpo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kendo_Kanban, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hariko, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sth, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Sinkai_Kabe, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Haka_Curtain, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Kin2_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Kin2_Fence, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Kin2_Picture, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Kin2_Shelf, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rail_Skb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tru_Mt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Um, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Neo_Reeba, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Mbar_Chair, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Block, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Mirror, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Rotaryroom, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dblue_Balance, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dblue_Waterfall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kaizoku, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ge2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ma_Yts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ma_Yto, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tokei_Turret, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Dblue_Elevator, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Warpstone, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zog, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Rotlift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Jg_Gakki, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Inibs_Movebg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Tree, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Y2lift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Y2shutter, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Boat, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Taru, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hunsui, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jc_Mato, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Mir_Ray3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zob, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Elf_Msg6, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Nozoki, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Toto, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Railgibud, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Baba, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Suttari, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zod, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kujiya, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Geg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kinoko, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Yasi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron1, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Chan, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zos, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_S_Goro, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ja, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_F40_Block, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_F40_Switch, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Po_Composer, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Guruguru, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Oceff_Wipe5, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(En_Stone_heishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Oceff_Wipe6, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(En_Scopenuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Scopecrow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Oceff_Wipe7, ALLOCTYPE_ABSOLUTE), - ACTOR_OVERLAY(Eff_Kamejima_Wave, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hgo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zov, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ah, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Hgdoor, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Ray, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Shutter, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Haka_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Haka_Tomb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sc_Ruppe, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Iknv_Doukutu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Iknv_Obj, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Pamera, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_HsStump, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hidden_Nuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Zow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Talk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Al, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tab, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nimotsu, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hit_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ruppecrow, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron5, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Tanron6, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Daiku2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Muto, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Baisen, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Heishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Demo_heishi, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Dt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Cha, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Dinner, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Lastday, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikana_Dharma, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Akindonuts, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Stk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ig, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rg, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Osk, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Sth2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Yb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rz, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Scopecoin, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bjt, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bomjima, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bomjimb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bombers, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bombers2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bombal, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Moon_Stone, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Mu_Pict, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Ikninside, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Eff_Zoraband, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kepn_Koya, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Usiyane, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Nnh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Kzsaku, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Milk_Bin, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Kitan, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Astr_Bombwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Iknin_Susceil, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bsb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Recepgirl, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Thiefbird, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Jgame_Tsn, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Jgame_Light, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Yado, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Syoten, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Demo_Moonend, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Lbfshot, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Bg_Last_Bwall, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_And, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Invadepoh_Demo, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Danpeilift, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Fall2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Al, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_An, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Ah, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Nb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Drs, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Bal, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Paper, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Hint_Skb, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Tag, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Bh, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero2, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero3, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero4, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero5, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Ending_Hero6, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Dm_Gm, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Swprize, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Invisible_Ruppe, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(Obj_Ending, ALLOCTYPE_NORMAL), - ACTOR_OVERLAY(En_Rsn, ALLOCTYPE_NORMAL), +#include "tables/actor_table.h" }; -s32 gMaxActorId = 0; +#undef DEFINE_ACTOR +#undef DEFINE_ACTOR_INTERNAL +#undef DEFINE_ACTOR_UNSET + +ActorId gMaxActorId = 0; FaultClient D_801ED930; FaultAddrConvClient D_801ED940; @@ -714,7 +44,7 @@ FaultAddrConvClient D_801ED940; void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) { ActorOverlay* overlayEntry; u32 overlaySize; - s32 i; + ActorId i; FaultDrawer_SetCharPad(-2, 0); @@ -733,7 +63,7 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) { void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1) { u8* ptr = arg0; ActorOverlay* overlayEntry = &gActorOverlayTable[0]; - s32 i; + ActorId i; u8* ramStart; u8* ramEnd; size_t size; 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 0667bd84b..eda6437af 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,5 +1,7 @@ +#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 @@ -45,7 +47,7 @@ u8 D_801B46C0[] = { /* 0x0E */ 1 }; -s16 sSmallMemScenes[] = { +s16 sSmallMemSceneIds[] = { SCENE_F01, }; @@ -70,17 +72,25 @@ BgSpecialSceneMaxObjects sCustomDynapolyMem[] = { // TODO: All these bss variables are localized to one function and can // likely be made into in-function static bss variables in the future -char D_801ED950[80]; -char D_801ED9A0[80]; + Vec3f D_801ED9F0[3]; // polyVerts Vec3f D_801EDA18[3]; // polyVerts -MtxF D_801EDA40; Vec3f D_801EDA80[3]; // polyVerts +Vec3f D_801EDB48[3]; // polyVerts + +#ifndef NON_MATCHING +Vec3f D_801EDB70[3]; // polyVerts; +Plane D_801EDB98; // plane; +Sphere16 D_801EDBA8; // sphere; +TriNorm D_801EDBB0; // tri; +#endif + +char D_801ED950[80]; +char D_801ED9A0[80]; + char D_801EDAA8[80]; char D_801EDAF8[80]; -Vec3f D_801EDB48[3]; // polyVerts -Vec3f D_801EDB70[3]; -Plane D_801EDB98; +MtxF D_801EDA40; void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast); @@ -124,13 +134,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; } @@ -279,7 +289,7 @@ void CollisionPoly_GetVertices(CollisionPoly* poly, Vec3s* vtxList, Vec3f* dest) void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest) { Vec3s* vtxList; - if (poly == NULL || bgId > BG_ACTOR_MAX || dest == NULL) { + if ((poly == NULL) || (bgId > BG_ACTOR_MAX) || (dest == NULL)) { if (dest != NULL) { // @bug: dest[2] x and y are not set to 0 dest[0].x = dest[0].y = dest[0].z = dest[1].x = dest[1].y = dest[1].z = dest[2].z = 0.0f; @@ -378,40 +388,52 @@ s32 CollisionPoly_CheckZIntersectApprox(CollisionPoly* poly, Vec3s* vtxList, f32 } #ifdef NON_MATCHING +// Matches, but needs in-function static bss s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0) { - static Vec3f polyVerts[3]; // D_801EDB70 - static Plane plane; // D_801EDB98 + static Vec3f sPolyVerts[3]; // D_801EDB70 + static Plane sPlane; // D_801EDB98 f32 planeDistA; f32 planeDistB; - f32 planeDistDelta; + f32 dpA; + f32 dpB; + f32 originDist; - plane.originDist = a0->poly->dist; - planeDistA = COLPOLY_GET_NORMAL(a0->poly->normal.x * a0->posA->x + a0->poly->normal.y * a0->posA->y + - a0->poly->normal.z * a0->posA->z) + - plane.originDist; - planeDistB = COLPOLY_GET_NORMAL(a0->poly->normal.x * a0->posB->x + a0->poly->normal.y * a0->posB->y + - a0->poly->normal.z * a0->posB->z) + - plane.originDist; + sPlane.originDist = a0->poly->dist; + originDist = sPlane.originDist; + planeDistA = originDist; + planeDistB = originDist; - planeDistDelta = planeDistA - planeDistB; - if ((planeDistA >= 0.0f && planeDistB >= 0.0f) || (planeDistA < 0.0f && planeDistB < 0.0f) || - ((a0->checkOneFace != 0) && (planeDistA < 0.0f && planeDistB > 0.0f)) || IS_ZERO(planeDistDelta)) { + dpA = a0->poly->normal.x * a0->posA->x; + dpB = a0->poly->normal.x * a0->posB->x; + dpA += a0->poly->normal.y * a0->posA->y; + dpB += a0->poly->normal.y * a0->posB->y; + dpA += a0->poly->normal.z * a0->posA->z; + dpB += a0->poly->normal.z * a0->posB->z; + + dpA *= COLPOLY_NORMAL_FRAC; + dpB *= COLPOLY_NORMAL_FRAC; + + planeDistA += dpA; + planeDistB += dpB; + + if (((planeDistA >= 0.0f) && (planeDistB >= 0.0f)) || ((planeDistA < 0.0f) && (planeDistB < 0.0f)) || + ((a0->checkOneFace != 0) && (planeDistA < 0.0f) && (0.0f < planeDistB)) || IS_ZERO(planeDistA - planeDistB)) { return false; } - CollisionPoly_GetNormalF(a0->poly, &plane.normal.x, &plane.normal.y, &plane.normal.z); - CollisionPoly_GetVertices(a0->poly, a0->vtxList, polyVerts); - Math3D_Lerp(a0->posA, a0->posB, planeDistA / planeDistDelta, a0->planeIntersect); + CollisionPoly_GetNormalF(a0->poly, &sPlane.normal.x, &sPlane.normal.y, &sPlane.normal.z); + CollisionPoly_GetVertices(a0->poly, a0->vtxList, sPolyVerts); + Math3D_Lerp(a0->posA, a0->posB, planeDistA / (planeDistA - planeDistB), a0->planeIntersect); - if ((fabsf(plane.normal.x) > 0.5f && - Math3D_TriChkPointParaXDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->y, - a0->planeIntersect->z, 0.0f, a0->checkDist, plane.normal.x)) || - (fabsf(plane.normal.y) > 0.5f && - Math3D_TriChkPointParaYDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->z, - a0->planeIntersect->x, 0.0f, a0->checkDist, plane.normal.y)) || - (fabsf(plane.normal.z) > 0.5f && - Math3D_TriChkLineSegParaZDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->x, - a0->planeIntersect->y, 0.0f, a0->checkDist, plane.normal.z))) { + if (((fabsf(sPlane.normal.x) > 0.5f) && + Math3D_TriChkPointParaXDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->y, + a0->planeIntersect->z, 0.0f, a0->checkDist, sPlane.normal.x)) || + ((fabsf(sPlane.normal.y) > 0.5f) && + Math3D_TriChkPointParaYDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->z, + a0->planeIntersect->x, 0.0f, a0->checkDist, sPlane.normal.y)) || + ((fabsf(sPlane.normal.z) > 0.5f) && + Math3D_TriChkLineSegParaZDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->x, + a0->planeIntersect->y, 0.0f, a0->checkDist, sPlane.normal.z))) { return true; } return false; @@ -421,20 +443,26 @@ s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0); #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_LineVsPoly.s") #endif +#ifdef NON_MATCHING +// Matches, but needs in-function static bss s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius) { - static Sphere16 sphere; // D_801EDBA8 - static TriNorm tri; // D_801EDBB0 + static Sphere16 sSphere; // D_801EDBA8 + static TriNorm sTri; // D_801EDBB0 Vec3f intersect; - CollisionPoly_GetVertices(poly, vtxList, tri.vtx); - CollisionPoly_GetNormalF(poly, &tri.plane.normal.x, &tri.plane.normal.y, &tri.plane.normal.z); - tri.plane.originDist = poly->dist; - sphere.center.x = center->x; - sphere.center.y = center->y; - sphere.center.z = center->z; - sphere.radius = radius; - return Math3D_ColSphereTri(&sphere, &tri, &intersect); + CollisionPoly_GetVertices(poly, vtxList, sTri.vtx); + CollisionPoly_GetNormalF(poly, &sTri.plane.normal.x, &sTri.plane.normal.y, &sTri.plane.normal.z); + sTri.plane.originDist = poly->dist; + sSphere.center.x = center->x; + sSphere.center.y = center->y; + sSphere.center.z = center->z; + sSphere.radius = radius; + return Math3D_ColSphereTri(&sSphere, &sTri, &intersect); } +#else +s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_SphVsPoly.s") +#endif /** * Add poly to StaticLookup table @@ -464,9 +492,9 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll curPolyId = curNode->polyId; // if the poly being inserted has a lower y than the first poly - if (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y && - polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y && - polyYMin < vtxList[polyList[curPolyId].vIC].y) { + if ((polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y) && + (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y) && + (polyYMin < vtxList[polyList[curPolyId].vIC].y)) { SSNodeList_SetSSListHead(&colCtx->polyNodes, ssList, &polyId); return; } @@ -485,9 +513,9 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll curPolyId = nextNode->polyId; // if the poly being inserted is lower than the next poly - if (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y && - polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y && - polyYMin < vtxList[polyList[curPolyId].vIC].y) { + if ((polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y) && + (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y) && + (polyYMin < vtxList[polyList[curPolyId].vIC].y)) { newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes); SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, curNode->next); curNode->next = newNodeId; @@ -540,8 +568,9 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList if (((flags & 1) && (colPoly->normal.y < 0)) || ((arg9 & 0x20) && ((colCtx->colHeader->surfaceTypeList[colPoly->type].data[0] >> 0x1E) & 1)) || COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } @@ -549,16 +578,16 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList continue; } - if (pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIA)].y && - pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIB)].y && - pos->y < colCtx->colHeader->vtxList[colPoly->vIC].y) { + if ((pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIA)].y) && + (pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIB)].y) && + (pos->y < colCtx->colHeader->vtxList[colPoly->vIC].y)) { break; } if (CollisionPoly_CheckYIntersect(colPoly, colCtx->colHeader->vtxList, pos->x, pos->z, &yIntersect, checkDist)) { // if poly is closer to pos without going over - if (yIntersect < pos->y && result < yIntersect) { + if ((yIntersect < pos->y) && (result < yIntersect)) { result = yIntersect; *outPoly = colPoly; } @@ -680,7 +709,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 vtxB = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)]; vtxC = &vtxList[curPoly->vIC]; - if (pos->y < vtxA->y && pos->y < vtxB->y && pos->y < vtxC->y) { + if ((pos->y < vtxA->y) && (pos->y < vtxB->y) && (pos->y < vtxC->y)) { break; } @@ -690,8 +719,9 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -731,7 +761,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 zMin -= radius; zMax += radius; - if (resultPos.z < zMin || resultPos.z > zMax) { + if ((resultPos.z < zMin) || (resultPos.z > zMax)) { if (curNode->next == SS_NULL) { break; } else { @@ -767,7 +797,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 vtxB = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)]; vtxC = &vtxList[curPoly->vIC]; - if (pos->y < vtxA->y && pos->y < vtxB->y && pos->y < vtxC->y) { + if ((pos->y < vtxA->y) && (pos->y < vtxB->y) && (pos->y < vtxC->y)) { break; } @@ -777,8 +807,9 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -818,7 +849,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 xMin -= radius; xMax += radius; - if (resultPos.x < xMin || xMax < resultPos.x) { + if ((resultPos.x < xMin) || (xMax < resultPos.x)) { if (curNode->next == SS_NULL) { break; } else { @@ -884,8 +915,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte curPoly = &polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && - ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -898,7 +929,7 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte intersectDist = ceilingY - *outY; ny = COLPOLY_GET_NORMAL(curPoly->normal.y); - if (intersectDist > 0 && intersectDist < checkHeight && intersectDist * ny <= 0) { + if ((intersectDist > 0) && (intersectDist < checkHeight) && (intersectDist * ny <= 0)) { *outY = ceilingY - checkHeight; *outPoly = curPoly; result = true; @@ -921,9 +952,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte * `posB` and `outPos` returns the point of intersection with `outPoly` * `outDistSq` returns the squared distance from `posA` to the point of intersect */ -#ifdef NON_MATCHING s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { - CollisionContext* colCtx; + CollisionPoly* polyList; s32 result; Vec3f polyIntersect; // sp7C SSNode* curNode; @@ -932,16 +962,14 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { f32 distSq; BgLineVsPolyTest test; // sp50 s16 polyId; - CollisionPoly* polyList; result = false; if (arg0->ssList->head == SS_NULL) { return result; } - colCtx = arg0->colCtx; - curNode = &colCtx->polyNodes.tbl[arg0->ssList->head]; - polyList = colCtx->colHeader->polyList; - test.vtxList = colCtx->colHeader->vtxList; + curNode = &arg0->colCtx->polyNodes.tbl[arg0->ssList->head]; + polyList = arg0->colCtx->colHeader->polyList; + test.vtxList = arg0->colCtx->colHeader->vtxList; test.posA = arg0->posA; test.posB = arg0->posB; test.planeIntersect = &polyIntersect; // reorder maybe @@ -953,22 +981,22 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { test.poly = &polyList[polyId]; checkedPoly = &arg0->colCtx->polyNodes.polyCheckTbl[polyId]; - if (*checkedPoly == true || - (arg0->xpFlags2 != 0 && !COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags2)) || + if ((*checkedPoly == true) || + ((arg0->xpFlags2 != 0) && !COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags2)) || COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags1) || (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && - ((arg0->actor != NULL && arg0->actor->category != ACTORCAT_PLAYER) || - (arg0->actor == NULL && arg0->xpFlags1 != COLPOLY_IGNORE_CAMERA)))) { + (((arg0->actor != NULL) && (arg0->actor->category != ACTORCAT_PLAYER)) || + ((arg0->actor == NULL) && (arg0->xpFlags1 != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { - curNode = &colCtx->polyNodes.tbl[curNode->next]; + curNode = &arg0->colCtx->polyNodes.tbl[curNode->next]; continue; } } *checkedPoly = true; minY = CollisionPoly_GetMinY(test.poly, test.vtxList); - if (test.posA->y < minY && test.posB->y < minY) { + if (((test.posA->y < minY)) && (test.posB->y < minY)) { break; } if (CollisionPoly_LineVsPoly(&test)) { @@ -988,10 +1016,6 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { } return result; } -#else -s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckLineAgainstSSList.s") -#endif /** * Tests if line `posA` to `posB` intersects with a static poly in `lookup`. Uses polyCheckTbl @@ -1003,21 +1027,21 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0); s32 BgCheck_CheckLineInSubdivision(StaticLineTest* arg0) { s32 result = false; - if ((arg0->bccFlags & BGCHECK_CHECK_FLOOR) && arg0->lookup->floor.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_FLOOR) && (arg0->lookup->floor.head != SS_NULL)) { arg0->ssList = &arg0->lookup->floor; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; } } - if ((arg0->bccFlags & BGCHECK_CHECK_WALL) && arg0->lookup->wall.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_WALL) && (arg0->lookup->wall.head != SS_NULL)) { arg0->ssList = &arg0->lookup->wall; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; } } - if ((arg0->bccFlags & BGCHECK_CHECK_CEILING) && arg0->lookup->ceiling.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_CEILING) && (arg0->lookup->ceiling.head != SS_NULL)) { arg0->ssList = &arg0->lookup->ceiling; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; @@ -1047,8 +1071,8 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext curPoly = &polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && - ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (node->next != SS_NULL) { node = &colCtx->polyNodes.tbl[node->next]; continue; @@ -1056,9 +1080,9 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext break; } - if (center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)].y && - center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)].y && - center->y + radius < vtxList[curPoly->vIC].y) { + if ((center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)].y) && + (center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)].y) && + (center->y + radius < vtxList[curPoly->vIC].y)) { break; } @@ -1084,19 +1108,19 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext */ s32 BgCheck_SphVsFirstStaticPoly(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius, CollisionPoly** outPoly, u16 bciFlags, Actor* actor) { - if (lookup->floor.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_FLOOR) && + if ((lookup->floor.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_FLOOR) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->floor.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; } - if (lookup->wall.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_WALL) && + if ((lookup->wall.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_WALL) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->wall.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; } - if (lookup->ceiling.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_CEILING) && + if ((lookup->ceiling.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_CEILING) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->ceiling.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; @@ -1191,7 +1215,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) { @@ -1376,7 +1400,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; @@ -1460,11 +1484,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) { - s16* i; +s32 BgCheck_IsSmallMemScene(PlayState* play) { + s16* sceneId; - for (i = sSmallMemScenes; i < sSmallMemScenes + ARRAY_COUNT(sSmallMemScenes); i++) { - if (globalCtx->sceneNum == *i) { + for (sceneId = sSmallMemSceneIds; sceneId < sSmallMemSceneIds + ARRAY_COUNT(sSmallMemSceneIds); sceneId++) { + if (play->sceneId == *sceneId) { return true; } } @@ -1499,11 +1523,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->sceneId == sCustomDynapolyMem[i].sceneId) { *maxNodes = sCustomDynapolyMem[i].maxNodes; *maxPolygons = sCustomDynapolyMem[i].maxPolygons; *maxVertices = sCustomDynapolyMem[i].maxVertices; @@ -1516,7 +1540,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; @@ -1527,7 +1551,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; @@ -1540,7 +1564,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis s32 useCustomSubdivisions; s32 i; - if (BgCheck_TryGetCustomMemsize(globalCtx->sceneNum, &customMemSize)) { + if (BgCheck_TryGetCustomMemsize(play->sceneId, &customMemSize)) { colCtx->memSize = customMemSize; } else { colCtx->memSize = 0x23000; @@ -1548,12 +1572,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->sceneId == sSceneSubdivisionList[i].sceneId) { colCtx->subdivAmount.x = sSceneSubdivisionList[i].subdivAmount.x; colCtx->subdivAmount.y = sSceneSubdivisionList[i].subdivAmount.y; colCtx->subdivAmount.z = sSceneSubdivisionList[i].subdivAmount.z; @@ -1568,7 +1592,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); @@ -1601,12 +1625,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); } /** @@ -1632,7 +1656,7 @@ CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId) if (bgId == BGCHECK_SCENE) { return colCtx->colHeader; } - if (bgId < 0 || bgId > BG_ACTOR_MAX) { + if ((bgId < 0) || (bgId > BG_ACTOR_MAX)) { return NULL; } if (!(colCtx->dyna.bgActorFlags[bgId] & 1)) { @@ -1645,12 +1669,12 @@ CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId) * Test if pos is near collision boundaries */ s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) { - if (pos->x < (colCtx->minBounds.x - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.x + BGCHECK_SUBDIV_OVERLAP) < pos->x || - pos->y < (colCtx->minBounds.y - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.y + BGCHECK_SUBDIV_OVERLAP) < pos->y || - pos->z < (colCtx->minBounds.z - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.z + BGCHECK_SUBDIV_OVERLAP) < pos->z) { + if ((pos->x < (colCtx->minBounds.x - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.x + BGCHECK_SUBDIV_OVERLAP) < pos->x) || + (pos->y < (colCtx->minBounds.y - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.y + BGCHECK_SUBDIV_OVERLAP) < pos->y) || + (pos->z < (colCtx->minBounds.z - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.z + BGCHECK_SUBDIV_OVERLAP) < pos->z)) { return false; } return true; @@ -1661,7 +1685,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; @@ -1693,7 +1717,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; @@ -1711,7 +1735,7 @@ f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, } } - if (yIntersect != BGCHECK_Y_MIN && func_800C9B68(colCtx, *outPoly, *outBgId)) { + if ((yIntersect != BGCHECK_Y_MIN) && func_800C9B68(colCtx, *outPoly, *outBgId)) { yIntersect -= 1.0f; } return yIntersect; @@ -1741,22 +1765,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); } /** @@ -1780,18 +1802,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); } /** @@ -1916,7 +1938,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul dz = posNext->z - posPrev->z; // if there's movement on the xz plane, and argA flag is 0, - if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) { + if (((dx != 0.0f) || (dz != 0.0f)) && !(argA & 1)) { if ((checkHeight + dy) < 5.0f) { //! @bug checkHeight is not applied to posPrev/posNext result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly, @@ -1977,7 +1999,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul *outPoly = poly; *outBgId = bgId; result = true; - if (COLPOLY_GET_NORMAL(poly->normal.y) > 0.5f) { + if (poly->normal.y * COLPOLY_NORMAL_FRAC > 0.5f) { if (actor != NULL) { actor->bgCheckFlags |= 0x1000; } @@ -2010,7 +2032,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul result = true; } // if a collision with a dyna poly was detected - if (dynaPolyCollision || *outBgId != BGCHECK_SCENE) { + if (dynaPolyCollision || (*outBgId != BGCHECK_SCENE)) { if (BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly, &bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) { nx3 = COLPOLY_GET_NORMAL(poly->normal.x); @@ -2202,7 +2224,7 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, checkLine.actor = actor; result = false; - if (subdivMin[0] != subdivMax[0] || subdivMin[1] != subdivMax[1] || subdivMin[2] != subdivMax[2]) { + if ((subdivMin[0] != subdivMax[0]) || (subdivMin[1] != subdivMax[1]) || (subdivMin[2] != subdivMax[2])) { for (i = 0; i < 3; i++) { if (subdivMax[i] < subdivMin[i]) { j = subdivMax[i]; @@ -2453,11 +2475,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"); @@ -2512,9 +2534,9 @@ void ScaleRotPos_SetValue(ScaleRotPos* srp, Vec3f* scale, Vec3s* rot, Vec3f* pos * ScaleRotPos equality test */ s32 ScaleRotPos_IsEqual(ScaleRotPos* a, ScaleRotPos* b) { - if (a->scale.x != b->scale.x || a->scale.y != b->scale.y || a->scale.z != b->scale.z || a->rot.x != b->rot.x || - a->rot.y != b->rot.y || a->rot.z != b->rot.z || a->pos.x != b->pos.x || a->pos.y != b->pos.y || - a->pos.z != b->pos.z) { + if ((a->scale.x != b->scale.x) || (a->scale.y != b->scale.y) || (a->scale.z != b->scale.z) || + (a->rot.x != b->rot.x) || (a->rot.y != b->rot.y) || (a->rot.z != b->rot.z) || (a->pos.x != b->pos.x) || + (a->pos.y != b->pos.y) || (a->pos.z != b->pos.z)) { return false; } return true; @@ -2554,7 +2576,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); @@ -2598,8 +2620,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); } /** @@ -2612,8 +2634,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); } /** @@ -2627,14 +2649,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; } @@ -2642,7 +2664,7 @@ void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor * Is BgActor Id */ s32 DynaPoly_IsBgIdBgActor(s32 bgId) { - if (bgId < 0 || bgId >= BG_ACTOR_MAX) { + if ((bgId < 0) || (bgId >= BG_ACTOR_MAX)) { return false; } return true; @@ -2651,43 +2673,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; @@ -2715,48 +2736,48 @@ s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Ac */ DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) { if (!DynaPoly_IsBgIdBgActor(bgId) || !(colCtx->dyna.bgActorFlags[bgId] & 1) || - colCtx->dyna.bgActorFlags[bgId] & 2) { + (colCtx->dyna.bgActorFlags[bgId] & 2)) { return NULL; } 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; @@ -2766,13 +2787,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; @@ -2781,7 +2802,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; } @@ -2839,8 +2860,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; @@ -2882,20 +2903,20 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3 if (dyna->bgActorFlags[bgId] & 4) { return; } - - if (!(DYNA_WATERBOX_MAX >= *waterBoxStartIndex + pbgdata->numWaterBoxes)) { + // if(&pos){} // fake but considerably improves match. commented out to stop warnings + if (*waterBoxStartIndex + pbgdata->numWaterBoxes > DYNA_WATERBOX_MAX) { sprintf(D_801EDAA8, "water_poly Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *waterBoxStartIndex + pbgdata->numWaterBoxes, DYNA_WATERBOX_MAX); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); } - if (!(dyna->polyListMax >= *polyStartIndex + pbgdata->numPolygons)) { + if (*polyStartIndex + pbgdata->numPolygons > dyna->polyListMax) { sprintf(D_801EDAA8, "bg_poly Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *polyStartIndex + pbgdata->numPolygons, dyna->polyListMax); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); } - if (!(dyna->vtxListMax >= *vtxStartIndex + pbgdata->numVertices)) { + if (*vtxStartIndex + pbgdata->numVertices > dyna->vtxListMax) { sprintf(D_801EDAA8, "bg_vert Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *vtxStartIndex + pbgdata->numVertices, dyna->vtxListMax); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); @@ -2939,7 +2960,8 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3 dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y, dyna->bgActors[bgId].curTransform.pos.z); - if (pbgdata->numVertices != 0 && pbgdata->numPolygons != 0) { + if ((pbgdata->numVertices != 0) && (pbgdata->numPolygons != 0)) { + s32 j; numVtxInverse = 1.0f / pbgdata->numVertices; newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f; for (i = 0; i < pbgdata->numVertices; i++) { @@ -2970,13 +2992,12 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3 sphere->center.z = newCenterPoint.z; newRadiusSq = -100.0f; - for (i = 0; i < pbgdata->numVertices; i++) { + for (i = 0, j = *vtxStartIndex; i < pbgdata->numVertices; i++, j++) { f32 radiusSq; - s32 idx = *vtxStartIndex + i; - newVtx.x = dyna->vtxList[idx].x; - newVtx.y = dyna->vtxList[idx].y; - newVtx.z = dyna->vtxList[idx].z; + newVtx.x = dyna->vtxList[j].x; + newVtx.y = dyna->vtxList[j].y; + newVtx.z = dyna->vtxList[j].z; radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint); if (newRadiusSq < radiusSq) { newRadiusSq = radiusSq; @@ -3023,7 +3044,7 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3 newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); } - newPoly->dist = -DOTXYZ(newNormal, dVtxList[vIA]); + newPoly->dist = func_80086D24(-DOTXYZ(newNormal, vtxA)); if (newNormal.y > 0.5f) { s16 polyId = *polyStartIndex + i; @@ -3040,21 +3061,22 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3 } } - for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { - Math_Vec3s_ToVec3f(&spB8, &pbgdata->waterBoxes[wi].minPos); - Math_Vec3f_Copy(&spA0, &spB8); - spA0.x += pbgdata->waterBoxes[wi].xLength; - Math_Vec3f_Copy(&sp88, &spB8); - sp88.z += pbgdata->waterBoxes[wi].zLength; - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spB8, &spAC); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spA0, &sp94); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &sp88, &sp7C); - waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; - BgCheck_CalcWaterboxDimensions(&spAC, &sp94, &sp7C, &waterBox->minPos, &waterBox->xLength, - &waterBox->zLength); - waterBox->properties = pbgdata->waterBoxes[wi].properties; + if (pbgdata->numWaterBoxes > 0) { + for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { + Math_Vec3s_ToVec3f(&spB8, &pbgdata->waterBoxes[wi].minPos); + Math_Vec3f_Copy(&spA0, &spB8); + spA0.x += pbgdata->waterBoxes[wi].xLength; + Math_Vec3f_Copy(&sp88, &spB8); + sp88.z += pbgdata->waterBoxes[wi].zLength; + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spB8, &spAC); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spA0, &sp94); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &sp88, &sp7C); + waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; + BgCheck_CalcWaterboxDimensions(&spAC, &sp94, &sp7C, &waterBox->minPos, &waterBox->xLength, + &waterBox->zLength); + waterBox->properties = pbgdata->waterBoxes[wi].properties; + } } - *polyStartIndex += pbgdata->numPolygons; *vtxStartIndex += pbgdata->numVertices; *waterBoxStartIndex += pbgdata->numWaterBoxes; @@ -3064,14 +3086,14 @@ 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); - if (dynaActor != NULL && &dynaActor->actor == actor) { + dynaActor = DynaPoly_GetActor(&play->colCtx, i); + if ((dynaActor != NULL) && (&dynaActor->actor == actor)) { DynaPolyActor_ResetState((DynaPolyActor*)actor); return; } @@ -3082,7 +3104,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; @@ -3099,19 +3121,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) { + 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; } } @@ -3120,7 +3142,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; @@ -3150,12 +3172,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]); } } } @@ -3182,8 +3204,8 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { id = curNode->polyId; if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycast->xpFlags) || (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIB, 4) && - ((dynaRaycast->actor != NULL && dynaRaycast->actor->category != ACTORCAT_PLAYER) || - (dynaRaycast->actor == NULL && dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA))) || + (((dynaRaycast->actor != NULL) && (dynaRaycast->actor->category != ACTORCAT_PLAYER)) || + ((dynaRaycast->actor == NULL) && (dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA)))) || ((dynaRaycast->unk_24 & 0x20) && func_800C9B68(dynaRaycast->colCtx, &polyList[id], dynaRaycast->unk1C))) { if (curNode->next == SS_NULL) { break; @@ -3193,7 +3215,7 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { } } if ((listType & (DYNA_RAYCAST_WALLS | DYNA_RAYCAST_CEILINGS)) && (dynaRaycast->unk_24 & 0x10) && - COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f) { + (COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f)) { if (curNode->next == SS_NULL) { break; } else { @@ -3203,7 +3225,7 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { } if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycast->dyna->vtxList, dynaRaycast->pos->x, dynaRaycast->pos->z, &yIntersect, dynaRaycast->checkDist) && - yIntersect < dynaRaycast->pos->y && result < yIntersect) { + (yIntersect < dynaRaycast->pos->y) && (result < yIntersect)) { result = yIntersect; *dynaRaycast->resultPoly = &dynaRaycast->dyna->polyList[id]; } @@ -3251,8 +3273,8 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { continue; } - if (dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor || - dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY || + if ((dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor) || + (dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY) || !Math3D_XZInSphere(&dynaRaycast->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycast->pos->x, dynaRaycast->pos->z)) { continue; @@ -3271,7 +3293,7 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { } } if ((dynaRaycast->unk_24 & BGCHECK_IGNORE_WALL) || - (*dynaRaycast->resultPoly == NULL && (dynaRaycast->unk_24 & 8))) { + ((*dynaRaycast->resultPoly == NULL) && (dynaRaycast->unk_24 & 8))) { dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.wall; intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_WALLS); if (dynaRaycast->yIntersect < intersect2) { @@ -3295,10 +3317,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 != PAUSE_STATE_OFF); 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; @@ -3389,8 +3411,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - ((COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4)) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3429,7 +3451,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo zMin -= radius; zMax += radius; - if (resultPos.z < zMin || zMax < resultPos.z) { + if ((resultPos.z < zMin) || (zMax < resultPos.z)) { if (curNode->next == SS_NULL) { break; } else { @@ -3465,8 +3487,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3505,7 +3527,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo xMin -= radius; xMax += radius; - if (resultPos.x < xMin || xMax < resultPos.x) { + if ((resultPos.x < xMin) || (xMax < resultPos.x)) { if (curNode->next == SS_NULL) { break; } else { @@ -3567,7 +3589,7 @@ s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* } bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->minY > resultPos.y || bgActor->maxY < resultPos.y) { + if ((bgActor->minY > resultPos.y) || (bgActor->maxY < resultPos.y)) { continue; } @@ -3576,7 +3598,7 @@ s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* r = bgActor->boundingSphere.radius; dx = bgActor->boundingSphere.center.x - resultPos.x; dz = bgActor->boundingSphere.center.z - resultPos.z; - if (SQ(r) < (SQ(dx) + SQ(dz)) || (!Math3D_XYInSphere(&bgActor->boundingSphere, resultPos.x, resultPos.y) && + if ((SQ(r) < SQ(dx) + SQ(dz)) || (!Math3D_XYInSphere(&bgActor->boundingSphere, resultPos.x, resultPos.y) && !Math3D_YZInSphere(&bgActor->boundingSphere, resultPos.y, resultPos.z))) { bgActor->boundingSphere.radius -= (s16)radius; continue; @@ -3625,8 +3647,8 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl polyId = curNode->polyId; poly = &dyna->polyList[polyId]; if (COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3645,7 +3667,7 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl } if (CollisionPoly_CheckYIntersectApprox2(poly, dyna->vtxList, testPos.x, testPos.z, &ceilingY)) { intersectDist = ceilingY - testPos.y; - if (testPos.y < ceilingY && intersectDist < checkHeight && intersectDist * ny <= 0.0f) { + if ((testPos.y < ceilingY) && (intersectDist < checkHeight) && (intersectDist * ny <= 0.0f)) { sign = (0.0f <= ny) ? 1.0f : -1.0f; testPos.y = (sign * checkHeight) + ceilingY; result = true; @@ -3734,8 +3756,8 @@ s32 BgCheck_CheckLineAgainstBgActorSSList(DynaLineTest* dynaLineTest) { test.poly = &dynaLineTest->dyna->polyList[polyId]; if (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, dynaLineTest->xpFlags) || (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && - ((dynaLineTest->actor != NULL && dynaLineTest->actor->category != ACTORCAT_PLAYER) || - (dynaLineTest->actor == NULL && dynaLineTest->xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((dynaLineTest->actor != NULL) && (dynaLineTest->actor->category != ACTORCAT_PLAYER)) || + ((dynaLineTest->actor == NULL) && (dynaLineTest->xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3831,17 +3853,19 @@ s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* p if (actor != colCtx->dyna.bgActors[i].actor) { ay = posA->y; by = posB->y; - if (!(ay < colCtx->dyna.bgActors[i].minY) || !(by < colCtx->dyna.bgActors[i].minY)) { - if (!(colCtx->dyna.bgActors[i].maxY < ay) || !(colCtx->dyna.bgActors[i].maxY < by)) { - line.a = *posA; - line.b = *posB; - if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) { - if (BgCheck_CheckLineAgainstBgActor(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq, - i, checkDist, bccFlags, actor)) { - *outBgId = i; - result = true; - } - } + if ((ay < colCtx->dyna.bgActors[i].minY) && (by < colCtx->dyna.bgActors[i].minY)) { + continue; + } + if ((ay > colCtx->dyna.bgActors[i].maxY) && (by > colCtx->dyna.bgActors[i].maxY)) { + continue; + } + line.a = *posA; + line.b = *posB; + if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) { + if (BgCheck_CheckLineAgainstBgActor(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq, i, + checkDist, bccFlags, actor)) { + *outBgId = i; + result = true; } } } @@ -3871,10 +3895,9 @@ s32 BgCheck_SphVsFirstDynaPolyList(CollisionContext* colCtx, u16 xpFlags, Collis curPolyId = curNode->polyId; curPoly = &dyna->polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) - - { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3964,8 +3987,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); @@ -3983,7 +4006,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; @@ -3991,7 +4014,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); } } @@ -4017,7 +4040,7 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, SurfaceType* surfaceTypes; colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); - if (colHeader == NULL || poly == NULL) { + if ((colHeader == NULL) || (poly == NULL)) { return 0; } surfaceTypes = colHeader->surfaceTypeList; @@ -4028,128 +4051,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); } /** @@ -4243,7 +4280,7 @@ u32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { s32 id = func_800C9BB8(colCtx, poly, bgId); - if (id < 0 || id > 14) { + if ((id < 0) || (id > 14)) { return NA_SE_PL_WALK_GROUND - SFX_FLAG; } return sSurfaceTypeSfx[id]; @@ -4255,7 +4292,7 @@ u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) s32 func_800C9C24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 arg3) { s32 id = func_800C9BB8(colCtx, poly, bgId); - if (id < 0 || id > 14) { + if ((id < 0) || (id > 14)) { return 0; } return D_801B46C0[id] & arg3; @@ -4318,18 +4355,22 @@ s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* } /** - * SurfaceType Get Conveyor Surface Type - * Return type 0 (CONVEYOR_WATER) if 'poly' is a surface that will only move player underwater - * Return type 1 (CONVEYOR_FLOOR) if `poly` is a surface that must be stood on to move player + * Checks if poly is a floor conveyor + * + * A conveyor surface is enabled with non-zero speed. + * When enabled, the conveyor will exhibit two types of behaviour depending on the return value: + * + * If true, then it is a floor conveyor and will push player only while being stood on + * If false, then it is a water conveyor and will push player only while in water */ -s32 SurfaceType_GetConveyorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u32 flags; if (BgCheck_GetCollisionHeader(colCtx, bgId) == NULL) { - return CONVEYOR_FLOOR; + return true; } if (poly == NULL) { - return CONVEYOR_WATER; + return false; } flags = poly->flags_vIB & 0x2000; return !!flags; @@ -4378,26 +4419,27 @@ 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; - WaterBox* curWaterBox; + s32 room; s32 i; + WaterBox* curWaterBox; + BgActor* bgActor; *bgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; - if (colHeader->numWaterBoxes != 0 && colHeader->waterBoxes != NULL) { + if ((colHeader->numWaterBoxes != 0) && (colHeader->waterBoxes != NULL)) { 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 == play->roomCtx.curRoom.num) || (room == 0x3F)) { if (curWaterBox->properties & 0x80000) { continue; } - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { *outWaterBox = curWaterBox; *ySurface = curWaterBox->minPos.y; return true; @@ -4408,27 +4450,24 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, } for (i = 0; i < BG_ACTOR_MAX; i++) { - if (colCtx->dyna.bgActorFlags[i] & 1) { - BgActor* bgActor; - if (colCtx->dyna.bgActorFlags[i] & 4) { - continue; - } - bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->colHeader->numWaterBoxes != 0 && bgActor->colHeader->waterBoxes != NULL) { - for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; - curWaterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + - bgActor->colHeader->numWaterBoxes; - curWaterBox++) { - if (curWaterBox->properties & 0x80000) { - continue; - } - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - *bgId = i; - return true; - } + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4)) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + if ((bgActor->colHeader->numWaterBoxes != 0) && (bgActor->colHeader->waterBoxes != NULL)) { + for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + curWaterBox < + colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; + curWaterBox++) { + if (curWaterBox->properties & 0x80000) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + *bgId = i; + return true; } } } @@ -4438,37 +4477,37 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, } // boolean -s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, +s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { - return WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox); + return WaterBox_GetSurface1_2(play, colCtx, x, z, ySurface, outWaterBox); } // boolean -s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, +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 /** * Gets the first active WaterBox at `pos` where WaterBox.properties & 0x80000 == 0 * `surfaceCheckDist` is the absolute y distance from the water surface to check * 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; s32 i; WaterBox* waterBox; + BgActor* bgActor; *bgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; //! @bug: check skips testing BgActor waterboxes - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == NULL) { + if ((colHeader->numWaterBoxes == 0) || (colHeader->waterBoxes == NULL)) { *outWaterBox = NULL; return -1; } @@ -4477,15 +4516,16 @@ 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.curRoom.num) && (room != 0x3F)) { continue; } if ((waterBox->properties & 0x80000)) { continue; } - if ((waterBox->minPos.x < pos->x && pos->x < waterBox->minPos.x + waterBox->xLength)) { - if ((waterBox->minPos.z < pos->z && pos->z < waterBox->minPos.z + waterBox->zLength)) { - if (pos->y - surfaceCheckDist < waterBox->minPos.y && waterBox->minPos.y < pos->y + surfaceCheckDist) { + if (((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength))) { + if ((waterBox->minPos.z < pos->z) && (pos->z < waterBox->minPos.z + waterBox->zLength)) { + if ((pos->y - surfaceCheckDist < waterBox->minPos.y) && + (waterBox->minPos.y < pos->y + surfaceCheckDist)) { *outWaterBox = waterBox; return i; } @@ -4494,27 +4534,25 @@ s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec } for (i = 0; i < BG_ACTOR_MAX; i++) { - WaterBox* iterator; - WaterBox* start; - BgActor* bgActor; + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4) || (colCtx->dyna.bgActorFlags[i] & 2)) { continue; } bgActor = &colCtx->dyna.bgActors[i]; - for (iterator = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; - iterator < + for (waterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + waterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; - iterator++) { - if (iterator->properties & 0x80000) { + waterBox++) { + if (waterBox->properties & 0x80000) { continue; } - if ((iterator->minPos.x < pos->x) && pos->x < iterator->minPos.x + iterator->xLength) { - if ((iterator->minPos.z < pos->z) && pos->z < iterator->minPos.z + iterator->zLength) { - if (pos->y - surfaceCheckDist < iterator->minPos.y && - iterator->minPos.y < pos->y + surfaceCheckDist) { + if ((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength)) { + if ((waterBox->minPos.z < pos->z) && (pos->z < waterBox->minPos.z + waterBox->zLength)) { + if ((pos->y - surfaceCheckDist < waterBox->minPos.y) && + (waterBox->minPos.y < pos->y + surfaceCheckDist)) { *bgId = i; - *outWaterBox = iterator; + *outWaterBox = waterBox; return i; } } @@ -4525,9 +4563,6 @@ s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec *outWaterBox = NULL; return -1; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface2.s") -#endif f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId) { CollisionHeader* colHeader; @@ -4543,41 +4578,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); } /** @@ -4589,78 +4629,75 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) return prop & 0x1F; } -#ifdef NON_MATCHING /** * Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input * same as WaterBox_GetSurfaceImpl, but tests if WaterBox properties & 0x80000 != 0 * 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; s32 i; + WaterBox* curWaterBox; BgActor* bgActor; + s32 room; - colHeader = colCtx->colHeader; *outWaterBox = NULL; *bgId = BGCHECK_SCENE; + colHeader = colCtx->colHeader; - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == NULL) { + if ((colHeader->numWaterBoxes == 0) || (colHeader->waterBoxes == NULL)) { return false; } 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 ((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) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - return true; - } - } + + if ((room != play->roomCtx.curRoom.num) && (room != 0x3F)) { + continue; + } + if (!(curWaterBox->properties & 0x80000)) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + return true; } } } - for (i = 0; i < BG_ACTOR_MAX; i++) { - if ((colCtx->dyna.bgActorFlags[i] & 1) && !(colCtx->dyna.bgActorFlags[i] & 2)) { - WaterBox* boxes; - boxes = colCtx->dyna.waterBoxList.boxes; - bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->colHeader->numWaterBoxes != 0 && bgActor->colHeader->waterBoxes != NULL) { - for (curWaterBox = boxes + bgActor->waterboxesStartIndex; - curWaterBox < boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; - curWaterBox++) { - 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) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - *bgId = i; - return true; - } - } - } + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + + for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + curWaterBox < + colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; + curWaterBox++) { + if (!(curWaterBox->properties & 0x80000)) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + *bgId = i; + return true; } } } } return false; } -#else -#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..f54fc93da 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -1,70 +1,456 @@ #include "global.h" +#include "z64quake.h" +#include "z64shrink_window.h" +#include "z64view.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_fabsf.s") +#include "z_camera_data.inc.c" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_LengthVec3f.s") +// BSS +s16 D_801EDBF0; +f32 D_801EDBF4; +f32 D_801EDBF8; +CameraCollision D_801EDC00; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB270.s") +PlayState* sCamPlayState; +SwingAnimation D_801EDC30[4]; +Vec3f D_801EDDD0; +Vec3f D_801EDDE0; +Vec3f D_801EDDF0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Lerpf.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_Lerps.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_800CB42C.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_LerpVec3f.s") + absX = Camera_fabsf(x); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB544.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_800CB584.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/func_800CB5DC.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_800CB60C.s") + y = 1.0f - (xQuadratic / xMaxQuadratic); + } + } + return y; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB674.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_800CB6C8.s") + return (Camera_fabsf(diff) >= minDiff) ? cur + step : target; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB700.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_800CB780.s") + return (ABS(diff) >= minDiff) ? cur + step : target; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB7CC.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_800CB7F8.s") + return (ABS(diff) >= minDiff) ? cur + step : cur; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB828.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_800CB854.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_800CB880.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_800CB8C8.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_800CB8F4.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_800CB924.s") + copy.x = src->x; + copy.y = src->y; + copy.z = src->z; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CB950.s") + *dest = copy; + return dest; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBA08.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_800CBA34.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_800CBA7C.s") +f32 Camera_GetFocalActorHeight(Camera* camera) { + PosRot actorFocus; + Actor* focalActor = camera->focalActor; + f32 focalHeight; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBAAC.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_800CBAD4.s") +f32 Camera_GetRunSpeedLimit(Camera* camera) { + Actor* focalActor = camera->focalActor; + f32 runSpeedLimit; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBB58.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_800CBB88.s") + return runSpeedLimit; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CBC00.s") +s32 func_800CB7CC(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_10; + } else { + return 0; + } +} +s32 Camera_IsMountedOnHorse(Camera* camera) { + Actor* focalActor = camera->focalActor; + + if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { + return ((Player*)focalActor)->stateFlags1 & PLAYER_STATE1_800000; + } else { + return 0; + } +} + +s32 Camera_IsDekuHovering(Camera* camera) { + Actor* focalActor = camera->focalActor; + + 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 +470,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") @@ -98,6 +549,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CC9C0.s") +s32 D_801B9E5C = 0; +f32 D_801B9E60 = 0.0f; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CCCEC.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CD04C.s") @@ -140,147 +594,175 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800CED90.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeNop.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Noop.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeNORM1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeNORM2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeNORM3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeNORM4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeNORM0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Normal0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModePARA1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModePARA2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModePARA3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModePARA4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModePARA0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Parallel0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeJUMP1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeJUMP2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeJUMP3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeJUMP4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeJUMP0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Jump0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeBATT1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeBATT2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeBATT3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeBATT4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeBATT0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Battle0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeKEEP1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeKEEP2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeKEEP3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeKEEP4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeKEEP0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_KeepOn0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeFIXD1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeFIXD2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeFIXD3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeFIXD4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeFIXD0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Fixed0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSUBJ1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSUBJ2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSUBJ3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSUBJ4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSUBJ0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Subject0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDATA0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDATA1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDATA2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDATA3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDATA4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Data4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ5.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique5.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ6.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique6.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ7.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique7.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeUNIQ9.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Unique9.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO2.s") +// Data for opening chests (default) +VecSph D_801B9E64[] = { + { 50.0f, 0xEE3A, 0xD558 }, + { 75.0f, 0x0000, 0x8008 }, + { 80.0f, 0xEE3A, 0x8008 }, + { 15.0f, 0xEE3A, 0x8008 }, +}; +Vec3f D_801B9E84[] = { + { 0.0f, 40.0f, 20.0f }, + { 0.0f, 40.0f, 0.0f }, + { 0.0f, 3.0f, -3.0f }, + { 0.0f, 3.0f, -3.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO3.s") +// Data for opening chests (goron) +VecSph D_801B9EB4[] = { + { 60.0f, 0xEE3A, 0xD558 }, + { 95.0f, 0x0000, 0x8008 }, + { 90.0f, 0xEE3A, 0x8008 }, + { 20.0f, 0xEE3A, 0x8008 }, +}; +Vec3f D_801B9ED4[] = { + { 0.0f, 40.0f, 20.0f }, + { 0.0f, 40.0f, 0.0f }, + { 0.0f, 3.0f, -3.0f }, + { 0.0f, 3.0f, -3.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO5.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO6.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO7.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo5.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo6.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO9.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo7.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeDEMO0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo9.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC1.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Demo0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC2.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC3.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special1.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special2.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC5.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special3.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC6.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC7.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special5.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special6.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_ModeSPEC9.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special7.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Special9.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Alloc.s") @@ -292,12 +774,20 @@ #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") +s16 sEarthquakeFreq[] = { + 0xFFC, // 1 Large Earthquake between CLOCK_TIME(0, 00) to CLOCK_TIME(1, 30) + 0x7FC, // 2 Large Earthquakes between CLOCK_TIME(1, 30) to CLOCK_TIME(3, 00) + 0x3FC, // 4 Large Earthquakes between CLOCK_TIME(3, 00) to CLOCK_TIME(4, 30) + 0x1FC, // 8 Large Earthquakes between CLOCK_TIME(4, 30) to CLOCK_TIME(6, 00) +}; +s16 sEarthquakeTimer = 0; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE62C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DE840.s") @@ -308,6 +798,8 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_Update.s") +s32 sModeChangeFlags = 0; + #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800DF498.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/Camera_SetMode.s") @@ -318,7 +810,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 +820,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 +842,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_camera_data.inc.c b/src/code/z_camera_data.inc.c new file mode 100644 index 000000000..a8e9fbb80 --- /dev/null +++ b/src/code/z_camera_data.inc.c @@ -0,0 +1,3810 @@ +#include "ultra64.h" +#include "global.h" + +/** + * All the data from `CameraSetting`, `CameraMode`, `sCameraUpdateHandlers`, and `CameraModeValue` below + * can be thought of as a single 2D ragged array table with holes in it, indexed by `[camSetting][camMode]`. + * + * The `CameraSetting` and `CameraMode` together build this 2D table, with data/functions/flags for each entry. + * + * Each entry in this 2D table consists of a both a camera-update function to run (`sCameraUpdateHandlers`), + * and a set of data to accompany that camera-update function (`CameraModeValue`). Often, `CameraModeValue` + * data entries are reused. Not every entry is valid, and the flags in the entry are used to indicate this. + */ + +typedef s32 (*CameraUpdateFunc)(Camera*); + +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 + +/*===================================================================== + * Default Data: NORMAL0 Setting + *===================================================================== + */ + +CameraModeValue sSetNormal0ModeNormalData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 10, 22, 15, 40, 60, 84, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal0ModeTargetData[] = { + CAM_FUNCDATA_PARA1(0, 350, 50, 0, 0, 5, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 60, 0), +}; + +CameraModeValue sSetNormal0ModeFollowTargetData[] = { + CAM_FUNCDATA_KEEP1(-30, 180, 200, 20, 40, -5, 10, 15, 45, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 30), +}; + +CameraModeValue sSetNormal0ModeBattleData[] = { + CAM_FUNCDATA_BATT1(-30, 150, 250, 10, 60, -5, 20, 35, 55, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 25, 40), +}; + +CameraModeValue sSetNormal0ModeFirstPersonData[] = { + CAM_FUNCDATA_SUBJ1(0, 5, 50, 10, 0, 0, 0, 45, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetNormal0ModeTalkData[] = { + CAM_FUNCDATA_KEEP3(-20, 80, 150, 50, 5, 20, 5, 40, 35, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, 0), + 60), +}; + +CameraModeValue sSetNormal0ModeClimbData[] = { + CAM_FUNCDATA_JUMP2(-20, 280, 320, 20, 5, 5, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetNormal0ModeBowArrowData[] = { + CAM_FUNCDATA_SUBJ1(0xFFF9, 0xE, 50, 10, 0, -30, -5, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetNormal0ModeBowArrowZData[] = { + CAM_FUNCDATA_SUBJ1(20, 70, 70, 10, 0xFF88, 20, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetNormal0ModeHookshotData[] = { + CAM_FUNCDATA_SPEC5(-20, 80, 250, 45, 60, 40, 6, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetNormal0ModeBoomerangData[] = { + CAM_FUNCDATA_SUBJ1(5, 50, 50, 10, 0, 0, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetNormal0ModeSlingshotData[] = { + CAM_FUNCDATA_SUBJ1(0xFFF9, 14, 50, 10, 0, -50, -10, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetNormal0ModeClimbZData[] = { + CAM_FUNCDATA_JUMP2(-20, 280, 320, 20, 999, 5, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, JUMP2_FLAG_2 | JUMP2_FLAG_1)), +}; + +CameraModeValue sSetNormal0ModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 240, 340, 10, 30, 12, 40, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal0ModeHangData[] = { + CAM_FUNCDATA_PARA1(-40, 320, 50, 40, 0, 8, 5, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_7 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 60, 12), +}; + +CameraModeValue sSetNormal0ModeHangZData[] = { + CAM_FUNCDATA_PARA1(0xFFB0, 300, 50, 70, 0, 12, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_7 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 60, 2), +}; + +CameraModeValue sSetNormal0ModeFreeFallData[] = { + CAM_FUNCDATA_PARA1( + -10, 320, 100, 70, 0, 4, 5, 70, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_7 | PARALLEL1_FLAG_3), 60, 12), +}; + +CameraModeValue sSetNormal0ModeChargeData[] = { + CAM_FUNCDATA_PARA1(0xFFB0, 300, -20, 50, 0, 50, 5, 80, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0), 60, 10), +}; + +CameraModeValue sSetNormal0ModeChargeZData[] = { + CAM_FUNCDATA_PARA1(0xFFB0, 300, -20, 40, 0, 50, 5, 80, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 60, 0), +}; + +CameraModeValue sSetNormal0ModeStillData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 10, 100, 100, 100, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal0ModePushPullData[] = { + CAM_FUNCDATA_PARA1( + 0, 350, 5, 45, 0, 5, 5, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 80, 0), +}; + +CameraModeValue sSetNormal0ModeFollowBoomerangData[] = { + CAM_FUNCDATA_KEEP1(-5, 220, 240, 5, 75, 10, 5, 40, 50, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 30), +}; + +CameraModeValue sSetNormal0ModeDekuShootData[] = { + CAM_FUNCDATA_SUBJ1(0, 5, 50, 10, 0, 50, 65, 45, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetNormal0ModeGoronDashData[] = { + CAM_FUNCDATA_NORM1(50, 160, 255, -2, 12, 10, 40, 92, 88, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_2 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal0ModeDekuHideData[] = { + CAM_FUNCDATA_PARA1( + 100, 300, -20, 40, 0, 4, 5, 80, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 80, + 20), +}; + +CameraModeValue sSetNormal0ModeDekuFlyData[] = { + CAM_FUNCDATA_NORM1(0xFFB0, 280, 320, 40, 20, 12, 40, 80, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal0ModeDekuFlyZData[] = { + CAM_FUNCDATA_PARA1(0xFFBA, 350, 10, 10, 0, 5, 5, 70, 90, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 90, 0), +}; + +CameraModeValue sSetNormal0ModeGoronJumpData[] = { + CAM_FUNCDATA_NORM1( + -10, 160, 400, 0, 18, 12, 40, 80, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_2 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal0ModeZoraFinData[] = { + CAM_FUNCDATA_SUBJ1(5, 100, 100, 10, 0, 0, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +/*===================================================================== + * Custom Data: NORMAL3 Setting + *===================================================================== + */ + +CameraModeValue sSetNormal3ModeNormalData[] = { + CAM_FUNCDATA_JUMP3(-40, 280, 300, 20, 15, 5, 40, 60, 100, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetNormal3ModeTargetData[] = { + CAM_FUNCDATA_PARA1( + -50, 280, 40, 10, 0, 15, 5, 60, 100, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1 | PARALLEL1_FLAG_0), 80, 0), +}; + +CameraModeValue sSetNormal3ModeFreeFallData[] = { + CAM_FUNCDATA_JUMP3(0, 80, 100, 30, 10, 5, 40, 80, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_2)), +}; + +CameraModeValue sSetNormal3ModeGoronJumpData[] = { + CAM_FUNCDATA_JUMP3(-40, 150, 240, -5, 18, 5, 40, 70, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_3 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetNormal3ModeDekuFlyData[] = { + CAM_FUNCDATA_JUMP3(-40, 150, 250, 10, 18, 5, 60, 60, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_2 | JUMP3_FLAG_0)), +}; + +CameraModeValue sSetNormal3ModeDekuHideData[] = { + CAM_FUNCDATA_JUMP3( + 0xFFC4, 150, 250, -15, 18, 5, 60, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_2 | JUMP3_FLAG_0)), +}; + +CameraModeValue sSetNormal3ModeStillData[] = { + CAM_FUNCDATA_NORM1(-40, 80, 300, 20, 100, 100, 100, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal3ModeGoronDashData[] = { + CAM_FUNCDATA_JUMP3(-40, 180, 200, 5, 20, 5, 40, 80, 35, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_3 | JUMP3_FLAG_2)), +}; + +/*===================================================================== + * Custom Data: PIVOT_DIVING Setting + *===================================================================== + */ + +CameraModeValue sSetPivotDivingModeNormalData[] = { + CAM_FUNCDATA_UNIQ2(-40, 60, 60, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, UNIQUE2_FLAG_1)), +}; + +CameraModeValue sSetPivotDivingModeTargetData[] = { + CAM_FUNCDATA_UNIQ2(-30, 45, 100, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, UNIQUE2_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: HORSE Setting + *===================================================================== + */ + +CameraModeValue sSetHorseModeNormalData[] = { + CAM_FUNCDATA_NORM3(-50, 220, 250, 10, 10, 20, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE, + NORMAL3_FLAG_5)), +}; + +CameraModeValue sSetHorseModeTargetData[] = { + CAM_FUNCDATA_NORM3(-40, 180, 200, -3, 2, 100, 50, 90, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, + CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE, NORMAL3_FLAG_1)), +}; + +CameraModeValue sSetHorseModeJumpData[] = { + CAM_FUNCDATA_NORM3( + -50, 220, 260, 10, 10, 20, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE, 0)), +}; + +CameraModeValue sSetHorseModeBowArrowData[] = { + CAM_FUNCDATA_SUBJ1( + 0xFFF9, 14, 100, 10, 0, -30, -5, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE, 0)), +}; + +CameraModeValue sSetHorseModeSlingShotData[] = { + CAM_FUNCDATA_SUBJ1(0xFFF9, 14, 100, 10, 0, -50, -10, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetHorseModeBattleData[] = { + CAM_FUNCDATA_BATT1(0xFFC4, 180, 280, 10, 60, -5, 20, 60, 60, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 25, 40), +}; + +CameraModeValue sSetHorseModeFollowTargetData[] = { + CAM_FUNCDATA_KEEP1(0xFFC4, 180, 220, 25, 45, -5, 15, 15, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, + CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE, KEEPON1_FLAG_0), + 20), +}; + +CameraModeValue sSetHorseModeTalkData[] = { + CAM_FUNCDATA_KEEP3(-50, 140, 200, 40, 10, 0, 5, 100, 45, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, 0), + 60), +}; + +CameraModeValue sSetHorseModeStillData[] = { + CAM_FUNCDATA_NORM3(-40, 180, 200, -3, 100, 100, 60, 10, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, NORMAL3_FLAG_7)), +}; + +/*===================================================================== + * Custom Data: ZORA_DIVING Setting + *===================================================================== + */ + +CameraModeValue sSetZoraDivingModeNormalData[] = { + CAM_FUNCDATA_NORM3(-20, 250, 250, 0, 20, 20, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE, + NORMAL3_FLAG_7)), +}; + +/*===================================================================== + * Custom Data: PREREND_FIXED Setting + *===================================================================== + */ + +CameraModeValue sSetPrerendFixedModeNormalData[] = { + CAM_FUNCDATA_FIXD3(CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +/*===================================================================== + * Custom Data: PREREND_PIVOT Setting + *===================================================================== + */ + +CameraModeValue sSetPrerendPivotModeNormalData[] = { + CAM_FUNCDATA_UNIQ7(60, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +/*===================================================================== + * Custom Data: DOORC Setting + *===================================================================== + */ + +CameraModeValue sSetDoorCModeNormalData[] = { + CAM_FUNCDATA_SPEC9(-5, 60, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE_4, CAM_HUD_VISIBILITY_NONE_ALT, SPECIAL9_FLAG_1)), +}; + +/*===================================================================== + * Custom Data: DEMO0 Setting + *===================================================================== + */ + +CameraModeValue D_801B4EF0[] = { + CAM_FUNCDATA_INTERFACE_FLAGS(CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_NONE_ALT, 0)), +}; + +/*===================================================================== + * Custom Data: Various Cutscenes + *===================================================================== + */ + +// Camera Settings: FREE0, NAVI, TRANSFORM, ATTENTION, WARP1, STOP0, CONNECT0 +CameraModeValue sSetCutscenesModeNormalData[] = { + CAM_FUNCDATA_INTERFACE_FLAGS(CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0)), +}; + +/*===================================================================== + * Custom Data: FUKAN0 Setting + *===================================================================== + */ + +CameraModeValue D_801B4EF8[] = { + CAM_FUNCDATA_NORM1( + -40, 600, 600, 45, 50, 10, 50, 45, 90, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_6 | NORMAL1_FLAG_1)), +}; + +CameraModeValue D_801B4F20[] = { + CAM_FUNCDATA_PARA1(-40, 400, 25, 60, 0, 5, 5, 60, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 80, 0), +}; + +CameraModeValue D_801B4F50[] = { + CAM_FUNCDATA_NORM1(-40, 600, 600, 45, 50, 10, 50, 45, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B4F78[] = { + CAM_FUNCDATA_NORM1(-40, 600, 600, 45, 100, 100, 100, 45, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: NORMAL1 Setting + *===================================================================== + */ + +CameraModeValue sSetNormal1ModeNormalData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 15, 18, 12, 70, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_1)), +}; + +CameraModeValue sSetNormal1ModeStillData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 15, 100, 100, 100, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: NANAME Setting + *===================================================================== + */ + +// Normal4 +CameraModeValue D_801B4FF0[] = { + CAM_FUNCDATA_NORM1( + -20, 280, 320, 10, 18, 12, 40, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: CIRCLE0 Setting + *===================================================================== + */ + +CameraModeValue D_801B5018[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 0x3200, 10, 20, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, FIXED2_FLAG_0)), +}; + +CameraModeValue D_801B5034[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 0x3200, 100, 80, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, FIXED2_FLAG_6)), +}; + +CameraModeValue D_801B5050[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 200, 100, 50, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, FIXED2_FLAG_7)), +}; + +/*===================================================================== + * Custom Data: FIXED0 Setting + *===================================================================== + */ + +CameraModeValue D_801B506C[] = { + CAM_FUNCDATA_FIXD1(-40, 10, 60, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +/*===================================================================== + * Custom Data: SPIRAL_DOOR Setting + *===================================================================== + */ + +CameraModeValue sSetSpiralDoorModeNormalData[] = { + CAM_FUNCDATA_SPEC8(-40, 50, 80, 60, 10, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, SPECIAL8_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: DUNGEON0 Setting + *===================================================================== + */ + +CameraModeValue sSetDungeon0ModeNormalData[] = { + CAM_FUNCDATA_NORM1(-20, 150, 250, 5, 18, 5, 45, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon0ModeTargetData[] = { + CAM_FUNCDATA_PARA1( + 0, 200, 25, 5, 0, 5, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_6 | PARALLEL1_FLAG_1), 80, 0), +}; + +CameraModeValue sSetDungeon0ModeFollowTargetData[] = { + CAM_FUNCDATA_KEEP1(-20, 120, 140, 25, 45, -5, 15, 15, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 20), +}; + +CameraModeValue sSetDungeon0ModeBattleData[] = { + CAM_FUNCDATA_BATT1(-30, 150, 240, 10, 50, 5, 10, 25, 50, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 25, 50), +}; + +CameraModeValue sSetDungeon0ModeFollowBoomerangData[] = { + CAM_FUNCDATA_KEEP1(-5, 150, 240, 5, 65, 10, 5, 40, 55, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 30), +}; + +CameraModeValue sSetDungeon0ModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 150, 250, 5, 24, 5, 50, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon0ModeFreeFallData[] = { + CAM_FUNCDATA_PARA1( + -10, 250, 100, 70, 0, 4, 5, 70, 10, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_7 | PARALLEL1_FLAG_3), 70, 12), +}; + +CameraModeValue sSetDungeon0ModeClimbData[] = { + CAM_FUNCDATA_JUMP2(-40, 150, 250, 20, 5, 5, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue sSetDungeon0ModeClimbZData[] = { + CAM_FUNCDATA_JUMP2(-40, 250, 250, 20, 999, 5, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, JUMP2_FLAG_2 | JUMP2_FLAG_1)), +}; + +CameraModeValue sSetDungeon0ModeChargeData[] = { + CAM_FUNCDATA_PARA1(0, 250, -20, 50, 0, 50, 5, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0), 60, 10), +}; + +CameraModeValue sSetDungeon0ModeChargeZData[] = { + CAM_FUNCDATA_PARA1(50, 250, -20, 40, 0, 50, 5, 80, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 60, 0), +}; + +CameraModeValue sSetDungeon0ModeHangData[] = { + CAM_FUNCDATA_PARA1(-40, 220, 50, 40, 0, 12, 5, 60, 10, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_7 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 60, 12), +}; + +CameraModeValue sSetDungeon0ModeHangZData[] = { + CAM_FUNCDATA_PARA1(0xFFB0, 250, 50, 70, 0, 10, 5, 45, 10, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_7 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 60, 2), +}; + +CameraModeValue sSetDungeon0ModeStillData[] = { + CAM_FUNCDATA_NORM1( + -10, 180, 220, 10, 100, 100, 100, 60, 10, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon0ModePushPullData[] = { + CAM_FUNCDATA_PARA1( + 0, 250, 5, 30, 0, 5, 5, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 80, 0), +}; + +/*===================================================================== + * Custom Data: ITEM0 Setting + *===================================================================== + */ + +CameraModeValue D_801B5338[] = { + CAM_FUNCDATA_KEEP4(5, 70, 25, 0, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B535C[] = { + CAM_FUNCDATA_KEEP4(-30, 35, 40, 0, 6, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B5380[] = { + CAM_FUNCDATA_KEEP4(-15, 90, -8, 0, 0, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B53A4[] = { + CAM_FUNCDATA_KEEP4(20, 45, 0x0037, 0, 12, 55, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B53C8[] = { + CAM_FUNCDATA_KEEP4(10, 70, 30, 0, 4, 42, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +/*===================================================================== + * Custom Data: ITEM1 Setting + *===================================================================== + */ + +CameraModeValue D_801B53EC[] = { + CAM_FUNCDATA_KEEP4(-45, 75, 0xFFF4, 165, 5, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B5410[] = { + CAM_FUNCDATA_KEEP4(-40, 70, 20, 140, 5, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B5434[] = { + CAM_FUNCDATA_KEEP4(-20, 85, -5, 140, 15, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B5458[] = { + CAM_FUNCDATA_KEEP4(-50, 0x005F, -15, 160, 6, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B547C[] = { + CAM_FUNCDATA_KEEP4( + 0xFFC4, 70, -15, 0xFF74, 30, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3 | KEEPON4_FLAG_2), 25, 6), +}; + +/*===================================================================== + * Custom Data: ITEM2 Setting + *===================================================================== + */ + +CameraModeValue D_801B54A0[] = { + CAM_FUNCDATA_KEEP4(-40, 0x006E, 5, 150, 5, 65, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B54C4[] = { + CAM_FUNCDATA_KEEP4(0xFFC4, 0x0082, -10, 0x00AA, 5, 65, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B54E8[] = { + CAM_FUNCDATA_KEEP4(-40, 0x006E, 0, 140, 5, 65, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B550C[] = { + CAM_FUNCDATA_KEEP4(-50, 140, -10, 160, 5, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B5530[] = { + CAM_FUNCDATA_KEEP4(0xFFC4, 120, -8, 150, 5, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +/*===================================================================== + * Custom Data: ITEM3 Setting + *===================================================================== + */ + +CameraModeValue D_801B5554[] = { + CAM_FUNCDATA_KEEP4( + -15, 65, 50, 0xFF65, 5, 75, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3 | KEEPON4_FLAG_2), 25, 6), +}; + +CameraModeValue D_801B5578[] = { + CAM_FUNCDATA_KEEP4( + -20, 60, 50, 0xFF65, 5, 75, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3 | KEEPON4_FLAG_2), 25, 6), +}; + +CameraModeValue D_801B559C[] = { + CAM_FUNCDATA_KEEP4(-15, 60, 40, 0x00AA, 5, 75, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 6), +}; + +CameraModeValue D_801B55C0[] = { + CAM_FUNCDATA_KEEP4( + -25, 0x005F, 50, 0xFF65, 5, 75, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3 | KEEPON4_FLAG_2), 25, 6), +}; + +CameraModeValue D_801B55E4[] = { + CAM_FUNCDATA_KEEP4( + -20, 75, 45, 0xFF6A, -5, 75, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3 | KEEPON4_FLAG_2), 25, 6), +}; + +/*===================================================================== + * Custom Data: WARP0 Setting + *===================================================================== + */ + +CameraModeValue D_801B5608[] = { + CAM_FUNCDATA_KEEP4(-45, 165, 0, 0x00B2, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, + KEEPON4_FLAG_6 | KEEPON4_FLAG_3 | KEEPON4_FLAG_2 | KEEPON4_FLAG_1), + 30, 10), +}; + +CameraModeValue D_801B562C[] = { + CAM_FUNCDATA_KEEP4(0xFFC9, 180, 0, 0x00B2, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, + KEEPON4_FLAG_6 | KEEPON4_FLAG_3 | KEEPON4_FLAG_2 | KEEPON4_FLAG_1), + 30, 10), +}; + +CameraModeValue D_801B5650[] = { + CAM_FUNCDATA_KEEP4(-20, 0x00AF, 0, 0x00B2, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, + KEEPON4_FLAG_6 | KEEPON4_FLAG_3 | KEEPON4_FLAG_2 | KEEPON4_FLAG_1), + 30, 10), +}; + +CameraModeValue D_801B5674[] = { + CAM_FUNCDATA_KEEP4(-50, 220, 0, 0x00B2, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, + KEEPON4_FLAG_6 | KEEPON4_FLAG_3 | KEEPON4_FLAG_2 | KEEPON4_FLAG_1), + 30, 10), +}; + +CameraModeValue D_801B5698[] = { + CAM_FUNCDATA_KEEP4(0xFFC4, 200, 0, 0x00B2, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, + KEEPON4_FLAG_6 | KEEPON4_FLAG_3 | KEEPON4_FLAG_2 | KEEPON4_FLAG_1), + 30, 10), +}; + +/*===================================================================== + * Custom Data: DEATH Setting + *===================================================================== + */ + +CameraModeValue sSetDeathModeNormalData[] = { + CAM_FUNCDATA_KEEP4(0xFFBA, 160, 0, 0, 10, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0), 5, 100), +}; + +CameraModeValue sSetDeathModeJumpData[] = { + CAM_FUNCDATA_KEEP4(0xFFBA, 160, 0, 0, 5, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0), 5, 100), +}; + +CameraModeValue sSetDeathModeDekuShootData[] = { + CAM_FUNCDATA_KEEP4(0xFFBA, 150, 0, 0, 5, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0), 5, 100), +}; + +/*===================================================================== + * Custom Data: REBIRTH Setting + *===================================================================== + */ + +CameraModeValue D_801B5728[] = { + CAM_FUNCDATA_KEEP4( + 0xFFC4, 160, 30, 160, 10, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_2 | KEEPON4_FLAG_1), 5, 100), +}; + +CameraModeValue D_801B574C[] = { + CAM_FUNCDATA_KEEP4( + -20, 140, 30, 160, 10, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_2 | KEEPON4_FLAG_1), 5, 100), +}; + +/*===================================================================== + * Custom Data: LONG_CHEST_OPENING Setting + *===================================================================== + */ + +CameraModeValue sSetLongChestOpeningModeNormalData[] = { + CAM_FUNCDATA_DEMO2(60, 30, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0)), +}; + +/*===================================================================== + * Custom Data: DUNGEON1 Setting + *===================================================================== + */ + +CameraModeValue sSetDungeon1ModeNormalData[] = { + CAM_FUNCDATA_NORM1(-20, 350, 400, 45, 50, 20, 70, 50, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon1ModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 350, 400, 40, 50, 20, 50, 50, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon1ModeStillData[] = { + CAM_FUNCDATA_NORM1(-20, 350, 400, 45, 100, 100, 100, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon1ModePushPullData[] = { + CAM_FUNCDATA_PARA1( + 0, 250, 5, 30, 0, 5, 5, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 30, 0), +}; + +/*===================================================================== + * Custom Data: FIXED1 Setting + *===================================================================== + */ + +CameraModeValue D_801B5824[] = { + CAM_FUNCDATA_FIXD1(-40, 100, 60, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0)), +}; + +/*===================================================================== + * Custom Data: FIXED2 Setting + *===================================================================== + */ + +CameraModeValue D_801B5834[] = { + CAM_FUNCDATA_FIXD1(-40, 10, 60, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0)), +}; + +/*===================================================================== + * Custom Data: MAZE Setting + *===================================================================== + */ + +CameraModeValue sSetMazeModeNormalData[] = { + CAM_FUNCDATA_PARA2(0xFFDD, 160, 65, -5, 2, 70, 99, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL2_FLAG_1)), +}; + +/*===================================================================== + * Custom Data: REMOTEBOMB Setting + *===================================================================== + */ + +CameraModeValue sSetRemoteBombModeNormalData[] = { + CAM_FUNCDATA_NORM2(20, 200, 800, 15, 6, 70, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL2_FLAG_1)), +}; + +/*===================================================================== + * Custom Data: CIRCLE1 Setting + *===================================================================== + */ + +CameraModeValue D_801B5884[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 0x3200, 10, 20, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, FIXED2_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: CIRCLE2 Setting + *===================================================================== + */ + +CameraModeValue D_801B58A0[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 0x3200, 100, 80, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0)), +}; + +/*===================================================================== + * Custom Data: CIRCLE3 Setting + *===================================================================== + */ + +CameraModeValue D_801B58BC[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 0x3200, 100, 80, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +/*===================================================================== + * Custom Data: CIRCLE4 Setting + *===================================================================== + */ + +CameraModeValue D_801B58D8[] = { + CAM_FUNCDATA_FIXD2( + -40, 40, 0x3200, 100, 10, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, FIXED2_FLAG_3 | FIXED2_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: FIXED3 Setting + *===================================================================== + */ + +CameraModeValue D_801B58F4[] = { + CAM_FUNCDATA_FIXD1(-40, 100, 60, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +/*===================================================================== + * Custom Data: CAM_SET_TOWER_ASCENT Setting + *===================================================================== + */ + +CameraModeValue sSetTowerClimbModeNormalData[] = { + CAM_FUNCDATA_NORM0(0, 350, 400, 20, 20, 50, 65, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL0_FLAG_0)), +}; + +CameraModeValue sSetTowerClimbModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 340, 400, 10, 30, 12, 40, 65, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetTowerClimbModeStillData[] = { + CAM_FUNCDATA_NORM1(0, 350, 400, 10, 100, 100, 100, 65, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: PARALLEL0 Setting + *===================================================================== + */ + +CameraModeValue D_801B5978[] = { + CAM_FUNCDATA_PARA1( + 0, 400, 20, 0, 0, 20, 5, 70, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_3 | PARALLEL1_FLAG_1), 80, 0), +}; + +/*===================================================================== + * Custom Data: NORMALD Setting + *===================================================================== + */ + +CameraModeValue D_801B59A8[] = { + CAM_FUNCDATA_NORM1( + 0, 400, 0x01F4, 15, 18, 12, 35, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: SUBJECTD Setting + *===================================================================== + */ + +CameraModeValue D_801B59D0[] = { + CAM_FUNCDATA_SUBJ1(0, 5, 50, 10, 0, 0, 10, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, 0)), +}; + +/*===================================================================== + * Custom Data: START0 Setting + *===================================================================== + */ + +CameraModeValue D_801B59F4[] = { + CAM_FUNCDATA_UNIQ0(0, 100, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, UNIQUE0_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: START2 Setting + *===================================================================== + */ + +CameraModeValue D_801B5A00[] = { + CAM_FUNCDATA_UNIQ0( + 0, 30, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, UNIQUE0_FLAG_4 | UNIQUE0_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: BOAT_CRUISE Setting + *===================================================================== + */ + +CameraModeValue sSetBoatCruiseModeNormalData[] = { + CAM_FUNCDATA_SUBJ1(20, 90, 80, 10, 0, 50, 0xFF38, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +/*===================================================================== + * Custom Data: VERTICAL_CLIMB Setting + *===================================================================== + */ + +CameraModeValue sSetVerticalClimbModeClimbData[] = { + CAM_FUNCDATA_PARA1_ALT(0, 400, 50, 0, 0, 5, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 70, 0, + 50), +}; + +/*===================================================================== + * Custom Data: SIDED Setting + *===================================================================== + */ + +CameraModeValue D_801B5A64[] = { + CAM_FUNCDATA_PARA1(0, 400, 10, 0, 0xFFA6, 20, 5, 70, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_5 | PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 70, 0), +}; + +/*===================================================================== + * Custom Data: DUNGEON2 Setting + *===================================================================== + */ + +CameraModeValue sSetDungeon2ModeNormalData[] = { + CAM_FUNCDATA_NORM1(-10, 270, 300, 20, 0x001C, 20, 65, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon2ModeBattleData[] = { + CAM_FUNCDATA_BATT1(-40, 200, 240, 50, 20, 5, 10, 20, 50, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 25, 40), +}; + +CameraModeValue sSetDungeon2ModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 270, 300, 40, 50, 20, 50, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon2ModeStillData[] = { + CAM_FUNCDATA_NORM1(-10, 270, 300, 20, 100, 100, 100, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon2ModePushPullData[] = { + CAM_FUNCDATA_PARA1( + 0, 200, 5, 15, 0, 5, 5, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 30, 0), +}; + +/*===================================================================== + * Custom Data: BOSS_ODOLWA Setting + *===================================================================== + */ + +CameraModeValue sSetBossOdolwaModeNormalData[] = { + CAM_FUNCDATA_NORM1(-20, 250, 350, 10, 24, 12, 40, 65, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossOdolwaModeFollowTargetData[] = { + CAM_FUNCDATA_KEEP1(-50, 300, 350, 10, 20, 5, 12, 70, 60, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0), 20), +}; + +CameraModeValue sSetBossOdolwaModeTalkData[] = { + CAM_FUNCDATA_KEEP3( + -20, 230, 260, 20, 10, 20, 15, 40, 55, 20, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, KEEPON3_FLAG_5), 40), +}; + +CameraModeValue sSetBossOdolwaModeBattleData[] = { + CAM_FUNCDATA_BATT1(0xFFC4, 200, 220, 20, 10, 0, 10, 60, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 10, 40), +}; + +CameraModeValue sSetBossOdolwaModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 250, 350, 10, 30, 12, 40, 65, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossOdolwaModeStillData[] = { + CAM_FUNCDATA_NORM1(-20, 250, 350, 10, 100, 100, 100, 65, 15, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: KEEP_BACK Setting + *===================================================================== + */ + +CameraModeValue D_801B5C80[] = { + CAM_FUNCDATA_PARA1( + 100, 300, -20, 40, 0, 4, 5, 80, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 60, 20), +}; + +/*===================================================================== + * Custom Data: CIRCLE6 Setting + *===================================================================== + */ + +CameraModeValue D_801B5CB0[] = { + CAM_FUNCDATA_FIXD2( + -40, 60, 0x3200, 10, 20, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, FIXED2_FLAG_1 | FIXED2_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: CIRCLE7 Setting + *===================================================================== + */ + +CameraModeValue D_801B5CCC[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 200, 10, 20, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, FIXED2_FLAG_5)), +}; + +/*===================================================================== + * Custom Data: MINI_BOSS Setting + *===================================================================== + */ + +CameraModeValue sSetMiniBossModeNormalData[] = { + CAM_FUNCDATA_NORM1(-15, 220, 280, 17, 14, 5, 65, 70, 75, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetMiniBossModeFollowTargetData[] = { + CAM_FUNCDATA_KEEP1(0, 200, 250, 25, 45, 40, 15, 40, 60, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 20), +}; + +CameraModeValue sSetMiniBossModeBattleData[] = { + CAM_FUNCDATA_BATT1(-25, 180, 220, 10, 40, 10, 0, 40, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 20, 50), +}; + +CameraModeValue sSetMiniBossModeJumpData[] = { + CAM_FUNCDATA_NORM1(-15, 220, 280, 16, 12, 5, 60, 70, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetMiniBossModeStillData[] = { + CAM_FUNCDATA_NORM1(-15, 220, 280, 16, 100, 100, 100, 70, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: RFIXED1 Setting + *===================================================================== + */ + +CameraModeValue D_801B5DC4[] = { + CAM_FUNCDATA_FIXD1(-40, 10, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, FIXED1_FLAG_4)), +}; + +/*===================================================================== + * Custom Data: TRESURE1 Setting + *===================================================================== + */ + +CameraModeValue sSetTreasureChestMinigameModeNormalData[] = { + CAM_FUNCDATA_NORM1( + -20, 80, 120, -10, 15, 20, 40, 70, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_7 | NORMAL1_FLAG_1)), +}; + +CameraModeValue sSetTreasureChestMinigameModeTargetData[] = { + CAM_FUNCDATA_PARA1( + 0xFFC4, 0x0226, 0, 65, 0, 5, 5, 75, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_6 | PARALLEL1_FLAG_1), 60, 0), +}; + +/*===================================================================== + * Custom Data: BOMBBASKET Setting + *===================================================================== + */ + +CameraModeValue D_801B5E2C[] = { + CAM_FUNCDATA_FIXD2(70, 50, 0x3200, 100, 30, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, FIXED2_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: CIRCLE8 Setting + *===================================================================== + */ + +CameraModeValue D_801B5E48[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 0x3200, 100, 20, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, FIXED2_FLAG_3)), +}; + +/*===================================================================== + * Custom Data: BIRDS_EYE_VIEW_1 Setting + *===================================================================== + */ + +CameraModeValue D_801B5E64[] = { + CAM_FUNCDATA_NORM1( + -20, 800, 800, 60, 50, 10, 50, 45, 90, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_6 | NORMAL1_FLAG_1)), +}; + +CameraModeValue D_801B5E8C[] = { + CAM_FUNCDATA_NORM1(-20, 800, 800, 60, 100, 100, 100, 45, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: DUNGEON3 Setting + *===================================================================== + */ + +CameraModeValue sSetDungeon3ModeNormalData[] = { + CAM_FUNCDATA_NORM1( + -30, 180, 250, -5, 18, 20, 60, 55, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_7 | NORMAL1_FLAG_1)), +}; + +CameraModeValue sSetDungeon3ModeTargetData[] = { + CAM_FUNCDATA_PARA1( + -30, 180, 20, 0, 0, 5, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_6 | PARALLEL1_FLAG_1), 80, 0), +}; + +CameraModeValue sSetDungeon3ModeJumpData[] = { + CAM_FUNCDATA_NORM1(-30, 160, 190, 0, 30, 20, 60, 55, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon3ModeStillData[] = { + CAM_FUNCDATA_NORM1(-40, 0x00AA, 200, 0, 100, 100, 100, 55, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon3ModePushPullData[] = { + CAM_FUNCDATA_PARA1( + 0, 180, 5, 5, 0, 5, 5, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 30, 0), +}; + +/*===================================================================== + * Custom Data: TELESCOPE Setting + *===================================================================== + */ + +CameraModeValue sSetTelescopeModeNormalData[] = { + CAM_FUNCDATA_SUBJ1(0, 5, 50, 10, 0, 0, 0, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_NONE_ALT, 0)), +}; + +CameraModeValue sSetTelescopeModeTargetData[] = { + CAM_FUNCDATA_SUBJ1(0, 5, 50, 10, 0, 0, 0, 15, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_NONE_ALT, 0)), +}; + +CameraModeValue sSetTelescopeModeFirstPersonData[] = { + CAM_FUNCDATA_SUBJ1(0, 5, 50, 10, 0, 0, 0, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_NONE_ALT, SUBJECT1_FLAG_4)), +}; + +CameraModeValue sSetTelescopeModeDekuHideData[] = { + CAM_FUNCDATA_SUBJ1(0, 5, 50, 0x0001, 0, 0, 0, 45, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_NONE_ALT, SUBJECT1_FLAG_4)), +}; + +/*===================================================================== + * Custom Data: ROOM0 Setting + *===================================================================== + */ + +CameraModeValue D_801B601C[] = { + CAM_FUNCDATA_NORM1(0xFFDD, 100, 220, 15, 0x0011, 12, 35, 65, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B6044[] = { + CAM_FUNCDATA_PARA1(-10, 200, 50, 0, 0, 5, 5, 65, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_6 | PARALLEL1_FLAG_4 | PARALLEL1_FLAG_1), + 60, 0), +}; + +CameraModeValue D_801B6074[] = { + CAM_FUNCDATA_KEEP1(-30, 60, 200, 20, 40, -5, 10, 30, 45, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 30), +}; + +CameraModeValue D_801B60A4[] = { + CAM_FUNCDATA_KEEP3( + -20, 50, 100, 50, 5, 20, 5, 40, 35, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, KEEPON3_FLAG_5), 60), +}; + +CameraModeValue D_801B60D8[] = { + CAM_FUNCDATA_BATT1(-25, 100, 140, 10, 40, -2, 10, 25, 50, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 25, 50), +}; + +CameraModeValue D_801B610C[] = { + CAM_FUNCDATA_JUMP2(-20, 100, 220, 20, 5, 5, 65, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue D_801B6130[] = { + CAM_FUNCDATA_JUMP2(-20, 120, 240, 20, 999, 5, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, JUMP2_FLAG_2 | JUMP2_FLAG_1)), +}; + +CameraModeValue D_801B6154[] = { + CAM_FUNCDATA_NORM1(-30, 100, 220, 10, 30, 12, 80, 65, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B617C[] = { + CAM_FUNCDATA_PARA1(-40, 200, 50, 40, 0, 8, 5, 65, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_7 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 60, 12), +}; + +CameraModeValue D_801B61AC[] = { + CAM_FUNCDATA_PARA1(0xFFB0, 240, 50, 70, 0, 12, 5, 45, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_7 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 60, 2), +}; + +CameraModeValue D_801B61DC[] = { + CAM_FUNCDATA_PARA1( + -10, 200, 100, 70, 0, 4, 5, 70, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_7 | PARALLEL1_FLAG_3), 65, 12), +}; + +CameraModeValue D_801B620C[] = { + CAM_FUNCDATA_PARA1(0xFFB0, 240, -20, 50, 0, 50, 5, 80, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0), 65, 10), +}; + +CameraModeValue D_801B623C[] = { + CAM_FUNCDATA_PARA1(0xFFB0, 240, -20, 40, 0, 50, 5, 80, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 65, 0), +}; + +CameraModeValue D_801B626C[] = { + CAM_FUNCDATA_NORM1(-20, 100, 220, 10, 100, 100, 100, 65, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B6294[] = { + CAM_FUNCDATA_PARA1(0, 200, 5, 45, 0, 5, 5, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_5 | PARALLEL1_FLAG_4 | PARALLEL1_FLAG_1), + 80, 0), +}; + +CameraModeValue D_801B62C4[] = { + CAM_FUNCDATA_KEEP1(-5, 120, 140, 5, 85, 10, 5, 25, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 30), +}; + +CameraModeValue D_801B62F4[] = { + CAM_FUNCDATA_NORM1(50, 140, 220, 0, 0xC, 10, 40, 90, 90, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_2 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B631C[] = { + CAM_FUNCDATA_PARA1( + 100, 220, -20, 40, 0, 4, 5, 80, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 80, + 20), +}; + +CameraModeValue D_801B634C[] = { + CAM_FUNCDATA_NORM1(0xFFC4, 150, 250, 40, 20, 12, 40, 80, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B6374[] = { + CAM_FUNCDATA_PARA1(0xFFC4, 220, 20, 10, 0, 5, 5, 60, 90, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_3 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 90, 0), +}; + +CameraModeValue D_801B63A4[] = { + CAM_FUNCDATA_NORM1( + -10, 120, 240, 0, 18, 12, 40, 80, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_2 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B63CC[] = { + CAM_FUNCDATA_PARA1(0, 220, 50, 0, 0, 5, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 60, 0), +}; + +/*===================================================================== + * Custom Data: RCIRC0 Setting + *===================================================================== + */ + +CameraModeValue D_801B63FC[] = { + CAM_FUNCDATA_FIXD2( + -10, 40, 0x3200, 100, 20, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, FIXED2_FLAG_4 | FIXED2_FLAG_3)), +}; + +/*===================================================================== + * Custom Data: CIRC9 Setting + *===================================================================== + */ + +CameraModeValue D_801B6418[] = { + CAM_FUNCDATA_FIXD2(-40, 40, 0x3200, 5, 25, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, FIXED2_FLAG_2 | FIXED2_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: ONTHEPOLE Setting + *===================================================================== + */ + +CameraModeValue D_801B6434[] = { + CAM_FUNCDATA_NORM1(-15, 60, 600, 35, 40, 20, 60, 45, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_1)), +}; + +CameraModeValue D_801B645C[] = { + CAM_FUNCDATA_PARA1( + 0, 300, 5, 35, 0, 5, 5, 60, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_6 | PARALLEL1_FLAG_1), 80, 0), +}; + +CameraModeValue D_801B648C[] = { + CAM_FUNCDATA_NORM1(-10, 320, 0x017C, 30, 0x0016, 10, 0x0020, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B64B4[] = { + CAM_FUNCDATA_JUMP2(-20, 280, 320, 20, 5, 5, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue D_801B64D8[] = { + CAM_FUNCDATA_JUMP2(-20, 280, 320, 20, 999, 5, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, JUMP2_FLAG_2 | JUMP2_FLAG_1)), +}; + +CameraModeValue D_801B64FC[] = { + CAM_FUNCDATA_PARA1(-40, 320, 50, 40, 0, 8, 5, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_7 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 50, 12), +}; + +CameraModeValue D_801B652C[] = { + CAM_FUNCDATA_PARA1(0xFFB0, 300, 50, 70, 0, 12, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, + PARALLEL1_FLAG_7 | PARALLEL1_FLAG_2 | PARALLEL1_FLAG_1), + 50, 2), +}; + +CameraModeValue D_801B655C[] = { + CAM_FUNCDATA_NORM1(-15, 340, 350, 30, 100, 100, 100, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: INBUSH Setting + *===================================================================== + */ + +CameraModeValue D_801B6584[] = { + CAM_FUNCDATA_NORM1( + 0, 260, 280, 20, 20, 12, 50, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_7 | NORMAL1_FLAG_1)), +}; + +CameraModeValue D_801B65AC[] = { + CAM_FUNCDATA_PARA1(10, 260, 50, 15, 0, 5, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 60, 0), +}; + +CameraModeValue D_801B65DC[] = { + CAM_FUNCDATA_KEEP1(10, 200, 220, 20, 40, 20, 30, 15, 45, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 30), +}; + +CameraModeValue D_801B660C[] = { + CAM_FUNCDATA_KEEP3( + 10, 180, 200, 30, 10, 30, 30, 70, 45, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, KEEPON3_FLAG_6), 60), +}; + +CameraModeValue D_801B6640[] = { + CAM_FUNCDATA_BATT1(10, 220, 220, 10, 80, 20, 30, 25, 50, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 25, 60), +}; + +CameraModeValue D_801B6674[] = { + CAM_FUNCDATA_SUBJ1(0, 10, 60, 10, 0, 50, 0, 45, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, 0)), +}; + +CameraModeValue D_801B6698[] = { + CAM_FUNCDATA_NORM1(0, 260, 280, 40, 20, 12, 40, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1)), +}; + +CameraModeValue D_801B66C0[] = { + CAM_FUNCDATA_NORM1(0, 260, 280, 20, 100, 100, 100, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: BOSS_MAJORA Setting + *===================================================================== + */ + +CameraModeValue sSetBossMajoraModeNormalData[] = { + CAM_FUNCDATA_NORM1(0, 280, 320, -5, 24, 12, 0x0020, 65, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossMajoraModeFollowTargetData[] = { + CAM_FUNCDATA_KEEP1(-30, 240, 260, 20, 40, 10, 5, 60, 50, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0), 30), +}; + +CameraModeValue sSetBossMajoraModeBattleData[] = { + CAM_FUNCDATA_BATT1(0xFFC4, 180, 200, 10, 20, 20, 10, 20, 70, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 10, 40), +}; + +CameraModeValue sSetBossMajoraModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 10, 30, 12, 40, 65, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossMajoraModeStillData[] = { + CAM_FUNCDATA_NORM1(0, 280, 320, 0, 100, 100, 100, 65, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: BOSS_TWINMOLD Setting + *===================================================================== + */ + +CameraModeValue sSetBossTwinmoldModeNormalData[] = { + CAM_FUNCDATA_NORM1(20, 350, 400, 0, 0x001A, 12, 0x0020, 75, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossTwinmoldModeTargetData[] = { + CAM_FUNCDATA_PARA1(0, 400, 50, 0, 0, 5, 5, 55, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 60, 0), +}; + +CameraModeValue sSetBossTwinmoldModeFollowTargetData[] = { + CAM_FUNCDATA_KEEP1(-30, 250, 300, 20, 40, 10, 5, 60, 50, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, 0), 30), +}; + +CameraModeValue sSetBossTwinmoldModeBattleData[] = { + CAM_FUNCDATA_BATT1(0, 150, 200, 10, 30, 10, 0, 20, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 10, 40), +}; + +CameraModeValue sSetBossTwinmoldModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 350, 400, 10, 30, 12, 40, 75, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossTwinmoldModeStillData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 10, 100, 100, 100, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_4 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: BOSS_GOHT Setting + *===================================================================== + */ + +CameraModeValue sSetBossGohtModeNormalData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 10, 20, 12, 50, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossGohtModeBattleData[] = { + CAM_FUNCDATA_BATT1(-25, 220, 220, 10, 80, -2, 10, 25, 50, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 25, 50), +}; + +CameraModeValue sSetBossGohtModeJumpData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 10, 30, 12, 40, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossGohtModeStillData[] = { + CAM_FUNCDATA_NORM1(-20, 280, 320, 10, 100, 100, 100, 60, 15, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetBossGohtModeGoronDashData[] = { + CAM_FUNCDATA_NORM1(60, 200, 340, 10, 15, 10, 50, 85, 90, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_2 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: BOSS_GYORG Setting + *===================================================================== + */ + +CameraModeValue sSetBossGyorgModeNormalData[] = { + CAM_FUNCDATA_JUMP3(-20, 280, 320, 10, 20, 12, 40, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetBossGyorgModeFollowTargetData[] = { + CAM_FUNCDATA_KEEP1(-30, 200, 240, 20, 40, -5, 10, 15, 45, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 30), +}; + +CameraModeValue sSetBossGyorgModeBattleData[] = { + CAM_FUNCDATA_BATT1(-30, 190, 250, 10, 50, 0, 10, 20, 50, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 25, 50), +}; + +CameraModeValue sSetBossGyorgModeGoronJumpData[] = { + CAM_FUNCDATA_JUMP3(-40, 160, 260, -5, 18, 5, 40, 70, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_3 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetBossGyorgModeDekuFlyData[] = { + CAM_FUNCDATA_JUMP3(-30, 220, 280, 0, 18, 5, 60, 60, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_2 | JUMP3_FLAG_0)), +}; + +CameraModeValue sSetBossGyorgModeDekuHideData[] = { + CAM_FUNCDATA_JUMP3( + 0xFFC4, 160, 280, -15, 18, 5, 60, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_2 | JUMP3_FLAG_0)), +}; + +CameraModeValue sSetBossGyorgModeStillData[] = { + CAM_FUNCDATA_NORM1(-40, 100, 320, 20, 100, 100, 100, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: PINNACLE_ROCK Setting + *===================================================================== + */ + +CameraModeValue sSetPinnacleRockModeNormalData[] = { + CAM_FUNCDATA_JUMP3(-40, 250, 350, 30, 15, 5, 40, 60, 100, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetPinnacleRockModeTargetData[] = { + CAM_FUNCDATA_PARA1( + -50, 350, 40, 10, 0, 15, 5, 60, 100, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1 | PARALLEL1_FLAG_0), 80, 0), +}; + +CameraModeValue sSetPinnacleRockModeGoronJumpData[] = { + CAM_FUNCDATA_JUMP3(-40, 320, 400, -5, 18, 5, 40, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_3 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetPinnacleRockModeDekuFlyData[] = { + CAM_FUNCDATA_JUMP3(-40, 300, 350, 10, 18, 5, 60, 60, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_2 | JUMP3_FLAG_0)), +}; + +CameraModeValue sSetPinnacleRockModeDekuHideData[] = { + CAM_FUNCDATA_JUMP3( + 0xFFC4, 150, 250, -18, 18, 5, 60, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_2 | JUMP3_FLAG_0)), +}; + +CameraModeValue sSetPinnacleRockModeStillData[] = { + CAM_FUNCDATA_NORM1(-40, 250, 350, 30, 100, 100, 100, 60, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetPinnacleRockModeGoronDashData[] = { + CAM_FUNCDATA_JUMP3(-40, 250, 280, 5, 0x0011, 5, 40, 75, 35, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_3 | JUMP3_FLAG_2)), +}; + +/*===================================================================== + * Custom Data: NORMAL2 Setting + *===================================================================== + */ + +CameraModeValue sSetNormal2ModeNormalData[] = { + CAM_FUNCDATA_NORM1(-10, 350, 400, 14, 25, 14, 60, 65, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal2ModeTargetData[] = { + CAM_FUNCDATA_PARA1(0, 350, 80, 0, 0, 5, 5, 50, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 60, 0), +}; + +CameraModeValue sSetNormal2ModeJumpData[] = { + CAM_FUNCDATA_NORM1(-10, 350, 0x01A4, 10, 30, 10, 40, 65, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetNormal2ModeStillData[] = { + CAM_FUNCDATA_NORM1(-10, 350, 400, 14, 100, 100, 100, 65, 16, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: BOMBBOWL Setting + *===================================================================== + */ + +CameraModeValue D_801B6C98[] = { + CAM_FUNCDATA_NORM1(-30, 300, 320, 15, 0x0016, 12, 30, 55, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B6CC0[] = { + CAM_FUNCDATA_KEEP1(-30, 180, 200, 20, 30, -5, 10, 40, 45, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 30), +}; + +CameraModeValue D_801B6CF0[] = { + CAM_FUNCDATA_KEEP3( + -30, 65, 70, 10, 10, 5, 5, 20, 45, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, KEEPON3_FLAG_5), 50), +}; + +CameraModeValue D_801B6D24[] = { + CAM_FUNCDATA_NORM1(-20, 300, 320, 10, 30, 12, 40, 55, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B6D4C[] = { + CAM_FUNCDATA_NORM1(-30, 300, 320, 15, 100, 100, 100, 55, 25, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: CIRCA Setting + *===================================================================== + */ + +CameraModeValue D_801B6D74[] = { + CAM_FUNCDATA_FIXD2(-40, 60, 0x3200, 100, 20, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, + FIXED2_FLAG_3 | FIXED2_FLAG_1 | FIXED2_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: WHIRLPOOL Setting + *===================================================================== + */ + +CameraModeValue sSetWhirlpoolModeNormalData[] = { + CAM_FUNCDATA_JUMP3( + -10, 280, 350, 50, 12, 5, 30, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_5 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetWhirlpoolModeFreeFallData[] = { + CAM_FUNCDATA_JUMP3(0, 180, 300, 30, 12, 5, 25, 75, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_4 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetWhirlpoolModeGoronJumpData[] = { + CAM_FUNCDATA_JUMP3( + -40, 320, 350, -5, 12, 5, 25, 65, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_4 | JUMP3_FLAG_3 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetWhirlpoolModeDekuFlyData[] = { + CAM_FUNCDATA_JUMP3( + -40, 300, 350, 10, 15, 5, 30, 65, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_5 | JUMP3_FLAG_2 | JUMP3_FLAG_0)), +}; + +CameraModeValue sSetWhirlpoolModeDekuHideData[] = { + CAM_FUNCDATA_JUMP3( + 0xFFC4, 150, 250, -18, 15, 5, 30, 60, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_4 | JUMP3_FLAG_2)), +}; + +CameraModeValue sSetWhirlpoolModeGoronDashData[] = { + CAM_FUNCDATA_JUMP3( + -40, 220, 260, 5, 8, 5, 20, 75, 35, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_4 | JUMP3_FLAG_3 | JUMP3_FLAG_2)), +}; + +/*===================================================================== + * Custom Data: CUCCO_SHACK Setting + *===================================================================== + */ + +CameraModeValue sSetCuccoShackModeNormalData[] = { + CAM_FUNCDATA_NORM1(0xFFBA, 250, 0x01F4, 5, 30, 12, 45, 50, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetCuccoShackModeStillData[] = { + CAM_FUNCDATA_NORM1(-40, 250, 0x01F4, 5, 100, 100, 100, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetCuccoShackModeDekuHideData[] = { + CAM_FUNCDATA_NORM1(-40, 250, 0x01F4, 5, 25, 12, 40, 50, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: GIANT Setting + *===================================================================== + */ + +CameraModeValue sSetGiantModeNormalData[] = { + CAM_FUNCDATA_NORM1(-40, 150, 160, -15, 25, 14, 50, 50, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetGiantModeTargetData[] = { + CAM_FUNCDATA_PARA1(-40, 180, 80, 0, 0, 5, 5, 50, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 60, 0), +}; + +CameraModeValue sSetGiantModeJumpData[] = { + CAM_FUNCDATA_NORM1(-10, 100, 150, 10, 30, 10, 40, 70, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetGiantModeStillData[] = { + CAM_FUNCDATA_NORM1(-40, 150, 160, 0xFFF4, 25, 14, 50, 50, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/*===================================================================== + * Custom Data: SCENE0 Setting + *===================================================================== + */ + +CameraModeValue D_801B6FA0[] = { + CAM_FUNCDATA_UNIQ2(-40, 20, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + UNIQUE2_FLAG_5 | UNIQUE2_FLAG_4 | UNIQUE2_FLAG_1)), +}; + +/*===================================================================== + * Custom Data: ROOM1 Setting + *===================================================================== + */ + +CameraModeValue D_801B6FB0[] = { + CAM_FUNCDATA_NORM1(-15, 120, 250, 16, 16, 5, 65, 60, 75, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B6FD8[] = { + CAM_FUNCDATA_KEEP1(-20, 100, 150, 0, 4, 20, 10, 40, 60, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_0), 20), +}; + +CameraModeValue D_801B7008[] = { + CAM_FUNCDATA_BATT1(-25, 100, 180, 10, 40, 10, 0, 40, 60, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_1), 20, 50), +}; + +CameraModeValue D_801B703C[] = { + CAM_FUNCDATA_NORM1(-15, 120, 250, 16, 12, 5, 60, 70, 40, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B7064[] = { + CAM_FUNCDATA_NORM1(-15, 120, 250, 16, 100, 100, 100, 70, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_5 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue D_801B708C[] = { + CAM_FUNCDATA_PARA1( + 0, 200, 5, 30, 0, 5, 5, 70, 30, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_5 | PARALLEL1_FLAG_1), 80, 0), +}; + +/*===================================================================== + * Custom Data: WATER2 Setting + *===================================================================== + */ + +CameraModeValue D_801B70BC[] = { + CAM_FUNCDATA_JUMP3(-10, 270, 300, 20, 30, 20, 65, 60, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_7 | JUMP3_FLAG_2)), +}; + +CameraModeValue D_801B70E4[] = { + CAM_FUNCDATA_PARA1( + -30, 280, 40, 10, 0, 15, 5, 60, 100, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1 | PARALLEL1_FLAG_0), 60, 0), +}; + +CameraModeValue D_801B7114[] = { + CAM_FUNCDATA_KEEP3(-20, 50, 100, 50, 5, 20, 10, 40, 45, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, 0), + 60), +}; + +CameraModeValue D_801B7148[] = { + CAM_FUNCDATA_JUMP3(-40, 180, 200, 5, 20, 5, 40, 75, 35, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, JUMP3_FLAG_3 | JUMP3_FLAG_2)), +}; + +/*===================================================================== + * Custom Data: FORCEKEEP Setting + *===================================================================== + */ + +CameraModeValue D_801B7170[] = { + CAM_FUNCDATA_KEEP1( + -30, 180, 200, 20, 40, -5, 10, 15, 45, 60, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, KEEPON1_FLAG_4 | KEEPON1_FLAG_0), 30), +}; + +CameraModeValue D_801B71A0[] = { + CAM_FUNCDATA_BATT1( + -30, 150, 250, 10, 60, -5, 20, 35, 55, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, BATTLE1_FLAG_4 | BATTLE1_FLAG_1), 25, 40), +}; + +/*===================================================================== + * Custom Data: PARALLEL1 Setting + *===================================================================== + */ + +CameraModeValue D_801B71D4[] = { + CAM_FUNCDATA_PARA1( + 0, 400, 20, 20, 0, 20, 5, 70, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_3 | PARALLEL1_FLAG_1), 80, 0), +}; + +/*===================================================================== + * Custom Data: START1 Setting + *===================================================================== + */ + +CameraModeValue D_801B7204[] = { + CAM_FUNCDATA_UNIQ0(0, 100, CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, UNIQUE0_FLAG_1)), +}; + +/*===================================================================== + * Custom Data: ROOM2 Setting + *===================================================================== + */ + +CameraModeValue D_801B7210[] = { + CAM_FUNCDATA_KEEP3( + -10, 120, 180, 50, 5, 10, 5, 70, 35, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, KEEPON3_FLAG_5), 60), +}; + +/*===================================================================== + * Custom Data: NORMAL4 Setting + *===================================================================== + */ + +CameraModeValue sSetNormal4ModeTalkData[] = { + CAM_FUNCDATA_KEEP3( + -20, 0x006E, 160, 80, 15, 10, 0, 70, 40, 50, 20, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_LARGE, CAM_HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE, KEEPON3_FLAG_5), 50), +}; + +/*===================================================================== + * Custom Data: ELEGY_SHELL Setting + *===================================================================== + */ + +CameraModeValue sSetElegyShellModeNormalData[] = { + CAM_FUNCDATA_KEEP4(-45, 150, -10, 165, 5, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 30), +}; + +CameraModeValue sSetElegyShellModeJumpData[] = { + CAM_FUNCDATA_KEEP4(-40, 150, 18, 140, 5, 70, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 30), +}; + +CameraModeValue sSetElegyShellModeDekuShootData[] = { + CAM_FUNCDATA_KEEP4(-20, 150, -2, 140, 15, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 30), +}; + +CameraModeValue sSetElegyShellModeGoronDashData[] = { + CAM_FUNCDATA_KEEP4(-50, 150, 0xFFF4, 160, 6, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_1), 25, 30), +}; + +CameraModeValue sSetElegyShellModeDekuFlyData[] = { + CAM_FUNCDATA_KEEP4( + 0xFFC4, 150, 0xFFF4, 0xFF74, 30, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_IGNORE, KEEPON4_FLAG_3 | KEEPON4_FLAG_2), 25, 30), +}; + +/*===================================================================== + * Custom Data: DUNGEON4 Setting + *===================================================================== + */ + +CameraModeValue sSetDungeon4ModeNormalData[] = { + CAM_FUNCDATA_NORM1(0, 150, 250, -5, 16, 5, 0x0034, 55, 80, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon4ModeTargetData[] = { + CAM_FUNCDATA_PARA1(0, 200, 25, 5, 0, 5, 5, 45, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_MEDIUM, CAM_HUD_VISIBILITY_ALL, PARALLEL1_FLAG_1), 80, 0), +}; + +CameraModeValue sSetDungeon4ModeJumpData[] = { + CAM_FUNCDATA_NORM1(0, 150, 250, 0, 24, 5, 50, 55, 50, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_NONE, CAM_HUD_VISIBILITY_ALL, + NORMAL1_FLAG_7 | NORMAL1_FLAG_3 | NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +CameraModeValue sSetDungeon4ModeStillData[] = { + CAM_FUNCDATA_NORM1( + 0, 180, 220, 5, 100, 100, 100, 55, 10, + CAM_INTERFACE_FLAGS(CAM_LETTERBOX_IGNORE, CAM_HUD_VISIBILITY_ALL, NORMAL1_FLAG_1 | NORMAL1_FLAG_0)), +}; + +/** + * ===================================================================== + * CAMERA SETTINGS: USAGE OF FUNCTIONS AND DATA FOR SPECIFIC MODES + * ===================================================================== + */ + +#define CAM_SETTING_MODE_ENTRY(func, data) \ + { func, ARRAY_COUNT(data), data } + +#define CAM_SETTING_MODE_NULL \ + { CAM_FUNC_NONE, 0, NULL } + +CameraMode sCamSetNormal0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronJumpData), // CAM_MODE_GORONJUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBoomerangData), // CAM_MODE_BOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeZData), // CAM_MODE_CHARGEZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_ZORAFINZ +}; + +CameraMode sCamSetNormal3Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal3ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_NULL, // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal3ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLYZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeGoronJumpData), // CAM_MODE_GORONJUMP +}; + +CameraMode sCamSetPivotDivingModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE2, sSetPivotDivingModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_NULL, // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_NULL, // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE2, sSetPivotDivingModeTargetData), // CAM_MODE_TARGET +}; + +CameraMode sCamSetHorseModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL3, sSetHorseModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL3, sSetHorseModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_NULL, // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_NULL, // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetHorseModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL3, sSetHorseModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetHorseModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetHorseModeSlingShotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetHorseModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetHorseModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL3, sSetHorseModeStillData), // CAM_MODE_STILL +}; + +CameraMode sCamSetZoraDivingModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL3, sSetZoraDivingModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetPreRendFixedModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED3, sSetPrerendFixedModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetPreRendPivotModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE7, sSetPrerendPivotModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetDoorCModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL9, sSetDoorCModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetDemo0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_DEMO1, D_801B4EF0), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetFree0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE6, sSetCutscenesModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetFukan0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B4EF8), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B4F50), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B4F20), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B4F78), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B4EF8), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetNormal1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal1ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal1ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetNanameModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL4, D_801B4FF0), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetCirc0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5018), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5034), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5050), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT +}; + +CameraMode sCamSetFixed0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED1, D_801B506C), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT +}; + +CameraMode sCamSetSpiralDoorModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL8, sSetSpiralDoorModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetDungeon0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon0ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetDungeon0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronJumpData), // CAM_MODE_GORONJUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBoomerangData), // CAM_MODE_BOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeZData), // CAM_MODE_CHARGEZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_ZORAFINZ +}; + +CameraMode sCamSetItem0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5338), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B535C), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B53A4), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5380), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B53C8), // CAM_MODE_DEKUFLY +}; + +CameraMode sCamSetItem1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B53EC), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5410), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5458), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5434), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B547C), // CAM_MODE_DEKUFLY +}; + +CameraMode sCamSetItem2Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B54A0), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B54C4), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B550C), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B54E8), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5530), // CAM_MODE_DEKUFLY +}; + +CameraMode sCamSetItem3Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5554), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5578), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B55C0), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B559C), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B55E4), // CAM_MODE_DEKUFLY +}; + +CameraMode sCamSetNaviModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE6, sSetCutscenesModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetWarp0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5608), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B562C), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5674), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5650), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5698), // CAM_MODE_DEKUFLY +}; + +CameraMode sCamSetDeathModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetDeathModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetDeathModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetDeathModeJumpData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetDeathModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetDeathModeJumpData), // CAM_MODE_DEKUFLY +}; + +CameraMode sCamSetRebirthModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5728), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5728), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5728), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B574C), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, D_801B5728), // CAM_MODE_DEKUFLY +}; + +CameraMode sCamSetLongChestOpeningModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_DEMO2, sSetLongChestOpeningModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetMaskTransformationModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_DEMO4, sSetCutscenesModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_DEMO5, sSetCutscenesModeNormalData), // CAM_MODE_JUMP +}; + +CameraMode sCamSetAttentionModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_DEMO1, sSetCutscenesModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetWarp1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_DEMO3, sSetCutscenesModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetDungeon1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon1ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon1ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetDungeon0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon1ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon1ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetFixed1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED1, D_801B5824), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetFixed2Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED1, D_801B5834), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetMazeModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL2, sSetMazeModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetRemoteBombModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL2, sSetRemoteBombModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetCirc1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5884), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetCirc2Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B58A0), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetCirc3Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B58BC), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5034), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5050), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT +}; + +CameraMode sCamSetCirc4Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B58D8), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetFixed3Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED1, D_801B58F4), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT +}; + +CameraMode sCamSetTowerClimbModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL0, sSetTowerClimbModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetTowerClimbModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetTowerClimbModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetParallel0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B5978), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetNormDModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B59A8), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetSubjectDModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, D_801B59D0), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetStart0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE0, D_801B59F4), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetStart2Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE0, D_801B5A00), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetStop0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE6, sSetCutscenesModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetBoatCruiseModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetBoatCruiseModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_NULL, // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW +}; + +CameraMode sCamSetVerticalClimbModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetVerticalClimbModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetVerticalClimbModeClimbData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetSidedModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B5A64), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetDungeon2Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon2ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon2ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetDungeon2ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon2ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon2ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetBossOdolwaModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossOdolwaModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossOdolwaModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetBossOdolwaModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetBossOdolwaModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetBossOdolwaModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossOdolwaModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetKeepBackModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B5C80), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetVerticalClimbModeClimbData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetCirc6Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5CB0), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetCirc7Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5CCC), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetMiniBossModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetMiniBossModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetMiniBossModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetMiniBossModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetMiniBossModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetMiniBossModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetRFixed1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED1, D_801B5DC4), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetTreasureChestMinigameModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetTreasureChestMinigameModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_NULL, // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_NULL, // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetTreasureChestMinigameModeTargetData), // CAM_MODE_TARGET +}; + +CameraMode sCamSetBombBasketModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5E2C), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetCirc8Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5E48), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetFukan1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B5E64), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B4F50), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B4F20), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B5E8C), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B4EF8), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetDungeon3Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon3ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon3ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon3ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetDungeon0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon3ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon3ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetTelescopeModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetTelescopeModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetTelescopeModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_NULL, // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_NULL, // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetTelescopeModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TALK + CAM_SETTING_MODE_NULL, // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROW + CAM_SETTING_MODE_NULL, // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetTelescopeModeDekuHideData), // CAM_MODE_DEKUHIDE +}; + +CameraMode sCamSetRoom0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B601C), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6154), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B62F4), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B634C), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B62C4), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B6074), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B6044), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, D_801B60A4), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, D_801B60D8), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B631C), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B626C), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B620C), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, D_801B610C), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, D_801B6130), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B61DC), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B617C), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B61AC), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B6294), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B6374), // CAM_MODE_DEKUFLYZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B63A4), // CAM_MODE_GORONJUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBoomerangData), // CAM_MODE_BOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B623C), // CAM_MODE_CHARGEZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B63CC), // CAM_MODE_ZORAFINZ +}; + +CameraMode sCamSetRCirc0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B63FC), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetCirc9Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B6418), // CAM_MODE_NORMAL + CAM_SETTING_MODE_NULL, // CAM_MODE_JUMP + CAM_SETTING_MODE_NULL, // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5034), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_NULL, // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B5050), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT +}; + +CameraMode sCamSetOnThePoleModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6434), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B648C), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B645C), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetDungeon0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B655C), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, D_801B64B4), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, D_801B64D8), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B64FC), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B652C), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon1ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetInBushModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6584), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6698), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, D_801B6674), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B65DC), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B65AC), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, D_801B660C), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, D_801B6640), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B66C0), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B4EF8), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetBossMajoraModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossMajoraModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossMajoraModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetBossMajoraModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetBossMajoraModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossMajoraModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetBossTwinmoldModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossTwinmoldModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossTwinmoldModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetBossTwinmoldModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetBossTwinmoldModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetBossTwinmoldModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossTwinmoldModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetBossGohtModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossGohtModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossGohtModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossGohtModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetBossGohtModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossGohtModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetBossGyorgModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetBossGyorgModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetBossGyorgModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetBossGyorgModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_NULL, // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetBossGyorgModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetBossGyorgModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetBossGyorgModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLYZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetBossGyorgModeGoronJumpData), // CAM_MODE_GORONJUMP +}; + +CameraMode sCamSetConnect0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_DEMO0, sSetCutscenesModeNormalData), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetPinnacleRockModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetPinnacleRockModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetPinnacleRockModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetPinnacleRockModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetPinnacleRockModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_NULL, // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetPinnacleRockModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetPinnacleRockModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLYZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetPinnacleRockModeGoronJumpData), // CAM_MODE_GORONJUMP +}; + +CameraMode sCamSetNormal2Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal2ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal2ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal2ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal2ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetBombBowlModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6C98), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6D24), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B62F4), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B634C), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B62C4), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B6CC0), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B6044), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, D_801B6CF0), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, D_801B60D8), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B631C), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6D4C), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B620C), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, D_801B610C), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, D_801B6130), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B61DC), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B617C), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B61AC), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B6294), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B6374), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetCircAModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_FIXED2, D_801B6D74), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetWhirlpoolModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetWhirlpoolModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetWhirlpoolModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetWhirlpoolModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetPinnacleRockModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_NULL, // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetWhirlpoolModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetWhirlpoolModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLYZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetWhirlpoolModeGoronJumpData), // CAM_MODE_GORONJUMP +}; + +CameraMode sCamSetCuccoShackModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetCuccoShackModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal2ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal2ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetCuccoShackModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetCuccoShackModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL +}; + +CameraMode sCamSetGiantModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetGiantModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetGiantModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetGiantModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetGiantModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetScene0Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE2, D_801B6FA0), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetRoom1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6FB0), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B703C), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B62C4), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B6FD8), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, D_801B60A4), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, D_801B7008), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B7064), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B708C), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetWater2Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, D_801B70BC), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, D_801B7148), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B70E4), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, D_801B7114), // CAM_MODE_TALK + CAM_SETTING_MODE_NULL, // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal3ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_NULL, // CAM_MODE_DEKUFLYZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP3, sSetNormal3ModeGoronJumpData), // CAM_MODE_GORONJUMP +}; + +CameraMode sCamSetWoodfallSwampModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE3, D_801B6584), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE3, D_801B6698), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE3, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE3, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, D_801B6674), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B65DC), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE4, D_801B65AC), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, D_801B660C), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE5, D_801B6640), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE4, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE3, D_801B66C0), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE4, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE4, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE4, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE4, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE3, D_801B6584), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE4, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetForceKeepModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B7170), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, D_801B71A0), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetParallel1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B71D4), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetStart1Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_UNIQUE0, D_801B7204), // CAM_MODE_NORMAL +}; + +CameraMode sCamSetRoom2Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B6FB0), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B703C), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B62C4), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, D_801B6FD8), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, D_801B7210), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, D_801B7008), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, D_801B7064), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, D_801B708C), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetNorm4Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetNormal0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal4ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetNormal0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetNormal0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraMode sCamSetElegyShellModes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetElegyShellModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetElegyShellModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetElegyShellModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetElegyShellModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_NULL, // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON4, sSetElegyShellModeDekuFlyData), // CAM_MODE_DEKUFLY +}; + +CameraMode sCamSetDungeon4Modes[] = { + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon4ModeNormalData), // CAM_MODE_NORMAL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon4ModeJumpData), // CAM_MODE_JUMP + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeGoronDashData), // CAM_MODE_GORONDASH + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeDekuShootData), // CAM_MODE_DEKUSHOOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowZData), // CAM_MODE_BOWARROWZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetNormal0ModeDekuFlyData), // CAM_MODE_DEKUFLY + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeFirstPersonData), // CAM_MODE_FIRSTPERSON + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowBoomerangData), // CAM_MODE_FOLLOWBOOMERANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeZoraFinData), // CAM_MODE_ZORAFIN + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON1, sSetDungeon0ModeFollowTargetData), // CAM_MODE_FOLLOWTARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon4ModeTargetData), // CAM_MODE_TARGET + CAM_SETTING_MODE_ENTRY(CAM_FUNC_KEEPON3, sSetNormal0ModeTalkData), // CAM_MODE_TALK + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeSlingshotData), // CAM_MODE_SLINGSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SUBJECT1, sSetNormal0ModeBowArrowData), // CAM_MODE_BOWARROW + CAM_SETTING_MODE_ENTRY(CAM_FUNC_BATTLE1, sSetDungeon0ModeBattleData), // CAM_MODE_BATTLE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuHideData), // CAM_MODE_DEKUHIDE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_NORMAL1, sSetDungeon4ModeStillData), // CAM_MODE_STILL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeChargeData), // CAM_MODE_CHARGE + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbData), // CAM_MODE_CLIMB + CAM_SETTING_MODE_ENTRY(CAM_FUNC_JUMP2, sSetDungeon0ModeClimbZData), // CAM_MODE_CLIMBZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_SPECIAL5, sSetNormal0ModeHookshotData), // CAM_MODE_HOOKSHOT + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeFreeFallData), // CAM_MODE_FREEFALL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangData), // CAM_MODE_HANG + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModeHangZData), // CAM_MODE_HANGZ + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetDungeon0ModePushPullData), // CAM_MODE_PUSHPULL + CAM_SETTING_MODE_ENTRY(CAM_FUNC_PARALLEL1, sSetNormal0ModeDekuFlyZData), // CAM_MODE_DEKUFLYZ +}; + +CameraSetting sCameraSettings[] = { + { 0x00000000, 0x00000000, NULL }, // CAM_SET_NONE + { 0x3FFFFFFF, 0x00000005, sCamSetNormal0Modes }, // CAM_SET_NORMAL0 + { 0x05FFEFF7, 0x00000005, sCamSetNormal3Modes }, // CAM_SET_NORMAL3 + { 0x00000401, 0x00000005, sCamSetPivotDivingModes }, // CAM_SET_PIVOT_DIVING + { 0x00017E13, 0x80000005, sCamSetHorseModes }, // CAM_SET_HORSE + { 0x00000001, 0x80000005, sCamSetZoraDivingModes }, // CAM_SET_ZORA_DIVING + { 0x00000001, 0x8000000C, sCamSetPreRendFixedModes }, // CAM_SET_PREREND_FIXED + { 0x00000001, 0x8000000C, sCamSetPreRendPivotModes }, // CAM_SET_PREREND_PIVOT + { 0x00000001, 0xC0000007, sCamSetDoorCModes }, // CAM_SET_DOORC + { 0x00000001, 0xC000000E, sCamSetDemo0Modes }, // CAM_SET_DEMO0 + { 0x00000001, 0x80000005, sCamSetFree0Modes }, // CAM_SET_FREE0 + { 0x03FFFFFF, 0x00000005, sCamSetFukan0Modes }, // CAM_SET_BIRDS_EYE_VIEW_0 + { 0x03FFFFFF, 0x00000005, sCamSetNormal1Modes }, // CAM_SET_NORMAL1 + { 0x03FFFFFF, 0x80000005, sCamSetNanameModes }, // CAM_SET_NANAME + { 0x00001BD9, 0x80000005, sCamSetCirc0Modes }, // CAM_SET_CIRCLE0 + { 0x000011D9, 0x80000005, sCamSetFixed0Modes }, // CAM_SET_FIXED0 + { 0x00000001, 0x40000005, sCamSetSpiralDoorModes }, // CAM_SET_SPIRAL_DOOR + { 0x3FFFFFFF, 0x00000005, sCamSetDungeon0Modes }, // CAM_SET_DUNGEON0 + { 0x0000002F, 0x00000005, sCamSetItem0Modes }, // CAM_SET_ITEM0 + { 0x0000002F, 0x00000005, sCamSetItem1Modes }, // CAM_SET_ITEM1 + { 0x0000002F, 0x00000005, sCamSetItem2Modes }, // CAM_SET_ITEM2 + { 0x0000002F, 0x00000005, sCamSetItem3Modes }, // CAM_SET_ITEM3 + { 0x00000001, 0x00000005, sCamSetNaviModes }, // CAM_SET_NAVI + { 0x0000002F, 0x00000005, sCamSetWarp0Modes }, // CAM_SET_WARP_PAD_MOON + { 0x0000002F, 0x00000005, sCamSetDeathModes }, // CAM_SET_DEATH + { 0x0000002F, 0x00000005, sCamSetRebirthModes }, // CAM_SET_REBIRTH + { 0x00000001, 0x40000005, sCamSetLongChestOpeningModes }, // CAM_SET_LONG_CHEST_OPENING + { 0x00000003, 0x00000005, sCamSetMaskTransformationModes }, // CAM_SET_MASK_TRANSFORMATION + { 0x00000001, 0x00000005, sCamSetAttentionModes }, // CAM_SET_ATTENTION + { 0x00000001, 0x00000005, sCamSetWarp1Modes }, // CAM_SET_WARP_PAD_ENTRANCE + { 0x03FFFFFF, 0x00000005, sCamSetDungeon1Modes }, // CAM_SET_DUNGEON1 + { 0x00000001, 0x80000005, sCamSetFixed1Modes }, // CAM_SET_FIXED1 + { 0x00000001, 0x80000005, sCamSetFixed2Modes }, // CAM_SET_FIXED2 + { 0x00000001, 0x00000005, sCamSetMazeModes }, // CAM_SET_MAZE + { 0x00000001, 0x00000005, sCamSetRemoteBombModes }, // CAM_SET_REMOTEBOMB + { 0x00000001, 0x80000005, sCamSetCirc1Modes }, // CAM_SET_CIRCLE1 + { 0x00000001, 0x80000005, sCamSetCirc2Modes }, // CAM_SET_CIRCLE2 + { 0x00001BD9, 0x80000005, sCamSetCirc3Modes }, // CAM_SET_CIRCLE3 + { 0x00000001, 0x80000005, sCamSetCirc4Modes }, // CAM_SET_CIRCLE4 + { 0x000011D9, 0x80000005, sCamSetFixed3Modes }, // CAM_SET_FIXED3 + { 0x03FFFFFF, 0x80000005, sCamSetTowerClimbModes }, // CAM_SET_TOWER_ASCENT + { 0x00000001, 0x80000005, sCamSetParallel0Modes }, // CAM_SET_PARALLEL0 + { 0x00000001, 0x00000005, sCamSetNormDModes }, // CAM_SET_NORMALD + { 0x00000001, 0x00000005, sCamSetSubjectDModes }, // CAM_SET_SUBJECTD + { 0x00000001, 0xC0000008, sCamSetStart0Modes }, // CAM_SET_START0 + { 0x00000001, 0xC0000008, sCamSetStart2Modes }, // CAM_SET_START2 + { 0x00000001, 0x00000005, sCamSetStop0Modes }, // CAM_SET_STOP0 + { 0x00003051, 0x00000005, sCamSetBoatCruiseModes }, // CAM_SET_BOAT_CRUISE + { 0x03FFFFFF, 0x00000005, sCamSetVerticalClimbModes }, // CAM_SET_VERTICAL_CLIMB + { 0x00000001, 0x00000005, sCamSetSidedModes }, // CAM_SET_SIDED + { 0x03FFFFFF, 0x00000005, sCamSetDungeon2Modes }, // CAM_SET_DUNGEON2 + { 0x03FFFFFF, 0x00000005, sCamSetBossOdolwaModes }, // CAM_SET_BOSS_ODOLWA + { 0x03FFFFFF, 0x80000005, sCamSetKeepBackModes }, // CAM_SET_KEEPBACK + { 0x00000001, 0x80000005, sCamSetCirc6Modes }, // CAM_SET_CIRCLE6 + { 0x00000001, 0x80000005, sCamSetCirc7Modes }, // CAM_SET_CIRCLE7 + { 0x03FFFFFF, 0x00000005, sCamSetMiniBossModes }, // CAM_SET_MINI_BOSS + { 0x00000001, 0x80000005, sCamSetRFixed1Modes }, // CAM_SET_RFIXED1 + { 0x00000401, 0x00000005, sCamSetTreasureChestMinigameModes }, // CAM_SET_TREASURE_CHEST_MINIGAME + { 0x00000001, 0x80000005, sCamSetBombBasketModes }, // CAM_SET_HONEY_AND_DARLING_1 + { 0x00000001, 0x80000005, sCamSetCirc8Modes }, // CAM_SET_CIRCLE8 + { 0x03FFFFFF, 0x00000005, sCamSetFukan1Modes }, // CAM_SET_BIRDS_EYE_VIEW_1 + { 0x03FFFFFF, 0x00000005, sCamSetDungeon3Modes }, // CAM_SET_DUNGEON3 + { 0x00008441, 0x0000000A, sCamSetTelescopeModes }, // CAM_SET_TELESCOPE + { 0x3FFFFFFF, 0x00000005, sCamSetRoom0Modes }, // CAM_SET_ROOM0 + { 0x00000001, 0x80000005, sCamSetRCirc0Modes }, // CAM_SET_RCIRC0 + { 0x00001BD9, 0x80000005, sCamSetCirc9Modes }, // CAM_SET_CIRCLE9 + { 0x03FFFFFF, 0x00000005, sCamSetOnThePoleModes }, // CAM_SET_ONTHEPOLE + { 0x03FFFFFF, 0x00000005, sCamSetInBushModes }, // CAM_SET_INBUSH + { 0x03FFFFFF, 0x00000005, sCamSetBossMajoraModes }, // CAM_SET_BOSS_MAJORA + { 0x03FFFFFF, 0x00000005, sCamSetBossTwinmoldModes }, // CAM_SET_BOSS_TWINMOLD + { 0x03FFFFFF, 0x00000005, sCamSetBossGohtModes }, // CAM_SET_BOSS_GOHT + { 0x05FFEFF7, 0x00000005, sCamSetBossGyorgModes }, // CAM_SET_BOSS_GYORG + { 0x00000001, 0x00000005, sCamSetConnect0Modes }, // CAM_SET_CONNECT0 + { 0x05FFEFF7, 0x00000005, sCamSetPinnacleRockModes }, // CAM_SET_PINNACLE_ROCK + { 0x03FFFFFF, 0x00000005, sCamSetNormal2Modes }, // CAM_SET_NORMAL2 + { 0x03FFFFFF, 0x00000005, sCamSetBombBowlModes }, // CAM_SET_HONEY_AND_DARLING_2 + { 0x00000001, 0x80000005, sCamSetCircAModes }, // CAM_SET_CIRCLEA + { 0x05FFEFF7, 0x00000005, sCamSetWhirlpoolModes }, // CAM_SET_WHIRLPOOL + { 0x01FFFFDF, 0x00000005, sCamSetCuccoShackModes }, // CAM_SET_CUCCO_SHACK + { 0x03FFFFFF, 0x00000005, sCamSetGiantModes }, // CAM_SET_GIANT + { 0x00000001, 0x00000008, sCamSetScene0Modes }, // CAM_SET_SCENE0 + { 0x03FFFFFF, 0x00000005, sCamSetRoom1Modes }, // CAM_SET_ROOM1 + { 0x05FFEFF7, 0x00000005, sCamSetWater2Modes }, // CAM_SET_WATER2 + { 0x03FFFFFF, 0x00000005, sCamSetWoodfallSwampModes }, // CAM_SET_WOODFALL_SWAMP + { 0x03FFFFFF, 0x00000005, sCamSetForceKeepModes }, // CAM_SET_FORCEKEEP + { 0x03FFFFFF, 0x80000005, sCamSetParallel1Modes }, // CAM_SET_PARALLEL1 + { 0x00000001, 0xC0000008, sCamSetStart1Modes }, // CAM_SET_START1 + { 0x03FFFFFF, 0x00000005, sCamSetRoom2Modes }, // CAM_SET_ROOM2 + { 0x03FFFFFF, 0x00000005, sCamSetNorm4Modes }, // CAM_SET_NORMAL4 + { 0x0000002F, 0x00000005, sCamSetElegyShellModes }, // CAM_SET_ELEGY_SHELL + { 0x03FFFFFF, 0x00000005, sCamSetDungeon4Modes }, // CAM_SET_DUNGEON4 +}; + +s16 sGlobalCamDataSettings[] = { + /* -25 */ CAM_SET_ELEGY_SHELL, + /* -24 */ CAM_SET_SIDED, + /* -23 */ CAM_SET_BOAT_CRUISE, + /* -22 */ CAM_SET_NONE, + /* -21 */ CAM_SET_SUBJECTD, + /* -20 */ CAM_SET_NORMALD, + /* -19 */ CAM_SET_NONE, + /* -18 */ CAM_SET_NONE, + /* -17 */ CAM_SET_NONE, + /* -16 */ CAM_SET_WARP_PAD_ENTRANCE, + /* -15 */ CAM_SET_ATTENTION, + /* -14 */ CAM_SET_CONNECT0, + /* -13 */ CAM_SET_REMOTEBOMB, + /* -12 */ CAM_SET_NONE, + /* -11 */ CAM_SET_MASK_TRANSFORMATION, + /* -10 */ CAM_SET_LONG_CHEST_OPENING, + /* -9 */ CAM_SET_REBIRTH, + /* -8 */ CAM_SET_DEATH, + /* -7 */ CAM_SET_WARP_PAD_MOON, + /* -6 */ CAM_SET_NAVI, + /* -5 */ CAM_SET_ITEM3, + /* -4 */ CAM_SET_ITEM2, + /* -3 */ CAM_SET_ITEM1, + /* -2 */ CAM_SET_ITEM0, + /* -1 */ CAM_SET_STOP0, + /* 0 */ CAM_SET_NONE, +}; + +s16* sGlobalCamDataSettingsPtr = &sGlobalCamDataSettings[ARRAY_COUNT(sGlobalCamDataSettings) - 1]; + +s32 Camera_Noop(Camera* camera); +s32 Camera_Normal1(Camera* camera); +s32 Camera_Normal2(Camera* camera); +s32 Camera_Normal3(Camera* camera); +s32 Camera_Normal4(Camera* camera); +s32 Camera_Normal0(Camera* camera); +s32 Camera_Parallel1(Camera* camera); +s32 Camera_Parallel2(Camera* camera); +s32 Camera_Parallel3(Camera* camera); +s32 Camera_Parallel4(Camera* camera); +s32 Camera_Parallel0(Camera* camera); +s32 Camera_Jump1(Camera* camera); +s32 Camera_Jump2(Camera* camera); +s32 Camera_Jump3(Camera* camera); +s32 Camera_Jump4(Camera* camera); +s32 Camera_Jump0(Camera* camera); +s32 Camera_Battle1(Camera* camera); +s32 Camera_Battle2(Camera* camera); +s32 Camera_Battle3(Camera* camera); +s32 Camera_Battle4(Camera* camera); +s32 Camera_Battle0(Camera* camera); +s32 Camera_KeepOn1(Camera* camera); +s32 Camera_KeepOn2(Camera* camera); +s32 Camera_KeepOn3(Camera* camera); +s32 Camera_KeepOn4(Camera* camera); +s32 Camera_KeepOn0(Camera* camera); +s32 Camera_Fixed1(Camera* camera); +s32 Camera_Fixed2(Camera* camera); +s32 Camera_Fixed3(Camera* camera); +s32 Camera_Fixed4(Camera* camera); +s32 Camera_Fixed0(Camera* camera); +s32 Camera_Subject1(Camera* camera); +s32 Camera_Subject2(Camera* camera); +s32 Camera_Subject3(Camera* camera); +s32 Camera_Subject4(Camera* camera); +s32 Camera_Subject0(Camera* camera); +s32 Camera_Data0(Camera* camera); +s32 Camera_Data1(Camera* camera); +s32 Camera_Data2(Camera* camera); +s32 Camera_Data3(Camera* camera); +s32 Camera_Data4(Camera* camera); +s32 Camera_Unique1(Camera* camera); +s32 Camera_Unique2(Camera* camera); +s32 Camera_Unique3(Camera* camera); +s32 Camera_Unique4(Camera* camera); +s32 Camera_Unique5(Camera* camera); +s32 Camera_Unique0(Camera* camera); +s32 Camera_Unique6(Camera* camera); +s32 Camera_Unique7(Camera* camera); +s32 Camera_Unique8(Camera* camera); +s32 Camera_Unique9(Camera* camera); +s32 Camera_Demo1(Camera* camera); +s32 Camera_Demo2(Camera* camera); +s32 Camera_Demo3(Camera* camera); +s32 Camera_Demo4(Camera* camera); +s32 Camera_Demo5(Camera* camera); +s32 Camera_Demo6(Camera* camera); +s32 Camera_Demo7(Camera* camera); +s32 Camera_Demo8(Camera* camera); +s32 Camera_Demo9(Camera* camera); +s32 Camera_Demo0(Camera* camera); +s32 Camera_Special0(Camera* camera); +s32 Camera_Special1(Camera* camera); +s32 Camera_Special2(Camera* camera); +s32 Camera_Special3(Camera* camera); +s32 Camera_Special4(Camera* camera); +s32 Camera_Special5(Camera* camera); +s32 Camera_Special6(Camera* camera); +s32 Camera_Special7(Camera* camera); +s32 Camera_Special8(Camera* camera); +s32 Camera_Special9(Camera* camera); + +CameraUpdateFunc sCameraUpdateHandlers[] = { + NULL, + Camera_Normal0, + Camera_Normal1, + Camera_Normal2, + Camera_Normal3, + Camera_Normal4, + Camera_Parallel0, + Camera_Parallel1, + Camera_Parallel2, + Camera_Parallel3, + Camera_Parallel4, + Camera_KeepOn0, + Camera_KeepOn1, + Camera_KeepOn2, + Camera_KeepOn3, + Camera_KeepOn4, + Camera_Subject0, + Camera_Subject1, + Camera_Subject2, + Camera_Subject3, + Camera_Subject4, + Camera_Jump0, + Camera_Jump1, + Camera_Jump2, + Camera_Jump3, + Camera_Jump4, + Camera_Battle0, + Camera_Battle1, + Camera_Battle2, + Camera_Battle3, + Camera_Battle4, + Camera_Fixed0, + Camera_Fixed1, + Camera_Fixed2, + Camera_Fixed3, + Camera_Fixed4, + Camera_Data0, + Camera_Data1, + Camera_Data2, + Camera_Data3, + Camera_Data4, + Camera_Unique0, + Camera_Unique1, + Camera_Unique2, + Camera_Unique3, + Camera_Unique4, + Camera_Unique5, + Camera_Unique6, + Camera_Unique7, + Camera_Unique8, + Camera_Unique9, + Camera_Demo0, + Camera_Demo1, + Camera_Demo2, + Camera_Demo3, + Camera_Demo4, + Camera_Demo5, + Camera_Demo6, + Camera_Demo7, + Camera_Demo8, + Camera_Demo9, + Camera_Special0, + Camera_Special1, + Camera_Special2, + Camera_Special3, + Camera_Special4, + Camera_Special5, + Camera_Special6, + Camera_Special7, + Camera_Special8, + Camera_Special9, +}; + +s16 sCameraNextUID = 0; +s32 sCameraInterfaceFlags = 1; +s32 sCameraHudVisibility = 2; +s32 sCameraLetterboxSize = 32; +s32 sCameraNegOne = -1; + +// VecSph yaw data +s16 D_801B9E18[] = { + 0x0AAA, 0xF556, 0x1555, 0xEAAB, 0x2AAA, 0xD556, 0x3FFF, 0xC001, 0x5555, 0xAAAB, 0x6AAA, 0x9556, 0x7FFF, 0x0000, +}; + +// VecSph pitch data +s16 D_801B9E34[] = { + 0x0000, 0x02C6, 0x058C, 0x0000, 0x0000, 0xFD3A, 0x0000, 0x0852, 0x0000, 0x0000, 0x0B18, 0x02C6, 0xFA74, 0x0000, +}; + +s32 sUpdateCameraDirection = false; +static s32 sIsFalse = false; +s32 sCameraInitSceneTimer = 0; 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 7ac956e5d..0e36f1c54 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" Vec3f D_801EDE00; @@ -90,7 +91,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, }; @@ -99,14 +100,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; @@ -119,7 +120,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; @@ -130,7 +131,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; @@ -141,62 +142,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, @@ -206,36 +207,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; @@ -243,11 +244,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 }, @@ -259,56 +260,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; @@ -317,12 +317,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; @@ -336,13 +336,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; @@ -353,11 +353,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)); @@ -368,8 +368,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; } @@ -378,12 +378,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)); @@ -394,8 +394,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; } @@ -403,19 +403,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; @@ -424,24 +424,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; } @@ -449,14 +449,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; } @@ -464,30 +464,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; } @@ -495,20 +495,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; } @@ -516,80 +516,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 }, @@ -599,11 +596,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; @@ -624,44 +621,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; @@ -670,13 +667,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; @@ -691,13 +688,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; @@ -708,11 +705,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)); @@ -723,8 +720,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; @@ -733,19 +730,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; @@ -754,24 +751,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; } @@ -779,14 +776,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; } @@ -794,19 +791,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 }, @@ -818,11 +815,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; } @@ -836,7 +833,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]; @@ -849,83 +846,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; } @@ -933,7 +930,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; @@ -947,10 +944,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 { @@ -961,80 +958,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); @@ -1045,14 +1041,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; @@ -1061,16 +1057,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; } @@ -1079,18 +1075,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; @@ -1123,14 +1119,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; } @@ -1142,13 +1138,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; @@ -1170,11 +1166,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; @@ -1202,13 +1198,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; @@ -1230,11 +1226,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; @@ -1262,13 +1258,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; @@ -1290,11 +1286,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; @@ -1320,14 +1316,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; @@ -1372,7 +1368,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) { } /** @@ -1381,7 +1377,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; @@ -1427,7 +1423,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") @@ -1439,7 +1435,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; @@ -1484,7 +1480,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") @@ -1494,55 +1490,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 { @@ -1584,8 +1580,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; } @@ -1595,26 +1591,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 { @@ -1634,7 +1630,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; @@ -1684,7 +1680,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; @@ -1707,7 +1703,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; @@ -1748,8 +1744,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; @@ -1763,8 +1759,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; @@ -1803,8 +1798,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; } } @@ -1814,8 +1808,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; @@ -1840,8 +1833,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; } } @@ -1852,8 +1845,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; @@ -1880,7 +1872,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; } @@ -1891,7 +1883,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; @@ -1927,7 +1919,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); } } @@ -1937,8 +1929,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; @@ -1977,7 +1968,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; @@ -1990,8 +1981,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; @@ -2035,7 +2025,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); } } } @@ -2043,8 +2033,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; @@ -2069,8 +2058,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; } } @@ -2080,8 +2068,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; @@ -2104,16 +2091,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); } } } @@ -2121,8 +2106,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; @@ -2160,7 +2144,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); } } } @@ -2168,8 +2152,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; @@ -2194,8 +2177,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; @@ -2209,8 +2192,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; @@ -2232,7 +2214,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; } @@ -2243,8 +2225,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; @@ -2268,8 +2249,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; } } @@ -2280,8 +2261,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; @@ -2308,7 +2288,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; } @@ -2319,8 +2299,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; @@ -2343,8 +2322,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); } } } @@ -2353,8 +2331,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; @@ -2379,13 +2356,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; @@ -2398,8 +2374,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; @@ -2418,26 +2393,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); } } } @@ -2446,8 +2419,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; @@ -2470,13 +2442,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; } @@ -2488,8 +2460,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; @@ -2513,14 +2484,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; } } @@ -2530,8 +2500,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; @@ -2548,13 +2517,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); } } } @@ -2562,7 +2531,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; @@ -2600,8 +2569,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); } } } @@ -2610,7 +2578,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; @@ -2648,7 +2616,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) {} @@ -2657,8 +2625,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; @@ -2681,8 +2648,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; } } @@ -2691,8 +2657,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; @@ -2714,14 +2679,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; @@ -2755,14 +2720,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; @@ -2772,8 +2737,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; } @@ -2783,7 +2748,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 && @@ -2791,7 +2756,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; } @@ -2800,7 +2765,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; @@ -2810,8 +2775,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; } @@ -2821,7 +2786,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 && @@ -2829,7 +2794,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; } } @@ -2837,7 +2802,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 && @@ -2845,7 +2810,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; } @@ -2859,7 +2824,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++) { @@ -2869,7 +2834,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); } } } @@ -2890,7 +2855,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++) { @@ -2904,7 +2869,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); } } } @@ -2916,7 +2881,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) { @@ -2930,11 +2895,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); } /** @@ -2955,8 +2920,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; @@ -3053,8 +3018,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; @@ -3079,7 +3043,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); } } @@ -3090,7 +3054,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; @@ -3109,7 +3073,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); } } @@ -3119,8 +3083,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; @@ -3139,7 +3102,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); } } @@ -3149,14 +3112,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; @@ -3169,8 +3132,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); } } } @@ -3178,7 +3141,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; @@ -3191,8 +3154,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); } } } @@ -3200,23 +3163,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; @@ -3229,8 +3190,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); } } } @@ -3278,7 +3239,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; @@ -3295,7 +3256,7 @@ void CollisionCheck_OC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) if (vsFunc == NULL) { continue; } - vsFunc(globalCtx, colCtxt, *left, *right); + vsFunc(play, colCtxt, *left, *right); } } } @@ -3365,7 +3326,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; @@ -3416,13 +3377,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); } } } @@ -3430,42 +3391,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[] = { @@ -3477,7 +3438,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++) { @@ -3489,15 +3450,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; @@ -3520,7 +3481,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; @@ -3538,8 +3499,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)) { @@ -3563,8 +3524,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; @@ -3592,7 +3553,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; } @@ -3604,17 +3565,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); } /** @@ -3669,11 +3630,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); } /** @@ -3750,7 +3710,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; @@ -3796,7 +3756,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") @@ -3808,7 +3768,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; @@ -3854,7 +3814,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") @@ -3863,7 +3823,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 }, @@ -3889,36 +3849,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 }, @@ -3944,7 +3904,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..0e682231f 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -6,17 +6,17 @@ void SaveContext_Init(void) { bzero(&gSaveContext, sizeof(SaveContext)); gSaveContext.save.playerForm = 0; - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; gSaveContext.unk_3F4D = 0; gSaveContext.nextDayTime = 0xFFFF; - gSaveContext.environmentTime = 0; + gSaveContext.skyboxTime = 0; gSaveContext.dogIsLost = true; - gSaveContext.nextTransition = 0xFF; - gSaveContext.unk_3F26 = 50; + gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; + gSaveContext.prevHudVisibility = HUD_VISIBILITY_ALL; gSaveContext.options.language = 1; gSaveContext.options.audioSetting = 0; 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 fb7378751..f98b8636e 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -7,10 +7,11 @@ 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*); +Gfx* DebugDisplay_PathDisplayList(GraphicsContext* gfxCtx, Path* path); DebugDispObject* DebugDisplay_Init(void) { sDebugObjectListHead = NULL; @@ -51,44 +52,44 @@ 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_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_Mult(&globalCtx->billboardMtxF, 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); @@ -96,30 +97,113 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContex 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[] = { - 0x00140000, 0x0000FFEC, 0x00000000, 0x00000014, 0x00000000, 0xFFEC0000, 0x00000000, 0x00140000, 0x0000FFEC, -}; +/** + * Visualise a path, see DebugDisplay_PathDisplayList for details. + */ -s32 D_801BB08C = 0; - -Gfx* func_800E99B0(GraphicsContext* gfxCtx, s32 arg1); - -void func_800E992C(GlobalContext* globalCtx, s32 arg1) { +void DebugDisplay_DrawPath(PlayState* play, Path* path) { 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++, DebugDisplay_PathDisplayList(play->state.gfxCtx, path)); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E99B0.s") +#define R_DRAW_PATH_SEGMENT 0 // bREG(82) +#define R_DRAW_PATH_SCALE 1.0f // (1.0f + 0.1f * bREG(83)) +#define R_DRAW_PATH_RED 0 // bREG(84) +#define R_DRAW_PATH_GREEN 0 // bREG(85) +#define R_DRAW_PATH_BLUE 0 // bREG(86) +#define R_DRAW_PATH_ALPHA 0 // bREG(87) + +/** + * Offsets of the points of the triaxial shape used for visualising paths + */ +Vec3s sDebugPathVtxOffsets[][2] = { + { { 20, 0, 0 }, { -20, 0, 0 } }, + { { 0, 20, 0 }, { 0, -20, 0 } }, + { { 0, 0, 20 }, { 0, 0, -20 } }, +}; + +/** + * Constructs a displaylist to show a Path, by extruding the three-axis shape defined by `sPathDebugVtx` along it. + */ +Gfx* DebugDisplay_PathDisplayList(GraphicsContext* gfxCtx, Path* path) { + Gfx* gfxHead; + Gfx* gfx; + Vtx* curVtx; + Vtx* curBaseVtx; // First Vtx for the current point + Vtx* prevBaseVtx; // First Vtx for the previous point + Vec3s* curPoint; + s32 segment; // of path ending at the current point, 1-indexed + + if (path != NULL) { + // (count - 1) segments, 1 gSPVertex and 3 gSP2Triangles for each, plus a gSPEndDisplayList + gfx = GRAPH_ALLOC(gfxCtx, ((path->count - 1) * 4 + 1) * sizeof(Gfx)); + curVtx = GRAPH_ALLOC(gfxCtx, path->count * 6 * sizeof(Vtx)); + + gfxHead = gfx; + curBaseVtx = curVtx; + curPoint = Lib_SegmentedToVirtual(path->points); + + for (segment = 0; segment < path->count; segment++, curPoint++) { + s32 i; + s32 j; + + prevBaseVtx = curBaseVtx; + curBaseVtx = curVtx; + + // Add a vertex for each point in the triaxial shape + for (i = 0; i < ARRAY_COUNT(sDebugPathVtxOffsets); i++) { + for (j = 0; j < ARRAY_COUNT(sDebugPathVtxOffsets[0]); j++) { + curVtx->v.ob[0] = curPoint->x + (s32)(sDebugPathVtxOffsets[i][j].x * R_DRAW_PATH_SCALE); + curVtx->v.ob[1] = curPoint->y + (s32)(sDebugPathVtxOffsets[i][j].y * R_DRAW_PATH_SCALE); + curVtx->v.ob[2] = curPoint->z + (s32)(sDebugPathVtxOffsets[i][j].z * R_DRAW_PATH_SCALE); + curVtx->v.flag = 0; + curVtx->v.tc[0] = 0; + curVtx->v.tc[1] = 0; + curVtx->v.cn[0] = 128 + R_DRAW_PATH_RED; + curVtx->v.cn[1] = 128 + R_DRAW_PATH_GREEN; + curVtx->v.cn[2] = 128 + R_DRAW_PATH_BLUE; + curVtx->v.cn[3] = 128 + R_DRAW_PATH_ALPHA; + curVtx++; + } + } + + // Draw the path segment ending at point `R_DRAW_PATH_SEGMENT`, or the whole path if `R_DRAW_PATH_SEGMENT` + // is 0 + if (R_DRAW_PATH_SEGMENT == 0) { + if (segment > 0) { + gSPVertex(gfx++, prevBaseVtx, 12, 0); + gSP2Triangles(gfx++, 0, 7, 1, 0, 0, 6, 7, 0); + gSP2Triangles(gfx++, 2, 3, 8, 0, 3, 9, 8, 0); + gSP2Triangles(gfx++, 4, 11, 10, 0, 4, 5, 11, 0); + } + } else { + if ((segment > 0) && (segment == R_DRAW_PATH_SEGMENT)) { + gSPVertex(gfx++, prevBaseVtx, 12, 0); + gSP2Triangles(gfx++, 0, 7, 1, 0, 0, 6, 7, 0); + gSP2Triangles(gfx++, 2, 3, 8, 0, 3, 9, 8, 0); + gSP2Triangles(gfx++, 4, 11, 10, 0, 4, 5, 11, 0); + } + } + } + + gSPEndDisplayList(gfx++); + } else { + // No path, trivial displaylist + gfx = gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + gSPEndDisplayList(gfx++); + } + return gfxHead; +} diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 01ed87e70..7d665e208 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,13 +1,17 @@ +#include "prevent_bss_reordering.h" #include "global.h" +#include "z64quake.h" +#include "z64rumble.h" +#include "z64shrink_window.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; @@ -27,14 +31,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; @@ -45,18 +49,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 @@ -66,9 +70,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); } } @@ -80,8 +84,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; } @@ -91,32 +95,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) { - Interface_ChangeAlpha(1); - ShrinkWindow_SetLetterboxTarget(32); - if (func_800EA220(globalCtx, csCtx, 1.0f)) { +void func_800EA258(PlayState* play, CutsceneContext* csCtx) { + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + ShrinkWindow_Letterbox_SetSizeTarget(32); + if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); csCtx->state++; } } -void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx) { - func_800ED980(globalCtx, csCtx); - Interface_ChangeAlpha(1); - ShrinkWindow_SetLetterboxTarget(32); - if (func_800EA220(globalCtx, csCtx, 1.0f)) { +void func_800EA2B8(PlayState* play, CutsceneContext* csCtx) { + func_800ED980(play, csCtx); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + ShrinkWindow_Letterbox_SetSizeTarget(32); + if (func_800EA220(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(true); csCtx->state++; } @@ -125,12 +129,11 @@ 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* play, CutsceneContext* csCtx, CsCmdBase* cmd) { static u16 D_801BB15C = 0xFFFF; - Player* player = GET_PLAYER(globalCtx2); - GlobalContext* globalCtx = globalCtx2; - u8 isStartFrame = false; + Player* player = GET_PLAYER(play); f32 progress; + u8 isStartFrame = false; SceneTableEntry* loadedScene; if ((csCtx->frames < cmd->startFrame) || ((csCtx->frames >= cmd->endFrame) && (cmd->endFrame != cmd->startFrame))) { @@ -146,33 +149,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); + Audio_SetAmbienceChannelIO(AMBIENCE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); + 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: @@ -182,16 +185,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), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -215,32 +218,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.curRoom.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; @@ -249,30 +252,29 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs break; case 0x12: if (!gSaveContext.save.isNight) { - gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)REG(15); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)R_TIME_SPEED; } else { - gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)(2 * REG(15)); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) - (u16)(2 * R_TIME_SPEED); } 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; break; case 0x17: - player->stateFlags2 |= 0x4000000; + player->stateFlags2 |= PLAYER_STATE2_4000000; break; case 0x18: - player->stateFlags2 &= ~0x4000000; + player->stateFlags2 &= ~PLAYER_STATE2_4000000; break; case 0x19: sCutsceneStoredPlayerForm = gSaveContext.save.playerForm; @@ -282,7 +284,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), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 30000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -290,15 +292,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: @@ -312,29 +314,29 @@ 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: if (csCtx->frames != D_801BB15C) { D_801BB15C = csCtx->frames; - if (REG(15) != 0) { - gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)REG(15); + if (R_TIME_SPEED != 0) { + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; gSaveContext.save.time = - ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); + ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset); } } 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), QUAKE_TYPE_6); Quake_SetSpeed(sCutsceneQuakeIndex, 22000); Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0); Quake_SetCountdown(sCutsceneQuakeIndex, 800); @@ -346,13 +348,10 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs gSaveContext.save.day = 9; - { - GameState* gameState = &globalCtx->state; - gameState->running = false; - } - SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); + STOP_GAMESTATE(&play->state); + SET_NEXT_GAMESTATE(&play->state, DayTelop_Init, sizeof(DayTelopState)); - Sram_SaveSpecialNewDay(globalCtx); + Sram_SaveSpecialNewDay(play); break; case 0x27: @@ -366,33 +365,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); + Audio_PlaySequenceInCutscene(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); + Audio_StopSequenceInCutscene(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; @@ -405,16 +404,14 @@ 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); + Audio_PlayAmbience(play->sequenceCtx.ambienceId); } } // 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); @@ -422,7 +419,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); @@ -432,7 +429,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; @@ -459,40 +456,39 @@ void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* break; case 4: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_1); - func_801A246C(SEQ_PLAYER_NATURE, 1); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_1); + func_801A246C(SEQ_PLAYER_AMBIENCE, 1); break; case 5: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_0); - func_801A246C(SEQ_PLAYER_NATURE, 0); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_0); + func_801A246C(SEQ_PLAYER_AMBIENCE, 0); break; case 6: - // func_801A246C(SEQ_PLAYER_NATURE, TYPE_2); - func_801A246C(SEQ_PLAYER_NATURE, 2); + // func_801A246C(SEQ_PLAYER_AMBIENCE, TYPE_2); + func_801A246C(SEQ_PLAYER_AMBIENCE, 2); break; case 7: - // Audio_GetActiveSequence - seqId = func_801A8A50(0); + seqId = Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN); break; case 8: if (seqId != NA_BGM_DISABLED) { - // Audio_PlayBgmForDayScene - func_801A25E4(seqId, dayMinusOne); + Audio_PlaySceneSequence(seqId, dayMinusOne); } break; } } } #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; @@ -501,18 +497,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; @@ -520,29 +516,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; @@ -553,48 +549,48 @@ 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; + gSaveContext.hudVisibilityForceButtonAlphasByStatus = true; } 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) { @@ -602,45 +598,45 @@ 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; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + 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; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + 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; + SET_WEEKEVENTREG(WEEKEVENTREG_55_80); + 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; + SET_WEEKEVENTREG(WEEKEVENTREG_52_20); + 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; } } @@ -649,142 +645,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) { - if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(0, true) != 0xFF)) { +void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { + if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(SEQ_PLAYER_BGM_MAIN, 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); @@ -803,8 +780,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) { @@ -812,112 +789,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); @@ -995,9 +972,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; @@ -1014,24 +991,24 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, D_801BB160 = CS_TEXTBOX_TYPE_1; D_801BB124 = cmd->base; if (cmd->type == CS_TEXTBOX_TYPE_BOSSES_REMAINS) { - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && 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; @@ -1039,7 +1016,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) { @@ -1047,17 +1024,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) { @@ -1065,7 +1043,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } } } else { - func_801477B4(globalCtx); + func_801477B4(play); csCtx->frames++; } } else { @@ -1074,7 +1052,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) { @@ -1082,24 +1060,24 @@ 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++; } if (originalCsFrames == csCtx->frames) { - Interface_ChangeAlpha(1); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); D_801BB124 = 0; D_801BB128 = 0; func_80161C0C(); @@ -1129,8 +1107,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). @@ -1157,16 +1133,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 @@ -1175,7 +1150,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; } @@ -1194,14 +1170,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; } @@ -1213,7 +1189,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; @@ -1222,7 +1198,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; @@ -1231,7 +1207,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; @@ -1240,7 +1216,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; @@ -1249,7 +1225,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; @@ -1258,7 +1234,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; @@ -1267,7 +1243,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; @@ -1276,7 +1252,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; @@ -1285,7 +1261,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; @@ -1294,7 +1270,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; @@ -1303,7 +1279,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; @@ -1312,7 +1288,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; @@ -1321,7 +1297,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; @@ -1331,22 +1307,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; @@ -1355,7 +1331,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; @@ -1366,7 +1342,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); } @@ -1376,7 +1352,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; @@ -1385,7 +1361,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; @@ -1394,7 +1370,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; @@ -1412,30 +1388,26 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, } } } -#else -void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr); -#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; @@ -1452,8 +1424,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; } @@ -1473,29 +1445,27 @@ 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) { - Interface_ChangeAlpha(1); - ShrinkWindow_SetLetterboxTarget(32); - ShrinkWindow_SetLetterboxMagnitude(0x20); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + ShrinkWindow_Letterbox_SetSizeTarget(32); + ShrinkWindow_Letterbox_SetSize(32); 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; @@ -1505,15 +1475,17 @@ 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)))) { + // TODO: macros for this kind of weekEventReg access + 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; } @@ -1525,31 +1497,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.sceneLayer)) & 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; @@ -1561,10 +1531,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; @@ -1574,7 +1544,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); } @@ -1583,10 +1553,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; } @@ -1594,21 +1564,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); @@ -1620,19 +1590,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; @@ -1641,16 +1611,16 @@ void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCt actor->shape.rot.y = actor->world.rot.y; } -s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx) { - s32 sceneSetupIndex = 0; +s32 Cutscene_GetSceneLayer(PlayState* play) { + s32 sceneLayer = 0; - if (gSaveContext.sceneSetupIndex > 0) { - sceneSetupIndex = gSaveContext.sceneSetupIndex; + if (gSaveContext.sceneLayer > 0) { + sceneLayer = gSaveContext.sceneLayer; } - return sceneSetupIndex; + return sceneLayer; } -s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd) { +s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd) { s32 i; s32 index = -1; @@ -1663,20 +1633,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 6ab70f1ef..5f0221969 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -408,7 +408,7 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* Math_Vec3s_ToVec3f(&sp6C, &this->elements[0].p2); - vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[4])); + vtx = GRAPH_ALLOC(gfxCtx, 4 * sizeof(Vtx)); if (vtx == NULL) { } else { vtx[0].v = baseVtx; @@ -559,7 +559,7 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem Math_Vec3f_Scale(&sp174, 0.5f); Math_Vec3f_Scale(&sp168, 0.5f); - vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[16])); + vtx = GRAPH_ALLOC(gfxCtx, 16 * sizeof(Vtx)); if (vtx == NULL) { } else { Math_Vec3f_Diff(&sp1CC, &sp138, &sp158); @@ -849,7 +849,7 @@ void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) { if (this->numElements >= 2) { vtxCount = this->numElements * 4; - vtx = GRAPH_ALLOC(gfxCtx, ALIGN16(vtxCount * sizeof(Vtx))); + vtx = GRAPH_ALLOC(gfxCtx, vtxCount * sizeof(Vtx)); if (vtx == NULL) { return; } @@ -941,7 +941,7 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { func_8012C560(gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[32])); + vtx = GRAPH_ALLOC(gfxCtx, 32 * sizeof(Vtx)); if (vtx == NULL) { } else { j = 0; diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index f959867fe..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_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..fdd25a6b4 100644 --- a/src/code/z_eff_spark.c +++ b/src/code/z_eff_spark.c @@ -120,9 +120,9 @@ s32 EffectSpark_Update(void* thisx) { } void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { - Vtx* vertices; + Vtx* vtx; EffectSpark* this = (EffectSpark*)thisx; - GlobalContext* globalCtx = Effect_GetGlobalCtx(); + PlayState* play = Effect_GetPlayState(); s32 i; s32 j; u8 sp1D3; @@ -162,8 +162,8 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); gDPPipeSync(POLY_XLU_DISP++); - vertices = GRAPH_ALLOC(gfxCtx, ALIGN16(this->numElements * sizeof(Vtx[4]))); - if (vertices == NULL) { + vtx = GRAPH_ALLOC(gfxCtx, this->numElements * (4 * sizeof(Vtx))); + if (vtx == NULL) { goto end; } @@ -199,52 +199,52 @@ 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; - vertices[j].v.ob[1] = -32; - vertices[j].v.ob[2] = 0; - vertices[j].v.cn[0] = sp1D3; - vertices[j].v.cn[1] = sp1D2; - vertices[j].v.cn[2] = sp1D1; - vertices[j].v.cn[3] = sp1D0; - vertices[j].v.tc[0] = 0; - vertices[j].v.tc[1] = 1024; - vertices[j].v.flag = 0; + vtx[j].v.ob[0] = -32; + vtx[j].v.ob[1] = -32; + vtx[j].v.ob[2] = 0; + vtx[j].v.cn[0] = sp1D3; + vtx[j].v.cn[1] = sp1D2; + vtx[j].v.cn[2] = sp1D1; + vtx[j].v.cn[3] = sp1D0; + vtx[j].v.tc[0] = 0; + vtx[j].v.tc[1] = 1024; + vtx[j].v.flag = 0; - vertices[j + 1].v.ob[0] = 32; - vertices[j + 1].v.ob[1] = 32; - vertices[j + 1].v.ob[2] = 0; - vertices[j + 1].v.cn[0] = sp1CF; - vertices[j + 1].v.cn[1] = sp1CE; - vertices[j + 1].v.cn[2] = sp1CD; - vertices[j + 1].v.cn[3] = sp1CC; - vertices[j + 1].v.tc[0] = 1024; - vertices[j + 1].v.tc[1] = 0; - vertices[j + 1].v.flag = 0; + vtx[j + 1].v.ob[0] = 32; + vtx[j + 1].v.ob[1] = 32; + vtx[j + 1].v.ob[2] = 0; + vtx[j + 1].v.cn[0] = sp1CF; + vtx[j + 1].v.cn[1] = sp1CE; + vtx[j + 1].v.cn[2] = sp1CD; + vtx[j + 1].v.cn[3] = sp1CC; + vtx[j + 1].v.tc[0] = 1024; + vtx[j + 1].v.tc[1] = 0; + vtx[j + 1].v.flag = 0; - vertices[j + 2].v.ob[0] = -32; - vertices[j + 2].v.ob[1] = 32; - vertices[j + 2].v.ob[2] = 0; - vertices[j + 2].v.cn[0] = sp1CB; - vertices[j + 2].v.cn[1] = sp1CA; - vertices[j + 2].v.cn[2] = sp1C9; - vertices[j + 2].v.cn[3] = sp1C8; - vertices[j + 2].v.tc[0] = 0; - vertices[j + 2].v.tc[1] = 0; - vertices[j + 2].v.flag = 0; + vtx[j + 2].v.ob[0] = -32; + vtx[j + 2].v.ob[1] = 32; + vtx[j + 2].v.ob[2] = 0; + vtx[j + 2].v.cn[0] = sp1CB; + vtx[j + 2].v.cn[1] = sp1CA; + vtx[j + 2].v.cn[2] = sp1C9; + vtx[j + 2].v.cn[3] = sp1C8; + vtx[j + 2].v.tc[0] = 0; + vtx[j + 2].v.tc[1] = 0; + vtx[j + 2].v.flag = 0; - vertices[j + 3].v.ob[0] = 32; - vertices[j + 3].v.ob[1] = -32; - vertices[j + 3].v.ob[2] = 0; - vertices[j + 3].v.cn[0] = sp1C7; - vertices[j + 3].v.cn[1] = sp1C6; - vertices[j + 3].v.cn[2] = sp1C5; - vertices[j + 3].v.cn[3] = sp1C4; - vertices[j + 3].v.tc[0] = 1024; - vertices[j + 3].v.tc[1] = 1024; - vertices[j + 3].v.flag = 0; + vtx[j + 3].v.ob[0] = 32; + vtx[j + 3].v.ob[1] = -32; + vtx[j + 3].v.ob[2] = 0; + vtx[j + 3].v.cn[0] = sp1C7; + vtx[j + 3].v.cn[1] = sp1C6; + vtx[j + 3].v.cn[2] = sp1C5; + vtx[j + 3].v.cn[3] = sp1C4; + vtx[j + 3].v.tc[0] = 1024; + vtx[j + 3].v.tc[1] = 1024; + vtx[j + 3].v.flag = 0; j += 4; @@ -254,7 +254,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { } gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPVertex(POLY_XLU_DISP++, &vertices[4 * i], 4, 0); + gSPVertex(POLY_XLU_DISP++, &vtx[4 * i], 4, 0); gSP2Triangles(POLY_XLU_DISP++, 2, 0, 3, 0, 2, 3, 1, 0); } 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_eff_tire_mark.c b/src/code/z_eff_tire_mark.c index 532e8e2fb..f19eb1289 100644 --- a/src/code/z_eff_tire_mark.c +++ b/src/code/z_eff_tire_mark.c @@ -1,8 +1,8 @@ #include "global.h" #include "objects/gameplay_keep/gameplay_keep.h" -void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f32 arg3, s16 arg4, - CollisionPoly* colPoly, s32 arg6) { +void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f32 arg3, s16 angle, + CollisionPoly* colPoly, s32 bgId) { Vec3s spB8; Vec3s spB0; EffectTireMarkElement* spAC; @@ -11,17 +11,17 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f u32 spA0; Vec3s* vtxList = colCtx->colHeader->vtxList; - if ((arg6 != 50) || (this->numElements >= (ARRAY_COUNT(this->elements) - 1)) || (colPoly == NULL)) { + if ((bgId != 50) || (this->numElements >= (ARRAY_COUNT(this->elements) - 1)) || (colPoly == NULL)) { func_800AEF44(this); return; } - spB8.x = (Math_SinS(arg4 - 0x4000) * arg3) + pos->x; - spB8.z = (Math_CosS(arg4 - 0x4000) * arg3) + pos->z; + spB8.x = (Math_SinS(angle - 0x4000) * arg3) + pos->x; + spB8.z = (Math_CosS(angle - 0x4000) * arg3) + pos->z; spB8.y = func_800BFD84(colPoly, spB8.x, spB8.z) + 2.0f; - spB0.x = (Math_SinS(arg4 + 0x4000) * arg3) + pos->x; - spB0.z = (Math_CosS(arg4 + 0x4000) * arg3) + pos->z; + spB0.x = (Math_SinS(angle + 0x4000) * arg3) + pos->x; + spB0.z = (Math_CosS(angle + 0x4000) * arg3) + pos->z; spB0.y = func_800BFD84(colPoly, spB0.x, spB0.z) + 2.0f; spAC = &this->elements[this->numElements - 1]; @@ -226,7 +226,7 @@ void EffectTireMark_Draw(void* thisx, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); if (this->numElements >= 2) { - vtx = GRAPH_ALLOC(gfxCtx, ALIGN16(this->numElements * sizeof(Vtx[2]))); + vtx = GRAPH_ALLOC(gfxCtx, this->numElements * (2 * sizeof(Vtx))); if (vtx != NULL) { gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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 1e9b25573..4f24651d1 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,16 +41,16 @@ 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); + gSegments[0x06] = VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); @@ -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,91 @@ 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, DUST_DRAWFLAG0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, + DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, + DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, + DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, + DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, + DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, + DUST_UPDATE_FIRE); } -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, DUST_DRAWFLAG1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, + DUST_UPDATE_FIRE); } 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, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG0, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, 100, 5, 10, DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG1, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, 100, 5, 10, DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG0, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, scale, scaleStep, 10, DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG1, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, scale, scaleStep, 10, DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG0, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, scale, scaleStep, life, DUST_UPDATE_NORMAL); } -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, DUST_DRAWFLAG_RAND_COLOR_OFFSET | DUST_DRAWFLAG1, pos, velocity, accel, &sDustBrownPrim, + &sDustBrownEnv, scale, scaleStep, life, DUST_UPDATE_NORMAL); } -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 +193,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 +201,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,24 +213,24 @@ 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) { +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); @@ -236,11 +247,11 @@ 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) { +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); @@ -255,10 +266,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 +279,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,13 +292,13 @@ 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, - Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 sclaeStepDecay, s16 life) { +void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 scaleStepDecay, s16 life) { EffectSsBlastInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -298,35 +308,35 @@ void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Color_RGBA8_Copy(&initParams.envColor, envColor); initParams.scale = scale; initParams.scaleStep = scaleStep; - initParams.sclaeStepDecay = sclaeStepDecay; + initParams.scaleStepDecay = scaleStepDecay; 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 +348,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 +366,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,17 +394,17 @@ 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, - s16 alpha, s16 fadeDelay, s16 arg8, s32 life) { +void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, + s16 alpha, s16 alphaStep, s16 fadeDelay, s32 life) { EffectSsDFireInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -403,16 +413,16 @@ void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.scale = scale; initParams.scaleStep = scaleStep; initParams.alpha = alpha; + initParams.alphaStep = alphaStep; initParams.fadeDelay = fadeDelay; - 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 +432,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 +445,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 +466,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,28 +493,28 @@ 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); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); - initParams.customColor = 0; + initParams.customColor = false; initParams.colorProfile = colorProfile; initParams.scale = scale; 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; @@ -516,9 +526,9 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec initParams.scale = scale; initParams.life = life; initParams.randXZ = randXZ; - initParams.customColor = 1; + initParams.customColor = true; - EffectSs_Spawn(globalCtx, EFFECT_SS_DT_BUBBLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams); } // EffectSsHahen Spawn Functions @@ -532,20 +542,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 +567,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 +581,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 +598,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 +620,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 reg0) { +void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 reg0) { EffectSsStone1InitParams initParams; initParams.pos = *pos; 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 +672,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,30 +697,30 @@ 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, - s16* linkDetected, s16 drawFlag) { +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, + s16* playerDetected, s16 flags) { EffectSsSolderSrchBallInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); - initParams.unused = unused; - initParams.linkDetected = linkDetected; - initParams.drawFlag = drawFlag; + initParams.scale = scale; + initParams.playerDetected = playerDetected; + initParams.flags = flags; - 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 +739,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 +752,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 +786,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 +836,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 +858,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 +873,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 +900,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 +912,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,13 +934,13 @@ 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, - Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk) { +void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim, + Color_RGBA8* env, s16 scale, s16 scaleStep, s32 life) { EffectSsDeadDbInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -946,12 +955,12 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.envColor.r = env->r; initParams.envColor.g = env->g; initParams.envColor.b = env->b; - initParams.unk_30 = unk; + initParams.life = life; - 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 +970,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 +991,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 +1011,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 +1028,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 +1041,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..830824024 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -1,62 +1,93 @@ +/** + * @file z_elf_message.c + * + * This file provides quest hints through Tatl. + * + * In Ocarina of Time, this was a more elaborate system that determined + * which hint to give based on a script. + * That system has been replaced with a single function that hardcodes the checks. + */ #include "global.h" -u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) { +/** + * Gets the relevant text ID for Tatl hints in first cycle. + */ +u16 QuestHint_GetTatlTextId(PlayState* play) { if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { return 0; } + if (CURRENT_DAY <= 0) { return 0; } - if (gSaveContext.save.weekEventReg[88] & 0x20) { + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_88_20)) { return 0; } - if (gSaveContext.save.weekEventReg[79] & 0x10) { - if (gSaveContext.save.weekEventReg[8] & 0x40) { + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_10)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40)) { return 0; } + return 0x224; } - if (!(gSaveContext.save.weekEventReg[8] & 0x80)) { - if (gSaveContext.save.weekEventReg[9] & 1) { + + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_08_80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_09_01)) { return 0x21E; } - if (globalCtx->sceneNum == SCENE_YOUSEI_IZUMI) { + + if (play->sceneId == SCENE_YOUSEI_IZUMI) { return 0; } + return 0x21D; } - if (gSaveContext.save.playerData.magicAcquired != true) { + + if (gSaveContext.save.playerData.isMagicAcquired != true) { return 0x21F; } + if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) { - if (globalCtx->sceneNum != SCENE_OKUJOU) { + if (play->sceneId != SCENE_OKUJOU) { return 0x244; } + return 0; } + if (INV_CONTENT(ITEM_MOON_TEAR) == ITEM_MOON_TEAR) { - if (gSaveContext.save.weekEventReg[86] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_04)) { return 0x242; } + return 0x243; } - if (gSaveContext.save.weekEventReg[74] & 0x20) { + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_74_20)) { return 0x223; } - if (gSaveContext.save.weekEventReg[73] & 0x80) { + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_80)) { return 0x222; } - if (gSaveContext.save.weekEventReg[73] & 0x20) { + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_20)) { return 0x221; } - if (gSaveContext.save.weekEventReg[77] & 2) { - if (gSaveContext.save.weekEventReg[73] & 0x10) { + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_02)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10)) { return 0x240; } + return 0x241; } - if ((gSaveContext.save.weekEventReg[86] & 2) || (gSaveContext.save.weekEventReg[73] & 0x40)) { + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_02) || CHECK_WEEKEVENTREG(WEEKEVENTREG_73_40)) { return 0x23F; } + return 0x220; } diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c index 1d083b2c7..a9bd49f6f 100644 --- a/src/code/z_en_a_keep.c +++ b/src/code/z_en_a_keep.c @@ -1,57 +1,106 @@ #include "global.h" +#include "assets/objects/gameplay_keep/gameplay_keep.h" + +#define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #define THIS ((EnAObj*)thisx) -void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx); +void EnAObj_Init(Actor* thisx, PlayState* play); +void EnAObj_Destroy(Actor* thisx, PlayState* play); +void EnAObj_Update(Actor* thisx, PlayState* play); +void EnAObj_Draw(Actor* thisx, PlayState* play); -void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAObj_Idle(EnAObj* this, PlayState* play); +void EnAObj_Talk(EnAObj* this, PlayState* play); + +ActorInit En_A_Obj_InitVars = { + ACTOR_EN_A_OBJ, + ACTORCAT_PROP, + FLAGS, + GAMEPLAY_KEEP, + sizeof(EnAObj), + (ActorFunc)EnAObj_Init, + (ActorFunc)EnAObj_Destroy, + (ActorFunc)EnAObj_Update, + (ActorFunc)EnAObj_Draw, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE, + BUMP_NONE, + OCELEM_ON, + }, + { 25, 60, 0, { 0, 0, 0 } }, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_U8(targetMode, 0, ICHAIN_STOP), +}; + +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); + this->actor.textId = AOBJ_GET_TEXTID(&this->actor); + this->actor.params = AOBJ_GET_TYPE(&this->actor); + Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 12); - Collider_InitAndSetCylinder(globalCtx, &this->collision, &this->actor, &enAObjCylinderInit); + Collider_InitAndSetCylinder(play, &this->collision, &this->actor, &sCylinderInit); Collider_UpdateCylinder(&this->actor, &this->collision); this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->actionFunc = EnAObj_Update1; + this->actionFunc = EnAObj_Idle; } -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_Idle(EnAObj* this, PlayState* play) { s32 yawDiff; - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actionFunc = EnAObj_Update2; + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = EnAObj_Talk; } 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); + if ((yawDiff < 0x2800) || ((this->actor.params == AOBJ_SIGNPOST_ARROW) && (yawDiff > 0x5800))) { + func_800B863C(&this->actor, play); } } } -void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->actor, globalCtx)) { - this->actionFunc = EnAObj_Update1; +void EnAObj_Talk(EnAObj* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { + this->actionFunc = EnAObj_Idle; } } -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]); +static Gfx* sDLists[] = { + gSignRectangularDL, // AOBJ_SIGNPOST_OBLONG + gSignDirectionalDL, // AOBJ_SIGNPOST_ARROW +}; + +void EnAObj_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, sDLists[thisx->params]); } diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 28c177068..01ec9eca3 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 }, @@ -45,20 +45,20 @@ 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] = VIRTUAL_TO_PHYSICAL(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] = VIRTUAL_TO_PHYSICAL(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] = VIRTUAL_TO_PHYSICAL(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); + enHy->skelAnime.moveFlags |= (ANIM_FLAG_UPDATEY | ANIM_FLAG_1); + 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 6b01753cc..944e650a0 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -1,23 +1,29 @@ #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 = { +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); + +ActorInit En_Item00_InitVars = { ACTOR_EN_ITEM00, ACTORCAT_MISC, FLAGS, @@ -53,8 +59,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,7 +68,7 @@ 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; @@ -74,22 +80,22 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + Actor_Kill(&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; @@ -101,12 +107,14 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk154 = 0.015f; shadowOffset = 750.0f; break; + case ITEM00_SMALL_KEY: this->unk150 = 0; Actor_SetScale(&this->actor, 0.03f); this->unk154 = 0.03f; shadowOffset = 350.0f; break; + case ITEM00_HEART_PIECE: case ITEM00_HEART_CONTAINER: this->unk150 = 0; @@ -117,12 +125,14 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { sp30 = -1; } break; - case ITEM00_HEART: - this->actor.home.rot.z = randPlusMinusPoint5Scaled(65535.0f); + + case ITEM00_RECOVERY_HEART: + this->actor.home.rot.z = randPlusMinusPoint5Scaled(0xFFFF); shadowOffset = 430.0f; Actor_SetScale(&this->actor, 0.02f); this->unk154 = 0.02f; break; + case ITEM00_ARROWS_10: case ITEM00_ARROWS_30: case ITEM00_ARROWS_40: @@ -131,6 +141,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk154 = 0.035f; shadowOffset = 250.0f; break; + case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: case ITEM00_NUTS_1: @@ -142,39 +153,47 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk154 = 0.03f; shadowOffset = 320.0f; break; + case ITEM00_MAGIC_LARGE: - Actor_SetScale(&this->actor, 0.044999998f); - this->unk154 = 0.044999998f; + Actor_SetScale(&this->actor, 4.5f * 0.01f); + this->unk154 = 4.5f * 0.01f; shadowOffset = 320.0f; break; + case ITEM00_RUPEE_HUGE: - Actor_SetScale(&this->actor, 0.044999998f); - this->unk154 = 0.044999998f; + Actor_SetScale(&this->actor, 4.5f * 0.01f); + this->unk154 = 4.5f * 0.01f; shadowOffset = 750.0f; break; + case ITEM00_RUPEE_PURPLE: Actor_SetScale(&this->actor, 0.03f); this->unk154 = 0.03f; shadowOffset = 750.0f; break; + case ITEM00_FLEXIBLE: case ITEM00_BIG_FAIRY: shadowOffset = 500.0f; Actor_SetScale(&this->actor, 0.01f); 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,13 +202,14 @@ 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; this->unk152 = -1; return; } + if (sp30 == 0) { this->actionFunc = func_800A640C; this->unk152 = -1; @@ -205,88 +225,105 @@ 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; break; + case ITEM00_NUTS_10: getItemId = GI_NUTS_10; break; + default: 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)) { + 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) { - s32 sp1C; +void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play) { + s32 objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS); - sp1C = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS); - if (Object_IsLoaded(&globalCtx->objectCtx, sp1C)) { - this->actor.objBankIndex = sp1C; + if (Object_IsLoaded(&play->objectCtx, objBankIndex)) { + this->actor.objBankIndex = objBankIndex; 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) && @@ -321,52 +358,53 @@ void func_800A640C(EnItem00* this, GlobalContext* globalCtx) { if (this->unk152 == 0) { if ((this->actor.params != ITEM00_SMALL_KEY) && (this->actor.params != ITEM00_HEART_PIECE) && (this->actor.params != ITEM00_HEART_CONTAINER)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } - if ((this->actor.gravity != 0.0f) && ((this->actor.bgCheckFlags & 1) == 0)) { + if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & 1)) { this->actionFunc = func_800A6650; } } -static Color_RGBA8 D_801ADF10 = { 255, 255, 127, 0 }; -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 }; +static Color_RGBA8 sEffectPrimColor = { 255, 255, 127, 0 }; +static Color_RGBA8 sEffectEnvColor = { 255, 255, 255, 0 }; +static Vec3f sEffectVelocity = { 0.0f, 0.1f, 0.0f }; +static Vec3f sEffectAccel = { 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, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } - if ((this->actor.bgCheckFlags & 3) != 0) { + + if (this->actor.bgCheckFlags & 3) { if (this->actor.velocity.y > -2.0f) { this->actionFunc = func_800A640C; - return; + } else { + this->actor.velocity.y = this->actor.velocity.y * -0.8f; + this->actor.bgCheckFlags &= ~1; } - - this->actor.velocity.y = this->actor.velocity.y * -0.8f; - this->actor.bgCheckFlags = this->actor.bgCheckFlags & 0xFFFE; } } -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; @@ -382,74 +420,74 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) { } if (this->actor.params <= ITEM00_RUPEE_RED) { - this->actor.shape.rot.y += 960; + this->actor.shape.rot.y += 0x3C0; } else if ((this->actor.params >= ITEM00_SHIELD_HERO) && (this->actor.params != ITEM00_NUTS_10) && (this->actor.params != ITEM00_BOMBS_0)) { - this->actor.world.rot.x -= 700; - this->actor.shape.rot.y += 400; + this->actor.world.rot.x -= 0x2BC; + this->actor.shape.rot.y += 0x190; this->actor.shape.rot.x = this->actor.world.rot.x - 0x4000; } if (this->actor.velocity.y <= 2.0f) { - var1 = (u16)this->actor.shape.rot.z + 10000; - if (var1 < 65535) { - this->actor.shape.rot.z += 10000; + var1 = (u16)this->actor.shape.rot.z + 0x2710; + if (var1 < 0xFFFF) { + this->actor.shape.rot.z += 0x2710; } else { this->actor.shape.rot.z = -1; } } - 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, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } - if (this->actor.bgCheckFlags & 0x0003) { + if (this->actor.bgCheckFlags & 3) { this->actionFunc = func_800A640C; this->actor.shape.rot.z = 0; this->actor.speedXZ = 0.0f; } } -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)) { + Actor_PickUp(&this->actor, play, this->getItemId, 50.0f, 80.0f); this->unk152++; } else { - this->unk14A = GI_NONE; + this->getItemId = GI_NONE; } } if (this->unk152 == 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } this->actor.world.pos = player->actor.world.pos; 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) { + this->actor.shape.rot.y += 0x3C0; + } else if (this->actor.params == ITEM00_RECOVERY_HEART) { this->actor.shape.rot.y = 0; } this->actor.world.pos.y += (40.0f + (Math_SinS(this->unk152 * 15000) * (this->unk152 * 0.3f))); if (LINK_IS_ADULT) { - this->actor.world.pos.y = this->actor.world.pos.y + 20.0f; + this->actor.world.pos.y += 20.0f; } } -void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Update(Actor* thisx, PlayState* play) { EnItem00* this = THIS; s32 pad; - Player* player = GET_PLAYER(globalCtx); - s32 sp38 = player->stateFlags3 & 0x1000; + Player* player = GET_PLAYER(play); + s32 sp38 = player->stateFlags3 & PLAYER_STATE3_1000; s32 getItemId = GI_NONE; s32 params; @@ -461,7 +499,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,16 +507,16 @@ 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); + Actor_Kill(&this->actor); return; } } 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,99 +531,122 @@ 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 != GAMEOVER_INACTIVE) { 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; break; + case ITEM00_NUTS_1: getItemId = GI_NUTS_1; break; + 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; break; + case ITEM00_HEART_PIECE: getItemId = GI_HEART_PIECE; break; + case ITEM00_HEART_CONTAINER: 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; break; + case ITEM00_MAP: getItemId = GI_MAP; break; + case ITEM00_COMPASS: getItemId = GI_COMPASS; break; + default: break; } 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,11 +657,12 @@ 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); - Actor_MarkForDeath(&this->actor); + if (Actor_HasParent(&this->actor, play)) { + Flags_SetCollectible(play, this->collectibleFlag); + Actor_Kill(&this->actor); } return; + default: break; } @@ -608,16 +670,16 @@ 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); - Actor_MarkForDeath(&this->actor); + if (Actor_HasParent(&this->actor, play)) { + Flags_SetCollectible(play, this->collectibleFlag); + Actor_Kill(&this->actor); } return; } else { 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 +690,11 @@ 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_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Draw(Actor* thisx, PlayState* play) { s32 pad; EnItem00* this = THIS; @@ -648,29 +705,34 @@ 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; } + // fallthrough case ITEM00_BOMBS_A: case ITEM00_ARROWS_10: case ITEM00_ARROWS_30: @@ -684,16 +746,21 @@ 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); + break; + case ITEM00_MASK: case ITEM00_FLEXIBLE: case ITEM00_3_HEARTS: @@ -704,114 +771,109 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { } } -TexturePtr D_801ADF30[] = { - gameplay_keep_Tex_061FC0, // Green rupee - gameplay_keep_Tex_061FE0, // Blue rupee - gameplay_keep_Tex_062000, // Red rupee - gameplay_keep_Tex_062040, // Orange rupee - gameplay_keep_Tex_062020 // Purple rupee +static TexturePtr sRupeeTextures[] = { + gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeeOrangeTex, gRupeePurpleTex, }; -void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawRupee(EnItem00* this, PlayState* play) { s32 pad; - s32 iconNb; + s32 texIndex; - 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; + texIndex = this->actor.params; } else { - iconNb = this->actor.params - 0x10; + texIndex = 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])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeTextures[texIndex])); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); // TODO symbol + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -TexturePtr D_801ADF44[12] = { - gameplay_keep_Tex_05E6F0, // Heart (Not used) - gameplay_keep_Tex_05CEF0, // Bombs (A), Bombs (0) - gameplay_keep_Tex_05BEF0, // Arrows (10) - gameplay_keep_Tex_05B6F0, // Arrows (30) - gameplay_keep_Tex_05C6F0, // Arrows (40), Arrows (50) - gameplay_keep_Tex_05CEF0, // Bombs (B) - gameplay_keep_Tex_0607C0, // Nuts (1), Nuts (10) - gameplay_keep_Tex_060FC0, // Sticks (1) - gameplay_keep_Tex_0617C0, // Magic (Large) - gameplay_keep_Tex_05FFC0, // Magic (Small) +TexturePtr sItemDropTextures[] = { + gDropRecoveryHeartTex, // Heart (Not used) + gDropBombTex, // Bombs (A), Bombs (0) + gDropArrows1Tex, // Arrows (10) + gDropArrows2Tex, // Arrows (30) + gDropArrows3Tex, // Arrows (40), Arrows (50) + gDropBombTex, // Bombs (B) + gDropDekuNutTex, // Nuts (1), Nuts (10) + gDropDekuStickTex, // Sticks (1) + gDropMagicLargeTex, // Magic (Large) + gDropMagicSmallTex, // Magic (Small) NULL, - gameplay_keep_Tex_05F7C0 // Small Key + gDropKeySmallTex // Small Key }; -void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx) { - s32 iconNb = this->actor.params - 3; +void EnItem00_DrawSprite(EnItem00* this, PlayState* play) { + s32 texIndex = 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; + texIndex = 6; } else if (this->actor.params == ITEM00_BOMBS_0) { - iconNb = 1; + texIndex = 1; } else if (this->actor.params >= ITEM00_ARROWS_30) { - iconNb -= 3; + texIndex -= 3; if (this->actor.params < ITEM00_ARROWS_50) { - iconNb++; + texIndex++; } } POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF44[iconNb])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sItemDropTextures[texIndex])); - 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); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void EnItem00_DrawHeartContainer(EnItem00* actor, GlobalContext* globalCtx) { - s32 pad; - s32 pad2; +void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play) { + s32 pad[2]; - if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) { - OPEN_DISPS(globalCtx->state.gfxCtx); + if (Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS) == this->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); + gSPDisplayList(POLY_XLU_DISP++, gHeartPieceInteriorDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } s16 func_800A7650(s16 dropId) { @@ -825,7 +887,7 @@ s16 func_800A7650(s16 dropId) { return ITEM00_NO_DROP; } - if (dropId == ITEM00_HEART) { + if (dropId == ITEM00_RECOVERY_HEART) { if (((void)0, gSaveContext.save.playerData.healthCapacity) == ((void)0, gSaveContext.save.playerData.health)) { return ITEM00_RUPEE_GREEN; } @@ -834,7 +896,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; @@ -850,29 +912,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); } } } @@ -881,8 +943,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; @@ -891,7 +953,7 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param } spawnedActor->speedXZ = 2.0f; spawnedActor->gravity = -0.9f; - spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(65536.0f); + spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(0x10000); Actor_SetScale(spawnedActor, 0.0f); ((EnItem00*)spawnedActor)->actionFunc = func_800A6780; ((EnItem00*)spawnedActor)->unk152 = 0xDC; @@ -907,7 +969,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; @@ -922,21 +984,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; @@ -946,7 +1008,7 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 para } else { spawnedActor->gravity = -0.9f; } - spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(65536.0f); + spawnedActor->world.rot.y = randPlusMinusPoint5Scaled(0x10000); spawnedActor->flags |= 0x10; } } @@ -957,61 +1019,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] = { @@ -1032,7 +1094,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; @@ -1052,7 +1114,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; @@ -1073,7 +1135,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; @@ -1084,19 +1146,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; @@ -1129,8 +1191,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; @@ -1148,7 +1210,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } } } else { - Item_DropCollectible(globalCtx, spawnPos, params | 0x8000); + Item_DropCollectible(play, spawnPos, params | 0x8000); } dropQuantity--; @@ -1158,13 +1220,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) { @@ -1185,6 +1247,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..5b8b8dce3 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64shrink_window.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_eventmgr/func_800F1460.s") @@ -42,7 +43,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_fbdemo_circle.c b/src/code/z_fbdemo_circle.c index a822262ee..2a8144ea4 100644 --- a/src/code/z_fbdemo_circle.c +++ b/src/code/z_fbdemo_circle.c @@ -1,19 +1,144 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Start.s") +Gfx D_801D0D00[] = { + gsDPPipeSync(), + gsDPSetOtherMode(G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_THRESHOLD | G_ZS_PRIM | AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | FORCE_BL | + GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) | + GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)), + gsDPSetPrimColor(0, 255, 0, 0, 0, 1), + gsDPSetBlendColor(0, 0, 0, 1), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Init.s") +//! @bug: TransitionCircle_Update should take an additional argument `s32 updateRate` +TransitionInit TransitionCircle_InitVars = { + TransitionCircle_Init, TransitionCircle_Destroy, (void*)TransitionCircle_Update, TransitionCircle_Draw, + TransitionCircle_Start, TransitionCircle_SetType, TransitionCircle_SetColor, NULL, + TransitionCircle_IsDone, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Destroy.s") +void TransitionCircle_Start(void* thisx) { + TransitionCircle* this = (TransitionCircle*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Update.s") + this->stepValue = 0.1f; + if (this->direction == TRANSITION_CIRCLE_IN) { + this->targetRadius = 0.0f; + this->startingRadius = 1.0f; + } else { + this->startingRadius = 0.0f; + this->targetRadius = 1.0f; + } + this->referenceRadius = this->startingRadius; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_SetColor.s") +void* TransitionCircle_Init(void* thisx) { + TransitionCircle* this = (TransitionCircle*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_SetType.s") + bzero(this, sizeof(TransitionCircle)); + this->maskType = 1; + this->texture = gCircleTex; + this->masks = 6; + this->maskt = 6; + this->unk_1E = 4; + this->unk_1F = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/func_80164C14.s") + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Draw.s") +void TransitionCircle_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_IsDone.s") +void TransitionCircle_Update(void* thisx) { + TransitionCircle* this = (TransitionCircle*)thisx; + + this->isDone = Math_StepToF(&this->referenceRadius, this->targetRadius, this->stepValue); +} + +void TransitionCircle_SetColor(void* thisx, u32 color) { + TransitionCircle* this = (TransitionCircle*)thisx; + + this->color.rgba = color; +} + +void TransitionCircle_SetType(void* thisx, s32 type) { + TransitionCircle* this = (TransitionCircle*)thisx; + + if (type & TC_SET_PARAMS) { + this->maskType = FBDEMO_CIRCLE_GET_MASK_TYPE(type); + } else if (type == 1) { + this->direction = TRANSITION_CIRCLE_OUT; + } else { + this->direction = TRANSITION_CIRCLE_IN; + } +} + +void TransitionCircle_LoadAndSetTexture(Gfx** gfxp, TexturePtr texture, s32 fmt, s32 arg3, s32 masks, s32 maskt, + f32 arg6) { + Gfx* gfx = *gfxp; + s32 xh = D_801FBBCC; + s32 yh = D_801FBBCE; + s32 width = 1 << masks; + s32 height = 1 << maskt; + f32 s; + f32 t; + s32 dtdy; + s32 dsdx; + + gDPLoadTextureBlock_4b(gfx++, texture, fmt, width, height, 0, G_TX_MIRROR | G_TX_CLAMP, G_TX_MIRROR | G_TX_CLAMP, + masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPSetTileSize(gfx++, G_TX_RENDERTILE, ((SCREEN_WIDTH / 2) - width) << 2, ((SCREEN_HEIGHT / 2) - height) << 2, + ((SCREEN_WIDTH / 2) + (width - 1)) << 2, ((SCREEN_HEIGHT / 2) + (height - 1)) << 2); + + s = ((1.0f - (1.0f / arg6)) * (SCREEN_WIDTH / 2)) + 70.0f; + t = ((1.0f - (1.0f / arg6)) * (SCREEN_HEIGHT / 2)) + 50.0f; + + if (s < -1023.0f) { + s = -1023.0f; + } + if (t < -1023.0f) { + t = -1023.0f; + } + + if ((s <= -1023.0f) || (t <= -1023.0f)) { + dsdx = 0; + dtdy = 0; + } else { + dsdx = ((SCREEN_WIDTH - (2.0f * s)) / gScreenWidth) * (1 << 10); + dtdy = ((SCREEN_HEIGHT - (2.0f * t)) / gScreenHeight) * (1 << 10); + } + + gSPTextureRectangle(gfx++, 0, 0, xh << 2, yh << 2, G_TX_RENDERTILE, (s32)(s * (1 << 5)), (s32)(t * (1 << 5)), dsdx, + dtdy); + gDPPipeSync(gfx++); + + *gfxp = gfx; +} + +void TransitionCircle_Draw(void* thisx, Gfx** gfxp) { + Gfx* gfx = *gfxp; + TransitionCircle* this = (TransitionCircle*)thisx; + + gDPPipeSync(gfx++); + gSPDisplayList(gfx++, &D_801D0D00); + gDPSetPrimColor(gfx++, 0, this->color.a, this->color.r, this->color.g, this->color.b, 1); + if (this->maskType == 0) { + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIM_LOD_FRAC, PRIMITIVE, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIM_LOD_FRAC, PRIMITIVE); + } else { + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, 1, TEXEL0, PRIM_LOD_FRAC, PRIMITIVE, 0, 0, 0, PRIMITIVE, 1, TEXEL0, + PRIM_LOD_FRAC, PRIMITIVE); + } + TransitionCircle_LoadAndSetTexture(&gfx, this->texture, G_IM_FMT_I, 0, this->masks, this->maskt, + this->referenceRadius); + gDPPipeSync(gfx++); + + *gfxp = gfx; +} + +s32 TransitionCircle_IsDone(void* thisx) { + TransitionCircle* this = (TransitionCircle*)thisx; + + return this->isDone; +} diff --git a/src/code/z_fbdemo_dlftbls.c b/src/code/z_fbdemo_dlftbls.c index 7ebce9e69..9d3685a45 100644 --- a/src/code/z_fbdemo_dlftbls.c +++ b/src/code/z_fbdemo_dlftbls.c @@ -1,5 +1,54 @@ #include "global.h" +#include "initvars.h" +#include "overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h" +#include "overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_dlftbls/func_80163C90.s") +#define TRANSITION_OVERLAY(name, filename) \ + { \ + { 0, 0 }, SEGMENT_START(ovl_##filename), SEGMENT_END(ovl_##filename), SEGMENT_ROM_START(ovl_##filename), \ + SEGMENT_ROM_END(ovl_##filename), &name##_InitVars, sizeof(name) \ + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_fbdemo_dlftbls/func_80163D80.s") +#define TRANSITION_OVERLAY_INTERNAL(name) \ + { { 0, 0 }, NULL, NULL, 0, 0, &name##_InitVars, sizeof(name) } + +#define TRANSITION_OVERLAY_UNSET \ + { 0 } + +TransitionOverlay gTransitionOverlayTable[] = { + TRANSITION_OVERLAY_INTERNAL(TransitionFade), TRANSITION_OVERLAY(TransitionTriforce, fbdemo_triforce), + TRANSITION_OVERLAY(TransitionWipe1, fbdemo_wipe1), TRANSITION_OVERLAY(TransitionWipe3, fbdemo_wipe3), + TRANSITION_OVERLAY(TransitionWipe4, fbdemo_wipe4), TRANSITION_OVERLAY_INTERNAL(TransitionCircle), + TRANSITION_OVERLAY(TransitionWipe5, fbdemo_wipe5), +}; + +void Transition_Init(TransitionContext* transitionCtx) { + TransitionOverlay* overlayEntry; + ptrdiff_t relocOffset; + TransitionInit* initInfo[1]; + + overlayEntry = &gTransitionOverlayTable[transitionCtx->fbdemoType]; + TransitionOverlay_Load(overlayEntry); + + relocOffset = (uintptr_t)Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr) - (uintptr_t)overlayEntry->vramStart; + initInfo[0] = NULL; + initInfo[0] = (overlayEntry->initInfo != NULL) ? (TransitionInit*)((uintptr_t)overlayEntry->initInfo + relocOffset) + : initInfo[0]; + + transitionCtx->init = initInfo[0]->init; + transitionCtx->destroy = initInfo[0]->destroy; + transitionCtx->start = initInfo[0]->start; + transitionCtx->isDone = initInfo[0]->isDone; + transitionCtx->draw = initInfo[0]->draw; + transitionCtx->update = initInfo[0]->update; + transitionCtx->setType = initInfo[0]->setType; + transitionCtx->setColor = initInfo[0]->setColor; + transitionCtx->setEnvColor = initInfo[0]->setEnvColor; +} + +void Transition_Destroy(TransitionContext* transitionCtx) { + TransitionOverlay_Free(&gTransitionOverlayTable[transitionCtx->fbdemoType]); +} 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 c8eb927fa..669e01348 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -1,130 +1,187 @@ +/** + * @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_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_TranslateRotateZYX(&pos, &rot); Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY); @@ -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_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 f627c6394..e4f014ffa 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); + if ((fire->flags & 2) && (player->heldItemAction == PLAYER_IA_STICK)) { + 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_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..11d390a28 100644 --- a/src/code/z_game_dlftbls.c +++ b/src/code/z_game_dlftbls.c @@ -4,6 +4,7 @@ #include "overlays/gamestates/ovl_opening/z_opening.h" #include "overlays/gamestates/ovl_select/z_select.h" #include "overlays/gamestates/ovl_title/z_title.h" +#include "z_title_setup.h" #define GAMESTATE_OVERLAY(name, init, destroy, size) \ { \ @@ -14,13 +15,13 @@ { NULL, 0, 0, NULL, NULL, 0, init, destroy, 0, 0, 0, size } GameStateOverlay gGameStateOverlayTable[] = { - GAMESTATE_OVERLAY_INTERNAL(TitleSetup_Init, TitleSetup_Destroy, sizeof(GameState)), - GAMESTATE_OVERLAY(select, Select_Init, Select_Destroy, sizeof(SelectContext)), - GAMESTATE_OVERLAY(title, Title_Init, Title_Destroy, sizeof(TitleContext)), - GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Fini, sizeof(GlobalContext)), - 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)), + GAMESTATE_OVERLAY_INTERNAL(Setup_Init, Setup_Destroy, sizeof(SetupState)), + GAMESTATE_OVERLAY(select, MapSelect_Init, MapSelect_Destroy, sizeof(MapSelectState)), + GAMESTATE_OVERLAY(title, ConsoleLogo_Init, ConsoleLogo_Destroy, sizeof(ConsoleLogoState)), + GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Destroy, sizeof(PlayState)), + GAMESTATE_OVERLAY(opening, TitleSetup_Init, TitleSetup_Destroy, sizeof(TitleSetupState)), + GAMESTATE_OVERLAY(file_choose, FileSelect_Init, FileSelect_Destroy, sizeof(FileSelectState)), + GAMESTATE_OVERLAY(daytelop, DayTelop_Init, DayTelop_Destroy, sizeof(DayTelopState)), }; s32 graphNumGameStates = ARRAY_COUNT(gGameStateOverlayTable); diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index 62d55bc00..5609a4727 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -1,33 +1,35 @@ #include "global.h" +#include "z64rumble.h" +#include "z64shrink_window.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; - s16 i; +void GameOver_Update(PlayState* play) { + GameOverContext* gameOverCtx = &play->gameOverCtx; + s16 timerId; 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; + for (timerId = 0; timerId < TIMER_ID_MAX; timerId++) { + gSaveContext.timerStates[timerId] = TIMER_STATE_OFF; } - gSaveContext.eventInf[1] &= ~1; + CLEAR_EVENTINF_ALT(EVENTINF_10); if (CUR_FORM == 0) { if (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_SWORD_KOKIRI && @@ -35,8 +37,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; } @@ -45,52 +47,52 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.unk_3DC0 = 2000; gSaveContext.save.playerData.tatlTimer = 0; - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.eventInf[0] = 0; 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.unk_3F1E = 0; - gSaveContext.unk_3F20 = 0; - gSaveContext.unk_3F22 = 0; - gSaveContext.unk_3F24 = 0; - Kankyo_InitGameOverLights(globalCtx); + 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.hudVisibilityForceButtonAlphasByStatus = false; + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibilityTimer = 0; + 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); + if (Audio_GetActiveSequence(SEQ_PLAYER_FANFARE) != NA_BGM_GAME_OVER) { + 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); - ShrinkWindow_SetLetterboxTarget(32); + Kankyo_InitGameOverLights(play); + ShrinkWindow_Letterbox_SetSizeTarget(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 +109,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_jpeg.c b/src/code/z_jpeg.c index 7b9254ccd..ad592a40e 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -24,22 +24,22 @@ extern u64 njpgdspMainDataStart[]; */ void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) { static OSTask_t sJpegTask = { - M_NJPEGTASK, // type - 0, // flags - NULL, // ucode_boot - 0, // ucode_boot_size - njpgdspMainTextStart, // ucode - 0x1000, // ucode_size - njpgdspMainDataStart, // ucode_data - 0x800, // ucode_data_size - NULL, // dram_stack - 0, // dram_stack_size - NULL, // output_buff - NULL, // output_buff_size - NULL, // data_ptr - sizeof(JpegTaskData), // data_size - NULL, // yield_data_ptr - 0x200, // yield_data_size + M_NJPEGTASK, // type + 0, // flags + NULL, // ucode_boot + 0, // ucode_boot_size + njpgdspMainTextStart, // ucode + SP_UCODE_SIZE, // ucode_size + njpgdspMainDataStart, // ucode_data + SP_UCODE_DATA_SIZE, // ucode_data_size + NULL, // dram_stack + 0, // dram_stack_size + NULL, // output_buff + NULL, // output_buff_size + NULL, // data_ptr + sizeof(JpegTaskData), // data_size + NULL, // yield_data_ptr + sizeof(jpegCtx->workBuf->yieldData), // yield_data_size }; JpegWork* workBuf = jpegCtx->workBuf; 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..5ab466ddc 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/src/code/z_kaleido_scope_call.c @@ -1,11 +1,13 @@ #include "prevent_bss_reordering.h" #include "global.h" +#include "z64shrink_window.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,38 +21,39 @@ 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 (pauseCtx->state == 1 || pauseCtx->state == 19) { - if (ShrinkWindow_GetLetterboxMagnitude() == 0) { - R_PAUSE_MENU_MODE = 1; - pauseCtx->unk_200 = 0; - pauseCtx->unk_208 = 0; + if ((play->pauseCtx.state != PAUSE_STATE_OFF) || (play->pauseCtx.debugEditor != DEBUG_EDITOR_NONE)) { + if ((pauseCtx->state == PAUSE_STATE_OPENING_0) || (pauseCtx->state == PAUSE_STATE_OWLWARP_0)) { + if (ShrinkWindow_Letterbox_GetSize() == 0) { + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; } - } else if (pauseCtx->state == 8) { - R_PAUSE_MENU_MODE = 1; - pauseCtx->unk_200 = 0; - pauseCtx->unk_208 = 0; + } else if (pauseCtx->state == PAUSE_STATE_GAMEOVER_0) { + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_0; pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; - } else if ((pauseCtx->state == 2) || (pauseCtx->state == 9) || (pauseCtx->state == 20)) { - if (R_PAUSE_MENU_MODE == 3) { + } else if ((pauseCtx->state == PAUSE_STATE_OPENING_1) || (pauseCtx->state == PAUSE_STATE_GAMEOVER_1) || + (pauseCtx->state == PAUSE_STATE_OWLWARP_1)) { + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_DONE) { pauseCtx->state++; } - } else if (pauseCtx->state != 0) { + } else if (pauseCtx->state != PAUSE_STATE_OFF) { if (gKaleidoMgrCurOvl != kaleidoScopeOvl) { if (gKaleidoMgrCurOvl != NULL) { KaleidoManager_ClearOvl(gKaleidoMgrCurOvl); @@ -60,9 +63,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 == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { KaleidoManager_ClearOvl(kaleidoScopeOvl); KaleidoScopeCall_LoadPlayer(); } @@ -71,14 +74,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 (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_DONE) { + if (((play->pauseCtx.state >= PAUSE_STATE_OPENING_3) && (play->pauseCtx.state <= PAUSE_STATE_SAVEPROMPT)) || + ((play->pauseCtx.state >= PAUSE_STATE_GAMEOVER_3) && (play->pauseCtx.state <= PAUSE_STATE_UNPAUSE_SETUP))) { 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..dac0d8300 100644 --- a/src/code/z_kaleido_setup.c +++ b/src/code/z_kaleido_setup.c @@ -1,43 +1,63 @@ #include "global.h" -#include "overlays/gamestates/ovl_file_choose/z_file_choose.h" +#include "z64rumble.h" +#include "z64shrink_window.h" +#include "z64view.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" -s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 }; -f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f }; -f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f }; +s16 sKaleidoSetupRightPageIndex[] = { + PAUSE_MAP, // PAUSE_ITEM + PAUSE_QUEST, // PAUSE_MAP + PAUSE_MASK, // PAUSE_QUEST + PAUSE_ITEM, // PAUSE_MASK +}; +f32 sKaleidoSetupRightPageEyeX[] = { + PAUSE_EYE_DIST * -PAUSE_MAP_X, // PAUSE_ITEM + PAUSE_EYE_DIST * -PAUSE_QUEST_X, // PAUSE_MAP + PAUSE_EYE_DIST * -PAUSE_MASK_X, // PAUSE_QUEST + PAUSE_EYE_DIST * -PAUSE_ITEM_X, // PAUSE_MASK +}; +f32 sKaleidoSetupRightPageEyeZ[] = { + PAUSE_EYE_DIST * -PAUSE_MAP_Z, // PAUSE_ITEM + PAUSE_EYE_DIST * -PAUSE_QUEST_Z, // PAUSE_MAP + PAUSE_EYE_DIST * -PAUSE_MASK_Z, // PAUSE_QUEST + PAUSE_EYE_DIST * -PAUSE_ITEM_Z, // PAUSE_MASK +}; -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; - pauseCtx->eye.x = sKaleidoSetupEyeX[pauseCtx->pageIndex]; - pauseCtx->eye.z = sKaleidoSetupEyeZ[pauseCtx->pageIndex]; - pauseCtx->pageIndex = D_801BDB00[pauseCtx->pageIndex]; - pauseCtx->unk_27E = -40; + pauseCtx->switchPageTimer = 0; + pauseCtx->mainState = PAUSE_MAIN_STATE_SWITCHING_PAGE; + + // Set eye position and pageIndex such that scrolling left brings to the desired page + pauseCtx->eye.x = sKaleidoSetupRightPageEyeX[pauseCtx->pageIndex]; + pauseCtx->eye.z = sKaleidoSetupRightPageEyeZ[pauseCtx->pageIndex]; + pauseCtx->pageIndex = sKaleidoSetupRightPageIndex[pauseCtx->pageIndex]; + pauseCtx->infoPanelOffsetY = -40; for (i = 0; i < ARRAY_COUNT(pauseCtx->worldMapPoints); i++) { - pauseCtx->worldMapPoints[i] = 0; + pauseCtx->worldMapPoints[i] = false; } - if (pauseCtx->state == 1) { - for (i = 0; i < 11; i++) { - if ((gSaveContext.save.mapsVisited >> i) & 1) { - pauseCtx->worldMapPoints[i] = 1; + if (pauseCtx->state == PAUSE_STATE_OPENING_0) { + for (i = 0; i < REGION_MAX; i++) { + if ((gSaveContext.save.regionsVisited >> i) & 1) { + pauseCtx->worldMapPoints[i] = true; } } } else { - for (i = 9; i >= 0; i--) { + for (i = OWL_WARP_STONE_TOWER; i >= OWL_WARP_GREAT_BAY_COAST; i--) { if ((gSaveContext.save.playerData.owlActivationFlags >> i) & 1) { - pauseCtx->worldMapPoints[i] = 1; - pauseCtx->unk_238[4] = i; + pauseCtx->worldMapPoints[i] = true; + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = i; } } if ((gSaveContext.save.playerData.owlActivationFlags >> 4) & 1) { - pauseCtx->unk_238[4] = 4; + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 4; } } @@ -54,42 +74,45 @@ void func_800F4A10(GlobalContext* globalCtx) { YREG(21) = -0x0622; YREG(22) = -0x0C44; YREG(23) = 0x0622; - YREG(24) = -0x0622; - YREG(25) = -0x005A; - YREG(26) = -0x3840; + R_PAUSE_WORLD_MAP_YAW = -0x622; + R_PAUSE_WORLD_MAP_Y_OFFSET = -90; + R_PAUSE_WORLD_MAP_DEPTH = -14400; } -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 == PAUSE_STATE_OFF) && (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 (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) { - if (!(globalCtx->actorCtx.unk5 & 2) && !(globalCtx->actorCtx.unk5 & 4)) { - if ((globalCtx->actorCtx.unk268 == 0) && - CHECK_BTN_ALL(input->press.button, BTN_START)) { - gSaveContext.unk_3F26 = gSaveContext.unk_3F22; - pauseCtx->unk_2B9 = 0; - pauseCtx->state = 1; - func_800F4A10(globalCtx); - pauseCtx->mode = pauseCtx->pageIndex * 2 + 1; + if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) { + if ((play->unk_1887C < 2) && (gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && + (gSaveContext.magicState != MAGIC_STATE_FILL)) { + if (!CHECK_EVENTINF(EVENTINF_17) && !(player->stateFlags1 & PLAYER_STATE1_20)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && + !(play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON)) { + if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) { + gSaveContext.prevHudVisibility = gSaveContext.hudVisibility; + pauseCtx->itemDescriptionOn = false; + pauseCtx->state = PAUSE_STATE_OPENING_0; + func_800F4A10(play); + // Set next page mode to scroll left + pauseCtx->nextPageMode = pauseCtx->pageIndex * 2 + 1; func_801A3A7C(1); } - if (pauseCtx->state == 1) { - Game_SetFramerateDivisor(&globalCtx->state, 2); - if (ShrinkWindow_GetLetterboxTarget() != 0) { - ShrinkWindow_SetLetterboxTarget(0); + if (pauseCtx->state == PAUSE_STATE_OPENING_0) { + Game_SetFramerateDivisor(&play->state, 2); + if (ShrinkWindow_Letterbox_GetSizeTarget() != 0) { + ShrinkWindow_Letterbox_SetSizeTarget(0); } func_801A3AEC(1); } @@ -102,44 +125,44 @@ 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; - pauseCtx->unk_214 = 160.0f; - pauseCtx->unk_210 = 160.0f; + pauseCtx->maskPageRoll = 160.0f; + pauseCtx->questPageRoll = 160.0f; + pauseCtx->mapPageRoll = 160.0f; + pauseCtx->itemPageRoll = 160.0f; pauseCtx->eye.x = -64.0f; pauseCtx->unk_20C = 936.0f; - pauseCtx->unk_220 = -314.0f; + pauseCtx->roll = -314.0f; - pauseCtx->unk_238[PAUSE_1] = XREG(94) + 3; + pauseCtx->cursorPoint[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + (DUNGEON_FLOOR_INDEX_4 - 1); - pauseCtx->unk_258 = 11; - pauseCtx->unk_25A = 0; + pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_RIGHT; + pauseCtx->pageSwitchTimer = 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] = PAUSE_ITEM_NONE; + pauseCtx->cursorItem[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + (DUNGEON_FLOOR_INDEX_4 - 1); + pauseCtx->cursorItem[PAUSE_QUEST] = PAUSE_ITEM_NONE; + pauseCtx->cursorItem[PAUSE_MASK] = PAUSE_ITEM_NONE; - pauseCtx->unk_268[PAUSE_0] = 0; - pauseCtx->unk_268[PAUSE_1] = XREG(94) + 3; + pauseCtx->cursorSlot[PAUSE_ITEM] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + (DUNGEON_FLOOR_INDEX_4 - 1); - pauseCtx->unk_284 = 2; - pauseCtx->unk_2A0 = -1; - pauseCtx->unk_2BA = 320; - pauseCtx->unk_2BC = 40; - pauseCtx->unk_29E = 100; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; + pauseCtx->ocarinaSongIndex = -1; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + pauseCtx->promptAlpha = 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_kankyo.c b/src/code/z_kankyo.c index ad66fe4a1..919abbb1d 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -124,11 +124,11 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FE3E0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FE484.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_StopTime.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FE498.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_StartTime.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FE4A8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/Environment_IsTimeStopped.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_kankyo/func_800FE4B8.s") diff --git a/src/code/z_lib.c b/src/code/z_lib.c index aaf4bc7d9..136918765 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -251,7 +251,7 @@ void func_800FF3A0(f32* distOut, s16* angleOut, Input* input) { if (dist > 0.0f) { x = input->cur.stick_x; y = input->cur.stick_y; - *angleOut = Math_FAtan2F(y, -x); + *angleOut = Math_Atan2S_XY(y, -x); } else { *angleOut = 0; } @@ -420,11 +420,11 @@ f32 Math_Vec3f_DiffY(Vec3f* a, Vec3f* b) { s16 Math_Vec3f_Yaw(Vec3f* a, Vec3f* b) { f32 f14 = b->x - a->x; f32 f12 = b->z - a->z; - return Math_FAtan2F(f12, f14); + return Math_Atan2S_XY(f12, f14); } s16 Math_Vec3f_Pitch(Vec3f* a, Vec3f* b) { - return Math_FAtan2F(Math_Vec3f_DistXZ(a, b), a->y - b->y); + return Math_Atan2S_XY(Math_Vec3f_DistXZ(a, b), a->y - b->y); } void IChain_Apply_u8(u8* ptr, InitChainEntry* ichain); @@ -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; @@ -704,11 +704,29 @@ void* Lib_SegmentedToVirtual(void* ptr) { void* Lib_SegmentedToVirtualNull(void* ptr) { if (((uintptr_t)ptr >> 28) == 0) { return ptr; + } else { + return SEGMENTED_TO_VIRTUAL(ptr); } - - return SEGMENTED_TO_VIRTUAL(ptr); } +/* + * Converts a 32-bit virtual address (0x80XXXXXX) to a 24-bit physical address (0xXXXXXX). The NULL case accounts for + * the NULL virtual address being 0x00000000 and not 0x80000000. Used by transition overlays, which store their + * addresses in 24-bit fields. + */ +void* Lib_VirtualToPhysical(void* ptr) { + if (ptr == NULL) { + return NULL; + } else { + return (void*)VIRTUAL_TO_PHYSICAL(ptr); + } +} + +/* + * Converts a 24-bit physical address (0xXXXXXX) to a 32-bit virtual address (0x80XXXXXX). The NULL case accounts for + * the NULL virtual address being 0x00000000 and not 0x80000000. Used by transition overlays, which store their + * addresses in 24-bit fields. + */ void* Lib_PhysicalToVirtual(void* ptr) { if (ptr == NULL) { return NULL; @@ -716,11 +734,3 @@ void* Lib_PhysicalToVirtual(void* ptr) { return (void*)PHYSICAL_TO_VIRTUAL(ptr); } } - -void* Lib_PhysicalToVirtualNull(void* ptr) { - if (ptr == NULL) { - return NULL; - } else { - return (void*)PHYSICAL_TO_VIRTUAL(ptr); - } -} diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index 73ba326b5..b123baab6 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,10 +33,10 @@ TexturePtr HeartDDTextures[] = { gDefenseHeartThreeQuarterTex, }; -void LifeMeter_Init(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void LifeMeter_Init(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; - interfaceCtx->unkTimer = 320; + interfaceCtx->healthTimer = 320; interfaceCtx->health = gSaveContext.save.playerData.health; @@ -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,42 +167,47 @@ void LifeMeter_UpdateColors(GlobalContext* globalCtx) { sBeatingHeartsDDEnv[2] = (u8)(bFactor + 0) & 0xFF; } -s32 LifeMeter_SaveInterfaceHealth(GlobalContext* globalCtx) { - gSaveContext.save.playerData.health = globalCtx->interfaceCtx.health; +// Unused +s32 LifeMeter_SaveInterfaceHealth(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + gSaveContext.save.playerData.health = interfaceCtx->health; return 1; } -s32 LifeMeter_IncreaseInterfaceHealth(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +// Unused +s32 LifeMeter_IncreaseInterfaceHealth(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; - interfaceCtx->unkTimer = 320; + interfaceCtx->healthTimer = 320; interfaceCtx->health += 0x10; - if (globalCtx->interfaceCtx.health >= gSaveContext.save.playerData.health) { - globalCtx->interfaceCtx.health = gSaveContext.save.playerData.health; - return 1; + if (play->interfaceCtx.health >= gSaveContext.save.playerData.health) { + play->interfaceCtx.health = gSaveContext.save.playerData.health; + return true; } - return 0; + return false; } -s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +// Unused +s32 LifeMeter_DecreaseInterfaceHealth(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; - if (interfaceCtx->unkTimer != 0) { - interfaceCtx->unkTimer--; + if (interfaceCtx->healthTimer != 0) { + interfaceCtx->healthTimer--; } else { - interfaceCtx->unkTimer = 320; + interfaceCtx->healthTimer = 320; interfaceCtx->health -= 0x10; if (interfaceCtx->health <= 0) { interfaceCtx->health = 0; - globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.save.playerData.health) + 1)); - return 1; + play->damagePlayer(play, -(((void)0, gSaveContext.save.playerData.health) + 1)); + return true; } } - return 0; + return false; } -void LifeMeter_Draw(GlobalContext* globalCtx) { +void LifeMeter_Draw(PlayState* play) { s32 pad[5]; TexturePtr heartTex; s32 curColorSet; @@ -213,8 +218,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,13 +228,14 @@ 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); if ((gSaveContext.save.playerData.health % 0x10) == 0) { fullHeartCount--; } + offsetY = 0.0f; offsetX = 0.0f; curColorSet = -1; @@ -376,12 +382,13 @@ void LifeMeter_Draw(GlobalContext* globalCtx) { } } mtx = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); - func_801780F0(mtx, 1.0f - (0.32f * lifesize), 1.0f - (0.32f * lifesize), 1.0f - (0.32f * lifesize), - -130.0f + offsetX, 94.5f - offsetY, 0.0f); + Mtx_SetTranslateScaleMtx(mtx, 1.0f - (0.32f * lifesize), 1.0f - (0.32f * lifesize), + 1.0f - (0.32f * lifesize), -130.0f + offsetX, 94.5f - offsetY, 0.0f); gSPMatrix(OVERLAY_DISP++, mtx, G_MTX_LOAD | G_MTX_MODELVIEW); gSPVertex(OVERLAY_DISP++, beatingHeartVtx, 4, 0); gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); } + offsetX += 10.0f; if (i == 9) { offsetY += 10.0f; @@ -391,16 +398,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 == PAUSE_STATE_OFF) && + (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && LifeMeter_IsCritical() && !Play_InCsMode(play)) { play_sound(NA_SE_SY_HITPOINT_ALARM); } } @@ -416,16 +423,14 @@ void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) { u32 LifeMeter_IsCritical(void) { s16 criticalThreshold; - if (gSaveContext.save.playerData.healthCapacity <= 80) { // healthCapacity <= 5 hearts? - criticalThreshold = 16; - - } else if (gSaveContext.save.playerData.healthCapacity <= 160) { // healthCapacity <= 10 hearts? - criticalThreshold = 24; - - } else if (gSaveContext.save.playerData.healthCapacity <= 240) { // healthCapacity <= 15 hearts? - criticalThreshold = 32; + if (gSaveContext.save.playerData.healthCapacity <= 0x50) { + criticalThreshold = 0x10; + } else if (gSaveContext.save.playerData.healthCapacity <= 0xA0) { + criticalThreshold = 0x18; + } 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 e9fae530a..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 { @@ -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); @@ -434,8 +434,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { 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..ac78d1229 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 sDungeonAndBossSceneIds[] = { + 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(sDungeonAndBossSceneIds); i++) { + if (Play_GetOriginalSceneId(play->sceneId) == sDungeonAndBossSceneIds[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 sDungeonSceneIds[] = { + 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(sDungeonSceneIds); i++) { + if (Play_GetOriginalSceneId(play->sceneId) == sDungeonSceneIds[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 sBossSceneIds[] = { + 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(sBossSceneIds); i++) { + if (Play_GetOriginalSceneId(play->sceneId) == sBossSceneIds[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_GetOriginalSceneId(play->sceneId) == 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_GetOriginalSceneId(play->sceneId)].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(PlayState* play) { + func_80105A40(play); +} + +void Map_Init(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s32 dungeonIndex; + + func_80105C40(play->roomCtx.curRoom.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->sceneId) { + 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.curRoom.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 <= PAUSE_STATE_OPENING_2) && (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 == PAUSE_STATE_OFF) && (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_GetOriginalSceneId(play->sceneId)].unk_14 |= + gBitFlags[FLOOR_INDEX_MAX - floor]; + R_REVERSE_FLOOR_INDEX = FLOOR_INDEX_MAX - floor; + if (interfaceCtx->mapRoomNum != sLastRoomNum) { + sLastRoomNum = interfaceCtx->mapRoomNum; + } + } + } else if (Map_IsInBossArea(play)) { + func_80105294(); + R_REVERSE_FLOOR_INDEX = FLOOR_INDEX_MAX - func_80105318(); + } + } +} diff --git a/src/code/z_message.c b/src/code/z_message.c index 2a90f38ca..e3eb9839d 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1,5 +1,8 @@ #include "global.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "message_data_static.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" #if 0 @@ -42,8 +45,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 +68,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 +87,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 +99,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 +117,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 +150,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 +159,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 +176,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 +212,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 +226,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 +256,38 @@ 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[OWL_WARP_MAX][9]; +extern s16 D_801D0250[OWL_WARP_MAX]; -void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) { - f32 sp3C; - s16 temp_s0; - s16 temp_s1; - s16 temp_s1_2; - s16 temp_s6; - s32 temp_s2; - s32 temp_s2_2; - u16* temp_v0; - s16 phi_v0; +void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) { + MessageContext* msgCtx = &play->msgCtx; + PauseContext* pauseCtx = &play->pauseCtx; + s16 stringLimit; + s16 temp_s1 = *arg3; + s32 temp_s2 = *arg1; + f32 sp3C = *arg2; + s16 owlWarpId; s16 phi_s0; - s16 phi_s1; - s32 phi_s2; - s16 phi_s1_2; - s32 phi_s2_2; - temp_s1 = *arg3; - temp_s2 = *arg1; - sp3C = *arg2; - if ((func_8010A0A4(arg0) != 0) || (arg0->sceneNum == 0x4F)) { - phi_v0 = 0xA; + if (func_8010A0A4(play) || (play->sceneId == SCENE_SECOM)) { + owlWarpId = OWL_WARP_ENTRANCE; } else { - phi_v0 = arg0->pauseCtx.unk_238[4]; + owlWarpId = pauseCtx->cursorPoint[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); + stringLimit = D_801D0250[owlWarpId]; + + for (phi_s0 = 0; phi_s0 < stringLimit; phi_s0++, temp_s1++, temp_s2 += 0x80) { + msgCtx->decodedBuffer.wchar[temp_s1] = D_801D0188[owlWarpId][phi_s0]; + Font_LoadChar(play, D_801D0188[owlWarpId][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 += (stringLimit - 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 +297,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, DO_ACTION_NEXT); } else if (textId != 0xF8) { - func_8011552C(globalCtx, 6); + func_8011552C(play, DO_ACTION_DECIDE); } } msgCtx->unk1203C = msgCtx->unk1203A; - if (globalCtx->pauseCtx.unk_1F0 != 0) { + if (play->pauseCtx.bombersNotebookOpen) { 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; @@ -382,29 +361,29 @@ void func_80151A68(GlobalContext* globalCtx, u16 textId) { XREG(77) = 0x3C; XREG(76) = 0x1C; msgCtx->unk11F1A[0] = msgCtx->unk11F1A[1] = msgCtx->unk11F1A[2] = 0; - Interface_ChangeAlpha(1); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); } } -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)) { - if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + if (!CHECK_WEEKEVENTREG(D_801C6B28[arg1])) { msgCtx->unk120B2[msgCtx->unk120B1] = temp; msgCtx->unk120B1++; } } else if (arg1 >= 20) { - if ((gSaveContext.save.weekEventReg[D_801C6B28[arg1] >> 8] & (u8)D_801C6B28[arg1]) == 0) { + if (!CHECK_WEEKEVENTREG(D_801C6B28[arg1])) { msgCtx->unk120B2[msgCtx->unk120B1] = temp; msgCtx->unk120B1++; } } } -u32 func_80151C9C(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +u32 func_80151C9C(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; while (true) { if (msgCtx->unk120B1 == 0) { @@ -412,14 +391,11 @@ u32 func_80151C9C(GlobalContext* globalCtx) { } msgCtx->unk120B1--; - if ((gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] & - (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]) == 0) { - gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8] = - ((void)0, gSaveContext.save.weekEventReg[D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]] >> 8]) | - (u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]]; + if (!CHECK_WEEKEVENTREG(D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]])) { + SET_WEEKEVENTREG(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 true; } @@ -429,43 +405,109 @@ 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") void func_80152C64(View* view) { SET_FULLSCREEN_VIEWPORT(view); - func_8013FBC8(view); + View_ApplyOrthoToOverlay(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 +515,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 +553,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 485f016ff..759c3d611 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 @@ -16,34 +17,46 @@ u8 D_801D06F0[4][8] = { { "rupee(s)" }, //EN // rupeesTextLength u8 D_801D0710[4] = {8,8,5,8}; -//TextArea -char D_801D0714[11][16] = { - "Great Bay Coast", - "Zora Cape", - "Snowhead", - "Mountain Village", - "Clock Town", - "Milk Road", - "Woodfall", - "Southern Swamp", - "Ikana Canyon", - "Stone Tower", - "Entrance" - }; +// sOwlWarpText +char D_801D0714[OWL_WARP_MAX][16] = { + "Great Bay Coast", // OWL_WARP_GREAT_BAY_COAST + "Zora Cape", // OWL_WARP_ZORA_CAPE + "Snowhead", // OWL_WARP_SNOWHEAD + "Mountain Village", // OWL_WARP_MOUNTAIN_VILLAGE + "Clock Town", // OWL_WARP_CLOCK_TOWN + "Milk Road", // OWL_WARP_MILK_ROAD + "Woodfall", // OWL_WARP_WOODFALL + "Southern Swamp", // OWL_WARP_SOUTHERN_SWAMP + "Ikana Canyon", // OWL_WARP_IKANA_CANYON + "Stone Tower", // OWL_WARP_STONE_TOWER + "Entrance", // OWL_WARP_ENTRANCE +}; -//TextAreaLength -s16 D_801D07C4[11] = {15,9,8,16,10,9,8,14,12,11,8}; +// sOwlWarpTextLength +s16 D_801D07C4[OWL_WARP_MAX] = { + 15, // OWL_WARP_GREAT_BAY_COAST + 9, // OWL_WARP_ZORA_CAPE + 8, // OWL_WARP_SNOWHEAD + 16, // OWL_WARP_MOUNTAIN_VILLAGE + 10, // OWL_WARP_CLOCK_TOWN + 9, // OWL_WARP_MILK_ROAD + 8, // OWL_WARP_WOODFALL + 14, // OWL_WARP_SOUTHERN_SWAMP + 12, // OWL_WARP_IKANA_CANYON + 11, // OWL_WARP_STONE_TOWER + 8, // OWL_WARP_ENTRANCE +}; #endif extern f32 D_801D0470[159]; extern u8 D_801D06F0[4][8]; extern u8 D_801D0710[4]; -extern u8 D_801D0714[11][16]; -extern s16 D_801D07C4[11]; +extern u8 D_801D0714[OWL_WARP_MAX][16]; +extern s16 D_801D07C4[OWL_WARP_MAX]; -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 +83,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 +96,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 +134,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 +145,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 +158,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,8 +201,8 @@ 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; @@ -199,13 +212,9 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar s16 i; if (arg1 == 0xCF) { - // Calculates the time left before the moon crashes. - // The day begins at CLOCK_TIME(6, 0) so it must be offset. - timeLeft = (4 - CURRENT_DAY) * DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); + timeLeft = TIME_UNTIL_MOON_CRASH; } else { - // Calculates the time left before a new day. - // The day begins at CLOCK_TIME(6, 0) so it must be offset. - timeLeft = DAY_LENGTH - (u16)(((void)0, gSaveContext.save.time) - CLOCK_TIME(6, 0)); + timeLeft = TIME_UNTIL_NEW_DAY; } timeLeftInMinutes = TIME_TO_MINUTES_F(timeLeft); @@ -225,12 +234,12 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar } 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++; @@ -243,28 +252,28 @@ 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_LoadOwlWarpTextNES(PlayState* play, s32* offset, f32* arg2, s16* decodedBufPos) { + MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; s32 o = *offset; f32 f = *arg2; s16 i; u8 currentChar; - s16 currentArea; + s16 owlWarpId; s16 stringLimit; - if ((func_8010A0A4(globalCtx) != 0) || (globalCtx->sceneNum == SCENE_SECOM)) { - currentArea = 10; + if (func_8010A0A4(play) || (play->sceneId == SCENE_SECOM)) { + owlWarpId = OWL_WARP_ENTRANCE; } else { - currentArea = globalCtx->pauseCtx.unk_238[4]; + owlWarpId = play->pauseCtx.cursorPoint[PAUSE_WORLD_MAP]; } - stringLimit = D_801D07C4[currentArea]; + stringLimit = D_801D07C4[owlWarpId]; for (i = 0; i < stringLimit; i++) { - msgCtx->decodedBuffer.schar[p] = D_801D0714[currentArea][i]; + msgCtx->decodedBuffer.schar[p] = D_801D0714[owlWarpId][i]; currentChar = msgCtx->decodedBuffer.schar[p]; if (currentChar != ' ') { - Font_LoadCharNES(globalCtx, D_801D0714[currentArea][i], o); + Font_LoadCharNES(play, D_801D0714[owlWarpId][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..2c8c8d6d7 100644 --- a/src/code/z_overlay.c +++ b/src/code/z_overlay.c @@ -1,13 +1,103 @@ +/** + * @file z_overlay.c + * + * Functions for handling transition overlays in memory + * + * Status codes returned from TransitionOverlay_Load and TransitionOverlay_Free: + * + * -1 : failed allocation or null reference + * 0 : successfully loaded/freed overlay + * 1 : successfully added/removed instance + * 2 : overlay is loaded but has no instances (?) TODO: Figure out why this exists + * 3 : internal overlay, so always loaded + */ + #include "global.h" +#include "z64load.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_801651B0.s") +void* TransitionOverlay_VramToRam(TransitionOverlay* overlayEntry, void* vramAddr) { + void* loadedRamAddr = Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_80165224.s") + if ((loadedRamAddr != NULL) && (vramAddr >= overlayEntry->vramStart) && (vramAddr < overlayEntry->vramEnd)) { + return ((uintptr_t)loadedRamAddr - (uintptr_t)overlayEntry->vramStart) + (uintptr_t)vramAddr; + } + return vramAddr; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_80165288.s") +void TransitionOverlay_VramToRamArray(TransitionOverlay* overlayEntry, void** vramAddrs, s32 count) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_8016537C.s") + for (i = 0; i < count; i++) { + vramAddrs[i] = TransitionOverlay_VramToRam(overlayEntry, vramAddrs[i]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_80165438.s") +s32 TransitionOverlay_Load(TransitionOverlay* overlayEntry) { + s32 count; + void* loadedRamAddr; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_overlay/func_80165444.s") + if (overlayEntry->vromStart == 0) { + return 3; + } + if (Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr) == NULL) { + loadedRamAddr = ZeldaArena_Malloc(VRAM_PTR_SIZE(overlayEntry)); + + if (loadedRamAddr == NULL) { + return -1; + } + Load2_LoadOverlay(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, + overlayEntry->vramEnd, loadedRamAddr); + overlayEntry->loadInfo.addr = Lib_VirtualToPhysical(loadedRamAddr); + overlayEntry->loadInfo.count = 1; + return 0; + } else { + count = overlayEntry->loadInfo.count; + if (count != 0) { + count++; + overlayEntry->loadInfo.count = count; + if (count == 0) { + return 2; + } else { + return 1; + } + } + return 2; + } +} + +s32 TransitionOverlay_Free(TransitionOverlay* overlayEntry) { + s32 count; + void* loadedRamAddr; + + if (overlayEntry->vromStart == 0) { + return 3; + } + loadedRamAddr = Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr); + if (loadedRamAddr != NULL) { + count = overlayEntry->loadInfo.count; + if (count != 0) { + count--; + overlayEntry->loadInfo.count = count; + if (count == 0) { + ZeldaArena_Free(loadedRamAddr); + overlayEntry->loadInfo.addr = Lib_VirtualToPhysical(NULL); + return 0; + } + return 1; + } + return 2; + } + return -1; +} + +void TransitionOverlay_ClearLoadInfo(TransitionOverlay* overlayEntry) { + overlayEntry->loadInfo.word = 0; // Equivalent to overlayEntry->loadInfo.count = 0, overlayEntry->loadInfo.addr = 0; +} + +void TransitionOverlay_SetSegment(TransitionOverlay* overlayEntry, void* vramStart, void* vramEnd, uintptr_t vromStart, + uintptr_t vromEnd) { + overlayEntry->vramStart = vramStart; + overlayEntry->vramEnd = vramEnd; + overlayEntry->vromStart = vromStart; + overlayEntry->vromEnd = vromEnd; +} diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 44b1de152..cd4ffa67f 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,89 +1,2576 @@ #include "global.h" +#include "z64view.h" +#include "interface/parameter_static/parameter_static.h" +#include "interface/do_action_static/do_action_static.h" +#include "misc/story_static/story_static.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010CB80.s") +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" +#include "overlays/actors/ovl_En_Mm3/z_en_mm3.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010CD98.s") +typedef enum { + /* 0 */ PICTO_BOX_STATE_OFF, // Not using the pictograph + /* 1 */ PICTO_BOX_STATE_LENS, // Looking through the lens of the pictograph + /* 2 */ PICTO_BOX_STATE_SETUP_PHOTO, // Looking at the photo currently taken + /* 3 */ PICTO_BOX_STATE_PHOTO +} PictoBoxState; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010CFBC.s") +typedef struct { + /* 0x00 */ u8 scene; + /* 0x01 */ u8 flags1; + /* 0x02 */ u8 flags2; + /* 0x03 */ u8 flags3; +} RestrictionFlags; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010D2D4.s") +Input sPostmanTimerInput[4]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010D480.s") +#define RESTRICTIONS_TABLE_END 0xFF -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010D7D0.s") +#define RESTRICTIONS_GET_BITS(flags, s) (((flags) & (3 << (s))) >> (s)) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010D9F4.s") +// does nothing +#define RESTRICTIONS_GET_HGAUGE(flags) RESTRICTIONS_GET_BITS((flags)->flags1, 6) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_B_BUTTON(flags) RESTRICTIONS_GET_BITS((flags)->flags1, 4) +// does nothing +#define RESTRICTIONS_GET_A_BUTTON(flags) RESTRICTIONS_GET_BITS((flags)->flags1, 2) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_TRADE_ITEMS(flags) RESTRICTIONS_GET_BITS((flags)->flags1, 0) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_SONG_OF_TIME(flags) RESTRICTIONS_GET_BITS((flags)->flags2, 6) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_SONG_OF_DOUBLE_TIME(flags) RESTRICTIONS_GET_BITS((flags)->flags2, 4) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_INV_SONG_OF_TIME(flags) RESTRICTIONS_GET_BITS((flags)->flags2, 2) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_SONG_OF_SOARING(flags) RESTRICTIONS_GET_BITS((flags)->flags2, 0) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_SONG_OF_STORMS(flags) RESTRICTIONS_GET_BITS((flags)->flags3, 6) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_MASKS(flags) RESTRICTIONS_GET_BITS((flags)->flags3, 4) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_PICTO_BOX(flags) RESTRICTIONS_GET_BITS((flags)->flags3, 2) +// 0 = usable, !0 = unusable +#define RESTRICTIONS_GET_ALL(flags) RESTRICTIONS_GET_BITS((flags)->flags3, 0) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010DC58.s") +#define RESTRICTIONS_SET(hGauge, bButton, aButton, tradeItems, songOfTime, songOfDoubleTime, invSongOfTime, \ + songOfSoaring, songOfStorms, masks, pictoBox, all) \ + ((((hGauge)&3) << 6) | (((bButton)&3) << 4) | (((aButton)&3) << 2) | (((tradeItems)&3) << 0)), \ + ((((songOfTime)&3) << 6) | (((songOfDoubleTime)&3) << 4) | (((invSongOfTime)&3) << 2) | \ + (((songOfSoaring)&3) << 0)), \ + ((((songOfStorms)&3) << 6) | (((masks)&3) << 4) | (((pictoBox)&3) << 2) | (((all)&3) << 0)) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010DE38.s") +// Common patterns +#define RESTRICTIONS_NONE RESTRICTIONS_SET(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) +#define RESTRICTIONS_INDOORS RESTRICTIONS_SET(0, 1, 0, 0, 0, 3, 0, 0, 3, 0, 0, 1) +#define RESTRICTIONS_MOON RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0) +#define RESTRICTIONS_NO_DOUBLE_TIME RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0) -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E028.s") +RestrictionFlags sRestrictionFlags[] = { + { SCENE_20SICHITAI2, RESTRICTIONS_NONE }, + { SCENE_UNSET_1, RESTRICTIONS_NONE }, + { SCENE_UNSET_2, RESTRICTIONS_NONE }, + { SCENE_UNSET_3, RESTRICTIONS_NONE }, + { SCENE_UNSET_4, RESTRICTIONS_NONE }, + { SCENE_UNSET_5, RESTRICTIONS_NONE }, + { SCENE_UNSET_6, RESTRICTIONS_NONE }, + { SCENE_KAKUSIANA, RESTRICTIONS_NONE }, + { SCENE_SPOT00, RESTRICTIONS_NONE }, + { SCENE_UNSET_9, RESTRICTIONS_NONE }, + { SCENE_WITCH_SHOP, RESTRICTIONS_INDOORS }, + { SCENE_LAST_BS, RESTRICTIONS_MOON }, + { SCENE_HAKASHITA, RESTRICTIONS_NONE }, + { SCENE_AYASHIISHOP, RESTRICTIONS_INDOORS }, + { SCENE_UNSET_E, RESTRICTIONS_NONE }, + { SCENE_UNSET_F, RESTRICTIONS_NONE }, + { SCENE_OMOYA, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 3, 0, 0, 0, 0) }, + { SCENE_BOWLING, RESTRICTIONS_INDOORS }, + { SCENE_SONCHONOIE, RESTRICTIONS_INDOORS }, + { SCENE_IKANA, RESTRICTIONS_NONE }, + { SCENE_KAIZOKU, RESTRICTIONS_NONE }, + { SCENE_MILK_BAR, RESTRICTIONS_INDOORS }, + { SCENE_INISIE_N, RESTRICTIONS_NONE }, + { SCENE_TAKARAYA, RESTRICTIONS_INDOORS }, + { SCENE_INISIE_R, RESTRICTIONS_NONE }, + { SCENE_OKUJOU, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0) }, + { SCENE_OPENINGDAN, RESTRICTIONS_NONE }, + { SCENE_MITURIN, RESTRICTIONS_NONE }, + { SCENE_13HUBUKINOMITI, RESTRICTIONS_NONE }, + { SCENE_CASTLE, RESTRICTIONS_NONE }, + { SCENE_DEKUTES, RESTRICTIONS_SET(0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1) }, + { SCENE_MITURIN_BS, RESTRICTIONS_NONE }, + { SCENE_SYATEKI_MIZU, RESTRICTIONS_INDOORS }, + { SCENE_HAKUGIN, RESTRICTIONS_NONE }, + { SCENE_ROMANYMAE, RESTRICTIONS_NONE }, + { SCENE_PIRATE, RESTRICTIONS_NONE }, + { SCENE_SYATEKI_MORI, RESTRICTIONS_INDOORS }, + { SCENE_SINKAI, RESTRICTIONS_NONE }, + { SCENE_YOUSEI_IZUMI, RESTRICTIONS_NONE }, + { SCENE_KINSTA1, RESTRICTIONS_NO_DOUBLE_TIME }, + { SCENE_KINDAN2, RESTRICTIONS_NO_DOUBLE_TIME }, + { SCENE_TENMON_DAI, RESTRICTIONS_SET(0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0) }, + { SCENE_LAST_DEKU, RESTRICTIONS_MOON }, + { SCENE_22DEKUCITY, RESTRICTIONS_NONE }, + { SCENE_KAJIYA, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 0) }, + { SCENE_00KEIKOKU, RESTRICTIONS_NONE }, + { SCENE_POSTHOUSE, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 1) }, + { SCENE_LABO, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 1) }, + { SCENE_DANPEI2TEST, RESTRICTIONS_NO_DOUBLE_TIME }, + { SCENE_UNSET_31, RESTRICTIONS_NONE }, + { SCENE_16GORON_HOUSE, RESTRICTIONS_NONE }, + { SCENE_33ZORACITY, RESTRICTIONS_SET(0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0) }, + { SCENE_8ITEMSHOP, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 1) }, + { SCENE_F01, RESTRICTIONS_NONE }, + { SCENE_INISIE_BS, RESTRICTIONS_NONE }, + { SCENE_30GYOSON, RESTRICTIONS_NONE }, + { SCENE_31MISAKI, RESTRICTIONS_NONE }, + { SCENE_TAKARAKUJI, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 1) }, + { SCENE_UNSET_3A, RESTRICTIONS_NONE }, + { SCENE_TORIDE, RESTRICTIONS_NONE }, + { SCENE_FISHERMAN, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 1) }, + { SCENE_GORONSHOP, RESTRICTIONS_INDOORS }, + { SCENE_DEKU_KING, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 0) }, + { SCENE_LAST_GORON, RESTRICTIONS_MOON }, + { SCENE_24KEMONOMITI, RESTRICTIONS_NONE }, + { SCENE_F01_B, RESTRICTIONS_NO_DOUBLE_TIME }, + { SCENE_F01C, RESTRICTIONS_NO_DOUBLE_TIME }, + { SCENE_BOTI, RESTRICTIONS_NONE }, + { SCENE_HAKUGIN_BS, RESTRICTIONS_NONE }, + { SCENE_20SICHITAI, RESTRICTIONS_NONE }, + { SCENE_21MITURINMAE, RESTRICTIONS_NONE }, + { SCENE_LAST_ZORA, RESTRICTIONS_MOON }, + { SCENE_11GORONNOSATO2, RESTRICTIONS_NONE }, + { SCENE_SEA, RESTRICTIONS_NONE }, + { SCENE_35TAKI, RESTRICTIONS_NONE }, + { SCENE_REDEAD, RESTRICTIONS_NONE }, + { SCENE_BANDROOM, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 0) }, + { SCENE_11GORONNOSATO, RESTRICTIONS_NONE }, + { SCENE_GORON_HAKA, RESTRICTIONS_NONE }, + { SCENE_SECOM, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 3, 0, 3, 0, 0, 0) }, + { SCENE_10YUKIYAMANOMURA, RESTRICTIONS_NONE }, + { SCENE_TOUGITES, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0) }, + { SCENE_DANPEI, RESTRICTIONS_NO_DOUBLE_TIME }, + { SCENE_IKANAMAE, RESTRICTIONS_NONE }, + { SCENE_DOUJOU, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 1) }, + { SCENE_MUSICHOUSE, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 0) }, + { SCENE_IKNINSIDE, RESTRICTIONS_SET(0, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0) }, + { SCENE_MAP_SHOP, RESTRICTIONS_INDOORS }, + { SCENE_F40, RESTRICTIONS_NONE }, + { SCENE_F41, RESTRICTIONS_NONE }, + { SCENE_10YUKIYAMANOMURA2, RESTRICTIONS_NONE }, + { SCENE_14YUKIDAMANOMITI, RESTRICTIONS_NONE }, + { SCENE_12HAKUGINMAE, RESTRICTIONS_NONE }, + { SCENE_17SETUGEN, RESTRICTIONS_NONE }, + { SCENE_17SETUGEN2, RESTRICTIONS_NONE }, + { SCENE_SEA_BS, RESTRICTIONS_NONE }, + { SCENE_RANDOM, RESTRICTIONS_NONE }, + { SCENE_YADOYA, RESTRICTIONS_INDOORS }, + { SCENE_KONPEKI_ENT, RESTRICTIONS_NONE }, + { SCENE_INSIDETOWER, RESTRICTIONS_SET(0, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0) }, + { SCENE_26SARUNOMORI, RESTRICTIONS_NO_DOUBLE_TIME }, + { SCENE_LOST_WOODS, RESTRICTIONS_NONE }, + { SCENE_LAST_LINK, RESTRICTIONS_MOON }, + { SCENE_SOUGEN, RESTRICTIONS_MOON }, + { SCENE_BOMYA, RESTRICTIONS_INDOORS }, + { SCENE_KYOJINNOMA, RESTRICTIONS_NONE }, + { SCENE_KOEPONARACE, RESTRICTIONS_NO_DOUBLE_TIME }, + { SCENE_GORONRACE, RESTRICTIONS_NONE }, + { SCENE_TOWN, RESTRICTIONS_NONE }, + { SCENE_ICHIBA, RESTRICTIONS_NONE }, + { SCENE_BACKTOWN, RESTRICTIONS_NONE }, + { SCENE_CLOCKTOWER, RESTRICTIONS_NONE }, + { SCENE_ALLEY, RESTRICTIONS_NONE }, + // { RESTRICTIONS_TABLE_END, RESTRICTIONS_NONE }, // See note below +}; +//! @note: in `Interface_SetSceneRestrictions`, `RESTRICTIONS_TABLE_END` act as a terminating value to +// stop looping through the array. If a scene is missing, then this will cause issues. -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E968.s") +s16 sPictoState = PICTO_BOX_STATE_OFF; +s16 sPictoPhotoBeingTaken = false; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010E9F0.s") +s16 sHBAScoreTier = 0; // Remnant of OoT, non-functional -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EA9C.s") +u16 sMinigameScoreDigits[] = { 0, 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EB50.s") +u16 sCUpInvisible = 0; +u16 sCUpTimer = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EBA0.s") +s16 sMagicMeterOutlinePrimRed = 255; +s16 sMagicMeterOutlinePrimGreen = 255; +s16 sMagicMeterOutlinePrimBlue = 255; +s16 sMagicBorderRatio = 2; +s16 sMagicBorderStep = 1; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EC54.s") +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 +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EE74.s") +s16 sEnvHazard = PLAYER_ENV_HAZARD_NONE; +s16 sEnvTimerActive = false; +s16 sPostmanBunnyHoodState = POSTMAN_MINIGAME_BUNNY_HOOD_OFF; +OSTime sTimerPausedOsTime = 0; +OSTime sBottleTimerPausedOsTime = 0; +OSTime D_801BF8F8[] = { + 0, 0, 0, 0, 0, 0, 0, +}; +OSTime D_801BF930[] = { + 0, 0, 0, 0, 0, 0, 0, +}; +u8 sIsTimerPaused = false; +u8 sIsBottleTimerPaused = false; +s16 sTimerId = TIMER_ID_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_ChangeAlpha.s") +s16 D_801BF974 = 0; +s16 D_801BF978 = 10; +s16 D_801BF97C = 255; +f32 D_801BF980 = 1.0f; +s32 D_801BF984 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010EF9C.s") +Gfx sScreenFillSetupDL[] = { + 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(), +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010F0D4.s") +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 }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8010F1A8.s") +s16 sFinalHoursClockDigitsRed = 0; +s16 sFinalHoursClockFrameEnvRed = 0; +s16 sFinalHoursClockFrameEnvGreen = 0; +s16 sFinalHoursClockFrameEnvBlue = 0; +s16 sFinalHoursClockColorTimer = 15; +s16 sFinalHoursClockColorTargetIndex = 0; + +/** + * Draw a RGBA16 texture on a rectangle + * + * @param gfx the display list pointer + * @param texture + * @param textureWidth texture image width in texels + * @param textureHeight texture image height in texels + * @param rectLeft the x-coordinate of upper-left corner of rectangle + * @param rectTop the y-coordinate of upper-left corner of rectangle + * @param rectWidth rectangle width in texels + * @param rectHeight rectangle height in texels + * @param dsdx the change in s for each change in x (s5.10) + * @param dtdy the change in t for each change in y (s5.10) + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawTexRectRGBA16(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, + s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy) { + gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_RGBA, G_IM_SIZ_16b, textureWidth, textureHeight, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, + G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + + return gfx; +} + +/** + * Draw an IA8 texture on a rectangle + * + * @param gfx the display list pointer + * @param texture + * @param textureWidth texture image width in texels + * @param textureHeight texture image height in texels + * @param rectLeft the x-coordinate of upper-left corner of rectangle + * @param rectTop the y-coordinate of upper-left corner of rectangle + * @param rectWidth rectangle width in texels + * @param rectHeight rectangle height in texels + * @param dsdx the change in s for each change in x (s5.10) + * @param dtdy the change in t for each change in y (s5.10) + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawTexRectIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, + s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy) { + gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, textureWidth, textureHeight, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, + G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + + return gfx; +} + +/** + * Draw an IA8 texture on a rectangle with a shadow slightly offset to the bottom-right + * + * @param gfx the display list pointer + * @param texture + * @param textureWidth texture image width in texels + * @param textureHeight texture image height in texels + * @param rectLeft the x-coordinate of upper-left corner of rectangle + * @param rectTop the y-coordinate of upper-left corner of rectangle + * @param rectWidth rectangle width in texels + * @param rectHeight rectangle height in texels + * @param dsdx the change in s for each change in x (s5.10) + * @param dtdy the change in t for each change in y (s5.10) + * @param r texture red + * @param g texture green + * @param b texture blue + * @param a texture alpha + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawTexRectIA8_DropShadow(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, + s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, s16 r, s16 g, s16 b, + s16 a) { + s16 dropShadowAlpha = a; + + if (a > 100) { + dropShadowAlpha = 100; + } + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, dropShadowAlpha); + + gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, textureWidth, textureHeight, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSPTextureRectangle(gfx++, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, + (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); + + gSPTextureRectangle(gfx++, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, + G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + + return gfx; +} + +/** + * Draw a colored rectangle with a shadow slightly offset to the bottom-right + * + * @param gfx the display list pointer + * @param rectLeft the x-coordinate of upper-left corner of rectangle + * @param rectTop the y-coordinate of upper-left corner of rectangle + * @param rectWidth rectangle width in texels + * @param rectHeight rectangle height in texels + * @param dsdx the change in s for each change in x (s5.10) + * @param dtdy the change in t for each change in y (s5.10) + * @param r // rectangle red + * @param g // rectangle green + * @param b // rectangle blue + * @param a // rectangle alpha + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawRect_DropShadow(Gfx* gfx, s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, + s16 r, s16 g, s16 b, s16 a) { + s16 dropShadowAlpha = a; + + if (a > 100) { + dropShadowAlpha = 100; + } + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, dropShadowAlpha); + gSPTextureRectangle(gfx++, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, + (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); + + gSPTextureRectangle(gfx++, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, + G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + + return gfx; +} + +/** + * Draw an IA8 texture on a rectangle with a shadow slightly offset to the bottom-right with additional texture offsets + * + * @param gfx the display list pointer + * @param texture + * @param textureWidth texture image width in texels + * @param textureHeight texture image height in texels + * @param rectLeft the x-coordinate of upper-left corner of rectangle + * @param rectTop the y-coordinate of upper-left corner of rectangle + * @param rectWidth rectangle width in texels + * @param rectHeight rectangle height in texels + * @param dsdx the change in s for each change in x (s5.10) + * @param dtdy the change in t for each change in y (s5.10) + * @param r // texture red + * @param g // texture green + * @param b // texture blue + * @param a // texture alpha + * @param masks specify the mask for the s axis + * @param rects the texture coordinate s of upper-left corner of rectangle (s10.5) + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawTexRectIA8_DropShadowOffset(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, + s16 rectLeft, s16 rectTop, s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy, + s16 r, s16 g, s16 b, s16 a, s32 masks, s32 rects) { + s16 dropShadowAlpha = a; + + if (a > 100) { + dropShadowAlpha = 100; + } + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, dropShadowAlpha); + + gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, textureWidth, textureHeight, 0, + G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(gfx++, (rectLeft + 2) * 4, (rectTop + 2) * 4, (rectLeft + rectWidth + 2) * 4, + (rectTop + rectHeight + 2) * 4, G_TX_RENDERTILE, rects, 0, dsdx, dtdy); + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0, r, g, b, a); + + gSPTextureRectangle(gfx++, rectLeft * 4, rectTop * 4, (rectLeft + rectWidth) * 4, (rectTop + rectHeight) * 4, + G_TX_RENDERTILE, rects, 0, dsdx, dtdy); + + return gfx; +} + +/** + * Draw an I8 texture on a rectangle + * + * @param gfx the display list pointer + * @param texture + * @param textureWidth texture image width in texels + * @param textureHeight texture image height in texels + * @param rectLeft the x-coordinate of upper-left corner of rectangle + * @param rectTop the y-coordinate of upper-left corner of rectangle + * @param rectWidth rectangle width in texels + * @param rectHeight rectangle height in texels + * @param dsdx the change in s for each change in x (s5.10) + * @param dtdy the change in t for each change in y (s5.10) + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawTexRectI8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, s16 rectLeft, s16 rectTop, + s16 rectWidth, s16 rectHeight, u16 dsdx, u16 dtdy) { + gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_I, G_IM_SIZ_8b, textureWidth, textureHeight, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, + G_TX_RENDERTILE, 0, 0, dsdx, dtdy); + + return gfx; +} + +/** + * Draw a 4b texture on a rectangle + * + * @param gfx the display list pointer + * @param texture + * @param fmt texture image format + * @param textureWidth texture image width in texels + * @param textureHeight texture image height in texels + * @param rectLeft the x-coordinate of upper-left corner of rectangle + * @param rectTop the y-coordinate of upper-left corner of rectangle + * @param rectWidth rectangle width in texels + * @param rectHeight rectangle height in texels + * @param cms gives the clamp, wrap, and mirror flag for the s axis + * @param masks specify the mask for the s axis + * @param rects the texture coordinate s of upper-left corner of rectangle (s10.5) + * @param dsdx the change in s for each change in x (s5.10) + * @param dtdy the change in t for each change in y (s5.10) + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawTexRect4b(Gfx* gfx, TexturePtr texture, s32 fmt, s16 textureWidth, s16 textureHeight, s16 rectLeft, + s16 rectTop, s16 rectWidth, s16 rectHeight, s32 cms, s32 masks, s32 rects, u16 dsdx, u16 dtdy) { + gDPLoadTextureBlock_4b(gfx++, texture, fmt, textureWidth, textureHeight, 0, cms, G_TX_NOMIRROR | G_TX_WRAP, masks, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(gfx++, rectLeft << 2, rectTop << 2, (rectLeft + rectWidth) << 2, (rectTop + rectHeight) << 2, + G_TX_RENDERTILE, rects, 0, dsdx, dtdy); + + return gfx; +} + +/** + * Draw an I8 texture on a Quadrangle + * + * @param gfx the display list pointer + * @param texture + * @param textureWidth texture image width in texels + * @param textureHeight texture image height in texels + * @param point index of the first point to draw the Quadrangle + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawTexQuadIA8(Gfx* gfx, TexturePtr texture, s16 textureWidth, s16 textureHeight, u16 point) { + gDPLoadTextureBlock(gfx++, texture, G_IM_FMT_IA, G_IM_SIZ_8b, textureWidth, textureHeight, 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); + + gSP1Quadrangle(gfx++, point, point + 2, point + 3, point + 1, 0); + + return gfx; +} + +/** + * Draw a 4b texture on a Quadrangle + * + * @param gfx the display list pointer + * @param texture + * @param fmt texture image format + * @param textureWidth texture image width in texels + * @param textureHeight texture image height in texels + * @param point index of the first point to draw the Quadrangle + * @return Gfx* the display list pointer + */ +Gfx* Gfx_DrawTexQuad4b(Gfx* gfx, TexturePtr texture, s32 fmt, s16 textureWidth, s16 textureHeight, u16 point) { + gDPLoadTextureBlock_4b(gfx++, texture, fmt, textureWidth, textureHeight, 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); + + gSP1Quadrangle(gfx++, point, point + 2, point + 3, point + 1, 0); + + return gfx; +} + +// Total number of non-minigame-perfect action quads +#define ACTION_QUAD_BASE_COUNT 11 + +s16 sActionVtxPosX[ACTION_QUAD_BASE_COUNT] = { + -14, // A Button + -14, // A Button Background + -24, // A Button Do-Action + -8, // Three-Day Clock's Star (for the Minute Tracker) + -12, // Three-Day Clock's Sun (for the Day-Time Hours Tracker) + -12, // Three-Day Clock's Moon (for the Night-Time Hours Tracker) + -7, // Three-Day Clock's Hour Digit Above the Sun + -8, // Three-Day Clock's Hour Digit Above the Sun + -7, // Three-Day Clock's Hour Digit Above the Moon + -8, // Three-Day Clock's Hour Digit Above the Moon + -12, // Minigame Countdown Textures +}; + +s16 sActionVtxWidths[ACTION_QUAD_BASE_COUNT] = { + 28, // A Button + 28, // A Button Background + 48, // A Button Do-Action + 16, // Three-Day Clock's Star (for the Minute Tracker) + 24, // Three-Day Clock's Sun (for the Day-Time Hours Tracker) + 24, // Three-Day Clock's Moon (for the Night-Time Hours Tracker) + 16, // Three-Day Clock's Hour Digit Above the Sun + 16, // Three-Day Clock's Hour Digit Above the Sun + 16, // Three-Day Clock's Hour Digit Above the Moon + 16, // Three-Day Clock's Hour Digit Above the Moon + 24, // Minigame Countdown Textures +}; + +s16 sActionVtxPosY[ACTION_QUAD_BASE_COUNT] = { + 14, // A Button + 14, // A Button Background + 8, // A Button Do-Action + 24, // Three-Day Clock's Star (for the Minute Tracker) + -82, // Three-Day Clock's Sun (for the Day-Time Hours Tracker) + -82, // Three-Day Clock's Moon (for the Night-Time Hours Tracker) + 58, // Three-Day Clock's Hour Digit Above the Sun + 59, // Three-Day Clock's Hour Digit Above the Sun + 58, // Three-Day Clock's Hour Digit Above the Moon + 59, // Three-Day Clock's Hour Digit Above the Moon + 32, // Minigame Countdown Textures +}; + +s16 sActionVtxHeights[ACTION_QUAD_BASE_COUNT] = { + 28, // A Button + 28, // A Button Background + 16, // A Button Do-Action + 16, // Three-Day Clock's Star (for the Minute Tracker) + 24, // Three-Day Clock's Sun (for the Day-Time Hours Tracker) + 24, // Three-Day Clock's Moon (for the Night-Time Hours Tracker) + 11, // Three-Day Clock's Hour Digit Above the Sun + 11, // Three-Day Clock's Hour Digit Above the Sun + 11, // Three-Day Clock's Hour Digit Above the Moon + 11, // Three-Day Clock's Hour Digit Above the Moon + 32, // Minigame Countdown Textures +}; + +#define PERFECT_LETTERS_VTX_WIDTH 32 +#define PERFECT_LETTERS_VTX_HEIGHT 33 + +// Used for PERFECT_LETTERS_TYPE_1 and only part of PERFECT_LETTERS_TYPE_3 +// Both PERFECT_LETTERS_TYPE_2 and PERFECT_LETTERS_TYPE_2 have (0, 0) as the center for all letters +s16 sPerfectLettersCenterX[PERFECT_LETTERS_NUM_LETTERS] = { + -61, // P + -45, // E + 29, // R + 104, // F + -117, // E + -42, // C + 32, // T + 55, // ! +}; + +s16 sPerfectLettersCenterY[PERFECT_LETTERS_NUM_LETTERS] = { + 1, // P + -70, // E + -99, // R + -70, // F + 71, // E + 101, // C + 72, // T + 1, // ! +}; + +/** + * interfaceCtx->actionVtx[0] -> A Button + * interfaceCtx->actionVtx[4] -> A Button Shadow + * interfaceCtx->actionVtx[8] -> A Button Do-Action + * interfaceCtx->actionVtx[12] -> Three-Day Clock's Star (for the Minute Tracker) + * interfaceCtx->actionVtx[16] -> Three-Day Clock's Sun (for the Day Hours Tracker) + * interfaceCtx->actionVtx[20] -> Three-Day Clock's Moon (for the Night Hours Tracker) + * interfaceCtx->actionVtx[24] -> Three-Day Clock's Hour Digit Above the Sun (uses 8 vertices) + * interfaceCtx->actionVtx[32] -> Three-Day Clock's Hour Digit Above the Moon (uses 8 vertices) + * interfaceCtx->actionVtx[40] -> Minigame Countdown Textures + * interfaceCtx->actionVtx[44] -> Minigame Perfect Letter P Shadow + * interfaceCtx->actionVtx[48] -> Minigame Perfect Letter E Shadow + * interfaceCtx->actionVtx[52] -> Minigame Perfect Letter R Shadow + * interfaceCtx->actionVtx[56] -> Minigame Perfect Letter F Shadow + * interfaceCtx->actionVtx[60] -> Minigame Perfect Letter E Shadow + * interfaceCtx->actionVtx[64] -> Minigame Perfect Letter C Shadow + * interfaceCtx->actionVtx[68] -> Minigame Perfect Letter T Shadow + * interfaceCtx->actionVtx[72] -> Minigame Perfect Letter ! Shadow + * interfaceCtx->actionVtx[76] -> Minigame Perfect Letter P Colored + * interfaceCtx->actionVtx[80] -> Minigame Perfect Letter E Colored + * interfaceCtx->actionVtx[84] -> Minigame Perfect Letter R Colored + * interfaceCtx->actionVtx[88] -> Minigame Perfect Letter F Colored + * interfaceCtx->actionVtx[92] -> Minigame Perfect Letter E Colored + * interfaceCtx->actionVtx[96] -> Minigame Perfect Letter C Colored + * interfaceCtx->actionVtx[100] -> Minigame Perfect Letter T Colored + * interfaceCtx->actionVtx[104] -> Minigame Perfect Letter ! Colored + */ + +#define BEATING_HEART_VTX_X -8 +#define BEATING_HEART_VTX_Y -8 +#define BEATING_HEART_VTX_WIDTH 16 + +void Interface_SetVertices(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i; + s16 j; + s16 k; + s16 shadowOffset; + + play->interfaceCtx.actionVtx = + GRAPH_ALLOC(play->state.gfxCtx, (ACTION_QUAD_BASE_COUNT + (2 * PERFECT_LETTERS_NUM_LETTERS)) * 4 * sizeof(Vtx)); + + // Loop over all non-minigame perfect vertices + // where (i) is the actionVtx index, (k) is the iterator + for (k = 0, i = 0; i < (ACTION_QUAD_BASE_COUNT * 4); i += 4, k++) { + // Left vertices x Pos + interfaceCtx->actionVtx[i + 0].v.ob[0] = interfaceCtx->actionVtx[i + 2].v.ob[0] = sActionVtxPosX[k]; + + // Right vertices x Pos + interfaceCtx->actionVtx[i + 1].v.ob[0] = interfaceCtx->actionVtx[i + 3].v.ob[0] = + interfaceCtx->actionVtx[i + 0].v.ob[0] + sActionVtxWidths[k]; + + // Top vertices y Pos + interfaceCtx->actionVtx[i + 0].v.ob[1] = interfaceCtx->actionVtx[i + 1].v.ob[1] = sActionVtxPosY[k]; + + // Bottom vertices y Pos + interfaceCtx->actionVtx[i + 2].v.ob[1] = interfaceCtx->actionVtx[i + 3].v.ob[1] = + interfaceCtx->actionVtx[i + 0].v.ob[1] - sActionVtxHeights[k]; + + // All vertices z Pos + interfaceCtx->actionVtx[i + 0].v.ob[2] = interfaceCtx->actionVtx[i + 1].v.ob[2] = + interfaceCtx->actionVtx[i + 2].v.ob[2] = interfaceCtx->actionVtx[i + 3].v.ob[2] = 0; + + // Unused flag + interfaceCtx->actionVtx[i + 0].v.flag = interfaceCtx->actionVtx[i + 1].v.flag = + interfaceCtx->actionVtx[i + 2].v.flag = interfaceCtx->actionVtx[i + 3].v.flag = 0; + + // Left and Top texture coordinates + interfaceCtx->actionVtx[i + 0].v.tc[0] = interfaceCtx->actionVtx[i + 0].v.tc[1] = + interfaceCtx->actionVtx[i + 1].v.tc[1] = interfaceCtx->actionVtx[i + 2].v.tc[0] = 0; + + // Right vertices texture coordinates + interfaceCtx->actionVtx[i + 1].v.tc[0] = interfaceCtx->actionVtx[i + 3].v.tc[0] = sActionVtxWidths[k] << 5; + + // Bottom vertices texture coordinates + interfaceCtx->actionVtx[i + 2].v.tc[1] = interfaceCtx->actionVtx[i + 3].v.tc[1] = sActionVtxHeights[k] << 5; + + // Set color + interfaceCtx->actionVtx[i + 0].v.cn[0] = interfaceCtx->actionVtx[i + 1].v.cn[0] = + interfaceCtx->actionVtx[i + 2].v.cn[0] = interfaceCtx->actionVtx[i + 3].v.cn[0] = + interfaceCtx->actionVtx[i + 0].v.cn[1] = interfaceCtx->actionVtx[i + 1].v.cn[1] = + interfaceCtx->actionVtx[i + 2].v.cn[1] = interfaceCtx->actionVtx[i + 3].v.cn[1] = + interfaceCtx->actionVtx[i + 0].v.cn[2] = interfaceCtx->actionVtx[i + 1].v.cn[2] = + interfaceCtx->actionVtx[i + 2].v.cn[2] = interfaceCtx->actionVtx[i + 3].v.cn[2] = 255; + + // Set alpha + interfaceCtx->actionVtx[i + 0].v.cn[3] = interfaceCtx->actionVtx[i + 1].v.cn[3] = + interfaceCtx->actionVtx[i + 2].v.cn[3] = interfaceCtx->actionVtx[i + 3].v.cn[3] = 255; + } + + // A button right and top texture coordinates + interfaceCtx->actionVtx[1].v.tc[0] = interfaceCtx->actionVtx[3].v.tc[0] = interfaceCtx->actionVtx[2].v.tc[1] = + interfaceCtx->actionVtx[3].v.tc[1] = 32 << 5; + + // A button background right and top texture coordinates + interfaceCtx->actionVtx[5].v.tc[0] = interfaceCtx->actionVtx[7].v.tc[0] = interfaceCtx->actionVtx[6].v.tc[1] = + interfaceCtx->actionVtx[7].v.tc[1] = 32 << 5; + + // Loop over vertices for the minigame-perfect letters + // Outer loop is to loop over 2 sets of letters: shadowed letters (j = 0) and colored letters (j = 1) + for (j = 0, shadowOffset = 2; j < 2; j++, shadowOffset -= 2) { + // Inner loop is to loop over letters (k) and actionVtx index (i) + for (k = 0; k < PERFECT_LETTERS_NUM_LETTERS; k++, i += 4) { + if ((interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_1) || + ((interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_3) && + (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_EXIT))) { + // Left vertices x Pos + interfaceCtx->actionVtx[i + 0].v.ob[0] = interfaceCtx->actionVtx[i + 2].v.ob[0] = + -((sPerfectLettersCenterX[k] - shadowOffset) + 16); + + // Right vertices x Pos + interfaceCtx->actionVtx[i + 1].v.ob[0] = interfaceCtx->actionVtx[i + 3].v.ob[0] = + interfaceCtx->actionVtx[i + 0].v.ob[0] + PERFECT_LETTERS_VTX_WIDTH; + + // Top vertices y Pos + interfaceCtx->actionVtx[i + 0].v.ob[1] = interfaceCtx->actionVtx[i + 1].v.ob[1] = + (sPerfectLettersCenterY[k] - shadowOffset) + 16; + + // Bottom vertices y Pos + interfaceCtx->actionVtx[i + 2].v.ob[1] = interfaceCtx->actionVtx[i + 3].v.ob[1] = + interfaceCtx->actionVtx[i + 0].v.ob[1] - PERFECT_LETTERS_VTX_HEIGHT; + + } else if ((interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_2) || + (interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_3)) { + // Left vertices x Pos + interfaceCtx->actionVtx[i + 0].v.ob[0] = interfaceCtx->actionVtx[i + 2].v.ob[0] = + -(interfaceCtx->perfectLettersOffsetX[k] - shadowOffset + 16); + + // Right vertices x Pos + interfaceCtx->actionVtx[i + 1].v.ob[0] = interfaceCtx->actionVtx[i + 3].v.ob[0] = + interfaceCtx->actionVtx[i + 0].v.ob[0] + PERFECT_LETTERS_VTX_WIDTH; + + // Top vertices y Pos + interfaceCtx->actionVtx[i + 0].v.ob[1] = interfaceCtx->actionVtx[i + 1].v.ob[1] = 16 - shadowOffset; + + // Bottom vertices y Pos + interfaceCtx->actionVtx[i + 2].v.ob[1] = interfaceCtx->actionVtx[i + 3].v.ob[1] = + interfaceCtx->actionVtx[i + 0].v.ob[1] - PERFECT_LETTERS_VTX_HEIGHT; + + } else { + // Left vertices x Pos + interfaceCtx->actionVtx[i + 0].v.ob[0] = interfaceCtx->actionVtx[i + 2].v.ob[0] = -(216 - shadowOffset); + + // Right vertices x Pos + interfaceCtx->actionVtx[i + 1].v.ob[0] = interfaceCtx->actionVtx[i + 3].v.ob[0] = + interfaceCtx->actionVtx[i + 0].v.ob[0] + PERFECT_LETTERS_VTX_WIDTH; + + // Top vertices y Pos + interfaceCtx->actionVtx[i + 0].v.ob[1] = interfaceCtx->actionVtx[i + 1].v.ob[1] = 24 - shadowOffset; + + // Bottom vertices y Pos + interfaceCtx->actionVtx[i + 2].v.ob[1] = interfaceCtx->actionVtx[i + 3].v.ob[1] = + interfaceCtx->actionVtx[i + 0].v.ob[1] - PERFECT_LETTERS_VTX_HEIGHT; + } + + // All vertices z Pos + interfaceCtx->actionVtx[i + 0].v.ob[2] = interfaceCtx->actionVtx[i + 1].v.ob[2] = + interfaceCtx->actionVtx[i + 2].v.ob[2] = interfaceCtx->actionVtx[i + 3].v.ob[2] = 0; + + // Unused flag + interfaceCtx->actionVtx[i + 0].v.flag = interfaceCtx->actionVtx[i + 1].v.flag = + interfaceCtx->actionVtx[i + 2].v.flag = interfaceCtx->actionVtx[i + 3].v.flag = 0; + + // Left and Top texture coordinates + interfaceCtx->actionVtx[i + 0].v.tc[0] = interfaceCtx->actionVtx[i + 0].v.tc[1] = + interfaceCtx->actionVtx[i + 1].v.tc[1] = interfaceCtx->actionVtx[i + 2].v.tc[0] = 0; + + // Right vertices texture coordinates + interfaceCtx->actionVtx[i + 1].v.tc[0] = interfaceCtx->actionVtx[i + 3].v.tc[0] = PERFECT_LETTERS_VTX_WIDTH + << 5; + + // Bottom vertices texture coordinates + interfaceCtx->actionVtx[i + 2].v.tc[1] = interfaceCtx->actionVtx[i + 3].v.tc[1] = PERFECT_LETTERS_VTX_HEIGHT + << 5; + + // Set color + interfaceCtx->actionVtx[i + 0].v.cn[0] = interfaceCtx->actionVtx[i + 1].v.cn[0] = + interfaceCtx->actionVtx[i + 2].v.cn[0] = interfaceCtx->actionVtx[i + 3].v.cn[0] = + interfaceCtx->actionVtx[i + 0].v.cn[1] = interfaceCtx->actionVtx[i + 1].v.cn[1] = + interfaceCtx->actionVtx[i + 2].v.cn[1] = interfaceCtx->actionVtx[i + 3].v.cn[1] = + interfaceCtx->actionVtx[i + 0].v.cn[2] = interfaceCtx->actionVtx[i + 1].v.cn[2] = + interfaceCtx->actionVtx[i + 2].v.cn[2] = interfaceCtx->actionVtx[i + 3].v.cn[2] = 255; + + // Set alpha + interfaceCtx->actionVtx[i + 0].v.cn[3] = interfaceCtx->actionVtx[i + 1].v.cn[3] = + interfaceCtx->actionVtx[i + 2].v.cn[3] = interfaceCtx->actionVtx[i + 3].v.cn[3] = 255; + } + } + + // Beating Hearts Vertices + interfaceCtx->beatingHeartVtx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Vtx)); + + // Left vertices x Pos + interfaceCtx->beatingHeartVtx[0].v.ob[0] = interfaceCtx->beatingHeartVtx[2].v.ob[0] = BEATING_HEART_VTX_X; + + // Right vertices x Pos + interfaceCtx->beatingHeartVtx[1].v.ob[0] = interfaceCtx->beatingHeartVtx[3].v.ob[0] = + BEATING_HEART_VTX_X + BEATING_HEART_VTX_WIDTH; + + // Top vertices y Pos + interfaceCtx->beatingHeartVtx[0].v.ob[1] = interfaceCtx->beatingHeartVtx[1].v.ob[1] = + BEATING_HEART_VTX_Y + BEATING_HEART_VTX_WIDTH; + + // Bottom vertices y Pos + interfaceCtx->beatingHeartVtx[2].v.ob[1] = interfaceCtx->beatingHeartVtx[3].v.ob[1] = BEATING_HEART_VTX_Y; + + // All vertices z Pos + interfaceCtx->beatingHeartVtx[0].v.ob[2] = interfaceCtx->beatingHeartVtx[1].v.ob[2] = + interfaceCtx->beatingHeartVtx[2].v.ob[2] = interfaceCtx->beatingHeartVtx[3].v.ob[2] = 0; + + // unused flag + interfaceCtx->beatingHeartVtx[0].v.flag = interfaceCtx->beatingHeartVtx[1].v.flag = + interfaceCtx->beatingHeartVtx[2].v.flag = interfaceCtx->beatingHeartVtx[3].v.flag = 0; + + // Texture Coordinates + interfaceCtx->beatingHeartVtx[0].v.tc[0] = interfaceCtx->beatingHeartVtx[0].v.tc[1] = + interfaceCtx->beatingHeartVtx[1].v.tc[1] = interfaceCtx->beatingHeartVtx[2].v.tc[0] = 0; + interfaceCtx->beatingHeartVtx[1].v.tc[0] = interfaceCtx->beatingHeartVtx[2].v.tc[1] = + interfaceCtx->beatingHeartVtx[3].v.tc[0] = interfaceCtx->beatingHeartVtx[3].v.tc[1] = + BEATING_HEART_VTX_WIDTH << 5; + + // Set color + interfaceCtx->beatingHeartVtx[0].v.cn[0] = interfaceCtx->beatingHeartVtx[1].v.cn[0] = + interfaceCtx->beatingHeartVtx[2].v.cn[0] = interfaceCtx->beatingHeartVtx[3].v.cn[0] = + interfaceCtx->beatingHeartVtx[0].v.cn[1] = interfaceCtx->beatingHeartVtx[1].v.cn[1] = + interfaceCtx->beatingHeartVtx[2].v.cn[1] = interfaceCtx->beatingHeartVtx[3].v.cn[1] = + interfaceCtx->beatingHeartVtx[0].v.cn[2] = interfaceCtx->beatingHeartVtx[1].v.cn[2] = + interfaceCtx->beatingHeartVtx[2].v.cn[2] = interfaceCtx->beatingHeartVtx[3].v.cn[2] = + interfaceCtx->beatingHeartVtx[0].v.cn[3] = interfaceCtx->beatingHeartVtx[1].v.cn[3] = + interfaceCtx->beatingHeartVtx[2].v.cn[3] = interfaceCtx->beatingHeartVtx[3].v.cn[3] = + 255; +} + +s32 sPostmanTimerInputBtnAPressed = false; + +void Interface_PostmanTimerCallback(s32 arg0) { + s32 btnAPressed; + + func_80175E68(&sPostmanTimerInput[0], 0); + btnAPressed = CHECK_BTN_ALL(sPostmanTimerInput[0].cur.button, BTN_A); + if ((btnAPressed != sPostmanTimerInputBtnAPressed) && btnAPressed) { + gSaveContext.postmanTimerStopOsTime = osGetTime(); + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_STOP; + } + + sPostmanTimerInputBtnAPressed = btnAPressed; +} + +void Interface_StartTimer(s16 timerId, s16 seconds) { + gSaveContext.timerX[timerId] = 115; + gSaveContext.timerY[timerId] = 80; + + sEnvTimerActive = false; + + gSaveContext.timerCurTimes[timerId] = SECONDS_TO_TIMER(seconds); + gSaveContext.timerTimeLimits[timerId] = gSaveContext.timerCurTimes[timerId]; + + if (gSaveContext.timerCurTimes[timerId] != SECONDS_TO_TIMER(0)) { + gSaveContext.timerDirections[timerId] = TIMER_COUNT_DOWN; + } else { + gSaveContext.timerDirections[timerId] = TIMER_COUNT_UP; + } + + gSaveContext.timerStates[timerId] = TIMER_STATE_START; +} + +void Interface_StartPostmanTimer(s16 seconds, s16 bunnyHoodState) { + gSaveContext.timerX[TIMER_ID_POSTMAN] = 115; + gSaveContext.timerY[TIMER_ID_POSTMAN] = 80; + + sPostmanBunnyHoodState = bunnyHoodState; + + gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(seconds); + gSaveContext.timerTimeLimits[TIMER_ID_POSTMAN] = gSaveContext.timerCurTimes[TIMER_ID_POSTMAN]; + + if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] != SECONDS_TO_TIMER(0)) { + gSaveContext.timerDirections[TIMER_ID_POSTMAN] = TIMER_COUNT_DOWN; + } else { + gSaveContext.timerDirections[TIMER_ID_POSTMAN] = TIMER_COUNT_UP; + } + + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_START; + gSaveContext.timerStopTimes[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[TIMER_ID_POSTMAN] = 0; +} + +// Unused, goron race actually uses TIMER_ID_MINIGAME_2 +void Interface_StartGoronRaceTimer(s32 arg0) { + if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] != TIMER_STATE_OFF) { + // Goron race started + if (CHECK_EVENTINF(EVENTINF_10)) { + gSaveContext.timerCurTimes[TIMER_ID_GORON_RACE_UNUSED] = SECONDS_TO_TIMER_PRECISE(2, 39); + } else { + gSaveContext.timerCurTimes[TIMER_ID_GORON_RACE_UNUSED] = SECONDS_TO_TIMER_PRECISE(0, 1); + } + } +} + +void Interface_StartBottleTimer(s16 seconds, s16 timerId) { + gSaveContext.bottleTimerStates[timerId] = BOTTLE_TIMER_STATE_COUNTING; + gSaveContext.bottleTimerCurTimes[timerId] = SECONDS_TO_TIMER(seconds); + gSaveContext.bottleTimerTimeLimits[timerId] = gSaveContext.bottleTimerCurTimes[timerId]; + gSaveContext.bottleTimerStartOsTimes[timerId] = osGetTime(); + gSaveContext.bottleTimerPausedOsTimes[timerId] = 0; + sBottleTimerPausedOsTime = 0; +} + +u32 Interface_GetCompressedTimerDigits(s16 timerId) { + u64 time; + s16 timerArr[6]; + + time = gSaveContext.timerCurTimes[timerId]; + + // 6 minutes + timerArr[0] = time / SECONDS_TO_TIMER(360); + time -= timerArr[0] * SECONDS_TO_TIMER(360); + + // minutes + timerArr[1] = time / SECONDS_TO_TIMER(60); + time -= timerArr[1] * SECONDS_TO_TIMER(60); + + // 10 seconds + timerArr[2] = time / SECONDS_TO_TIMER(10); + time -= timerArr[2] * SECONDS_TO_TIMER(10); + + // seconds + timerArr[3] = time / SECONDS_TO_TIMER(1); + time -= timerArr[3] * SECONDS_TO_TIMER(1); + + // 100 milliseconds + timerArr[4] = time / SECONDS_TO_TIMER_PRECISE(0, 10); + time -= timerArr[4] * SECONDS_TO_TIMER_PRECISE(0, 10); + + // 10 milliseconds + timerArr[5] = time; + + return (timerArr[0] << 0x14) | (timerArr[1] << 0x10) | (timerArr[2] << 0xC) | (timerArr[3] << 8) | + (timerArr[4] << 4) | timerArr[5]; +} + +void Interface_NewDay(PlayState* play, s32 day) { + s32 pad; + s16 i = day - 1; + + // i is used to store dayMinusOne + if ((i < 0) || (i >= 3)) { + i = 0; + } + + // Loads day number from week_static for the three-day clock + DmaMgr_SendRequest0((u32)play->interfaceCtx.doActionSegment + 0x780, + (u32)SEGMENT_ROM_START(week_static) + i * 0x510, 0x510); + + // i is used to store sceneId + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.permanentSceneFlags); i++) { + gSaveContext.save.permanentSceneFlags[i].chest = gSaveContext.cycleSceneFlags[i].chest; + gSaveContext.save.permanentSceneFlags[i].switch0 = gSaveContext.cycleSceneFlags[i].switch0; + gSaveContext.save.permanentSceneFlags[i].switch1 = gSaveContext.cycleSceneFlags[i].switch1; + gSaveContext.save.permanentSceneFlags[i].clearedRoom = gSaveContext.cycleSceneFlags[i].clearedRoom; + gSaveContext.save.permanentSceneFlags[i].collectible = gSaveContext.cycleSceneFlags[i].collectible; + } +} + +void Interface_SetHudVisibility(u16 hudVisibility) { + if (gSaveContext.hudVisibility != hudVisibility) { + gSaveContext.hudVisibility = hudVisibility; + gSaveContext.nextHudVisibility = hudVisibility; + gSaveContext.hudVisibilityTimer = 1; + } +} + +/** + * Sets the button alphas to be dimmed for disabled buttons, or to the requested alpha for non-disabled buttons + */ +void Interface_UpdateButtonAlphasByStatus(PlayState* play, s16 risingAlpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + if ((gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) || (gSaveContext.unk_1015 == ITEM_NONE)) { + if (interfaceCtx->bAlpha != 70) { + interfaceCtx->bAlpha = 70; + } + } else { + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] == BTN_DISABLED) { + if (interfaceCtx->cLeftAlpha != 70) { + interfaceCtx->cLeftAlpha = 70; + } + } else { + if (interfaceCtx->cLeftAlpha != 255) { + interfaceCtx->cLeftAlpha = risingAlpha; + } + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] == BTN_DISABLED) { + if (interfaceCtx->cDownAlpha != 70) { + interfaceCtx->cDownAlpha = 70; + } + } else { + if (interfaceCtx->cDownAlpha != 255) { + interfaceCtx->cDownAlpha = risingAlpha; + } + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] == BTN_DISABLED) { + if (interfaceCtx->cRightAlpha != 70) { + interfaceCtx->cRightAlpha = 70; + } + } else { + if (interfaceCtx->cRightAlpha != 255) { + interfaceCtx->cRightAlpha = risingAlpha; + } + } + + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + if (interfaceCtx->aAlpha != 70) { + interfaceCtx->aAlpha = 70; + } + } else { + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + } +} + +/** + * Lower button alphas on the HUD to the requested value + * If (gSaveContext.hudVisibilityForceButtonAlphasByStatus), then instead update button alphas + * depending on button status + */ +void Interface_UpdateButtonAlphas(PlayState* play, s16 dimmingAlpha, s16 risingAlpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + if (gSaveContext.hudVisibilityForceButtonAlphasByStatus) { + Interface_UpdateButtonAlphasByStatus(play, risingAlpha); + return; + } + + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } +} + +void Interface_UpdateHudAlphas(PlayState* play, s16 dimmingAlpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 risingAlpha = 255 - dimmingAlpha; + + switch (gSaveContext.nextHudVisibility) { + case HUD_VISIBILITY_NONE: + case HUD_VISIBILITY_NONE_ALT: + case HUD_VISIBILITY_B: + if (gSaveContext.nextHudVisibility == HUD_VISIBILITY_B) { + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + } else { + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_WITH_OVERWRITE: + // aAlpha is immediately overwritten in Interface_UpdateButtonAlphas + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + Interface_UpdateButtonAlphas(play, dimmingAlpha, risingAlpha + 0); + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + // aAlpha is immediately overwritten below + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE: + Interface_UpdateButtonAlphas(play, dimmingAlpha, risingAlpha); + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + // aAlpha overwrites the value set in Interface_UpdateButtonAlphas + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE: + Interface_UpdateButtonAlphas(play, dimmingAlpha, risingAlpha); + + // aAlpha overwrites the value set in Interface_UpdateButtonAlphas + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (play->sceneId == SCENE_SPOT00) { + if (interfaceCtx->minimapAlpha < 170) { + interfaceCtx->minimapAlpha = risingAlpha; + } else { + interfaceCtx->minimapAlpha = 170; + } + } else if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_ALL_NO_MINIMAP_W_DISABLED: + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + Interface_UpdateButtonAlphasByStatus(play, risingAlpha); + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_MAGIC: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_B_ALT: + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_B_MINIMAP: + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if ((gSaveContext.buttonStatus[EQUIP_SLOT_B] == BTN_DISABLED) || (gSaveContext.unk_1015 == ITEM_NONE)) { + if (interfaceCtx->bAlpha != 70) { + interfaceCtx->bAlpha = 70; + } + } else { + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_MAGIC_WITH_OVERWRITE: + Interface_UpdateButtonAlphas(play, dimmingAlpha, risingAlpha); + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + // aAlpha overwrites the value set in Interface_UpdateButtonAlphas + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_MAGIC_C: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->cLeftAlpha != 255) { + interfaceCtx->cLeftAlpha = risingAlpha; + } + + if (interfaceCtx->cDownAlpha != 255) { + interfaceCtx->cDownAlpha = risingAlpha; + } + + if (interfaceCtx->cRightAlpha != 255) { + interfaceCtx->cRightAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_ALL_NO_MINIMAP: + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->cLeftAlpha != 255) { + interfaceCtx->cLeftAlpha = risingAlpha; + } + + if (interfaceCtx->cDownAlpha != 255) { + interfaceCtx->cDownAlpha = risingAlpha; + } + + if (interfaceCtx->cRightAlpha != 255) { + interfaceCtx->cRightAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_B_C: + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->cLeftAlpha != 255) { + interfaceCtx->cLeftAlpha = risingAlpha; + } + + if (interfaceCtx->cDownAlpha != 255) { + interfaceCtx->cDownAlpha = risingAlpha; + } + + if (interfaceCtx->cRightAlpha != 255) { + interfaceCtx->cRightAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_B_MINIMAP: + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_HEARTS_MAGIC_MINIMAP: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP: + if ((interfaceCtx->bAlpha != 0) && (interfaceCtx->bAlpha > dimmingAlpha)) { + interfaceCtx->bAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_B_MAGIC: + if ((interfaceCtx->aAlpha != 0) && (interfaceCtx->aAlpha > dimmingAlpha)) { + interfaceCtx->aAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + break; + + case HUD_VISIBILITY_A_B: + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > dimmingAlpha)) { + interfaceCtx->minimapAlpha = dimmingAlpha; + } + + if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > dimmingAlpha)) { + interfaceCtx->magicAlpha = dimmingAlpha; + } + + if ((interfaceCtx->healthAlpha != 0) && (interfaceCtx->healthAlpha > dimmingAlpha)) { + interfaceCtx->healthAlpha = dimmingAlpha; + } + + break; + + case HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP: + if ((interfaceCtx->cLeftAlpha != 0) && (interfaceCtx->cLeftAlpha > dimmingAlpha)) { + interfaceCtx->cLeftAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cDownAlpha != 0) && (interfaceCtx->cDownAlpha > dimmingAlpha)) { + interfaceCtx->cDownAlpha = dimmingAlpha; + } + + if ((interfaceCtx->cRightAlpha != 0) && (interfaceCtx->cRightAlpha > dimmingAlpha)) { + interfaceCtx->cRightAlpha = dimmingAlpha; + } + + if (interfaceCtx->bAlpha != 255) { + interfaceCtx->bAlpha = risingAlpha; + } + + if (interfaceCtx->aAlpha != 255) { + interfaceCtx->aAlpha = risingAlpha; + } + + if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + break; + } + + if ((play->roomCtx.curRoom.unk3 == 1) && (interfaceCtx->minimapAlpha >= 255)) { + interfaceCtx->minimapAlpha = 255; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80110038.s") +void func_80111CB4(PlayState* play); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80111CB4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801129E4.s") +void Interface_SetSceneRestrictions(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i = 0; + u8 currentScene; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112AF4.s") + do { + currentScene = (u8)play->sceneId; + if (currentScene == sRestrictionFlags[i].scene) { + interfaceCtx->restrictions.hGauge = RESTRICTIONS_GET_HGAUGE(&sRestrictionFlags[i]); + interfaceCtx->restrictions.bButton = RESTRICTIONS_GET_B_BUTTON(&sRestrictionFlags[i]); + interfaceCtx->restrictions.aButton = RESTRICTIONS_GET_A_BUTTON(&sRestrictionFlags[i]); + interfaceCtx->restrictions.tradeItems = RESTRICTIONS_GET_TRADE_ITEMS(&sRestrictionFlags[i]); + interfaceCtx->restrictions.songOfTime = RESTRICTIONS_GET_SONG_OF_TIME(&sRestrictionFlags[i]); + interfaceCtx->restrictions.songOfDoubleTime = RESTRICTIONS_GET_SONG_OF_DOUBLE_TIME(&sRestrictionFlags[i]); + interfaceCtx->restrictions.invSongOfTime = RESTRICTIONS_GET_INV_SONG_OF_TIME(&sRestrictionFlags[i]); + interfaceCtx->restrictions.songOfSoaring = RESTRICTIONS_GET_SONG_OF_SOARING(&sRestrictionFlags[i]); + interfaceCtx->restrictions.songOfStorms = RESTRICTIONS_GET_SONG_OF_STORMS(&sRestrictionFlags[i]); + interfaceCtx->restrictions.masks = RESTRICTIONS_GET_MASKS(&sRestrictionFlags[i]); + interfaceCtx->restrictions.pictoBox = RESTRICTIONS_GET_PICTO_BOX(&sRestrictionFlags[i]); + interfaceCtx->restrictions.all = RESTRICTIONS_GET_ALL(&sRestrictionFlags[i]); + break; + } + i++; + } while (sRestrictionFlags[i].scene != RESTRICTIONS_TABLE_END); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112AFC.s") +void Interface_Noop(void) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112B40.s") +void Interface_InitMinigame(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80112BE4.s") + gSaveContext.minigameStatus = MINIGAME_STATUS_ACTIVE; + gSaveContext.minigameScore = 0; + gSaveContext.minigameHiddenScore = 0; + + sHBAScoreTier = 0; + interfaceCtx->minigamePoints = interfaceCtx->minigameHiddenPoints = interfaceCtx->minigameUnusedPoints = 0; + + interfaceCtx->minigameAmmo = 20; +} + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_LoadItemIconImpl.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) { + //! @bug: Sets QUEST_QUIVER instead of QUEST_SKULL_TOKEN + // Setting `QUEST_SKULL_TOKEN` will result in misplaced digits on the pause menu - Quest Status page. + SET_QUEST_ITEM(item - ITEM_SKULL_TOKEN + QUEST_QUIVER); + Inventory_IncrementSkullTokenCount(play->sceneId); + 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); + CUR_FORM_EQUIP(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_ODOLWA); + return ITEM_NONE; + + } else if (item == ITEM_RECOVERY_HEART) { + Health_ChangeBy(play, 0x10); + return item; + + } else if (item == ITEM_MAGIC_SMALL) { + Magic_Add(play, MAGIC_NORMAL_METER / 2); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_12_80); + return ITEM_NONE; + } + return item; + + } else if (item == ITEM_MAGIC_LARGE) { + Magic_Add(play, MAGIC_NORMAL_METER); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_12_80); + 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) { + Interface_StartBottleTimer(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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_80)) { + 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) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_DEITY; + } else if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_SWORD_DEITY) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_NONE; + } else { + CUR_FORM_EQUIP(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) { + Interface_StartBottleTimer(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, +}; + +void func_80115428(InterfaceContext* interfaceCtx, u16 doAction, s16 loadOffset); #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,76 +2581,3517 @@ #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; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Parameter_AddMagic.s") +void Health_GiveHearts(s16 hearts) { + gSaveContext.save.playerData.healthCapacity += hearts * 0x10; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115D5C.s") +void Rupees_ChangeBy(s16 rupeeChange) { + gSaveContext.rupeeAccumulator += rupeeChange; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80115DB4.s") +void Inventory_ChangeAmmo(s16 item, s16 ammoChange) { + if (item == ITEM_STICK) { + AMMO(ITEM_STICK) += ammoChange; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116088.s") + 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; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116114.s") + } else if (item == ITEM_NUT) { + AMMO(ITEM_NUT) += ammoChange; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116348.s") + 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; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116918.s") + } 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; + } + } +} + +void Magic_Add(PlayState* play, s16 magicToAdd) { + if (((void)0, gSaveContext.save.playerData.magic) < ((void)0, gSaveContext.magicCapacity)) { + gSaveContext.magicToAdd += magicToAdd; + gSaveContext.isMagicRequested = true; + } +} + +void Magic_Reset(PlayState* play) { + if ((gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { + sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; + gSaveContext.magicState = MAGIC_STATE_IDLE; + } +} + +/** + * Request to consume magic. + * + * @param magicToConsume the positive-valued amount to decrease magic by + * @param type how the magic is consumed. + * @return false if the request failed + */ +s32 Magic_Consume(PlayState* play, s16 magicToConsume, s16 type) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + // Magic is not acquired yet + if (!gSaveContext.save.playerData.isMagicAcquired) { + return false; + } + + // Not enough magic available to consume + if ((gSaveContext.save.playerData.magic - magicToConsume) < 0) { + if (gSaveContext.magicCapacity != 0) { + play_sound(NA_SE_SY_ERROR); + } + return false; + } + + switch (type) { + case MAGIC_CONSUME_NOW: + case MAGIC_CONSUME_NOW_ALT: + // Drain magic immediately e.g. Deku Bubble + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || + (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + play->actorCtx.lensActive = false; + } + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + magicToConsume = 0; + } + gSaveContext.magicToConsume = magicToConsume; + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; + return true; + } else { + play_sound(NA_SE_SY_ERROR); + return false; + } + + case MAGIC_CONSUME_WAIT_NO_PREVIEW: + // Sets consume target but waits to consume. + // No yellow magic to preview target consumption. + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || + (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + play->actorCtx.lensActive = false; + } + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + magicToConsume = 0; + } + gSaveContext.magicToConsume = magicToConsume; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_3; + return true; + } else { + play_sound(NA_SE_SY_ERROR); + return false; + } + + case MAGIC_CONSUME_LENS: + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { + if (gSaveContext.save.playerData.magic != 0) { + interfaceCtx->magicConsumptionTimer = 80; + gSaveContext.magicState = MAGIC_STATE_CONSUME_LENS; + return true; + } else { + return false; + } + } else if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + return true; + } else { + return false; + } + + case MAGIC_CONSUME_WAIT_PREVIEW: + // Sets consume target but waits to consume. + // Preview consumption with a yellow bar. e.g. Spin Attack + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || + (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + play->actorCtx.lensActive = false; + } + gSaveContext.magicToConsume = magicToConsume; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_2; + return true; + } else { + play_sound(NA_SE_SY_ERROR); + return false; + } + + case MAGIC_CONSUME_GORON_ZORA: + // Goron spiked rolling or Zora electric barrier + if (gSaveContext.save.playerData.magic != 0) { + interfaceCtx->magicConsumptionTimer = 10; + gSaveContext.magicState = MAGIC_STATE_CONSUME_GORON_ZORA_SETUP; + return true; + } else { + return false; + } + + case MAGIC_CONSUME_GIANTS_MASK: + // Wearing Giant's Mask + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { + if (gSaveContext.save.playerData.magic != 0) { + interfaceCtx->magicConsumptionTimer = R_MAGIC_CONSUME_TIMER_GIANTS_MASK; + gSaveContext.magicState = MAGIC_STATE_CONSUME_GIANTS_MASK; + return true; + } else { + return false; + } + } + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_GIANTS_MASK) { + return true; + } else { + return false; + } + + case MAGIC_CONSUME_DEITY_BEAM: + // Consumes magic immediately + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || + (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + play->actorCtx.lensActive = false; + } + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + magicToConsume = 0; + } + gSaveContext.save.playerData.magic -= magicToConsume; + return true; + } else { + play_sound(NA_SE_SY_ERROR); + return false; + } + } + + return false; +} + +void Magic_UpdateAddRequest(void) { + if (gSaveContext.isMagicRequested) { + gSaveContext.save.playerData.magic += 4; + play_sound(NA_SE_SY_GAUGE_UP - SFX_FLAG); + + if (((void)0, gSaveContext.save.playerData.magic) >= ((void)0, gSaveContext.magicCapacity)) { + gSaveContext.save.playerData.magic = gSaveContext.magicCapacity; + gSaveContext.magicToAdd = 0; + gSaveContext.isMagicRequested = false; + } else { + gSaveContext.magicToAdd -= 4; + if (gSaveContext.magicToAdd <= 0) { + gSaveContext.magicToAdd = 0; + gSaveContext.isMagicRequested = false; + } + } + } +} + +s16 sMagicBorderColors[][3] = { + { 255, 255, 255 }, + { 150, 150, 150 }, +}; +s16 sMagicBorderIndices[] = { 0, 1, 1, 0 }; +s16 sMagicBorderColorTimerIndex[] = { 2, 1, 2, 1 }; + +void Magic_FlashMeterBorder(void) { + s16 borderChangeR; + s16 borderChangeG; + s16 borderChangeB; + s16 index = sMagicBorderIndices[sMagicBorderStep]; + + borderChangeR = ABS_ALT(sMagicMeterOutlinePrimRed - sMagicBorderColors[index][0]) / sMagicBorderRatio; + borderChangeG = ABS_ALT(sMagicMeterOutlinePrimGreen - sMagicBorderColors[index][1]) / sMagicBorderRatio; + borderChangeB = ABS_ALT(sMagicMeterOutlinePrimBlue - sMagicBorderColors[index][2]) / sMagicBorderRatio; + + if (sMagicMeterOutlinePrimRed >= sMagicBorderColors[index][0]) { + sMagicMeterOutlinePrimRed -= borderChangeR; + } else { + sMagicMeterOutlinePrimRed += borderChangeR; + } + + if (sMagicMeterOutlinePrimGreen >= sMagicBorderColors[index][1]) { + sMagicMeterOutlinePrimGreen -= borderChangeG; + } else { + sMagicMeterOutlinePrimGreen += borderChangeG; + } + + if (sMagicMeterOutlinePrimBlue >= sMagicBorderColors[index][2]) { + sMagicMeterOutlinePrimBlue -= borderChangeB; + } else { + sMagicMeterOutlinePrimBlue += borderChangeB; + } + + sMagicBorderRatio--; + if (sMagicBorderRatio == 0) { + sMagicMeterOutlinePrimRed = sMagicBorderColors[index][0]; + sMagicMeterOutlinePrimGreen = sMagicBorderColors[index][1]; + sMagicMeterOutlinePrimBlue = sMagicBorderColors[index][2]; + + sMagicBorderRatio = sMagicBorderColorTimerIndex[sMagicBorderStep]; + + sMagicBorderStep++; + if (sMagicBorderStep >= 4) { + sMagicBorderStep = 0; + } + } +} + +void Magic_Update(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 magicCapacityTarget; + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + Magic_FlashMeterBorder(); + } + + switch (gSaveContext.magicState) { + case MAGIC_STATE_STEP_CAPACITY: + // Step magicCapacity to the capacity determined by magicLevel + // This changes the width of the magic meter drawn + magicCapacityTarget = gSaveContext.save.playerData.magicLevel * MAGIC_NORMAL_METER; + if (gSaveContext.magicCapacity != magicCapacityTarget) { + if (gSaveContext.magicCapacity < magicCapacityTarget) { + gSaveContext.magicCapacity += 0x10; + if (gSaveContext.magicCapacity > magicCapacityTarget) { + gSaveContext.magicCapacity = magicCapacityTarget; + } + } else { + gSaveContext.magicCapacity -= 0x10; + if (gSaveContext.magicCapacity <= magicCapacityTarget) { + gSaveContext.magicCapacity = magicCapacityTarget; + } + } + } else { + // Once the capacity has reached its target, + // follow up by filling magic to magicFillTarget + gSaveContext.magicState = MAGIC_STATE_FILL; + } + break; + + case MAGIC_STATE_FILL: + // Add magic until magicFillTarget is reached + gSaveContext.save.playerData.magic += 0x10; + + if ((gSaveContext.gameMode == 0) && (gSaveContext.sceneLayer < 4)) { + play_sound(NA_SE_SY_GAUGE_UP - SFX_FLAG); + } + + if (((void)0, gSaveContext.save.playerData.magic) >= ((void)0, gSaveContext.magicFillTarget)) { + gSaveContext.save.playerData.magic = gSaveContext.magicFillTarget; + gSaveContext.magicState = MAGIC_STATE_IDLE; + } + break; + + case MAGIC_STATE_CONSUME_SETUP: + // Sets the speed at which magic border flashes + sMagicBorderRatio = 2; + gSaveContext.magicState = MAGIC_STATE_CONSUME; + break; + + case MAGIC_STATE_CONSUME: + // Consume magic until target is reached or no more magic is available + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + gSaveContext.save.playerData.magic = + ((void)0, gSaveContext.save.playerData.magic) - ((void)0, gSaveContext.magicToConsume); + if (gSaveContext.save.playerData.magic <= 0) { + gSaveContext.save.playerData.magic = 0; + } + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; + sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; + } + // fallthrough (flash border while magic is being consumed) + case MAGIC_STATE_METER_FLASH_1: + case MAGIC_STATE_METER_FLASH_2: + case MAGIC_STATE_METER_FLASH_3: + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + Magic_FlashMeterBorder(); + } + break; + + case MAGIC_STATE_RESET: + sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; + gSaveContext.magicState = MAGIC_STATE_IDLE; + break; + + case MAGIC_STATE_CONSUME_LENS: + // Slowly consume magic while Lens of Truth is active + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + (msgCtx->msgMode == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !Play_InCsMode(play)) { + + if ((gSaveContext.save.playerData.magic == 0) || + ((Player_GetEnvironmentalHazard(play) >= PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) && + (Player_GetEnvironmentalHazard(play) <= PLAYER_ENV_HAZARD_UNDERWATER_FREE)) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) != ITEM_LENS) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) != ITEM_LENS) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) != ITEM_LENS)) || + !play->actorCtx.lensActive) { + // Deactivate Lens of Truth and set magic state to idle + play->actorCtx.lensActive = false; + play_sound(NA_SE_SY_GLASSMODE_OFF); + gSaveContext.magicState = MAGIC_STATE_IDLE; + sMagicMeterOutlinePrimRed = sMagicMeterOutlinePrimGreen = sMagicMeterOutlinePrimBlue = 255; + break; + } + + interfaceCtx->magicConsumptionTimer--; + if (interfaceCtx->magicConsumptionTimer == 0) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + gSaveContext.save.playerData.magic--; + } + interfaceCtx->magicConsumptionTimer = 80; + } + } + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + Magic_FlashMeterBorder(); + } + break; + + case MAGIC_STATE_CONSUME_GORON_ZORA_SETUP: + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + gSaveContext.save.playerData.magic -= 2; + } + if (gSaveContext.save.playerData.magic <= 0) { + gSaveContext.save.playerData.magic = 0; + } + gSaveContext.magicState = MAGIC_STATE_CONSUME_GORON_ZORA; + // fallthrough + case MAGIC_STATE_CONSUME_GORON_ZORA: + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == 0) && + (msgCtx->msgMode == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { + if (!Play_InCsMode(play)) { + interfaceCtx->magicConsumptionTimer--; + if (interfaceCtx->magicConsumptionTimer == 0) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + gSaveContext.save.playerData.magic--; + } + if (gSaveContext.save.playerData.magic <= 0) { + gSaveContext.save.playerData.magic = 0; + } + interfaceCtx->magicConsumptionTimer = 10; + } + } + } + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + Magic_FlashMeterBorder(); + } + break; + + case MAGIC_STATE_CONSUME_GIANTS_MASK: + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + (msgCtx->msgMode == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { + if (!Play_InCsMode(play)) { + interfaceCtx->magicConsumptionTimer--; + if (interfaceCtx->magicConsumptionTimer == 0) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + gSaveContext.save.playerData.magic--; + } + if (gSaveContext.save.playerData.magic <= 0) { + gSaveContext.save.playerData.magic = 0; + } + interfaceCtx->magicConsumptionTimer = R_MAGIC_CONSUME_TIMER_GIANTS_MASK; + } + } + } + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + Magic_FlashMeterBorder(); + } + break; + + default: + gSaveContext.magicState = MAGIC_STATE_IDLE; + break; + } +} + +void Magic_DrawMeter(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 magicBarY; + + OPEN_DISPS(play->state.gfxCtx); + + if (gSaveContext.save.playerData.magicLevel != 0) { + if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + magicBarY = 42; // two rows of hearts + } else { + magicBarY = 34; // one row of hearts + } + + func_8012C654(play->state.gfxCtx); + + gDPSetEnvColor(OVERLAY_DISP++, 100, 50, 50, 255); + + OVERLAY_DISP = Gfx_DrawTexRectIA8_DropShadow( + OVERLAY_DISP, gMagicMeterEndTex, 8, 16, 18, magicBarY, 8, 16, 1 << 10, 1 << 10, sMagicMeterOutlinePrimRed, + sMagicMeterOutlinePrimGreen, sMagicMeterOutlinePrimBlue, interfaceCtx->magicAlpha); + OVERLAY_DISP = Gfx_DrawTexRectIA8_DropShadow(OVERLAY_DISP, gMagicMeterMidTex, 24, 16, 26, magicBarY, + ((void)0, gSaveContext.magicCapacity), 16, 1 << 10, 1 << 10, + sMagicMeterOutlinePrimRed, sMagicMeterOutlinePrimGreen, + sMagicMeterOutlinePrimBlue, interfaceCtx->magicAlpha); + OVERLAY_DISP = Gfx_DrawTexRectIA8_DropShadowOffset( + OVERLAY_DISP, gMagicMeterEndTex, 8, 16, ((void)0, gSaveContext.magicCapacity) + 26, magicBarY, 8, 16, + 1 << 10, 1 << 10, sMagicMeterOutlinePrimRed, sMagicMeterOutlinePrimGreen, sMagicMeterOutlinePrimBlue, + interfaceCtx->magicAlpha, 3, 0x100); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + + if (gSaveContext.magicState == MAGIC_STATE_METER_FLASH_2) { + // Yellow part of the meter indicating the amount of magic to be subtracted + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 250, 250, 0, interfaceCtx->magicAlpha); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gMagicMeterFillTex, G_IM_FMT_I, 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); + gSPTextureRectangle(OVERLAY_DISP++, 104, (magicBarY + 3) << 2, + (((void)0, gSaveContext.save.playerData.magic) + 26) << 2, (magicBarY + 10) << 2, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + + // Fill the rest of the meter with the normal magic color + gDPPipeSync(OVERLAY_DISP++); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + // Blue magic + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 200, interfaceCtx->magicAlpha); + } else { + // Green magic (default) + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 200, 0, interfaceCtx->magicAlpha); + } + + gSPTextureRectangle( + OVERLAY_DISP++, 104, (magicBarY + 3) << 2, + ((((void)0, gSaveContext.save.playerData.magic) - ((void)0, gSaveContext.magicToConsume)) + 26) << 2, + (magicBarY + 10) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } else { + // Fill the whole meter with the normal magic color + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI)) { + // Blue magic + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 200, interfaceCtx->magicAlpha); + } else { + // Green magic (default) + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 200, 0, interfaceCtx->magicAlpha); + } + + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gMagicMeterFillTex, G_IM_FMT_I, 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); + gSPTextureRectangle(OVERLAY_DISP++, 104, (magicBarY + 3) << 2, + (((void)0, gSaveContext.save.playerData.magic) + 26) << 2, (magicBarY + 10) << 2, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80116FD8.s") +void func_801170B8(InterfaceContext* interfaceCtx); #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 }; + +void func_80117100(PlayState* play); #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") +void func_80118084(PlayState* play); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118084.s") +void func_80118890(PlayState* play); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80118890.s") +void func_80118BA4(PlayState* play); #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 + +void func_80119030(PlayState* play); #pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80119030.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80119610.s") +/** + * Draws either the analog three-day clock or the digital final-hours clock + */ +#ifdef NON_MATCHING +void Interface_DrawClock(PlayState* play) { + static s16 sThreeDayClockAlpha = 255; + static s16 D_801BFB30 = 0; // sClockAlphaTimer1 + static s16 D_801BFB34 = 0; // sClockAlphaTimer2 + static u16 sThreeDayClockHours[] = { + 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, + }; + static TexturePtr sThreeDayClockHourTextures[] = { + gThreeDayClockHour12Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, + gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, + gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, + gThreeDayClockHour12Tex, gThreeDayClockHour1Tex, gThreeDayClockHour2Tex, gThreeDayClockHour3Tex, + gThreeDayClockHour4Tex, gThreeDayClockHour5Tex, gThreeDayClockHour6Tex, gThreeDayClockHour7Tex, + gThreeDayClockHour8Tex, gThreeDayClockHour9Tex, gThreeDayClockHour10Tex, gThreeDayClockHour11Tex, + }; + static s16 D_801BFBCC = 0; // sClockInvDiamondPrimRed + static s16 D_801BFBD0 = 0; // sClockInvDiamondPrimGreen + static s16 D_801BFBD4 = 255; // sClockInvDiamondPrimBlue + static s16 D_801BFBD8 = 0; // sClockInvDiamondEnvRed + static s16 D_801BFBDC = 0; // sClockInvDiamondEnvGreen + static s16 D_801BFBE0 = 0; // sClockInvDiamondEnvBlue + static s16 D_801BFBE4 = 15; // sClockInvDiamondTimer + static s16 D_801BFBE8 = 0; // sClockInvDiamondTargetIndex + static s16 D_801BFBEC[] = { 100, 0 }; // sClockInvDiamondPrimRedTargets + static s16 D_801BFBF0[] = { 205, 155 }; // sClockInvDiamondPrimGreenTargets + static s16 D_801BFBF4[] = { 255, 255 }; // sClockInvDiamondPrimBlueTargets + static s16 D_801BFBF8[] = { 30, 0 }; // sClockInvDiamondEnvRedTargets + static s16 D_801BFBFC[] = { 30, 0 }; // sClockInvDiamondEnvGreenTargets + static s16 D_801BFC00[] = { 100, 0 }; // sClockInvDiamondEnvBlueTargets + static s16 D_801BFC04[] = { 255, 0 }; // sFinalHoursClockDigitsRed + static s16 D_801BFC08[] = { 100, 0 }; // sFinalHoursClockFrameEnvRedTargets + static s16 D_801BFC0C[] = { 30, 0 }; // sFinalHoursClockFrameEnvGreenTargets + static s16 D_801BFC10[] = { 100, 0 }; // sFinalHoursClockFrameEnvBlueTargets + static TexturePtr sFinalHoursDigitTextures[] = { + gFinalHoursClockDigit0Tex, gFinalHoursClockDigit1Tex, gFinalHoursClockDigit2Tex, gFinalHoursClockDigit3Tex, + gFinalHoursClockDigit4Tex, gFinalHoursClockDigit5Tex, gFinalHoursClockDigit6Tex, gFinalHoursClockDigit7Tex, + gFinalHoursClockDigit8Tex, gFinalHoursClockDigit9Tex, gFinalHoursClockColonTex, + }; + // sFinalHoursDigitSlotPosXOffset + static s16 D_801BFC40[] = { + 127, 136, 144, 151, 160, 168, 175, 184, + }; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; + s16 sp1E6; + f32 temp_f14; + u32 timeUntilMoonCrash; + f32 sp1D8; + f32 timeInMinutes; + f32 timeInSeconds; + f32 sp1CC; + s32 new_var; + s16 sp1C6; + s16 currentHour; + u16 time; + s16 temp; + s16 colorStep; + s16 finalHoursClockSlots[8]; // sp1AC + s16 index; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B4E0.s") + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B5C0.s") + if (R_TIME_SPEED != 0) { + if ((msgCtx->msgMode == 0) || ((play->actorCtx.flags & ACTORCTX_FLAG_1) && !Play_InCsMode(play)) || + (msgCtx->msgMode == 0) || ((msgCtx->currentTextId >= 0x100) && (msgCtx->currentTextId <= 0x200)) || + (gSaveContext.gameMode == 3)) { + if (!FrameAdvance_IsEnabled(&play->state) && !Environment_IsTimeStopped() && (gSaveContext.save.day < 4)) { + /** + * Changes Clock's transparancy depending if Player is moving or not and possibly other things + */ + if (gSaveContext.hudVisibility == HUD_VISIBILITY_ALL) { + if (func_801234D4(play)) { + sThreeDayClockAlpha = 80; + D_801BFB30 = 5; + D_801BFB34 = 20; + } else if (D_801BFB34 != 0) { + D_801BFB34--; + } else if (D_801BFB30 != 0) { + colorStep = ABS_ALT(sThreeDayClockAlpha - 255) / D_801BFB30; + sThreeDayClockAlpha += colorStep; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011B9E0.s") + if (sThreeDayClockAlpha >= 255) { + sThreeDayClockAlpha = 255; + D_801BFB30 = 0; + } + } else { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + sThreeDayClockAlpha = 255; + } else { + sThreeDayClockAlpha = interfaceCtx->bAlpha; + } + D_801BFB34 = 0; + D_801BFB30 = 0; + } + } else { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + sThreeDayClockAlpha = 255; + } else { + sThreeDayClockAlpha = interfaceCtx->bAlpha; + } + D_801BFB34 = 0; + D_801BFB30 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011BF70.s") + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C4C4.s") + func_8012C654(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C808.s") + /** + * Draw Clock's Hour Lines + */ + gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); + gDPSetRenderMode(OVERLAY_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 130, 130, 130, sThreeDayClockAlpha); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, + TEXEL0, 0, PRIMITIVE, 0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011C898.s") + OVERLAY_DISP = Gfx_DrawTexRect4b(OVERLAY_DISP, gThreeDayClockHourLinesTex, 4, 64, 35, 96, 180, 128, + 35, 1, 6, 0, 1 << 10, 1 << 10); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011CA64.s") + /** + * Draw Clock's Border + */ + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, sThreeDayClockAlpha); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, + TEXEL0, 0, PRIMITIVE, 0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E3B4.s") + //! @bug A texture height of 50 is given below. The texture is only 48 units height + //! resulting in this reading into the next texture. This results in a white + //! dot in the bottom center of the clock. For the three-day clock, this is + //! covered by the diamond. However, it can be seen by the final-hours clock. + OVERLAY_DISP = Gfx_DrawTexRect4b(OVERLAY_DISP, gThreeDayClockBorderTex, 4, 64, 50, 96, 168, 128, 50, + 1, 6, 0, 1 << 10, 1 << 10); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011E730.s") + if (((CURRENT_DAY >= 4) || ((CURRENT_DAY == 3) && (((void)0, gSaveContext.save.time) >= 5) && + (((void)0, gSaveContext.save.time) < CLOCK_TIME(6, 0))))) { + func_8012C8D4(play->state.gfxCtx); + gSPMatrix(OVERLAY_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } else { + /** + * Draw Three-Day Clock's Diamond + */ + gDPPipeSync(OVERLAY_DISP++); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_8011F0E0.s") + // Time is slowed down to half speed with inverted song of time + if (gSaveContext.save.timeSpeedOffset == -2) { + // Clock diamond is blue and flashes white + colorStep = ABS_ALT(D_801BFBCC - D_801BFBEC[D_801BFBE8]) / D_801BFBE4; + if (D_801BFBCC >= D_801BFBEC[D_801BFBE8]) { + D_801BFBCC -= colorStep; + } else { + D_801BFBCC += colorStep; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80120F90.s") + colorStep = ABS_ALT(D_801BFBD0 - D_801BFBF0[D_801BFBE8]) / D_801BFBE4; + if (D_801BFBD0 >= D_801BFBF0[D_801BFBE8]) { + D_801BFBD0 -= colorStep; + } else { + D_801BFBD0 += colorStep; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121064.s") + colorStep = ABS_ALT(D_801BFBD4 - D_801BFBF4[D_801BFBE8]) / D_801BFBE4; + if (D_801BFBD4 >= D_801BFBF4[D_801BFBE8]) { + D_801BFBD4 -= colorStep; + } else { + D_801BFBD4 += colorStep; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_801210E0.s") + colorStep = ABS_ALT(D_801BFBD8 - D_801BFBF8[D_801BFBE8]) / D_801BFBE4; + if (D_801BFBD8 >= D_801BFBF8[D_801BFBE8]) { + D_801BFBD8 -= colorStep; + } else { + D_801BFBD8 += colorStep; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121F94.s") + colorStep = ABS_ALT(D_801BFBDC - D_801BFBFC[D_801BFBE8]) / D_801BFBE4; + if (D_801BFBDC >= D_801BFBFC[D_801BFBE8]) { + D_801BFBDC -= colorStep; + } else { + D_801BFBDC += colorStep; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/func_80121FC4.s") + colorStep = ABS_ALT(D_801BFBE0 - D_801BFC00[D_801BFBE8]) / D_801BFBE4; + if (D_801BFBE0 >= D_801BFC00[D_801BFBE8]) { + D_801BFBE0 -= colorStep; + } else { + D_801BFBE0 += colorStep; + } + + D_801BFBE4--; + + if (D_801BFBE4 == 0) { + D_801BFBCC = D_801BFBEC[D_801BFBE8]; + D_801BFBD0 = D_801BFBF0[D_801BFBE8]; + D_801BFBD4 = D_801BFBF4[D_801BFBE8]; + D_801BFBD8 = D_801BFBF8[D_801BFBE8]; + D_801BFBDC = D_801BFBFC[D_801BFBE8]; + D_801BFBE0 = D_801BFC00[D_801BFBE8]; + D_801BFBE4 = 15; + D_801BFBE8 ^= 1; + } + + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, + PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, + PRIMITIVE, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, D_801BFBCC, D_801BFBD0, 255, sThreeDayClockAlpha); + gDPSetEnvColor(OVERLAY_DISP++, D_801BFBD8, D_801BFBDC, D_801BFBE0, 0); + } else { + // Clock diamond is green for regular timeSpeedOffset + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 170, 100, sThreeDayClockAlpha); + } + + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gThreeDayClockDiamondTex, 40, 32, 140, 190, 40, + 32, 1 << 10, 1 << 10); + + /** + * Draw Three-Day Clock's Day-Number over Diamond + */ + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 155, sThreeDayClockAlpha); + + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, interfaceCtx->doActionSegment + 0x780, 48, 27, + 137, 192, 48, 27, 1 << 10, 1 << 10); + + /** + * Draw Three-Day Clock's Star (for the Minute Tracker) + */ + gDPPipeSync(OVERLAY_DISP++); + + if (D_801BF974 != 0) { + D_801BF980 += 0.02f; + D_801BF97C += 11; + } else { + D_801BF980 -= 0.02f; + D_801BF97C -= 11; + } + + D_801BF978--; + if (D_801BF978 == 0) { + D_801BF978 = 10; + D_801BF974 ^= 1; + } + + timeInSeconds = TIME_TO_SECONDS_F(gSaveContext.save.time); + timeInSeconds -= ((s16)(timeInSeconds / 3600.0f)) * 3600.0f; + + func_8012C8D4(play->state.gfxCtx); + + gSPMatrix(OVERLAY_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (sThreeDayClockAlpha != 255) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 110, sThreeDayClockAlpha); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 110, D_801BF97C); + } + + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); + gDPSetRenderMode(OVERLAY_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + + Matrix_Translate(0.0f, -86.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, D_801BF980, MTXMODE_APPLY); + Matrix_RotateZF(-(timeInSeconds * 0.0175f) / 10.0f, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[12], 4, 0); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gThreeDayClockStarMinuteTex, G_IM_FMT_I, 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); + gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); + } + + /** + * Cuts off Three-Day Clock's Sun and Moon when they dip below the clock + */ + gDPPipeSync(OVERLAY_DISP++); + gDPSetScissorFrac(OVERLAY_DISP++, G_SC_NON_INTERLACE, 400, 620, 880, + R_THREE_DAY_CLOCK_SUN_MOON_CUTOFF * 4.0f); + + // determines the current hour + for (sp1C6 = 0; sp1C6 <= 24; sp1C6++) { + if (((void)0, gSaveContext.save.time) < sThreeDayClockHours[sp1C6 + 1]) { + break; + } + } + + /** + * Draw Three-Day Clock's Sun (for the Day-Time Hours Tracker) + */ + time = gSaveContext.save.time; + sp1D8 = Math_SinS(time) * -40.0f; + temp_f14 = Math_CosS(time) * -34.0f; + + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 100, 110, sThreeDayClockAlpha); + + Matrix_Translate(sp1D8, temp_f14, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[16], 4, 0); + + OVERLAY_DISP = Gfx_DrawTexQuadIA8(OVERLAY_DISP, gThreeDayClockSunHourTex, 24, 24, 0); + + /** + * Draw Three-Day Clock's Moon (for the Night-Time Hours Tracker) + */ + sp1D8 = Math_SinS(time) * 40.0f; + temp_f14 = Math_CosS(time) * 34.0f; + + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 55, sThreeDayClockAlpha); + + Matrix_Translate(sp1D8, temp_f14, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[20], 4, 0); + + OVERLAY_DISP = Gfx_DrawTexQuadIA8(OVERLAY_DISP, gThreeDayClockMoonHourTex, 24, 24, 0); + + /** + * Cuts off Three-Day Clock's Hour Digits when they dip below the clock + */ + gDPPipeSync(OVERLAY_DISP++); + gDPSetScissorFrac(OVERLAY_DISP++, G_SC_NON_INTERLACE, 400, 620, 880, + R_THREE_DAY_CLOCK_HOUR_DIGIT_CUTOFF * 4.0f); + + /** + * Draws Three-Day Clock's Hour Digit Above the Sun + */ + sp1CC = gSaveContext.save.time * 0.000096131f; + + // Rotates Three-Day Clock's Hour Digit To Above the Sun + Matrix_Translate(0.0f, R_THREE_DAY_CLOCK_Y_POS / 10.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZF(-(sp1CC - 3.15f), MTXMODE_APPLY); + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + // Draws Three-Day Clock's Hour Digit Above the Sun + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, + TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, sThreeDayClockAlpha); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[24], 8, 0); + + OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTextures[sp1C6], 4, 16, 11, 0); + + // Colours the Three-Day Clocks's Hour Digit Above the Sun + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 155, sThreeDayClockAlpha); + gSP1Quadrangle(OVERLAY_DISP++, 4, 6, 7, 5, 0); + + /** + * Draws Three-Day Clock's Hour Digit Above the Moon + */ + // Rotates Three-Day Clock's Hour Digit To Above the Moon + Matrix_Translate(0.0f, R_THREE_DAY_CLOCK_Y_POS / 10.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZF(-sp1CC, MTXMODE_APPLY); + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + // Draws Three-Day Clock's Hour Digit Above the Moon + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, + TEXEL0, 0, PRIMITIVE, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, sThreeDayClockAlpha); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[32], 8, 0); + + OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, sThreeDayClockHourTextures[sp1C6], 4, 16, 11, 0); + + // Colours the Three-Day Clocks's Hour Digit Above the Moon + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 155, sThreeDayClockAlpha); + gSP1Quadrangle(OVERLAY_DISP++, 4, 6, 7, 5, 0); + + gSPDisplayList(OVERLAY_DISP++, D_0E000000.setScissor); + + // Final Hours + if ((CURRENT_DAY >= 4) || ((CURRENT_DAY == 3) && (((void)0, gSaveContext.save.time) >= 5) && + (((void)0, gSaveContext.save.time) < CLOCK_TIME(6, 0)))) { + if (((void)0, gSaveContext.save.time) >= CLOCK_TIME(5, 0)) { + // The Final Hours clock will flash red + + colorStep = + ABS_ALT(sFinalHoursClockDigitsRed - D_801BFC04[sFinalHoursClockColorTargetIndex]) / + sFinalHoursClockColorTimer; + if (sFinalHoursClockDigitsRed >= D_801BFC04[sFinalHoursClockColorTargetIndex]) { + sFinalHoursClockDigitsRed -= colorStep; + } else { + sFinalHoursClockDigitsRed += colorStep; + } + + colorStep = + ABS_ALT(sFinalHoursClockFrameEnvRed - D_801BFC08[sFinalHoursClockColorTargetIndex]) / + sFinalHoursClockColorTimer; + if (sFinalHoursClockFrameEnvRed >= D_801BFC08[sFinalHoursClockColorTargetIndex]) { + sFinalHoursClockFrameEnvRed -= colorStep; + } else { + sFinalHoursClockFrameEnvRed += colorStep; + } + + colorStep = + ABS_ALT(sFinalHoursClockFrameEnvGreen - D_801BFC0C[sFinalHoursClockColorTargetIndex]) / + sFinalHoursClockColorTimer; + if (sFinalHoursClockFrameEnvGreen >= D_801BFC0C[sFinalHoursClockColorTargetIndex]) { + sFinalHoursClockFrameEnvGreen -= colorStep; + } else { + sFinalHoursClockFrameEnvGreen += colorStep; + } + + colorStep = + ABS_ALT(sFinalHoursClockFrameEnvBlue - D_801BFC10[sFinalHoursClockColorTargetIndex]) / + sFinalHoursClockColorTimer; + if (sFinalHoursClockFrameEnvBlue >= D_801BFC10[sFinalHoursClockColorTargetIndex]) { + sFinalHoursClockFrameEnvBlue -= colorStep; + } else { + sFinalHoursClockFrameEnvBlue += colorStep; + } + + sFinalHoursClockColorTimer--; + + if (sFinalHoursClockColorTimer == 0) { + sFinalHoursClockDigitsRed = D_801BFC04[sFinalHoursClockColorTargetIndex]; + sFinalHoursClockFrameEnvRed = D_801BFC08[sFinalHoursClockColorTargetIndex]; + sFinalHoursClockFrameEnvGreen = D_801BFC0C[sFinalHoursClockColorTargetIndex]; + sFinalHoursClockFrameEnvBlue = D_801BFC10[sFinalHoursClockColorTargetIndex]; + sFinalHoursClockColorTimer = 6; + sFinalHoursClockColorTargetIndex ^= 1; + } + } + + sp1E6 = sThreeDayClockAlpha; + if (sp1E6 != 0) { + sp1E6 = 255; + } + + func_8012C654(play->state.gfxCtx); + + /** + * Draws Final-Hours Clock's Frame + */ + gSPMatrix(OVERLAY_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); + gDPSetRenderMode(OVERLAY_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, + PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, + PRIMITIVE, 0); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 195, sp1E6); + gDPSetEnvColor(OVERLAY_DISP++, sFinalHoursClockFrameEnvRed, sFinalHoursClockFrameEnvGreen, + sFinalHoursClockFrameEnvBlue, 0); + + OVERLAY_DISP = Gfx_DrawTexRect4b(OVERLAY_DISP, gFinalHoursClockFrameTex, 3, 80, 13, 119, 202, + 80, 13, 0, 0, 0, 1 << 10, 1 << 10); + + finalHoursClockSlots[0] = 0; + + timeUntilMoonCrash = TIME_UNTIL_MOON_CRASH; + + timeInMinutes = TIME_TO_MINUTES_F(timeUntilMoonCrash); + + // digits for hours + finalHoursClockSlots[1] = timeInMinutes / 60.0f; + finalHoursClockSlots[2] = timeInMinutes / 60.0f; + + temp = (s32)timeInMinutes % 60; + + while (finalHoursClockSlots[1] >= 10) { + finalHoursClockSlots[0]++; + finalHoursClockSlots[1] -= 10; + } + + // digits for minutes + finalHoursClockSlots[3] = 0; + finalHoursClockSlots[4] = temp; + + while (finalHoursClockSlots[4] >= 10) { + finalHoursClockSlots[3]++; + finalHoursClockSlots[4] -= 10; + } + + // digits for seconds + finalHoursClockSlots[6] = 0; + finalHoursClockSlots[7] = + timeUntilMoonCrash - (u32)((finalHoursClockSlots[2] * ((f32)0x10000 / 24)) + + (((void)0, temp) * ((f32)0x10000 / (24 * 60)))); + + while (finalHoursClockSlots[7] >= 10) { + finalHoursClockSlots[6]++; + finalHoursClockSlots[7] -= 10; + } + + // Colon separating hours from minutes and minutes from seconds + finalHoursClockSlots[2] = finalHoursClockSlots[5] = 10; + + /** + * Draws Final-Hours Clock's Digits + */ + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sFinalHoursClockDigitsRed, 0, 0, sp1E6); + gDPSetEnvColor(OVERLAY_DISP++, sFinalHoursClockDigitsRed, 0, 0, 0); + + for (sp1C6 = 0; sp1C6 < 8; sp1C6++) { + index = D_801BFC40[sp1C6]; + + OVERLAY_DISP = + Gfx_DrawTexRectI8(OVERLAY_DISP, sFinalHoursDigitTextures[finalHoursClockSlots[sp1C6]], + 8, 8, index, 205, 8, 8, 1 << 10, 1 << 10); + } + } + } + } + } + } + CLOSE_DISPS(play->state.gfxCtx); +} +#else +s16 sThreeDayClockAlpha = 255; +s16 D_801BFB30 = 0; +s16 D_801BFB34 = 0; +u16 sThreeDayClockHours[] = { + 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 sThreeDayClockHourTextures[] = { + 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 sFinalHoursDigitTextures[] = { + gFinalHoursClockDigit0Tex, gFinalHoursClockDigit1Tex, gFinalHoursClockDigit2Tex, gFinalHoursClockDigit3Tex, + gFinalHoursClockDigit4Tex, gFinalHoursClockDigit5Tex, gFinalHoursClockDigit6Tex, gFinalHoursClockDigit7Tex, + gFinalHoursClockDigit8Tex, gFinalHoursClockDigit9Tex, gFinalHoursClockColonTex, +}; +s16 D_801BFC40[] = { + 127, 136, 144, 151, 160, 168, 175, 184, +}; +void Interface_DrawClock(PlayState* play); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_parameter/Interface_DrawClock.s") +#endif + +void Interface_SetPerfectLetters(PlayState* play, s16 perfectLettersType) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i; + + interfaceCtx->perfectLettersOn = true; + interfaceCtx->perfectLettersType = perfectLettersType; + + interfaceCtx->perfectLettersPrimColor[0] = 255; + interfaceCtx->perfectLettersPrimColor[1] = 165; + interfaceCtx->perfectLettersPrimColor[2] = 55; + interfaceCtx->perfectLettersPrimColor[3] = 255; + interfaceCtx->perfectLettersColorTimer = 20; + + interfaceCtx->perfectLettersColorIndex = 0; + interfaceCtx->perfectLettersCount = 1; + interfaceCtx->perfectLettersTimer = 0; + + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersAngles[i] = 0; + interfaceCtx->perfectLettersState[i] = interfaceCtx->perfectLettersOffsetX[i] = 0; + if (interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_1) { + interfaceCtx->perfectLettersSemiAxisX[i] = 140.0f; + interfaceCtx->perfectLettersSemiAxisY[i] = 100.0f; + } else { + interfaceCtx->perfectLettersSemiAxisY[i] = 200.0f; + interfaceCtx->perfectLettersSemiAxisX[i] = 200.0f; + } + } + interfaceCtx->perfectLettersState[0] = PERFECT_LETTERS_STATE_INIT; +} + +u16 sPerfectLettersType1OffScreenAngles[PERFECT_LETTERS_NUM_LETTERS] = { + 6 * PERFECT_LETTERS_ANGLE_PER_LETTER, // P + 7 * PERFECT_LETTERS_ANGLE_PER_LETTER, // E + 0 * PERFECT_LETTERS_ANGLE_PER_LETTER, // R + 1 * PERFECT_LETTERS_ANGLE_PER_LETTER, // F + 5 * PERFECT_LETTERS_ANGLE_PER_LETTER, // E + 4 * PERFECT_LETTERS_ANGLE_PER_LETTER, // C + 3 * PERFECT_LETTERS_ANGLE_PER_LETTER, // T + 2 * PERFECT_LETTERS_ANGLE_PER_LETTER, // ! +}; + +s16 sPerfectLettersType1PrimColorTargets[2][3] = { + { 255, 255, 255 }, + { 255, 165, 55 }, +}; + +void Interface_UpdatePerfectLettersType1(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i; + s16 count; + s16 colorStepR; + s16 colorStepG; + s16 colorStepB; + + // Update letter positions + for (count = 0, i = 0; i < interfaceCtx->perfectLettersCount; i++, count += 4) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_INIT) { + // Initialize letter positions along the elliptical spirals + interfaceCtx->perfectLettersAngles[i] = sPerfectLettersType1OffScreenAngles[i] + 0xA000; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_ENTER; + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_ENTER) { + // Swirl inwards along elliptical spirals to form the spelt-out word + interfaceCtx->perfectLettersAngles[i] -= 0x800; + if (interfaceCtx->perfectLettersAngles[i] == sPerfectLettersType1OffScreenAngles[i]) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_STATIONARY; + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_SPREAD) { + // Swirl outwards along elliptical spirals offscreen + interfaceCtx->perfectLettersAngles[i] -= 0x800; + if (interfaceCtx->perfectLettersAngles[i] == (u16)(sPerfectLettersType1OffScreenAngles[i] - 0x8000)) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_OFF; + } + } + } + + // Initialize the next letter in the list + // if `perfectLettersCount == PERFECT_LETTERS_NUM_LETTERS`, + // then perfectLettersState[] is accessed + if ((interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] == PERFECT_LETTERS_STATE_OFF) && + (interfaceCtx->perfectLettersCount < PERFECT_LETTERS_NUM_LETTERS)) { + interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] = PERFECT_LETTERS_STATE_INIT; + + interfaceCtx->perfectLettersSemiAxisX[interfaceCtx->perfectLettersCount] = 140.0f; + interfaceCtx->perfectLettersSemiAxisY[interfaceCtx->perfectLettersCount] = 100.0f; + interfaceCtx->perfectLettersAngles[interfaceCtx->perfectLettersCount] = + sPerfectLettersType1OffScreenAngles[interfaceCtx->perfectLettersCount] + 0xA000; + + interfaceCtx->perfectLettersCount++; + } + + // Update letter colors + if ((interfaceCtx->perfectLettersCount == PERFECT_LETTERS_NUM_LETTERS) && + (interfaceCtx->perfectLettersState[PERFECT_LETTERS_NUM_LETTERS - 1] == PERFECT_LETTERS_STATE_STATIONARY)) { + + colorStepR = ABS_ALT(interfaceCtx->perfectLettersPrimColor[0] - + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) / + interfaceCtx->perfectLettersColorTimer; + colorStepG = ABS_ALT(interfaceCtx->perfectLettersPrimColor[1] - + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) / + interfaceCtx->perfectLettersColorTimer; + colorStepB = ABS_ALT(interfaceCtx->perfectLettersPrimColor[2] - + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) / + interfaceCtx->perfectLettersColorTimer; + + if (interfaceCtx->perfectLettersPrimColor[0] >= + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) { + interfaceCtx->perfectLettersPrimColor[0] -= colorStepR; + } else { + interfaceCtx->perfectLettersPrimColor[0] += colorStepR; + } + + if (interfaceCtx->perfectLettersPrimColor[1] >= + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) { + interfaceCtx->perfectLettersPrimColor[1] -= colorStepG; + } else { + interfaceCtx->perfectLettersPrimColor[1] += colorStepG; + } + + if (interfaceCtx->perfectLettersPrimColor[2] >= + sPerfectLettersType1PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) { + interfaceCtx->perfectLettersPrimColor[2] -= colorStepB; + } else { + interfaceCtx->perfectLettersPrimColor[2] += colorStepB; + } + + interfaceCtx->perfectLettersColorTimer--; + + if (interfaceCtx->perfectLettersColorTimer == 0) { + interfaceCtx->perfectLettersColorTimer = 20; + interfaceCtx->perfectLettersColorIndex ^= 1; + interfaceCtx->perfectLettersTimer++; + + if (interfaceCtx->perfectLettersTimer == 6) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_SPREAD; + } + } + } + } + + for (count = 0, i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_OFF) { + count++; + } + } + + if (count == PERFECT_LETTERS_NUM_LETTERS) { + interfaceCtx->perfectLettersOn = false; + } +} + +// Targets to offset each letter to properly spell "PERFECT!" +s16 sPerfectLettersType2SpellingOffsetsX[PERFECT_LETTERS_NUM_LETTERS] = { + 78, // P + 54, // E + 29, // R + 5, // F + -18, // E + -42, // C + -67, // T + -85, // ! +}; + +// Targets to offset each letter to sweep horizontally offscreen +s16 sPerfectLettersType2OffScreenOffsetsX[PERFECT_LETTERS_NUM_LETTERS] = { + 180, // P (offscreen left) + 180, // E (offscreen left) + 180, // R (offscreen left) + 180, // F (offscreen left) + -180, // E (offscreen right) + -180, // C (offscreen right) + -180, // T (offscreen right) + -180, // ! (offscreen right) +}; + +s16 sPerfectLettersType2PrimColorTargets[2][3] = { + { 255, 255, 255 }, + { 255, 165, 55 }, +}; + +void Interface_UpdatePerfectLettersType2(PlayState* play) { + s16 i; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 colorStepR; + s16 colorStepG; + s16 colorStepB; + s16 colorStepA; + s16 j = 0; // unused incrementer + + // Update letter positions + for (i = 0; i < interfaceCtx->perfectLettersCount; i++, j += 4) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_INIT) { + // Initialize letter positions along the elliptical spirals + interfaceCtx->perfectLettersAngles[i] = i * (0x10000 / PERFECT_LETTERS_NUM_LETTERS); + interfaceCtx->perfectLettersSemiAxisX[i] = 200.0f; + interfaceCtx->perfectLettersSemiAxisY[i] = 200.0f; + + interfaceCtx->perfectLettersOffsetX[i] = 0; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_ENTER; + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_ENTER) { + // Swirl inwards along elliptical spirals to the center of the screen + interfaceCtx->perfectLettersAngles[i] -= 0x800; + interfaceCtx->perfectLettersSemiAxisX[i] -= 8.0f; + interfaceCtx->perfectLettersSemiAxisY[i] -= 8.0f; + + if (interfaceCtx->perfectLettersSemiAxisX[i] <= 0.0f) { + // The letter has reached the center of the screen + interfaceCtx->perfectLettersSemiAxisY[i] = 0.0f; + interfaceCtx->perfectLettersSemiAxisX[i] = 0.0f; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_STATIONARY; + + if (i == (PERFECT_LETTERS_NUM_LETTERS - 1)) { + // The last letter has reached the center of the screen + interfaceCtx->perfectLettersColorTimer = 5; + interfaceCtx->perfectLettersState[0] = interfaceCtx->perfectLettersState[1] = + interfaceCtx->perfectLettersState[2] = interfaceCtx->perfectLettersState[3] = + interfaceCtx->perfectLettersState[4] = interfaceCtx->perfectLettersState[5] = + interfaceCtx->perfectLettersState[6] = interfaceCtx->perfectLettersState[7] = + PERFECT_LETTERS_STATE_SPREAD; + } + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_SPREAD) { + // Spread out the letters horizontally from the center to the spelt-out word + colorStepR = ABS_ALT(interfaceCtx->perfectLettersOffsetX[i] - sPerfectLettersType2SpellingOffsetsX[i]) / + interfaceCtx->perfectLettersColorTimer; + if (interfaceCtx->perfectLettersOffsetX[i] >= sPerfectLettersType2SpellingOffsetsX[i]) { + interfaceCtx->perfectLettersOffsetX[i] -= colorStepR; + } else { + interfaceCtx->perfectLettersOffsetX[i] += colorStepR; + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_EXIT) { + // Spread out the letters horizontally from the spelt-out world to offscreen + colorStepR = ABS_ALT(interfaceCtx->perfectLettersOffsetX[i] - sPerfectLettersType2OffScreenOffsetsX[i]) / + interfaceCtx->perfectLettersColorTimer; + if (interfaceCtx->perfectLettersOffsetX[i] >= sPerfectLettersType2OffScreenOffsetsX[i]) { + interfaceCtx->perfectLettersOffsetX[i] -= colorStepR; + } else { + interfaceCtx->perfectLettersOffsetX[i] += colorStepR; + } + } + } + + if ((interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_SPREAD) || + (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_EXIT)) { + if (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_EXIT) { + colorStepA = interfaceCtx->perfectLettersPrimColor[3] / interfaceCtx->perfectLettersColorTimer; + interfaceCtx->perfectLettersPrimColor[3] -= colorStepA; + } + interfaceCtx->perfectLettersColorTimer--; + if (interfaceCtx->perfectLettersColorTimer == 0) { + + if (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_SPREAD) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_DISPLAY; + } + interfaceCtx->perfectLettersColorTimer = 20; + } else { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_OFF; + } + interfaceCtx->perfectLettersOn = false; + } + } + } + + // Initialize the next letter in the list + if (interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] == PERFECT_LETTERS_STATE_OFF) { + if (interfaceCtx->perfectLettersCount < PERFECT_LETTERS_NUM_LETTERS) { + interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] = PERFECT_LETTERS_STATE_INIT; + interfaceCtx->perfectLettersCount++; + } + } + + // Update letter colors + if (interfaceCtx->perfectLettersCount == PERFECT_LETTERS_NUM_LETTERS) { + if (interfaceCtx->perfectLettersState[PERFECT_LETTERS_NUM_LETTERS - 1] == PERFECT_LETTERS_STATE_DISPLAY) { + + colorStepR = ABS_ALT(interfaceCtx->perfectLettersPrimColor[0] - + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) / + interfaceCtx->perfectLettersColorTimer; + colorStepG = ABS_ALT(interfaceCtx->perfectLettersPrimColor[1] - + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) / + interfaceCtx->perfectLettersColorTimer; + colorStepB = ABS_ALT(interfaceCtx->perfectLettersPrimColor[2] - + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) / + interfaceCtx->perfectLettersColorTimer; + + if (interfaceCtx->perfectLettersPrimColor[0] >= + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) { + interfaceCtx->perfectLettersPrimColor[0] -= colorStepR; + } else { + interfaceCtx->perfectLettersPrimColor[0] += colorStepR; + } + + if (interfaceCtx->perfectLettersPrimColor[1] >= + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) { + interfaceCtx->perfectLettersPrimColor[1] -= colorStepG; + } else { + interfaceCtx->perfectLettersPrimColor[1] += colorStepG; + } + + if (interfaceCtx->perfectLettersPrimColor[2] >= + sPerfectLettersType2PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) { + interfaceCtx->perfectLettersPrimColor[2] -= colorStepB; + } else { + interfaceCtx->perfectLettersPrimColor[2] += colorStepB; + } + + interfaceCtx->perfectLettersColorTimer--; + if (interfaceCtx->perfectLettersColorTimer == 0) { + interfaceCtx->perfectLettersColorTimer = 20; + interfaceCtx->perfectLettersColorIndex ^= 1; + interfaceCtx->perfectLettersTimer++; + if (interfaceCtx->perfectLettersTimer == 6) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_EXIT; + } + interfaceCtx->perfectLettersColorTimer = 5; + } + } + } + } +} + +// Targets to offset each letter to properly spell "PERFECT!" +s16 sPerfectLettersType3SpellingOffsetsX[PERFECT_LETTERS_NUM_LETTERS] = { + 78, // P + 54, // E + 29, // R + 5, // F + -18, // E + -42, // C + -67, // T + -85, // ! +}; + +// Targets to sweep each letter's angle along an elliptical spiral offscreen +u16 sPerfectLettersType3OffScreenAngles[PERFECT_LETTERS_NUM_LETTERS] = { + 6 * PERFECT_LETTERS_ANGLE_PER_LETTER, // P + 7 * PERFECT_LETTERS_ANGLE_PER_LETTER, // E + 0 * PERFECT_LETTERS_ANGLE_PER_LETTER, // R + 1 * PERFECT_LETTERS_ANGLE_PER_LETTER, // F + 5 * PERFECT_LETTERS_ANGLE_PER_LETTER, // E + 4 * PERFECT_LETTERS_ANGLE_PER_LETTER, // C + 3 * PERFECT_LETTERS_ANGLE_PER_LETTER, // T + 2 * PERFECT_LETTERS_ANGLE_PER_LETTER, // ! +}; + +s16 sPerfectLettersType3PrimColorTargets[2][3] = { + { 255, 255, 255 }, + { 255, 165, 55 }, +}; + +void Interface_UpdatePerfectLettersType3(PlayState* play) { + s16 i; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 colorStepR; + s16 colorStepG; + s16 colorStepB; + s16 j = 0; + + // Update letter positions + for (i = 0; i < interfaceCtx->perfectLettersCount; i++, j += 4) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_INIT) { + // Initialize letter positions along the elliptical spirals + interfaceCtx->perfectLettersAngles[i] = i * (0x10000 / PERFECT_LETTERS_NUM_LETTERS); + interfaceCtx->perfectLettersSemiAxisX[i] = 200.0f; + interfaceCtx->perfectLettersSemiAxisY[i] = 200.0f; + + interfaceCtx->perfectLettersOffsetX[i] = 0; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_ENTER; + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_ENTER) { + // Swirl inwards along elliptical spirals to the center of the screen + interfaceCtx->perfectLettersAngles[i] -= 0x800; + interfaceCtx->perfectLettersSemiAxisX[i] -= 8.0f; + interfaceCtx->perfectLettersSemiAxisY[i] -= 8.0f; + + if (interfaceCtx->perfectLettersSemiAxisX[i] <= 0.0f) { + // The letter has reached the center of the screen + interfaceCtx->perfectLettersSemiAxisY[i] = 0.0f; + interfaceCtx->perfectLettersSemiAxisX[i] = 0.0f; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_STATIONARY; + + if (i == (PERFECT_LETTERS_NUM_LETTERS - 1)) { + // The last letter has reached the center of the screen + interfaceCtx->perfectLettersColorTimer = 5; + interfaceCtx->perfectLettersState[0] = interfaceCtx->perfectLettersState[1] = + interfaceCtx->perfectLettersState[2] = interfaceCtx->perfectLettersState[3] = + interfaceCtx->perfectLettersState[4] = interfaceCtx->perfectLettersState[5] = + interfaceCtx->perfectLettersState[6] = interfaceCtx->perfectLettersState[7] = + PERFECT_LETTERS_STATE_SPREAD; + } + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_SPREAD) { + // Spread out the letters horizontally from the center to the spelt-out word + colorStepR = ABS_ALT(interfaceCtx->perfectLettersOffsetX[i] - sPerfectLettersType3SpellingOffsetsX[i]) / + interfaceCtx->perfectLettersColorTimer; + if (interfaceCtx->perfectLettersOffsetX[i] >= sPerfectLettersType3SpellingOffsetsX[i]) { + interfaceCtx->perfectLettersOffsetX[i] -= colorStepR; + } else { + interfaceCtx->perfectLettersOffsetX[i] += colorStepR; + } + } else if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_EXIT) { + // Swirl outwards along elliptical spirals offscreen + interfaceCtx->perfectLettersAngles[i] -= 0x800; + if (interfaceCtx->perfectLettersAngles[i] == (u16)(sPerfectLettersType3OffScreenAngles[i] - 0x8000)) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_OFF; + } + } + } + + if (interfaceCtx->perfectLettersState[0] == PERFECT_LETTERS_STATE_SPREAD) { + interfaceCtx->perfectLettersColorTimer--; + if (interfaceCtx->perfectLettersColorTimer == 0) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_DISPLAY; + } + interfaceCtx->perfectLettersColorTimer = 20; + } + } + + // Initialize the next letter in the list + if ((interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] == PERFECT_LETTERS_STATE_OFF) && + (interfaceCtx->perfectLettersCount < PERFECT_LETTERS_NUM_LETTERS)) { + interfaceCtx->perfectLettersState[interfaceCtx->perfectLettersCount] = PERFECT_LETTERS_STATE_INIT; + interfaceCtx->perfectLettersCount++; + } + + // Update letter colors + if ((interfaceCtx->perfectLettersCount == PERFECT_LETTERS_NUM_LETTERS) && + (interfaceCtx->perfectLettersState[PERFECT_LETTERS_NUM_LETTERS - 1] == PERFECT_LETTERS_STATE_DISPLAY)) { + + colorStepR = ABS_ALT(interfaceCtx->perfectLettersPrimColor[0] - + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) / + interfaceCtx->perfectLettersColorTimer; + colorStepG = ABS_ALT(interfaceCtx->perfectLettersPrimColor[1] - + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) / + interfaceCtx->perfectLettersColorTimer; + colorStepB = ABS_ALT(interfaceCtx->perfectLettersPrimColor[2] - + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) / + interfaceCtx->perfectLettersColorTimer; + + if (interfaceCtx->perfectLettersPrimColor[0] >= + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][0]) { + interfaceCtx->perfectLettersPrimColor[0] -= colorStepR; + } else { + interfaceCtx->perfectLettersPrimColor[0] += colorStepR; + } + + if (interfaceCtx->perfectLettersPrimColor[1] >= + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][1]) { + interfaceCtx->perfectLettersPrimColor[1] -= colorStepG; + } else { + interfaceCtx->perfectLettersPrimColor[1] += colorStepG; + } + + if (interfaceCtx->perfectLettersPrimColor[2] >= + sPerfectLettersType3PrimColorTargets[interfaceCtx->perfectLettersColorIndex][2]) { + interfaceCtx->perfectLettersPrimColor[2] -= colorStepB; + } else { + interfaceCtx->perfectLettersPrimColor[2] += colorStepB; + } + + interfaceCtx->perfectLettersColorTimer--; + if (interfaceCtx->perfectLettersColorTimer == 0) { + interfaceCtx->perfectLettersColorTimer = 20; + interfaceCtx->perfectLettersColorIndex ^= 1; + interfaceCtx->perfectLettersTimer++; + if (interfaceCtx->perfectLettersTimer == 6) { + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + interfaceCtx->perfectLettersSemiAxisX[i] = 140.0f; + interfaceCtx->perfectLettersSemiAxisY[i] = 100.0f; + interfaceCtx->perfectLettersAngles[i] = sPerfectLettersType3OffScreenAngles[i]; + interfaceCtx->perfectLettersState[i] = PERFECT_LETTERS_STATE_EXIT; + } + interfaceCtx->perfectLettersColorTimer = 5; + } + } + } + + j = 0; + for (i = 0; i < PERFECT_LETTERS_NUM_LETTERS; i++) { + if (interfaceCtx->perfectLettersState[i] == PERFECT_LETTERS_STATE_OFF) { + j++; + } + } + + if (j == PERFECT_LETTERS_NUM_LETTERS) { + interfaceCtx->perfectLettersOn = false; + } +} + +TexturePtr sPerfectLettersTextures[PERFECT_LETTERS_NUM_LETTERS] = { + gPerfectLetterPTex, gPerfectLetterETex, gPerfectLetterRTex, gPerfectLetterFTex, + gPerfectLetterETex, gPerfectLetterCTex, gPerfectLetterTTex, gPerfectLetterExclamationTex, +}; + +void Interface_DrawPerfectLetters(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + f32 letterX; + f32 letterY; + s16 i; + s16 vtxOffset; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C8D4(play->state.gfxCtx); + + gSPMatrix(OVERLAY_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + + for (vtxOffset = 0, i = 0; i < PERFECT_LETTERS_NUM_LETTERS; vtxOffset += 4, i++) { + if (interfaceCtx->perfectLettersState[i] != PERFECT_LETTERS_STATE_OFF) { + + // The positions follow the path of an elliptical spiral + letterX = Math_SinS(interfaceCtx->perfectLettersAngles[i]) * interfaceCtx->perfectLettersSemiAxisX[i]; + letterY = Math_CosS(interfaceCtx->perfectLettersAngles[i]) * interfaceCtx->perfectLettersSemiAxisY[i]; + + // Draw Minigame Perfect Shadows + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->perfectLettersPrimColor[3]); + + Matrix_Translate(letterX, letterY, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[44 + vtxOffset], 4, 0); + + OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, sPerfectLettersTextures[i], 4, 32, 33, 0); + + // Draw Minigame Perfect Colored Letters + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->perfectLettersPrimColor[0], + interfaceCtx->perfectLettersPrimColor[1], interfaceCtx->perfectLettersPrimColor[2], + interfaceCtx->perfectLettersPrimColor[3]); + + Matrix_Translate(letterX, letterY, 0.0f, MTXMODE_NEW); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[76 + vtxOffset], 4, 0); + + OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, sPerfectLettersTextures[i], 4, 32, 33, 0); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Interface_StartMoonCrash(PlayState* play) { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + Audio_QueueSeqCmd(0xE0000100); + } + + gSaveContext.save.day = 4; + gSaveContext.save.daysElapsed = 4; + gSaveContext.save.time = CLOCK_TIME(6, 0) + 10; + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 12); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; +} + +void Interface_GetTimerDigits(u64 timer, s16* timerArr) { + u64 time = timer; + + // 6 minutes + timerArr[0] = time / SECONDS_TO_TIMER(360); + time -= timerArr[0] * SECONDS_TO_TIMER(360); + + // minutes + timerArr[1] = time / SECONDS_TO_TIMER(60); + time -= timerArr[1] * SECONDS_TO_TIMER(60); + + // 10 seconds + timerArr[3] = time / SECONDS_TO_TIMER(10); + time -= timerArr[3] * SECONDS_TO_TIMER(10); + + // seconds + timerArr[4] = time / SECONDS_TO_TIMER(1); + time -= timerArr[4] * SECONDS_TO_TIMER(1); + + // 100 milliseconds + timerArr[6] = time / SECONDS_TO_TIMER_PRECISE(0, 10); + time -= timerArr[6] * SECONDS_TO_TIMER_PRECISE(0, 10); + + // 10 milliseconds + timerArr[7] = time; +} + +#define IS_POSTMAN_TIMER_DRAWN \ + (((sTimerId == TIMER_ID_POSTMAN) && \ + (gSaveContext.timerStates[TIMER_ID_POSTMAN] == TIMER_STATE_POSTMAN_COUNTING) && \ + (sPostmanBunnyHoodState == POSTMAN_MINIGAME_BUNNY_HOOD_OFF) && \ + (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] < SECONDS_TO_TIMER(3))) || \ + (sPostmanBunnyHoodState == POSTMAN_MINIGAME_BUNNY_HOOD_ON)) + +/** + * Update and draw the timers + */ +void Interface_DrawTimers(PlayState* play) { + static s16 sTimerStateTimer = 0; + static s16 sTimerDigits[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + static s16 sTimerBeepSfxSeconds = 99; + static s16 sTimerDigitsOffsetX[] = { + 16, 25, 34, 42, 51, 60, 68, 77, + }; + static s16 sTimerDigitsWidth[] = { + 9, 9, 8, 9, 9, 8, 9, 9, + }; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; + Player* player = GET_PLAYER(play); + OSTime osTime; + OSTime postmanTimerStopOsTime; + s16 j; + s16 i; + + OPEN_DISPS(play->state.gfxCtx); + + // Not satisfying any of these conditions will pause the timer + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + ((msgCtx->msgMode == 0) || + ((msgCtx->msgMode != 0) && (msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6))) && + !(player->stateFlags1 & PLAYER_STATE1_200) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) { + + // Account for osTime when the timer is paused + if (sIsTimerPaused) { + osTime = osGetTime(); + + for (j = 0; j < TIMER_ID_MAX; j++) { + if (gSaveContext.timerStates[j] == TIMER_STATE_COUNTING) { + gSaveContext.timerPausedOsTimes[j] = + gSaveContext.timerPausedOsTimes[j] + (osTime - sTimerPausedOsTime); + } + } + sIsTimerPaused = false; + } + + sTimerId = TIMER_ID_NONE; + + // Update all timer states + for (i = 0; i < TIMER_ID_MAX; i++) { + if (gSaveContext.timerStates[i] == TIMER_STATE_OFF) { + continue; + } + + sTimerId = i; + + // Process the timer for the postman counting minigame + if (sTimerId == TIMER_ID_POSTMAN) { + switch (gSaveContext.timerStates[TIMER_ID_POSTMAN]) { + case TIMER_STATE_POSTMAN_START: + if (gSaveContext.timerDirections[TIMER_ID_POSTMAN] != TIMER_COUNT_DOWN) { + gSaveContext.timerStartOsTimes[TIMER_ID_POSTMAN] = osGetTime(); + } + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_COUNTING; + sPostmanTimerInputBtnAPressed = true; + func_80174F7C(Interface_PostmanTimerCallback, NULL); + break; + + case TIMER_STATE_POSTMAN_STOP: + postmanTimerStopOsTime = gSaveContext.postmanTimerStopOsTime; + gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] = OSTIME_TO_TIMER( + postmanTimerStopOsTime - ((void)0, gSaveContext.timerStartOsTimes[TIMER_ID_POSTMAN]) - + ((void)0, gSaveContext.timerPausedOsTimes[TIMER_ID_POSTMAN])); + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_END; + func_80174F9C(Interface_PostmanTimerCallback, NULL); + break; + + case TIMER_STATE_POSTMAN_COUNTING: + case TIMER_STATE_POSTMAN_END: + break; + } + break; + } + + // process the remaining timers + switch (gSaveContext.timerStates[sTimerId]) { + case TIMER_STATE_START: + case TIMER_STATE_ALT_START: + sTimerStateTimer = 20; + if (interfaceCtx->minigameState != MINIGAME_STATE_NONE) { + + // Set the timer position + gSaveContext.timerX[sTimerId] = 26; + + if (interfaceCtx->magicAlpha != 255) { + gSaveContext.timerY[sTimerId] = 22; + } else if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + gSaveContext.timerY[sTimerId] = 54; + } else { + gSaveContext.timerY[sTimerId] = 46; + } + + if ((interfaceCtx->minigameState == MINIGAME_STATE_COUNTDOWN_GO) || + (interfaceCtx->minigameState == MINIGAME_STATE_PLAYING)) { + if (gSaveContext.timerStates[sTimerId] == TIMER_STATE_START) { + gSaveContext.timerStates[sTimerId] = TIMER_STATE_COUNTING; + } else { + gSaveContext.timerStates[sTimerId] = TIMER_STATE_ALT_COUNTING; + D_801BF8F8[sTimerId] = osGetTime(); + D_801BF930[sTimerId] = 0; + } + + gSaveContext.timerStartOsTimes[sTimerId] = osGetTime(); + gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[sTimerId] = 0; + } + } else { + gSaveContext.timerStates[sTimerId] = TIMER_STATE_HOLD_TIMER; + } + break; + + case TIMER_STATE_HOLD_TIMER: + sTimerStateTimer--; + if (sTimerStateTimer == 0) { + sTimerStateTimer = 20; + gSaveContext.timerStates[sTimerId] = TIMER_STATE_MOVING_TIMER; + } + break; + + case TIMER_STATE_MOVING_TIMER: + // Move the timer from the center of the screen to the timer location where it will count. + if (sTimerId == TIMER_ID_MOON_CRASH) { + j = ((((void)0, gSaveContext.timerX[sTimerId]) - R_MOON_CRASH_TIMER_X) / sTimerStateTimer); + gSaveContext.timerX[sTimerId] = ((void)0, gSaveContext.timerX[sTimerId]) - j; + j = ((((void)0, gSaveContext.timerY[sTimerId]) - R_MOON_CRASH_TIMER_Y) / sTimerStateTimer); + gSaveContext.timerY[sTimerId] = ((void)0, gSaveContext.timerY[sTimerId]) - j; + } else { + j = ((((void)0, gSaveContext.timerX[sTimerId]) - 26) / sTimerStateTimer); + gSaveContext.timerX[sTimerId] = ((void)0, gSaveContext.timerX[sTimerId]) - j; + + j = (gSaveContext.save.playerData.healthCapacity > 0xA0) + ? ((((void)0, gSaveContext.timerY[sTimerId]) - 54) / sTimerStateTimer) + : ((((void)0, gSaveContext.timerY[sTimerId]) - 46) / sTimerStateTimer); + gSaveContext.timerY[sTimerId] = ((void)0, gSaveContext.timerY[sTimerId]) - j; + } + + sTimerStateTimer--; + if (sTimerStateTimer == 0) { + sTimerStateTimer = 20; + + if (sTimerId == TIMER_ID_MOON_CRASH) { + gSaveContext.timerY[sTimerId] = R_MOON_CRASH_TIMER_Y; + } else { + gSaveContext.timerX[sTimerId] = 26; + if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + gSaveContext.timerY[sTimerId] = 54; + } else { + gSaveContext.timerY[sTimerId] = 46; + } + } + + gSaveContext.timerStates[sTimerId] = TIMER_STATE_COUNTING; + gSaveContext.timerStartOsTimes[sTimerId] = osGetTime(); + gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[sTimerId] = 0; + } + // fallthrough + case TIMER_STATE_COUNTING: + if ((gSaveContext.timerStates[sTimerId] == TIMER_STATE_COUNTING) && + (sTimerId == TIMER_ID_MOON_CRASH)) { + gSaveContext.timerX[TIMER_ID_MOON_CRASH] = R_MOON_CRASH_TIMER_X; + gSaveContext.timerY[TIMER_ID_MOON_CRASH] = R_MOON_CRASH_TIMER_Y; + } + break; + + case TIMER_STATE_10: + D_801BF8F8[sTimerId] = osGetTime(); + D_801BF930[sTimerId] = 0; + gSaveContext.timerStates[sTimerId] = TIMER_STATE_ALT_COUNTING; + // fallthrough + case TIMER_STATE_ALT_COUNTING: + D_801BF930[sTimerId] = osGetTime() - D_801BF8F8[sTimerId]; + break; + + case TIMER_STATE_12: + osTime = osGetTime(); + + gSaveContext.timerPausedOsTimes[sTimerId] = + gSaveContext.timerPausedOsTimes[sTimerId] + osTime - D_801BF8F8[sTimerId]; + D_801BF930[sTimerId] = 0; + gSaveContext.timerStates[sTimerId] = TIMER_STATE_COUNTING; + break; + + case TIMER_STATE_ENV_HAZARD_START: + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(gSaveContext.save.playerData.health >> 1); + gSaveContext.timerDirections[sTimerId] = TIMER_COUNT_DOWN; + gSaveContext.timerTimeLimits[sTimerId] = gSaveContext.timerCurTimes[sTimerId]; + sTimerStateTimer = 20; + gSaveContext.timerStates[sTimerId] = TIMER_STATE_MOVING_TIMER; + break; + + case TIMER_STATE_STOP: + osTime = osGetTime(); + + gSaveContext.timerStopTimes[sTimerId] = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTimes[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTimes[sTimerId])); + + gSaveContext.timerStates[sTimerId] = TIMER_STATE_OFF; + + if (sTimerId == TIMER_ID_MOON_CRASH) { + gSaveContext.save.day = 4; + if ((play->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneLayer == 3)) { + play->nextEntrance = ENTRANCE(TERMINA_FIELD, 1); + gSaveContext.nextCutsceneIndex = 0xFFF0; + play->transitionTrigger = TRANS_TRIGGER_START; + } else { + Interface_StartMoonCrash(play); + } + } else if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] != TIMER_STATE_OFF) { + gSaveContext.timerX[TIMER_ID_GORON_RACE_UNUSED] = 115; + gSaveContext.timerY[TIMER_ID_GORON_RACE_UNUSED] = 80; + if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] <= TIMER_STATE_10) { + gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] = TIMER_STATE_MOVING_TIMER; + } + } + break; + + case TIMER_STATE_6: + osTime = osGetTime(); + + gSaveContext.timerStopTimes[sTimerId] = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTimes[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTimes[sTimerId])); + + if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if (gSaveContext.timerStopTimes[sTimerId] >= SECONDS_TO_TIMER(120)) { + gSaveContext.timerStopTimes[sTimerId] = SECONDS_TO_TIMER(120); + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(120); + } + } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES) && + (gSaveContext.timerStopTimes[sTimerId] >= SECONDS_TO_TIMER(120))) { + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(120); + } + gSaveContext.timerStates[sTimerId] = TIMER_STATE_7; + + if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] != TIMER_STATE_OFF) { + gSaveContext.timerX[TIMER_ID_GORON_RACE_UNUSED] = 115; + gSaveContext.timerY[TIMER_ID_GORON_RACE_UNUSED] = 80; + if (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] <= TIMER_STATE_10) { + gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] = TIMER_STATE_MOVING_TIMER; + } + gSaveContext.timerStates[sTimerId] = TIMER_STATE_OFF; + } + break; + } + break; + } + + // Update timer counting + if ((sTimerId != TIMER_ID_NONE) && gSaveContext.timerStates[sTimerId]) { // != TIMER_STATE_OFF + if (gSaveContext.timerDirections[sTimerId] == TIMER_COUNT_DOWN) { + sTimerDigits[0] = sTimerDigits[1] = sTimerDigits[3] = sTimerDigits[4] = sTimerDigits[6] = 0; + + // Used to index the counter colon + sTimerDigits[2] = sTimerDigits[5] = 10; + + // Get the total amount of unpaused time since the start of the timer, centiseconds (1/100th sec). + if ((gSaveContext.timerStates[sTimerId] == TIMER_STATE_COUNTING) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_10) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_ALT_COUNTING) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_POSTMAN_COUNTING)) { + osTime = osGetTime(); + + osTime = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerPausedOsTimes[sTimerId]) - + D_801BF930[sTimerId] - ((void)0, gSaveContext.timerStartOsTimes[sTimerId])); + } else if (gSaveContext.timerStates[sTimerId] == TIMER_STATE_7) { + osTime = gSaveContext.timerStopTimes[sTimerId]; + } else { + osTime = 0; + } + + // Check how much unpaused time has passed + if (osTime == 0) { + // No unpaused time has passed since the start of the timer. + gSaveContext.timerCurTimes[sTimerId] = gSaveContext.timerTimeLimits[sTimerId] - osTime; + } else if (osTime <= gSaveContext.timerTimeLimits[sTimerId]) { + // Time has passed, but the time limit has not been exceeded + if (osTime >= gSaveContext.timerTimeLimits[sTimerId]) { + // The time is exactly at the time limit. No time remaining. + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(0); + } else { + // Update the time remaining + gSaveContext.timerCurTimes[sTimerId] = gSaveContext.timerTimeLimits[sTimerId] - osTime; + } + } else { + // Time has passed, and the time limit has been exceeded. + gSaveContext.timerCurTimes[sTimerId] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[sTimerId] = TIMER_STATE_STOP; + if (sEnvTimerActive) { + gSaveContext.save.playerData.health = 0; + play->damagePlayer(play, -(((void)0, gSaveContext.save.playerData.health) + 2)); + } + sEnvTimerActive = false; + } + + Interface_GetTimerDigits(((void)0, gSaveContext.timerCurTimes[sTimerId]), sTimerDigits); + + // Use seconds to determine when to beep + if (gSaveContext.timerCurTimes[sTimerId] > SECONDS_TO_TIMER(60)) { + if ((sTimerBeepSfxSeconds != sTimerDigits[4]) && (sTimerDigits[4] == 1)) { + play_sound(NA_SE_SY_MESSAGE_WOMAN); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } else if (gSaveContext.timerCurTimes[sTimerId] > SECONDS_TO_TIMER(10)) { + if ((sTimerBeepSfxSeconds != sTimerDigits[4]) && ((sTimerDigits[4] % 2) != 0)) { + play_sound(NA_SE_SY_WARNING_COUNT_N); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } else if (sTimerBeepSfxSeconds != sTimerDigits[4]) { + play_sound(NA_SE_SY_WARNING_COUNT_E); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } else { // TIMER_COUNT_UP + sTimerDigits[0] = sTimerDigits[1] = sTimerDigits[3] = sTimerDigits[4] = sTimerDigits[6] = 0; + + // Used to index the counter colon + sTimerDigits[2] = sTimerDigits[5] = 10; + + // Get the total amount of unpaused time since the start of the timer, centiseconds (1/100th sec). + if ((gSaveContext.timerStates[sTimerId] == TIMER_STATE_COUNTING) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_POSTMAN_COUNTING)) { + osTime = osGetTime(); + osTime = + OSTIME_TO_TIMER(osTime - ((void)0, gSaveContext.timerStartOsTimes[sTimerId]) - + ((void)0, gSaveContext.timerPausedOsTimes[sTimerId]) - D_801BF930[sTimerId]); + } else if (gSaveContext.timerStates[sTimerId] == TIMER_STATE_7) { + osTime = gSaveContext.timerStopTimes[sTimerId]; + } else if (sTimerId == TIMER_ID_POSTMAN) { + osTime = gSaveContext.timerCurTimes[sTimerId]; + } else { + osTime = SECONDS_TO_TIMER(0); + } + + if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if (osTime >= SECONDS_TO_TIMER(120)) { + osTime = SECONDS_TO_TIMER(120); + } + } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES) && + (osTime >= SECONDS_TO_TIMER(120))) { + osTime = SECONDS_TO_TIMER(120); + } + + // Update the time remaining with the total amount of time since the start of the timer, + gSaveContext.timerCurTimes[sTimerId] = osTime; + + Interface_GetTimerDigits(osTime, sTimerDigits); + + // Use seconds to determine when to beep + if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if ((gSaveContext.timerCurTimes[sTimerId] > SECONDS_TO_TIMER(110)) && + (sTimerBeepSfxSeconds != sTimerDigits[4])) { + play_sound(NA_SE_SY_WARNING_COUNT_E); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES)) { + if ((((void)0, gSaveContext.timerCurTimes[sTimerId]) > + (gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] - SECONDS_TO_TIMER(9))) && + (sTimerBeepSfxSeconds != sTimerDigits[4])) { + play_sound(NA_SE_SY_WARNING_COUNT_E); + sTimerBeepSfxSeconds = sTimerDigits[4]; + } + } + } + + // Draw timer + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); + OVERLAY_DISP = Gfx_DrawTexRectIA8( + OVERLAY_DISP, gTimerClockIconTex, 0x10, 0x10, ((void)0, gSaveContext.timerX[sTimerId]), + ((void)0, gSaveContext.timerY[sTimerId]) + 2, 0x10, 0x10, 1 << 10, 1 << 10); + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, + 0, PRIMITIVE, 0); + + if (IS_POSTMAN_TIMER_DRAWN || (gSaveContext.timerStates[sTimerId] <= TIMER_STATE_12)) { + // Set the timer color + if (gSaveContext.timerStates[sTimerId]) { // != TIMER_STATE_OFF + if (sTimerId == TIMER_ID_2) { + if ((gSaveContext.timerCurTimes[sTimerId] == SECONDS_TO_TIMER(0)) || + (gSaveContext.timerStates[sTimerId] == TIMER_STATE_COUNTING)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + } + } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && + (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0))) { + if (gSaveContext.timerCurTimes[sTimerId] >= SECONDS_TO_TIMER(110)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + } + } else if (CHECK_EVENTINF(EVENTINF_34) && (play->sceneId == SCENE_DEKUTES)) { + if (((void)0, gSaveContext.timerCurTimes[sTimerId]) >= + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); + } else if (((void)0, gSaveContext.timerCurTimes[sTimerId]) >= + (gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1] - + SECONDS_TO_TIMER(9))) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 0, 255); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + } + } else if ((gSaveContext.timerCurTimes[sTimerId] < SECONDS_TO_TIMER(10)) && + (gSaveContext.timerDirections[sTimerId] == TIMER_COUNT_DOWN) && + (gSaveContext.timerStates[sTimerId] != TIMER_STATE_ALT_COUNTING)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 50, 0, 255); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); + } + } + + // Draw the timer + if (sTimerId == TIMER_ID_POSTMAN) { + if (sPostmanBunnyHoodState == POSTMAN_MINIGAME_BUNNY_HOOD_ON) { + // draw sTimerDigits[3] (10s of seconds) to sTimerDigits[6] (100s of milliseconds) + for (j = 0; j < 4; j++) { + OVERLAY_DISP = Gfx_DrawTexRectI8( + OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j + 3])), 8, 0x10, + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); + } + } else { + // draw sTimerDigits[3] (10s of seconds) to sTimerDigits[7] (10s of milliseconds) + for (j = 0; j < 5; j++) { + OVERLAY_DISP = Gfx_DrawTexRectI8( + OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j + 3])), 8, 0x10, + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); + } + } + } else { + // draw sTimerDigits[3] (6s of minutes) to sTimerDigits[7] (10s of milliseconds) + for (j = 0; j < 8; j++) { + OVERLAY_DISP = Gfx_DrawTexRectI8( + OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sTimerDigits[j])), 8, 0x10, + ((void)0, gSaveContext.timerX[sTimerId]) + sTimerDigitsOffsetX[j], + ((void)0, gSaveContext.timerY[sTimerId]), sTimerDigitsWidth[j], 0xFA, 0x370, 0x370); + } + } + } + } + + } else if (!sIsTimerPaused) { + sTimerPausedOsTime = osGetTime(); + sIsTimerPaused = true; + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Interface_UpdateBottleTimers(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + s16 i; + s16 j; + u64 osTime; + s32 pad[2]; + + // Not satisfying any of these conditions will pause the bottle timer + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + ((msgCtx->msgMode == 0) || ((msgCtx->currentTextId >= 0x100) && (msgCtx->currentTextId <= 0x200)) || + ((msgCtx->currentTextId >= 0x1BB2) && (msgCtx->currentTextId <= 0x1BB6))) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !Play_InCsMode(play)) { + + // Account for osTime when the timer is paused + if (sIsBottleTimerPaused) { + osTime = osGetTime(); + + for (j = BOTTLE_FIRST; j < BOTTLE_MAX; j++) { + if (gSaveContext.bottleTimerStates[j] == BOTTLE_TIMER_STATE_COUNTING) { + gSaveContext.bottleTimerPausedOsTimes[j] += osTime - sBottleTimerPausedOsTime; + } + } + + sIsBottleTimerPaused = false; + } + + sTimerId = TIMER_ID_NONE; + + for (i = BOTTLE_FIRST; i < BOTTLE_MAX; i++) { + if (gSaveContext.bottleTimerStates[i] == BOTTLE_TIMER_STATE_COUNTING) { + osTime = osGetTime(); + + // Get the total amount of unpaused time since the start of the timer, centiseconds (1/100th sec). + osTime = OSTIME_TO_TIMER_ALT(osTime - ((void)0, gSaveContext.bottleTimerPausedOsTimes[i]) - + ((void)0, gSaveContext.bottleTimerStartOsTimes[i])); + + if (osTime == 0) { + // No unpaused time has passed since the start of the timer. + gSaveContext.bottleTimerCurTimes[i] = gSaveContext.bottleTimerTimeLimits[i] - osTime; + } else if (osTime <= gSaveContext.bottleTimerTimeLimits[i]) { + // Time has passed, but the time limit has not been exceeded + if (osTime >= gSaveContext.bottleTimerTimeLimits[i]) { + // The time is exactly at the time limit. No time remaining. + gSaveContext.bottleTimerCurTimes[i] = SECONDS_TO_TIMER(0); + } else { + // Update the time remaining + gSaveContext.bottleTimerCurTimes[i] = gSaveContext.bottleTimerTimeLimits[i] - osTime; + } + } else { + // Time has passed, and the time limit has been exceeded. + gSaveContext.bottleTimerCurTimes[i] = SECONDS_TO_TIMER(0); + + if (gSaveContext.save.inventory.items[i + SLOT_BOTTLE_1] == ITEM_HOT_SPRING_WATER) { + Inventory_UpdateItem(play, i + SLOT_BOTTLE_1, ITEM_SPRING_WATER); + Message_StartTextbox(play, 0xFA, NULL); + } + gSaveContext.bottleTimerStates[i] = BOTTLE_TIMER_STATE_OFF; + } + } + } + } else if (!sIsBottleTimerPaused) { + sBottleTimerPausedOsTime = osGetTime(); + sIsBottleTimerPaused = true; + } +} + +void Interface_DrawMinigameIcons(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s16 i; + s16 numDigitsDrawn; + s16 rectX; + s16 rectY; + s16 width; + s16 height; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C654(play->state.gfxCtx); + + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + // Carrots rendering if the action corresponds to riding a horse + if (interfaceCtx->unk_212 == DO_ACTION_FASTER) { + // Load Carrot Icon + gDPLoadTextureBlock(OVERLAY_DISP++, gCarrotIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 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); + + rectX = 110; + rectY = (interfaceCtx->minigameState != MINIGAME_STATE_NONE) ? 200 : 56; + + // Draw 6 carrots + for (i = 1; i < 7; i++, rectX += 16) { + // Carrot Color (based on availability) + if ((interfaceCtx->numHorseBoosts == 0) || (interfaceCtx->numHorseBoosts < i)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 150, 255, interfaceCtx->aAlpha); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->aAlpha); + } + + gSPTextureRectangle(OVERLAY_DISP++, rectX << 2, rectY << 2, (rectX + 16) << 2, (rectY + 16) << 2, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + } + + if (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) { + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + width = 24; + height = 16; + rectX = 20; + if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + rectY = 75; // two rows of hearts + } else { + rectY = 67; // one row of hearts + } + + if (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 1)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gBeaverRingIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 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); + } else if (play->sceneId == SCENE_DOUJOU) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 140, 50, interfaceCtx->bAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gSwordTrainingLogIconTex, G_IM_FMT_IA, G_IM_SIZ_8b, 24, 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); + } else if (play->sceneId == SCENE_30GYOSON) { + width = 16; + height = 30; + rectX = 24; + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 100, 75, interfaceCtx->bAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 55, 55, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gFishermanMinigameTorchIconTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 30, 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); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gArcheryScoreIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 24, 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); + } + + gSPTextureRectangle(OVERLAY_DISP++, (rectX << 2), (rectY << 2), ((rectX + width) << 2), + ((rectY + height) << 2), G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, + 0, PRIMITIVE, 0); + + if (play->sceneId == SCENE_30GYOSON) { + rectX += 20; + if (gSaveContext.save.playerData.healthCapacity > 0xA0) { + rectY = 87; // two rows of hearts + } else { + rectY = 79; // one row of hearts + } + } else { + rectX += 26; + } + + for (i = 0, numDigitsDrawn = 0; i < 4; i++) { + if ((sMinigameScoreDigits[i] != 0) || (numDigitsDrawn != 0) || (i >= 3)) { + OVERLAY_DISP = + Gfx_DrawTexRectI8(OVERLAY_DISP, ((u8*)gCounterDigit0Tex + (8 * 16 * sMinigameScoreDigits[i])), + 8, 0x10, rectX, rectY - 2, 9, 0xFA, 0x370, 0x370); + rectX += 9; + numDigitsDrawn++; + } + } + + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +s16 sRupeeDigitsFirst[] = { 1, 0, 0, 0 }; + +s16 sRupeeDigitsCount[] = { 2, 3, 3, 0 }; + +Color_RGB16 sRupeeCounterIconPrimColors[] = { + { 200, 255, 100 }, + { 170, 170, 255 }, + { 255, 105, 105 }, +}; + +Color_RGB16 sRupeeCounterIconEnvColors[] = { + { 0, 80, 0 }, + { 10, 10, 80 }, + { 40, 10, 0 }, +}; + +TexturePtr sMinigameCountdownTextures[] = { + gMinigameCountdown3Tex, + gMinigameCountdown2Tex, + gMinigameCountdown1Tex, + gMinigameCountdownGoTex, +}; + +s16 sMinigameCountdownTexWidths[] = { 24, 24, 24, 40 }; + +Color_RGB16 sMinigameCountdownPrimColors[] = { + { 100, 255, 100 }, + { 255, 255, 60 }, + { 255, 100, 0 }, + { 120, 170, 255 }, +}; + +TexturePtr sStoryTextures[] = { + gStoryMaskFestivalTex, + gStoryGiantsLeavingTex, +}; + +TexturePtr sStoryTLUTs[] = { + gStoryMaskFestivalTLUT, + gStoryGiantsLeavingTLUT, +}; + +void Interface_Draw(PlayState* play) { + s32 pad; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + Gfx* gfx; + s16 sp2CE; + s16 sp2CC; + s16 sp2CA; + s16 sp2C8; + PauseContext* pauseCtx = &play->pauseCtx; + f32 minigameCountdownScale; + s16 counterDigits[4]; + s16 magicAlpha; + + OPEN_DISPS(play->state.gfxCtx); + + gSPSegment(OVERLAY_DISP++, 0x02, interfaceCtx->parameterSegment); + gSPSegment(OVERLAY_DISP++, 0x09, interfaceCtx->doActionSegment); + gSPSegment(OVERLAY_DISP++, 0x08, interfaceCtx->iconItemSegment); + gSPSegment(OVERLAY_DISP++, 0x0B, interfaceCtx->mapSegment); + + if (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) { + Interface_SetVertices(play); + func_801170B8(interfaceCtx); + + // Draw Grandma's Story + if (interfaceCtx->storyDmaStatus == STORY_DMA_DONE) { + gSPSegment(OVERLAY_DISP++, 0x07, interfaceCtx->storySegment); + func_8012C628(play->state.gfxCtx); + + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + // Load in Grandma's Story + gSPLoadUcodeL(OVERLAY_DISP++, gspS2DEX2_fifo); + gfx = OVERLAY_DISP; + func_80172758(&gfx, sStoryTextures[interfaceCtx->storyType], sStoryTLUTs[interfaceCtx->storyType], + SCREEN_WIDTH, SCREEN_HEIGHT, 2, 1, 0x8000, 0x100, 0.0f, 0.0f, 1.0f, 1.0f, 0); + OVERLAY_DISP = gfx; + gSPLoadUcode(OVERLAY_DISP++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); + + gDPPipeSync(OVERLAY_DISP++); + + // Fill the screen with a black rectangle + gDPSetRenderMode(OVERLAY_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, R_STORY_FILL_SCREEN_ALPHA); + gDPFillRectangle(OVERLAY_DISP++, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } + + LifeMeter_Draw(play); + + func_8012C654(play->state.gfxCtx); + + // Draw Rupee Icon + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sRupeeCounterIconPrimColors[CUR_UPG_VALUE(UPG_WALLET)].r, + sRupeeCounterIconPrimColors[CUR_UPG_VALUE(UPG_WALLET)].g, + sRupeeCounterIconPrimColors[CUR_UPG_VALUE(UPG_WALLET)].b, interfaceCtx->magicAlpha); + gDPSetEnvColor(OVERLAY_DISP++, sRupeeCounterIconEnvColors[CUR_UPG_VALUE(UPG_WALLET)].r, + sRupeeCounterIconEnvColors[CUR_UPG_VALUE(UPG_WALLET)].g, + sRupeeCounterIconEnvColors[CUR_UPG_VALUE(UPG_WALLET)].b, 255); + OVERLAY_DISP = + Gfx_DrawTexRectIA8(OVERLAY_DISP, gRupeeCounterIconTex, 16, 16, 26, 206, 16, 16, 1 << 10, 1 << 10); + + switch (play->sceneId) { + case SCENE_INISIE_N: + case SCENE_INISIE_R: + case SCENE_MITURIN: + case SCENE_HAKUGIN: + case SCENE_SEA: + if (DUNGEON_KEY_COUNT(gSaveContext.mapIndex) >= 0) { + // Small Key Icon + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 230, 255, interfaceCtx->magicAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 20, 255); + OVERLAY_DISP = Gfx_DrawTexRectIA8(OVERLAY_DISP, gSmallKeyCounterIconTex, 16, 16, 26, 190, 16, 16, + 1 << 10, 1 << 10); + + // Small Key Counter + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, + TEXEL0, 0, PRIMITIVE, 0); + + counterDigits[2] = 0; + counterDigits[3] = DUNGEON_KEY_COUNT(gSaveContext.mapIndex); + + while (counterDigits[3] >= 10) { + counterDigits[2]++; + counterDigits[3] -= 10; + } + + sp2CA = 42; + + if (counterDigits[2] != 0) { + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); + + OVERLAY_DISP = + Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[2]), 8, 16, + 43, 191, 8, 16, 1 << 10, 1 << 10); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); + gSPTextureRectangle(OVERLAY_DISP++, 168, 760, 200, 824, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); + + sp2CA += 8; + } + + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); + + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[3]), + 8, 16, sp2CA + 1, 191, 8, 16, 1 << 10, 1 << 10); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); + gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 760, (sp2CA * 4) + 0x20, 824, G_TX_RENDERTILE, 0, 0, + 1 << 10, 1 << 10); + } + break; + + case SCENE_KINSTA1: + case SCENE_KINDAN2: + // Gold Skulltula Icon + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); + gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); + gDPLoadTextureBlock(OVERLAY_DISP++, gGoldSkulltulaCounterIconTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 24, + 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(OVERLAY_DISP++, 80, 748, 176, 820, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + + // Gold Skulluta Counter + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, + TEXEL0, 0, PRIMITIVE, 0); + + counterDigits[2] = 0; + counterDigits[3] = Inventory_GetSkullTokenCount(play->sceneId); + + while (counterDigits[3] >= 10) { + counterDigits[2]++; + counterDigits[3] -= 10; + } + + sp2CA = 42; + + if (counterDigits[2] != 0) { + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); + + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[2]), + 8, 16, 43, 191, 8, 16, 1 << 10, 1 << 10); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); + gSPTextureRectangle(OVERLAY_DISP++, 168, 760, 200, 824, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + + sp2CA += 8; + } + + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->magicAlpha); + + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[3]), 8, + 16, sp2CA + 1, 191, 8, 16, 1 << 10, 1 << 10); + + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); + gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 760, (sp2CA * 4) + 0x20, 824, G_TX_RENDERTILE, 0, 0, + 1 << 10, 1 << 10); + break; + + default: + break; + } + + // Rupee Counter + gDPPipeSync(OVERLAY_DISP++); + gDPSetCombineLERP(OVERLAY_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + + counterDigits[0] = counterDigits[1] = 0; + counterDigits[2] = gSaveContext.save.playerData.rupees; + + if ((counterDigits[2] > 9999) || (counterDigits[2] < 0)) { + counterDigits[2] &= 0xDDD; + } + + while (counterDigits[2] >= 100) { + counterDigits[0]++; + counterDigits[2] -= 100; + } + + while (counterDigits[2] >= 10) { + counterDigits[1]++; + counterDigits[2] -= 10; + } + + sp2CC = sRupeeDigitsFirst[CUR_UPG_VALUE(UPG_WALLET)]; + sp2C8 = sRupeeDigitsCount[CUR_UPG_VALUE(UPG_WALLET)]; + + magicAlpha = interfaceCtx->magicAlpha; + if (magicAlpha > 180) { + magicAlpha = 180; + } + + for (sp2CE = 0, sp2CA = 42; sp2CE < sp2C8; sp2CE++, sp2CC++, sp2CA += 8) { + gDPPipeSync(OVERLAY_DISP++); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, magicAlpha); + + OVERLAY_DISP = Gfx_DrawTexRectI8(OVERLAY_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[sp2CC]), 8, + 16, sp2CA + 1, 207, 8, 16, 1 << 10, 1 << 10); + + gDPPipeSync(OVERLAY_DISP++); + + if (gSaveContext.save.playerData.rupees == CUR_CAPACITY(UPG_WALLET)) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 255, 0, interfaceCtx->magicAlpha); + } else if (gSaveContext.save.playerData.rupees != 0) { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->magicAlpha); + } else { + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 100, 100, 100, interfaceCtx->magicAlpha); + } + + gSPTextureRectangle(OVERLAY_DISP++, sp2CA * 4, 824, (sp2CA * 4) + 0x20, 888, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); + } + + Magic_DrawMeter(play); + Minimap_Draw(play); + + if ((R_PAUSE_BG_PRERENDER_STATE != 2) && (R_PAUSE_BG_PRERENDER_STATE != 3)) { + Actor_DrawZTarget(&play->actorCtx.targetContext, play); + } + + func_8012C654(play->state.gfxCtx); + + func_80117100(play); + + if (player->transformation == ((void)0, gSaveContext.save.playerForm)) { + func_80118084(play); + } + func_80118890(play); + + func_80118BA4(play); + + func_80119030(play); + + // Draw either the minigame countdown or the three-day clock + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + if ((interfaceCtx->minigameState != MINIGAME_STATE_NONE) && + (interfaceCtx->minigameState < MINIGAME_STATE_NO_COUNTDOWN_SETUP)) { + // Minigame Countdown + if (((u32)interfaceCtx->minigameState % 2) == 0) { + + sp2CE = (interfaceCtx->minigameState >> 1) - 1; + minigameCountdownScale = interfaceCtx->minigameCountdownScale / 100.0f; + + if (sp2CE == 3) { + interfaceCtx->actionVtx[40 + 0].v.ob[0] = interfaceCtx->actionVtx[40 + 2].v.ob[0] = -20; + interfaceCtx->actionVtx[40 + 1].v.ob[0] = interfaceCtx->actionVtx[40 + 3].v.ob[0] = + interfaceCtx->actionVtx[40 + 0].v.ob[0] + 40; + interfaceCtx->actionVtx[40 + 1].v.tc[0] = interfaceCtx->actionVtx[40 + 3].v.tc[0] = 40 << 5; + } + + interfaceCtx->actionVtx[40 + 2].v.tc[1] = interfaceCtx->actionVtx[40 + 3].v.tc[1] = 32 << 5; + + func_8012C8D4(play->state.gfxCtx); + + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sMinigameCountdownPrimColors[sp2CE].r, + sMinigameCountdownPrimColors[sp2CE].g, sMinigameCountdownPrimColors[sp2CE].b, + interfaceCtx->minigameCountdownAlpha); + + Matrix_Translate(0.0f, -40.0f, 0.0f, MTXMODE_NEW); + Matrix_Scale(minigameCountdownScale, minigameCountdownScale, 0.0f, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[40], 4, 0); + + OVERLAY_DISP = Gfx_DrawTexQuadIA8(OVERLAY_DISP, sMinigameCountdownTextures[sp2CE], + sMinigameCountdownTexWidths[sp2CE], 32, 0); + } + } else { + Interface_DrawClock(play); + } + } + + // Draw the letters of minigame perfect + if (interfaceCtx->perfectLettersOn) { + Interface_DrawPerfectLetters(play); + } + + Interface_DrawMinigameIcons(play); + Interface_DrawTimers(play); + } + + // Draw pictograph focus icons + if (sPictoState == PICTO_BOX_STATE_LENS) { + + func_8012C654(play->state.gfxCtx); + + gDPSetAlphaCompare(OVERLAY_DISP++, G_AC_THRESHOLD); + gDPSetRenderMode(OVERLAY_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 155, 255); + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gPictoBoxFocusBorderTex, G_IM_FMT_IA, 16, 16, 0, G_TX_MIRROR | G_TX_WRAP, + G_TX_MIRROR | G_TX_WRAP, 4, 4, G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(OVERLAY_DISP++, R_PICTO_FOCUS_BORDER_TOPLEFT_X << 2, R_PICTO_FOCUS_BORDER_TOPLEFT_Y << 2, + (R_PICTO_FOCUS_BORDER_TOPLEFT_X << 2) + (16 << 2), + (R_PICTO_FOCUS_BORDER_TOPLEFT_Y << 2) + (16 << 2), G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, R_PICTO_FOCUS_BORDER_TOPRIGHT_X << 2, R_PICTO_FOCUS_BORDER_TOPRIGHT_Y << 2, + (R_PICTO_FOCUS_BORDER_TOPRIGHT_X << 2) + (16 << 2), + (R_PICTO_FOCUS_BORDER_TOPRIGHT_Y << 2) + (16 << 2), G_TX_RENDERTILE, 512, 0, 1 << 10, + 1 << 10); + gSPTextureRectangle( + OVERLAY_DISP++, R_PICTO_FOCUS_BORDER_BOTTOMLEFT_X << 2, R_PICTO_FOCUS_BORDER_BOTTOMLEFT_Y << 2, + (R_PICTO_FOCUS_BORDER_BOTTOMLEFT_X << 2) + (16 << 2), (R_PICTO_FOCUS_BORDER_BOTTOMLEFT_Y << 2) + (16 << 2), + G_TX_RENDERTILE, 0, 512, 1 << 10, 1 << 10); + gSPTextureRectangle( + OVERLAY_DISP++, R_PICTO_FOCUS_BORDER_BOTTOMRIGHT_X << 2, R_PICTO_FOCUS_BORDER_BOTTOMRIGHT_Y << 2, + (R_PICTO_FOCUS_BORDER_BOTTOMRIGHT_X << 2) + (16 << 2), + (R_PICTO_FOCUS_BORDER_BOTTOMRIGHT_Y << 2) + (16 << 2), G_TX_RENDERTILE, 512, 512, 1 << 10, 1 << 10); + + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gPictoBoxFocusIconTex, G_IM_FMT_I, 32, 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); + + gSPTextureRectangle(OVERLAY_DISP++, R_PICTO_FOCUS_ICON_X << 2, R_PICTO_FOCUS_ICON_Y << 2, + (R_PICTO_FOCUS_ICON_X << 2) + 0x80, (R_PICTO_FOCUS_ICON_Y << 2) + (16 << 2), + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + + gDPLoadTextureBlock_4b(OVERLAY_DISP++, gPictoBoxFocusTextTex, G_IM_FMT_I, 32, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(OVERLAY_DISP++, R_PICTO_FOCUS_TEXT_X << 2, R_PICTO_FOCUS_TEXT_Y << 2, + (R_PICTO_FOCUS_TEXT_X << 2) + 0x80, (R_PICTO_FOCUS_TEXT_Y << 2) + 0x20, G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + } + + // Draw pictograph photo + if (sPictoState >= PICTO_BOX_STATE_SETUP_PHOTO) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON)) { + Play_CompressI8ToI5((play->pictoPhotoI8 != NULL) ? play->pictoPhotoI8 : D_801FBB90, + (u8*)gSaveContext.pictoPhotoI5, PICTO_PHOTO_WIDTH * PICTO_PHOTO_HEIGHT); + + interfaceCtx->unk_222 = interfaceCtx->unk_224 = 0; + + sPictoState = PICTO_BOX_STATE_OFF; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } else { + s16 pictoRectTop; + s16 pictoRectLeft; + + if (sPictoState == PICTO_BOX_STATE_SETUP_PHOTO) { + sPictoState = PICTO_BOX_STATE_PHOTO; + Message_StartTextbox(play, 0xF8, NULL); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + player->stateFlags1 |= PLAYER_STATE1_200; + } + + gDPPipeSync(OVERLAY_DISP++); + gDPSetRenderMode(OVERLAY_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 200, 200, 250); + gDPFillRectangle(OVERLAY_DISP++, 70, 22, 251, 151); + + func_8012C654(play->state.gfxCtx); + + gDPSetRenderMode(OVERLAY_DISP++, G_RM_OPA_SURF, G_RM_OPA_SURF2); + gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEI_PRIM, G_CC_MODULATEI_PRIM); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 250, 160, 160, 255); + + // Picture is offset up by 33 pixels to give room for the message box at the bottom + pictoRectTop = PICTO_PHOTO_TOPLEFT_Y - 33; + for (sp2CC = 0; sp2CC < (PICTO_PHOTO_HEIGHT / 8); sp2CC++, pictoRectTop += 8) { + pictoRectLeft = PICTO_PHOTO_TOPLEFT_X; + gDPLoadTextureBlock(OVERLAY_DISP++, + (u8*)((play->pictoPhotoI8 != NULL) ? play->pictoPhotoI8 : D_801FBB90) + + (0x500 * sp2CC), + G_IM_FMT_I, G_IM_SIZ_8b, PICTO_PHOTO_WIDTH, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(OVERLAY_DISP++, pictoRectLeft << 2, pictoRectTop << 2, + (pictoRectLeft + PICTO_PHOTO_WIDTH) << 2, (pictoRectTop << 2) + (8 << 2), + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + } + } + } + + // Draw over the entire screen (used in gameover) + if (interfaceCtx->screenFillAlpha != 0) { + gDPPipeSync(OVERLAY_DISP++); + gSPDisplayList(OVERLAY_DISP++, sScreenFillSetupDL); + gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, interfaceCtx->screenFillAlpha); + gSPDisplayList(OVERLAY_DISP++, D_0E000000.fillRect); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Interface_LoadStory(PlayState* play, s32 osMesgFlag) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + switch (interfaceCtx->storyDmaStatus) { + case STORY_DMA_IDLE: + if (interfaceCtx->storySegment == NULL) { + break; + } + osCreateMesgQueue(&interfaceCtx->storyMsgQueue, &interfaceCtx->storyMsgBuf, 1); + DmaMgr_SendRequestImpl(&interfaceCtx->dmaRequest, interfaceCtx->storySegment, interfaceCtx->storyAddr, + interfaceCtx->storySize, 0, &interfaceCtx->storyMsgQueue, NULL); + interfaceCtx->storyDmaStatus = STORY_DMA_LOADING; + // fallthrough + case STORY_DMA_LOADING: + if (osRecvMesg(&interfaceCtx->storyMsgQueue, NULL, osMesgFlag) == 0) { + interfaceCtx->storyDmaStatus = STORY_DMA_DONE; + } + break; + + default: // STORY_DMA_DONE + break; + } +} + +void Interface_AllocStory(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + + interfaceCtx->storyAddr = SEGMENT_ROM_START(story_static); + interfaceCtx->storySize = SEGMENT_ROM_SIZE(story_static); + + if (interfaceCtx->storySegment == NULL) { + interfaceCtx->storySegment = ZeldaArena_Malloc(interfaceCtx->storySize); + } + Interface_LoadStory(play, OS_MESG_NOBLOCK); +} + +void Interface_Update(PlayState* play) { + static u8 sIsSunsPlayedAtDay = false; + static s16 sPrevTimeSpeed = 0; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; + Player* player = GET_PLAYER(play); + s16 dimmingAlpha; + s16 risingAlpha; + u16 aButtonDoAction; + + // Update buttons + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + if (play->gameOverCtx.state == GAMEOVER_INACTIVE) { + func_80111CB4(play); + } + } + + // Update hud visibility + switch (gSaveContext.nextHudVisibility) { + case HUD_VISIBILITY_NONE: + case HUD_VISIBILITY_NONE_ALT: + case HUD_VISIBILITY_B: + dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer << 5); + if (dimmingAlpha < 0) { + dimmingAlpha = 0; + } + + Interface_UpdateHudAlphas(play, dimmingAlpha); + gSaveContext.hudVisibilityTimer += 2; + if (dimmingAlpha == 0) { + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + } + break; + + case HUD_VISIBILITY_HEARTS_WITH_OVERWRITE: + case HUD_VISIBILITY_A: + case HUD_VISIBILITY_A_HEARTS_MAGIC_WITH_OVERWRITE: + case HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_WITH_OVERWRITE: + case HUD_VISIBILITY_ALL_NO_MINIMAP_W_DISABLED: + case HUD_VISIBILITY_HEARTS_MAGIC: + case HUD_VISIBILITY_B_ALT: + case HUD_VISIBILITY_HEARTS: + case HUD_VISIBILITY_A_B_MINIMAP: + case HUD_VISIBILITY_HEARTS_MAGIC_WITH_OVERWRITE: + case HUD_VISIBILITY_HEARTS_MAGIC_C: + case HUD_VISIBILITY_ALL_NO_MINIMAP: + case HUD_VISIBILITY_A_B_C: + case HUD_VISIBILITY_B_MINIMAP: + case HUD_VISIBILITY_HEARTS_MAGIC_MINIMAP: + case HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP: + case HUD_VISIBILITY_B_MAGIC: + case HUD_VISIBILITY_A_B: + case HUD_VISIBILITY_A_B_HEARTS_MAGIC_MINIMAP: + dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer << 5); + if (dimmingAlpha < 0) { + dimmingAlpha = 0; + } + + Interface_UpdateHudAlphas(play, dimmingAlpha); + gSaveContext.hudVisibilityTimer++; + if (dimmingAlpha == 0) { + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + } + break; + + case HUD_VISIBILITY_ALL: + dimmingAlpha = 255 - (gSaveContext.hudVisibilityTimer << 5); + if (dimmingAlpha < 0) { + dimmingAlpha = 0; + } + + risingAlpha = 255 - dimmingAlpha; + if (risingAlpha >= 255) { + risingAlpha = 255; + } + + Interface_UpdateButtonAlphasByStatus(play, risingAlpha); + + if (gSaveContext.buttonStatus[5] == BTN_DISABLED) { + if (interfaceCtx->startAlpha != 70) { + interfaceCtx->startAlpha = 70; + } + } else { + if (interfaceCtx->startAlpha != 255) { + interfaceCtx->startAlpha = risingAlpha; + } + } + + if (interfaceCtx->healthAlpha != 255) { + interfaceCtx->healthAlpha = risingAlpha; + } + + if (interfaceCtx->magicAlpha != 255) { + interfaceCtx->magicAlpha = risingAlpha; + } + + if (play->sceneId == SCENE_SPOT00) { + if (interfaceCtx->minimapAlpha < 170) { + interfaceCtx->minimapAlpha = risingAlpha; + } else { + interfaceCtx->minimapAlpha = 170; + } + } else if (interfaceCtx->minimapAlpha != 255) { + interfaceCtx->minimapAlpha = risingAlpha; + } + + gSaveContext.hudVisibilityTimer++; + + if (risingAlpha == 255) { + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + } + + break; + + case HUD_VISIBILITY_NONE_INSTANT: + // Turn off all Hud immediately + gSaveContext.nextHudVisibility = HUD_VISIBILITY_NONE; + Interface_UpdateHudAlphas(play, 0); + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + // fallthrough + default: + break; + } + + Map_Update(play); + + // Update health + if (gSaveContext.healthAccumulator != 0) { + gSaveContext.healthAccumulator -= 4; + gSaveContext.save.playerData.health += 4; + + if ((gSaveContext.save.playerData.health & 0xF) < 4) { + play_sound(NA_SE_SY_HP_RECOVER); + } + + if (((void)0, gSaveContext.save.playerData.health) >= ((void)0, gSaveContext.save.playerData.healthCapacity)) { + gSaveContext.save.playerData.health = gSaveContext.save.playerData.healthCapacity; + gSaveContext.healthAccumulator = 0; + } + } + + LifeMeter_UpdateSizeAndBeep(play); + + // Update environmental hazard (remnant of OoT) + sEnvHazard = Player_GetEnvironmentalHazard(play); + if (sEnvHazard == PLAYER_ENV_HAZARD_HOTROOM) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) == EQUIP_VALUE_TUNIC_GORON) { + sEnvHazard = PLAYER_ENV_HAZARD_NONE; + } + } else if ((Player_GetEnvironmentalHazard(play) >= PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) && + (Player_GetEnvironmentalHazard(play) <= PLAYER_ENV_HAZARD_UNDERWATER_FREE)) { + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) == EQUIP_VALUE_TUNIC_ZORA) { + sEnvHazard = PLAYER_ENV_HAZARD_NONE; + } + } + + LifeMeter_UpdateColors(play); + + // Update rupees + if (gSaveContext.rupeeAccumulator != 0) { + if (gSaveContext.rupeeAccumulator > 0) { + if (gSaveContext.save.playerData.rupees < CUR_CAPACITY(UPG_WALLET)) { + gSaveContext.rupeeAccumulator--; + gSaveContext.save.playerData.rupees++; + play_sound(NA_SE_SY_RUPY_COUNT); + } else { + // Max rupees + gSaveContext.save.playerData.rupees = CUR_CAPACITY(UPG_WALLET); + gSaveContext.rupeeAccumulator = 0; + } + } else if (gSaveContext.save.playerData.rupees != 0) { + if (gSaveContext.rupeeAccumulator <= -50) { + gSaveContext.rupeeAccumulator += 10; + gSaveContext.save.playerData.rupees -= 10; + if (gSaveContext.save.playerData.rupees < 0) { + gSaveContext.save.playerData.rupees = 0; + } + play_sound(NA_SE_SY_RUPY_COUNT); + } else { + gSaveContext.rupeeAccumulator++; + gSaveContext.save.playerData.rupees--; + play_sound(NA_SE_SY_RUPY_COUNT); + } + } else { + gSaveContext.rupeeAccumulator = 0; + } + } + + // Update perfect letters + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + if (interfaceCtx->perfectLettersOn) { + if (interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_1) { + Interface_UpdatePerfectLettersType1(play); + } else if (interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_2) { + Interface_UpdatePerfectLettersType2(play); + } else if (interfaceCtx->perfectLettersType == PERFECT_LETTERS_TYPE_3) { + Interface_UpdatePerfectLettersType3(play); + } + } + } + + // Update minigame State + if ((play->pauseCtx.state == PAUSE_STATE_OFF) && (play->pauseCtx.debugEditor == DEBUG_EDITOR_NONE)) { + if ((u32)interfaceCtx->minigameState != MINIGAME_STATE_NONE) { + switch (interfaceCtx->minigameState) { + case MINIGAME_STATE_COUNTDOWN_SETUP_3: + case MINIGAME_STATE_COUNTDOWN_SETUP_2: + case MINIGAME_STATE_COUNTDOWN_SETUP_1: + case MINIGAME_STATE_COUNTDOWN_SETUP_GO: + interfaceCtx->minigameCountdownAlpha = 255; + interfaceCtx->minigameCountdownScale = 100; + interfaceCtx->minigameState++; + if (interfaceCtx->minigameState == MINIGAME_STATE_COUNTDOWN_GO) { + interfaceCtx->minigameCountdownScale = 160; + play_sound(NA_SE_SY_START_SHOT); + } else { + play_sound(NA_SE_SY_WARNING_COUNT_E); + } + break; + + case MINIGAME_STATE_COUNTDOWN_3: + case MINIGAME_STATE_COUNTDOWN_2: + case MINIGAME_STATE_COUNTDOWN_1: + interfaceCtx->minigameCountdownAlpha -= 10; + interfaceCtx->minigameCountdownScale += 3; + if (interfaceCtx->minigameCountdownAlpha < 22) { + interfaceCtx->minigameState++; + } + break; + + case MINIGAME_STATE_COUNTDOWN_GO: + interfaceCtx->minigameCountdownAlpha -= 10; + if (interfaceCtx->minigameCountdownAlpha <= 150) { + interfaceCtx->minigameState = MINIGAME_STATE_PLAYING; + } + break; + + case MINIGAME_STATE_NO_COUNTDOWN_SETUP: + interfaceCtx->minigameCountdownAlpha = 0; + interfaceCtx->minigameState++; + break; + + case MINIGAME_STATE_NO_COUNTDOWN: + interfaceCtx->minigameCountdownAlpha++; + if (interfaceCtx->minigameCountdownAlpha >= 18) { + interfaceCtx->minigameState = MINIGAME_STATE_PLAYING; + } + break; + } + } + } + + // Update A Button + switch (interfaceCtx->aButtonState) { + case A_BTN_STATE_1: + interfaceCtx->aButtonRoll += 10466.667f; + if (interfaceCtx->aButtonRoll >= 15700.0f) { + interfaceCtx->aButtonRoll = -15700.0f; + interfaceCtx->aButtonState = A_BTN_STATE_2; + + if ((msgCtx->msgMode != 0) && (msgCtx->unk12006 == 0x26)) { + R_A_BTN_Y_OFFSET = -14; + } else { + R_A_BTN_Y_OFFSET = 0; + } + } + break; + + case A_BTN_STATE_2: + interfaceCtx->aButtonRoll += 10466.667f; + if (interfaceCtx->aButtonRoll >= 0.0f) { + interfaceCtx->aButtonRoll = 0.0f; + interfaceCtx->aButtonState = A_BTN_STATE_0; + interfaceCtx->unk_212 = interfaceCtx->aButtonDoAction; + aButtonDoAction = interfaceCtx->unk_212; + if ((aButtonDoAction == DO_ACTION_MAX) || (aButtonDoAction == DO_ACTION_MAX + 1)) { + aButtonDoAction = DO_ACTION_NONE; + } + func_80115428(&play->interfaceCtx, aButtonDoAction, 0); + } + break; + + case A_BTN_STATE_3: + interfaceCtx->aButtonRoll += 10466.667f; + if (interfaceCtx->aButtonRoll >= 15700.0f) { + interfaceCtx->aButtonRoll = -15700.0f; + interfaceCtx->aButtonState = A_BTN_STATE_2; + } + break; + + case A_BTN_STATE_4: + interfaceCtx->aButtonRoll += 10466.667f; + if (interfaceCtx->aButtonRoll >= 0.0f) { + interfaceCtx->aButtonRoll = 0.0f; + interfaceCtx->aButtonState = A_BTN_STATE_0; + interfaceCtx->unk_212 = interfaceCtx->aButtonDoAction; + aButtonDoAction = interfaceCtx->unk_212; + if ((aButtonDoAction == DO_ACTION_MAX) || (aButtonDoAction == DO_ACTION_MAX + 1)) { + aButtonDoAction = DO_ACTION_NONE; + } + + func_80115428(&play->interfaceCtx, aButtonDoAction, 0); + } + break; + + default: // A_BTN_STATE_0 + break; + } + + // Update magic + if (!(player->stateFlags1 & PLAYER_STATE1_200)) { + if (R_MAGIC_DBG_SET_UPGRADE == MAGIC_DBG_SET_UPGRADE_DOUBLE_METER) { + // Upgrade to double magic + if (!gSaveContext.save.playerData.isMagicAcquired) { + gSaveContext.save.playerData.isMagicAcquired = true; + } + gSaveContext.save.playerData.isDoubleMagicAcquired = true; + gSaveContext.save.playerData.magic = MAGIC_DOUBLE_METER; + gSaveContext.save.playerData.magicLevel = 0; + R_MAGIC_DBG_SET_UPGRADE = MAGIC_DBG_SET_UPGRADE_NO_ACTION; + } else if (R_MAGIC_DBG_SET_UPGRADE == MAGIC_DBG_SET_UPGRADE_NORMAL_METER) { + // Upgrade to normal magic + if (!gSaveContext.save.playerData.isMagicAcquired) { + gSaveContext.save.playerData.isMagicAcquired = true; + } + gSaveContext.save.playerData.isDoubleMagicAcquired = false; + gSaveContext.save.playerData.magic = MAGIC_NORMAL_METER; + gSaveContext.save.playerData.magicLevel = 0; + R_MAGIC_DBG_SET_UPGRADE = MAGIC_DBG_SET_UPGRADE_NO_ACTION; + } + + if ((gSaveContext.save.playerData.isMagicAcquired) && (gSaveContext.save.playerData.magicLevel == 0)) { + // Prepare to step `magicCapacity` to full capacity + gSaveContext.save.playerData.magicLevel = gSaveContext.save.playerData.isDoubleMagicAcquired + 1; + gSaveContext.magicFillTarget = gSaveContext.save.playerData.magic; + gSaveContext.save.playerData.magic = 0; + gSaveContext.magicState = MAGIC_STATE_STEP_CAPACITY; + BUTTON_ITEM_EQUIP(PLAYER_FORM_DEKU, EQUIP_SLOT_B) = ITEM_NUT; + } + + Magic_Update(play); + Magic_UpdateAddRequest(); + } + + // Update environmental hazard timer + if (gSaveContext.timerStates[TIMER_ID_ENV_HAZARD] == TIMER_STATE_OFF) { + if ((sEnvHazard == PLAYER_ENV_HAZARD_HOTROOM) || (sEnvHazard == PLAYER_ENV_HAZARD_UNDERWATER_FREE)) { + if (CUR_FORM != PLAYER_FORM_ZORA) { + if (play->gameOverCtx.state == GAMEOVER_INACTIVE) { + if ((gSaveContext.save.playerData.health >> 1) != 0) { + gSaveContext.timerStates[TIMER_ID_ENV_HAZARD] = TIMER_STATE_ENV_HAZARD_START; + gSaveContext.timerX[TIMER_ID_ENV_HAZARD] = 115; + gSaveContext.timerY[TIMER_ID_ENV_HAZARD] = 80; + sEnvTimerActive = true; + gSaveContext.timerDirections[TIMER_ID_ENV_HAZARD] = TIMER_COUNT_DOWN; + } + } + } + } + } else if (((sEnvHazard == PLAYER_ENV_HAZARD_NONE) || (sEnvHazard == PLAYER_ENV_HAZARD_SWIMMING)) && + (gSaveContext.timerStates[TIMER_ID_ENV_HAZARD] <= TIMER_STATE_COUNTING)) { + gSaveContext.timerStates[TIMER_ID_ENV_HAZARD] = TIMER_STATE_OFF; + } + + // Update minigame + if (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) { + gSaveContext.minigameScore += interfaceCtx->minigamePoints; + gSaveContext.minigameHiddenScore += interfaceCtx->minigameHiddenPoints; + interfaceCtx->minigamePoints = 0; + interfaceCtx->minigameHiddenPoints = 0; + + // Update horseback archery tier, unused remnant of OoT. + if (sHBAScoreTier == 0) { + if (gSaveContext.minigameScore >= 1000) { + sHBAScoreTier++; + } + } else if (sHBAScoreTier == 1) { + if (gSaveContext.minigameScore >= 1500) { + sHBAScoreTier++; + } + } + + // Get minigame digits + sMinigameScoreDigits[0] = sMinigameScoreDigits[1] = 0; + sMinigameScoreDigits[2] = 0; + sMinigameScoreDigits[3] = gSaveContext.minigameScore; + + while (sMinigameScoreDigits[3] >= 1000) { + sMinigameScoreDigits[0]++; + sMinigameScoreDigits[3] -= 1000; + } + + while (sMinigameScoreDigits[3] >= 100) { + sMinigameScoreDigits[1]++; + sMinigameScoreDigits[3] -= 100; + } + + while (sMinigameScoreDigits[3] >= 10) { + sMinigameScoreDigits[2]++; + sMinigameScoreDigits[3] -= 10; + } + } + + // Update Sun Song + if (gSaveContext.sunsSongState != SUNSSONG_INACTIVE) { + // exit out of ocarina mode after suns song finishes playing + if ((msgCtx->ocarinaAction != 0x39) && (gSaveContext.sunsSongState == SUNSSONG_START)) { + play->msgCtx.ocarinaMode = 4; + } + + // handle suns song in areas where time moves + if (play->envCtx.sceneTimeSpeed != 0) { + if (gSaveContext.sunsSongState != SUNSSONG_SPEED_TIME) { + sIsSunsPlayedAtDay = false; + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + sIsSunsPlayedAtDay = true; + } + + gSaveContext.sunsSongState = SUNSSONG_SPEED_TIME; + sPrevTimeSpeed = R_TIME_SPEED; + R_TIME_SPEED = 400; + } else if (!sIsSunsPlayedAtDay) { + // Nighttime + if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time <= CLOCK_TIME(18, 0))) { + // Daytime has been reached. End suns song effect + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + R_TIME_SPEED = sPrevTimeSpeed; + play->msgCtx.ocarinaMode = 4; + } + } else { + // Daytime + if (gSaveContext.save.time > CLOCK_TIME(18, 0)) { + // Nighttime has been reached. End suns song effect + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + R_TIME_SPEED = sPrevTimeSpeed; + play->msgCtx.ocarinaMode = 4; + } + } + } else { + gSaveContext.sunsSongState = SUNSSONG_SPECIAL; + } + } + + Interface_UpdateBottleTimers(play); + + // Update Grandma's Story + if (interfaceCtx->storyState != STORY_STATE_OFF) { + if (interfaceCtx->storyState == STORY_STATE_INIT) { + interfaceCtx->storyDmaStatus = STORY_DMA_IDLE; + interfaceCtx->storyState = STORY_STATE_IDLE; + R_STORY_FILL_SCREEN_ALPHA = 0; + } + + Interface_AllocStory(play); + + if (interfaceCtx->storyState == STORY_STATE_DESTROY) { + interfaceCtx->storyState = STORY_STATE_OFF; + interfaceCtx->storyDmaStatus = STORY_DMA_IDLE; + if (interfaceCtx->storySegment != NULL) { + ZeldaArena_Free(interfaceCtx->storySegment); + interfaceCtx->storySegment = NULL; + } + } else if (interfaceCtx->storyState == STORY_STATE_SETUP_IDLE) { + interfaceCtx->storyState = STORY_STATE_IDLE; + } else if (interfaceCtx->storyState == STORY_STATE_FADE_OUT) { + R_STORY_FILL_SCREEN_ALPHA += 10; + if (R_STORY_FILL_SCREEN_ALPHA >= 250) { + R_STORY_FILL_SCREEN_ALPHA = 255; + interfaceCtx->storyState = STORY_STATE_IDLE; + } + } else if (interfaceCtx->storyState == STORY_STATE_FADE_IN) { + R_STORY_FILL_SCREEN_ALPHA -= 10; + if (R_STORY_FILL_SCREEN_ALPHA < 0) { + R_STORY_FILL_SCREEN_ALPHA = 0; + interfaceCtx->storyState = STORY_STATE_IDLE; + } + } + } +} + +void Interface_Destroy(PlayState* play) { + Map_Destroy(play); + func_80174F9C(Interface_PostmanTimerCallback, NULL); +} + +void Interface_Init(PlayState* play) { + s32 pad; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + size_t parameterStaticSize; + s32 i; + + bzero(interfaceCtx, sizeof(InterfaceContext)); + + gSaveContext.sunsSongState = SUNSSONG_INACTIVE; + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + + View_Init(&interfaceCtx->view, play->state.gfxCtx); + + interfaceCtx->magicConsumptionTimer = 16; + interfaceCtx->healthTimer = 200; + + parameterStaticSize = SEGMENT_ROM_SIZE(parameter_static); + interfaceCtx->parameterSegment = THA_AllocEndAlign16(&play->state.heap, parameterStaticSize); + DmaMgr_SendRequest0(interfaceCtx->parameterSegment, SEGMENT_ROM_START(parameter_static), parameterStaticSize); + + interfaceCtx->doActionSegment = THA_AllocEndAlign16(&play->state.heap, 0xC90); + DmaMgr_SendRequest0(interfaceCtx->doActionSegment, SEGMENT_ROM_START(do_action_static), 0x300); + DmaMgr_SendRequest0(interfaceCtx->doActionSegment + 0x300, SEGMENT_ROM_START(do_action_static) + 0x480, 0x180); + + Interface_NewDay(play, CURRENT_DAY); + + interfaceCtx->iconItemSegment = THA_AllocEndAlign16(&play->state.heap, 0x4000); + + if (CUR_FORM_EQUIP(EQUIP_SLOT_B) < ITEM_F0) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } else if ((CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_NONE) && (CUR_FORM_EQUIP(EQUIP_SLOT_B) != ITEM_FD)) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_B); + } + + if (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) < ITEM_F0) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + } + + if (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) < ITEM_F0) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + } + + if (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) < ITEM_F0) { + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + } + + if (((gSaveContext.timerStates[TIMER_ID_MINIGAME_2] == TIMER_STATE_COUNTING) || + (gSaveContext.timerStates[TIMER_ID_GORON_RACE_UNUSED] == TIMER_STATE_COUNTING)) && + ((gSaveContext.respawnFlag == -1) || (gSaveContext.respawnFlag == 1)) && + (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] == TIMER_STATE_COUNTING)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_START; + gSaveContext.timerX[TIMER_ID_MINIGAME_2] = 115; + gSaveContext.timerY[TIMER_ID_MINIGAME_2] = 80; + } + + LifeMeter_Init(play); + Map_Init(play); + + gSaveContext.minigameStatus = MINIGAME_STATUS_END; + interfaceCtx->perfectLettersPrimColor[0] = 255; + interfaceCtx->perfectLettersPrimColor[1] = 165; + interfaceCtx->perfectLettersPrimColor[2] = 55; + + if (CHECK_EVENTINF(EVENTINF_34)) { + CLEAR_EVENTINF(EVENTINF_34); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; + } + + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_OFF; + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimits[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerStartOsTimes[TIMER_ID_MINIGAME_1] = 0; + gSaveContext.timerStopTimes[TIMER_ID_MINIGAME_1] = 0; + gSaveContext.timerPausedOsTimes[TIMER_ID_MINIGAME_1] = 0; + + for (i = 0; i < TIMER_ID_MAX; i++) { + if (gSaveContext.timerStates[i] == TIMER_STATE_7) { + gSaveContext.timerStates[i] = TIMER_STATE_OFF; + } + } + + sPictoState = PICTO_BOX_STATE_OFF; + sPictoPhotoBeingTaken = false; + + if ((play->sceneId != SCENE_MITURIN_BS) && (play->sceneId != SCENE_HAKUGIN_BS) && (play->sceneId != SCENE_SEA_BS) && + (play->sceneId != SCENE_INISIE_BS) && (play->sceneId != SCENE_LAST_BS) && (play->sceneId != SCENE_MITURIN) && + (play->sceneId != SCENE_HAKUGIN) && (play->sceneId != SCENE_SEA) && (play->sceneId != SCENE_INISIE_N) && + (play->sceneId != SCENE_INISIE_R) && (play->sceneId != SCENE_LAST_DEKU) && + (play->sceneId != SCENE_LAST_GORON) && (play->sceneId != SCENE_LAST_ZORA) && + (play->sceneId != SCENE_LAST_LINK)) { + + CLEAR_EVENTINF(EVENTINF_53); // Goht intro cutscene watched + CLEAR_EVENTINF(EVENTINF_54); // Odolwa intro cutscene watched + CLEAR_EVENTINF(EVENTINF_55); // Twinmold intro cutscene watched + CLEAR_EVENTINF(EVENTINF_56); // Gyorg intro cutscene watched + CLEAR_EVENTINF(EVENTINF_57); // Igos du Ikana intro cutscene watched + CLEAR_EVENTINF(EVENTINF_60); // Wart intro cutscene watched + CLEAR_EVENTINF(EVENTINF_61); // Majoras intro cutscene watched + CLEAR_EVENTINF(EVENTINF_62); // + CLEAR_EVENTINF(EVENTINF_63); // Gomess intro cutscene watched + } + + sFinalHoursClockDigitsRed = sFinalHoursClockFrameEnvRed = sFinalHoursClockFrameEnvGreen = + sFinalHoursClockFrameEnvBlue = 0; + sFinalHoursClockColorTimer = 15; + sFinalHoursClockColorTargetIndex = 0; +} 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..7b3a875c2 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1,4 +1,7 @@ #include "global.h" +#include "z64quake.h" +#include "z64shrink_window.h" +#include "z64view.h" #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80165460.s") @@ -34,11 +37,11 @@ #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") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_CompressI8ToI5.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80166644.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_DecompressI5ToI8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_801668B4.s") @@ -46,7 +49,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 +59,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,193 +77,379 @@ 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 * enters. */ -s16 Play_GetOriginalSceneNumber(s16 sceneNum) { +s16 Play_GetOriginalSceneId(s16 sceneId) { // Inverted Stone Tower Temple -> Stone Tower Temple - if (sceneNum == SCENE_INISIE_R) { + if (sceneId == SCENE_INISIE_R) { return SCENE_INISIE_N; } // Purified Southern Swamp -> Poisoned Sothern Swamp - if (sceneNum == SCENE_20SICHITAI2) { + if (sceneId == SCENE_20SICHITAI2) { return SCENE_20SICHITAI; } // Spring Mountain Village -> Winter Mountain Village - if (sceneNum == SCENE_10YUKIYAMANOMURA2) { + if (sceneId == SCENE_10YUKIYAMANOMURA2) { return SCENE_10YUKIYAMANOMURA; } // Spring Goron Village -> Winter Goron Village - if (sceneNum == SCENE_11GORONNOSATO2) { + if (sceneId == SCENE_11GORONNOSATO2) { return SCENE_11GORONNOSATO; } // Spring Path to Goron Village -> Winter Path to Goron Village - if (sceneNum == SCENE_17SETUGEN2) { + if (sceneId == SCENE_17SETUGEN2) { return SCENE_17SETUGEN; } // Inverted Stone Tower -> Stone Tower - if (sceneNum == SCENE_F41) { + if (sceneId == SCENE_F41) { return SCENE_F40; } - return sceneNum; + return sceneId; } /** * 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_GetOriginalSceneId(this->sceneId)]; + cycleSceneFlags->chest = this->actorCtx.sceneFlags.chest; + cycleSceneFlags->switch0 = this->actorCtx.sceneFlags.switches[0]; + cycleSceneFlags->switch1 = this->actorCtx.sceneFlags.switches[1]; - if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple - cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum]; + if (this->sceneId == SCENE_INISIE_R) { // Inverted Stone Tower Temple + cycleSceneFlags = &gSaveContext.cycleSceneFlags[this->sceneId]; } - cycleSceneFlags->collectible = globalCtx->actorCtx.flags.collectible[0]; - cycleSceneFlags->clearedRoom = globalCtx->actorCtx.flags.clearedRoom; + cycleSceneFlags->collectible = this->actorCtx.sceneFlags.collectible[0]; + cycleSceneFlags->clearedRoom = this->actorCtx.sceneFlags.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.sceneFlags.switches[2]; + gSaveContext.respawn[respawnMode].unk_18 = this->actorCtx.sceneFlags.collectible[1]; + gSaveContext.respawn[respawnMode].tempCollectFlags = this->actorCtx.sceneFlags.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->sceneId != SCENE_KAKUSIANA) { // Grottos + Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entrance), + this->roomCtx.curRoom.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->sceneId == 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.sceneFlags.switches[2]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].unk_18 = this->actorCtx.sceneFlags.collectible[1]; + gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = this->actorCtx.sceneFlags.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.curRoom.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 +457,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 +476,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 +488,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 +509,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; @@ -353,13 +540,13 @@ 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) { - MREG(64) = arg1; - MREG(65) = arg2; - MREG(66) = arg3; - MREG(67) = arg4; - MREG(68) = arg5; +// Set values to fill screen +void Play_FillScreen(GameState* thisx, s16 fillScreenOn, u8 red, u8 green, u8 blue, u8 alpha) { + R_PLAY_FILL_SCREEN_ON = fillScreenOn; + R_PLAY_FILL_SCREEN_R = red; + R_PLAY_FILL_SCREEN_G = green; + R_PLAY_FILL_SCREEN_B = blue; + R_PLAY_FILL_SCREEN_ALPHA = alpha; } #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Init.s") diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 7ed1ce5ce..a4ceeba95 100644 --- a/src/code/z_player_call.c +++ b/src/code/z_player_call.c @@ -9,12 +9,12 @@ 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 = { +ActorInit Player_InitVars = { ACTOR_PLAYER, ACTORCAT_PLAYER, FLAGS, @@ -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..d00325224 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1,153 +1,1806 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801226E0.s") +#include "objects/gameplay_keep/gameplay_keep.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122744.s") +#include "objects/object_link_boy/object_link_boy.h" +#include "objects/object_link_goron/object_link_goron.h" +#include "objects/object_link_zora/object_link_zora.h" +#include "objects/object_link_nuts/object_link_nuts.h" +#include "objects/object_link_child/object_link_child.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122760.s") +#include "objects/object_mask_truth/object_mask_truth.h" +#include "objects/object_mask_kerfay/object_mask_kerfay.h" +#include "objects/object_mask_yofukasi/object_mask_yofukasi.h" +#include "objects/object_mask_rabit/object_mask_rabit.h" +#include "objects/object_mask_ki_tan/object_mask_ki_tan.h" +#include "objects/object_mask_json/object_mask_json.h" +#include "objects/object_mask_romerny/object_mask_romerny.h" +#include "objects/object_mask_zacho/object_mask_zacho.h" +#include "objects/object_mask_posthat/object_mask_posthat.h" +#include "objects/object_mask_meoto/object_mask_meoto.h" +#include "objects/object_mask_bigelf/object_mask_bigelf.h" +#include "objects/object_mask_gibudo/object_mask_gibudo.h" +#include "objects/object_mask_gero/object_mask_gero.h" +#include "objects/object_mask_dancer/object_mask_dancer.h" +#include "objects/object_mask_skj/object_mask_skj.h" +#include "objects/object_mask_stone/object_mask_stone.h" +#include "objects/object_mask_bree/object_mask_bree.h" +#include "objects/object_mask_bakuretu/object_mask_bakuretu.h" +#include "objects/object_mask_bu_san/object_mask_bu_san.h" +#include "objects/object_mask_kyojin/object_mask_kyojin.h" +#include "objects/object_mask_boy/object_mask_boy.h" +#include "objects/object_mask_goron/object_mask_goron.h" +#include "objects/object_mask_zora/object_mask_zora.h" +#include "objects/object_mask_nuts/object_mask_nuts.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122868.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_801229A0.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_801229EC.s") +struct_801F58B0 D_801F58B0[3][3]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801229FC.s") +Vec3f D_801F59B0[2]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122BA4.s") +s32 D_801F59C8[2]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122C20.s") +typedef struct { + /* 0x0 */ s16 unk_0; + /* 0x2 */ s16 unk_2; + /* 0x4 */ s16 unk_4; + /* 0x6 */ s16 unk_6; + /* 0x8 */ s16 unk_8; +} struct_801F59D0; // size = 0xA -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122D44.s") +struct_801F59D0 D_801F59D0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122ED8.s") +Vec3f* D_801F59DC; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122EEC.s") +s32 D_801F59E0; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122F28.s") +s32 D_801F59E4; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122F9C.s") +Vec3f D_801F59E8; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80122FCC.s") +s32 D_801F59F4; +s32 D_801F59F8; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012300C.s") +void func_80127B64(struct_801F58B0 arg0[], s32 count, Vec3f* arg2); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012301C.s") +s32 func_801226E0(PlayState* play, s32 arg1) { + if (arg1 == 0) { + Play_SetupRespawnPoint(&play->state, RESPAWN_MODE_DOWN, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B)); + if (play->sceneId == SCENE_KAKUSIANA) { + return 1; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123140.s") + gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 0; + return arg1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123358.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/Player_InCsMode.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_80123420.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_80123434.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_80123448.s") + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801234B0.s") + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801234D4.s") +void func_80122868(PlayState* play, Player* player) { + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123590.s") + if (player->invincibilityTimer > 0) { + s32 phi_v0 = 50 - player->invincibilityTimer; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801235DC.s") + phi_v0 = CLAMP(phi_v0, 8, 40); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012364C.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_80123810.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123960.s") +void func_801229A0(PlayState* play, Player* player) { + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801239AC.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_80123AA4.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123BD4.s") +void func_801229EC(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123C58.s") +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, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_SetEquipmentData.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]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123D50.s") + 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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123DA4.s") + if (player->currentMask == PLAYER_MASK_GREAT_FAIRY) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123DC0.s") + for (i = 0; i < ARRAY_COUNT(D_801F58B0); i++) { + func_80127B64(D_801F58B0[i], ARRAY_COUNT(D_801F58B0[i]), + &player->bodyPartsPos[PLAYER_BODYPART_HEAD]); + } + } + } + } 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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123E90.s") + for (i = 0; i < ARRAY_COUNT(D_801F59C8); i++) { + D_801F59C8[i] += Rand_S16Offset(4, 23) + (s32)(fabsf(player->linearVelocity) * 50.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F14.s") +void func_80122BA4(PlayState* play, struct_80122D44_arg1* arg1, s32 arg2, s32 alpha) { + if (arg2 == arg1->unk_00) { + s32 index; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F2C.s") + arg1->unk_01--; + if (arg1->unk_01 < 0) { + arg1->unk_01 = 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80123F48.s") + 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); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124020.s") + arg1->unk_00 = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_GetMask.s") +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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_RemoveMask.s") + 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; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012405C.s") +typedef struct { + /* 0x0 */ Color_RGB8 color; + /* 0x4 */ Gfx* dList; +} struct_801BFDD0; // size = 0x08 -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124088.s") +struct_801BFDD0 D_801BFDD0[] = { + { { 180, 200, 255 }, gLinkGoronCurledDL }, + { { 155, 0, 0 }, gLinkGoronRollingSpikesAndEffectDL }, + { { 255, 0, 0 }, gLinkGoronGoronPunchEffectDL }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801240C8.s") +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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801240DC.s") + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124110.s") + 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); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124148.s") + gDPPipeSync(POLY_XLU_DISP++); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124168.s") + if (!phi_s6 && phi_s2->unk_00 == 2) { + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_goron_Matanimheader_013138)); + phi_s6 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124190.s") + Scene_SetRenderModeXlu(play, 1, 2); + gDPSetEnvColor(POLY_XLU_DISP++, temp_s3->color.r, temp_s3->color.g, temp_s3->color.b, phi_s2->alpha); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801241B4.s") + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801241E0.s") + gSPDisplayList(POLY_XLU_DISP++, temp_s3->dList); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012420C.s") + phi_s2++; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_8012422C.s") + CLOSE_DISPS(play->state.gfxCtx); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_GetExplosiveHeld.s") +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 +}; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124278.s") +u8 Player_MaskIdToItemId(s32 maskIdMinusOne) { + return sMaskItemIds[maskIdMinusOne]; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801242B4.s") +s32 Player_GetCurMaskItemId(PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801242DC.s") + 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_400 | PLAYER_STATE1_800 | PLAYER_STATE1_200000 | PLAYER_STATE1_800000 | + PLAYER_STATE1_20000000))) && + (!(player->stateFlags2 & PLAYER_STATE2_1))) { + if (player->doorType <= PLAYER_DOORTYPE_TALKING) { + 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(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + Player* this = (Player*)thisx; + + this->unk_AE7++; + + if (this->unk_AE7 == 2) { + s16 objectId = gPlayerFormObjectIndices[GET_PLAYER_FORM]; + + gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId = objectId; + func_8012F73C(&play->objectCtx, this->actor.objBankIndex, objectId); + this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, GAMEPLAY_KEEP); + } else if (this->unk_AE7 >= 3) { + s32 objBankIndex = Object_GetIndex(&play->objectCtx, gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId); + + if (Object_IsLoaded(&play->objectCtx, objBankIndex)) { + this->actor.objBankIndex = objBankIndex; + this->actor.shape.rot.z = GET_PLAYER_FORM + 1; + this->actor.init = PlayerCall_Init; + this->actor.update = PlayerCall_Update; + this->actor.draw = PlayerCall_Draw; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; + } + } +} + +FlexSkeletonHeader* gPlayerSkeletons[PLAYER_FORM_MAX] = { + &gLinkFierceDeitySkel, &gLinkGoronSkel, &gLinkZoraSkel, &gLinkDekuSkel, &gLinkHumanSkel, +}; + +s16 D_801BFE14[][18] = { + { 200, 666, 200, 700, 366, 200, 600, 175, 60, 800, 1000, -100, 600, 590, 800, 125, 300, 65 }, + { 200, 1000, 300, 800, 500, 400, 800, 400, 120, 800, 550, -100, 600, 540, 750, 125, 400, 200 }, + { 100, 1000, 300, 800, 250, 200, 800, 200, 90, 800, 350, -80, 600, 540, 750, 60, 200, 200 }, + { 200, 1000, 300, 700, 550, 270, 600, 1000, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + { 200, 1000, 300, 700, 550, 270, 700, 300, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + { 200, 1000, 300, 700, 550, 270, 700, 300, 120, 800, 600, -100, 600, 590, 750, 125, 200, 130 }, + { 200, 1000, 300, 700, 550, 270, 700, 200, 120, 800, 600, -140, 600, 590, 750, 125, 200, 130 }, + { 80, 800, 150, 700, 480, 270, 600, 50, 120, 800, 300, -40, 400, 540, 270, 25, 0, 80 }, +}; + +// 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.curRoom.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_80 | PLAYER_STATE1_200 | PLAYER_STATE1_20000000)) || + (player->csMode != 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_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); +} + +// 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->targetedActor == 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; +} + +ItemId func_8012364C(PlayState* play, Player* player, s32 arg2) { + if (arg2 >= 4) { + return ITEM_NONE; + } + + if (arg2 == 0) { + ItemId item = Inventory_GetBtnBItem(play); + + if (item >= ITEM_FD) { + return item; + } + + if ((player->currentMask == PLAYER_MASK_BLAST) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_EXPLODE)) { + return ITEM_F0; + } + + if ((player->currentMask == PLAYER_MASK_BREMEN) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_MARCH)) { + return ITEM_F1; + } + + if ((player->currentMask == PLAYER_MASK_KAMARO) && (play->interfaceCtx.bButtonDoAction == DO_ACTION_DANCE)) { + return ITEM_F2; + } + + return item; + } + + if (arg2 == 1) { + return C_BTN_ITEM(EQUIP_SLOT_C_LEFT); + } + + if (arg2 == 2) { + return C_BTN_ITEM(EQUIP_SLOT_C_DOWN); + } + + return C_BTN_ITEM(EQUIP_SLOT_C_RIGHT); +} + +u16 sCItemButtons[] = { BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; + +PlayerItemAction func_80123810(PlayState* play) { + Player* player = GET_PLAYER(play); + PlayerItemAction itemAction; + ItemId itemId; + s32 i; + + if (gSaveContext.save.unk_06 == 0) { + if (CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_A | BTN_B)) { + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; + Interface_SetHudVisibility(play->msgCtx.unk_120BC); + return PLAYER_IA_MINUS1; + } + } else { + gSaveContext.save.unk_06--; + } + + for (i = 0; i < ARRAY_COUNT(sCItemButtons); i++) { + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, sCItemButtons[i])) { + i++; + itemId = func_8012364C(play, player, i); + + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; + Interface_SetHudVisibility(play->msgCtx.unk_120BC); + + if ((itemId >= ITEM_FD) || ((itemAction = play->unk_18794(play, player, itemId)) <= PLAYER_IA_MINUS1)) { + play_sound(NA_SE_SY_ERROR); + return PLAYER_IA_MINUS1; + } else { + s32 pad; + + player->heldItemButton = i; + return itemAction; + } + } + } + + return PLAYER_IA_NONE; +} + +// Used to map item actions to model groups +u8 sActionModelGroups[PLAYER_IA_MAX] = { + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_NONE + PLAYER_MODELGROUP_13, // PLAYER_IA_LAST_USED + PLAYER_MODELGROUP_STICK, // PLAYER_IA_FISHING_ROD + PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_IA_SWORD_KOKIRI + PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_IA_SWORD_RAZOR + PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_IA_SWORD_GILDED + PLAYER_MODELGROUP_TWO_HAND_SWORD, // PLAYER_IA_SWORD_GREAT_FAIRY + PLAYER_MODELGROUP_STICK, // PLAYER_IA_STICK + PLAYER_MODELGROUP_ZORA_FINS, // PLAYER_IA_ZORA_FINS + PLAYER_MODELGROUP_BOW, // PLAYER_IA_BOW + PLAYER_MODELGROUP_BOW, // PLAYER_IA_BOW_FIRE + PLAYER_MODELGROUP_BOW, // PLAYER_IA_BOW_ICE + PLAYER_MODELGROUP_BOW, // PLAYER_IA_BOW_LIGHT + PLAYER_MODELGROUP_HOOKSHOT, // PLAYER_IA_HOOKSHOT + PLAYER_MODELGROUP_EXPLOSIVES, // PLAYER_IA_BOMB + PLAYER_MODELGROUP_EXPLOSIVES, // PLAYER_IA_POWDER_KEG + PLAYER_MODELGROUP_EXPLOSIVES, // PLAYER_IA_BOMBCHU + PLAYER_MODELGROUP_8, // PLAYER_IA_11 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_NUT + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_PICTO_BOX + PLAYER_MODELGROUP_INSTRUMENT, // PLAYER_IA_OCARINA + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_FISH + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_SPRING_WATER + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_HOT_SPRING_WATER + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_ZORA_EGG + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_DEKU_PRINCESS + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_GOLD_DUST + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_1C + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_SEAHORSE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_MUSHROOM + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_HYLIAN_LOACH + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_BUG + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_POE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_BIG_POE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_POTION_RED + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_POTION_BLUE + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_POTION_GREEN + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_MILK + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_MILK_HALF + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_CHATEAU + PLAYER_MODELGROUP_BOTTLE, // PLAYER_IA_BOTTLE_FAIRY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MOON_TEAR + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_DEED_LAND + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_ROOM_KEY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_LETTER_TO_KAFEI + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MAGIC_BEANS + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_DEED_SWAMP + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_DEED_MOUNTAIN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_DEED_OCEAN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_32 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_LETTER_MAMA + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_34 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_35 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_PENDANT_OF_MEMORIES + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_37 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_38 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_39 + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_TRUTH + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_KAFEIS_MASK + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_ALL_NIGHT + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_BUNNY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_KEATON + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GARO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_ROMANI + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_CIRCUS_LEADER + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_POSTMAN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_COUPLE + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GREAT_FAIRY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GIBDO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_DON_GERO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_KAMARO + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_CAPTAIN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_STONE + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_BREMEN + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_BLAST + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_SCENTS + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GIANT + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_FIERCE_DEITY + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_GORON + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_ZORA + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_MASK_DEKU + PLAYER_MODELGROUP_DEFAULT, // PLAYER_IA_LENS +}; + +PlayerModelGroup Player_ActionToModelGroup(Player* player, PlayerItemAction itemAction) { + PlayerModelGroup modelGroup = sActionModelGroups[itemAction]; + + if ((modelGroup == PLAYER_MODELGROUP_ONE_HAND_SWORD) && Player_IsGoronOrDeku(player)) { + return PLAYER_MODELGROUP_1; + } + return modelGroup; +} + +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 +}; + +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 +}; + +typedef struct { + /* 0x0 */ u8 flag; + /* 0x2 */ u16 textId; +} EnvHazardTextTriggerEntry; // size = 0x4 + +// These textIds are OoT remnants. The corresponding text entries are not present in this game, and so these don't point +// to anything relevant. +EnvHazardTextTriggerEntry sEnvHazardTextTriggers[] = { + { ENV_HAZARD_TEXT_TRIGGER_HOTROOM, 0x26FC }, // PLAYER_ENV_HAZARD_HOTROOM - 1 + { ENV_HAZARD_TEXT_TRIGGER_UNDERWATER, 0x26FD }, // PLAYER_ENV_HAZARD_UNDERWATER_FLOOR - 1 + { 0, 0 }, // PLAYER_ENV_HAZARD_SWIMMING - 1 + { ENV_HAZARD_TEXT_TRIGGER_UNDERWATER, 0x26FD }, // PLAYER_ENV_HAZARD_UNDERWATER_FREE - 1 +}; + +PlayerModelIndices gPlayerModelTypes[PLAYER_MODELGROUP_MAX] = { + /* PLAYER_MODELGROUP_0 */ + { PLAYER_ANIMTYPE_2, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_SHIELD, PLAYER_MODELTYPE_SHEATH_12, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_1 */ + { PLAYER_ANIMTYPE_1, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_15, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_ONE_HAND_SWORD */ + { PLAYER_ANIMTYPE_1, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_SHIELD, PLAYER_MODELTYPE_SHEATH_13, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_DEFAULT */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_4 */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_TWO_HAND_SWORD */ + { PLAYER_ANIMTYPE_3, PLAYER_MODELTYPE_LH_TWO_HAND_SWORD, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_BOW */ + { PLAYER_ANIMTYPE_4, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_BOW, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_EXPLOSIVES */ + { PLAYER_ANIMTYPE_5, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_8 */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_4, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_HOOKSHOT */ + { PLAYER_ANIMTYPE_4, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_HOOKSHOT, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_STICK */ + { PLAYER_ANIMTYPE_3, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_INSTRUMENT */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_OPEN, PLAYER_MODELTYPE_RH_INSTRUMENT, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_BOTTLE */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_BOTTLE, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_13 */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_ONE_HAND_SWORD, PLAYER_MODELTYPE_RH_OPEN, PLAYER_MODELTYPE_SHEATH_15, + PLAYER_MODELTYPE_WAIST }, + /* PLAYER_MODELGROUP_ZORA_FINS */ + { PLAYER_ANIMTYPE_0, PLAYER_MODELTYPE_LH_CLOSED, PLAYER_MODELTYPE_RH_CLOSED, PLAYER_MODELTYPE_SHEATH_14, + PLAYER_MODELTYPE_WAIST }, +}; + +/* DLists groups start */ +// Note: Only the ones with size 2 * PLAYER_FORM_MAX + +Gfx* gPlayerWaistDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityWaistDL, gLinkFierceDeityWaistDL, gLinkGoronWaistDL, gLinkGoronWaistDL, gLinkZoraWaistDL, + gLinkZoraWaistDL, gLinkDekuWaistDL, gLinkDekuWaistDL, gLinkHumanWaistDL, gLinkHumanWaistDL, +}; + +Gfx* gPlayerHandHoldingShields[PLAYER_SHIELD_MAX - 1][2] = { + { gLinkHumanRightHandHoldingHylianShieldDL, gLinkHumanRightHandHoldingHylianShieldDL }, + { gLinkHumanRightHandHoldingMirrorShieldDL, gLinkHumanRightHandHoldingMirrorShieldDL }, +}; + +Gfx* gPlayerSheath12DLs[2 * PLAYER_FORM_MAX] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + gLinkDekuSheathDL, + gLinkDekuSheathDL, + gLinkHumanSheathEmptyDL, + gLinkHumanSheathEmptyDL, +}; + +Gfx* gPlayerSheath13DLs[2 * PLAYER_FORM_MAX] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + gLinkDekuSheathDL, + gLinkDekuSheathDL, + gLinkHumanSheathEmptyDL, + gLinkHumanSheathEmptyDL, +}; + +Gfx* gPlayerSheath14DLs[2 * PLAYER_FORM_MAX] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + gLinkDekuSheathDL, + gLinkDekuSheathDL, + gLinkHumanSheathEmptyDL, + gLinkHumanSheathEmptyDL, +}; + +Gfx* gPlayerShields[][2] = { + { gLinkHumanHylianShieldWithMtxDL, gLinkHumanHylianShieldWithMtxDL }, + { gLinkHumanMirrorShieldWithMtxDL, gLinkHumanMirrorShieldWithMtxDL }, +}; + +Gfx* gPlayerSheathedSwords[][2] = { + { gLinkHumanSheathedKokiriSwordDL, gLinkHumanSheathedKokiriSwordDL }, + { gLinkHumanSheathedRazorSwordDL, gLinkHumanSheathedRazorSwordDL }, + { gLinkHumanSheathedGildedSwordDL, gLinkHumanSheathedGildedSwordDL }, +}; + +Gfx* gPlayerSwordSheaths[][2] = { + { gLinkHumanKokiriSwordSheathDL, gLinkHumanKokiriSwordSheathDL }, + { gLinkHumanRazorSwordSheathDL, gLinkHumanRazorSwordSheathDL }, + { gLinkHumanGildedSwordSheathDL, gLinkHumanGildedSwordSheathDL }, +}; + +Gfx* gPlayerLeftHandTwoHandSwordDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandHoldingSwordDL, + gLinkFierceDeityLeftHandHoldingSwordDL, + gLinkGoronLeftHandOpenDL, + gLinkGoronLeftHandOpenDL, + gLinkZoraLeftHandOpenDL, + gLinkZoraLeftHandOpenDL, + gLinkDekuLeftHandDL, + gLinkDekuLeftHandDL, + gLinkHumanLeftHandHoldingGreatFairysSwordDL, + gLinkHumanLeftHandHoldingGreatFairysSwordDL, +}; + +Gfx* gPlayerLeftHandOpenDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, gLinkFierceDeityLeftHandDL, gLinkGoronLeftHandOpenDL, gLinkGoronLeftHandOpenDL, + gLinkZoraLeftHandOpenDL, gLinkZoraLeftHandOpenDL, gLinkDekuLeftHandDL, gLinkDekuLeftHandDL, + gLinkHumanLeftHandOpenDL, gLinkHumanLeftHandOpenDL, +}; + +Gfx* gPlayerLeftHandClosedDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, gLinkFierceDeityLeftHandDL, gLinkGoronLeftHandClosedDL, gLinkGoronLeftHandClosedDL, + gLinkZoraLeftHandClosedDL, gLinkZoraLeftHandClosedDL, gLinkDekuLeftHandDL, gLinkDekuLeftHandDL, + gLinkHumanLeftHandClosedDL, gLinkHumanLeftHandClosedDL, +}; + +Gfx* gPlayerLeftHandOneHandSwordDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, + gLinkFierceDeityLeftHandDL, + gLinkGoronLeftHandOpenDL, + gLinkGoronLeftHandOpenDL, + gLinkZoraLeftHandClosedDL, + gLinkZoraLeftHandClosedDL, + gLinkDekuLeftHandDL, + gLinkDekuLeftHandDL, + gLinkHumanLeftHandHoldingKokiriSwordDL, + gLinkHumanLeftHandHoldingKokiriSwordDL, +}; + +Gfx* D_801C018C[][2] = { + { gLinkHumanLeftHandHoldingKokiriSwordDL, gLinkHumanLeftHandHoldingKokiriSwordDL }, + { gLinkHumanLeftHandHoldingRazorSwordDL, gLinkHumanLeftHandHoldingRazorSwordDL }, + { gLinkHumanLeftHandHoldingGildedSwordDL, gLinkHumanLeftHandHoldingGildedSwordDL }, +}; + +Gfx* gPlayerRightHandOpenDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, gLinkFierceDeityRightHandDL, gLinkGoronRightHandOpenDL, gLinkGoronRightHandOpenDL, + gLinkZoraRightHandOpenDL, gLinkZoraRightHandOpenDL, gLinkDekuRightHandDL, gLinkDekuRightHandDL, + gLinkHumanRightHandOpenDL, gLinkHumanRightHandOpenDL, +}; + +Gfx* gPlayerRightHandClosedDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, gLinkFierceDeityRightHandDL, gLinkGoronRightHandClosedDL, gLinkGoronRightHandClosedDL, + gLinkZoraRightHandClosedDL, gLinkZoraRightHandClosedDL, gLinkDekuRightHandDL, gLinkDekuRightHandDL, + gLinkHumanRightHandClosedDL, gLinkHumanRightHandClosedDL, +}; + +Gfx* gPlayerRightHandBowDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + gLinkFierceDeityRightHandDL, + gLinkGoronRightHandOpenDL, + gLinkGoronRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + gLinkDekuRightHandDL, + gLinkHumanRightHandHoldingBowDL, + gLinkHumanRightHandHoldingBowDL, +}; + +Gfx* gPlayerRightHandInstrumentDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + gLinkFierceDeityRightHandDL, + gLinkGoronRightHandOpenDL, + gLinkGoronRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + gLinkDekuRightHandDL, + gLinkHumanRightHandHoldingOcarinaDL, + gLinkHumanRightHandHoldingOcarinaDL, +}; + +Gfx* gPlayerRightHandHookshotDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + gLinkFierceDeityRightHandDL, + gLinkGoronRightHandOpenDL, + gLinkGoronRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + gLinkDekuRightHandDL, + gLinkHumanRightHandHoldingHookshotDL, + gLinkHumanRightHandHoldingHookshotDL, +}; + +Gfx* gPlayerLeftHandBottleDLs[2 * PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, + gLinkFierceDeityLeftHandDL, + gLinkGoronLeftHandHoldBottleDL, + gLinkGoronLeftHandHoldBottleDL, + gLinkZoraLeftHandHoldBottleDL, + gLinkZoraLeftHandHoldBottleDL, + gLinkDekuLeftHandDL, + gLinkDekuLeftHandDL, + gLinkHumanLeftHandHoldBottleDL, + gLinkHumanLeftHandHoldBottleDL, +}; + +/* DLists groups end */ + +Gfx* D_801C0294[PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftForearmDL, gLinkGoronLeftForearmDL, gLinkZoraLeftForearmDL, + gLinkDekuLeftForearmDL, gLinkHumanLeftForearmDL, +}; + +Gfx* D_801C02A8[PLAYER_FORM_MAX] = { + gLinkFierceDeityLeftHandDL, gLinkGoronLeftHandOpenDL, gLinkZoraLeftHandClosedDL, + gLinkDekuLeftHandDL, gLinkHumanLeftHandClosedDL, +}; + +Gfx* D_801C02BC[PLAYER_FORM_MAX] = { + gLinkFierceDeityRightShoulderDL, gLinkGoronRightShoulderDL, gLinkZoraRightShoulderDL, + gLinkDekuRightShoulderDL, gLinkHumanRightShoulderDL, +}; + +Gfx* D_801C02D0[PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + //! @bug This is in the middle of a texture in the link_goron object. It has the same offset as a link_nuts dlist + 0x060038C0, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + object_link_child_DL_018490, +}; + +Gfx* D_801C02E4[PLAYER_FORM_MAX] = { + gLinkFierceDeityRightHandDL, + //! @bug This is in the middle of a texture in the link_goron object. It has the same offset as a link_nuts dlist + 0x060038C0, + gLinkZoraRightHandOpenDL, + gLinkDekuRightHandDL, + object_link_child_DL_017B40, +}; + +// Indexed by model types (left hand, right hand, sheath or waist) +Gfx** sPlayerDListGroups[PLAYER_MODELTYPE_MAX] = { + gPlayerLeftHandOpenDLs, // PLAYER_MODELTYPE_LH_OPEN + gPlayerLeftHandClosedDLs, // PLAYER_MODELTYPE_LH_CLOSED + gPlayerLeftHandOneHandSwordDLs, // PLAYER_MODELTYPE_LH_ONE_HAND_SWORD + gPlayerLeftHandTwoHandSwordDLs, // PLAYER_MODELTYPE_LH_TWO_HAND_SWORD + gPlayerLeftHandOpenDLs, // PLAYER_MODELTYPE_LH_4 + gPlayerLeftHandBottleDLs, // PLAYER_MODELTYPE_LH_BOTTLE + gPlayerRightHandOpenDLs, // PLAYER_MODELTYPE_RH_OPEN + gPlayerRightHandClosedDLs, // PLAYER_MODELTYPE_RH_CLOSED + gPlayerRightHandClosedDLs, // PLAYER_MODELTYPE_RH_SHIELD + gPlayerRightHandBowDLs, // PLAYER_MODELTYPE_RH_BOW + gPlayerRightHandInstrumentDLs, // PLAYER_MODELTYPE_RH_INSTRUMENT + gPlayerRightHandHookshotDLs, // PLAYER_MODELTYPE_RH_HOOKSHOT + gPlayerSheath12DLs, // PLAYER_MODELTYPE_SHEATH_12 + gPlayerSheath13DLs, // PLAYER_MODELTYPE_SHEATH_13 + gPlayerSheath14DLs, // PLAYER_MODELTYPE_SHEATH_14 + gPlayerSheath14DLs, // PLAYER_MODELTYPE_SHEATH_15 + gPlayerWaistDLs, // PLAYER_MODELTYPE_WAIST + NULL, // PLAYER_MODELTYPE_17 +}; + +struct_80124618 D_801C0340[] = { + { 0, { 0, 0, 0 } }, { 5, { 0, 0, 0 } }, { 7, { 100, 100, 100 } }, + { 9, { 110, 110, 110 } }, { 11, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0368[] = { + { 0, { 0, 0, 0 } }, { 4, { 0, 0, 0 } }, { 6, { 120, 150, 60 } }, { 8, { 130, 80, 160 } }, + { 9, { 100, 100, 100 } }, { 10, { 90, 100, 90 } }, { 11, { 100, 100, 100 } }, +}; +struct_80124618 D_801C03A0[] = { + { 0, { 100, 100, 100 } }, + { 2, { 120, 120, 120 } }, + { 6, { 90, 90, 90 } }, + { 7, { 93, 93, 93 } }, +}; +struct_80124618 D_801C03C0[] = { + { 0, { 200, 100, 110 } }, + { 2, { 90, 100, 100 } }, + { 3, { 100, 100, 100 } }, + { 7, { 100, 100, 100 } }, +}; +struct_80124618 D_801C03E0[] = { + { 0, { 100, 100, 110 } }, { 2, { 60, 100, 80 } }, { 3, { 130, 105, 110 } }, + { 7, { 130, 105, 110 } }, { 10, { 100, 100, 100 } }, { 19, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0410[] = { + { 0, { 0, 0, 0 } }, + { 2, { 80, 110, 80 } }, + { 3, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0428[] = { + { 0, { 0, 0, 0 } }, { 6, { 0, 0, 0 } }, { 7, { 60, 60, 50 } }, { 8, { 120, 130, 100 } }, + { 9, { 100, 120, 80 } }, { 11, { 100, 100, 100 } }, { 13, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0460[] = { + { 0, { 100, 100, 100 } }, { 5, { 100, 100, 100 } }, { 7, { 100, 74, 80 } }, + { 8, { 100, 180, 130 } }, { 10, { 100, 80, 80 } }, { 13, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0490[] = { + { 0, { 100, 100, 100 } }, { 1, { 100, 100, 100 } }, { 2, { 90, 100, 105 } }, { 4, { 110, 100, 100 } }, + { 5, { 90, 100, 105 } }, { 6, { 100, 100, 100 } }, { 7, { 90, 100, 105 } }, { 8, { 100, 100, 100 } }, + { 9, { 90, 100, 105 } }, { 10, { 100, 100, 100 } }, { 11, { 90, 100, 105 } }, { 12, { 110, 100, 100 } }, + { 13, { 100, 100, 100 } }, { 14, { 90, 100, 105 } }, { 15, { 90, 100, 105 } }, { 17, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0510[] = { + { 0, { 100, 100, 100 } }, { 4, { 100, 100, 100 } }, { 5, { 90, 110, 100 } }, + { 6, { 110, 105, 100 } }, { 8, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0538[] = { + { 0, { 100, 100, 100 } }, { 5, { 100, 100, 100 } }, { 6, { 0, 0, 0 } }, + { 8, { 100, 100, 100 } }, { 14, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0560[] = { + { 0, { 100, 100, 100 } }, + { 2, { 95, 95, 100 } }, + { 3, { 105, 105, 100 } }, + { 5, { 102, 102, 102 } }, +}; +struct_80124618 D_801C0580[] = { + { 0, { 100, 100, 100 } }, { 9, { 100, 100, 100 } }, { 10, { 150, 150, 150 } }, + { 12, { 0, 0, 0 } }, { 14, { 0, 0, 0 } }, +}; +struct_80124618 D_801C05A8[] = { + { 0, { 100, 100, 100 } }, + { 6, { 100, 100, 100 } }, + { 7, { 0, 0, 0 } }, + { 17, { 0, 0, 0 } }, +}; +struct_80124618 D_801C05C8[] = { + { 0, { 0, 0, 0 } }, + { 17, { 50, 50, 50 } }, +}; +struct_80124618 D_801C05D8[] = { + { 0, { 0, 0, 0 } }, + { 5, { 0, 0, 0 } }, + { 9, { 100, 100, 100 } }, +}; +struct_80124618 D_801C05F0[] = { + { 0, { 100, 100, 100 } }, + { 5, { 100, 100, 100 } }, + { 9, { 0, 0, 0 } }, +}; +struct_80124618 D_801C0608[] = { + { 0, { 100, 100, 100 } }, + { 10, { 100, 100, 100 } }, + { 32, { 100, 115, 105 } }, + { 58, { 100, 101, 100 } }, +}; +struct_80124618 D_801C0628[] = { + { 0, { 100, 100, 100 } }, { 5, { 100, 100, 100 } }, { 15, { 100, 100, 105 } }, { 25, { 100, 100, 105 } }, + { 34, { 100, 100, 100 } }, { 46, { 100, 100, 100 } }, { 57, { 100, 100, 105 } }, { 67, { 100, 100, 105 } }, + { 76, { 100, 100, 100 } }, { 78, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0678[] = { + { 0, { 0, 0, 0 } }, + { 6, { 0, 0, 0 } }, + { 8, { 100, 100, 100 } }, + { 11, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0698[] = { + { 0, { 0, 0, 0 } }, + { 7, { 1120, 112, 112 } }, + { 8, { 140, 168, 168 } }, + { 11, { 140, 140, 140 } }, +}; +struct_80124618 D_801C06B8[] = { + { 0, { 100, 100, 100 } }, { 7, { 100, 100, 100 } }, { 8, { 70, 30, 70 } }, { 10, { 0, 0, 0 } }, { 14, { 0, 0, 0 } }, +}; +struct_80124618 D_801C06E0[] = { + { 0, { 140, 140, 140 } }, + { 1, { 0, 0, 0 } }, + { 14, { 0, 0, 0 } }, +}; +struct_80124618 D_801C06F8[] = { + { 0, { 100, 100, 100 } }, + { 5, { 100, 100, 100 } }, + { 6, { 0, 0, 0 } }, + { 10, { 0, 0, 0 } }, +}; +struct_80124618 D_801C0718[] = { + { 0, { 140, 140, 140 } }, + { 1, { 0, 0, 0 } }, + { 10, { 0, 0, 0 } }, +}; +struct_80124618 D_801C0730[] = { + { 0, { 100, 100, 100 } }, + { 13, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0740[] = { + { 0, { 140, 140, 140 } }, + { 13, { 140, 140, 140 } }, +}; +struct_80124618 D_801C0750[] = { + { 0, { 100, 100, 100 } }, { 5, { 100, 100, 100 } }, { 6, { 200, 200, 200 } }, + { 10, { 200, 200, 200 } }, { 11, { 100, 100, 100 } }, +}; + +// alpha values +u8 D_801C0778[] = { + 0, 0, 0, 0, 0, 100, 200, 255, 255, 255, 200, 100, +}; + +struct_80124618 D_801C0784[] = { + { 0, { 100, 100, 100 } }, { 14, { 100, 100, 100 } }, { 15, { 200, 200, 200 } }, + { 16, { 200, 200, 200 } }, { 18, { 100, 100, 100 } }, +}; + +u8 D_801C07AC[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 200, 255, 255, 255, 200, 100, 0, +}; + +void Player_SetModelsForHoldingShield(Player* player) { + if (player->stateFlags1 & PLAYER_STATE1_400000) { + if ((player->itemAction <= PLAYER_IA_MINUS1) || (player->itemAction == player->heldItemAction)) { + if (!Player_IsHoldingTwoHandedWeapon(player)) { + if (!Player_IsGoronOrDeku(player)) { + D_801F59E0 = player->transformation * 2; + player->rightHandType = PLAYER_MODELTYPE_RH_SHIELD; + player->rightHandDLists = &sPlayerDListGroups[PLAYER_MODELTYPE_RH_SHIELD][D_801F59E0]; + + if (player->sheathType == PLAYER_MODELTYPE_SHEATH_14) { + player->sheathType = PLAYER_MODELTYPE_SHEATH_12; + } else if (player->sheathType == PLAYER_MODELTYPE_SHEATH_15) { + player->sheathType = PLAYER_MODELTYPE_SHEATH_13; + } + + player->sheathDLists = &sPlayerDListGroups[player->sheathType][D_801F59E0]; + player->modelAnimType = PLAYER_ANIMTYPE_2; + player->itemAction = PLAYER_IA_MINUS1; + } + } + } + } +} + +void Player_SetModels(Player* player, PlayerModelGroup modelGroup) { + PlayerModelIndices* playerModelTypes; + + D_801F59E0 = player->transformation * 2; + player->leftHandType = gPlayerModelTypes[modelGroup].leftHandType; + player->rightHandType = gPlayerModelTypes[modelGroup].rightHandType; + player->sheathType = gPlayerModelTypes[modelGroup].sheathType; + + if (player->sheathType == PLAYER_MODELTYPE_SHEATH_14) { + if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) { + player->sheathType = PLAYER_MODELTYPE_SHEATH_15; + } + } + + playerModelTypes = &gPlayerModelTypes[modelGroup]; + + player->leftHandDLists = &sPlayerDListGroups[playerModelTypes->leftHandType][D_801F59E0]; + player->rightHandDLists = &sPlayerDListGroups[playerModelTypes->rightHandType][D_801F59E0]; + player->sheathDLists = &sPlayerDListGroups[playerModelTypes->sheathType][D_801F59E0]; + player->waistDLists = &sPlayerDListGroups[playerModelTypes->waistType][D_801F59E0]; + + Player_SetModelsForHoldingShield(player); +} + +void Player_SetModelGroup(Player* player, PlayerModelGroup modelGroup) { + player->modelGroup = modelGroup; + + if (modelGroup == PLAYER_MODELGROUP_1) { + player->modelAnimType = PLAYER_ANIMTYPE_0; + } else { + player->modelAnimType = gPlayerModelTypes[modelGroup].modelAnimType; + } + + if (player->modelAnimType < PLAYER_ANIMTYPE_3) { + if (((player->transformation != PLAYER_FORM_FIERCE_DEITY) && (player->transformation != PLAYER_FORM_HUMAN)) || + (player->currentShield == PLAYER_SHIELD_NONE)) { + player->modelAnimType = PLAYER_ANIMTYPE_0; + } + } + + Player_SetModels(player, modelGroup); +} + +void func_80123C58(Player* player) { + player->itemAction = player->heldItemAction; + Player_SetModelGroup(player, Player_ActionToModelGroup(player, player->heldItemAction)); + player->unk_AA5 = 0; +} + +void Player_SetEquipmentData(PlayState* play, Player* player) { + if (player->csMode != PLAYER_CSMODE_134) { + 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->heldItemAction)); + func_80123140(play, player); + if (player->unk_B62 != 0) { + player->unk_B62 = 1; + } + } +} + +void Player_UpdateBottleHeld(PlayState* play, Player* player, ItemId itemId, PlayerItemAction itemAction) { + Inventory_UpdateBottleItem(play, itemId, player->heldItemButton); + + if (itemId != ITEM_BOTTLE) { + player->heldItemId = itemId; + player->heldItemAction = itemAction; + } + + player->itemAction = itemAction; +} + +void func_80123DA4(Player* player) { + player->targetedActor = NULL; + player->stateFlags2 &= ~PLAYER_STATE2_2000; +} + +void func_80123DC0(Player* player) { + if ((player->actor.bgCheckFlags & 1) || + (player->stateFlags1 & (PLAYER_STATE1_200000 | PLAYER_STATE1_800000 | PLAYER_STATE1_8000000)) || + (!(player->stateFlags1 & (PLAYER_STATE1_40000 | PLAYER_STATE1_80000)) && + ((player->actor.world.pos.y - player->actor.floorHeight) < 100.0f))) { + player->stateFlags1 &= ~(PLAYER_STATE1_8000 | PLAYER_STATE1_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_80000 | PLAYER_STATE1_40000000); + } else if (!(player->stateFlags1 & (PLAYER_STATE1_40000 | PLAYER_STATE1_80000 | PLAYER_STATE1_200000))) { + player->stateFlags1 |= PLAYER_STATE1_80000; + } else if ((player->stateFlags1 & PLAYER_STATE1_40000) && (player->transformation == PLAYER_FORM_DEKU)) { + player->stateFlags1 &= + ~(PLAYER_STATE1_8000 | PLAYER_STATE1_10000 | PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); + } + + func_80123DA4(player); +} + +void func_80123E90(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); + + func_80123DC0(player); + player->targetedActor = 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); +} + +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->heldItemAction == PLAYER_IA_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[GET_PLAYER_FORM]; +} + +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 == PLAYER_MODELTYPE_RH_SHIELD) && + (player->currentShield == PLAYER_SHIELD_MIRROR_SHIELD); +} + +s32 Player_IsHoldingHookshot(Player* player) { + return player->heldItemAction == PLAYER_IA_HOOKSHOT; +} + +s32 func_801240DC(Player* player) { + return Player_IsHoldingHookshot(player) && (player->heldActor == NULL); +} + +s32 func_80124110(Player* player, PlayerItemAction itemAction) { + s32 temp_v0 = itemAction - PLAYER_IA_FISHING_ROD; + + if (player->transformation != PLAYER_FORM_GORON) { + if (((itemAction - PLAYER_IA_FISHING_ROD) > (PLAYER_IA_FISHING_ROD - PLAYER_IA_FISHING_ROD)) && + ((itemAction - PLAYER_IA_FISHING_ROD) < (PLAYER_IA_SWORD_GREAT_FAIRY - PLAYER_IA_FISHING_ROD))) { + return temp_v0; + } + } + + return 0; +} + +s32 func_80124148(Player* player) { + return func_80124110(player, player->heldItemAction); +} + +s32 Player_ActionToMeleeWeapon(PlayerItemAction itemAction) { + s32 weapon = itemAction - (PLAYER_IA_SWORD_KOKIRI - 1); + + if ((weapon > 0) && (weapon <= (PLAYER_IA_ZORA_FINS - (PLAYER_IA_SWORD_KOKIRI - 1)))) { + return weapon; + } + return 0; +} + +s32 Player_GetMeleeWeaponHeld(Player* player) { + return Player_ActionToMeleeWeapon(player->heldItemAction); +} + +s32 Player_IsHoldingTwoHandedWeapon(Player* player) { + // Relies on the itemActions for two-handed weapons being contiguous. + if ((player->heldItemAction >= PLAYER_IA_SWORD_GREAT_FAIRY) && (player->heldItemAction <= PLAYER_IA_STICK)) { + return true; + } + + return false; +} + +s32 Player_ActionToBottle(Player* player, PlayerItemAction itemAction) { + s32 bottle = itemAction - PLAYER_IA_BOTTLE; + + // Relies on bottle-related item actions to be contiguous + if ((bottle >= (PLAYER_IA_BOTTLE - PLAYER_IA_BOTTLE)) && (bottle <= (PLAYER_IA_BOTTLE_FAIRY - PLAYER_IA_BOTTLE))) { + return bottle; + } + + return -1; +} + +s32 Player_GetBottleHeld(Player* Player) { + return Player_ActionToBottle(Player, Player->heldItemAction); +} + +s32 Player_ActionToExplosive(Player* player, PlayerItemAction itemAction) { + s32 explosive = itemAction - PLAYER_IA_BOMB; + + // Relies on explosive-related item actions to be contiguous + if ((explosive >= (PLAYER_IA_BOMB - PLAYER_IA_BOMB)) && (explosive <= (PLAYER_IA_BOMBCHU - PLAYER_IA_BOMB))) { + return explosive; + } + + return -1; +} + +s32 Player_GetExplosiveHeld(Player* player) { + return Player_ActionToExplosive(player, player->heldItemAction); +} + +s32 Player_ActionToSword(Actor* actor, PlayerItemAction itemAction) { + s32 sword = 0; + + //! FAKE: + if ((itemAction == PLAYER_IA_LAST_USED) || + ((sword = itemAction - PLAYER_IA_SWORD_KOKIRI, (sword >= PLAYER_IA_SWORD_KOKIRI - PLAYER_IA_SWORD_KOKIRI)) && + (sword <= PLAYER_IA_SWORD_GREAT_FAIRY - PLAYER_IA_SWORD_KOKIRI))) { + return sword; + } + + return -1; +} + +s32 func_801242B4(Player* player) { + return (player->stateFlags1 & PLAYER_STATE1_8000000) && (player->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER); +} + +s32 Player_GetEnvironmentalHazard(PlayState* play) { + Player* player = GET_PLAYER(play); + EnvHazardTextTriggerEntry* triggerEntry; + s32 envHazard; + + if (play->roomCtx.curRoom.unk2 == 3) { // Room is hot + envHazard = PLAYER_ENV_HAZARD_HOTROOM - 1; + } else if ((player->transformation != PLAYER_FORM_ZORA) && (player->underwaterTimer > 80)) { + envHazard = PLAYER_ENV_HAZARD_UNDERWATER_FREE - 1; + } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { + if ((player->transformation == PLAYER_FORM_ZORA) && (player->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) && + (player->actor.bgCheckFlags & 1)) { + envHazard = PLAYER_ENV_HAZARD_UNDERWATER_FLOOR - 1; + } else { + envHazard = PLAYER_ENV_HAZARD_SWIMMING - 1; + } + } else { + return PLAYER_ENV_HAZARD_NONE; + } + + triggerEntry = &sEnvHazardTextTriggers[envHazard]; + if (!Player_InCsMode(play)) { + if ((triggerEntry->flag) && !(gSaveContext.envHazardTextTriggerFlags & triggerEntry->flag) && + (envHazard == (PLAYER_ENV_HAZARD_HOTROOM - 1))) { + Message_StartTextbox(play, triggerEntry->textId, NULL); + gSaveContext.envHazardTextTriggerFlags |= triggerEntry->flag; + } + } + + return envHazard + 1; +} + +void func_80124420(Player* player); #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; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801246F4.s") + 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; +} + +struct_80124618 D_801C07C0[] = { + { 0, { 100, 100, 100 } }, { 10, { 100, 100, 100 } }, { 11, { 100, 120, 120 } }, + { 12, { 100, 120, 120 } }, { 14, { 100, 100, 100 } }, { 19, { 100, 100, 100 } }, +}; + +struct_80124618 D_801C07F0[] = { + { 0, { 40, 60, 70 } }, { 3, { 40, 60, 70 } }, { 4, { 75, 90, 85 } }, + { 5, { 110, 120, 100 } }, { 7, { 100, 100, 100 } }, { 8, { 100, 100, 100 } }, +}; +struct_80124618 D_801C0820[] = { + { 0, { 100, 100, 100 } }, + { 7, { 100, 100, 100 } }, + { 12, { 40, 60, 70 } }, +}; +struct_80124618 D_801C0838[] = { + { 0, { 40, 60, 70 } }, + { 7, { 40, 60, 70 } }, + { 12, { 100, 100, 100 } }, +}; + +Gfx gCullBackDList[] = { + gsSPSetGeometryMode(G_CULL_BACK), + gsSPEndDisplayList(), +}; +Gfx gCullFrontDList[] = { + gsSPSetGeometryMode(G_CULL_FRONT), + gsSPEndDisplayList(), +}; + +TexturePtr sPlayerEyesTextures[] = { + gLinkHumanEyesOpenTex, gLinkHumanEyesHalfTex, gLinkHumanEyesClosedTex, gLinkHumanEyesRollRightTex, + gLinkHumanEyesRollLeftTex, gLinkHumanEyesRollUpTex, gLinkHumanEyesRollDownTex, object_link_child_Tex_003800, +}; + +TexturePtr sPlayerMouthTextures[] = { + gLinkHumanMouthClosedTex, + gLinkHumanMouthTeethTex, + gLinkHumanMouthAngryTex, + gLinkHumanMouthHappyTex, +}; + +typedef struct PlayerFaceIndices { + /* 0x00 */ u8 eyeIndex; + /* 0x01 */ u8 mouthIndex; +} PlayerFaceIndices; // size = 0x02 + +PlayerFaceIndices sPlayerFaces[] = { + { PLAYER_EYES_OPEN, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_0 + { PLAYER_EYES_HALF, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_1 + { PLAYER_EYES_CLOSED, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_2 + { PLAYER_EYES_OPEN, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_3 + { PLAYER_EYES_HALF, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_4 + { PLAYER_EYES_CLOSED, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_5 + { PLAYER_EYES_ROLL_LEFT, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_6 + { PLAYER_EYES_ROLL_UP, PLAYER_MOUTH_TEETH }, // PLAYER_FACE_7 + { PLAYER_EYES_7, PLAYER_MOUTH_ANGRY }, // PLAYER_FACE_8 + { PLAYER_EYES_OPEN, PLAYER_MOUTH_ANGRY }, // PLAYER_FACE_9 + { PLAYER_EYES_ROLL_RIGHT, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_10 + { PLAYER_EYES_ROLL_LEFT, PLAYER_MOUTH_CLOSED }, // PLAYER_FACE_11 + { PLAYER_EYES_CLOSED, PLAYER_MOUTH_ANGRY }, // PLAYER_FACE_12 + { PLAYER_EYES_HALF, PLAYER_MOUTH_TEETH }, // PLAYER_FACE_13 + { PLAYER_EYES_OPEN, PLAYER_MOUTH_ANGRY }, // PLAYER_FACE_14 + { PLAYER_EYES_OPEN, PLAYER_MOUTH_HAPPY }, // PLAYER_FACE_15 +}; + +// Note the correct pointer to pass as the jointTable is the jointTable pointer from the SkelAnime struct, not the +// buffer from the Player struct itself since that one may be misaligned. +void Player_DrawImpl(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, + PlayerTransformation playerForm, s32 boots, s32 face, OverrideLimbDrawFlex overrideLimbDraw, + PostLimbDrawFlex postLimbDraw, Actor* actor) { + s32 eyeIndex = (jointTable[22].x & 0xF) - 1; + s32 mouthIndex = ((jointTable[22].x >> 4) & 0xF) - 1; + Gfx* gfx; + + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + if (eyeIndex < 0) { + eyeIndex = sPlayerFaces[face].eyeIndex; + } + + if (playerForm == PLAYER_FORM_GORON) { + if ((eyeIndex >= PLAYER_EYES_ROLL_RIGHT) && (eyeIndex <= PLAYER_EYES_ROLL_DOWN)) { + eyeIndex = PLAYER_EYES_OPEN; + } else if (eyeIndex == PLAYER_EYES_7) { + eyeIndex = PLAYER_EYES_ROLL_RIGHT; + } + } + + gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(sPlayerEyesTextures[eyeIndex])); + + if (mouthIndex < 0) { + mouthIndex = sPlayerFaces[face].mouthIndex; + } + + gSPSegment(&gfx[1], 0x09, Lib_SegmentedToVirtual(sPlayerMouthTextures[mouthIndex])); + + POLY_OPA_DISP = &gfx[2]; + + D_801F59E0 = playerForm * 2; + D_801F59E4 = lod; + SkelAnime_DrawFlexLod(play, skeleton, jointTable, dListCount, overrideLimbDraw, postLimbDraw, actor, lod); + + CLOSE_DISPS(play->state.gfxCtx); +} + +Vec3f D_801C08C0[PLAYER_FORM_MAX] = { + { 1304.0f, 0.0f, 0.0f }, { 1156.0f, 0.0f, 0.0f }, { 1406.0f, 0.0f, 0.0f }, + { 408.0f, 0.0f, 0.0f }, { 695.0f, 0.0f, 0.0f }, +}; + +f32 D_801C08FC[PLAYER_FORM_MAX] = { + 1265.0f, 1056.0f, 1506.0f, 359.0f, 826.0f, +}; +f32 D_801C0910[PLAYER_FORM_MAX] = { + 170.0416f, 133.63359f, 197.68358f, 16.646399f, 48.302498f, +}; +f32 D_801C0924[PLAYER_FORM_MAX] = { + 10.019104f, 22.120003f, -29.12001f, 3.7582989f, -19.925102f, +}; +f32 D_801C0938[PLAYER_FORM_MAX] = { + 5.0f, 4.0f, 1.0f, 1.0f, 3.0f, +}; #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124870.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124CC4.s") +void func_80124CC4(PlayState* play, Player* player, f32 arg2) { + static Vec3f D_801C094C = { -500.0f, -100.0f, 0.0f }; + CollisionPoly* poly; + s32 bgId; + Vec3f sp7C; + Vec3f sp70; + Vec3f pos; + Vec3f sp58; + f32 sp54; + f32 scale; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124F18.s") + D_801C094C.z = 0.0f; + Matrix_MultVec3f(&D_801C094C, &sp7C); + D_801C094C.z = arg2; + Matrix_MultVec3f(&D_801C094C, &sp70); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80124FF0.s") + if (BgCheck_AnyLineTest3(&play->colCtx, &sp7C, &sp70, &pos, &poly, true, true, true, true, &bgId)) { + if (!func_800B90AC(play, &player->actor, poly, bgId, &pos) || + BgCheck_ProjectileLineTest(&play->colCtx, &sp7C, &sp70, &pos, &poly, true, true, true, true, &bgId)) { + OPEN_DISPS(play->state.gfxCtx); + + OVERLAY_DISP = Gfx_CallSetupDL(OVERLAY_DISP, 7); + + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &sp58, &sp54); + if (sp54 < 200.0f) { + scale = 0.08f; + } else { + scale = (sp54 / 200.0f) * 0.08f; + } + Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.status[player->actor.objBankIndex].segment); + gSPDisplayList(OVERLAY_DISP++, gameplay_keep_DL_04F250); + + CLOSE_DISPS(play->state.gfxCtx); + } + } +} + +s32 D_801C0958 = false; + +Gfx** D_801C095C[] = { + gPlayerLeftHandClosedDLs, + gPlayerLeftHandOpenDLs, +}; +Gfx** D_801C0964[] = { + gPlayerRightHandClosedDLs, + gPlayerRightHandOpenDLs, +}; + +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_Atan2S_XY(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_Atan2S_XY(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 +1809,239 @@ #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") +u8 D_801C096C[PLAYER_SHIELD_MAX] = { + COLTYPE_METAL, + COLTYPE_METAL, + COLTYPE_METAL, +}; + +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); + } +} + +Vec3f D_801C0970[] = { + { 0.0f, 400.0f, 0.0f }, + { 0.0f, 1400.0f, -1000.0f }, + { 0.0f, -400.0f, 1000.0f }, +}; + +Vec3f D_801C0994[] = { + { 5000.0f, 400.0f, 0.0f }, + { 5000.0f, -400.0f, 1000.0f }, + { 5000.0f, 1400.0f, -1000.0f }, +}; + +Vec3f D_801C09B8[] = { + { 0.0f, 750.0f, 750.0f }, + { 1500.0f, 1500.0f, 1500.0f }, + { -2500.0f, -2000.0f, -3000.0f }, +}; + +Vec3f D_801C09DC[] = { + { 900.0f, 300.0f, 100.0f }, + { 1300.0f, 700.0f, -300.0f }, + { 500.0f, -100.0f, 500.0f }, +}; + +Vec3f D_801C0A00[] = { + { -2500.0f, 1400.0f, 1100.0f }, + { -2900.0f, 1000.0f, 1500.0f }, + { -2100.0f, 1800.0f, 700.0f }, +}; + +Vec3f D_801C0A24[] = { + { 0.0f, 0.0f, 0.0f }, + { -800.0f, 800.0f, 800.0f }, + { -800.0f, -800.0f, -800.0f }, +}; + +Vec3f D_801C0A48[] = { + { 2000.0f, 0.0f, 0.0f }, + { 2800.0f, -800.0f, -800.0f }, + { 2800.0f, 800.0f, 800.0f }, +}; + +Vec3f D_801C0A6C[] = { + { -400.0f, 800.0f, 0.0f }, + { -5000.0f, -500.0f, -4000.0f }, + { -5000.0f, 8000.0f, 4000.0f }, +}; + +Vec3f D_801C0A90[] = { + { -400.0f, 1800.0f, 0.0f }, + { 5000.0f, 8000.0f, 4000.0f }, + { 5000.0f, -500.0f, -4000.0f }, +}; + +Gfx* D_801C0AB4[] = { + object_link_zora_DL_00CC38, + object_link_zora_DL_00CDA0, +}; + +Gfx* D_801C0ABC[] = { + object_link_zora_DL_010868, + object_link_zora_DL_010978, +}; + +Vec3f D_801C0AC4[] = { + { 5400.0f, 1700.0f, 1800.0f }, + { 5400.0f, 1700.0f, -1800.0f }, +}; + +Vec3f D_801C0ADC[] = { + { 5250.0f, 570.0f, 2400.0f }, + { 5250.0f, 570.0f, -2400.0f }, +}; + +struct_80124618* D_801C0AF4[] = { + D_801C0678, + D_801C0698, +}; + +struct_80124618* D_801C0AFC[] = { + D_801C06B8, + D_801C06E0, +}; + +struct_80124618* D_801C0B04[] = { + D_801C06F8, + D_801C0718, +}; + +struct_80124618* D_801C0B0C[] = { + D_801C0730, + D_801C0740, +}; + +Gfx* D_801C0B14[] = { + object_link_nuts_DL_008760, + object_link_nuts_DL_008660, +}; + +u8 D_801C0B1C[] = { + 0x0C, + 0x0F, +}; + +Gfx* D_801C0B20[] = { + object_mask_truth_DL_0001A0, + object_mask_kerfay_DL_000D40, + object_mask_yofukasi_DL_000490, + object_mask_rabit_DL_000610, + object_mask_ki_tan_DL_0004A0, + object_mask_json_DL_0004C0, + object_mask_romerny_DL_0007A0, + object_mask_zacho_DL_000700, + object_mask_posthat_DL_000290, + object_mask_meoto_DL_0005A0, + object_mask_bigelf_DL_0016F0, + object_mask_gibudo_DL_000250, + gDonGeroMaskDL, + object_mask_dancer_DL_000EF0, + object_mask_skj_DL_0009F0, + object_mask_stone_DL_000820, + object_mask_bree_DL_0003C0, + object_mask_bakuretu_DL_0005C0, + object_mask_bu_san_DL_000710, + object_mask_kyojin_DL_000380, + gameplay_keep_DL_00B260, + gameplay_keep_DL_005A10, + gameplay_keep_DL_005360, + gDekuMaskDL, + object_mask_boy_DL_000900, + object_mask_goron_DL_0014A0, + object_mask_zora_DL_000DB0, + object_mask_nuts_DL_001D90, +}; + +Vec3f D_801C0B90[] = { + { 950.0f, -800.0f, 300.0f }, + { 950.0f, -800.0f, -300.0f }, +}; #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] = VIRTUAL_TO_PHYSICAL(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[PLAYER_BODYPART_LEFT_HAND].x; + refPos.y = player->bodyPartsPos[PLAYER_BODYPART_LEFT_HAND].y - 6.0f; + refPos.z = player->bodyPartsPos[PLAYER_BODYPART_LEFT_HAND].z; + } + } else { + refPos.y = player->actor.world.pos.y + 28.0f; + } + } else { + Math_Vec3f_Copy(&refPos, &D_801F59E8); + } + + drawIdPlusOne = ABS_ALT(player->getItemDrawId); + Player_DrawGetItemImpl(play, player, &refPos, drawIdPlusOne); + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80126AB4.s") @@ -176,27 +2051,302 @@ #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); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127594.s") + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801278F8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127A60.s") +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] = VIRTUAL_TO_PHYSICAL(player->maskObjectSegment); + AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_meoto_Matanimheader_001CD8)); +} + +void Player_DrawCircusLeadersMask(PlayState* play, Actor* actor) { + static Vec3f bubbleVelocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f bubbleAccel = { 0.0f, 0.0f, 0.0f }; + Gfx* gfx; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + gfx = POLY_XLU_DISP; + + for (i = 0; i < ARRAY_COUNT(D_801C0B90); i++) { + f32 scaleY = (D_801F59C8[i] / 400.0f) * 0.1f; + + Matrix_MultVec3f(&D_801C0B90[i], &D_801F59B0[i]); + + //! FAKE + if (1) {} + + D_801F59B0[i].y += -10.0f * scaleY; + + if (D_801F59C8[i] < 0x190) { + f32 scaleXZ = CLAMP_MAX(scaleY, 0.05f); + + Matrix_Push(); + Matrix_Translate(D_801F59B0[i].x, D_801F59B0[i].y, D_801F59B0[i].z, MTXMODE_NEW); + Matrix_Scale(scaleXZ, scaleY, scaleXZ, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(&gfx[1], 0x08, VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(gEffBubble1Tex))); + gDPSetPrimColor(&gfx[2], 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(&gfx[3], 150, 150, 150, 0); + gSPDisplayList(&gfx[4], gEffBubbleDL); + gSPPopMatrix(&gfx[5], G_MTX_MODELVIEW); + + Matrix_Pop(); + + gfx = &gfx[6]; + } else { + Player* player = (Player*)actor; + f32 temp_f0 = sqrtf(SQ(player->actor.velocity.x) + SQ(player->actor.velocity.z)); + s16 phi_s0 = temp_f0 * 2000.0f; + f32 temp_f20; + + bubbleVelocity.y = temp_f0 * 0.4f; + bubbleAccel.y = -0.3f; + + if (phi_s0 > 0x3E80) { + phi_s0 = 0x3E80; + } + + phi_s0 = player->actor.focus.rot.y + ((i != 0) ? phi_s0 : -phi_s0); + temp_f20 = temp_f0 * 0.2f; + + if (temp_f20 > 4.0f) { + temp_f20 = 4.0f; + } + + bubbleVelocity.x = -Math_SinS(phi_s0) * temp_f20; + bubbleVelocity.z = -Math_CosS(phi_s0) * temp_f20; + + EffectSsDtBubble_SpawnColorProfile(play, &D_801F59B0[i], &bubbleVelocity, &bubbleAccel, 20, 20, 3, 0); + D_801F59C8[i] -= 0x190; + } + } + + POLY_XLU_DISP = gfx; + + CLOSE_DISPS(play->state.gfxCtx); +} + +void Player_DrawBlastMask(PlayState* play, Player* player) { + static Gfx D_801C0BC0[] = { + gsDPSetEnvColor(0, 0, 0, 255), + gsSPEndDisplayList(), + }; + static Gfx D_801C0BD0[] = { + gsDPSetRenderMode(AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)), + gsSPEndDisplayList(), + }; + + OPEN_DISPS(play->state.gfxCtx); + + if (player->unk_B60 != 0) { + s32 alpha; + + gSegments[0xA] = VIRTUAL_TO_PHYSICAL(player->maskObjectSegment); + + AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_bakuretu_Matanimheader_0011F8)); + + if (player->unk_B60 < 11) { + alpha = (player->unk_B60 / 10.0f) * 255; + } else { + alpha = 255; + } + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, (u8)alpha); + gSPDisplayList(POLY_OPA_DISP++, object_mask_bakuretu_DL_000440); + gSPSegment(POLY_OPA_DISP++, 0x09, D_801C0BD0); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, (u8)(255 - alpha)); + } else { + gSPSegment(POLY_OPA_DISP++, 0x09, D_801C0BC0); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +Vec3f D_801C0BE0 = { 0.0f, 0.3f, 0.0f }; +Vec3f D_801C0BEC = { 0.0f, -0.025f, 0.0f }; +Color_RGBA8 D_801C0BF8 = { 250, 100, 100, 0 }; +Color_RGBA8 D_801C0BFC = { 0, 0, 100, 0 }; + +Vec3f D_801C0C00 = { 0.0f, 20.0f, 0.0f }; + +Vec3f D_801C0C0C[] = { + { 174.0f, -1269.0f, -1.0f }, + { 401.0f, -729.0f, -701.0f }, + { 401.0f, -729.0f, 699.0f }, +}; + +Vec3f D_801C0C30[] = { + { 74.0f, -1269.0f, -1.0f }, + { 301.0f, -729.0f, -701.0f }, + { 301.0f, -729.0f, 699.0f }, +}; + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ f32 unk_14; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; +} struct_80128388_arg1; // size = 0x1C + +struct_80128388_arg1 D_801C0C54[] = { + { 0.0f, 0x0000, 0x8000, { 0.0f, 0.0f, 0.0f }, 0.0f, 0x0000, 0x0000 }, + { 16.8f, 0x0000, 0x0000, { 0.0f, 0.0f, 0.0f }, 20.0f, 0x1388, 0x1388 }, + { 30.0f, 0x0000, 0x0000, { 0.0f, 0.0f, 0.0f }, 20.0f, 0x1F40, 0x2EE0 }, +}; + +Color_RGB8 D_801C0CA8[] = { + { 255, 255, 255 }, { 80, 80, 255 }, { 136, 192, 255 }, { 136, 192, 255 }, { 184, 232, 232 }, { 248, 200, 0 }, + { 255, 180, 0 }, { 0, 128, 0 }, { 252, 238, 0 }, { 131, 0, 174 }, { 64, 64, 32 }, { 0, 0, 255 }, + { 255, 0, 255 }, { 255, 0, 255 }, { 255, 0, 0 }, { 0, 0, 255 }, { 0, 200, 0 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 80, 80, 255 }, +}; + +Vec3f D_801C0CE8[PLAYER_FORM_MAX] = { + { 0.0f, 0.0f, 0.0f }, { 300.0f, 300.0f, -230.0f }, { 0.0f, 90.0f, -50.0f }, + { 0.0f, 20.0f, -60.0f }, { 0.0f, 0.0f, 0.0f }, +}; +Vec3f D_801C0D24[PLAYER_FORM_MAX] = { + { 200.0f, 300.0f, 0.0f }, { 200.0f, 200.0f, 0.0f }, { 200.0f, 300.0f, 0.0f }, + { 200.0f, 150.0f, 0.0f }, { 200.0f, 200.0f, 0.0f }, +}; +Vec3f D_801C0D60 = { 398.0f, 1419.0f, 244.0f }; +Vec3f D_801C0D6C = { 420.0f, 1210.0f, 380.0f }; + +f32 D_801C0D78[] = { + 0.0f, // Player is not holding a melee weapon + 3000.0f, // PLAYER_IA_SWORD_KOKIRI + 3000.0f, // PLAYER_IA_SWORD_RAZOR + 4000.0f, // PLAYER_IA_SWORD_GILDED + 5500.0f, // PLAYER_IA_SWORD_GREAT_FAIRY + -1.0f, // PLAYER_IA_STICK + 2500.0f, // PLAYER_IA_ZORA_FINS +}; + +Gfx* D_801C0D94 = object_link_child_DL_017818; + +f32 D_801C0D98 = -35.0f; + +f32 D_801C0D9C = -395.0f; +f32 D_801C0DA0 = 0.0f; + +f32 D_801C0DA4 = 0.0f; + +Vec3f D_801C0DA8[4] = { + { -4500.0f, -3000.0f, -600.0f }, + { 1500.0f, -3000.0f, -600.0f }, + { -4500.0f, 3000.0f, -600.0f }, + { 1500.0f, 3000.0f, -600.0f }, +}; + +Vec3f D_801C0DD8 = { 50.0f, 800.0f, 0.0f }; +Vec3f D_801C0DE4 = { 50.0f, 850.0f, 0.0f }; +Gfx* D_801C0DF0[] = { + object_link_goron_DL_010590, object_link_goron_DL_010368, object_link_goron_DL_010140, + object_link_goron_DL_00FF18, object_link_goron_DL_00FCF0, +}; + +Vec2f D_801C0E04[PLAYER_FORM_MAX] = { + { 140.0f, -130.0f }, { 0.0f, -200.0f }, { -160.0f, 0.0f }, { 220.0f, -200.0f }, { 0.0f, 0.0f }, +}; + +Gfx* D_801C0E2C[] = { + object_link_nuts_DL_007A28, object_link_nuts_DL_0077D0, object_link_nuts_DL_007548, + object_link_nuts_DL_007900, object_link_nuts_DL_0076A0, +}; +Vec3f D_801C0E40[PLAYER_FORM_MAX] = { + { 0.0f, 0.0f, 0.0f }, { -578.3f, -1100.9f, 0.0f }, { -189.5f, -594.87f, 0.0f }, + { -570.0f, -812.0f, 0.0f }, { -230.0f, -520.0f, 0.0f }, +}; +Vec3f D_801C0E7C = { 1100.0f, -700.0f, 0.0f }; + +// unused +Vec3f D_801C0E88 = { 1600.0f, -1700.0f, -70.0f }; + +Vec3f D_801C0E94 = { 1800.0f, -300.0f, 0.0f }; +Vec3f D_801C0EA0 = { 1300.0f, -400.0f, 0.0f }; +Vec3f D_801C0EAC = { 630.0f, 100.0f, -30.0f }; +Vec3s D_801C0EB8 = { 0, 0, 0x7FFF }; + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/Player_DrawBunnyHood.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127B64.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127BE8.s") +void func_80127DA4(PlayState* play, struct_801F58B0 arg1[], struct_80128388_arg1 arg2[], s32 arg3, Vec3f* arg4, + Vec3f* arg5, u32* arg6); #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80127DA4.s") +void func_80128388(struct_801F58B0 arg0[], struct_80128388_arg1 arg1[], s32 arg2, Mtx** arg3); #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80128388.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_801284A0.s") +void Player_DrawGreatFairysMask(PlayState* play, Player* player) { + s32 pad; + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, 6 * sizeof(Mtx)); + Vec3f sp84; + Vec3f sp78; + Vec3f* iter = D_801C0C0C; + Vec3f* iter2 = D_801C0C30; + u32 sp6C = play->gameplayFrames; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x0B, mtx); + + Matrix_MultVec3f(&D_801C0C00, &D_801C0C54[1].unk_08); + Math_Vec3f_Lerp(&player->bodyPartsPos[7], &player->bodyPartsPos[0], 0.2f, &D_801C0C54[2].unk_08); + + for (i = 0; i < ARRAY_COUNT(D_801C0C0C); i++) { + Matrix_MultVec3f(iter, &sp84); + Matrix_MultVec3f(iter2, &sp78); + + func_80127DA4(play, D_801F58B0[i], D_801C0C54, 3, &sp84, &sp78, &sp6C); + sp6C += 11; + + Matrix_Push(); + Matrix_Translate(iter->x, iter->y, iter->z, MTXMODE_APPLY); + func_80128388(D_801F58B0[i], D_801C0C54, 3, &mtx); + Matrix_Pop(); + iter++; + iter2++; + } + + CLOSE_DISPS(play->state.gfxCtx); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_player_lib/func_80128640.s") diff --git a/src/code/z_prenmi.c b/src/code/z_prenmi.c index 0e9c435c6..e0381153a 100644 --- a/src/code/z_prenmi.c +++ b/src/code/z_prenmi.c @@ -1,23 +1,22 @@ -#include "global.h" +#include "z_prenmi.h" -void PreNMI_Stop(PreNMIContext* prenmiCtx) { - prenmiCtx->state.running = 0; - prenmiCtx->state.nextGameStateInit = NULL; - prenmiCtx->state.nextGameStateSize = 0; +void PreNMI_Stop(PreNMIState* this) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, NULL, 0); } -void PreNMI_Update(PreNMIContext* prenmiCtx) { - if (prenmiCtx->timer == 0) { +void PreNMI_Update(PreNMIState* this) { + if (this->timer == 0) { ViConfig_UpdateVi(1); - PreNMI_Stop(prenmiCtx); + PreNMI_Stop(this); return; } - prenmiCtx->timer--; + this->timer--; } -void PreNMI_Draw(PreNMIContext* prenmiCtx) { - GraphicsContext* gfxCtx = prenmiCtx->state.gfxCtx; +void PreNMI_Draw(PreNMIState* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; func_8012CF0C(gfxCtx, true, true, 0, 0, 0); @@ -26,26 +25,30 @@ void PreNMI_Draw(PreNMIContext* prenmiCtx) { func_8012C470(gfxCtx); gDPSetFillColor(POLY_OPA_DISP++, (GPACK_RGBA5551(255, 255, 255, 1) << 16) | GPACK_RGBA5551(255, 255, 255, 1)); - gDPFillRectangle(POLY_OPA_DISP++, 0, prenmiCtx->timer + 100, SCREEN_WIDTH - 1, prenmiCtx->timer + 100); + gDPFillRectangle(POLY_OPA_DISP++, 0, this->timer + 100, SCREEN_WIDTH - 1, this->timer + 100); CLOSE_DISPS(gfxCtx); } -void PreNMI_Main(PreNMIContext* prenmiCtx) { - PreNMI_Update(prenmiCtx); - PreNMI_Draw(prenmiCtx); +void PreNMI_Main(GameState* thisx) { + PreNMIState* this = (PreNMIState*)thisx; - prenmiCtx->state.unk_A3 = 1; + PreNMI_Update(this); + PreNMI_Draw(this); + + this->state.unk_A3 = 1; } -void PreNMI_Destroy(PreNMIContext* prenmiCtx) { +void PreNMI_Destroy(GameState* thisx) { } -void PreNMI_Init(PreNMIContext* prenmiCtx) { - prenmiCtx->state.main = (GameStateFunc)PreNMI_Main; - prenmiCtx->state.destroy = (GameStateFunc)PreNMI_Destroy; - prenmiCtx->timer = 30; - prenmiCtx->unkA8 = 10; +void PreNMI_Init(GameState* thisx) { + PreNMIState* this = (PreNMIState*)thisx; - Game_SetFramerateDivisor(&prenmiCtx->state, 1); + this->state.main = PreNMI_Main; + this->state.destroy = PreNMI_Destroy; + this->timer = 30; + this->unkA8 = 10; + + Game_SetFramerateDivisor(&this->state, 1); } diff --git a/src/code/z_quake.c b/src/code/z_quake.c index d57dc8e54..b57012ce1 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -1,7 +1,47 @@ #include "global.h" +#include "z64quake.h" +#include "z64view.h" + +typedef struct { + /* 0x00 */ s16 randIndex; + /* 0x02 */ s16 countdownMax; + /* 0x04 */ Camera* camera; + /* 0x08 */ u32 type; + /* 0x0C */ s16 verticalMag; + /* 0x0E */ s16 horizontalMag; + /* 0x10 */ s16 zoom; + /* 0x12 */ s16 rollOffset; + /* 0x14 */ Vec3s shakePlaneOffset; // angle deviations from shaking in the perpendicular plane + /* 0x1A */ s16 speed; + /* 0x1C */ s16 isShakePerpendicular; + /* 0x1E */ s16 countdown; + /* 0x20 */ s16 camId; +} QuakeRequest; // size = 0x24 + +typedef struct { + /* 0x0 */ PlayState* play; + /* 0x4 */ s32 type; // bitfield, highest set bit determines type + /* 0x8 */ s16 countdown; + /* 0xA */ s16 state; +} DistortionRequest; // size = 0xC + +typedef struct { + /* 0x00 */ Vec3f atOffset; + /* 0x0C */ Vec3f eyeOffset; + /* 0x18 */ s16 rollOffset; + /* 0x1A */ s16 zoom; +} ShakeInfo; // size = 0x1C + +typedef s16 (*QuakeCallbackFunc)(QuakeRequest*, ShakeInfo*); + +typedef enum { + /* 0 */ DISTORTION_INACTIVE, + /* 1 */ DISTORTION_ACTIVE, + /* 2 */ DISTORTION_SETUP +} DistortionState; QuakeRequest sQuakeRequest[4]; -DistortionContext sDistortionContext; +DistortionRequest sDistortionRequest; static s16 sIsQuakeInitialized = true; static s16 sQuakeRequestCount = 0; @@ -51,7 +91,7 @@ void Quake_UpdateShakeInfo(QuakeRequest* req, ShakeInfo* shake, f32 verticalPert shake->zoom = req->zoom * verticalPertubation; } -s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType1(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown); @@ -61,7 +101,7 @@ s16 Quake_Callback1(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType5(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown); @@ -71,7 +111,7 @@ s16 Quake_Callback5(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType6(QuakeRequest* req, ShakeInfo* shake) { f32 perpendicularPertubation; req->countdown--; @@ -80,7 +120,7 @@ s16 Quake_Callback6(QuakeRequest* req, ShakeInfo* shake) { return 1; } -s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType3(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Math_SinS(req->speed * req->countdown) * ((f32)req->countdown / (f32)req->countdownMax); @@ -91,7 +131,7 @@ s16 Quake_Callback3(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType2(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Quake_Random(); @@ -101,7 +141,7 @@ s16 Quake_Callback2(QuakeRequest* req, ShakeInfo* shake) { return req->countdown; } -s16 Quake_Callback4(QuakeRequest* req, ShakeInfo* shake) { +s16 Quake_CallbackType4(QuakeRequest* req, ShakeInfo* shake) { if (req->countdown > 0) { f32 perpendicularPertubation = Quake_Random() * ((f32)req->countdown / (f32)req->countdownMax); @@ -117,7 +157,7 @@ s16 Quake_GetFreeIndex(void) { s32 min = 0x10000; for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - if (sQuakeRequest[i].callbackIdx == 0) { + if (sQuakeRequest[i].type == 0) { ret = i; break; } @@ -131,43 +171,43 @@ s16 Quake_GetFreeIndex(void) { return ret; } -QuakeRequest* Quake_AddImpl(Camera* camera, u32 callbackIdx) { - s16 idx = Quake_GetFreeIndex(); - QuakeRequest* req = &sQuakeRequest[idx]; +QuakeRequest* Quake_AddImpl(Camera* camera, u32 type) { + s16 index = Quake_GetFreeIndex(); + QuakeRequest* req = &sQuakeRequest[index]; __osMemset(req, 0, sizeof(QuakeRequest)); req->camera = camera; req->camId = camera->camId; - req->callbackIdx = callbackIdx; + req->type = type; req->isShakePerpendicular = true; - req->randIdx = ((s16)(Rand_ZeroOne() * (f32)0x10000) & ~3) + idx; + req->randIndex = ((s16)(Rand_ZeroOne() * 0x10000) & ~3) + index; sQuakeRequestCount++; return req; } -void Quake_Remove(QuakeRequest* req) { - req->callbackIdx = 0; +void Quake_RemoveRequest(QuakeRequest* req) { + req->type = 0; req->countdown = -1; sQuakeRequestCount--; } -QuakeRequest* Quake_GetRequest(s16 idx) { - QuakeRequest* req = &sQuakeRequest[idx & 3]; +QuakeRequest* Quake_GetRequest(s16 quakeIndex) { + QuakeRequest* req = &sQuakeRequest[quakeIndex & 3]; - if (req->callbackIdx == 0) { + if (req->type == 0) { return NULL; } - if (idx != req->randIdx) { + if (quakeIndex != req->randIndex) { return NULL; } return req; } -u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetValue(s16 quakeIndex, s16 valueType, s16 value) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req == NULL) { return false; @@ -176,62 +216,75 @@ u32 Quake_SetValue(s16 idx, s16 valueType, s16 value) { case QUAKE_SPEED: req->speed = value; break; + case QUAKE_VERTICAL_MAG: req->verticalMag = value; break; + case QUAKE_HORIZONTAL_MAG: req->horizontalMag = value; break; + case QUAKE_ZOOM: req->zoom = value; break; + case QUAKE_ROLL_OFFSET: req->rollOffset = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_X: req->shakePlaneOffset.x = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_Y: req->shakePlaneOffset.y = value; break; + case QUAKE_SHAKE_PLANE_OFFSET_Z: req->shakePlaneOffset.z = value; break; + case QUAKE_COUNTDOWN: req->countdown = value; req->countdownMax = req->countdown; break; + case QUAKE_IS_SHAKE_PERPENDICULAR: req->isShakePerpendicular = value; break; + + default: + break; } + return true; } } -u32 Quake_SetSpeed(s16 idx, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetSpeed(s16 quakeIndex, s16 speed) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { - req->speed = value; + req->speed = speed; return true; } return false; } -u32 Quake_SetCountdown(s16 idx, s16 value) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetCountdown(s16 quakeIndex, s16 countdown) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { - req->countdown = value; + req->countdown = countdown; req->countdownMax = req->countdown; return true; } return false; } -s16 Quake_GetCountdown(s16 idx) { - QuakeRequest* req = Quake_GetRequest(idx); +s16 Quake_GetCountdown(s16 quakeIndex) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { return req->countdown; @@ -239,8 +292,8 @@ s16 Quake_GetCountdown(s16 idx) { return 0; } -u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetQuakeValues(s16 quakeIndex, s16 verticalMag, s16 horizontalMag, s16 zoom, s16 rollOffset) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { req->verticalMag = verticalMag; @@ -252,8 +305,8 @@ u32 Quake_SetQuakeValues(s16 idx, s16 verticalMag, s16 horizontalMag, s16 zoom, return false; } -u32 Quake_SetQuakeValues2(s16 idx, s16 isShakePerpendicular, Vec3s shakePlaneOffset) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_SetQuakeValues2(s16 quakeIndex, s16 isShakePerpendicular, Vec3s shakePlaneOffset) { + QuakeRequest* req = Quake_GetRequest(quakeIndex); if (req != NULL) { req->isShakePerpendicular = isShakePerpendicular; @@ -267,29 +320,35 @@ void Quake_Init(void) { s16 i; for (i = 0; i < ARRAY_COUNT(sQuakeRequest); i++) { - sQuakeRequest[i].callbackIdx = 0; + sQuakeRequest[i].type = 0; sQuakeRequest[i].countdown = 0; } sIsQuakeInitialized = true; sQuakeRequestCount = 0; } -s16 Quake_Add(Camera* camera, u32 callbackIdx) { - return Quake_AddImpl(camera, callbackIdx)->randIdx; +s16 Quake_Add(Camera* camera, u32 type) { + return Quake_AddImpl(camera, type)->randIndex; } -u32 Quake_RemoveFromIdx(s16 idx) { - QuakeRequest* req = Quake_GetRequest(idx); +u32 Quake_Remove(s16 index) { + QuakeRequest* req = Quake_GetRequest(index); if (req != NULL) { - Quake_Remove(req); + Quake_RemoveRequest(req); return true; } return false; } static QuakeCallbackFunc sQuakeCallbacks[] = { - NULL, Quake_Callback1, Quake_Callback2, Quake_Callback3, Quake_Callback4, Quake_Callback5, Quake_Callback6, + NULL, + Quake_CallbackType1, + Quake_CallbackType2, + Quake_CallbackType3, + Quake_CallbackType4, + Quake_CallbackType5, + Quake_CallbackType6, }; s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { @@ -299,11 +358,11 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { f32 absSpeedDiv; f32 maxCurr; f32 maxNext; - s32 idx; + s32 index; s32 ret; u32 eq; Vec3f originVec; - GlobalContext* globalCtx = camera->globalCtx; + PlayState* play = camera->play; originVec.x = 0.0f; originVec.y = 0.0f; @@ -323,16 +382,16 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { } ret = 0; - for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) { - req = &sQuakeRequest[idx]; - if (req->callbackIdx != 0) { - if (globalCtx->cameraPtrs[req->camId] == NULL) { - Quake_Remove(req); + for (index = 0; index < ARRAY_COUNT(sQuakeRequest); index++) { + req = &sQuakeRequest[index]; + if (req->type != 0) { + if (play->cameraPtrs[req->camId] == NULL) { + Quake_RemoveRequest(req); } else { eq = (camera->camId != req->camera->camId); absSpeedDiv = ABS(req->speed) / (f32)0x8000; - if (sQuakeCallbacks[req->callbackIdx](req, &shake) == 0) { - Quake_Remove(req); + if (sQuakeCallbacks[req->type](req, &shake) == 0) { + Quake_RemoveRequest(req); } else if (eq == 0) { if (fabsf(camData->atOffset.x) < fabsf(shake.atOffset.x)) { camData->atOffset.x = shake.atOffset.x; @@ -382,36 +441,36 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { return ret; } -void Distortion_Init(GlobalContext* globalCtx) { - sDistortionContext.globalCtx = globalCtx; - View_ClearDistortion(&globalCtx->view); - sDistortionContext.type = 0; - sDistortionContext.countdown = 0; - sDistortionContext.state = DISTORTION_INACTIVE; +void Distortion_Init(PlayState* play) { + sDistortionRequest.play = play; + View_ClearDistortion(&play->view); + sDistortionRequest.type = 0; + sDistortionRequest.countdown = 0; + sDistortionRequest.state = DISTORTION_INACTIVE; } void Distortion_SetCountdown(s16 countdown) { - sDistortionContext.countdown = countdown; - sDistortionContext.state = DISTORTION_SETUP; + sDistortionRequest.countdown = countdown; + sDistortionRequest.state = DISTORTION_SETUP; } s16 Distortion_GetCountdown(void) { - return sDistortionContext.countdown; + return sDistortionRequest.countdown; } s16 Distortion_GetType(void) { - return sDistortionContext.type; + return sDistortionRequest.type; } void Distortion_SetType(s32 type) { - if (sDistortionContext.type < type) { - sDistortionContext.type = type; + if (sDistortionRequest.type < type) { + sDistortionRequest.type = type; } } void Distortion_ClearType(s32 type) { - if (sDistortionContext.type == type) { - sDistortionContext.type = 0; + if (sDistortionRequest.type == type) { + sDistortionRequest.type = 0; } } @@ -419,9 +478,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, - player->actor.floorBgId) == CONVEYOR_WATER) { - return SurfaceType_GetConveyorSpeed(&sDistortionContext.globalCtx->colCtx, player->actor.floorPoly, + if (!SurfaceType_IsFloorConveyor(&sDistortionRequest.play->colCtx, player->actor.floorPoly, + player->actor.floorBgId)) { + return SurfaceType_GetConveyorSpeed(&sDistortionRequest.play->colCtx, player->actor.floorPoly, player->actor.floorBgId); } return 0; @@ -446,14 +505,14 @@ void Distortion_Update(void) { f32 zScale; f32 speed; Player* player; - GlobalContext* globalCtx = sDistortionContext.globalCtx; + PlayState* play = sDistortionRequest.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) { - if (sDistortionContext.type & 0x800) { - sDistortionContext.countdown = 2; + if (sDistortionRequest.type != 0) { + if (sDistortionRequest.type & DISTORTION_TYPE_B) { + sDistortionRequest.countdown = 2; depthPhase = 0x3F0; screenPlanePhase = 0x156; @@ -469,11 +528,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.6f; - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / 60.0f; + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / 60.0f; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x400) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_A) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x3F0; screenPlanePhase = 0x156; } @@ -490,11 +549,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.4f; - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; speedScaleFactor = 0.5f; - } else if (sDistortionContext.type & 0x200) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_9) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x1FC; screenPlanePhase = 0x156; } @@ -511,11 +570,11 @@ void Distortion_Update(void) { zScale = 0.0f; speed = 0.1f; - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x100) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_8) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x2710; screenPlanePhase = 0x3E8; } @@ -532,15 +591,15 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.5f; - if (sDistortionContext.countdown < 5) { - xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionContext.countdown) / (f32)countdownMax; + if (sDistortionRequest.countdown < 5) { + xyScaleFactor = zScaleFactor = ((f32)countdownMax - sDistortionRequest.countdown) / (f32)countdownMax; } else { xyScaleFactor = zScaleFactor = 0.0f; } speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x80) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_7) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x4B0; screenPlanePhase = 0x7D0; } @@ -557,11 +616,11 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.5f; - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / (f32)countdownMax; + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x40) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_6) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x9C4; screenPlanePhase = 0xBB8; } @@ -578,15 +637,15 @@ void Distortion_Update(void) { zScale = 0.01f; speed = 1.3f; - if (sDistortionContext.countdown < 4) { - xyScaleFactor = zScaleFactor = sDistortionContext.countdown / (f32)countdownMax; + if (sDistortionRequest.countdown < 4) { + xyScaleFactor = zScaleFactor = sDistortionRequest.countdown / (f32)countdownMax; } else { xyScaleFactor = zScaleFactor = 0.0f; } speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x20) { - sDistortionContext.countdown = 2; - if (sDistortionContext.state == DISTORTION_SETUP) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_5) { + sDistortionRequest.countdown = 2; + if (sDistortionRequest.state == DISTORTION_SETUP) { depthPhase = 0x9C4; screenPlanePhase = 0xBB8; } @@ -609,9 +668,9 @@ void Distortion_Update(void) { zScaleFactor = 1.0f; xyScaleFactor = 1.0f; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 0x10) { - if (sDistortionContext.state == DISTORTION_SETUP) { - countdownMax = sDistortionContext.countdown; + } else if (sDistortionRequest.type & DISTORTION_TYPE_4) { + if (sDistortionRequest.state == DISTORTION_SETUP) { + countdownMax = sDistortionRequest.countdown; depthPhase = 0x760; screenPlanePhase = 0x1BC; } @@ -628,15 +687,15 @@ void Distortion_Update(void) { zScale = 0.2f; speed = 0.25f; - countdownRatio = sDistortionContext.countdown / (f32)countdownMax; + countdownRatio = sDistortionRequest.countdown / (f32)countdownMax; zScaleFactor = xyScaleFactor = countdownRatio; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 8) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_3) { depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; - player = GET_PLAYER(globalCtx); + sDistortionRequest.countdown = 2; + player = GET_PLAYER(play); if (player != NULL) { Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor); @@ -656,18 +715,21 @@ void Distortion_Update(void) { zScale = 0.03f; speed = 0.33f; break; + case 2: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; speed = 0.33f; break; + case 1: xScale = -0.06f; yScale = 0.1f; zScale = 0.03f; speed = 0.33f; break; + default: xScale = -0.06f; yScale = 0.1f; @@ -676,19 +738,19 @@ void Distortion_Update(void) { break; } - if (player->unk_B88 < 0) { - xyScaleFactor = (player->unk_B88 - (f32)0x4000) / (f32)0xC000; + if (player->unk_B86[1] < 0) { + xyScaleFactor = (player->unk_B86[1] - (f32)0x4000) / (f32)0xC000; } else { - xyScaleFactor = (player->unk_B88 + (f32)0x4000) / (f32)0xC000; + xyScaleFactor = (player->unk_B86[1] + (f32)0x4000) / (f32)0xC000; } zScaleFactor = -xyScaleFactor; speedScaleFactor = 1.0f; - } else if (sDistortionContext.type & 4) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_2) { depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; - player = GET_PLAYER(globalCtx); + sDistortionRequest.countdown = 2; + player = GET_PLAYER(play); depthPhaseStep = 359.2f; screenPlanePhaseStep = -18.5f; @@ -703,18 +765,21 @@ void Distortion_Update(void) { zScale = 0.08f; speed = 0.18f; break; + case 2: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; speed = 0.12f; break; + case 1: xScale = 0.12f; yScale = 0.12f; zScale = 0.08f; speed = 0.08f; break; + default: xScale = 0.12f; yScale = 0.12f; @@ -731,12 +796,12 @@ void Distortion_Update(void) { xyScaleFactor = speedScaleFactor = (waterYScaleFactor * 0.15f) + 0.35f + (speedRatio * 0.4f); zScaleFactor = 0.9f - xyScaleFactor; - } else if (sDistortionContext.type & 1) { + } else if (sDistortionRequest.type & DISTORTION_TYPE_0) { // Gives a small mirage-like appearance depthPhase = 0x3F0; screenPlanePhase = 0x156; - sDistortionContext.countdown = 2; + sDistortionRequest.countdown = 2; depthPhaseStep = 0.0f; screenPlanePhaseStep = 150.0f; @@ -756,32 +821,32 @@ 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, - 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_SetDistortionOrientation(&sDistortionRequest.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(&sDistortionRequest.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(&sDistortionRequest.play->view, speed * speedScaleFactor); - sDistortionContext.state = DISTORTION_ACTIVE; + sDistortionRequest.state = DISTORTION_ACTIVE; - } else if (sDistortionContext.state != DISTORTION_INACTIVE) { - View_ClearDistortion(&globalCtx->view); + } else if (sDistortionRequest.state != DISTORTION_INACTIVE) { + View_ClearDistortion(&play->view); - sDistortionContext.state = DISTORTION_INACTIVE; - sDistortionContext.countdown = 0; + sDistortionRequest.state = DISTORTION_INACTIVE; + sDistortionRequest.countdown = 0; } - if (sDistortionContext.countdown != 0) { - sDistortionContext.countdown--; - if (sDistortionContext.countdown == 0) { - sDistortionContext.type = 0; + if (sDistortionRequest.countdown != 0) { + sDistortionRequest.countdown--; + if (sDistortionRequest.countdown == 0) { + sDistortionRequest.type = 0; } } } @@ -790,16 +855,16 @@ s32 Quake_NumActiveQuakes(void) { QuakeRequest* req = sQuakeRequest; s32 numActiveQuakes = 0; - if (req[0].callbackIdx != 0) { + if (req[0].type != 0) { numActiveQuakes++; } - if (req[1].callbackIdx != 0) { + if (req[1].type != 0) { numActiveQuakes++; } - if (req[2].callbackIdx != 0) { + if (req[2].type != 0) { numActiveQuakes++; } - if (req[3].callbackIdx != 0) { + if (req[3].type != 0) { numActiveQuakes++; } diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index f4ffd43c1..39f09f1d4 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1,4 +1,5 @@ #include "global.h" +#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" Gfx sSetupDL[438] = { /* 0x00 */ @@ -896,8 +897,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) { @@ -1107,13 +1108,13 @@ void func_8012CA38(GraphicsContext* gfxCtx) { } Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); + Gfx* gfx = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); - gDPTileSync(displayList); - gDPSetTileSize(displayList + 1, 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); - gSPEndDisplayList(displayList + 2); + gDPTileSync(&gfx[0]); + gDPSetTileSize(&gfx[1], 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); + gSPEndDisplayList(&gfx[2]); - return displayList; + return gfx; } void func_8012CB04(Gfx** gfxp, u32 x, u32 y) { @@ -1125,101 +1126,71 @@ Gfx* func_8012CB28(GraphicsContext* gfxCtx, u32 x, u32 y) { } Gfx* Gfx_TexScroll(GraphicsContext* gfxCtx, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList; - - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 4; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 3 * sizeof(Gfx)); x %= 2048; y %= 2048; - gDPTileSync(displayList); - gDPSetTileSize(displayList + 1, 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); - gSPEndDisplayList(displayList + 2); + gDPTileSync(&gfx[0]); + gDPSetTileSize(&gfx[1], 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); + gSPEndDisplayList(&gfx[2]); - return displayList; + return gfx; } Gfx* Gfx_TwoTexScroll(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2) { - Gfx* displayList; - - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 6; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 5 * sizeof(Gfx)); x1 %= 2048; y1 %= 2048; x2 %= 2048; y2 %= 2048; - gDPTileSync(displayList); - gDPSetTileSize(displayList + 1, tile1, x1, y1, (x1 + ((width1 - 1) << 2)), (y1 + ((height1 - 1) << 2))); - gDPTileSync(displayList + 2); - gDPSetTileSize(displayList + 3, tile2, x2, y2, (x2 + ((width2 - 1) << 2)), (y2 + ((height2 - 1) << 2))); - gSPEndDisplayList(displayList + 4); + gDPTileSync(&gfx[0]); + gDPSetTileSize(&gfx[1], tile1, x1, y1, (x1 + ((width1 - 1) << 2)), (y1 + ((height1 - 1) << 2))); + gDPTileSync(&gfx[2]); + gDPSetTileSize(&gfx[3], tile2, x2, y2, (x2 + ((width2 - 1) << 2)), (y2 + ((height2 - 1) << 2))); + gSPEndDisplayList(&gfx[4]); - return displayList; + return gfx; } Gfx* Gfx_TwoTexScrollEnvColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList; - - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 6; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 6 * sizeof(Gfx)); x1 %= 2048; y1 %= 2048; x2 %= 2048; y2 %= 2048; - gDPTileSync(displayList); - gDPSetTileSize(displayList + 1, tile1, x1, y1, (x1 + ((width1 - 1) << 2)), (y1 + ((height1 - 1) << 2))); - gDPTileSync(displayList + 2); - gDPSetTileSize(displayList + 3, tile2, x2, y2, (x2 + ((width2 - 1) << 2)), (y2 + ((height2 - 1) << 2))); - gDPSetEnvColor(displayList + 4, r, g, b, a); - gSPEndDisplayList(displayList + 5); + gDPTileSync(&gfx[0]); + gDPSetTileSize(&gfx[1], tile1, x1, y1, (x1 + ((width1 - 1) << 2)), (y1 + ((height1 - 1) << 2))); + gDPTileSync(&gfx[2]); + gDPSetTileSize(&gfx[3], tile2, x2, y2, (x2 + ((width2 - 1) << 2)), (y2 + ((height2 - 1) << 2))); + gDPSetEnvColor(&gfx[4], r, g, b, a); + gSPEndDisplayList(&gfx[5]); - return displayList; + return gfx; } Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList; + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 2; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + gDPSetEnvColor(&gfx[0], r, g, b, a); + gSPEndDisplayList(&gfx[1]); - gDPSetEnvColor(displayList, r, g, b, a); - gSPEndDisplayList(displayList + 1); - - return displayList; + return gfx; } Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList; + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 2; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + gDPSetPrimColor(&gfx[0], 0, lodfrac, r, g, b, a); + gSPEndDisplayList(&gfx[1]); - gDPSetPrimColor(displayList, 0, lodfrac, r, g, b, a); - gSPEndDisplayList(displayList + 1); - - return displayList; + return gfx; } void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b) { @@ -1239,11 +1210,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 +1238,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 +1246,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g masterGfx = gGfxMasterDL->clearFrameBuffer; - gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, &D_0F000000); + gDPSetColorImage(&masterGfx[0], G_IM_FMT_RGBA, G_IM_SIZ_16b, D_801FBBCC, D_0F000000); gDPSetCycleType(&masterGfx[1], G_CYC_FILL); gDPSetRenderMode(&masterGfx[2], G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(&masterGfx[3], (GPACK_RGBA5551(r, g, b, 1) << 16) | GPACK_RGBA5551(r, g, b, 1)); @@ -1328,7 +1299,7 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g } void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b) { - if ((R_PAUSE_MENU_MODE < 2) && (D_801F6D10 < 2)) { + if ((R_PAUSE_BG_PRERENDER_STATE <= PAUSE_BG_PRERENDER_SETUP) && (D_801F6D10 < 2)) { func_8012CF0C(gfxCtx, true, true, r, g, b); } else { func_8012CF0C(gfxCtx, false, false, r, g, b); diff --git a/src/code/z_room.c b/src/code/z_room.c index 7579c6200..eb615c409 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,21 +51,21 @@ 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; + roomCtx->curRoom.num = -1; + roomCtx->curRoom.segment = NULL; roomCtx->unk78 = 1; roomCtx->unk79 = 0; for (i = 0; i < 3; i++) { @@ -75,23 +75,22 @@ 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; - roomCtx->prevRoom = roomCtx->currRoom; - roomCtx->currRoom.num = index; - roomCtx->currRoom.segment = NULL; + roomCtx->prevRoom = roomCtx->curRoom; + roomCtx->curRoom.num = index; + roomCtx->curRoom.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,26 +99,25 @@ 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; - roomCtx->currRoom.segment = roomCtx->activeRoomVram; + roomCtx->curRoom.segment = roomCtx->activeRoomVram; // TODO: Segment number enum - gSegments[0x03] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram); + gSegments[0x03] = VIRTUAL_TO_PHYSICAL(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->curRoom.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->sceneId != SCENE_IKANA) || (roomCtx->curRoom.num != 1)) && (play->sceneId != 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 +127,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); + gSegments[0x03] = VIRTUAL_TO_PHYSICAL(room->segment); + 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->curRoom.num > -1) { + Map_InitRoomData(play, roomCtx->curRoom.num); + Minimap_SavePlayerRoomInitInfo(play); } - func_801A3CD8(globalCtx->roomCtx.currRoom.echo); + func_801A3CD8(play->roomCtx.curRoom.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 b9dbb35dd..b70dfb1f5 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->sceneId == SCENE_CLOCKTOWER || play->sceneId == SCENE_TOWN || play->sceneId == SCENE_BACKTOWN || + play->sceneId == SCENE_ICHIBA) { spaceSize = OBJECT_SPACE_SIZE_CLOCK_TOWN; - } else if (globalCtx->sceneNum == SCENE_MILK_BAR) { + } else if (play->sceneId == SCENE_MILK_BAR) { spaceSize = OBJECT_SPACE_SIZE_MILK_BAR; - } else if (globalCtx->sceneNum == SCENE_00KEIKOKU) { + } else if (play->sceneId == SCENE_00KEIKOKU) { spaceSize = OBJECT_SPACE_SIZE_TERMINA_FIELD; } else { spaceSize = OBJECT_SPACE_SIZE_DEFAULT; @@ -52,7 +52,7 @@ void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) { objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, GAMEPLAY_KEEP); - gSegments[0x04] = PHYSICAL_TO_VIRTUAL(objectCtx->status[objectCtx->mainKeepIndex].segment); + gSegments[0x04] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment); } void Object_UpdateBank(ObjectContext* objectCtx) { @@ -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) { @@ -108,29 +108,29 @@ s32 Object_IsLoaded(ObjectContext* objectCtx, s32 index) { void Object_LoadAll(ObjectContext* objectCtx) { s32 i; s32 id; - u32 vromSize; + uintptr_t vromSize; 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); } } void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { u32 addr; - u32 vromSize; + uintptr_t vromSize; RomFile* fileTableEntry; 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,45 +141,46 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) { } // SceneTableEntry Header Command 0x00: Spawn List -void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) { s32 loadedCount; s16 playerObjectId; 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 ((PLAYER_GET_INITMODE(play->linkActorEntry) == PLAYER_INITMODE_TELESCOPE) || + ((gSaveContext.respawnFlag == 0x02) && + (gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams == PLAYER_PARAMS(0xFF, PLAYER_INITMODE_TELESCOPE)))) { // 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 = globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment; - globalCtx->objectCtx.num = loadedCount; - globalCtx->objectCtx.spawnedObjectCount = loadedCount; - playerObjectId = gLinkFormObjectIndexes[(void)0, gSaveContext.save.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[GET_PLAYER_FORM]; 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; @@ -192,63 +193,65 @@ 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) { - static RomFile tatlMessageFiles[2] = { +void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) { + // @note These quest hint files are identical to OoT's. + // They are not relevant in this game and the system to process these scripts has been removed. + static RomFile naviQuestHintFiles[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] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); } - if (cmd->specialFiles.cUpElfMsgNum != 0) { - globalCtx->unk_18868 = Play_LoadScene(globalCtx, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]); + if (cmd->specialFiles.naviQuestHintFileId != NAVI_QUEST_HINTS_NONE) { + play->naviQuestHints = Play_LoadScene(play, &naviQuestHintFiles[cmd->specialFiles.naviQuestHintFileId - 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.curRoom.unk3 = cmd->roomBehavior.gpFlag1; + play->roomCtx.curRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF; + play->roomCtx.curRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1; + play->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; + play->roomCtx.curRoom.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.curRoom.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; @@ -260,21 +263,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; } @@ -286,7 +289,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; @@ -297,30 +300,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. @@ -329,16 +332,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. */ -void 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) }, @@ -350,194 +353,194 @@ void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) { { SEGMENT_ROM_START(scene_texture_07), SEGMENT_ROM_END(scene_texture_07) }, { SEGMENT_ROM_START(scene_texture_08), SEGMENT_ROM_END(scene_texture_08) }, }; - u32 vromStart = sceneTextureFiles[fileIndex].vromStart; + uintptr_t vromStart = sceneTextureFiles[fileIndex].vromStart; size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart; if (size != 0) { - globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size); - DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size); + play->roomCtx.unk74 = THA_AllocEndAlign16(&play->state.heap, size); + DmaMgr_SendRequest0(play->roomCtx.unk74, vromStart, size); } } // 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) { - if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) { - gSaveContext.environmentTime = gSaveContext.save.time = - (u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f); +void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) { + if ((cmd->timeSettings.hour != 0xFF) && (cmd->timeSettings.min != 0xFF)) { + gSaveContext.skyboxTime = gSaveContext.save.time = + CLOCK_TIME_ALT2_F(cmd->timeSettings.hour, cmd->timeSettings.min); } - if (cmd->timeSettings.unk6 != 0xFF) { - globalCtx->envCtx.timeIncrement = cmd->timeSettings.unk6; + if (cmd->timeSettings.timeSpeed != 0xFF) { + play->envCtx.sceneTimeSpeed = cmd->timeSettings.timeSpeed; } else { - globalCtx->envCtx.timeIncrement = 0; + play->envCtx.sceneTimeSpeed = 0; } - if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) { - globalCtx->envCtx.timeIncrement = 5; + // Increase time speed during first cycle + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (play->envCtx.sceneTimeSpeed != 0)) { + play->envCtx.sceneTimeSpeed = 5; } if (gSaveContext.sunsSongState == SUNSSONG_INACTIVE) { - REG(15) = globalCtx->envCtx.timeIncrement; + R_TIME_SPEED = play->envCtx.sceneTimeSpeed; } - globalCtx->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; - globalCtx->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f; - globalCtx->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f; + play->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; + play->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; + play->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.save.time) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f; - if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) { - gSaveContext.environmentTime = gSaveContext.save.time; + if ((play->envCtx.sceneTimeSpeed == 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->sequenceCtx.seqId = cmd->soundSettings.seqId; + play->sequenceCtx.ambienceId = cmd->soundSettings.ambienceId; - if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { - audio_setBGM(cmd->soundSettings.bgmId); + if (gSaveContext.seqId == (u8)NA_BGM_DISABLED || + Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == NA_BGM_FINAL_HOURS) { + Audio_SetSpec(cmd->soundSettings.specId); } } // 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.curRoom.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.sceneLayer != 0) { altHeaderList = Lib_SegmentedToVirtual(cmd->altHeaders.segment); - altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1]; + altHeader = altHeaderList[gSaveContext.sceneLayer - 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->cutsceneList.sceneCsCount; + play->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->cutsceneList.segment); } // 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) { +// SceneTableEntry Header Command 0x19: Sets Region Visited Flag +void Scene_HeaderCmdSetRegionVisitedFlag(PlayState* play, SceneCmd* cmd) { s16 j = 0; s16 i = 0; while (true) { - if (gScenesPerRegion[i][j] == 0xFFFF) { + if (gSceneIdsPerRegion[i][j] == 0xFFFF) { i++; j = 0; - if (i == ARRAY_COUNT(gScenesPerRegion)) { + if (i == REGION_MAX) { break; } } - if (globalCtx->sceneNum == gScenesPerRegion[i][j]) { + if (play->sceneId == gSceneIdsPerRegion[i][j]) { break; } j++; } - if (i < ARRAY_COUNT(gScenesPerRegion)) { - gSaveContext.save.mapsVisited = (gBitFlags[i] | gSaveContext.save.mapsVisited) | gSaveContext.save.mapsVisited; + if (i < REGION_MAX) { + gSaveContext.save.regionsVisited = + (gBitFlags[i] | gSaveContext.save.regionsVisited) | gSaveContext.save.regionsVisited; } } // 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, @@ -563,7 +566,7 @@ s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) { Scene_HeaderCmdEchoSetting, Scene_HeaderCmdCutsceneList, Scene_HeaderCmdAltHeaderList, - Scene_HeaderCmdSetAreaVisitedFlag, + Scene_HeaderCmdSetRegionVisitedFlag, Scene_HeaderCmdAnimatedMaterials, Scene_HeaderCmdActorCutsceneList, Scene_HeaderCmdMiniMap, @@ -580,7 +583,7 @@ s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) { } if (cmdId < SCENE_CMD_MAX) { - sceneCmdHandlers[cmdId](globalCtx, header); + sceneCmdHandlers[cmdId](play, header); } header++; @@ -590,15 +593,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 layer. */ -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 8f369008f..67f503e58 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,39 +106,39 @@ 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* gfx = GRAPH_ALLOC(play->state.gfxCtx, 3 * sizeof(Gfx)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); // clang-format off - if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, colorDList); } - if (sMatAnimFlags & 2) { gSPSegment(POLY_XLU_DISP++, segment, colorDList); } + if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, gfx); } + if (sMatAnimFlags & 2) { gSPSegment(POLY_XLU_DISP++, segment, gfx); } // clang-format on - gDPSetPrimColor(colorDList++, 0, primColorResult->lodFrac, primColorResult->r, primColorResult->g, - primColorResult->b, (u8)(primColorResult->a * sMatAnimAlphaRatio)); + gDPSetPrimColor(gfx++, 0, primColorResult->lodFrac, primColorResult->r, primColorResult->g, primColorResult->b, + (u8)(primColorResult->a * sMatAnimAlphaRatio)); if (envColor != NULL) { - gDPSetEnvColor(colorDList++, envColor->r, envColor->g, envColor->b, envColor->a); + gDPSetEnvColor(gfx++, envColor->r, envColor->g, envColor->b, envColor->a); } - gSPEndDisplayList(colorDList++); + gSPEndDisplayList(gfx++); - 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); } /** @@ -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* matAnim, u32 step) { + AnimatedMat_DrawMain(play, matAnim, 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,90 +702,88 @@ 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(), }; s32 lodFrac; s32 i; - Gfx* dListHead; - Gfx* dList; + Gfx* gfx; + Gfx* gfxHead; - 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); + gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 18 * sizeof(Gfx)); - 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) { + for (gfx = gfxHead, i = 0; i < 9; i++, gfx += 2) { lodFrac = 0; - bcopy(greatBayTempleColorSetDL, dListHead, sizeof(greatBayTempleColorSetDL)); + bcopy(greatBayTempleColorSetDL, gfx, sizeof(greatBayTempleColorSetDL)); 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; } - gDPSetPrimColor(dListHead, 0, lodFrac, 255, 255, 255, 255); + gDPSetPrimColor(gfx, 0, lodFrac, 255, 255, 255, 255); } - gSPSegment(POLY_OPA_DISP++, 0x06, dList); - gSPSegment(POLY_XLU_DISP++, 0x06, dList); + gSPSegment(POLY_OPA_DISP++, 0x06, gfxHead); + gSPSegment(POLY_XLU_DISP++, 0x06, gfxHead); - 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..ed4549966 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -7,131 +7,131 @@ { { 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[] = { - { 0x12, 0x00, 0x4102 }, + { SCENE_SONCHONOIE, 0, 0x4102 }, }; static EntranceTableEntry sMayorsResidenceEntrance1[] = { - { 0x12, 0x01, 0x4102 }, + { SCENE_SONCHONOIE, 1, 0x4102 }, }; static EntranceTableEntry sMayorsResidenceEntrance2[] = { - { 0x12, 0x02, 0x4102 }, + { SCENE_SONCHONOIE, 2, 0x4102 }, }; static EntranceTableEntry* sMayorsResidenceEntranceTable[] = { @@ -141,7 +141,7 @@ static EntranceTableEntry* sMayorsResidenceEntranceTable[] = { }; static EntranceTableEntry sMajorasLairEntrance0[] = { - { 0xF5, 0x00, 0x0387 }, + { -SCENE_LAST_BS, 0, 0x0387 }, }; static EntranceTableEntry* sMajorasLairEntranceTable[] = { @@ -149,7 +149,7 @@ static EntranceTableEntry* sMajorasLairEntranceTable[] = { }; static EntranceTableEntry sMagicHagsPotionShopEntrance0[] = { - { 0x0A, 0x00, 0x4102 }, + { SCENE_WITCH_SHOP, 0, 0x4102 }, }; static EntranceTableEntry* sMagicHagsPotionShopEntranceTable[] = { @@ -157,11 +157,11 @@ static EntranceTableEntry* sMagicHagsPotionShopEntranceTable[] = { }; static EntranceTableEntry sRanchHouseEntrance0[] = { - { 0x10, 0x00, 0x0102 }, + { SCENE_OMOYA, 0, 0x0102 }, }; static EntranceTableEntry sRanchHouseEntrance1[] = { - { 0x10, 0x01, 0x4102 }, + { SCENE_OMOYA, 1, 0x4102 }, }; static EntranceTableEntry* sRanchHouseEntranceTable[] = { @@ -170,7 +170,7 @@ static EntranceTableEntry* sRanchHouseEntranceTable[] = { }; static EntranceTableEntry sHoneyAndDarlingsShopEntrance0[] = { - { 0x11, 0x00, 0x4102 }, + { SCENE_BOWLING, 0, 0x4102 }, }; static EntranceTableEntry* sHoneyAndDarlingsShopEntranceTable[] = { @@ -178,11 +178,11 @@ static EntranceTableEntry* sHoneyAndDarlingsShopEntranceTable[] = { }; static EntranceTableEntry sBeneathTheGraveryardEntrance0[] = { - { 0xF4, 0x00, 0x4102 }, + { -SCENE_HAKASHITA, 0, 0x4102 }, }; static EntranceTableEntry sBeneathTheGraveryardEntrance1[] = { - { 0xF4, 0x01, 0x4102 }, + { -SCENE_HAKASHITA, 1, 0x4102 }, }; static EntranceTableEntry* sBeneathTheGraveryardEntranceTable[] = { @@ -191,47 +191,47 @@ static EntranceTableEntry* sBeneathTheGraveryardEntranceTable[] = { }; static EntranceTableEntry sSouthernSwampClearedEntrance0[] = { - { 0x00, 0x00, 0xCA14 }, + { SCENE_20SICHITAI2, 0, 0xCA14 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance1[] = { - { 0x00, 0x01, 0x4102 }, + { SCENE_20SICHITAI2, 1, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance2[] = { - { 0x00, 0x02, 0xC102 }, + { SCENE_20SICHITAI2, 2, 0xC102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance3[] = { - { 0x00, 0x03, 0x4102 }, + { SCENE_20SICHITAI2, 3, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance4[] = { - { 0x00, 0x04, 0x4102 }, + { SCENE_20SICHITAI2, 4, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance5[] = { - { 0x00, 0x05, 0x4102 }, + { SCENE_20SICHITAI2, 5, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance6[] = { - { 0x00, 0x06, 0x0102 }, + { SCENE_20SICHITAI2, 6, 0x0102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance7[] = { - { 0x00, 0x07, 0x4102 }, + { SCENE_20SICHITAI2, 7, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance8[] = { - { 0x00, 0x08, 0x4102 }, + { SCENE_20SICHITAI2, 8, 0x4102 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance9[] = { - { 0x00, 0x09, 0x4A14 }, + { SCENE_20SICHITAI2, 9, 0x4A14 }, }; static EntranceTableEntry sSouthernSwampClearedEntrance10[] = { - { 0x00, 0x0A, 0x4A14 }, + { SCENE_20SICHITAI2, 10, 0x4A14 }, }; static EntranceTableEntry* sSouthernSwampClearedEntranceTable[] = { @@ -242,19 +242,19 @@ static EntranceTableEntry* sSouthernSwampClearedEntranceTable[] = { }; static EntranceTableEntry sCuriosityShopEntrance0[] = { - { 0x0D, 0x00, 0x4102 }, + { SCENE_AYASHIISHOP, 0, 0x4102 }, }; static EntranceTableEntry sCuriosityShopEntrance1[] = { - { 0x0D, 0x01, 0x0102 }, + { SCENE_AYASHIISHOP, 1, 0x0102 }, }; static EntranceTableEntry sCuriosityShopEntrance2[] = { - { 0x0D, 0x02, 0x8A95 }, + { SCENE_AYASHIISHOP, 2, 0x8A95 }, }; static EntranceTableEntry sCuriosityShopEntrance3[] = { - { 0x0D, 0x03, 0x8102 }, + { SCENE_AYASHIISHOP, 3, 0x8102 }, }; static EntranceTableEntry* sCuriosityShopEntranceTable[] = { @@ -265,113 +265,113 @@ static EntranceTableEntry* sCuriosityShopEntranceTable[] = { }; static EntranceTableEntry sIkanaCanyonEntrance0[] = { - { 0x13, 0x00, 0xCA14 }, { 0x13, 0x00, 0x8A14 }, { 0x13, 0x00, 0x0A14 }, - { 0x13, 0x00, 0x4A14 }, { 0x13, 0x00, 0x8102 }, + { SCENE_IKANA, 0, 0xCA14 }, { SCENE_IKANA, 0, 0x8A14 }, { SCENE_IKANA, 0, 0x0A14 }, + { SCENE_IKANA, 0, 0x4A14 }, { SCENE_IKANA, 0, 0x8102 }, }; static EntranceTableEntry sIkanaCanyonEntrance1[] = { - { 0x13, 0x01, 0x4102 }, - { 0x13, 0x01, 0x4102 }, - { 0x13, 0x01, 0xCA14 }, - { 0x13, 0x01, 0x4102 }, + { SCENE_IKANA, 1, 0x4102 }, + { SCENE_IKANA, 1, 0x4102 }, + { SCENE_IKANA, 1, 0xCA14 }, + { SCENE_IKANA, 1, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance2[] = { - { 0x13, 0x02, 0x4102 }, - { 0x13, 0x02, 0x4102 }, - { 0x13, 0x02, 0x4102 }, - { 0x13, 0x02, 0x4102 }, + { SCENE_IKANA, 2, 0x4102 }, + { SCENE_IKANA, 2, 0x4102 }, + { SCENE_IKANA, 2, 0x4102 }, + { SCENE_IKANA, 2, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance3[] = { - { 0x13, 0x03, 0x4102 }, - { 0x13, 0x03, 0x4102 }, - { 0x13, 0x03, 0x4102 }, - { 0x13, 0x03, 0x4102 }, + { SCENE_IKANA, 3, 0x4102 }, + { SCENE_IKANA, 3, 0x4102 }, + { SCENE_IKANA, 3, 0x4102 }, + { SCENE_IKANA, 3, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance4[] = { - { 0x13, 0x04, 0x4A14 }, - { 0x13, 0x04, 0x4A14 }, - { 0x13, 0x04, 0x4A14 }, - { 0x13, 0x04, 0x4A14 }, + { SCENE_IKANA, 4, 0x4A14 }, + { SCENE_IKANA, 4, 0x4A14 }, + { SCENE_IKANA, 4, 0x4A14 }, + { SCENE_IKANA, 4, 0x4A14 }, }; static EntranceTableEntry sIkanaCanyonEntrance5[] = { - { 0x13, 0x05, 0x4102 }, - { 0x13, 0x05, 0x4102 }, - { 0x13, 0x05, 0x4102 }, - { 0x13, 0x05, 0x4102 }, + { SCENE_IKANA, 5, 0x4102 }, + { SCENE_IKANA, 5, 0x4102 }, + { SCENE_IKANA, 5, 0x4102 }, + { SCENE_IKANA, 5, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance6[] = { - { 0x13, 0x06, 0x4102 }, - { 0x13, 0x06, 0x4102 }, - { 0x13, 0x06, 0x4102 }, - { 0x13, 0x06, 0x4102 }, + { SCENE_IKANA, 6, 0x4102 }, + { SCENE_IKANA, 6, 0x4102 }, + { SCENE_IKANA, 6, 0x4102 }, + { SCENE_IKANA, 6, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance7[] = { - { 0x13, 0x07, 0x4A14 }, - { 0x13, 0x07, 0x4A14 }, - { 0x13, 0x07, 0x4A14 }, - { 0x13, 0x07, 0x4A14 }, + { SCENE_IKANA, 7, 0x4A14 }, + { SCENE_IKANA, 7, 0x4A14 }, + { SCENE_IKANA, 7, 0x4A14 }, + { SCENE_IKANA, 7, 0x4A14 }, }; static EntranceTableEntry sIkanaCanyonEntrance8[] = { - { 0x13, 0x08, 0x4102 }, - { 0x13, 0x08, 0x4102 }, - { 0x13, 0x08, 0x4102 }, - { 0x13, 0x08, 0x4102 }, + { SCENE_IKANA, 8, 0x4102 }, + { SCENE_IKANA, 8, 0x4102 }, + { SCENE_IKANA, 8, 0x4102 }, + { SCENE_IKANA, 8, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance9[] = { - { 0x13, 0x09, 0x4A14 }, - { 0x13, 0x09, 0x4A14 }, - { 0x13, 0x09, 0x4A14 }, - { 0x13, 0x09, 0x4A14 }, + { SCENE_IKANA, 9, 0x4A14 }, + { SCENE_IKANA, 9, 0x4A14 }, + { SCENE_IKANA, 9, 0x4A14 }, + { SCENE_IKANA, 9, 0x4A14 }, }; static EntranceTableEntry sIkanaCanyonEntrance10[] = { - { 0x13, 0x0A, 0x4A14 }, - { 0x13, 0x0A, 0x4A14 }, - { 0x13, 0x0A, 0x4A14 }, - { 0x13, 0x0A, 0x4A14 }, + { SCENE_IKANA, 10, 0x4A14 }, + { SCENE_IKANA, 10, 0x4A14 }, + { SCENE_IKANA, 10, 0x4A14 }, + { SCENE_IKANA, 10, 0x4A14 }, }; static EntranceTableEntry sIkanaCanyonEntrance11[] = { - { 0x13, 0x0B, 0x4102 }, - { 0x13, 0x0B, 0x4102 }, - { 0x13, 0x0B, 0x4102 }, - { 0x13, 0x0B, 0x4102 }, + { SCENE_IKANA, 11, 0x4102 }, + { SCENE_IKANA, 11, 0x4102 }, + { SCENE_IKANA, 11, 0x4102 }, + { SCENE_IKANA, 11, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance12[] = { - { 0x13, 0x0C, 0x4102 }, - { 0x13, 0x0C, 0x4102 }, - { 0x13, 0x0C, 0x4102 }, - { 0x13, 0x0C, 0x4102 }, + { SCENE_IKANA, 12, 0x4102 }, + { SCENE_IKANA, 12, 0x4102 }, + { SCENE_IKANA, 12, 0x4102 }, + { SCENE_IKANA, 12, 0x4102 }, }; static EntranceTableEntry sIkanaCanyonEntrance13[] = { - { 0x13, 0x0D, 0x8102 }, - { 0x13, 0x0D, 0x8102 }, - { 0x13, 0x0D, 0x8102 }, - { 0x13, 0x0D, 0x8102 }, + { SCENE_IKANA, 13, 0x8102 }, + { SCENE_IKANA, 13, 0x8102 }, + { SCENE_IKANA, 13, 0x8102 }, + { SCENE_IKANA, 13, 0x8102 }, }; static EntranceTableEntry sIkanaCanyonEntrance14[] = { - { 0x13, 0x0E, 0x8102 }, - { 0x13, 0x0E, 0x8102 }, - { 0x13, 0x0E, 0x8102 }, - { 0x13, 0x0E, 0x8102 }, + { SCENE_IKANA, 14, 0x8102 }, + { SCENE_IKANA, 14, 0x8102 }, + { SCENE_IKANA, 14, 0x8102 }, + { SCENE_IKANA, 14, 0x8102 }, }; static EntranceTableEntry sIkanaCanyonEntrance15[] = { - { 0x13, 0x0F, 0x8102 }, - { 0x13, 0x0F, 0x8102 }, - { 0x13, 0x0F, 0x8102 }, - { 0x13, 0x0F, 0x0183 }, + { SCENE_IKANA, 15, 0x8102 }, + { SCENE_IKANA, 15, 0x8102 }, + { SCENE_IKANA, 15, 0x8102 }, + { SCENE_IKANA, 15, 0x0183 }, }; static EntranceTableEntry* sIkanaCanyonEntranceTable[] = { @@ -382,66 +382,66 @@ static EntranceTableEntry* sIkanaCanyonEntranceTable[] = { }; static EntranceTableEntry sPiratesFortressEntrance0[] = { - { 0x14, 0x00, 0x8102 }, - { 0x14, 0x00, 0x8102 }, - { 0x14, 0x00, 0x8102 }, + { SCENE_KAIZOKU, 0, 0x8102 }, + { SCENE_KAIZOKU, 0, 0x8102 }, + { SCENE_KAIZOKU, 0, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance1[] = { - { 0x14, 0x01, 0x8102 }, - { 0x14, 0x01, 0x8102 }, + { SCENE_KAIZOKU, 1, 0x8102 }, + { SCENE_KAIZOKU, 1, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance2[] = { - { 0x14, 0x02, 0x8102 }, + { SCENE_KAIZOKU, 2, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance3[] = { - { 0x14, 0x03, 0x8102 }, + { SCENE_KAIZOKU, 3, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance4[] = { - { 0x14, 0x04, 0x8102 }, + { SCENE_KAIZOKU, 4, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance5[] = { - { 0x14, 0x05, 0x8102 }, + { SCENE_KAIZOKU, 5, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance6[] = { - { 0x14, 0x06, 0x8102 }, + { SCENE_KAIZOKU, 6, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance7[] = { - { 0x14, 0x07, 0x8102 }, + { SCENE_KAIZOKU, 7, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance8[] = { - { 0x14, 0x08, 0x8102 }, + { SCENE_KAIZOKU, 8, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance9[] = { - { 0x14, 0x09, 0x8102 }, + { SCENE_KAIZOKU, 9, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance10[] = { - { 0x14, 0x0A, 0x8A95 }, + { SCENE_KAIZOKU, 10, 0x8A95 }, }; static EntranceTableEntry sPiratesFortressEntrance11[] = { - { 0x14, 0x0B, 0x8102 }, + { SCENE_KAIZOKU, 11, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance12[] = { - { 0x14, 0x0C, 0x8102 }, + { SCENE_KAIZOKU, 12, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance13[] = { - { 0x14, 0x0D, 0x8102 }, + { SCENE_KAIZOKU, 13, 0x8102 }, }; static EntranceTableEntry sPiratesFortressEntrance14[] = { - { 0x14, 0x0E, 0x8102 }, + { SCENE_KAIZOKU, 14, 0x8102 }, }; static EntranceTableEntry* sPiratesFortressEntranceTable[] = { @@ -452,8 +452,8 @@ static EntranceTableEntry* sPiratesFortressEntranceTable[] = { }; static EntranceTableEntry sMilkBarEntrance0[] = { - { 0x15, 0x00, 0x4102 }, { 0x15, 0x00, 0x8102 }, { 0x15, 0x00, 0x8102 }, - { 0x15, 0x00, 0x8102 }, { 0x15, 0x00, 0x8102 }, + { SCENE_MILK_BAR, 0, 0x4102 }, { SCENE_MILK_BAR, 0, 0x8102 }, { SCENE_MILK_BAR, 0, 0x8102 }, + { SCENE_MILK_BAR, 0, 0x8102 }, { SCENE_MILK_BAR, 0, 0x8102 }, }; static EntranceTableEntry* sMilkBarEntranceTable[] = { @@ -461,11 +461,11 @@ static EntranceTableEntry* sMilkBarEntranceTable[] = { }; static EntranceTableEntry sStoneTowerTempleEntrance0[] = { - { 0xEA, 0x00, 0xC102 }, + { -SCENE_INISIE_N, 0, 0xC102 }, }; static EntranceTableEntry sStoneTowerTempleEntrance1[] = { - { 0xEA, 0x01, 0x4102 }, + { -SCENE_INISIE_N, 1, 0x4102 }, }; static EntranceTableEntry* sStoneTowerTempleEntranceTable[] = { @@ -474,11 +474,11 @@ static EntranceTableEntry* sStoneTowerTempleEntranceTable[] = { }; static EntranceTableEntry sTreasureChestShopEntrance0[] = { - { 0x17, 0x00, 0x4102 }, + { SCENE_TAKARAYA, 0, 0x4102 }, }; static EntranceTableEntry sTreasureChestShopEntrance1[] = { - { 0x17, 0x01, 0x0102 }, + { SCENE_TAKARAYA, 1, 0x0102 }, }; static EntranceTableEntry* sTreasureChestShopEntranceTable[] = { @@ -486,41 +486,41 @@ static EntranceTableEntry* sTreasureChestShopEntranceTable[] = { sTreasureChestShopEntrance1, }; -static EntranceTableEntry sStoneTowerTempleReversedEntrance0[] = { - { 0xE8, 0x00, 0xC102 }, +static EntranceTableEntry sStoneTowerTempleInvertedEntrance0[] = { + { -SCENE_INISIE_R, 0, 0xC102 }, }; -static EntranceTableEntry sStoneTowerTempleReversedEntrance1[] = { - { 0xE8, 0x01, 0x8102 }, +static EntranceTableEntry sStoneTowerTempleInvertedEntrance1[] = { + { -SCENE_INISIE_R, 1, 0x8102 }, }; -static EntranceTableEntry sStoneTowerTempleReversedEntrance2[] = { - { 0xE8, 0x02, 0x8102 }, +static EntranceTableEntry sStoneTowerTempleInvertedEntrance2[] = { + { -SCENE_INISIE_R, 2, 0x8102 }, }; -static EntranceTableEntry* sStoneTowerTempleReversedEntranceTable[] = { - sStoneTowerTempleReversedEntrance0, - sStoneTowerTempleReversedEntrance1, - sStoneTowerTempleReversedEntrance2, +static EntranceTableEntry* sStoneTowerTempleInvertedEntranceTable[] = { + sStoneTowerTempleInvertedEntrance0, + sStoneTowerTempleInvertedEntrance1, + sStoneTowerTempleInvertedEntrance2, }; static EntranceTableEntry sClockTowerRooftopEntrance0[] = { - { 0xE7, 0x00, 0x0102 }, - { 0xE7, 0x00, 0x8102 }, - { 0xE7, 0x00, 0x0102 }, - { 0xE7, 0x00, 0x0102 }, + { -SCENE_OKUJOU, 0, 0x0102 }, + { -SCENE_OKUJOU, 0, 0x8102 }, + { -SCENE_OKUJOU, 0, 0x0102 }, + { -SCENE_OKUJOU, 0, 0x0102 }, }; static EntranceTableEntry sClockTowerRooftopEntrance1[] = { - { 0xE7, 0x01, 0x0102 }, - { 0xE7, 0x01, 0x0102 }, - { 0xE7, 0x01, 0x0102 }, + { -SCENE_OKUJOU, 1, 0x0102 }, + { -SCENE_OKUJOU, 1, 0x0102 }, + { -SCENE_OKUJOU, 1, 0x0102 }, }; static EntranceTableEntry sClockTowerRooftopEntrance2[] = { - { 0xE7, 0x02, 0x858B }, - { 0xE7, 0x02, 0x858B }, - { 0xE7, 0x02, 0x8102 }, + { -SCENE_OKUJOU, 2, 0x858B }, + { -SCENE_OKUJOU, 2, 0x858B }, + { -SCENE_OKUJOU, 2, 0x8102 }, }; static EntranceTableEntry* sClockTowerRooftopEntranceTable[] = { @@ -530,24 +530,24 @@ static EntranceTableEntry* sClockTowerRooftopEntranceTable[] = { }; static EntranceTableEntry sOpeningDungeonEntrance0[] = { - { 0xE6, 0x00, 0x0102 }, - { 0xE6, 0x00, 0x8102 }, + { -SCENE_OPENINGDAN, 0, 0x0102 }, + { -SCENE_OPENINGDAN, 0, 0x8102 }, }; static EntranceTableEntry sOpeningDungeonEntrance1[] = { - { 0xE6, 0x01, 0x0102 }, + { -SCENE_OPENINGDAN, 1, 0x0102 }, }; static EntranceTableEntry sOpeningDungeonEntrance2[] = { - { 0xE6, 0x02, 0x0102 }, + { -SCENE_OPENINGDAN, 2, 0x0102 }, }; static EntranceTableEntry sOpeningDungeonEntrance3[] = { - { 0xE6, 0x03, 0x0102 }, + { -SCENE_OPENINGDAN, 3, 0x0102 }, }; static EntranceTableEntry sOpeningDungeonEntrance4[] = { - { 0xE6, 0x04, 0x058B }, + { -SCENE_OPENINGDAN, 4, 0x058B }, }; static EntranceTableEntry* sOpeningDungeonEntranceTable[] = { @@ -556,15 +556,15 @@ static EntranceTableEntry* sOpeningDungeonEntranceTable[] = { }; static EntranceTableEntry sWoodfallTempleEntrance0[] = { - { 0xE5, 0x00, 0x4102 }, + { -SCENE_MITURIN, 0, 0x4102 }, }; static EntranceTableEntry sWoodfallTempleEntrance1[] = { - { 0xE5, 0x01, 0x0102 }, + { -SCENE_MITURIN, 1, 0x0102 }, }; static EntranceTableEntry sWoodfallTempleEntrance2[] = { - { 0xE5, 0x02, 0x0102 }, + { -SCENE_MITURIN, 2, 0x0102 }, }; static EntranceTableEntry* sWoodfallTempleEntranceTable[] = { @@ -574,13 +574,13 @@ static EntranceTableEntry* sWoodfallTempleEntranceTable[] = { }; static EntranceTableEntry sPathToMountainVillageEntrance0[] = { - { 0x1C, 0x00, 0x8A14 }, - { 0x1C, 0x00, 0x8A14 }, + { SCENE_13HUBUKINOMITI, 0, 0x8A14 }, + { SCENE_13HUBUKINOMITI, 0, 0x8A14 }, }; static EntranceTableEntry sPathToMountainVillageEntrance1[] = { - { 0x1C, 0x01, 0x8A14 }, - { 0x1C, 0x01, 0x8A14 }, + { SCENE_13HUBUKINOMITI, 1, 0x8A14 }, + { SCENE_13HUBUKINOMITI, 1, 0x8A14 }, }; static EntranceTableEntry* sPathToMountainVillageEntranceTable[] = { @@ -589,31 +589,31 @@ static EntranceTableEntry* sPathToMountainVillageEntranceTable[] = { }; static EntranceTableEntry sIkanaCastleEntrance0[] = { - { 0xE3, 0x00, 0x4102 }, + { -SCENE_CASTLE, 0, 0x4102 }, }; static EntranceTableEntry sIkanaCastleEntrance1[] = { - { 0xE3, 0x01, 0x4102 }, + { -SCENE_CASTLE, 1, 0x4102 }, }; static EntranceTableEntry sIkanaCastleEntrance2[] = { - { 0xE3, 0x02, 0x8102 }, + { -SCENE_CASTLE, 2, 0x8102 }, }; static EntranceTableEntry sIkanaCastleEntrance3[] = { - { 0xE3, 0x03, 0x8102 }, + { -SCENE_CASTLE, 3, 0x8102 }, }; static EntranceTableEntry sIkanaCastleEntrance4[] = { - { 0xE3, 0x04, 0x8102 }, + { -SCENE_CASTLE, 4, 0x8102 }, }; static EntranceTableEntry sIkanaCastleEntrance5[] = { - { 0xE3, 0x05, 0x8102 }, + { -SCENE_CASTLE, 5, 0x8102 }, }; static EntranceTableEntry sIkanaCastleEntrance6[] = { - { 0xE3, 0x06, 0x8102 }, + { -SCENE_CASTLE, 6, 0x8102 }, }; static EntranceTableEntry* sIkanaCastleEntranceTable[] = { @@ -622,11 +622,11 @@ static EntranceTableEntry* sIkanaCastleEntranceTable[] = { }; static EntranceTableEntry sDekuScrubPlaygroundEntrance0[] = { - { 0x1E, 0x00, 0x0102 }, + { SCENE_DEKUTES, 0, 0x0102 }, }; static EntranceTableEntry sDekuScrubPlaygroundEntrance1[] = { - { 0x1E, 0x01, 0x0102 }, + { SCENE_DEKUTES, 1, 0x0102 }, }; static EntranceTableEntry* sDekuScrubPlaygroundEntranceTable[] = { @@ -635,7 +635,7 @@ static EntranceTableEntry* sDekuScrubPlaygroundEntranceTable[] = { }; static EntranceTableEntry sOdolwasLairEntrance0[] = { - { 0xE1, 0x00, 0x8102 }, + { -SCENE_MITURIN_BS, 0, 0x8102 }, }; static EntranceTableEntry* sOdolwasLairEntranceTable[] = { @@ -643,11 +643,11 @@ static EntranceTableEntry* sOdolwasLairEntranceTable[] = { }; static EntranceTableEntry sTownShootingGalleryEntrance0[] = { - { 0x20, 0x00, 0x4102 }, + { SCENE_SYATEKI_MIZU, 0, 0x4102 }, }; static EntranceTableEntry sTownShootingGalleryEntrance1[] = { - { 0x20, 0x01, 0x0102 }, + { SCENE_SYATEKI_MIZU, 1, 0x0102 }, }; static EntranceTableEntry* sTownShootingGalleryEntranceTable[] = { @@ -656,11 +656,11 @@ static EntranceTableEntry* sTownShootingGalleryEntranceTable[] = { }; static EntranceTableEntry sSnowheadTempleEntrance0[] = { - { 0xDF, 0x00, 0x4102 }, + { -SCENE_HAKUGIN, 0, 0x4102 }, }; static EntranceTableEntry sSnowheadTempleEntrance1[] = { - { 0xDF, 0x01, 0x4102 }, + { -SCENE_HAKUGIN, 1, 0x4102 }, }; static EntranceTableEntry* sSnowheadTempleEntranceTable[] = { @@ -669,31 +669,31 @@ static EntranceTableEntry* sSnowheadTempleEntranceTable[] = { }; static EntranceTableEntry sMilkRoadEntrance0[] = { - { 0x22, 0x00, 0xCA14 }, + { SCENE_ROMANYMAE, 0, 0xCA14 }, }; static EntranceTableEntry sMilkRoadEntrance1[] = { - { 0x22, 0x01, 0x4A14 }, + { SCENE_ROMANYMAE, 1, 0x4A14 }, }; static EntranceTableEntry sMilkRoadEntrance2[] = { - { 0x22, 0x02, 0x4A14 }, + { SCENE_ROMANYMAE, 2, 0x4A14 }, }; static EntranceTableEntry sMilkRoadEntrance3[] = { - { 0x22, 0x03, 0x4A14 }, + { SCENE_ROMANYMAE, 3, 0x4A14 }, }; static EntranceTableEntry sMilkRoadEntrance4[] = { - { 0x22, 0x04, 0x4A14 }, + { SCENE_ROMANYMAE, 4, 0x4A14 }, }; static EntranceTableEntry sMilkRoadEntrance5[] = { - { 0x22, 0x05, 0x0102 }, + { SCENE_ROMANYMAE, 5, 0x0102 }, }; static EntranceTableEntry sMilkRoadEntrance6[] = { - { 0x22, 0x06, 0x0102 }, + { SCENE_ROMANYMAE, 6, 0x0102 }, }; static EntranceTableEntry* sMilkRoadEntranceTable[] = { @@ -702,67 +702,67 @@ static EntranceTableEntry* sMilkRoadEntranceTable[] = { }; static EntranceTableEntry sPiratesFortressInteriorEntrance0[] = { - { 0x23, 0x00, 0x8102 }, + { SCENE_PIRATE, 0, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance1[] = { - { 0x23, 0x01, 0x8102 }, + { SCENE_PIRATE, 1, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance2[] = { - { 0x23, 0x02, 0x8102 }, + { SCENE_PIRATE, 2, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance3[] = { - { 0x23, 0x03, 0x8102 }, + { SCENE_PIRATE, 3, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance4[] = { - { 0x23, 0x04, 0x8102 }, + { SCENE_PIRATE, 4, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance5[] = { - { 0x23, 0x05, 0x8102 }, + { SCENE_PIRATE, 5, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance6[] = { - { 0x23, 0x06, 0x8102 }, + { SCENE_PIRATE, 6, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance7[] = { - { 0x23, 0x07, 0x8102 }, + { SCENE_PIRATE, 7, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance8[] = { - { 0x23, 0x08, 0x8102 }, + { SCENE_PIRATE, 8, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance9[] = { - { 0x23, 0x09, 0x8993 }, + { SCENE_PIRATE, 9, 0x8993 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance10[] = { - { 0x23, 0x0A, 0x8102 }, + { SCENE_PIRATE, 10, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance11[] = { - { 0x23, 0x0B, 0x8102 }, + { SCENE_PIRATE, 11, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance12[] = { - { 0x23, 0x0C, 0x8102 }, + { SCENE_PIRATE, 12, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance13[] = { - { 0x23, 0x0D, 0x8102 }, + { SCENE_PIRATE, 13, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance14[] = { - { 0x23, 0x0E, 0x8102 }, + { SCENE_PIRATE, 14, 0x8102 }, }; static EntranceTableEntry sPiratesFortressInteriorEntrance15[] = { - { 0x23, 0x0F, 0x8102 }, + { SCENE_PIRATE, 15, 0x8102 }, }; static EntranceTableEntry* sPiratesFortressInteriorEntranceTable[] = { @@ -775,65 +775,65 @@ static EntranceTableEntry* sPiratesFortressInteriorEntranceTable[] = { }; static EntranceTableEntry sSwampShootingGalleryEntrance0[] = { - { 0x24, 0x00, 0x4102 }, + { SCENE_SYATEKI_MORI, 0, 0x4102 }, }; static EntranceTableEntry* sSwampShootingGalleryEntranceTable[] = { sSwampShootingGalleryEntrance0, }; -static EntranceTableEntry sPinaccleRockEntrance0[] = { - { 0x25, 0x00, 0x4A14 }, +static EntranceTableEntry sPinnacleRockEntrance0[] = { + { SCENE_SINKAI, 0, 0x4A14 }, }; -static EntranceTableEntry sPinaccleRockEntrance1[] = { - { 0x25, 0x01, 0x0A14 }, +static EntranceTableEntry sPinnacleRockEntrance1[] = { + { SCENE_SINKAI, 1, 0x0A14 }, }; -static EntranceTableEntry* sPinaccleRockEntranceTable[] = { - sPinaccleRockEntrance0, - sPinaccleRockEntrance1, +static EntranceTableEntry* sPinnacleRockEntranceTable[] = { + sPinnacleRockEntrance0, + sPinnacleRockEntrance1, }; static EntranceTableEntry sFairyFountainEntrance0[] = { - { 0x26, 0x00, 0x4102 }, - { 0x26, 0x00, 0x8102 }, + { SCENE_YOUSEI_IZUMI, 0, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 0, 0x8102 }, }; static EntranceTableEntry sFairyFountainEntrance1[] = { - { 0x26, 0x01, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 1, 0x4102 }, }; static EntranceTableEntry sFairyFountainEntrance2[] = { - { 0x26, 0x02, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 2, 0x4102 }, }; static EntranceTableEntry sFairyFountainEntrance3[] = { - { 0x26, 0x03, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 3, 0x4102 }, }; static EntranceTableEntry sFairyFountainEntrance4[] = { - { 0x26, 0x04, 0x4102 }, + { SCENE_YOUSEI_IZUMI, 4, 0x4102 }, }; static EntranceTableEntry sFairyFountainEntrance5[] = { - { 0x26, 0x05, 0x8183 }, + { SCENE_YOUSEI_IZUMI, 5, 0x8183 }, }; static EntranceTableEntry sFairyFountainEntrance6[] = { - { 0x26, 0x06, 0x858B }, + { SCENE_YOUSEI_IZUMI, 6, 0x858B }, }; static EntranceTableEntry sFairyFountainEntrance7[] = { - { 0x26, 0x07, 0x858B }, + { SCENE_YOUSEI_IZUMI, 7, 0x858B }, }; static EntranceTableEntry sFairyFountainEntrance8[] = { - { 0x26, 0x08, 0x858B }, + { SCENE_YOUSEI_IZUMI, 8, 0x858B }, }; static EntranceTableEntry sFairyFountainEntrance9[] = { - { 0x26, 0x09, 0x858B }, + { SCENE_YOUSEI_IZUMI, 9, 0x858B }, }; static EntranceTableEntry* sFairyFountainEntranceTable[] = { @@ -843,7 +843,7 @@ static EntranceTableEntry* sFairyFountainEntranceTable[] = { }; static EntranceTableEntry sSwampSpiderHouseEntrance0[] = { - { 0xD9, 0x00, 0x4102 }, + { -SCENE_KINSTA1, 0, 0x4102 }, }; static EntranceTableEntry* sSwampSpiderHouseEntranceTable[] = { @@ -851,7 +851,7 @@ static EntranceTableEntry* sSwampSpiderHouseEntranceTable[] = { }; static EntranceTableEntry sOceansideSpiderHouseEntrance0[] = { - { 0xD8, 0x00, 0x4102 }, + { -SCENE_KINDAN2, 0, 0x4102 }, }; static EntranceTableEntry* sOceansideSpiderHouseEntranceTable[] = { @@ -859,15 +859,15 @@ static EntranceTableEntry* sOceansideSpiderHouseEntranceTable[] = { }; static EntranceTableEntry sAstralObservatoryEntrance0[] = { - { 0x29, 0x00, 0x0102 }, + { SCENE_TENMON_DAI, 0, 0x0102 }, }; static EntranceTableEntry sAstralObservatoryEntrance1[] = { - { 0x29, 0x01, 0x4102 }, + { SCENE_TENMON_DAI, 1, 0x4102 }, }; static EntranceTableEntry sAstralObservatoryEntrance2[] = { - { 0x29, 0x02, 0x8115 }, + { SCENE_TENMON_DAI, 2, 0x8115 }, }; static EntranceTableEntry* sAstralObservatoryEntranceTable[] = { @@ -877,7 +877,7 @@ static EntranceTableEntry* sAstralObservatoryEntranceTable[] = { }; static EntranceTableEntry sMoonDekuTrialEntrance0[] = { - { 0xD6, 0x00, 0x0387 }, + { -SCENE_LAST_DEKU, 0, 0x0387 }, }; static EntranceTableEntry* sMoonDekuTrialEntranceTable[] = { @@ -885,47 +885,47 @@ static EntranceTableEntry* sMoonDekuTrialEntranceTable[] = { }; static EntranceTableEntry sDekuPalaceEntrance0[] = { - { 0x2B, 0x00, 0x4102 }, + { SCENE_22DEKUCITY, 0, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance1[] = { - { 0x2B, 0x01, 0x8A14 }, + { SCENE_22DEKUCITY, 1, 0x8A14 }, }; static EntranceTableEntry sDekuPalaceEntrance2[] = { - { 0x2B, 0x02, 0xC102 }, + { SCENE_22DEKUCITY, 2, 0xC102 }, }; static EntranceTableEntry sDekuPalaceEntrance3[] = { - { 0x2B, 0x03, 0xC102 }, + { SCENE_22DEKUCITY, 3, 0xC102 }, }; static EntranceTableEntry sDekuPalaceEntrance4[] = { - { 0x2B, 0x04, 0x4102 }, + { SCENE_22DEKUCITY, 4, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance5[] = { - { 0x2B, 0x05, 0x4102 }, + { SCENE_22DEKUCITY, 5, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance6[] = { - { 0x2B, 0x06, 0x4102 }, + { SCENE_22DEKUCITY, 6, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance7[] = { - { 0x2B, 0x07, 0x4102 }, + { SCENE_22DEKUCITY, 7, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance8[] = { - { 0x2B, 0x08, 0x4102 }, + { SCENE_22DEKUCITY, 8, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance9[] = { - { 0x2B, 0x09, 0x4102 }, + { SCENE_22DEKUCITY, 9, 0x4102 }, }; static EntranceTableEntry sDekuPalaceEntrance10[] = { - { 0x2B, 0x0A, 0x4102 }, + { SCENE_22DEKUCITY, 10, 0x4102 }, }; static EntranceTableEntry* sDekuPalaceEntranceTable[] = { @@ -935,7 +935,7 @@ static EntranceTableEntry* sDekuPalaceEntranceTable[] = { }; static EntranceTableEntry sMountainSmithyEntrance0[] = { - { 0x2C, 0x00, 0x4102 }, + { SCENE_KAJIYA, 0, 0x4102 }, }; static EntranceTableEntry* sMountainSmithyEntranceTable[] = { @@ -943,79 +943,81 @@ static EntranceTableEntry* sMountainSmithyEntranceTable[] = { }; static EntranceTableEntry sTerminaFieldEntrance0[] = { - { 0x2D, 0x00, 0x4102 }, { 0xD3, 0x00, 0x0A14 }, { 0xD3, 0x00, 0x0A14 }, { 0xD3, 0x00, 0x058B }, - { 0x2D, 0x00, 0x0A14 }, { 0x2D, 0x00, 0x0A14 }, { 0x2D, 0x00, 0x058B }, { 0x2D, 0x00, 0x8102 }, - { 0x2D, 0x00, 0x0102 }, { 0x2D, 0x00, 0x8102 }, + { SCENE_00KEIKOKU, 0, 0x4102 }, { -SCENE_00KEIKOKU, 0, 0x0A14 }, { -SCENE_00KEIKOKU, 0, 0x0A14 }, + { -SCENE_00KEIKOKU, 0, 0x058B }, { SCENE_00KEIKOKU, 0, 0x0A14 }, { SCENE_00KEIKOKU, 0, 0x0A14 }, + { SCENE_00KEIKOKU, 0, 0x058B }, { SCENE_00KEIKOKU, 0, 0x8102 }, { SCENE_00KEIKOKU, 0, 0x0102 }, + { SCENE_00KEIKOKU, 0, 0x8102 }, }; static EntranceTableEntry sTerminaFieldEntrance1[] = { - { 0x2D, 0x01, 0xCA14 }, { 0x2D, 0x01, 0x0A14 }, { 0x2D, 0x01, 0x058B }, { 0xD3, 0x01, 0x858B }, - { 0x2D, 0x01, 0x0A14 }, { 0x2D, 0x01, 0x0A14 }, { 0x2D, 0x01, 0x058B }, { 0x2D, 0x01, 0x858B }, - { 0x2D, 0x01, 0x0102 }, { 0x2D, 0x01, 0x8102 }, + { SCENE_00KEIKOKU, 1, 0xCA14 }, { SCENE_00KEIKOKU, 1, 0x0A14 }, { SCENE_00KEIKOKU, 1, 0x058B }, + { -SCENE_00KEIKOKU, 1, 0x858B }, { SCENE_00KEIKOKU, 1, 0x0A14 }, { SCENE_00KEIKOKU, 1, 0x0A14 }, + { SCENE_00KEIKOKU, 1, 0x058B }, { SCENE_00KEIKOKU, 1, 0x858B }, { SCENE_00KEIKOKU, 1, 0x0102 }, + { SCENE_00KEIKOKU, 1, 0x8102 }, }; static EntranceTableEntry sTerminaFieldEntrance2[] = { - { 0x2D, 0x02, 0xCA14 }, { 0xD3, 0x02, 0x0A14 }, { 0xD3, 0x02, 0x0A14 }, - { 0xD3, 0x02, 0x058B }, { 0x2D, 0x02, 0x0A14 }, { 0x2D, 0x02, 0x0A14 }, + { SCENE_00KEIKOKU, 2, 0xCA14 }, { -SCENE_00KEIKOKU, 2, 0x0A14 }, { -SCENE_00KEIKOKU, 2, 0x0A14 }, + { -SCENE_00KEIKOKU, 2, 0x058B }, { SCENE_00KEIKOKU, 2, 0x0A14 }, { SCENE_00KEIKOKU, 2, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance3[] = { - { 0x2D, 0x03, 0xCA14 }, { 0xD3, 0x03, 0x0A14 }, { 0xD3, 0x03, 0x0A14 }, - { 0xD3, 0x03, 0x058B }, { 0x2D, 0x03, 0x0A14 }, { 0x2D, 0x03, 0x0A14 }, + { SCENE_00KEIKOKU, 3, 0xCA14 }, { -SCENE_00KEIKOKU, 3, 0x0A14 }, { -SCENE_00KEIKOKU, 3, 0x0A14 }, + { -SCENE_00KEIKOKU, 3, 0x058B }, { SCENE_00KEIKOKU, 3, 0x0A14 }, { SCENE_00KEIKOKU, 3, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance4[] = { - { 0x2D, 0x04, 0xCA14 }, { 0xD3, 0x04, 0x0A14 }, { 0xD3, 0x04, 0x0A14 }, - { 0xD3, 0x04, 0x058B }, { 0x2D, 0x04, 0x0A14 }, { 0x2D, 0x04, 0x0A14 }, + { SCENE_00KEIKOKU, 4, 0xCA14 }, { -SCENE_00KEIKOKU, 4, 0x0A14 }, { -SCENE_00KEIKOKU, 4, 0x0A14 }, + { -SCENE_00KEIKOKU, 4, 0x058B }, { SCENE_00KEIKOKU, 4, 0x0A14 }, { SCENE_00KEIKOKU, 4, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance5[] = { - { 0x2D, 0x05, 0xCA14 }, { 0xD3, 0x05, 0x0A14 }, { 0xD3, 0x05, 0x0A14 }, - { 0xD3, 0x05, 0x858B }, { 0x2D, 0x05, 0x0A14 }, { 0x2D, 0x05, 0x0A14 }, + { SCENE_00KEIKOKU, 5, 0xCA14 }, { -SCENE_00KEIKOKU, 5, 0x0A14 }, { -SCENE_00KEIKOKU, 5, 0x0A14 }, + { -SCENE_00KEIKOKU, 5, 0x858B }, { SCENE_00KEIKOKU, 5, 0x0A14 }, { SCENE_00KEIKOKU, 5, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance6[] = { - { 0x2D, 0x06, 0x4102 }, { 0xD3, 0x06, 0x0A14 }, { 0xD3, 0x06, 0x0A14 }, - { 0xD3, 0x06, 0x858B }, { 0x2D, 0x06, 0x0A14 }, { 0x2D, 0x06, 0x0A14 }, + { SCENE_00KEIKOKU, 6, 0x4102 }, { -SCENE_00KEIKOKU, 6, 0x0A14 }, { -SCENE_00KEIKOKU, 6, 0x0A14 }, + { -SCENE_00KEIKOKU, 6, 0x858B }, { SCENE_00KEIKOKU, 6, 0x0A14 }, { SCENE_00KEIKOKU, 6, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance7[] = { - { 0x2D, 0x07, 0x4102 }, { 0xD3, 0x07, 0x0A14 }, { 0xD3, 0x07, 0x0A14 }, - { 0xD3, 0x07, 0x858B }, { 0x2D, 0x07, 0x0A14 }, { 0x2D, 0x07, 0x0A14 }, + { SCENE_00KEIKOKU, 7, 0x4102 }, { -SCENE_00KEIKOKU, 7, 0x0A14 }, { -SCENE_00KEIKOKU, 7, 0x0A14 }, + { -SCENE_00KEIKOKU, 7, 0x858B }, { SCENE_00KEIKOKU, 7, 0x0A14 }, { SCENE_00KEIKOKU, 7, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance8[] = { - { 0x2D, 0x08, 0x4102 }, { 0xD3, 0x08, 0x0A14 }, { 0xD3, 0x08, 0x0A14 }, - { 0xD3, 0x08, 0x058B }, { 0x2D, 0x08, 0x0A14 }, { 0x2D, 0x08, 0x0A14 }, + { SCENE_00KEIKOKU, 8, 0x4102 }, { -SCENE_00KEIKOKU, 8, 0x0A14 }, { -SCENE_00KEIKOKU, 8, 0x0A14 }, + { -SCENE_00KEIKOKU, 8, 0x058B }, { SCENE_00KEIKOKU, 8, 0x0A14 }, { SCENE_00KEIKOKU, 8, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance9[] = { - { 0x2D, 0x09, 0x4102 }, { 0xD3, 0x09, 0x0A14 }, { 0xD3, 0x09, 0x0A14 }, - { 0xD3, 0x09, 0x058B }, { 0x2D, 0x09, 0x0A14 }, { 0x2D, 0x09, 0x0A14 }, + { SCENE_00KEIKOKU, 9, 0x4102 }, { -SCENE_00KEIKOKU, 9, 0x0A14 }, { -SCENE_00KEIKOKU, 9, 0x0A14 }, + { -SCENE_00KEIKOKU, 9, 0x058B }, { SCENE_00KEIKOKU, 9, 0x0A14 }, { SCENE_00KEIKOKU, 9, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance10[] = { - { 0x2D, 0x0A, 0x8A95 }, { 0xD3, 0x0A, 0x0A14 }, { 0xD3, 0x0A, 0x0A14 }, - { 0xD3, 0x0A, 0x058B }, { 0x2D, 0x0A, 0x0A14 }, { 0x2D, 0x0A, 0x0A95 }, + { SCENE_00KEIKOKU, 10, 0x8A95 }, { -SCENE_00KEIKOKU, 10, 0x0A14 }, { -SCENE_00KEIKOKU, 10, 0x0A14 }, + { -SCENE_00KEIKOKU, 10, 0x058B }, { SCENE_00KEIKOKU, 10, 0x0A14 }, { SCENE_00KEIKOKU, 10, 0x0A95 }, }; static EntranceTableEntry sTerminaFieldEntrance11[] = { - { 0x2D, 0x0B, 0x4A14 }, { 0xD3, 0x0B, 0x0A14 }, { 0xD3, 0x0B, 0x0A14 }, - { 0xD3, 0x0B, 0x058B }, { 0x2D, 0x0B, 0x0A14 }, { 0x2D, 0x0B, 0x0A14 }, + { SCENE_00KEIKOKU, 11, 0x4A14 }, { -SCENE_00KEIKOKU, 11, 0x0A14 }, { -SCENE_00KEIKOKU, 11, 0x0A14 }, + { -SCENE_00KEIKOKU, 11, 0x058B }, { SCENE_00KEIKOKU, 11, 0x0A14 }, { SCENE_00KEIKOKU, 11, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance12[] = { - { 0x2D, 0x0C, 0x0A14 }, { 0xD3, 0x0C, 0x0A14 }, { 0xD3, 0x0C, 0x0A14 }, - { 0xD3, 0x0C, 0x058B }, { 0x2D, 0x0C, 0x0A14 }, { 0x2D, 0x0C, 0x0A14 }, + { SCENE_00KEIKOKU, 12, 0x0A14 }, { -SCENE_00KEIKOKU, 12, 0x0A14 }, { -SCENE_00KEIKOKU, 12, 0x0A14 }, + { -SCENE_00KEIKOKU, 12, 0x058B }, { SCENE_00KEIKOKU, 12, 0x0A14 }, { SCENE_00KEIKOKU, 12, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance13[] = { - { 0x2D, 0x0D, 0x0A14 }, { 0xD3, 0x0D, 0x0A14 }, { 0xD3, 0x0D, 0x0A14 }, - { 0xD3, 0x0D, 0x058B }, { 0x2D, 0x0D, 0x0A14 }, { 0x2D, 0x0D, 0x0A14 }, + { SCENE_00KEIKOKU, 13, 0x0A14 }, { -SCENE_00KEIKOKU, 13, 0x0A14 }, { -SCENE_00KEIKOKU, 13, 0x0A14 }, + { -SCENE_00KEIKOKU, 13, 0x058B }, { SCENE_00KEIKOKU, 13, 0x0A14 }, { SCENE_00KEIKOKU, 13, 0x0A14 }, }; static EntranceTableEntry sTerminaFieldEntrance14[] = { - { 0x2D, 0x0E, 0x858B }, + { SCENE_00KEIKOKU, 14, 0x858B }, }; static EntranceTableEntry* sTerminaFieldEntranceTable[] = { @@ -1026,7 +1028,7 @@ static EntranceTableEntry* sTerminaFieldEntranceTable[] = { }; static EntranceTableEntry sPostOfficeEntrance0[] = { - { 0x2E, 0x00, 0x4102 }, + { SCENE_POSTHOUSE, 0, 0x4102 }, }; static EntranceTableEntry* sPostOfficeEntranceTable[] = { @@ -1034,7 +1036,7 @@ static EntranceTableEntry* sPostOfficeEntranceTable[] = { }; static EntranceTableEntry sMarineResearchLabEntrance0[] = { - { 0x2F, 0x00, 0x4102 }, + { SCENE_LABO, 0, 0x4102 }, }; static EntranceTableEntry* sMarineResearchLabEntranceTable[] = { @@ -1042,11 +1044,11 @@ static EntranceTableEntry* sMarineResearchLabEntranceTable[] = { }; static EntranceTableEntry sDampesHouseEntrance0[] = { - { 0x30, 0x00, 0x4102 }, + { SCENE_DANPEI2TEST, 0, 0x4102 }, }; static EntranceTableEntry sDampesHouseEntrance1[] = { - { 0x30, 0x01, 0x0102 }, + { SCENE_DANPEI2TEST, 1, 0x0102 }, }; static EntranceTableEntry* sDampesHouseEntranceTable[] = { @@ -1055,23 +1057,23 @@ static EntranceTableEntry* sDampesHouseEntranceTable[] = { }; static EntranceTableEntry sGoronShrineEntrance0[] = { - { 0x32, 0x00, 0x4102 }, - { 0x32, 0x00, 0x4102 }, + { SCENE_16GORON_HOUSE, 0, 0x4102 }, + { SCENE_16GORON_HOUSE, 0, 0x4102 }, }; static EntranceTableEntry sGoronShrineEntrance1[] = { - { 0x32, 0x01, 0x0102 }, - { 0x32, 0x01, 0x0102 }, + { SCENE_16GORON_HOUSE, 1, 0x0102 }, + { SCENE_16GORON_HOUSE, 1, 0x0102 }, }; static EntranceTableEntry sGoronShrineEntrance2[] = { - { 0x32, 0x02, 0x058B }, - { 0x32, 0x02, 0x058B }, + { SCENE_16GORON_HOUSE, 2, 0x058B }, + { SCENE_16GORON_HOUSE, 2, 0x058B }, }; static EntranceTableEntry sGoronShrineEntrance3[] = { - { 0x32, 0x03, 0x0102 }, - { 0x32, 0x03, 0x0102 }, + { SCENE_16GORON_HOUSE, 3, 0x0102 }, + { SCENE_16GORON_HOUSE, 3, 0x0102 }, }; static EntranceTableEntry* sGoronShrineEntranceTable[] = { @@ -1082,40 +1084,40 @@ static EntranceTableEntry* sGoronShrineEntranceTable[] = { }; static EntranceTableEntry sZoraHallEntrance0[] = { - { 0x33, 0x00, 0x4993 }, - { 0x33, 0x00, 0x8102 }, + { SCENE_33ZORACITY, 0, 0x4993 }, + { SCENE_33ZORACITY, 0, 0x8102 }, }; static EntranceTableEntry sZoraHallEntrance1[] = { - { 0x33, 0x01, 0x4102 }, + { SCENE_33ZORACITY, 1, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance2[] = { - { 0x33, 0x02, 0x4102 }, + { SCENE_33ZORACITY, 2, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance3[] = { - { 0x33, 0x03, 0x4102 }, + { SCENE_33ZORACITY, 3, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance4[] = { - { 0x33, 0x04, 0x4102 }, + { SCENE_33ZORACITY, 4, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance5[] = { - { 0x33, 0x05, 0x4102 }, + { SCENE_33ZORACITY, 5, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance6[] = { - { 0x33, 0x06, 0x4102 }, + { SCENE_33ZORACITY, 6, 0x4102 }, }; static EntranceTableEntry sZoraHallEntrance7[] = { - { 0x33, 0x07, 0x058B }, + { SCENE_33ZORACITY, 7, 0x058B }, }; static EntranceTableEntry sZoraHallEntrance8[] = { - { 0x33, 0x08, 0x8183 }, + { SCENE_33ZORACITY, 8, 0x8183 }, }; static EntranceTableEntry* sZoraHallEntranceTable[] = { @@ -1124,11 +1126,11 @@ static EntranceTableEntry* sZoraHallEntranceTable[] = { }; static EntranceTableEntry sTradingPostEntrance0[] = { - { 0x34, 0x00, 0x4102 }, + { SCENE_8ITEMSHOP, 0, 0x4102 }, }; static EntranceTableEntry sTradingPostEntrance1[] = { - { 0x34, 0x01, 0x0102 }, + { SCENE_8ITEMSHOP, 1, 0x0102 }, }; static EntranceTableEntry* sTradingPostEntranceTable[] = { @@ -1137,52 +1139,52 @@ static EntranceTableEntry* sTradingPostEntranceTable[] = { }; static EntranceTableEntry sRomaniRanchEntrance0[] = { - { 0x35, 0x00, 0x4A14 }, { 0x35, 0x00, 0x0A14 }, { 0x35, 0x00, 0x8102 }, { 0x35, 0x00, 0x858B }, - { 0x35, 0x00, 0x858B }, { 0x35, 0x00, 0x0102 }, { 0x35, 0x00, 0x8102 }, + { SCENE_F01, 0, 0x4A14 }, { SCENE_F01, 0, 0x0A14 }, { SCENE_F01, 0, 0x8102 }, { SCENE_F01, 0, 0x858B }, + { SCENE_F01, 0, 0x858B }, { SCENE_F01, 0, 0x0102 }, { SCENE_F01, 0, 0x8102 }, }; static EntranceTableEntry sRomaniRanchEntrance1[] = { - { 0x35, 0x01, 0x0A14 }, + { SCENE_F01, 1, 0x0A14 }, }; static EntranceTableEntry sRomaniRanchEntrance2[] = { - { 0x35, 0x02, 0x0102 }, + { SCENE_F01, 2, 0x0102 }, }; static EntranceTableEntry sRomaniRanchEntrance3[] = { - { 0x35, 0x03, 0x0102 }, + { SCENE_F01, 3, 0x0102 }, }; static EntranceTableEntry sRomaniRanchEntrance4[] = { - { 0x35, 0x04, 0x8102 }, + { SCENE_F01, 4, 0x8102 }, }; static EntranceTableEntry sRomaniRanchEntrance5[] = { - { 0x35, 0x05, 0x8102 }, + { SCENE_F01, 5, 0x8102 }, }; static EntranceTableEntry sRomaniRanchEntrance6[] = { - { 0x35, 0x06, 0x0A14 }, + { SCENE_F01, 6, 0x0A14 }, }; static EntranceTableEntry sRomaniRanchEntrance7[] = { - { 0x35, 0x07, 0x0A14 }, + { SCENE_F01, 7, 0x0A14 }, }; static EntranceTableEntry sRomaniRanchEntrance8[] = { - { 0x35, 0x08, 0x0A14 }, + { SCENE_F01, 8, 0x0A14 }, }; static EntranceTableEntry sRomaniRanchEntrance9[] = { - { 0x35, 0x09, 0x0102 }, + { SCENE_F01, 9, 0x0102 }, }; static EntranceTableEntry sRomaniRanchEntrance10[] = { - { 0x35, 0x0A, 0x0102 }, + { SCENE_F01, 10, 0x0102 }, }; static EntranceTableEntry sRomaniRanchEntrance11[] = { - { 0x35, 0x0B, 0x0102 }, + { SCENE_F01, 11, 0x0102 }, }; static EntranceTableEntry* sRomaniRanchEntranceTable[] = { @@ -1192,23 +1194,23 @@ static EntranceTableEntry* sRomaniRanchEntranceTable[] = { }; static EntranceTableEntry sTwinmoldsLairEntrance0[] = { - { 0xCA, 0x00, 0x0102 }, + { -SCENE_INISIE_BS, 0, 0x0102 }, }; static EntranceTableEntry sTwinmoldsLairEntrance1[] = { - { 0xCA, 0x01, 0x0102 }, + { -SCENE_INISIE_BS, 1, 0x0102 }, }; static EntranceTableEntry sTwinmoldsLairEntrance2[] = { - { 0xCA, 0x02, 0x0102 }, + { -SCENE_INISIE_BS, 2, 0x0102 }, }; static EntranceTableEntry sTwinmoldsLairEntrance3[] = { - { 0xCA, 0x03, 0x0102 }, + { -SCENE_INISIE_BS, 3, 0x0102 }, }; static EntranceTableEntry sTwinmoldsLairEntrance4[] = { - { 0xCA, 0x04, 0x0102 }, + { -SCENE_INISIE_BS, 4, 0x0102 }, }; static EntranceTableEntry* sTwinmoldsLairEntranceTable[] = { @@ -1217,74 +1219,74 @@ static EntranceTableEntry* sTwinmoldsLairEntranceTable[] = { }; static EntranceTableEntry sGreatBayCoastEntrance0[] = { - { 0x37, 0x00, 0xCA14 }, - { 0x37, 0x00, 0xCA14 }, - { 0x37, 0x00, 0x8102 }, + { SCENE_30GYOSON, 0, 0xCA14 }, + { SCENE_30GYOSON, 0, 0xCA14 }, + { SCENE_30GYOSON, 0, 0x8102 }, }; static EntranceTableEntry sGreatBayCoastEntrance1[] = { - { 0x37, 0x01, 0xCA14 }, - { 0x37, 0x01, 0xCA14 }, + { SCENE_30GYOSON, 1, 0xCA14 }, + { SCENE_30GYOSON, 1, 0xCA14 }, }; static EntranceTableEntry sGreatBayCoastEntrance2[] = { - { 0x37, 0x02, 0x4993 }, - { 0x37, 0x02, 0x4993 }, + { SCENE_30GYOSON, 2, 0x4993 }, + { SCENE_30GYOSON, 2, 0x4993 }, }; static EntranceTableEntry sGreatBayCoastEntrance3[] = { - { 0x37, 0x03, 0x4A14 }, - { 0x37, 0x03, 0x4A14 }, + { SCENE_30GYOSON, 3, 0x4A14 }, + { SCENE_30GYOSON, 3, 0x4A14 }, }; static EntranceTableEntry sGreatBayCoastEntrance4[] = { - { 0x37, 0x04, 0x4102 }, - { 0x37, 0x04, 0x4102 }, + { SCENE_30GYOSON, 4, 0x4102 }, + { SCENE_30GYOSON, 4, 0x4102 }, }; static EntranceTableEntry sGreatBayCoastEntrance5[] = { - { 0x37, 0x05, 0x4993 }, - { 0x37, 0x05, 0x4993 }, + { SCENE_30GYOSON, 5, 0x4993 }, + { SCENE_30GYOSON, 5, 0x4993 }, }; static EntranceTableEntry sGreatBayCoastEntrance6[] = { - { 0x37, 0x06, 0x4993 }, - { 0x37, 0x06, 0x4993 }, + { SCENE_30GYOSON, 6, 0x4993 }, + { SCENE_30GYOSON, 6, 0x4993 }, }; static EntranceTableEntry sGreatBayCoastEntrance7[] = { - { 0x37, 0x07, 0x4102 }, - { 0x37, 0x07, 0x4102 }, + { SCENE_30GYOSON, 7, 0x4102 }, + { SCENE_30GYOSON, 7, 0x4102 }, }; static EntranceTableEntry sGreatBayCoastEntrance8[] = { - { 0x37, 0x08, 0x4102 }, - { 0x37, 0x08, 0x4102 }, + { SCENE_30GYOSON, 8, 0x4102 }, + { SCENE_30GYOSON, 8, 0x4102 }, }; static EntranceTableEntry sGreatBayCoastEntrance9[] = { - { 0x37, 0x09, 0x058B }, - { 0x37, 0x09, 0x058B }, + { SCENE_30GYOSON, 9, 0x058B }, + { SCENE_30GYOSON, 9, 0x058B }, }; static EntranceTableEntry sGreatBayCoastEntrance10[] = { - { 0x37, 0x0A, 0x858B }, - { 0x37, 0x0A, 0x858B }, + { SCENE_30GYOSON, 10, 0x858B }, + { SCENE_30GYOSON, 10, 0x858B }, }; static EntranceTableEntry sGreatBayCoastEntrance11[] = { - { 0x37, 0x0B, 0x0A14 }, - { 0x37, 0x0B, 0x0A14 }, + { SCENE_30GYOSON, 11, 0x0A14 }, + { SCENE_30GYOSON, 11, 0x0A14 }, }; static EntranceTableEntry sGreatBayCoastEntrance12[] = { - { 0x37, 0x0C, 0x0A14 }, - { 0x37, 0x0C, 0x0A14 }, + { SCENE_30GYOSON, 12, 0x0A14 }, + { SCENE_30GYOSON, 12, 0x0A14 }, }; static EntranceTableEntry sGreatBayCoastEntrance13[] = { - { 0x37, 0x0D, 0x0A14 }, - { 0x37, 0x0D, 0x0A14 }, + { SCENE_30GYOSON, 13, 0x0A14 }, + { SCENE_30GYOSON, 13, 0x0A14 }, }; static EntranceTableEntry* sGreatBayCoastEntranceTable[] = { @@ -1295,53 +1297,53 @@ static EntranceTableEntry* sGreatBayCoastEntranceTable[] = { }; static EntranceTableEntry sZoraCapeEntrance0[] = { - { 0x38, 0x00, 0x8A14 }, - { 0x38, 0x00, 0x8A14 }, + { SCENE_31MISAKI, 0, 0x8A14 }, + { SCENE_31MISAKI, 0, 0x8A14 }, }; static EntranceTableEntry sZoraCapeEntrance1[] = { - { 0x38, 0x01, 0x4993 }, - { 0x38, 0x01, 0x4993 }, + { SCENE_31MISAKI, 1, 0x4993 }, + { SCENE_31MISAKI, 1, 0x4993 }, }; static EntranceTableEntry sZoraCapeEntrance2[] = { - { 0x38, 0x02, 0x4102 }, - { 0x38, 0x02, 0x4102 }, + { SCENE_31MISAKI, 2, 0x4102 }, + { SCENE_31MISAKI, 2, 0x4102 }, }; static EntranceTableEntry sZoraCapeEntrance3[] = { - { 0x38, 0x03, 0x0993 }, - { 0x38, 0x03, 0x0993 }, + { SCENE_31MISAKI, 3, 0x0993 }, + { SCENE_31MISAKI, 3, 0x0993 }, }; static EntranceTableEntry sZoraCapeEntrance4[] = { - { 0x38, 0x04, 0x4102 }, - { 0x38, 0x04, 0x4102 }, + { SCENE_31MISAKI, 4, 0x4102 }, + { SCENE_31MISAKI, 4, 0x4102 }, }; static EntranceTableEntry sZoraCapeEntrance5[] = { - { 0x38, 0x05, 0x0102 }, - { 0x38, 0x05, 0x0102 }, + { SCENE_31MISAKI, 5, 0x0102 }, + { SCENE_31MISAKI, 5, 0x0102 }, }; static EntranceTableEntry sZoraCapeEntrance6[] = { - { 0x38, 0x06, 0x0A14 }, - { 0x38, 0x06, 0x0A14 }, + { SCENE_31MISAKI, 6, 0x0A14 }, + { SCENE_31MISAKI, 6, 0x0A14 }, }; static EntranceTableEntry sZoraCapeEntrance7[] = { - { 0x38, 0x07, 0x0A14 }, - { 0x38, 0x07, 0x0A14 }, + { SCENE_31MISAKI, 7, 0x0A14 }, + { SCENE_31MISAKI, 7, 0x0A14 }, }; static EntranceTableEntry sZoraCapeEntrance8[] = { - { 0x38, 0x08, 0x0A14 }, - { 0x38, 0x08, 0x0A14 }, + { SCENE_31MISAKI, 8, 0x0A14 }, + { SCENE_31MISAKI, 8, 0x0A14 }, }; static EntranceTableEntry sZoraCapeEntrance9[] = { - { 0x38, 0x09, 0x0A14 }, - { 0x38, 0x09, 0x0A14 }, + { SCENE_31MISAKI, 9, 0x0A14 }, + { SCENE_31MISAKI, 9, 0x0A14 }, }; static EntranceTableEntry* sZoraCapeEntranceTable[] = { @@ -1350,7 +1352,7 @@ static EntranceTableEntry* sZoraCapeEntranceTable[] = { }; static EntranceTableEntry sLotteryShopEntrance0[] = { - { 0x39, 0x00, 0x4102 }, + { SCENE_TAKARAKUJI, 0, 0x4102 }, }; static EntranceTableEntry* sLotteryShopEntranceTable[] = { @@ -1358,31 +1360,31 @@ static EntranceTableEntry* sLotteryShopEntranceTable[] = { }; static EntranceTableEntry sPiratesFortressExteriorEntrance0[] = { - { 0x3B, 0x00, 0x4993 }, + { SCENE_TORIDE, 0, 0x4993 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance1[] = { - { 0x3B, 0x01, 0x8102 }, + { SCENE_TORIDE, 1, 0x8102 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance2[] = { - { 0x3B, 0x02, 0x8993 }, + { SCENE_TORIDE, 2, 0x8993 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance3[] = { - { 0x3B, 0x03, 0x8993 }, + { SCENE_TORIDE, 3, 0x8993 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance4[] = { - { 0x3B, 0x04, 0x8102 }, + { SCENE_TORIDE, 4, 0x8102 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance5[] = { - { 0x3B, 0x05, 0x8102 }, + { SCENE_TORIDE, 5, 0x8102 }, }; static EntranceTableEntry sPiratesFortressExteriorEntrance6[] = { - { 0x3B, 0x06, 0x8102 }, + { SCENE_TORIDE, 6, 0x8102 }, }; static EntranceTableEntry* sPiratesFortressExteriorEntranceTable[] = { @@ -1392,7 +1394,7 @@ static EntranceTableEntry* sPiratesFortressExteriorEntranceTable[] = { }; static EntranceTableEntry sFishermansHutEntrance0[] = { - { 0x3C, 0x00, 0x4102 }, + { SCENE_FISHERMAN, 0, 0x4102 }, }; static EntranceTableEntry* sFishermansHutEntranceTable[] = { @@ -1400,7 +1402,7 @@ static EntranceTableEntry* sFishermansHutEntranceTable[] = { }; static EntranceTableEntry sGoronShopEntrance0[] = { - { 0x3D, 0x00, 0x4102 }, + { SCENE_GORONSHOP, 0, 0x4102 }, }; static EntranceTableEntry* sGoronShopEntranceTable[] = { @@ -1408,20 +1410,20 @@ static EntranceTableEntry* sGoronShopEntranceTable[] = { }; static EntranceTableEntry sDekuKingsChamberEntrance0[] = { - { 0xC2, 0x00, 0xC102 }, - { 0xC2, 0x00, 0x8102 }, + { -SCENE_DEKU_KING, 0, 0xC102 }, + { -SCENE_DEKU_KING, 0, 0x8102 }, }; static EntranceTableEntry sDekuKingsChamberEntrance1[] = { - { 0xC2, 0x01, 0xC102 }, + { -SCENE_DEKU_KING, 1, 0xC102 }, }; static EntranceTableEntry sDekuKingsChamberEntrance2[] = { - { 0xC2, 0x02, 0x858B }, + { -SCENE_DEKU_KING, 2, 0x858B }, }; static EntranceTableEntry sDekuKingsChamberEntrance3[] = { - { 0xC2, 0x03, 0x0102 }, + { -SCENE_DEKU_KING, 3, 0x0102 }, }; static EntranceTableEntry* sDekuKingsChamberEntranceTable[] = { @@ -1432,7 +1434,7 @@ static EntranceTableEntry* sDekuKingsChamberEntranceTable[] = { }; static EntranceTableEntry sMoonGoronTrialEntrance0[] = { - { 0xC1, 0x00, 0x0387 }, + { -SCENE_LAST_GORON, 0, 0x0387 }, }; static EntranceTableEntry* sMoonGoronTrialEntranceTable[] = { @@ -1440,15 +1442,15 @@ static EntranceTableEntry* sMoonGoronTrialEntranceTable[] = { }; static EntranceTableEntry sRoadToSouthernSwampEntrance0[] = { - { 0x40, 0x00, 0x8A14 }, + { SCENE_24KEMONOMITI, 0, 0x8A14 }, }; static EntranceTableEntry sRoadToSouthernSwampEntrance1[] = { - { 0x40, 0x01, 0x8A14 }, + { SCENE_24KEMONOMITI, 1, 0x8A14 }, }; static EntranceTableEntry sRoadToSouthernSwampEntrance2[] = { - { 0x40, 0x02, 0x0102 }, + { SCENE_24KEMONOMITI, 2, 0x0102 }, }; static EntranceTableEntry* sRoadToSouthernSwampEntranceTable[] = { @@ -1458,11 +1460,11 @@ static EntranceTableEntry* sRoadToSouthernSwampEntranceTable[] = { }; static EntranceTableEntry sDoggyRacetrackEntrance0[] = { - { 0x41, 0x00, 0xC102 }, + { SCENE_F01_B, 0, 0xC102 }, }; static EntranceTableEntry sDoggyRacetrackEntrance1[] = { - { 0x41, 0x01, 0x0A14 }, + { SCENE_F01_B, 1, 0x0A14 }, }; static EntranceTableEntry* sDoggyRacetrackEntranceTable[] = { @@ -1471,12 +1473,12 @@ static EntranceTableEntry* sDoggyRacetrackEntranceTable[] = { }; static EntranceTableEntry sCuccoShackEntrance0[] = { - { 0x42, 0x00, 0xC102 }, - { 0x42, 0x00, 0x8102 }, + { SCENE_F01C, 0, 0xC102 }, + { SCENE_F01C, 0, 0x8102 }, }; static EntranceTableEntry sCuccoShackEntrance1[] = { - { 0x42, 0x01, 0x0A14 }, + { SCENE_F01C, 1, 0x0A14 }, }; static EntranceTableEntry* sCuccoShackEntranceTable[] = { @@ -1485,28 +1487,28 @@ static EntranceTableEntry* sCuccoShackEntranceTable[] = { }; static EntranceTableEntry sIkanaGraveyardEntrance0[] = { - { 0x43, 0x00, 0x4A14 }, - { 0x43, 0x00, 0x8102 }, + { SCENE_BOTI, 0, 0x4A14 }, + { SCENE_BOTI, 0, 0x8102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance1[] = { - { 0x43, 0x01, 0x4102 }, + { SCENE_BOTI, 1, 0x4102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance2[] = { - { 0x43, 0x02, 0x4102 }, + { SCENE_BOTI, 2, 0x4102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance3[] = { - { 0x43, 0x03, 0x4102 }, + { SCENE_BOTI, 3, 0x4102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance4[] = { - { 0x43, 0x04, 0x4102 }, + { SCENE_BOTI, 4, 0x4102 }, }; static EntranceTableEntry sIkanaGraveyardEntrance5[] = { - { 0x43, 0x05, 0x058B }, + { SCENE_BOTI, 5, 0x058B }, }; static EntranceTableEntry* sIkanaGraveyardEntranceTable[] = { @@ -1515,7 +1517,7 @@ static EntranceTableEntry* sIkanaGraveyardEntranceTable[] = { }; static EntranceTableEntry sGohtsLairEntrance0[] = { - { 0xBC, 0x00, 0x8102 }, + { -SCENE_HAKUGIN_BS, 0, 0x8102 }, }; static EntranceTableEntry* sGohtsLairEntranceTable[] = { @@ -1523,47 +1525,47 @@ static EntranceTableEntry* sGohtsLairEntranceTable[] = { }; static EntranceTableEntry sSouthernSwampPoisonedEntrance0[] = { - { 0x45, 0x00, 0xCA14 }, + { SCENE_20SICHITAI, 0, 0xCA14 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance1[] = { - { 0x45, 0x01, 0x4102 }, + { SCENE_20SICHITAI, 1, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance2[] = { - { 0x45, 0x02, 0xC102 }, + { SCENE_20SICHITAI, 2, 0xC102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance3[] = { - { 0x45, 0x03, 0x4102 }, + { SCENE_20SICHITAI, 3, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance4[] = { - { 0x45, 0x04, 0x4102 }, + { SCENE_20SICHITAI, 4, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance5[] = { - { 0x45, 0x05, 0x4102 }, + { SCENE_20SICHITAI, 5, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance6[] = { - { 0x45, 0x06, 0x0102 }, + { SCENE_20SICHITAI, 6, 0x0102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance7[] = { - { 0x45, 0x07, 0x4102 }, + { SCENE_20SICHITAI, 7, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance8[] = { - { 0x45, 0x08, 0x4102 }, + { SCENE_20SICHITAI, 8, 0x4102 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance9[] = { - { 0x45, 0x09, 0x4A14 }, + { SCENE_20SICHITAI, 9, 0x4A14 }, }; static EntranceTableEntry sSouthernSwampPoisonedEntrance10[] = { - { 0x45, 0x0A, 0x4A14 }, + { SCENE_20SICHITAI, 10, 0x4A14 }, }; static EntranceTableEntry* sSouthernSwampPoisonedEntranceTable[] = { @@ -1574,33 +1576,33 @@ static EntranceTableEntry* sSouthernSwampPoisonedEntranceTable[] = { }; static EntranceTableEntry sWoodfallEntrance0[] = { - { 0x46, 0x00, 0xC102 }, - { 0x46, 0x00, 0x0183 }, - { 0x46, 0x00, 0xC102 }, + { SCENE_21MITURINMAE, 0, 0xC102 }, + { SCENE_21MITURINMAE, 0, 0x0183 }, + { SCENE_21MITURINMAE, 0, 0xC102 }, }; static EntranceTableEntry sWoodfallEntrance1[] = { - { 0x46, 0x01, 0x4102 }, - { 0x46, 0x01, 0x0183 }, - { 0x46, 0x01, 0x4102 }, + { SCENE_21MITURINMAE, 1, 0x4102 }, + { SCENE_21MITURINMAE, 1, 0x0183 }, + { SCENE_21MITURINMAE, 1, 0x4102 }, }; static EntranceTableEntry sWoodfallEntrance2[] = { - { 0x46, 0x02, 0x4102 }, - { 0x46, 0x02, 0x0183 }, - { 0x46, 0x02, 0x4102 }, + { SCENE_21MITURINMAE, 2, 0x4102 }, + { SCENE_21MITURINMAE, 2, 0x0183 }, + { SCENE_21MITURINMAE, 2, 0x4102 }, }; static EntranceTableEntry sWoodfallEntrance3[] = { - { 0x46, 0x03, 0x4102 }, - { 0x46, 0x03, 0x0183 }, - { 0x46, 0x03, 0x4102 }, + { SCENE_21MITURINMAE, 3, 0x4102 }, + { SCENE_21MITURINMAE, 3, 0x0183 }, + { SCENE_21MITURINMAE, 3, 0x4102 }, }; static EntranceTableEntry sWoodfallEntrance4[] = { - { 0x46, 0x04, 0x4102 }, - { 0x46, 0x04, 0x0183 }, - { 0x46, 0x04, 0x4102 }, + { SCENE_21MITURINMAE, 4, 0x4102 }, + { SCENE_21MITURINMAE, 4, 0x0183 }, + { SCENE_21MITURINMAE, 4, 0x4102 }, }; static EntranceTableEntry* sWoodfallEntranceTable[] = { @@ -1608,11 +1610,11 @@ static EntranceTableEntry* sWoodfallEntranceTable[] = { }; static EntranceTableEntry sMoonZoraTrialEntrance0[] = { - { 0xB9, 0x00, 0x0387 }, + { -SCENE_LAST_ZORA, 0, 0x0387 }, }; static EntranceTableEntry sMoonZoraTrialEntrance1[] = { - { 0xB9, 0x01, 0x0102 }, + { -SCENE_LAST_ZORA, 1, 0x0102 }, }; static EntranceTableEntry* sMoonZoraTrialEntranceTable[] = { @@ -1621,24 +1623,24 @@ static EntranceTableEntry* sMoonZoraTrialEntranceTable[] = { }; static EntranceTableEntry sGoronVillageSpringEntrance0[] = { - { 0x48, 0x00, 0xC102 }, - { 0x48, 0x00, 0x8102 }, + { SCENE_11GORONNOSATO2, 0, 0xC102 }, + { SCENE_11GORONNOSATO2, 0, 0x8102 }, }; static EntranceTableEntry sGoronVillageSpringEntrance1[] = { - { 0x48, 0x01, 0x4102 }, + { SCENE_11GORONNOSATO2, 1, 0x4102 }, }; static EntranceTableEntry sGoronVillageSpringEntrance2[] = { - { 0x48, 0x02, 0x4102 }, + { SCENE_11GORONNOSATO2, 2, 0x4102 }, }; static EntranceTableEntry sGoronVillageSpringEntrance3[] = { - { 0x48, 0x03, 0x4102 }, + { SCENE_11GORONNOSATO2, 3, 0x4102 }, }; static EntranceTableEntry sGoronVillageSpringEntrance4[] = { - { 0x48, 0x04, 0x0A14 }, + { SCENE_11GORONNOSATO2, 4, 0x0A14 }, }; static EntranceTableEntry* sGoronVillageSpringEntranceTable[] = { @@ -1647,15 +1649,15 @@ static EntranceTableEntry* sGoronVillageSpringEntranceTable[] = { }; static EntranceTableEntry sGreatBayTempleEntrance0[] = { - { 0xB7, 0x00, 0x4102 }, + { -SCENE_SEA, 0, 0x4102 }, }; static EntranceTableEntry sGreatBayTempleEntrance1[] = { - { 0xB7, 0x01, 0x0102 }, + { -SCENE_SEA, 1, 0x0102 }, }; static EntranceTableEntry sGreatBayTempleEntrance2[] = { - { 0xB7, 0x02, 0x0102 }, + { -SCENE_SEA, 2, 0x0102 }, }; static EntranceTableEntry* sGreatBayTempleEntranceTable[] = { @@ -1665,19 +1667,19 @@ static EntranceTableEntry* sGreatBayTempleEntranceTable[] = { }; static EntranceTableEntry sWaterfallRapidsEntrance0[] = { - { 0x4A, 0x00, 0x4102 }, + { SCENE_35TAKI, 0, 0x4102 }, }; static EntranceTableEntry sWaterfallRapidsEntrance1[] = { - { 0x4A, 0x01, 0x0A14 }, + { SCENE_35TAKI, 1, 0x0A14 }, }; static EntranceTableEntry sWaterfallRapidsEntrance2[] = { - { 0x4A, 0x02, 0x0A14 }, + { SCENE_35TAKI, 2, 0x0A14 }, }; static EntranceTableEntry sWaterfallRapidsEntrance3[] = { - { 0x4A, 0x03, 0x0A14 }, + { SCENE_35TAKI, 3, 0x0A14 }, }; static EntranceTableEntry* sWaterfallRapidsEntranceTable[] = { @@ -1688,11 +1690,11 @@ static EntranceTableEntry* sWaterfallRapidsEntranceTable[] = { }; static EntranceTableEntry sBeneathTheWellEntrance0[] = { - { 0xB5, 0x00, 0x4102 }, + { -SCENE_REDEAD, 0, 0x4102 }, }; static EntranceTableEntry sBeneathTheWellEntrance1[] = { - { 0xB5, 0x01, 0x4102 }, + { -SCENE_REDEAD, 1, 0x4102 }, }; static EntranceTableEntry* sBeneathTheWellEntranceTable[] = { @@ -1701,31 +1703,31 @@ static EntranceTableEntry* sBeneathTheWellEntranceTable[] = { }; static EntranceTableEntry sZoraHallRoomsEntrance0[] = { - { 0x4C, 0x00, 0x0102 }, + { SCENE_BANDROOM, 0, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance1[] = { - { 0x4C, 0x01, 0x0102 }, + { SCENE_BANDROOM, 1, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance2[] = { - { 0x4C, 0x02, 0x0102 }, + { SCENE_BANDROOM, 2, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance3[] = { - { 0x4C, 0x03, 0x0102 }, + { SCENE_BANDROOM, 3, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance4[] = { - { 0x4C, 0x04, 0x858B }, + { SCENE_BANDROOM, 4, 0x858B }, }; static EntranceTableEntry sZoraHallRoomsEntrance5[] = { - { 0x4C, 0x05, 0x0102 }, + { SCENE_BANDROOM, 5, 0x0102 }, }; static EntranceTableEntry sZoraHallRoomsEntrance6[] = { - { 0x4C, 0x06, 0x0102 }, + { SCENE_BANDROOM, 6, 0x0102 }, }; static EntranceTableEntry* sZoraHallRoomsEntranceTable[] = { @@ -1734,23 +1736,23 @@ static EntranceTableEntry* sZoraHallRoomsEntranceTable[] = { }; static EntranceTableEntry sGoronVillageWinterEntrance0[] = { - { 0x4D, 0x00, 0xC102 }, + { SCENE_11GORONNOSATO, 0, 0xC102 }, }; static EntranceTableEntry sGoronVillageWinterEntrance1[] = { - { 0x4D, 0x01, 0x4102 }, + { SCENE_11GORONNOSATO, 1, 0x4102 }, }; static EntranceTableEntry sGoronVillageWinterEntrance2[] = { - { 0x4D, 0x02, 0x4102 }, + { SCENE_11GORONNOSATO, 2, 0x4102 }, }; static EntranceTableEntry sGoronVillageWinterEntrance3[] = { - { 0x4D, 0x03, 0x4102 }, + { SCENE_11GORONNOSATO, 3, 0x4102 }, }; static EntranceTableEntry sGoronVillageWinterEntrance4[] = { - { 0x4D, 0x04, 0x0A14 }, + { SCENE_11GORONNOSATO, 4, 0x0A14 }, }; static EntranceTableEntry* sGoronVillageWinterEntranceTable[] = { @@ -1759,11 +1761,11 @@ static EntranceTableEntry* sGoronVillageWinterEntranceTable[] = { }; static EntranceTableEntry sGoronGraveryardEntrance0[] = { - { 0x4E, 0x00, 0x4102 }, + { SCENE_GORON_HAKA, 0, 0x4102 }, }; static EntranceTableEntry sGoronGraveryardEntrance1[] = { - { 0x4E, 0x01, 0x058B }, + { SCENE_GORON_HAKA, 1, 0x058B }, }; static EntranceTableEntry* sGoronGraveryardEntranceTable[] = { @@ -1772,7 +1774,7 @@ static EntranceTableEntry* sGoronGraveryardEntranceTable[] = { }; static EntranceTableEntry sSakonsHideoutEntrance0[] = { - { 0x4F, 0x00, 0x4102 }, + { SCENE_SECOM, 0, 0x4102 }, }; static EntranceTableEntry* sSakonsHideoutEntranceTable[] = { @@ -1780,39 +1782,39 @@ static EntranceTableEntry* sSakonsHideoutEntranceTable[] = { }; static EntranceTableEntry sMountainVillageWinterEntrance0[] = { - { 0x50, 0x00, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA, 0, 0x4A14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance1[] = { - { 0x50, 0x01, 0x4102 }, + { SCENE_10YUKIYAMANOMURA, 1, 0x4102 }, }; static EntranceTableEntry sMountainVillageWinterEntrance2[] = { - { 0x50, 0x02, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA, 2, 0xCA14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance3[] = { - { 0x50, 0x03, 0x4102 }, + { SCENE_10YUKIYAMANOMURA, 3, 0x4102 }, }; static EntranceTableEntry sMountainVillageWinterEntrance4[] = { - { 0x50, 0x04, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA, 4, 0xCA14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance5[] = { - { 0x50, 0x05, 0x4102 }, + { SCENE_10YUKIYAMANOMURA, 5, 0x4102 }, }; static EntranceTableEntry sMountainVillageWinterEntrance6[] = { - { 0x50, 0x06, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA, 6, 0x4A14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance7[] = { - { 0x50, 0x07, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA, 7, 0x4A14 }, }; static EntranceTableEntry sMountainVillageWinterEntrance8[] = { - { 0x50, 0x08, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA, 8, 0x4A14 }, }; static EntranceTableEntry* sMountainVillageWinterEntranceTable[] = { @@ -1822,15 +1824,15 @@ static EntranceTableEntry* sMountainVillageWinterEntranceTable[] = { }; static EntranceTableEntry sGhostHutEntrance0[] = { - { 0x51, 0x00, 0x4102 }, + { SCENE_TOUGITES, 0, 0x4102 }, }; static EntranceTableEntry sGhostHutEntrance1[] = { - { 0x51, 0x01, 0x0102 }, + { SCENE_TOUGITES, 1, 0x0102 }, }; static EntranceTableEntry sGhostHutEntrance2[] = { - { 0x51, 0x02, 0x0102 }, + { SCENE_TOUGITES, 2, 0x0102 }, }; static EntranceTableEntry* sGhostHutEntranceTable[] = { @@ -1840,15 +1842,15 @@ static EntranceTableEntry* sGhostHutEntranceTable[] = { }; static EntranceTableEntry sDekuShrineEntrance0[] = { - { 0x52, 0x00, 0x4102 }, + { SCENE_DANPEI, 0, 0x4102 }, }; static EntranceTableEntry sDekuShrineEntrance1[] = { - { 0x52, 0x01, 0x0102 }, + { SCENE_DANPEI, 1, 0x0102 }, }; static EntranceTableEntry sDekuShrineEntrance2[] = { - { 0x52, 0x02, 0x0102 }, + { SCENE_DANPEI, 2, 0x0102 }, }; static EntranceTableEntry* sDekuShrineEntranceTable[] = { @@ -1858,15 +1860,15 @@ static EntranceTableEntry* sDekuShrineEntranceTable[] = { }; static EntranceTableEntry sRoadToIkanaEntrance0[] = { - { 0x53, 0x00, 0x8A14 }, + { SCENE_IKANAMAE, 0, 0x8A14 }, }; static EntranceTableEntry sRoadToIkanaEntrance1[] = { - { 0x53, 0x01, 0x8A14 }, + { SCENE_IKANAMAE, 1, 0x8A14 }, }; static EntranceTableEntry sRoadToIkanaEntrance2[] = { - { 0x53, 0x02, 0x0A14 }, + { SCENE_IKANAMAE, 2, 0x0A14 }, }; static EntranceTableEntry* sRoadToIkanaEntranceTable[] = { @@ -1876,7 +1878,7 @@ static EntranceTableEntry* sRoadToIkanaEntranceTable[] = { }; static EntranceTableEntry sMusicBoxHouseEntrance0[] = { - { 0x55, 0x00, 0x4102 }, + { SCENE_MUSICHOUSE, 0, 0x4102 }, }; static EntranceTableEntry* sMusicBoxHouseEntranceTable[] = { @@ -1884,8 +1886,8 @@ static EntranceTableEntry* sMusicBoxHouseEntranceTable[] = { }; static EntranceTableEntry sIgosDuIkanasLairEntrance0[] = { - { 0xAA, 0x00, 0x8102 }, - { 0xAA, 0x00, 0x8102 }, + { -SCENE_IKNINSIDE, 0, 0x8102 }, + { -SCENE_IKNINSIDE, 0, 0x8102 }, }; static EntranceTableEntry* sIgosDuIkanasLairEntranceTable[] = { @@ -1893,7 +1895,7 @@ static EntranceTableEntry* sIgosDuIkanasLairEntranceTable[] = { }; static EntranceTableEntry sSwordmansSchoolEntrance0[] = { - { 0x54, 0x00, 0x4102 }, + { SCENE_DOUJOU, 0, 0x4102 }, }; static EntranceTableEntry* sSwordmansSchoolEntranceTable[] = { @@ -1901,15 +1903,15 @@ static EntranceTableEntry* sSwordmansSchoolEntranceTable[] = { }; static EntranceTableEntry sTouristInformationEntrance0[] = { - { 0x57, 0x00, 0x4102 }, + { SCENE_MAP_SHOP, 0, 0x4102 }, }; static EntranceTableEntry sTouristInformationEntrance1[] = { - { 0x57, 0x01, 0x0102 }, + { SCENE_MAP_SHOP, 1, 0x0102 }, }; static EntranceTableEntry sTouristInformationEntrance2[] = { - { 0x57, 0x02, 0x0102 }, + { SCENE_MAP_SHOP, 2, 0x0102 }, }; static EntranceTableEntry* sTouristInformationEntranceTable[] = { @@ -1919,19 +1921,19 @@ static EntranceTableEntry* sTouristInformationEntranceTable[] = { }; static EntranceTableEntry sStoneTowerEntrance0[] = { - { 0x58, 0x00, 0x4102 }, + { SCENE_F40, 0, 0x4102 }, }; static EntranceTableEntry sStoneTowerEntrance1[] = { - { 0x58, 0x01, 0xCA14 }, + { SCENE_F40, 1, 0xCA14 }, }; static EntranceTableEntry sStoneTowerEntrance2[] = { - { 0x58, 0x02, 0xC102 }, + { SCENE_F40, 2, 0xC102 }, }; static EntranceTableEntry sStoneTowerEntrance3[] = { - { 0x58, 0x03, 0x4A14 }, + { SCENE_F40, 3, 0x4A14 }, }; static EntranceTableEntry* sStoneTowerEntranceTable[] = { @@ -1942,11 +1944,11 @@ static EntranceTableEntry* sStoneTowerEntranceTable[] = { }; static EntranceTableEntry sStoneTowerInvertedEntrance0[] = { - { 0x59, 0x00, 0x4A14 }, + { SCENE_F41, 0, 0x4A14 }, }; static EntranceTableEntry sStoneTowerInvertedEntrance1[] = { - { 0x59, 0x01, 0xC102 }, + { SCENE_F41, 1, 0xC102 }, }; static EntranceTableEntry* sStoneTowerInvertedEntranceTable[] = { @@ -1955,40 +1957,40 @@ static EntranceTableEntry* sStoneTowerInvertedEntranceTable[] = { }; static EntranceTableEntry sMountainVillageSpringEntrance0[] = { - { 0x5A, 0x00, 0x4A14 }, - { 0x5A, 0x00, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA2, 0, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA2, 0, 0x4A14 }, }; static EntranceTableEntry sMountainVillageSpringEntrance1[] = { - { 0x5A, 0x01, 0x4102 }, + { SCENE_10YUKIYAMANOMURA2, 1, 0x4102 }, }; static EntranceTableEntry sMountainVillageSpringEntrance2[] = { - { 0x5A, 0x02, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA2, 2, 0xCA14 }, }; static EntranceTableEntry sMountainVillageSpringEntrance3[] = { - { 0x5A, 0x03, 0x4102 }, + { SCENE_10YUKIYAMANOMURA2, 3, 0x4102 }, }; static EntranceTableEntry sMountainVillageSpringEntrance4[] = { - { 0x5A, 0x04, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA2, 4, 0xCA14 }, }; static EntranceTableEntry sMountainVillageSpringEntrance5[] = { - { 0x5A, 0x05, 0x4102 }, + { SCENE_10YUKIYAMANOMURA2, 5, 0x4102 }, }; static EntranceTableEntry sMountainVillageSpringEntrance6[] = { - { 0x5A, 0x06, 0xCA14 }, + { SCENE_10YUKIYAMANOMURA2, 6, 0xCA14 }, }; static EntranceTableEntry sMountainVillageSpringEntrance7[] = { - { 0x5A, 0x07, 0x458B }, + { SCENE_10YUKIYAMANOMURA2, 7, 0x458B }, }; static EntranceTableEntry sMountainVillageSpringEntrance8[] = { - { 0x5A, 0x08, 0x4A14 }, + { SCENE_10YUKIYAMANOMURA2, 8, 0x4A14 }, }; static EntranceTableEntry* sMountainVillageSpringEntranceTable[] = { @@ -1998,13 +2000,13 @@ static EntranceTableEntry* sMountainVillageSpringEntranceTable[] = { }; static EntranceTableEntry sPathToSnowheadEntrance0[] = { - { 0x5B, 0x00, 0xCA14 }, - { 0x5B, 0x00, 0xCA14 }, + { SCENE_14YUKIDAMANOMITI, 0, 0xCA14 }, + { SCENE_14YUKIDAMANOMITI, 0, 0xCA14 }, }; static EntranceTableEntry sPathToSnowheadEntrance1[] = { - { 0x5B, 0x01, 0xCA14 }, - { 0x5B, 0x01, 0xCA14 }, + { SCENE_14YUKIDAMANOMITI, 1, 0xCA14 }, + { SCENE_14YUKIDAMANOMITI, 1, 0xCA14 }, }; static EntranceTableEntry* sPathToSnowheadEntranceTable[] = { @@ -2013,23 +2015,23 @@ static EntranceTableEntry* sPathToSnowheadEntranceTable[] = { }; static EntranceTableEntry sSnowheadEntrance0[] = { - { 0x5C, 0x00, 0xCA14 }, - { 0x5C, 0x00, 0xCA14 }, + { SCENE_12HAKUGINMAE, 0, 0xCA14 }, + { SCENE_12HAKUGINMAE, 0, 0xCA14 }, }; static EntranceTableEntry sSnowheadEntrance1[] = { - { 0x5C, 0x01, 0x4102 }, - { 0x5C, 0x01, 0x4102 }, + { SCENE_12HAKUGINMAE, 1, 0x4102 }, + { SCENE_12HAKUGINMAE, 1, 0x4102 }, }; static EntranceTableEntry sSnowheadEntrance2[] = { - { 0x5C, 0x02, 0x4102 }, - { 0x5C, 0x02, 0x4102 }, + { SCENE_12HAKUGINMAE, 2, 0x4102 }, + { SCENE_12HAKUGINMAE, 2, 0x4102 }, }; static EntranceTableEntry sSnowheadEntrance3[] = { - { 0x5C, 0x03, 0x4102 }, - { 0x5C, 0x03, 0x4102 }, + { SCENE_12HAKUGINMAE, 3, 0x4102 }, + { SCENE_12HAKUGINMAE, 3, 0x4102 }, }; static EntranceTableEntry* sSnowheadEntranceTable[] = { @@ -2040,15 +2042,15 @@ static EntranceTableEntry* sSnowheadEntranceTable[] = { }; static EntranceTableEntry sPathToGoronVillageWinterEntrance0[] = { - { 0x5D, 0x00, 0x8A14 }, + { SCENE_17SETUGEN, 0, 0x8A14 }, }; static EntranceTableEntry sPathToGoronVillageWinterEntrance1[] = { - { 0x5D, 0x01, 0x8102 }, + { SCENE_17SETUGEN, 1, 0x8102 }, }; static EntranceTableEntry sPathToGoronVillageWinterEntrance2[] = { - { 0x5D, 0x02, 0x0102 }, + { SCENE_17SETUGEN, 2, 0x0102 }, }; static EntranceTableEntry* sPathToGoronVillageWinterEntranceTable[] = { @@ -2058,15 +2060,15 @@ static EntranceTableEntry* sPathToGoronVillageWinterEntranceTable[] = { }; static EntranceTableEntry sPathToGoronVillageSpringEntrance0[] = { - { 0x5E, 0x00, 0x8A14 }, + { SCENE_17SETUGEN2, 0, 0x8A14 }, }; static EntranceTableEntry sPathToGoronVillageSpringEntrance1[] = { - { 0x5E, 0x01, 0x8102 }, + { SCENE_17SETUGEN2, 1, 0x8102 }, }; static EntranceTableEntry sPathToGoronVillageSpringEntrance2[] = { - { 0x5E, 0x02, 0x0102 }, + { SCENE_17SETUGEN2, 2, 0x0102 }, }; static EntranceTableEntry* sPathToGoronVillageSpringEntranceTable[] = { @@ -2076,11 +2078,11 @@ static EntranceTableEntry* sPathToGoronVillageSpringEntranceTable[] = { }; static EntranceTableEntry sGyorgsLairEntrance0[] = { - { 0xA1, 0x00, 0x8102 }, + { -SCENE_SEA_BS, 0, 0x8102 }, }; static EntranceTableEntry sGyorgsLairEntrance1[] = { - { 0xA1, 0x01, 0x8102 }, + { -SCENE_SEA_BS, 1, 0x8102 }, }; static EntranceTableEntry* sGyorgsLairEntranceTable[] = { @@ -2089,7 +2091,7 @@ static EntranceTableEntry* sGyorgsLairEntranceTable[] = { }; static EntranceTableEntry sSecretShrineEntrance0[] = { - { 0xA0, 0x00, 0x4102 }, + { -SCENE_RANDOM, 0, 0x4102 }, }; static EntranceTableEntry* sSecretShrineEntranceTable[] = { @@ -2097,28 +2099,28 @@ static EntranceTableEntry* sSecretShrineEntranceTable[] = { }; static EntranceTableEntry sStockPotInnEntrance0[] = { - { 0x61, 0x00, 0x4102 }, - { 0x61, 0x00, 0x8102 }, + { SCENE_YADOYA, 0, 0x4102 }, + { SCENE_YADOYA, 0, 0x8102 }, }; static EntranceTableEntry sStockPotInnEntrance1[] = { - { 0x61, 0x01, 0x4102 }, + { SCENE_YADOYA, 1, 0x4102 }, }; static EntranceTableEntry sStockPotInnEntrance2[] = { - { 0x61, 0x02, 0x0102 }, + { SCENE_YADOYA, 2, 0x0102 }, }; static EntranceTableEntry sStockPotInnEntrance3[] = { - { 0x61, 0x03, 0x0102 }, + { SCENE_YADOYA, 3, 0x0102 }, }; static EntranceTableEntry sStockPotInnEntrance4[] = { - { 0x61, 0x04, 0x0102 }, + { SCENE_YADOYA, 4, 0x0102 }, }; static EntranceTableEntry sStockPotInnEntrance5[] = { - { 0x61, 0x05, 0x0102 }, + { SCENE_YADOYA, 5, 0x0102 }, }; static EntranceTableEntry* sStockPotInnEntranceTable[] = { @@ -2127,7 +2129,7 @@ static EntranceTableEntry* sStockPotInnEntranceTable[] = { }; static EntranceTableEntry sGreatBayCutsceneEntrance0[] = { - { 0x62, 0x00, 0x4102 }, + { SCENE_KONPEKI_ENT, 0, 0x4102 }, }; static EntranceTableEntry* sGreatBayCutsceneEntranceTable[] = { @@ -2135,31 +2137,31 @@ static EntranceTableEntry* sGreatBayCutsceneEntranceTable[] = { }; static EntranceTableEntry sClockTowerInteriorEntrance0[] = { - { 0x63, 0x00, 0x0102 }, + { SCENE_INSIDETOWER, 0, 0x0102 }, }; static EntranceTableEntry sClockTowerInteriorEntrance1[] = { - { 0x63, 0x01, 0x0102 }, + { SCENE_INSIDETOWER, 1, 0x0102 }, }; static EntranceTableEntry sClockTowerInteriorEntrance2[] = { - { 0x63, 0x02, 0x058B }, + { SCENE_INSIDETOWER, 2, 0x058B }, }; static EntranceTableEntry sClockTowerInteriorEntrance3[] = { - { 0x63, 0x03, 0x0102 }, + { SCENE_INSIDETOWER, 3, 0x0102 }, }; static EntranceTableEntry sClockTowerInteriorEntrance4[] = { - { 0x63, 0x04, 0x058B }, + { SCENE_INSIDETOWER, 4, 0x058B }, }; static EntranceTableEntry sClockTowerInteriorEntrance5[] = { - { 0x63, 0x05, 0x0102 }, + { SCENE_INSIDETOWER, 5, 0x0102 }, }; static EntranceTableEntry sClockTowerInteriorEntrance6[] = { - { 0x63, 0x06, 0x858B }, + { SCENE_INSIDETOWER, 6, 0x858B }, }; static EntranceTableEntry* sClockTowerInteriorEntranceTable[] = { @@ -2169,7 +2171,7 @@ static EntranceTableEntry* sClockTowerInteriorEntranceTable[] = { }; static EntranceTableEntry sWoodsOfMysteryEntrance0[] = { - { 0x64, 0x00, 0x4102 }, + { SCENE_26SARUNOMORI, 0, 0x4102 }, }; static EntranceTableEntry* sWoodsOfMysteryEntranceTable[] = { @@ -2177,24 +2179,24 @@ static EntranceTableEntry* sWoodsOfMysteryEntranceTable[] = { }; static EntranceTableEntry sLostWoodsEntrance0[] = { - { 0x9B, 0x00, 0x858B }, - { 0x9B, 0x00, 0x8183 }, - { 0x9B, 0x00, 0x858B }, - { 0x9B, 0x00, 0x8102 }, + { -SCENE_LOST_WOODS, 0, 0x858B }, + { -SCENE_LOST_WOODS, 0, 0x8183 }, + { -SCENE_LOST_WOODS, 0, 0x858B }, + { -SCENE_LOST_WOODS, 0, 0x8102 }, }; static EntranceTableEntry sLostWoodsEntrance1[] = { - { 0x9B, 0x01, 0x058B }, - { 0x9B, 0x01, 0x058B }, - { 0x9B, 0x01, 0x058B }, - { 0x9B, 0x01, 0x058B }, + { -SCENE_LOST_WOODS, 1, 0x058B }, + { -SCENE_LOST_WOODS, 1, 0x058B }, + { -SCENE_LOST_WOODS, 1, 0x058B }, + { -SCENE_LOST_WOODS, 1, 0x058B }, }; static EntranceTableEntry sLostWoodsEntrance2[] = { - { 0x9B, 0x02, 0x058B }, - { 0x9B, 0x02, 0x058B }, - { 0x9B, 0x02, 0x058B }, - { 0x9B, 0x02, 0x058B }, + { -SCENE_LOST_WOODS, 2, 0x058B }, + { -SCENE_LOST_WOODS, 2, 0x058B }, + { -SCENE_LOST_WOODS, 2, 0x058B }, + { -SCENE_LOST_WOODS, 2, 0x058B }, }; static EntranceTableEntry* sLostWoodsEntranceTable[] = { @@ -2204,7 +2206,7 @@ static EntranceTableEntry* sLostWoodsEntranceTable[] = { }; static EntranceTableEntry sMoonLinkTrialEntrance0[] = { - { 0x66, 0x00, 0x0387 }, + { SCENE_LAST_LINK, 0, 0x0387 }, }; static EntranceTableEntry* sMoonLinkTrialEntranceTable[] = { @@ -2212,7 +2214,7 @@ static EntranceTableEntry* sMoonLinkTrialEntranceTable[] = { }; static EntranceTableEntry sTheMoonEntrance0[] = { - { 0x67, 0x00, 0x0387 }, + { SCENE_SOUGEN, 0, 0x0387 }, }; static EntranceTableEntry* sTheMoonEntranceTable[] = { @@ -2220,11 +2222,11 @@ static EntranceTableEntry* sTheMoonEntranceTable[] = { }; static EntranceTableEntry sBombShopEntrance0[] = { - { 0x68, 0x00, 0x4102 }, + { SCENE_BOMYA, 0, 0x4102 }, }; static EntranceTableEntry sBombShopEntrance1[] = { - { 0x68, 0x01, 0x0102 }, + { SCENE_BOMYA, 1, 0x0102 }, }; static EntranceTableEntry* sBombShopEntranceTable[] = { @@ -2233,9 +2235,10 @@ static EntranceTableEntry* sBombShopEntranceTable[] = { }; static EntranceTableEntry sGiantsChamberEntrance0[] = { - { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, - { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, - { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, { 0x69, 0x00, 0x0102 }, + { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, + { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, + { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, + { SCENE_KYOJINNOMA, 0, 0x0102 }, { SCENE_KYOJINNOMA, 0, 0x0102 }, }; static EntranceTableEntry* sGiantsChamberEntranceTable[] = { @@ -2243,27 +2246,27 @@ static EntranceTableEntry* sGiantsChamberEntranceTable[] = { }; static EntranceTableEntry sGormanTrackEntrance0[] = { - { 0x6A, 0x00, 0x4A14 }, + { SCENE_KOEPONARACE, 0, 0x4A14 }, }; static EntranceTableEntry sGormanTrackEntrance1[] = { - { 0x6A, 0x01, 0x4A14 }, + { SCENE_KOEPONARACE, 1, 0x4A14 }, }; static EntranceTableEntry sGormanTrackEntrance2[] = { - { 0x6A, 0x02, 0x4A14 }, + { SCENE_KOEPONARACE, 2, 0x4A14 }, }; static EntranceTableEntry sGormanTrackEntrance3[] = { - { 0x6A, 0x03, 0x4A14 }, + { SCENE_KOEPONARACE, 3, 0x4A14 }, }; static EntranceTableEntry sGormanTrackEntrance4[] = { - { 0x6A, 0x04, 0x0102 }, + { SCENE_KOEPONARACE, 4, 0x0102 }, }; static EntranceTableEntry sGormanTrackEntrance5[] = { - { 0x6A, 0x05, 0x0A14 }, + { SCENE_KOEPONARACE, 5, 0x0A14 }, }; static EntranceTableEntry* sGormanTrackEntranceTable[] = { @@ -2272,18 +2275,18 @@ static EntranceTableEntry* sGormanTrackEntranceTable[] = { }; static EntranceTableEntry sGoronRacetrackEntrance0[] = { - { 0x6B, 0x00, 0x4102 }, - { 0x6B, 0x00, 0x4102 }, + { SCENE_GORONRACE, 0, 0x4102 }, + { SCENE_GORONRACE, 0, 0x4102 }, }; static EntranceTableEntry sGoronRacetrackEntrance1[] = { - { 0x6B, 0x01, 0x8A14 }, - { 0x6B, 0x01, 0x8A14 }, + { SCENE_GORONRACE, 1, 0x8A14 }, + { SCENE_GORONRACE, 1, 0x8A14 }, }; static EntranceTableEntry sGoronRacetrackEntrance2[] = { - { 0x6B, 0x02, 0x0A14 }, - { 0x6B, 0x02, 0x0A14 }, + { SCENE_GORONRACE, 2, 0x0A14 }, + { SCENE_GORONRACE, 2, 0x0A14 }, }; static EntranceTableEntry* sGoronRacetrackEntranceTable[] = { @@ -2293,57 +2296,57 @@ static EntranceTableEntry* sGoronRacetrackEntranceTable[] = { }; static EntranceTableEntry sEastClockTownEntrance0[] = { - { 0x6C, 0x00, 0x4102 }, - { 0x6C, 0x00, 0x8102 }, - { 0x6C, 0x00, 0x058B }, + { SCENE_TOWN, 0, 0x4102 }, + { SCENE_TOWN, 0, 0x8102 }, + { SCENE_TOWN, 0, 0x058B }, }; static EntranceTableEntry sEastClockTownEntrance1[] = { - { 0x6C, 0x01, 0xCA14 }, + { SCENE_TOWN, 1, 0xCA14 }, }; static EntranceTableEntry sEastClockTownEntrance2[] = { - { 0x6C, 0x02, 0x4102 }, + { SCENE_TOWN, 2, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance3[] = { - { 0x6C, 0x03, 0xC102 }, + { SCENE_TOWN, 3, 0xC102 }, }; static EntranceTableEntry sEastClockTownEntrance4[] = { - { 0x6C, 0x04, 0x4102 }, + { SCENE_TOWN, 4, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance5[] = { - { 0x6C, 0x05, 0xC102 }, + { SCENE_TOWN, 5, 0xC102 }, }; static EntranceTableEntry sEastClockTownEntrance6[] = { - { 0x6C, 0x06, 0x4102 }, + { SCENE_TOWN, 6, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance7[] = { - { 0x6C, 0x07, 0x4102 }, + { SCENE_TOWN, 7, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance8[] = { - { 0x6C, 0x08, 0x4102 }, + { SCENE_TOWN, 8, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance9[] = { - { 0x6C, 0x09, 0x4102 }, + { SCENE_TOWN, 9, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance10[] = { - { 0x6C, 0x0A, 0x4102 }, + { SCENE_TOWN, 10, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance11[] = { - { 0x6C, 0x0B, 0x4102 }, + { SCENE_TOWN, 11, 0x4102 }, }; static EntranceTableEntry sEastClockTownEntrance12[] = { - { 0x6C, 0x0C, 0x4102 }, + { SCENE_TOWN, 12, 0x4102 }, }; static EntranceTableEntry* sEastClockTownEntranceTable[] = { @@ -2354,44 +2357,44 @@ static EntranceTableEntry* sEastClockTownEntranceTable[] = { }; static EntranceTableEntry sWestClockTownEntrance0[] = { - { 0x6D, 0x00, 0x4102 }, - { 0x6D, 0x00, 0x8102 }, + { SCENE_ICHIBA, 0, 0x4102 }, + { SCENE_ICHIBA, 0, 0x8102 }, }; static EntranceTableEntry sWestClockTownEntrance1[] = { - { 0x6D, 0x01, 0xC102 }, + { SCENE_ICHIBA, 1, 0xC102 }, }; static EntranceTableEntry sWestClockTownEntrance2[] = { - { 0x6D, 0x02, 0xCA14 }, + { SCENE_ICHIBA, 2, 0xCA14 }, }; static EntranceTableEntry sWestClockTownEntrance3[] = { - { 0x6D, 0x03, 0x4102 }, + { SCENE_ICHIBA, 3, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance4[] = { - { 0x6D, 0x04, 0x4102 }, + { SCENE_ICHIBA, 4, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance5[] = { - { 0x6D, 0x05, 0x4102 }, + { SCENE_ICHIBA, 5, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance6[] = { - { 0x6D, 0x06, 0x4102 }, + { SCENE_ICHIBA, 6, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance7[] = { - { 0x6D, 0x07, 0x4102 }, + { SCENE_ICHIBA, 7, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance8[] = { - { 0x6D, 0x08, 0x4102 }, + { SCENE_ICHIBA, 8, 0x4102 }, }; static EntranceTableEntry sWestClockTownEntrance9[] = { - { 0x6D, 0x09, 0x4A14 }, + { SCENE_ICHIBA, 9, 0x4A14 }, }; static EntranceTableEntry* sWestClockTownEntranceTable[] = { @@ -2401,36 +2404,36 @@ static EntranceTableEntry* sWestClockTownEntranceTable[] = { }; static EntranceTableEntry sNorthClockTownEntrance0[] = { - { 0x6E, 0x00, 0x4102 }, - { 0x6E, 0x00, 0x458B }, + { SCENE_BACKTOWN, 0, 0x4102 }, + { SCENE_BACKTOWN, 0, 0x458B }, }; static EntranceTableEntry sNorthClockTownEntrance1[] = { - { 0x6E, 0x01, 0xC102 }, + { SCENE_BACKTOWN, 1, 0xC102 }, }; static EntranceTableEntry sNorthClockTownEntrance2[] = { - { 0x6E, 0x02, 0xC102 }, + { SCENE_BACKTOWN, 2, 0xC102 }, }; static EntranceTableEntry sNorthClockTownEntrance3[] = { - { 0x6E, 0x03, 0x4102 }, + { SCENE_BACKTOWN, 3, 0x4102 }, }; static EntranceTableEntry sNorthClockTownEntrance4[] = { - { 0x6E, 0x04, 0x4102 }, + { SCENE_BACKTOWN, 4, 0x4102 }, }; static EntranceTableEntry sNorthClockTownEntrance5[] = { - { 0x6E, 0x05, 0x8A14 }, + { SCENE_BACKTOWN, 5, 0x8A14 }, }; static EntranceTableEntry sNorthClockTownEntrance6[] = { - { 0x6E, 0x06, 0x8A14 }, + { SCENE_BACKTOWN, 6, 0x8A14 }, }; static EntranceTableEntry sNorthClockTownEntrance7[] = { - { 0x6E, 0x07, 0x8A14 }, + { SCENE_BACKTOWN, 7, 0x8A14 }, }; static EntranceTableEntry* sNorthClockTownEntranceTable[] = { @@ -2439,51 +2442,51 @@ static EntranceTableEntry* sNorthClockTownEntranceTable[] = { }; static EntranceTableEntry sSouthClockTownEntrance0[] = { - { 0x6F, 0x00, 0x4102 }, - { 0x6F, 0x00, 0x8102 }, - { 0x6F, 0x00, 0x0A14 }, - { 0x6F, 0x00, 0x0102 }, + { SCENE_CLOCKTOWER, 0, 0x4102 }, + { SCENE_CLOCKTOWER, 0, 0x8102 }, + { SCENE_CLOCKTOWER, 0, 0x0A14 }, + { SCENE_CLOCKTOWER, 0, 0x0102 }, }; static EntranceTableEntry sSouthClockTownEntrance1[] = { - { 0x6F, 0x01, 0x4102 }, - { 0x6F, 0x01, 0x8102 }, + { SCENE_CLOCKTOWER, 1, 0x4102 }, + { SCENE_CLOCKTOWER, 1, 0x8102 }, }; static EntranceTableEntry sSouthClockTownEntrance2[] = { - { 0x6F, 0x02, 0xC102 }, + { SCENE_CLOCKTOWER, 2, 0xC102 }, }; static EntranceTableEntry sSouthClockTownEntrance3[] = { - { 0x6F, 0x03, 0xCA14 }, + { SCENE_CLOCKTOWER, 3, 0xCA14 }, }; static EntranceTableEntry sSouthClockTownEntrance4[] = { - { 0x6F, 0x04, 0xC102 }, + { SCENE_CLOCKTOWER, 4, 0xC102 }, }; static EntranceTableEntry sSouthClockTownEntrance5[] = { - { 0x6F, 0x05, 0xC102 }, + { SCENE_CLOCKTOWER, 5, 0xC102 }, }; static EntranceTableEntry sSouthClockTownEntrance6[] = { - { 0x6F, 0x06, 0xCA14 }, + { SCENE_CLOCKTOWER, 6, 0xCA14 }, }; static EntranceTableEntry sSouthClockTownEntrance7[] = { - { 0x6F, 0x07, 0xCA14 }, + { SCENE_CLOCKTOWER, 7, 0xCA14 }, }; static EntranceTableEntry sSouthClockTownEntrance8[] = { - { 0x6F, 0x08, 0x4A14 }, + { SCENE_CLOCKTOWER, 8, 0x4A14 }, }; static EntranceTableEntry sSouthClockTownEntrance9[] = { - { 0x6F, 0x09, 0x4A14 }, + { SCENE_CLOCKTOWER, 9, 0x4A14 }, }; static EntranceTableEntry sSouthClockTownEntrance10[] = { - { 0x6F, 0x0A, 0x058B }, + { SCENE_CLOCKTOWER, 10, 0x058B }, }; static EntranceTableEntry* sSouthClockTownEntranceTable[] = { @@ -2493,15 +2496,15 @@ static EntranceTableEntry* sSouthClockTownEntranceTable[] = { }; static EntranceTableEntry sLaundryPoolEntrance0[] = { - { 0x70, 0x00, 0xCA14 }, + { SCENE_ALLEY, 0, 0xCA14 }, }; static EntranceTableEntry sLaundryPoolEntrance1[] = { - { 0x70, 0x01, 0x4A14 }, + { SCENE_ALLEY, 1, 0x4A14 }, }; static EntranceTableEntry sLaundryPoolEntrance2[] = { - { 0x70, 0x02, 0x4102 }, + { SCENE_ALLEY, 2, 0x4102 }, }; static EntranceTableEntry* sLaundryPoolEntranceTable[] = { @@ -2511,71 +2514,71 @@ static EntranceTableEntry* sLaundryPoolEntranceTable[] = { }; static EntranceTableEntry sGrottosEntrance0[] = { - { 0x07, 0x00, 0x0102 }, + { SCENE_KAKUSIANA, 0, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance1[] = { - { 0x07, 0x01, 0x0102 }, + { SCENE_KAKUSIANA, 1, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance2[] = { - { 0x07, 0x02, 0x0102 }, + { SCENE_KAKUSIANA, 2, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance3[] = { - { 0x07, 0x03, 0x0102 }, + { SCENE_KAKUSIANA, 3, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance4[] = { - { 0x07, 0x04, 0x0102 }, + { SCENE_KAKUSIANA, 4, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance5[] = { - { 0x07, 0x05, 0x0102 }, + { SCENE_KAKUSIANA, 5, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance6[] = { - { 0x07, 0x06, 0x0102 }, + { SCENE_KAKUSIANA, 6, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance7[] = { - { 0x07, 0x07, 0x0102 }, + { SCENE_KAKUSIANA, SCENE_KAKUSIANA, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance8[] = { - { 0x07, 0x08, 0x0102 }, + { SCENE_KAKUSIANA, 8, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance9[] = { - { 0x07, 0x09, 0x0102 }, + { SCENE_KAKUSIANA, 9, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance10[] = { - { 0x07, 0x0A, 0x0102 }, + { SCENE_KAKUSIANA, 10, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance11[] = { - { 0x07, 0x0B, 0x0102 }, + { SCENE_KAKUSIANA, 11, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance12[] = { - { 0x07, 0x0C, 0x0102 }, + { SCENE_KAKUSIANA, 12, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance13[] = { - { 0x07, 0x0D, 0x0102 }, + { SCENE_KAKUSIANA, 13, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance14[] = { - { 0x07, 0x0E, 0x0102 }, + { SCENE_KAKUSIANA, 14, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance15[] = { - { 0x07, 0x0F, 0x0102 }, + { SCENE_KAKUSIANA, 15, 0x0102 }, }; static EntranceTableEntry sGrottosEntrance16[] = { - { 0x07, 0x10, 0x0102 }, + { SCENE_KAKUSIANA, 16, 0x0102 }, }; static EntranceTableEntry* sGrottosEntranceTable[] = { @@ -2586,63 +2589,73 @@ static EntranceTableEntry* sGrottosEntranceTable[] = { }; static EntranceTableEntry sCutsceneEntrance0[] = { - { 0xF8, 0x00, 0x0102 }, { 0xF8, 0x00, 0x0102 }, { 0xF8, 0x00, 0x8102 }, { 0xF8, 0x00, 0x0102 }, - { 0xF8, 0x00, 0x058B }, { 0xF8, 0x00, 0x058B }, { 0xF8, 0x00, 0x058B }, { 0xF8, 0x00, 0x058B }, - { 0xF8, 0x00, 0x0183 }, { 0xF8, 0x00, 0x0183 }, { 0xF8, 0x00, 0x8102 }, { 0xF8, 0x00, 0x0102 }, + { -SCENE_SPOT00, 0, 0x0102 }, { -SCENE_SPOT00, 0, 0x0102 }, { -SCENE_SPOT00, 0, 0x8102 }, + { -SCENE_SPOT00, 0, 0x0102 }, { -SCENE_SPOT00, 0, 0x058B }, { -SCENE_SPOT00, 0, 0x058B }, + { -SCENE_SPOT00, 0, 0x058B }, { -SCENE_SPOT00, 0, 0x058B }, { -SCENE_SPOT00, 0, 0x0183 }, + { -SCENE_SPOT00, 0, 0x0183 }, { -SCENE_SPOT00, 0, 0x8102 }, { -SCENE_SPOT00, 0, 0x0102 }, }; static EntranceTableEntry sCutsceneEntrance1[] = { - { 0xF8, 0x01, 0x0183 }, { 0xF8, 0x01, 0x0102 }, { 0xF8, 0x01, 0x8102 }, { 0xF8, 0x01, 0x0102 }, - { 0xF8, 0x01, 0x8102 }, { 0xF8, 0x01, 0x058B }, { 0xF8, 0x01, 0x058B }, { 0xF8, 0x01, 0x058B }, - { 0xF8, 0x01, 0x058B }, { 0xF8, 0x01, 0x8102 }, { 0xF8, 0x01, 0x8102 }, { 0xF8, 0x01, 0x0102 }, + { -SCENE_SPOT00, 1, 0x0183 }, { -SCENE_SPOT00, 1, 0x0102 }, { -SCENE_SPOT00, 1, 0x8102 }, + { -SCENE_SPOT00, 1, 0x0102 }, { -SCENE_SPOT00, 1, 0x8102 }, { -SCENE_SPOT00, 1, 0x058B }, + { -SCENE_SPOT00, 1, 0x058B }, { -SCENE_SPOT00, 1, 0x058B }, { -SCENE_SPOT00, 1, 0x058B }, + { -SCENE_SPOT00, 1, 0x8102 }, { -SCENE_SPOT00, 1, 0x8102 }, { -SCENE_SPOT00, 1, 0x0102 }, }; static EntranceTableEntry sCutsceneEntrance2[] = { - { 0xF8, 0x02, 0x0183 }, { 0xF8, 0x02, 0x0102 }, { 0xF8, 0x02, 0x8102 }, { 0xF8, 0x02, 0x0102 }, - { 0xF8, 0x02, 0x8102 }, { 0xF8, 0x02, 0x058B }, { 0xF8, 0x02, 0x058B }, { 0xF8, 0x02, 0x058B }, - { 0xF8, 0x02, 0x058B }, { 0xF8, 0x02, 0x858B }, { 0xF8, 0x02, 0x8102 }, + { -SCENE_SPOT00, 2, 0x0183 }, { -SCENE_SPOT00, 2, 0x0102 }, { -SCENE_SPOT00, 2, 0x8102 }, + { -SCENE_SPOT00, 2, 0x0102 }, { -SCENE_SPOT00, 2, 0x8102 }, { -SCENE_SPOT00, 2, 0x058B }, + { -SCENE_SPOT00, 2, 0x058B }, { -SCENE_SPOT00, 2, 0x058B }, { -SCENE_SPOT00, 2, 0x058B }, + { -SCENE_SPOT00, 2, 0x858B }, { -SCENE_SPOT00, 2, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance3[] = { - { 0xF8, 0x03, 0x0183 }, { 0xF8, 0x03, 0x0102 }, { 0xF8, 0x03, 0x8102 }, { 0xF8, 0x03, 0x0102 }, - { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x058B }, - { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x058B }, { 0xF8, 0x03, 0x8102 }, + { -SCENE_SPOT00, 3, 0x0183 }, { -SCENE_SPOT00, 3, 0x0102 }, { -SCENE_SPOT00, 3, 0x8102 }, + { -SCENE_SPOT00, 3, 0x0102 }, { -SCENE_SPOT00, 3, 0x058B }, { -SCENE_SPOT00, 3, 0x058B }, + { -SCENE_SPOT00, 3, 0x058B }, { -SCENE_SPOT00, 3, 0x058B }, { -SCENE_SPOT00, 3, 0x058B }, + { -SCENE_SPOT00, 3, 0x058B }, { -SCENE_SPOT00, 3, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance4[] = { - { 0xF8, 0x04, 0x0183 }, { 0xF8, 0x04, 0x0102 }, { 0xF8, 0x04, 0x8102 }, { 0xF8, 0x04, 0x0102 }, - { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x058B }, - { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x058B }, { 0xF8, 0x04, 0x8102 }, + { -SCENE_SPOT00, 4, 0x0183 }, { -SCENE_SPOT00, 4, 0x0102 }, { -SCENE_SPOT00, 4, 0x8102 }, + { -SCENE_SPOT00, 4, 0x0102 }, { -SCENE_SPOT00, 4, 0x058B }, { -SCENE_SPOT00, 4, 0x058B }, + { -SCENE_SPOT00, 4, 0x058B }, { -SCENE_SPOT00, 4, 0x058B }, { -SCENE_SPOT00, 4, 0x058B }, + { -SCENE_SPOT00, 4, 0x058B }, { -SCENE_SPOT00, 4, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance5[] = { - { 0xF8, 0x05, 0x0183 }, { 0xF8, 0x05, 0x0102 }, { 0xF8, 0x05, 0x8102 }, { 0xF8, 0x05, 0x0102 }, - { 0xF8, 0x05, 0x058B }, { 0xF8, 0x05, 0x058B }, { 0xF8, 0x05, 0x058B }, { 0xF8, 0x05, 0x058B }, - { 0xF8, 0x05, 0x058B }, { 0xF8, 0x05, 0x858B }, { 0xF8, 0x05, 0x8102 }, + { -SCENE_SPOT00, 5, 0x0183 }, { -SCENE_SPOT00, 5, 0x0102 }, { -SCENE_SPOT00, 5, 0x8102 }, + { -SCENE_SPOT00, 5, 0x0102 }, { -SCENE_SPOT00, 5, 0x058B }, { -SCENE_SPOT00, 5, 0x058B }, + { -SCENE_SPOT00, 5, 0x058B }, { -SCENE_SPOT00, 5, 0x058B }, { -SCENE_SPOT00, 5, 0x058B }, + { -SCENE_SPOT00, 5, 0x858B }, { -SCENE_SPOT00, 5, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance6[] = { - { 0xF8, 0x06, 0x0183 }, { 0xF8, 0x06, 0x0102 }, { 0xF8, 0x06, 0x8102 }, { 0xF8, 0x06, 0x0102 }, - { 0xF8, 0x06, 0x058B }, { 0xF8, 0x06, 0x058B }, { 0xF8, 0x06, 0x058B }, { 0xF8, 0x06, 0x058B }, - { 0xF8, 0x06, 0x058B }, { 0xF8, 0x06, 0x858B }, { 0xF8, 0x06, 0x8102 }, + { -SCENE_SPOT00, 6, 0x0183 }, { -SCENE_SPOT00, 6, 0x0102 }, { -SCENE_SPOT00, 6, 0x8102 }, + { -SCENE_SPOT00, 6, 0x0102 }, { -SCENE_SPOT00, 6, 0x058B }, { -SCENE_SPOT00, 6, 0x058B }, + { -SCENE_SPOT00, 6, 0x058B }, { -SCENE_SPOT00, 6, 0x058B }, { -SCENE_SPOT00, 6, 0x058B }, + { -SCENE_SPOT00, 6, 0x858B }, { -SCENE_SPOT00, 6, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance7[] = { - { 0xF8, 0x07, 0x0183 }, { 0xF8, 0x07, 0x0102 }, { 0xF8, 0x07, 0x8102 }, { 0xF8, 0x07, 0x0102 }, - { 0xF8, 0x07, 0x058B }, { 0xF8, 0x07, 0x058B }, { 0xF8, 0x07, 0x058B }, { 0xF8, 0x07, 0x058B }, - { 0xF8, 0x07, 0x058B }, { 0xF8, 0x07, 0x858B }, { 0xF8, 0x07, 0x8102 }, + { -SCENE_SPOT00, 7, 0x0183 }, { -SCENE_SPOT00, 7, 0x0102 }, { -SCENE_SPOT00, 7, 0x8102 }, + { -SCENE_SPOT00, 7, 0x0102 }, { -SCENE_SPOT00, 7, 0x058B }, { -SCENE_SPOT00, 7, 0x058B }, + { -SCENE_SPOT00, 7, 0x058B }, { -SCENE_SPOT00, 7, 0x058B }, { -SCENE_SPOT00, 7, 0x058B }, + { -SCENE_SPOT00, 7, 0x858B }, { -SCENE_SPOT00, 7, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance8[] = { - { 0xF8, 0x08, 0x0183 }, { 0xF8, 0x08, 0x0102 }, { 0xF8, 0x08, 0x8102 }, { 0xF8, 0x08, 0x0102 }, - { 0xF8, 0x08, 0x058B }, { 0xF8, 0x08, 0x058B }, { 0xF8, 0x08, 0x058B }, { 0xF8, 0x08, 0x058B }, - { 0xF8, 0x08, 0x058B }, { 0xF8, 0x08, 0x858B }, { 0xF8, 0x08, 0x8102 }, + { -SCENE_SPOT00, 8, 0x0183 }, { -SCENE_SPOT00, 8, 0x0102 }, { -SCENE_SPOT00, 8, 0x8102 }, + { -SCENE_SPOT00, 8, 0x0102 }, { -SCENE_SPOT00, 8, 0x058B }, { -SCENE_SPOT00, 8, 0x058B }, + { -SCENE_SPOT00, 8, 0x058B }, { -SCENE_SPOT00, 8, 0x058B }, { -SCENE_SPOT00, 8, 0x058B }, + { -SCENE_SPOT00, 8, 0x858B }, { -SCENE_SPOT00, 8, 0x8102 }, }; static EntranceTableEntry sCutsceneEntrance9[] = { - { 0xF8, 0x09, 0x0183 }, { 0xF8, 0x09, 0x0102 }, { 0xF8, 0x09, 0x8102 }, { 0xF8, 0x09, 0x0102 }, - { 0xF8, 0x09, 0x058B }, { 0xF8, 0x09, 0x058B }, { 0xF8, 0x09, 0x058B }, { 0xF8, 0x09, 0x058B }, - { 0xF8, 0x09, 0x058B }, { 0xF8, 0x09, 0x858B }, { 0xF8, 0x09, 0x8102 }, + { -SCENE_SPOT00, 9, 0x0183 }, { -SCENE_SPOT00, 9, 0x0102 }, { -SCENE_SPOT00, 9, 0x8102 }, + { -SCENE_SPOT00, 9, 0x0102 }, { -SCENE_SPOT00, 9, 0x058B }, { -SCENE_SPOT00, 9, 0x058B }, + { -SCENE_SPOT00, 9, 0x058B }, { -SCENE_SPOT00, 9, 0x058B }, { -SCENE_SPOT00, 9, 0x058B }, + { -SCENE_SPOT00, 9, 0x858B }, { -SCENE_SPOT00, 9, 0x8102 }, }; static EntranceTableEntry* sCutsceneEntranceTable[] = { @@ -2657,152 +2670,152 @@ 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_GetSceneId(u16 entrance) { + EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance); - return tableEntry->sceneNum; + return tableEntry->sceneId; } /** * 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_GetSceneIdAbsolute(u16 entrance) { + EntranceTableEntry* tableEntry = Entrance_GetTableEntry(entrance); - return ABS_ALT(tableEntry->sceneNum); + return ABS_ALT(tableEntry->sceneId); } /** * 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 +2823,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 index 4c57a57d4..fdefb0f42 100644 --- a/src/code/z_schedule.c +++ b/src/code/z_schedule.c @@ -6,29 +6,29 @@ (dest) = (temp) * (0x10000 / 60 / 24.0f); \ (dest) = SCHEDULE_CONVERT_TIME(dest); -s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckFlagS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script; - u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + u16 flag = PACK_WEEKEVENTREG_FLAG(cmd->flagByte, cmd->flagMask); - if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + if (CHECK_WEEKEVENTREG(flag)) { *script += cmd->offset; } return false; } -s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckFlagL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script; - u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + u16 flag = PACK_WEEKEVENTREG_FLAG(cmd->flagByte, cmd->flagMask); - if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + if (CHECK_WEEKEVENTREG(flag)) { *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); } return false; } -s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckTimeRangeS(PlayState* play, u8** script, ScheduleOutput* output) { s32 inRange = false; ScheduleCmdCheckTimeRangeS* cmd = (ScheduleCmdCheckTimeRangeS*)*script; f32 f; @@ -54,7 +54,7 @@ s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResu return false; } -s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckTimeRangeL(PlayState* play, u8** script, ScheduleOutput* output) { s32 inRange = false; ScheduleCmdCheckTimeRangeL* cmd = (ScheduleCmdCheckTimeRangeL*)*script; f32 f; @@ -80,77 +80,77 @@ s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResu return false; } -s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_ReturnValueL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script; //! @bug result is a u8, value is truncated - result->result = (cmd->retH << 8) | cmd->retL; - result->hasResult = true; + output->result = (cmd->retH << 8) | cmd->retL; + output->hasResult = true; return true; } -s32 Schedule_ReturnNone(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { - result->hasResult = false; +s32 Schedule_ReturnNone(PlayState* play, u8** script, ScheduleOutput* output) { + output->hasResult = false; return true; } -s32 Schedule_ReturnEmpty(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { - result->hasResult = true; +s32 Schedule_ReturnEmpty(PlayState* play, u8** script, ScheduleOutput* output) { + output->hasResult = true; return true; } -s32 Schedule_Nop(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_Nop(PlayState* play, u8** script, ScheduleOutput* output) { return false; } -s32 Schedule_CheckMiscS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckMiscS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script; if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) || ((cmd->which == SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI) && (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_LETTER_TO_KAFEI)) || - ((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI))) { + ((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(play) == PLAYER_MASK_ROMANI))) { *script += cmd->offset; } return false; } -s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_ReturnValueS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script; - result->result = cmd->result; - result->hasResult = true; + output->result = cmd->result; + output->hasResult = true; return true; } -s32 Schedule_CheckNotInSceneS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script; - s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + s16 sceneId = (cmd->sceneIdH << 8) | cmd->sceneIdL; - if (scene != globalCtx->sceneNum) { + if (sceneId != play->sceneId) { *script += cmd->offset; } return false; } -s32 Schedule_CheckNotInSceneL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckNotInSceneL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script; - s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + s16 sceneId = (cmd->sceneIdH << 8) | cmd->sceneIdL; - if (scene != globalCtx->sceneNum) { + if (sceneId != play->sceneId) { *script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL); } return false; } -s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckNotInDayS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInDayS* cmd = (ScheduleCmdCheckNotInDayS*)*script; s16 day = (cmd->dayH << 8) | cmd->dayL; @@ -161,7 +161,7 @@ s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResul return false; } -s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckNotInDayL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckNotInDayL* cmd = (ScheduleCmdCheckNotInDayL*)*script; s16 day = (cmd->dayH << 8) | cmd->dayL; @@ -172,7 +172,7 @@ s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResul return false; } -s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_ReturnTime(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdReturnTime* cmd = (ScheduleCmdReturnTime*)*script; f32 f; u16 time0; @@ -183,15 +183,15 @@ s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* r SCHEDULE_CALC_TIME(cmd->time1Hr, cmd->time1Min, time1, f); time1--; - result->result = cmd->result; - result->time0 = time0; - result->time1 = time1; - result->hasResult = true; + output->result = cmd->result; + output->time0 = time0; + output->time1 = time1; + output->hasResult = true; return true; } -s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckBeforeTimeS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckBeforeTimeS* cmd = (ScheduleCmdCheckBeforeTimeS*)*script; f32 f; u16 testTime; @@ -208,7 +208,7 @@ s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleRes return false; } -s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_CheckBeforeTimeL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdCheckBeforeTimeL* cmd = (ScheduleCmdCheckBeforeTimeL*)*script; f32 f; u16 testTime; @@ -225,21 +225,21 @@ s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleRes return false; } -s32 Schedule_BranchS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_BranchS(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script; *script += cmd->offset; return false; } -s32 Schedule_BranchL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { +s32 Schedule_BranchL(PlayState* play, u8** script, ScheduleOutput* output) { ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script; *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); return false; } -static s32 (*sScheduleCmdFuncs[])(GlobalContext*, u8**, ScheduleResult*) = { +static s32 (*sScheduleCmdFuncs[])(PlayState*, u8**, ScheduleOutput*) = { Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL, Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop, Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL, @@ -269,15 +269,15 @@ static u8 sScheduleCmdSizes[] = { sizeof(ScheduleCmdBranchL), }; -s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result) { +s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleOutput* output) { u8 size; s32 stop; do { size = sScheduleCmdSizes[*script]; - stop = (*sScheduleCmdFuncs[*script])(globalCtx, &script, result); + stop = (*sScheduleCmdFuncs[*script])(play, &script, output); script += size; } while (!stop); - return result->hasResult; + return output->hasResult; } diff --git a/src/code/z_shrink_window.c b/src/code/z_shrink_window.c index 5bfca86d9..21d8bde40 100644 --- a/src/code/z_shrink_window.c +++ b/src/code/z_shrink_window.c @@ -2,72 +2,80 @@ * File: z_shrink_window.c * Description: Draws black top/bottom/side borders on the viewing window (e.g. Z-targeting, talking to NPC) */ -#include "prevent_bss_reordering.h" + #include "global.h" +#include "z64shrink_window.h" -ShrinkWindowContext gShrinkWindowContext; -ShrinkWindowContext* gShrinkWindowContextPtr; +typedef struct { + /* 0x0 */ s8 letterboxTarget; + /* 0x1 */ s8 letterboxSize; + /* 0x2 */ s8 pillarboxTarget; + /* 0x3 */ s8 pillarboxSize; +} ShrinkWindow; // size = 0x4 -void ShrinkWindow_SetLetterboxTarget(s32 target) { - gShrinkWindowContextPtr->letterboxTarget = target; +ShrinkWindow sShrinkWindow; +ShrinkWindow* sShrinkWindowPtr; + +void ShrinkWindow_Letterbox_SetSizeTarget(s32 target) { + sShrinkWindowPtr->letterboxTarget = target; } -s32 ShrinkWindow_GetLetterboxTarget(void) { - return gShrinkWindowContextPtr->letterboxTarget; +s32 ShrinkWindow_Letterbox_GetSizeTarget(void) { + return sShrinkWindowPtr->letterboxTarget; } -void ShrinkWindow_SetLetterboxMagnitude(s32 magnitude) { - gShrinkWindowContextPtr->letterboxMagnitude = magnitude; +void ShrinkWindow_Letterbox_SetSize(s32 size) { + sShrinkWindowPtr->letterboxSize = size; } -s32 ShrinkWindow_GetLetterboxMagnitude(void) { - return gShrinkWindowContextPtr->letterboxMagnitude; +s32 ShrinkWindow_Letterbox_GetSize(void) { + return sShrinkWindowPtr->letterboxSize; } -void ShrinkWindow_SetPillarboxTarget(s32 target) { - gShrinkWindowContextPtr->pillarboxTarget = target; +void ShrinkWindow_Pillarbox_SetSizeTarget(s32 target) { + sShrinkWindowPtr->pillarboxTarget = target; } -s32 ShrinkWindow_GetPillarboxTarget(void) { - return gShrinkWindowContextPtr->pillarboxTarget; +s32 ShrinkWindow_Pillarbox_GetSizeTarget(void) { + return sShrinkWindowPtr->pillarboxTarget; } -void ShrinkWindow_SetPillarboxMagnitude(s32 magnitude) { - gShrinkWindowContextPtr->pillarboxMagnitude = magnitude; +void ShrinkWindow_Pillarbox_SetSize(s32 size) { + sShrinkWindowPtr->pillarboxSize = size; } -s32 ShrinkWindow_GetPillarboxMagnitude(void) { - return gShrinkWindowContextPtr->pillarboxMagnitude; +s32 ShrinkWindow_Pillarbox_GetSize(void) { + return sShrinkWindowPtr->pillarboxSize; } void ShrinkWindow_Init(void) { - gShrinkWindowContextPtr = &gShrinkWindowContext; - bzero(gShrinkWindowContextPtr, sizeof(gShrinkWindowContext)); + sShrinkWindowPtr = &sShrinkWindow; + bzero(sShrinkWindowPtr, sizeof(sShrinkWindow)); } void ShrinkWindow_Destroy(void) { - gShrinkWindowContextPtr = NULL; + sShrinkWindowPtr = NULL; } void ShrinkWindow_Update(s32 framerateDivisor) { - s32 step = ((framerateDivisor == 3) ? 10 : 30 / framerateDivisor); - s32 nextMagnitude; + s32 step = (framerateDivisor == 3) ? 10 : (30 / framerateDivisor); + s32 nextSize; - nextMagnitude = gShrinkWindowContextPtr->letterboxMagnitude; - Math_StepToIGet(&nextMagnitude, gShrinkWindowContextPtr->letterboxTarget, step); - gShrinkWindowContextPtr->letterboxMagnitude = nextMagnitude; + nextSize = sShrinkWindowPtr->letterboxSize; + Math_StepToIGet(&nextSize, sShrinkWindowPtr->letterboxTarget, step); + sShrinkWindowPtr->letterboxSize = nextSize; - nextMagnitude = gShrinkWindowContextPtr->pillarboxMagnitude; - Math_StepToIGet(&nextMagnitude, gShrinkWindowContextPtr->pillarboxTarget, step); - gShrinkWindowContextPtr->pillarboxMagnitude = nextMagnitude; + nextSize = sShrinkWindowPtr->pillarboxSize; + Math_StepToIGet(&nextSize, sShrinkWindowPtr->pillarboxTarget, step); + sShrinkWindowPtr->pillarboxSize = nextSize; } void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { Gfx* gfx; - s8 letterboxMagnitude = gShrinkWindowContextPtr->letterboxMagnitude; - s8 pillarboxMagnitude = gShrinkWindowContextPtr->pillarboxMagnitude; + s8 letterboxSize = sShrinkWindowPtr->letterboxSize; + s8 pillarboxSize = sShrinkWindowPtr->pillarboxSize; - if (letterboxMagnitude > 0) { + if (letterboxSize > 0) { OPEN_DISPS(gfxCtx); gfx = OVERLAY_DISP; @@ -76,23 +84,23 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetCycleType(gfx++, G_CYC_FILL); gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, letterboxMagnitude - 1); - gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxMagnitude, gScreenWidth - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, letterboxSize - 1); + gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxSize, gScreenWidth - 1, gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillRectangle(gfx++, 0, letterboxMagnitude, gScreenWidth, letterboxMagnitude + 1); - gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxMagnitude - 1, gScreenWidth, - gScreenHeight - letterboxMagnitude); + gDPFillRectangle(gfx++, 0, letterboxSize, gScreenWidth, letterboxSize + 1); + gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxSize - 1, gScreenWidth, gScreenHeight - letterboxSize); gDPPipeSync(gfx++); OVERLAY_DISP = gfx++; CLOSE_DISPS(gfxCtx); } - if (pillarboxMagnitude > 0) { + + if (pillarboxSize > 0) { OPEN_DISPS(gfxCtx); gfx = OVERLAY_DISP; @@ -102,17 +110,16 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - gDPFillRectangle(gfx++, 0, 0, pillarboxMagnitude - 1, gScreenHeight - 1); - gDPFillRectangle(gfx++, gScreenWidth - pillarboxMagnitude, 0, gScreenWidth - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, 0, 0, pillarboxSize - 1, gScreenHeight - 1); + gDPFillRectangle(gfx++, gScreenWidth - pillarboxSize, 0, gScreenWidth - 1, gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillRectangle(gfx++, pillarboxMagnitude, 0, pillarboxMagnitude + 2, gScreenHeight); - gDPFillRectangle(gfx++, gScreenWidth - pillarboxMagnitude - 2, 0, gScreenWidth - pillarboxMagnitude, - gScreenHeight); + gDPFillRectangle(gfx++, pillarboxSize, 0, pillarboxSize + 2, gScreenHeight); + gDPFillRectangle(gfx++, gScreenWidth - pillarboxSize - 2, 0, gScreenWidth - pillarboxSize, gScreenHeight); gDPPipeSync(gfx++); OVERLAY_DISP = gfx++; diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 0a3334bc8..318f49809 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -2,15 +2,15 @@ #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, - f32 frame, f32 frameCount, u8 animationMode, f32 morphFrames); +void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle); +void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, + f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); static AnimationEntryCallback sAnimationLoadDone[] = { @@ -24,14 +24,14 @@ 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_Push(); limb = Lib_SegmentedToVirtual(skeleton[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)) { + 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_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,7 +88,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -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)) { + 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_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,7 +139,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -156,7 +154,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dLists[lod]; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*mtx); @@ -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_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,13 +200,13 @@ 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, dListCount * sizeof(Mtx)); if (skeleton == NULL) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); Matrix_Push(); @@ -222,7 +220,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dLists[lod]; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Gfx* polyTemp = POLY_OPA_DISP; @@ -238,30 +236,30 @@ 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_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_Push(); @@ -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)) { + 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_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,7 +314,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); rootLimb = Lib_SegmentedToVirtual(skeleton[0]); @@ -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)) { + 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_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,7 +359,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -375,7 +373,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*limbMatricies); @@ -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_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,13 +418,13 @@ 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, dListCount * sizeof(Mtx)); if (skeleton == NULL) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); @@ -441,7 +439,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) { + 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_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,7 +479,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -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)) { + 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; @@ -518,22 +516,22 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, } 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_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,9 +558,9 @@ 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, dListCount * sizeof(Mtx)); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); @@ -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)) { + 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; @@ -599,17 +597,17 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V } 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_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,7 +649,7 @@ 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; @@ -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)) { + 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_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; @@ -728,22 +722,22 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable dList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor, &gfx)) { + 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_Pop(); @@ -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; @@ -775,7 +769,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel newDList = limbDList = limb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { + 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); @@ -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_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,7 +822,7 @@ 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, dListCount * sizeof(Mtx)); gSPSegment(gfx++, 0x0D, mtx); @@ -844,7 +838,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT newDList = limbDList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor, &gfx)) { + 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); @@ -860,12 +854,12 @@ 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_Pop(); @@ -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,13 +990,13 @@ 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); - u32 ram = frameTable; + uintptr_t ram = frameTable; osCreateMesgQueue(&entry->data.load.msgQueue, &entry->data.load.msg, 1); DmaMgr_SendRequestImpl(&entry->data.load.req, ram, @@ -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,8 +1186,8 @@ 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, - LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, +void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, + LinkAnimationHeader* animation, s32 flags, void* jointTableBuffer, void* morphTableBuffer, s32 limbBufCount) { FlexSkeletonHeader* skeletonHeader; s32 headerJointCount; @@ -1222,15 +1216,15 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel allocSize += 2; } - if (jointTable == NULL) { + if (jointTableBuffer == NULL) { skelAnime->jointTable = ZeldaArena_Malloc(allocSize); skelAnime->morphTable = ZeldaArena_Malloc(allocSize); } else { - skelAnime->jointTable = (Vec3s*)ALIGN16((u32)jointTable); - skelAnime->morphTable = (Vec3s*)ALIGN16((u32)morphTable); + skelAnime->jointTable = (void*)ALIGN16((uintptr_t)jointTableBuffer); + skelAnime->morphTable = (void*)ALIGN16((uintptr_t)morphTableBuffer); } - 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); } /** @@ -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.link(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))) { @@ -1356,15 +1350,14 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn morphFrames = -morphFrames; } else { skelAnime->update.link = LinkAnimation_Morph; - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, + 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) { - Vec3s* alignedBlendTable; +void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, + LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, void* blendTableBuffer) { + void* 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); + alignedBlendTable = (void*)ALIGN16((uintptr_t)blendTableBuffer); - 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) { - Vec3s* alignedBlendTable; +void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, + LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, void* blendTableBuffer) { + void* 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); + alignedBlendTable = (void*)ALIGN16((uintptr_t)blendTableBuffer); - 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; @@ -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 de449c02d..0d3e0bf85 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -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_snap.c b/src/code/z_snap.c index f85f33f0a..5d37e3eac 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->sceneId == 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->sceneId) { 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 90b60809e..94d0e69c3 100644 --- a/src/code/z_sram_NES.c +++ b/src/code/z_sram_NES.c @@ -131,16 +131,109 @@ u32 D_801C5FC0[SCENE_MAX][4] = { { 0, 0, 1, 0 }, // SCENE_ALLEY }; -// Related to weekEventReg +// TODO: figure out a way to use the WEEKEVENTREG defines here +// weekEventReg flags which will be not be cleared on a cycle reset u16 D_801C66D0[ARRAY_COUNT(gSaveContext.save.weekEventReg)] = { - 0xFFFC, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0, 0, 0xC000, 0xC00, 0, 0xC0, 0, 0x300, - 0x3000, 0xC000, 0xC00, 0, 0, 0, 0, 0, 0, 0xC00C, 0xC00C, 0xC008, 3, - 0x3000, 0, 0, 0, 0xFF00, 0xC3F, 0x3F, 0, 0, 0xCFFF, 0, 0, 0xC00, - 0xC00, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3C, 0x20, - 0, 0x300C, 0x3000, 0, 0xC, 0xC0, 0, 0xFF0, 0x300, 0, 0, 0xC00, 0, - 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xC0, 0, 0xC000, 0, 3, - 0, 0xC000, 0, 0xC0, 0x300, 0, 0, 0, 0xC000, 0xFFF0, 0, 0, 0x300, - 0, 0xC000, 0xF0, 0, 0, 0, 0, 0, 0, + /* 0 */ 0xFFFC, + /* 1 */ 0xFFFF, + /* 2 */ 0xFFFF, + /* 3 */ 0xFFFF, + /* 4 */ 0, + /* 5 */ 0, + /* 6 */ 0, + /* 7 */ 0xC000, + /* 8 */ 0xC00, + /* 9 */ 0, + /* 10 */ 0xC0, + /* 11 */ 0, + /* 12 */ 0x300, + /* 13 */ 0x3000, + /* 14 */ 0xC000, + /* 15 */ 0xC00, + /* 16 */ 0, + /* 17 */ 0, + /* 18 */ 0, + /* 19 */ 0, + /* 20 */ 0, + /* 21 */ 0, + /* 22 */ 0xC00C, + /* 23 */ 0xC00C, + /* 24 */ 0xC008, + /* 25 */ 3, + /* 26 */ 0x3000, + /* 27 */ 0, + /* 28 */ 0, + /* 29 */ 0, + /* 30 */ 0xFF00, + /* 31 */ 0xC3F, + /* 32 */ 0x3F, + /* 33 */ 0, + /* 34 */ 0, + /* 35 */ 0xCFFF, + /* 36 */ 0, + /* 37 */ 0, + /* 38 */ 0xC00, + /* 39 */ 0xC00, + /* 40 */ 0, + /* 41 */ 0xC0, + /* 42 */ 0, + /* 43 */ 0, + /* 44 */ 0, + /* 45 */ 0, + /* 46 */ 0, + /* 47 */ 0, + /* 48 */ 0, + /* 49 */ 0, + /* 50 */ 0x3C, + /* 51 */ 0x20, + /* 52 */ 0, + /* 53 */ 0x300C, + /* 54 */ 0x3000, + /* 55 */ 0, + /* 56 */ 0xC, + /* 57 */ 0xC0, + /* 58 */ 0, + /* 59 */ 0xFF0, + /* 60 */ 0x300, + /* 61 */ 0, + /* 62 */ 0, + /* 63 */ 0xC00, + /* 64 */ 0, + /* 65 */ 0, + /* 66 */ 0xFFFF, + /* 67 */ 0xFFFF, + /* 68 */ 0xFFFF, + /* 69 */ 0xFFFF, + /* 70 */ 0xFFFF, + /* 71 */ 0xFFFF, + /* 72 */ 0xFFFF, + /* 73 */ 0xC0, + /* 74 */ 0, + /* 75 */ 0xC000, + /* 76 */ 0, + /* 77 */ 3, + /* 78 */ 0, + /* 79 */ 0xC000, + /* 80 */ 0, + /* 81 */ 0xC0, + /* 82 */ 0x300, + /* 83 */ 0, + /* 84 */ 0, + /* 85 */ 0, + /* 86 */ 0xC000, + /* 87 */ 0xFFF0, + /* 88 */ 0, + /* 89 */ 0, + /* 90 */ 0x300, + /* 91 */ 0, + /* 92 */ 0xC000, + /* 93 */ 0xF0, + /* 94 */ 0, + /* 95 */ 0, + /* 96 */ 0, + /* 97 */ 0, + /* 98 */ 0, + /* 99 */ 0, }; // used in other files @@ -148,23 +241,38 @@ 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 }; +s32 D_801C67C8[] = { 0, 0x40, 0x80, 0xC0, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380 }; -s32 D_801C67E8[] = { 0x300, 0x380 }; +s32 D_801C67F0[] = { 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80, 1, 1 }; -s32 D_801C67F0[] = { 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80 }; - -s32 D_801C6810[] = { 1, 1 }; - -s32 D_801C6818[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; - -s32 D_801C6838[] = { 1, 1 }; +s32 D_801C6818[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 1, 1 }; s32 D_801C6840[] = { 0x100, 0x180, 0x200, 0x280 }; @@ -198,42 +306,37 @@ void Sram_ActivateOwl(u8 owlId) { void Sram_ClearHighscores(void) { gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF) | 0x130000; gSaveContext.save.unk_EE8 = (gSaveContext.save.unk_EE8 & 0xFFFF0000) | 0xA; - gSaveContext.save.horseBackBalloonHighScore = 6000; // 60 seconds - gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF0000) | 0x27; - gSaveContext.save.unk_EF4 = (gSaveContext.save.unk_EF4 & 0xFFFF) | 0xA0000; + gSaveContext.save.horseBackBalloonHighScore = SECONDS_TO_TIMER(60); + 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 - gSaveContext.save.dekuPlaygroundHighScores[2] = 7600; // 76 seconds + gSaveContext.save.dekuPlaygroundHighScores[0] = SECONDS_TO_TIMER(75); + gSaveContext.save.dekuPlaygroundHighScores[1] = SECONDS_TO_TIMER(75); + gSaveContext.save.dekuPlaygroundHighScores[2] = SECONDS_TO_TIMER(76); } /** * Clears specific weekEventReg flags. Used by the "Dawn of the First Day" message */ void Sram_ClearFlagsAtDawnOfTheFirstDay(void) { - // Unconfirmed: "Link the Goron Claims His Reservation: 4:30 PM" - gSaveContext.save.weekEventReg[55] &= (u8)~2; - // Unconfirmed: "Postman fleeing town" - gSaveContext.save.weekEventReg[90] &= (u8)~1; - // Unconfirmed: "Postman is about to flee" - gSaveContext.save.weekEventReg[89] &= (u8)~0x40; - // Unconfirmed: "Postman has delivered priority mail" - gSaveContext.save.weekEventReg[89] &= (u8)~8; - // Unconfirmed: "Postman showing priority mail to Madame" - gSaveContext.save.weekEventReg[85] &= (u8)~0x80; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_55_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_89_40); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_89_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_85_80); } /** * Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene */ -void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { - s16 sceneNum; +void Sram_SaveEndOfCycle(PlayState* play) { + s16 sceneId; s32 j; s32 i; - u8 temp; - u8 temp2; + u8 slot; + u8 item; - gSaveContext.save.daySpeed = 0; + gSaveContext.save.timeSpeedOffset = 0; gSaveContext.save.daysElapsed = 0; gSaveContext.save.day = 0; gSaveContext.save.time = CLOCK_TIME(6, 0) - 1; @@ -243,14 +346,14 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { gSaveContext.save.playerData.deaths = 999; } - sceneNum = Play_GetOriginalSceneNumber(globalCtx->sceneNum); - Play_SaveCycleSceneFlags(&globalCtx->state); + sceneId = Play_GetOriginalSceneId(play->sceneId); + 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.sceneFlags.chest &= D_801C5FC0[sceneId][2]; + play->actorCtx.sceneFlags.switches[0] &= D_801C5FC0[sceneId][0]; + play->actorCtx.sceneFlags.switches[1] &= D_801C5FC0[sceneId][1]; + play->actorCtx.sceneFlags.collectible[0] &= D_801C5FC0[sceneId][3]; + play->actorCtx.sceneFlags.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 +363,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++) { @@ -271,12 +374,12 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { gSaveContext.cycleSceneFlags[i].collectible = 0; } - for (i = 0; i < ARRAY_COUNT(gSaveContext.maskMaskBit); i++) { - gSaveContext.maskMaskBit[i] = 0; + for (i = 0; i < ARRAY_COUNT(gSaveContext.masksGivenOnMoon); i++) { + gSaveContext.masksGivenOnMoon[i] = 0; } - if (gSaveContext.save.weekEventReg[84] & 0x20) { - func_801149A0(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_20)) { + Inventory_DeleteItem(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); } for (i = 0; i < ARRAY_COUNT(D_801C66D0); i++) { @@ -295,46 +398,46 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { gSaveContext.eventInf[i] = 0; } - gSaveContext.eventInf[7] &= (u8)~1; - gSaveContext.eventInf[7] &= (u8)~2; - gSaveContext.eventInf[7] &= (u8)~4; - gSaveContext.eventInf[7] &= (u8)~8; - gSaveContext.eventInf[7] &= (u8)~0x10; + CLEAR_EVENTINF(EVENTINF_70); + CLEAR_EVENTINF(EVENTINF_71); + CLEAR_EVENTINF(EVENTINF_72); + CLEAR_EVENTINF(EVENTINF_73); + CLEAR_EVENTINF(EVENTINF_74); if (gSaveContext.save.playerData.rupees != 0) { - gSaveContext.eventInf[7] |= 1; + SET_EVENTINF(EVENTINF_70); } if (INV_CONTENT(ITEM_BOMB) == ITEM_BOMB) { - temp2 = INV_CONTENT(ITEM_BOMB); - if (AMMO(temp2) != 0) { - gSaveContext.eventInf[7] |= 2; + item = INV_CONTENT(ITEM_BOMB); + if (AMMO(item) != 0) { + SET_EVENTINF(EVENTINF_71); } } if (INV_CONTENT(ITEM_NUT) == ITEM_NUT) { - temp2 = INV_CONTENT(ITEM_NUT); - if (AMMO(temp2) != 0) { - gSaveContext.eventInf[7] |= 4; + item = INV_CONTENT(ITEM_NUT); + if (AMMO(item) != 0) { + SET_EVENTINF(EVENTINF_72); } } if (INV_CONTENT(ITEM_STICK) == ITEM_STICK) { - temp2 = INV_CONTENT(ITEM_STICK); - if (AMMO(temp2) != 0) { - gSaveContext.eventInf[7] |= 8; + item = INV_CONTENT(ITEM_STICK); + if (AMMO(item) != 0) { + SET_EVENTINF(EVENTINF_73); } } if (INV_CONTENT(ITEM_BOW) == ITEM_BOW) { - temp2 = INV_CONTENT(ITEM_BOW); - if (AMMO(temp2) != 0) { - gSaveContext.eventInf[7] |= 0x10; + item = INV_CONTENT(ITEM_BOW); + if (AMMO(item) != 0) { + SET_EVENTINF(EVENTINF_74); } } - 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 +446,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 +457,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); + CUR_FORM_EQUIP(EQUIP_SLOT_B) = ITEM_SWORD_GILDED; + SET_EQUIP_VALUE(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_GILDED); } else { - BUTTON_ITEM_EQUIP(CUR_FORM, EQUIP_SLOT_B) = ITEM_SWORD_KOKIRI; + CUR_FORM_EQUIP(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 +488,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 +510,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 +536,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 +548,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) { gSaveContext.jinxTimer = 0; gSaveContext.rupeeAccumulator = 0; - func_800F3B2C(globalCtx); + func_800F3B2C(play); } void Sram_IncrementDay(void) { @@ -462,10 +564,8 @@ void Sram_IncrementDay(void) { gSaveContext.save.bombersCaughtOrder[3] = 0; gSaveContext.save.bombersCaughtOrder[4] = 0; - // Unconfirmed: "Bombers Hide & Seek started on Day 1???" - gSaveContext.save.weekEventReg[73] &= (u8)~0x10; - // Unconfirmed: "Bombers Hide & Seek in Progress" - gSaveContext.save.weekEventReg[85] &= (u8)~2; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_73_10); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_85_02); } u16 Sram_CalcChecksum(void* data, size_t count) { @@ -481,13 +581,13 @@ 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; gSaveContext.save.linkAge = 0; gSaveContext.save.isNight = false; - gSaveContext.save.daySpeed = 0; + gSaveContext.save.timeSpeedOffset = 0; gSaveContext.save.snowheadCleared = 0; gSaveContext.save.hasTatl = false; gSaveContext.save.isOwlSave = false; @@ -577,18 +677,18 @@ SavePlayerData sSaveDefaultPlayerData = { 0x30, // healthCapacity 0x30, // health 0, // magicLevel - 0x30, // magic + MAGIC_NORMAL_METER, // magic 0, // rupees 0, // swordHealth 0, // tatlTimer - 0, // magicAcquired - 0, // doubleMagic + false, // isMagicAcquired + false, // isDoubleMagicAcquired 0, // doubleDefense 0, // unk_1F 0xFF, // unk_20 0x0000, // owlActivationFlags 0xFF, // unk_24 - SCENE_SPOT00, // savedSceneNum + SCENE_SPOT00, // savedSceneId }; ItemEquips sSaveDefaultItemEquips = { @@ -596,7 +696,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 +725,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 }, + // defenseHearts + 0, // strayFairies { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // dekuPlaygroundPlayerName @@ -657,7 +759,7 @@ void Sram_InitNewSave(void) { Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDefaultInventory, sizeof(Inventory)); Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDefaultChecksum, sizeof(gSaveContext.save.checksum)); - gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.sceneId = SCENE_F01; gSaveContext.save.horseData.pos.x = -1420; gSaveContext.save.horseData.pos.y = 257; gSaveContext.save.horseData.pos.z = -1285; @@ -675,18 +777,18 @@ SavePlayerData sSaveDebugPlayerData = { 0x80, // healthCapacity 0x80, // health 0, // magicLevel - 0x30, // magic - 0x32, // rupees - 0x64, // swordHealth + MAGIC_NORMAL_METER, // magic + 50, // rupees + 100, // swordHealth 0, // tatlTimer - 1, // magicAcquired - 0, // doubleMagic + true, // isMagicAcquired + false, // isDoubleMagicAcquired 0, // doubleDefense 0, // unk_1F 0xFF, // unk_20 0, // owlActivationFlags 0xFF, // unk_24 - SCENE_SPOT00, // savedSceneNum + SCENE_SPOT00, // savedSceneId }; ItemEquips sSaveDebugItemEquips = { @@ -769,7 +871,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 }, + // defenseHearts + 0, // strayFairies { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // dekuPlaygroundPlayerName @@ -808,28 +912,25 @@ void Sram_InitDebugSave(void) { Lib_MemCpy(&gSaveContext.save.inventory, &sSaveDebugInventory, sizeof(Inventory)); Lib_MemCpy(&gSaveContext.save.checksum, &sSaveDebugChecksum, sizeof(gSaveContext.save.checksum)); - if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - BUTTON_ITEM_EQUIP(0, 2) = D_801C6A48[((void)0, gSaveContext.save.playerForm & 0xFF)]; - C_SLOT_EQUIP(0, 2) = D_801C6A50[((void)0, gSaveContext.save.playerForm & 0xFF)]; + if (GET_PLAYER_FORM != PLAYER_FORM_HUMAN) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = D_801C6A48[GET_PLAYER_FORM]; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = D_801C6A50[GET_PLAYER_FORM]; } gSaveContext.save.hasTatl = true; - gSaveContext.save.horseData.scene = SCENE_F01; + gSaveContext.save.horseData.sceneId = SCENE_F01; gSaveContext.save.horseData.pos.x = -1420; gSaveContext.save.horseData.pos.y = 257; gSaveContext.save.horseData.pos.z = -1285; gSaveContext.save.horseData.yaw = -0x7554; - gSaveContext.save.entranceIndex = 0x1C00; + gSaveContext.save.entrance = ENTRANCE(CUTSCENE, 0); gSaveContext.save.isFirstCycle = true; - // - gSaveContext.save.weekEventReg[0x0F] |= 0x20; - // Unconfirmed: "Entered South Clock Town" - gSaveContext.save.weekEventReg[0x3B] |= 0x04; - // Unconfirmed: "Tatl's Second Cycle Text?" - gSaveContext.save.weekEventReg[0x1F] |= 0x04; + SET_WEEKEVENTREG(WEEKEVENTREG_15_20); + SET_WEEKEVENTREG(WEEKEVENTREG_59_04); + SET_WEEKEVENTREG(WEEKEVENTREG_31_04); gSaveContext.cycleSceneFlags[SCENE_INSIDETOWER].switch0 = 1; gSaveContext.save.permanentSceneFlags[SCENE_INSIDETOWER].switch0 = 1; @@ -870,13 +971,13 @@ void func_80144A94(SramContext* sramCtx) { gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; } - for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { - gSaveContext.unk_3DD0[i] = 0; - gSaveContext.unk_3DE0[i] = 0; - gSaveContext.unk_3E18[i] = 0; - gSaveContext.unk_3E50[i] = 0; - gSaveContext.unk_3E88[i] = 0; - gSaveContext.unk_3EC0[i] = 0; + for (i = 0; i < TIMER_ID_MAX; i++) { + gSaveContext.timerStates[i] = TIMER_STATE_OFF; + gSaveContext.timerCurTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimits[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerStartOsTimes[i] = 0; + gSaveContext.timerStopTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[i] = 0; } D_801BDAA0 = 1; @@ -886,15 +987,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) { +void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) { s32 i; s32 pad; s32 phi_t1; - s32 pad1[2]; + s32 pad1; s32 fileNum; if (gSaveContext.unk_3F3F) { @@ -902,7 +1007,7 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { if (gSaveContext.fileNum == 0xFF) { func_80185968(sramCtx->saveBuf, D_801C67C8[0], D_801C67F0[0]); - } else if (fileChooseCtx->unk_2446A[gSaveContext.fileNum] != 0) { + } else if (fileSelect->unk_2446A[gSaveContext.fileNum] != 0) { phi_t1 = gSaveContext.fileNum + 2; phi_t1 *= 2; @@ -941,33 +1046,32 @@ void Sram_OpenSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) { gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.permanentSceneFlags[i].collectible; } - for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) { - gSaveContext.unk_3DD0[i] = 0; - gSaveContext.unk_3DE0[i] = 0; - gSaveContext.unk_3E18[i] = 0; - gSaveContext.unk_3E50[i] = 0; - gSaveContext.unk_3E88[i] = 0; - gSaveContext.unk_3EC0[i] = 0; + for (i = 0; i < TIMER_ID_MAX; i++) { + gSaveContext.timerStates[i] = TIMER_STATE_OFF; + gSaveContext.timerCurTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimits[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerStartOsTimes[i] = 0; + gSaveContext.timerStopTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[i] = 0; } 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)) { - // Unconfirmed weekEventReg: "Woodfall Temple Prison Entrance raised / Water cleansed" - gSaveContext.save.entranceIndex = 0xCA0; - } else if (D_801C6A58[gSaveContext.save.owlSaveLocation] == 0x9A80 && - (gSaveContext.save.weekEventReg[33] & 0x80)) { - // Unconfirmed weekEventReg: "Mountain Village Unfrozen" - gSaveContext.save.entranceIndex = 0xAE80; + gSaveContext.save.entrance = D_801C6A58[(void)0, gSaveContext.save.owlSaveLocation]; + if ((gSaveContext.save.entrance == ENTRANCE(SOUTHERN_SWAMP_POISONED, 10)) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + gSaveContext.save.entrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 10); + } else if ((gSaveContext.save.entrance == ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8)) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + gSaveContext.save.entrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 8); } for (i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) { @@ -979,19 +1083,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) { @@ -1053,8 +1154,8 @@ void func_80145698(SramContext* sramCtx) { // Verifies save and use backup if corrupted? #ifdef NON_EQUIVALENT -void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { - FileChooseContext* fileChooseCtx = fileChooseCtx2; +void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) { + FileSelectState* fileSelect = fileSelect2; u16 sp7A; // u16 sp78; u16 sp76; @@ -1093,7 +1194,7 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } if (sp76 < 2) { - fileChooseCtx->unk_24468[sp76] = 0; + fileSelect->unk_24468[sp76] = 0; if (phi_s2) { bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]); @@ -1131,34 +1232,33 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { - fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + fileSelect->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; } - if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { - fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + if (!CHECK_NEWF(fileSelect->newf[sp76])) { + fileSelect->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { - fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + fileSelect->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; } - fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; - fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; - fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; - fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; - fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; - fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; - fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; - fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; - fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + fileSelect->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileSelect->health[sp76] = gSaveContext.save.playerData.health; + fileSelect->unk_24454[sp76] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24458[sp76] = gSaveContext.save.time; + fileSelect->unk_24460[sp76] = gSaveContext.save.day; + fileSelect->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileSelect->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileSelect->unk_24474[sp76] = CUR_UPG_VALUE(4); for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { phi_a0++; } } - fileChooseCtx->maskCount[sp76] = phi_a0; - fileChooseCtx->heartPieceCount[sp76] = - ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); + fileSelect->maskCount[sp76] = phi_a0; + fileSelect->heartPieceCount[sp76] = ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); } if (sp6E == 1) { @@ -1183,9 +1283,9 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } } } else if (sp76 < 4) { - fileChooseCtx->unk_24468[sp76] = 0; + fileSelect->unk_24468[sp76] = 0; - if (!CHECK_NEWF(fileChooseCtx->newf2[(s32)sp76])) { // TODO: Needed? + if (!CHECK_NEWF(fileSelect->newf2[(s32)sp76])) { // TODO: Needed? if (phi_s2) { bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, @@ -1225,34 +1325,34 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { Sram_CalcChecksum(&gSaveContext, D_801C6870[sp64 & 0xFFFFFFFF]); // TODO: Needed? for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.newf); sp7A++) { - fileChooseCtx->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; + fileSelect->newf[sp76][sp7A] = gSaveContext.save.playerData.newf[sp7A]; } - if (!CHECK_NEWF(fileChooseCtx->newf[sp76])) { - fileChooseCtx->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; + if (!CHECK_NEWF(fileSelect->newf[sp76])) { + fileSelect->unk_2440C[sp76] = gSaveContext.save.playerData.deaths; for (sp7A = 0; sp7A < ARRAY_COUNT(gSaveContext.save.playerData.playerName); sp7A++) { phi_s2 += 0; // TODO: Needed? - fileChooseCtx->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; + fileSelect->unk_24414[sp76][sp7A] = gSaveContext.save.playerData.playerName[sp7A]; } - fileChooseCtx->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; - fileChooseCtx->health[sp76] = gSaveContext.save.playerData.health; - fileChooseCtx->unk_24454[sp76] = gSaveContext.save.inventory.dungeonKeys[9]; - fileChooseCtx->unk_24444[sp76] = gSaveContext.save.inventory.questItems; - fileChooseCtx->unk_24458[sp76] = gSaveContext.save.time; - fileChooseCtx->unk_24460[sp76] = gSaveContext.save.day; - fileChooseCtx->unk_24468[sp76] = gSaveContext.save.isOwlSave; - fileChooseCtx->rupees[sp76] = gSaveContext.save.playerData.rupees; - fileChooseCtx->unk_24474[sp76] = CUR_UPG_VALUE(4); + fileSelect->healthCapacity[sp76] = gSaveContext.save.playerData.healthCapacity; + fileSelect->health[sp76] = gSaveContext.save.playerData.health; + fileSelect->unk_24454[sp76] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_24444[sp76] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24458[sp76] = gSaveContext.save.time; + fileSelect->unk_24460[sp76] = gSaveContext.save.day; + fileSelect->unk_24468[sp76] = gSaveContext.save.isOwlSave; + fileSelect->rupees[sp76] = gSaveContext.save.playerData.rupees; + fileSelect->unk_24474[sp76] = CUR_UPG_VALUE(4); for (sp7A = 0, phi_a0 = 0; sp7A < 24; sp7A++) { if (gSaveContext.save.inventory.items[sp7A + 24] != 0xFF) { phi_a0++; } } - fileChooseCtx->maskCount[sp76] = phi_a0; - fileChooseCtx->heartPieceCount[sp76] = + fileSelect->maskCount[sp76] = phi_a0; + fileSelect->heartPieceCount[sp76] = ((gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C); } @@ -1316,14 +1416,14 @@ void func_801457CC(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_801457CC.s") #endif -void func_80146580(FileChooseContext* fileChooseCtx2, SramContext* sramCtx, s32 fileNum) { - FileChooseContext* fileChooseCtx = fileChooseCtx2; +void func_80146580(FileSelectState* fileSelect2, SramContext* sramCtx, s32 fileNum) { + FileSelectState* fileSelect = fileSelect2; s32 pad; if (gSaveContext.unk_3F3F) { - if (fileChooseCtx->unk_2446A[fileNum]) { + if (fileSelect->unk_2446A[fileNum]) { func_80147314(sramCtx, fileNum); - fileChooseCtx->unk_2446A[fileNum] = 0; + fileSelect->unk_2446A[fileNum] = 0; } bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save)); @@ -1335,30 +1435,30 @@ void func_80146580(FileChooseContext* fileChooseCtx2, SramContext* sramCtx, s32 #ifdef NON_MATCHING // v0/v1 -void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { - FileChooseContext* fileChooseCtx = fileChooseCtx2; +void func_80146628(FileSelectState* fileSelect2, SramContext* sramCtx) { + FileSelectState* fileSelect = fileSelect2; u16 i; s16 maskCount; if (gSaveContext.unk_3F3F) { - if (fileChooseCtx->unk_2446A[fileChooseCtx->unk_2448E]) { - func_80147414(sramCtx, fileChooseCtx->unk_2448E, fileChooseCtx->fileNum); - fileChooseCtx->unk_24410[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + if (fileSelect->unk_2446A[fileSelect->unk_2448E]) { + func_80147414(sramCtx, fileSelect->unk_2448E, fileSelect->fileNum); + fileSelect->unk_24410[fileSelect->fileNum] = gSaveContext.save.playerData.deaths; for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { - fileChooseCtx->unk_24424[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + fileSelect->unk_24424[fileSelect->fileNum][i] = gSaveContext.save.playerData.playerName[i]; } - fileChooseCtx->unk_24438[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; - fileChooseCtx->unk_24440[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; - fileChooseCtx->unk_24456[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; - fileChooseCtx->unk_2444C[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; - fileChooseCtx->unk_2445C[fileChooseCtx->fileNum] = gSaveContext.save.time; - fileChooseCtx->unk_24464[fileChooseCtx->fileNum] = gSaveContext.save.day; - fileChooseCtx->unk_2446A[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; - fileChooseCtx->unk_24470[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + fileSelect->unk_24438[fileSelect->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileSelect->unk_24440[fileSelect->fileNum] = gSaveContext.save.playerData.health; + fileSelect->unk_24456[fileSelect->fileNum] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_2444C[fileSelect->fileNum] = gSaveContext.save.inventory.questItems; + fileSelect->unk_2445C[fileSelect->fileNum] = gSaveContext.save.time; + fileSelect->unk_24464[fileSelect->fileNum] = gSaveContext.save.day; + fileSelect->unk_2446A[fileSelect->fileNum] = gSaveContext.save.isOwlSave; + fileSelect->unk_24470[fileSelect->fileNum] = gSaveContext.save.playerData.rupees; // = CUR_UPG_VALUE(UPG_WALLET); - fileChooseCtx->unk_24476[fileChooseCtx->fileNum] = + fileSelect->unk_24476[fileSelect->fileNum] = (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; for (i = 0, maskCount = 0; i < 24; i++) { @@ -1367,41 +1467,39 @@ void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } } - fileChooseCtx->unk_2447A[fileChooseCtx->fileNum] = maskCount; - fileChooseCtx->unk_2447E[fileChooseCtx->fileNum] = - (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; + fileSelect->unk_2447A[fileSelect->fileNum] = maskCount; + fileSelect->unk_2447E[fileSelect->fileNum] = (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; } // clear buffer bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); // read to buffer - func_80185968(sramCtx->saveBuf, D_801C67C8[fileChooseCtx->unk_2448E * 2], - D_801C67F0[fileChooseCtx->unk_2448E * 2]); + func_80185968(sramCtx->saveBuf, D_801C67C8[fileSelect->unk_2448E * 2], D_801C67F0[fileSelect->unk_2448E * 2]); if (1) {} - func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileChooseCtx->unk_2448E * 2 + 1], - D_801C67F0[fileChooseCtx->unk_2448E * 2 + 1]); + func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileSelect->unk_2448E * 2 + 1], + D_801C67F0[fileSelect->unk_2448E * 2 + 1]); if (1) {} // copy buffer to save context Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save)); - fileChooseCtx->unk_2440C[fileChooseCtx->fileNum] = gSaveContext.save.playerData.deaths; + fileSelect->unk_2440C[fileSelect->fileNum] = gSaveContext.save.playerData.deaths; for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { - fileChooseCtx->unk_24414[fileChooseCtx->fileNum][i] = gSaveContext.save.playerData.playerName[i]; + fileSelect->unk_24414[fileSelect->fileNum][i] = gSaveContext.save.playerData.playerName[i]; } - fileChooseCtx->healthCapacity[fileChooseCtx->fileNum] = gSaveContext.save.playerData.healthCapacity; - fileChooseCtx->health[fileChooseCtx->fileNum] = gSaveContext.save.playerData.health; - fileChooseCtx->unk_24454[fileChooseCtx->fileNum] = gSaveContext.save.inventory.dungeonKeys[9]; - fileChooseCtx->unk_24444[fileChooseCtx->fileNum] = gSaveContext.save.inventory.questItems; - fileChooseCtx->unk_24458[fileChooseCtx->fileNum] = gSaveContext.save.time; - fileChooseCtx->unk_24460[fileChooseCtx->fileNum] = gSaveContext.save.day; - fileChooseCtx->unk_24468[fileChooseCtx->fileNum] = gSaveContext.save.isOwlSave; - fileChooseCtx->rupees[fileChooseCtx->fileNum] = gSaveContext.save.playerData.rupees; + fileSelect->healthCapacity[fileSelect->fileNum] = gSaveContext.save.playerData.healthCapacity; + fileSelect->health[fileSelect->fileNum] = gSaveContext.save.playerData.health; + fileSelect->unk_24454[fileSelect->fileNum] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_24444[fileSelect->fileNum] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24458[fileSelect->fileNum] = gSaveContext.save.time; + fileSelect->unk_24460[fileSelect->fileNum] = gSaveContext.save.day; + fileSelect->unk_24468[fileSelect->fileNum] = gSaveContext.save.isOwlSave; + fileSelect->rupees[fileSelect->fileNum] = gSaveContext.save.playerData.rupees; // = CUR_UPG_VALUE(UPG_WALLET); - fileChooseCtx->unk_24474[fileChooseCtx->fileNum] = + fileSelect->unk_24474[fileSelect->fileNum] = (gSaveContext.save.inventory.upgrades & gUpgradeMasks[4]) >> gUpgradeShifts[4]; for (i = 0, maskCount = 0; i < 24; i++) { @@ -1410,8 +1508,8 @@ void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } } - fileChooseCtx->maskCount[fileChooseCtx->fileNum] = maskCount; - fileChooseCtx->heartPieceCount[fileChooseCtx->fileNum] = + fileSelect->maskCount[fileSelect->fileNum] = maskCount; + fileSelect->heartPieceCount[fileSelect->fileNum] = (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; } @@ -1422,21 +1520,20 @@ void func_80146628(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_sram_NES/func_80146628.s") #endif -void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { +void Sram_InitSave(FileSelectState* fileSelect2, SramContext* sramCtx) { s32 phi_v0; u16 i; - FileChooseContext* fileChooseCtx = fileChooseCtx2; + FileSelectState* fileSelect = fileSelect2; s16 maskCount; if (gSaveContext.unk_3F3F) { Sram_InitNewSave(); - if (fileChooseCtx->unk_24480 == 0) { + if (fileSelect->unk_24480 == 0) { gSaveContext.save.cutscene = 0xFFF0; } for (phi_v0 = 0; phi_v0 < ARRAY_COUNT(gSaveContext.save.playerData.playerName); phi_v0++) { - gSaveContext.save.playerData.playerName[phi_v0] = - fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][phi_v0]; + gSaveContext.save.playerData.playerName[phi_v0] = fileSelect->unk_24414[fileSelect->unk_24480][phi_v0]; } gSaveContext.save.playerData.newf[0] = 'Z'; @@ -1452,24 +1549,24 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save)); for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.newf); i++) { - fileChooseCtx->newf[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.newf[i]; + fileSelect->newf[fileSelect->unk_24480][i] = gSaveContext.save.playerData.newf[i]; } - fileChooseCtx->unk_2440C[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.deaths; + fileSelect->unk_2440C[fileSelect->unk_24480] = gSaveContext.save.playerData.deaths; for (i = 0; i < ARRAY_COUNT(gSaveContext.save.playerData.playerName); i++) { - fileChooseCtx->unk_24414[fileChooseCtx->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; + fileSelect->unk_24414[fileSelect->unk_24480][i] = gSaveContext.save.playerData.playerName[i]; } - fileChooseCtx->healthCapacity[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.healthCapacity; - fileChooseCtx->health[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.health; - fileChooseCtx->unk_24454[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.dungeonKeys[9]; - fileChooseCtx->unk_24444[fileChooseCtx->unk_24480] = gSaveContext.save.inventory.questItems; - fileChooseCtx->unk_24458[fileChooseCtx->unk_24480] = gSaveContext.save.time; - fileChooseCtx->unk_24460[fileChooseCtx->unk_24480] = gSaveContext.save.day; - fileChooseCtx->unk_24468[fileChooseCtx->unk_24480] = gSaveContext.save.isOwlSave; - fileChooseCtx->rupees[fileChooseCtx->unk_24480] = gSaveContext.save.playerData.rupees; - fileChooseCtx->unk_24474[fileChooseCtx->unk_24480] = CUR_UPG_VALUE(UPG_WALLET); + fileSelect->healthCapacity[fileSelect->unk_24480] = gSaveContext.save.playerData.healthCapacity; + fileSelect->health[fileSelect->unk_24480] = gSaveContext.save.playerData.health; + fileSelect->unk_24454[fileSelect->unk_24480] = gSaveContext.save.inventory.defenseHearts; + fileSelect->unk_24444[fileSelect->unk_24480] = gSaveContext.save.inventory.questItems; + fileSelect->unk_24458[fileSelect->unk_24480] = gSaveContext.save.time; + fileSelect->unk_24460[fileSelect->unk_24480] = gSaveContext.save.day; + fileSelect->unk_24468[fileSelect->unk_24480] = gSaveContext.save.isOwlSave; + fileSelect->rupees[fileSelect->unk_24480] = gSaveContext.save.playerData.rupees; + fileSelect->unk_24474[fileSelect->unk_24480] = CUR_UPG_VALUE(UPG_WALLET); for (i = 0, maskCount = 0; i < 24; i++) { if (gSaveContext.save.inventory.items[i + 24] != ITEM_NONE) { @@ -1477,8 +1574,8 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx2, SramContext* sramCtx) { } } - fileChooseCtx->maskCount[fileChooseCtx->unk_24480] = maskCount; - fileChooseCtx->heartPieceCount[fileChooseCtx->unk_24480] = + fileSelect->maskCount[fileSelect->unk_24480] = maskCount; + fileSelect->heartPieceCount[fileSelect->unk_24480] = (gSaveContext.save.inventory.questItems & 0xF0000000) >> 0x1C; } @@ -1495,14 +1592,14 @@ void func_80146DF8(SramContext* sramCtx) { } void Sram_InitSram(GameState* gameState, SramContext* sramCtx) { - if (gSaveContext.save.entranceIndex) {} // Required to match + if (gSaveContext.save.entrance) {} // Required to match func_801A3D98(gSaveContext.options.audioSetting); } -void Sram_Alloc(GameState* gamestate, SramContext* sramCtx) { +void Sram_Alloc(GameState* gameState, SramContext* sramCtx) { if (gSaveContext.unk_3F3F) { - sramCtx->saveBuf = THA_AllocEndAlign16(&gamestate->heap, SAVE_BUFFER_SIZE); + sramCtx->saveBuf = THA_AllocEndAlign16(&gameState->heap, SAVE_BUFFER_SIZE); sramCtx->status = 0; } } @@ -1519,9 +1616,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,24 +1629,22 @@ 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; day = gSaveContext.save.day; - // Unconfirmed: "Obtained Fierce Deity Mask?" - gSaveContext.save.weekEventReg[84] &= (u8)~0x20; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_84_20); - 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) { @@ -1577,7 +1672,7 @@ void func_80147068(SramContext* sramCtx) { sramCtx->status = 4; } } - } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->unk_18) >= SECONDS_TO_TIMER(2)) { sramCtx->status = 0; } } @@ -1614,7 +1709,7 @@ void func_80147198(SramContext* sramCtx) { sramCtx->status = 4; } } - } else if (((osGetTime() - sramCtx->unk_18) * 0x40) / 3000 / 10000 >= 200) { + } else if (OSTIME_TO_TIMER(osGetTime() - sramCtx->unk_18) >= SECONDS_TO_TIMER(2)) { sramCtx->status = 0; bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE); gSaveContext.save.isOwlSave = false; diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 3e5443bc6..8f412364d 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -17,12 +17,12 @@ 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; @@ -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)) { + 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); @@ -80,15 +80,15 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** 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_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,7 +112,7 @@ 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, dListCount * sizeof(Mtx)); if (skeleton == NULL) { return NULL; @@ -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)) { + 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); @@ -147,21 +147,21 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo } 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_Pop(); return gfx; } -s32 SubS_InCsMode(GlobalContext* globalCtx) { +s32 SubS_InCsMode(PlayState* play) { s32 inCsMode = false; - if (Play_InCsMode(globalCtx)) { + if (Play_InCsMode(play)) { inCsMode = true; } @@ -178,8 +178,7 @@ s32 SubS_InCsMode(GlobalContext* globalCtx) { * @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 + * @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; @@ -214,25 +213,280 @@ 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; @@ -245,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; @@ -254,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) { @@ -277,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; } @@ -331,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) + @@ -344,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; @@ -362,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; @@ -382,57 +816,66 @@ s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { } //! TODO: Needs docs with func_800B8500 -s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type) { +s32 func_8013C964(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 itemId, s32 type) { s32 ret = false; s16 x; s16 y; f32 xzDistToPlayerTemp; - Actor_GetScreenPos(globalCtx, actor, &x, &y); + Actor_GetScreenPos(play, actor, &x, &y); switch (type) { case 1: yRange = fabsf(actor->playerHeightRel) + 1.0f; xzRange = actor->xzDistToPlayer + 1.0f; - ret = Actor_PickUp(actor, globalCtx, itemId, xzRange, yRange); + ret = Actor_PickUp(actor, play, itemId, xzRange, yRange); break; + case 2: if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { - ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + ret = func_800B8500(actor, play, xzRange, yRange, itemId); } break; + case 3: //! @bug: Both x and y conditionals are always true, || should be an && if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) { - ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + ret = func_800B8500(actor, play, xzRange, yRange, itemId); } break; + case 4: yRange = fabsf(actor->playerHeightRel) + 1.0f; xzRange = actor->xzDistToPlayer + 1.0f; xzDistToPlayerTemp = actor->xzDistToPlayer; actor->xzDistToPlayer = 0.0f; - actor->flags |= 0x10000; - ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + actor->flags |= ACTOR_FLAG_10000; + ret = func_800B8500(actor, play, xzRange, yRange, itemId); actor->xzDistToPlayer = xzDistToPlayerTemp; break; + case 5: //! @bug: Both x and y conditionals are always true, || should be an && if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange) && actor->isTargeted) { - actor->flags |= 0x10000; - ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + actor->flags |= ACTOR_FLAG_10000; + ret = func_800B8500(actor, play, xzRange, yRange, itemId); } break; + case 6: //! @bug: Both x and y conditionals are always true, || should be an && if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) && (fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) { - actor->flags |= 0x10000; - ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId); + actor->flags |= ACTOR_FLAG_10000; + ret = func_800B8500(actor, play, xzRange, yRange, itemId); } break; + + default: + break; } + return ret; } @@ -557,10 +1000,10 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { 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++, gShadowDL); + 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++, gShadowVtxDL); + gSPDisplayList(POLY_OPA_DISP++, gShadowModelDL); CLOSE_DISPS(gfxCtx); } @@ -575,7 +1018,7 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { * @param[in] stepMin the minimun step in degrees * @param[in] stepMax the maximum step in degrees */ -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { +s16 SubS_ComputeTrackPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax) { s16 prevRot = *rot; f32 step; f32 prevRotStep; @@ -611,44 +1054,42 @@ s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f /** * Computes the necessary HeadRot and TorsoRot to smoothly turn an actors's head and torso to a point * - * @param[in] point the point to turn to + * @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] turnTarget the intermediate target step that headRot and torsoRot step towards + * @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_ComputeTurnToPointRot and - * TurnOptions/TurnOptionsSet` - * + * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTrackPointRot() */ -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, - TurnOptionsSet* options) { +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 = point->x - focusPos->x; + f32 diffX = target->x - focusPos->x; s16 targetX; - f32 diffZ = point->z - focusPos->z; + f32 diffZ = target->z - focusPos->z; - yaw = Math_FAtan2F(diffZ, diffX); - pitch = Math_FAtan2F(sqrtf(SQ(diffX) + SQ(diffZ)), point->y - focusPos->y); - Math_SmoothStepToS(&turnTarget->x, pitch, 4, 0x2710, 0); - Math_SmoothStepToS(&turnTarget->y, yaw, 4, 0x2710, 0); + yaw = Math_Atan2S_XY(diffZ, diffX); + pitch = Math_Atan2S_XY(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_ComputeTurnToPointRot(&headRot->x, options->headRotX.rotMax, turnTarget->x, options->headRotX.slowness, - options->headRotX.rotStepMin, options->headRotX.rotStepMax); + SubS_ComputeTrackPointRot(&headRot->x, options->headRotX.rotMax, trackTarget->x, options->headRotX.slowness, + options->headRotX.rotStepMin, options->headRotX.rotStepMax); //! @bug: torsoRotX uses headRotX slowness - SubS_ComputeTurnToPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, - options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); + SubS_ComputeTrackPointRot(&torsoRot->x, options->torsoRotX.rotMax, targetX, options->headRotX.slowness, + options->torsoRotX.rotStepMin, options->torsoRotX.rotStepMax); - targetY = turnTarget->y - shapeRot->y; - SubS_ComputeTurnToPointRot(&headRot->y, options->headRotY.rotMax, targetY - torsoRot->y, options->headRotY.slowness, - options->headRotY.rotStepMin, options->headRotY.rotStepMax); - SubS_ComputeTurnToPointRot(&torsoRot->y, options->torsoRotY.rotMax, targetY - headRot->y, - options->torsoRotY.slowness, options->torsoRotY.rotStepMin, - options->torsoRotY.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; } @@ -657,8 +1098,8 @@ 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) { @@ -720,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) { @@ -745,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; @@ -757,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; @@ -766,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) { @@ -781,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); @@ -817,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; @@ -839,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; @@ -867,22 +1306,22 @@ void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* diff.z = actorPath->curPoint.z - actorPath->worldPos->z; actorPath->distSqToCurPointXZ = Math3D_XZLengthSquared(diff.x, diff.z); actorPath->distSqToCurPoint = Math3D_LengthSquared(&diff); - actorPath->rotToCurPoint.y = Math_FAtan2F(diff.z, diff.x); - actorPath->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPath->distSqToCurPointXZ), -diff.y); + actorPath->rotToCurPoint.y = Math_Atan2S_XY(diff.z, diff.x); + actorPath->rotToCurPoint.x = Math_Atan2S_XY(sqrtf(actorPath->distSqToCurPointXZ), -diff.y); 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); @@ -918,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; } } @@ -944,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) { @@ -1004,9 +1443,7 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { * @param[in] rot the angles to rotate with, uses just the x and y components * @param[out] plane the computed plane * - * Notes: - * The unit input vector is expected to already be normalized (only uses are with the z unit vector) - * + * @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; @@ -1053,18 +1490,18 @@ s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePoi * 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; } @@ -1072,18 +1509,18 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor } //! TODO: Needs docs with func_800B8500 -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, +s32 func_8013E748(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc) { s32 ret = false; - if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(globalCtx, actor, data))) { - ret = func_800B8500(actor, globalCtx, xzRange, yRange, exchangeItemId); + if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(play, actor, data))) { + ret = func_800B8500(actor, play, xzRange, yRange, exchangeItemId); } return ret; } -s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data) { - Player* player = GET_PLAYER(globalCtx); +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)); @@ -1102,13 +1539,13 @@ s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, voi } //! TODO: Needs docs with func_800B8500 -s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, +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, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther); + return func_8013E748(actor, play, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther); } /** @@ -1129,9 +1566,9 @@ s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang * @param[in] torsoZRotStepMax the max torso's Z rotation step * @param[in] torsoXRotStepMax the max torso's X rotation step */ -s32 SubS_TurnToPointStep(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) { +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; diff --git a/src/code/z_view.c b/src/code/z_view.c index 915c196b7..105e6643a 100644 --- a/src/code/z_view.c +++ b/src/code/z_view.c @@ -1,4 +1,9 @@ #include "global.h" +#include "z64shrink_window.h" +#include "z64view.h" + +s32 View_ApplyPerspective(View* view); +s32 View_ApplyOrtho(View* view); void View_ViewportToVp(Vp* dest, Viewport* src) { s32 width = src->rightX - src->leftX; @@ -13,41 +18,45 @@ void View_ViewportToVp(Vp* dest, Viewport* src) { dest->vp.vtrans[2] = 0x01FF; dest->vp.vtrans[3] = 0; - if (src->leftX == 0 && src->rightX == 576 && src->topY == 0 && src->bottomY) {} + if ((src->leftX == 0) && (src->rightX == SCREEN_WIDTH_HIGH_RES) && (src->topY == 0) && + (src->bottomY == SCREEN_HEIGHT_HIGH_RES)) {} } void View_Init(View* view, GraphicsContext* gfxCtx) { view->gfxCtx = gfxCtx; + view->viewport.topY = 0; - view->viewport.bottomY = 240; + view->viewport.bottomY = SCREEN_HEIGHT; view->viewport.leftX = 0; - view->viewport.rightX = 320; + view->viewport.rightX = SCREEN_WIDTH; + view->magic = 0x56494557; // "VIEW" - view->unk164 = 0; - view->flags = 1 | 2 | 4; - - if (1) { - ; - } + if (1) {} view->scale = 1.0f; - view->up.y = 1.0f; view->fovy = 60.0f; - view->eye.x = 0.0f; - view->eye.y = 0.0f; - view->at.x = 0.0f; - view->up.x = 0.0f; - view->up.z = 0.0f; view->zNear = 10.0f; view->zFar = 12800.0f; + + view->eye.x = 0.0f; + view->eye.y = 0.0f; view->eye.z = -1.0f; + view->at.x = 0.0f; + + view->up.x = 0.0f; + view->up.y = 1.0f; + view->up.z = 0.0f; + + view->unk164 = 0; + view->flags = VIEW_VIEWING | VIEW_VIEWPORT | VIEW_PROJECTION_PERSPECTIVE; + View_InitDistortion(view); } -void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { - if (eye->x == at->x && eye->z == at->z) { +void View_LookAt(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { + if ((eye->x == at->x) && (eye->z == at->z)) { eye->z += 0.1f; up->z = 0.0f; up->x = 0.0f; @@ -57,17 +66,21 @@ void View_SetViewOrientation(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { view->eye = *eye; view->at = *at; view->up = *up; - view->flags |= 1; + view->flags |= VIEW_VIEWING; } -void func_8013F050(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { +/* + * Unused. View_LookAt is always used instead. This version is similar but + * is missing the input sanitization and the update to the flags. + */ +void View_LookAtUnsafe(View* view, Vec3f* eye, Vec3f* at, Vec3f* up) { view->eye = *eye; view->at = *at; view->up = *up; } void View_SetScale(View* view, f32 scale) { - view->flags |= 4; + view->flags |= VIEW_PROJECTION_PERSPECTIVE; view->scale = scale; } @@ -75,28 +88,32 @@ void View_GetScale(View* view, f32* scale) { *scale = view->scale; } -void func_8013F0D0(View* view, f32 fovy, f32 zNear, f32 zFar) { +void View_SetPerspective(View* view, f32 fovy, f32 zNear, f32 zFar) { view->fovy = fovy; view->zNear = zNear; view->zFar = zFar; - view->flags |= 4; + view->flags |= VIEW_PROJECTION_PERSPECTIVE; } -void func_8013F100(View* view, f32* fovy, f32* zNear, f32* zFar) { +void View_GetPerspective(View* view, f32* fovy, f32* zNear, f32* zFar) { *fovy = view->fovy; *zNear = view->zNear; *zFar = view->zFar; } -void func_8013F120(View* view, f32 fovy, f32 zNear, f32 zFar) { +void View_SetOrtho(View* view, f32 fovy, f32 zNear, f32 zFar) { view->fovy = fovy; view->zNear = zNear; view->zFar = zFar; - view->flags |= 8; + view->flags |= VIEW_PROJECTION_ORTHO; view->scale = 1.0f; } -void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar) { +/* + * Identical to View_GetPerspective, and never called. + * Named as it seems to fit the "set, get" pattern. + */ +void View_GetOrtho(View* view, f32* fovy, f32* zNear, f32* zFar) { *fovy = view->fovy; *zNear = view->zNear; *zFar = view->zFar; @@ -104,14 +121,14 @@ void func_8013F15C(View* view, f32* fovy, f32* zNear, f32* zFar) { void View_SetViewport(View* view, Viewport* viewport) { view->viewport = *viewport; - view->flags |= 2; + view->flags |= VIEW_VIEWPORT; } void View_GetViewport(View* view, Viewport* viewport) { *viewport = view->viewport; } -void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { +void View_SetScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { Gfx* gfxp = *gfx; gDPSetScissor(gfxp++, G_SC_NON_INTERLACE, ulx, uly, lrx, lry); @@ -119,7 +136,7 @@ void View_WriteScissor(Gfx** gfx, s32 ulx, s32 uly, s32 lrx, s32 lry) { *gfx = gfxp; } -void View_SyncAndWriteScissor(View* view, Gfx** gfx) { +void View_ClearScissor(View* view, Gfx** gfx) { Gfx* gfxp = *gfx; s32 ulx = view->viewport.leftX; s32 uly = view->viewport.topY; @@ -127,12 +144,12 @@ void View_SyncAndWriteScissor(View* view, Gfx** gfx) { s32 lry = view->viewport.bottomY; gDPPipeSync(gfxp++); - View_WriteScissor(&gfxp, ulx, uly, lrx, lry); + View_SetScissor(&gfxp, ulx, uly, lrx, lry); *gfx = gfxp; } -void View_SetScissorForLetterbox(View* view) { +void View_ApplyLetterbox(View* view) { s32 letterboxY; s32 letterboxX; s32 pad1; @@ -143,20 +160,21 @@ void View_SetScissorForLetterbox(View* view) { OPEN_DISPS(view->gfxCtx); - letterboxY = ShrinkWindow_GetLetterboxMagnitude(); + letterboxY = ShrinkWindow_Letterbox_GetSize(); + letterboxX = -1; // The following is optimized to varX = 0 but affects codegen if (letterboxX < 0) { letterboxX = 0; } - if (letterboxX > 160) { - letterboxX = 160; + if (letterboxX > (SCREEN_WIDTH / 2)) { + letterboxX = SCREEN_WIDTH / 2; } if (letterboxY < 0) { letterboxY = 0; - } else if (letterboxY > 120) { - letterboxY = 120; + } else if (letterboxY > (SCREEN_HEIGHT / 2)) { + letterboxY = SCREEN_HEIGHT / 2; } ulx = view->viewport.leftX + letterboxX; @@ -166,31 +184,31 @@ void View_SetScissorForLetterbox(View* view) { gDPPipeSync(POLY_OPA_DISP++); { - s32 pad3; + s32 pad2; Gfx* polyOpa; polyOpa = POLY_OPA_DISP; - View_WriteScissor(&polyOpa, ulx, uly, lrx, lry); + View_SetScissor(&polyOpa, ulx, uly, lrx, lry); POLY_OPA_DISP = polyOpa; } gDPPipeSync(POLY_XLU_DISP++); { Gfx* polyXlu; - s32 pad4; + s32 pad3; polyXlu = POLY_XLU_DISP; - View_WriteScissor(&polyXlu, ulx, uly, lrx, lry); + View_SetScissor(&polyXlu, ulx, uly, lrx, lry); POLY_XLU_DISP = polyXlu; } CLOSE_DISPS(view->gfxCtx); } -s32 View_SetDistortionDirRot(View* view, f32 dirRotX, f32 dirRotY, f32 dirRotZ) { - view->distortionDirRot.x = dirRotX; - view->distortionDirRot.y = dirRotY; - view->distortionDirRot.z = dirRotZ; +s32 View_SetDistortionOrientation(View* view, f32 rotX, f32 rotY, f32 rotZ) { + view->distortionOrientation.x = rotX; + view->distortionOrientation.y = rotY; + view->distortionOrientation.z = rotZ; return 1; } @@ -207,22 +225,22 @@ s32 View_SetDistortionSpeed(View* view, f32 speed) { } s32 View_InitDistortion(View* view) { - view->distortionDirRot.x = 0.0f; - view->distortionDirRot.y = 0.0f; - view->distortionDirRot.z = 0.0f; + view->distortionOrientation.x = 0.0f; + view->distortionOrientation.y = 0.0f; + view->distortionOrientation.z = 0.0f; view->distortionScale.x = 1.0f; view->distortionScale.y = 1.0f; view->distortionScale.z = 1.0f; - view->curDistortionDirRot = view->distortionDirRot; + view->curDistortionOrientation = view->distortionOrientation; view->curDistortionScale = view->distortionScale; view->distortionSpeed = 0.0f; return 1; } s32 View_ClearDistortion(View* view) { - view->distortionDirRot.x = 0.0f; - view->distortionDirRot.y = 0.0f; - view->distortionDirRot.z = 0.0f; + view->distortionOrientation.x = 0.0f; + view->distortionOrientation.y = 0.0f; + view->distortionOrientation.z = 0.0f; view->distortionScale.x = 1.0f; view->distortionScale.y = 1.0f; view->distortionScale.z = 1.0f; @@ -230,8 +248,8 @@ s32 View_ClearDistortion(View* view) { return 1; } -s32 View_SetDistortion(View* view, Vec3f dirRot, Vec3f scale, f32 speed) { - view->distortionDirRot = dirRot; +s32 View_SetDistortion(View* view, Vec3f orientation, Vec3f scale, f32 speed) { + view->distortionOrientation = orientation; view->distortionScale = scale; view->distortionSpeed = speed; return 1; @@ -242,17 +260,19 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { if (view->distortionSpeed == 0.0f) { return false; - } else if (view->distortionSpeed == 1.0f) { - view->curDistortionDirRot = view->distortionDirRot; + } + + if (view->distortionSpeed == 1.0f) { + view->curDistortionOrientation = view->distortionOrientation; view->curDistortionScale = view->distortionScale; view->distortionSpeed = 0.0f; } else { - view->curDistortionDirRot.x = - F32_LERPIMP(view->curDistortionDirRot.x, view->distortionDirRot.x, view->distortionSpeed); - view->curDistortionDirRot.y = - F32_LERPIMP(view->curDistortionDirRot.y, view->distortionDirRot.y, view->distortionSpeed); - view->curDistortionDirRot.z = - F32_LERPIMP(view->curDistortionDirRot.z, view->distortionDirRot.z, view->distortionSpeed); + view->curDistortionOrientation.x = + F32_LERPIMP(view->curDistortionOrientation.x, view->distortionOrientation.x, view->distortionSpeed); + view->curDistortionOrientation.y = + F32_LERPIMP(view->curDistortionOrientation.y, view->distortionOrientation.y, view->distortionSpeed); + view->curDistortionOrientation.z = + F32_LERPIMP(view->curDistortionOrientation.z, view->distortionOrientation.z, view->distortionSpeed); view->curDistortionScale.x = F32_LERPIMP(view->curDistortionScale.x, view->distortionScale.x, view->distortionSpeed); @@ -264,29 +284,32 @@ s32 View_StepDistortion(View* view, Mtx* projectionMtx) { 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_RotateXFApply(view->curDistortionOrientation.x); + Matrix_RotateYF(view->curDistortionOrientation.y, MTXMODE_APPLY); + Matrix_RotateZF(view->curDistortionOrientation.z, MTXMODE_APPLY); Matrix_Scale(view->curDistortionScale.x, view->curDistortionScale.y, view->curDistortionScale.z, MTXMODE_APPLY); - Matrix_RotateZF(-view->curDistortionDirRot.z, MTXMODE_APPLY); - Matrix_RotateYF(-view->curDistortionDirRot.y, MTXMODE_APPLY); - Matrix_RotateXFApply(-view->curDistortionDirRot.x); + Matrix_RotateZF(-view->curDistortionOrientation.z, MTXMODE_APPLY); + Matrix_RotateYF(-view->curDistortionOrientation.y, MTXMODE_APPLY); + Matrix_RotateXFApply(-view->curDistortionOrientation.x); Matrix_ToMtx(projectionMtx); return true; } -void View_RenderView(View* view, s32 uParm2) { - uParm2 = (view->flags & uParm2) | uParm2 >> 4; +/** + * Apply view to POLY_OPA_DISP, POLY_XLU_DISP (and OVERLAY_DISP if ortho) + */ +void View_Apply(View* view, s32 mask) { + mask = (view->flags & mask) | (mask >> 4); - if (uParm2 & 8) { - View_RenderToOrthographicMatrix(view); + if (mask & VIEW_PROJECTION_ORTHO) { + View_ApplyOrtho(view); } else { - View_RenderToPerspectiveMatrix(view); + View_ApplyPerspective(view); } } -s32 View_RenderToPerspectiveMatrix(View* view) { +s32 View_ApplyPerspective(View* view) { f32 aspect; s32 width; s32 height; @@ -297,36 +320,39 @@ s32 View_RenderToPerspectiveMatrix(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + // Viewport + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; - View_SetScissorForLetterbox(view); + View_ApplyLetterbox(view); gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + // Perspective projection + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; width = view->viewport.rightX - view->viewport.leftX; height = view->viewport.bottomY - view->viewport.topY; aspect = (f32)width / (f32)height; - guPerspective(projection, &view->normal, view->fovy, aspect, view->zNear, view->zFar, view->scale); + guPerspective(projection, &view->perspNorm, view->fovy, aspect, view->zNear, view->zFar, view->scale); view->projection = *projection; View_StepDistortion(view, projection); - gSPPerspNormalize(POLY_OPA_DISP++, view->normal); + gSPPerspNormalize(POLY_OPA_DISP++, view->perspNorm); gSPMatrix(POLY_OPA_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - gSPPerspNormalize(POLY_XLU_DISP++, view->normal); + gSPPerspNormalize(POLY_XLU_DISP++, view->perspNorm); gSPMatrix(POLY_XLU_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - viewing = GRAPH_ALLOC(gfxCtx, sizeof(*viewing)); + // View matrix (look-at) + viewing = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->viewingPtr = viewing; - if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { + if ((view->eye.x == view->at.x) && (view->eye.y == view->at.y) && (view->eye.z == view->at.z)) { view->eye.z += 2.0f; } @@ -343,24 +369,24 @@ s32 View_RenderToPerspectiveMatrix(View* view) { return 1; } -s32 View_RenderToOrthographicMatrix(View* view) { +s32 View_ApplyOrtho(View* view) { Vp* vp; Mtx* projection; GraphicsContext* gfxCtx = view->gfxCtx; OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; - View_SetScissorForLetterbox(view); + View_ApplyLetterbox(view); gSPViewport(POLY_OPA_DISP++, vp); gSPViewport(POLY_XLU_DISP++, vp); gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, @@ -376,7 +402,10 @@ s32 View_RenderToOrthographicMatrix(View* view) { return 1; } -s32 func_8013FBC8(View* view) { +/** + * Apply scissor, viewport and projection (ortho) to OVERLAY_DISP. + */ +s32 View_ApplyOrthoToOverlay(View* view) { Vp* vp; Mtx* projection; GraphicsContext* gfxCtx; @@ -385,7 +414,7 @@ s32 func_8013FBC8(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -395,26 +424,29 @@ s32 func_8013FBC8(View* view) { s32 pad; overlay = OVERLAY_DISP; - View_WriteScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, - view->viewport.bottomY); + View_SetScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, + view->viewport.bottomY); OVERLAY_DISP = overlay; } gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, view->zNear, view->zFar, view->scale); view->projection = *projection; - gSPMatrix(OVERLAY_DISP++, projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(OVERLAY_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); CLOSE_DISPS(gfxCtx); return 1; } -s32 func_8013FD74(View* view) { +/** + * Apply scissor, viewport, view and projection (perspective) to OVERLAY_DISP. + */ +s32 View_ApplyPerspectiveToOverlay(View* view) { f32 aspect; s32 width; s32 height; @@ -428,7 +460,7 @@ s32 func_8013FD74(View* view) { OPEN_DISPS(gfxCtx); - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, &view->viewport); view->vp = *vp; @@ -438,28 +470,30 @@ s32 func_8013FD74(View* view) { Gfx* overlay; overlay = OVERLAY_DISP; - View_WriteScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, - view->viewport.bottomY); + View_SetScissor(&overlay, view->viewport.leftX, view->viewport.topY, view->viewport.rightX, + view->viewport.bottomY); OVERLAY_DISP = overlay; } gSPViewport(OVERLAY_DISP++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; width = view->viewport.rightX - view->viewport.leftX; height = view->viewport.bottomY - view->viewport.topY; aspect = (f32)width / (f32)height; - guPerspective(projection, &view->normal, view->fovy, aspect, view->zNear, view->zFar, view->scale); + guPerspective(projection, &view->perspNorm, view->fovy, aspect, view->zNear, view->zFar, view->scale); + view->projection = *projection; - gSPPerspNormalize(OVERLAY_DISP++, view->normal); + gSPPerspNormalize(OVERLAY_DISP++, view->perspNorm); gSPMatrix(OVERLAY_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - viewing = GRAPH_ALLOC(gfxCtx, sizeof(*viewing)); + viewing = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->viewingPtr = viewing; + // This check avoids a divide-by-zero in guLookAt if eye == at if (view->eye.x == view->at.x && view->eye.y == view->at.y && view->eye.z == view->at.z) { view->eye.z += 2.0f; } @@ -476,7 +510,10 @@ s32 func_8013FD74(View* view) { return 1; } -s32 func_80140024(View* view) { +/** + * Just updates view's view matrix from its eye/at/up vectors. + */ +s32 View_UpdateViewingMatrix(View* view) { guLookAt(view->viewingPtr, view->eye.x, view->eye.y, view->eye.z, view->at.x, view->at.y, view->at.z, view->up.x, view->up.y, view->up.z); @@ -486,22 +523,22 @@ s32 func_80140024(View* view) { return 1; } -s32 func_801400CC(View* view, Gfx** gfxp) { +s32 View_ApplyTo(View* view, Gfx** gfxp) { Gfx* gfx = *gfxp; GraphicsContext* gfxCtx = view->gfxCtx; Viewport* viewport = &view->viewport; Mtx* projection; Vp* vp; - vp = GRAPH_ALLOC(gfxCtx, sizeof(*vp)); + vp = GRAPH_ALLOC(gfxCtx, sizeof(Vp)); View_ViewportToVp(vp, viewport); view->vp = *vp; - View_SyncAndWriteScissor(view, &gfx); + View_ClearScissor(view, &gfx); gSPViewport(gfx++, vp); - projection = GRAPH_ALLOC(gfxCtx, sizeof(*projection)); + projection = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); view->projectionPtr = projection; guOrtho(projection, gScreenWidth * -0.5f, gScreenWidth * 0.5f, gScreenHeight * -0.5f, gScreenHeight * 0.5f, @@ -509,7 +546,7 @@ s32 func_801400CC(View* view, Gfx** gfxp) { view->projection = *projection; - gSPMatrix(gfx++, projection, G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gfx++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); *gfxp = gfx; return 1; diff --git a/src/code/z_vimode.c b/src/code/z_vimode.c index 76479a028..b7d2dea64 100644 --- a/src/code/z_vimode.c +++ b/src/code/z_vimode.c @@ -15,9 +15,3 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_vimode/func_8014090C.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_vimode/func_80140970.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vimode/func_80140CE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vimode/func_80140D04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vimode/func_80140D10.s") 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..907004a7a 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -1,15 +1,15 @@ #include "global.h" -s32 D_801C5E30[] = { 0, 0x2000, 0x4000, 0x6000, 0x8000, 0xC000 }; +u32 D_801C5E30[] = { 0, 0x2000, 0x4000, 0x6000, 0x8000, 0xC000 }; u16 D_801C5E48[] = { 0, 2, 10, 12, 2, 4, 12, 14, 10, 12, 20, 22, 12, 14, 22, 24, 1, 3, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19, 21, 23, }; -s32 D_801C5E88[] = { 0, 0x7C0, 0xF80, 0x1740, 0x1F00 }; +s32 D_801C5E88[] = { 0, 62 << 5, 124 << 5, 186 << 5, 248 << 5 }; -s32 D_801C5E9C[] = { 0, 0x7C0, 0xF80, 0x1740, 0x1F00 }; +s32 D_801C5E9C[] = { 0, 62 << 5, 124 << 5, 186 << 5, 248 << 5 }; -s32 D_801C5EB0[] = { 0, 0x7C0, 0xF80, 0x7C0, 0 }; +s32 D_801C5EB0[] = { 0, 62 << 5, 124 << 5, 62 << 5, 0 }; s16 D_801C5EC4[] = { 0, 16, 19, 18, 16, 1, 20, 19, 1, 17, 21, 20, 17, 5, 22, 21, 18, 19, 23, 2, 19, 20, @@ -17,7 +17,155 @@ s16 D_801C5EC4[] = { 24, 7, 29, 28, 25, 26, 30, 10, 26, 27, 11, 30, 27, 28, 31, 11, 28, 29, 15, 31, }; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_vr_box/func_80142440.s") +s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, + s32 arg8) { + s32 i; + s32 j; + s32 k; + s16 phi_a0_4; + s16 phi_t1; + s32 temp1; + u16 index; + s16 phi_a2_4; + s16 phi_ra; + s16 phi_t2_4; + s32 temp2; + s32 roomVtxPosX[5 * 5]; + s32 roomVtxPosY[5 * 5]; + s32 roomVtxPosZ[5 * 5]; + s32 roomVtxTexU[5 * 5]; + s32 roomVtxTexV[5 * 5]; + s32 pad; + + switch (arg8) { + case 0: + case 1: + temp1 = arg4; + + for (i = 0, k = 0; k < 25; i++) { + temp2 = arg3; + for (j = 0; j < 5; j++, k++) { + roomVtxPosZ[k] = arg5; + roomVtxPosX[k] = temp2; + roomVtxPosY[k] = temp1; + roomVtxTexU[k] = D_801C5E88[j]; + roomVtxTexV[k] = D_801C5EB0[i]; + temp2 += arg6; + } + temp1 += arg7; + } + break; + + case 2: + case 3: + temp1 = arg4; + + for (i = 0, k = 0; k < 25; i++) { + temp2 = arg5; + for (j = 0; j < 5; j++, k++) { + roomVtxPosX[k] = arg3; + roomVtxPosY[k] = temp1; + roomVtxPosZ[k] = temp2; + roomVtxTexU[k] = D_801C5E88[j]; + roomVtxTexV[k] = D_801C5EB0[i]; + temp2 += arg6; + } + temp1 += arg7; + } + break; + + case 4: + case 5: + temp1 = arg5; + + for (i = 0, k = 0; k < 25; i++) { + temp2 = arg3; + for (j = 0; j < 5; j++, k++) { + roomVtxPosY[k] = arg4; + roomVtxPosX[k] = temp2; + roomVtxPosZ[k] = temp1; + roomVtxTexU[k] = D_801C5E88[j]; + roomVtxTexV[k] = D_801C5E9C[i]; + temp2 += arg6; + } + temp1 += arg7; + } + break; + + default: + break; + } + + skyboxCtx->roomDL = &skyboxCtx->dListBuf[2 * arg8][0]; + + for (i = 0; i < 0x20; i++) { + index = D_801C5E48[i]; + + roomVtx[arg2 + i].v.ob[0] = roomVtxPosX[index]; + roomVtx[arg2 + i].v.ob[1] = roomVtxPosY[index]; + roomVtx[arg2 + i].v.ob[2] = roomVtxPosZ[index]; + roomVtx[arg2 + i].v.flag = 0; + roomVtx[arg2 + i].v.tc[0] = roomVtxTexU[index]; + roomVtx[arg2 + i].v.tc[1] = roomVtxTexV[index]; + roomVtx[arg2 + i].v.cn[1] = 0; + roomVtx[arg2 + i].v.cn[2] = 0; + roomVtx[arg2 + i].v.cn[0] = 255; + } + gSPVertex(skyboxCtx->roomDL++, &roomVtx[arg2], 32, 0); + arg2 += i; + gSPCullDisplayList(skyboxCtx->roomDL++, 0, 15); + + if ((arg8 == 4) || (arg8 == 5)) { + phi_a2_4 = 0; + for (phi_t2_4 = 0, phi_ra = 0; phi_ra < 4; phi_ra++, phi_a2_4 += 0x1F) { + for (phi_a0_4 = 0, phi_t1 = 0; phi_t1 < 4; phi_t1++, phi_a0_4 += 0x1F, phi_t2_4 += 4) { + gDPLoadMultiTile(skyboxCtx->roomDL++, (uintptr_t)skyboxCtx->staticSegments[0] + D_801C5E30[arg8], 0, + G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, + phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gDPLoadMultiTile(skyboxCtx->roomDL++, (uintptr_t)skyboxCtx->staticSegments[1] + D_801C5E30[arg8], 0x80, + 1, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, + phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gSP1Quadrangle(skyboxCtx->roomDL++, D_801C5EC4[phi_t2_4 + 1], D_801C5EC4[phi_t2_4 + 2], + D_801C5EC4[phi_t2_4 + 3], D_801C5EC4[phi_t2_4 + 0], 3); + } + } + } else { + phi_a2_4 = 0; + for (phi_t2_4 = 0, phi_ra = 0; phi_ra < 2; phi_ra++, phi_a2_4 += 0x1F) { + for (phi_a0_4 = 0, phi_t1 = 0; phi_t1 < 4; phi_t1++, phi_a0_4 += 0x1F, phi_t2_4 += 4) { + gDPLoadMultiTile(skyboxCtx->roomDL++, (uintptr_t)skyboxCtx->staticSegments[0] + D_801C5E30[arg8], 0, + G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, + phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gDPLoadMultiTile(skyboxCtx->roomDL++, (uintptr_t)skyboxCtx->staticSegments[1] + D_801C5E30[arg8], 0x80, + 1, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, + phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gSP1Quadrangle(skyboxCtx->roomDL++, D_801C5EC4[phi_t2_4 + 1], D_801C5EC4[phi_t2_4 + 2], + D_801C5EC4[phi_t2_4 + 3], D_801C5EC4[phi_t2_4 + 0], 3); + } + } + phi_a2_4 -= 0x1F; + for (phi_ra = 0; phi_ra < 2; phi_ra++, phi_a2_4 -= 0x1F) { + for (phi_a0_4 = 0, phi_t1 = 0; phi_t1 < 4; phi_t1++, phi_a0_4 += 0x1F, phi_t2_4 += 4) { + gDPLoadMultiTile(skyboxCtx->roomDL++, (uintptr_t)skyboxCtx->staticSegments[0] + D_801C5E30[arg8], 0, + G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, + phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gDPLoadMultiTile(skyboxCtx->roomDL++, (uintptr_t)skyboxCtx->staticSegments[1] + D_801C5E30[arg8], 0x80, + 1, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, + phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); + gSP1Quadrangle(skyboxCtx->roomDL++, D_801C5EC4[phi_t2_4 + 1], D_801C5EC4[phi_t2_4 + 2], + D_801C5EC4[phi_t2_4 + 3], D_801C5EC4[phi_t2_4 + 0], 3); + } + } + } + gSPEndDisplayList(skyboxCtx->roomDL++); + return arg2; +} void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) { static struct_801C5F44 D_801C5F44[] = { @@ -35,114 +183,120 @@ void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) { } } -void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) { - GlobalContext* globalCtx = (GlobalContext*)gameState; +void Skybox_Setup(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) { + PlayState* play = (PlayState*)gameState; size_t size; - void* offset; - s32 pad; + void* segment; skyboxCtx->rotZ = 0.0f; - if (skyType != 1) { - if (skyType != 2) { - return; - } - } else { - // Send a DMA request for the cloudy sky texture - skyboxCtx->skyboxStaticSegment[0] = &D_80025D00; - size = SEGMENT_ROM_SIZE(d2_cloud_static); - offset = (void*)ALIGN8((u32)skyboxCtx->skyboxStaticSegment[0] + size); - DmaMgr_SendRequest0(skyboxCtx->skyboxStaticSegment[0], SEGMENT_ROM_START(d2_cloud_static), size); + switch (skyboxId) { + case 1: + // Send a DMA request for the cloudy sky texture + skyboxCtx->staticSegments[0] = &D_80025D00; + size = SEGMENT_ROM_SIZE(d2_cloud_static); + segment = (void*)ALIGN8((uintptr_t)skyboxCtx->staticSegments[0] + size); + DmaMgr_SendRequest0(skyboxCtx->staticSegments[0], SEGMENT_ROM_START(d2_cloud_static), size); - // Send a DMA request for the clear sky texture - skyboxCtx->skyboxStaticSegment[1] = offset; - size = SEGMENT_ROM_SIZE(d2_fine_static); - offset = (void*)ALIGN8((u32)offset + size); - DmaMgr_SendRequest0(skyboxCtx->skyboxStaticSegment[1], SEGMENT_ROM_START(d2_fine_static), size); + // Send a DMA request for the clear sky texture + skyboxCtx->staticSegments[1] = segment; + size = SEGMENT_ROM_SIZE(d2_fine_static); + segment = (void*)ALIGN8((uintptr_t)segment + size); + DmaMgr_SendRequest0(skyboxCtx->staticSegments[1], SEGMENT_ROM_START(d2_fine_static), size); - // Send a DMA request for the skybox palette - skyboxCtx->skyboxPaletteStaticSegment = offset; - size = SEGMENT_ROM_SIZE(d2_fine_pal_static); - offset = (void*)ALIGN8((u32)offset + size); - DmaMgr_SendRequest0(skyboxCtx->skyboxPaletteStaticSegment, SEGMENT_ROM_START(d2_fine_pal_static), size); + // Send a DMA request for the skybox palette + skyboxCtx->paletteStaticSegment = segment; + size = SEGMENT_ROM_SIZE(d2_fine_pal_static); + segment = (void*)ALIGN8((uintptr_t)segment + size); + DmaMgr_SendRequest0(skyboxCtx->paletteStaticSegment, SEGMENT_ROM_START(d2_fine_pal_static), size); - skyboxCtx->primR = 145; - skyboxCtx->primG = 120; - skyboxCtx->primB = 155; + skyboxCtx->primR = 145; + skyboxCtx->primG = 120; + skyboxCtx->primB = 155; - skyboxCtx->envR = 40; - skyboxCtx->envG = 0; - skyboxCtx->envB = 40; + skyboxCtx->envR = 40; + skyboxCtx->envG = 0; + skyboxCtx->envB = 40; - // Inverted Stone Tower Temple and Inverted Stone Tower - if ((globalCtx->sceneNum == SCENE_F41) || (globalCtx->sceneNum == SCENE_INISIE_R)) { - skyboxCtx->rotZ = 3.15000009537f; - } + // Inverted Stone Tower Temple and Inverted Stone Tower + if ((play->sceneId == SCENE_F41) || (play->sceneId == SCENE_INISIE_R)) { + skyboxCtx->rotZ = 3.15000009537f; + } + break; + + case 2: + break; + + default: + break; } } -void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType) { +void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { size_t size; - if (1) {} + switch (skyboxId) { + case 1: + osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); - if (skyType == 1) { - osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); + if (play->envCtx.unk_10 == 0) { + // Send a DMA request for the clear sky texture + size = SEGMENT_ROM_SIZE(d2_fine_static); - if (globalCtx->envCtx.unk_10 == 0) { - // Send a DMA request for the clear sky texture - size = SEGMENT_ROM_SIZE(d2_fine_static); + DmaMgr_SendRequestImpl(&skyboxCtx->unk188, skyboxCtx->staticSegments[0], + SEGMENT_ROM_START(d2_fine_static), size, 0, &skyboxCtx->loadQueue, NULL); + } else { + // Send a DMA request for the cloudy sky texture + size = SEGMENT_ROM_SIZE(d2_cloud_static); - DmaMgr_SendRequestImpl(&skyboxCtx->unk188, skyboxCtx->skyboxStaticSegment[0], - SEGMENT_ROM_START(d2_fine_static), size, 0, &skyboxCtx->loadQueue, NULL); - } else { - // Send a DMA request for the cloudy sky texture - size = SEGMENT_ROM_SIZE(d2_cloud_static); + DmaMgr_SendRequestImpl(&skyboxCtx->unk188, skyboxCtx->staticSegments[0], + SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL); + } - DmaMgr_SendRequestImpl(&skyboxCtx->unk188, skyboxCtx->skyboxStaticSegment[0], - SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL); - } + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); + osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); - osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); - osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); + if (play->envCtx.unk_11 == 0) { + // Send a DMA request for the clear sky texture + size = SEGMENT_ROM_SIZE(d2_fine_static); - if (globalCtx->envCtx.unk_11 == 0) { - // Send a DMA request for the clear sky texture - size = SEGMENT_ROM_SIZE(d2_fine_static); + DmaMgr_SendRequestImpl(&skyboxCtx->unk1A8, skyboxCtx->staticSegments[1], + SEGMENT_ROM_START(d2_fine_static), size, 0, &skyboxCtx->loadQueue, NULL); + } else { + // Send a DMA request for the cloudy sky texture + size = SEGMENT_ROM_SIZE(d2_cloud_static); - DmaMgr_SendRequestImpl(&skyboxCtx->unk1A8, skyboxCtx->skyboxStaticSegment[1], - SEGMENT_ROM_START(d2_fine_static), size, 0, &skyboxCtx->loadQueue, NULL); - } else { - // Send a DMA request for the cloudy sky texture - size = SEGMENT_ROM_SIZE(d2_cloud_static); + DmaMgr_SendRequestImpl(&skyboxCtx->unk1A8, skyboxCtx->staticSegments[1], + SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL); + } - DmaMgr_SendRequestImpl(&skyboxCtx->unk1A8, skyboxCtx->skyboxStaticSegment[1], - SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL); - } + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); + osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); - osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); - osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); + size = SEGMENT_ROM_SIZE(d2_fine_pal_static); - size = SEGMENT_ROM_SIZE(d2_fine_pal_static); + // Send a DMA request for the skybox palette + DmaMgr_SendRequestImpl(&skyboxCtx->unk1C8, skyboxCtx->paletteStaticSegment, + SEGMENT_ROM_START(d2_fine_pal_static), size, 0, &skyboxCtx->loadQueue, NULL); - // Send a DMA request for the skybox palette - DmaMgr_SendRequestImpl(&skyboxCtx->unk1C8, skyboxCtx->skyboxPaletteStaticSegment, - SEGMENT_ROM_START(d2_fine_pal_static), size, 0, &skyboxCtx->loadQueue, NULL); + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); + break; - osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); + default: + break; } } -void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) { +void Skybox_Init(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->skyboxShouldDraw = 0; skyboxCtx->rotX = skyboxCtx->rotY = skyboxCtx->rotZ = 0.0f; - func_801431E8(gameState, skyboxCtx, skyType); + Skybox_Setup(gameState, skyboxCtx, skyboxId); - if (skyType != 0) { + if (skyboxId != 0) { skyboxCtx->dListBuf = THA_AllocEndAlign16(&gameState->heap, 0x3840); - if (skyType == 5) { + if (skyboxId == 5) { // Allocate enough space for the vertices for a 6 sided skybox (cube) skyboxCtx->roomVtx = THA_AllocEndAlign16(&gameState->heap, sizeof(Vtx) * 32 * 6); func_80143148(skyboxCtx, 6); diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index 326fcb3e2..88da288f0 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -25,7 +25,7 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb func_8012C6AC(gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x0B, skyboxCtx->skyboxPaletteStaticSegment); + gSPSegment(POLY_OPA_DISP++, 0x0B, skyboxCtx->paletteStaticSegment); gSPTexture(POLY_OPA_DISP++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON); sSkyboxDrawMatrix = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); @@ -40,7 +40,7 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb gSPMatrix(POLY_OPA_DISP++, sSkyboxDrawMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetColorDither(POLY_OPA_DISP++, G_CD_MAGICSQ); gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); - gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->skyboxPaletteStaticSegment); + gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->paletteStaticSegment); gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16); gDPSetTextureConvert(POLY_OPA_DISP++, G_TC_FILT); gDPSetCombineLERP(POLY_OPA_DISP++, TEXEL1, TEXEL0, PRIMITIVE_ALPHA, TEXEL0, TEXEL1, TEXEL0, PRIMITIVE, TEXEL0, @@ -49,13 +49,13 @@ void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyb gDPSetEnvColor(POLY_OPA_DISP++, skyboxCtx->envR, skyboxCtx->envG, skyboxCtx->envB, 0); gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[0]); - gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[300]); - gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[600]); - gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[900]); - gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[1200]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[2]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[4]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[6]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[8]); if (skyboxId == SKYBOX_CUTSCENE_MAP) { - gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[1500]); + gSPDisplayList(POLY_OPA_DISP++, &skyboxCtx->dListBuf[10]); } gDPPipeSync(POLY_OPA_DISP++); diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c index edba06fc2..cd4420c4a 100644 --- a/src/libultra/flash/osFlash.c +++ b/src/libultra/flash/osFlash.c @@ -32,9 +32,9 @@ OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 return &__osFlashHandler; } -void osFlashChange(u32 flash_num) { - __osFlashHandler.baseAddress = RDRAM_UNCACHED | (FRAM_STATUS_REGISTER + (flash_num << 17)); - __osFlashHandler.type = 8 + flash_num; +void osFlashChange(u32 flashNum) { + __osFlashHandler.baseAddress = RDRAM_UNCACHED | (FRAM_STATUS_REGISTER + (flashNum << 17)); + __osFlashHandler.type = 8 + flashNum; return; } 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/rotate.c b/src/libultra/gu/rotate.c index 11d00ff73..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; 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..aadd8ad5b 100644 --- a/src/libultra/io/epirawdma.c +++ b/src/libultra/io/epirawdma.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size) { +s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, void* dramAddr, size_t size) { s32 status; OSPiHandle* curHandle; @@ -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/sirawread.c b/src/libultra/io/sirawread.c index 19327db49..7e3537603 100644 --- a/src/libultra/io/sirawread.c +++ b/src/libultra/io/sirawread.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osSiRawReadIo(u32 devAddr, u32* data) { +s32 __osSiRawReadIo(uintptr_t devAddr, u32* data) { if (__osSiDeviceBusy()) { return -1; } diff --git a/src/libultra/io/sirawwrite.c b/src/libultra/io/sirawwrite.c index 040fdee0d..0f98b08c5 100644 --- a/src/libultra/io/sirawwrite.c +++ b/src/libultra/io/sirawwrite.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osSiRawWriteIo(u32 devAddr, u32 data) { +s32 __osSiRawWriteIo(uintptr_t devAddr, u32 data) { if (__osSiDeviceBusy() != 0) { return -1; } 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/overlay.cfg b/src/overlays/actors/ovl_Arms_Hook/overlay.cfg deleted file mode 100644 index 4a8f59822..000000000 --- a/src/overlays/actors/ovl_Arms_Hook/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Arms_Hook -z_arms_hook.c 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 16aa93bd9..e3ac3e753 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -12,15 +12,15 @@ #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 = { +ActorInit Arms_Hook_InitVars = { ACTOR_ARMS_HOOK, ACTORCAT_ITEMACTION, FLAGS, @@ -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; + this->grabbed->flags &= ~ACTOR_FLAG_2000; } - 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; } } @@ -100,16 +100,17 @@ s32 ArmsHook_AttachToPlayer(ArmsHook* this, Player* player) { void ArmsHook_DetachHookFromActor(ArmsHook* this) { if (this->grabbed != NULL) { - this->grabbed->flags &= ~0x2000; + this->grabbed->flags &= ~ACTOR_FLAG_2000; this->grabbed = NULL; } } s32 ArmsHook_CheckForCancel(ArmsHook* this) { Player* player = (Player*)this->actor.parent; - if (func_801240C8(player)) { - if ((player->heldItemActionParam != player->itemActionParam) || ((player->actor.flags & ACTOR_FLAG_100)) || - ((player->stateFlags1 & 0x4000080))) { + + if (Player_IsHoldingHookshot(player)) { + if ((player->itemAction != player->heldItemAction) || (player->actor.flags & ACTOR_FLAG_100) || + (player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_4000000))) { this->timer = 0; ArmsHook_DetachHookFromActor(this); Math_Vec3f_Copy(&this->actor.world.pos, &player->rightHandWorld.pos); @@ -120,17 +121,17 @@ s32 ArmsHook_CheckForCancel(ArmsHook* this) { } void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) { - actor->flags |= 0x2000; + actor->flags |= ACTOR_FLAG_2000; this->grabbed = 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); + Actor_Kill(&this->actor); return; } @@ -140,10 +141,10 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { if (this->timer != 0 && (this->collider.base.atFlags & AT_HIT) && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { Actor* touchedActor = this->collider.base.at; - if ((touchedActor->update != NULL) && (touchedActor->flags & 0x600)) { + if ((touchedActor->update != NULL) && (touchedActor->flags & (ACTOR_FLAG_200 | ACTOR_FLAG_400))) { if (this->collider.info.atHitInfo->bumperFlags & BUMP_HOOKABLE) { ArmsHook_AttachHookToActor(this, touchedActor); - if ((touchedActor->flags & 0x400) == 0x400) { + if (CHECK_FLAG_ALL(touchedActor->flags, ACTOR_FLAG_400)) { func_808C1154(this); } } @@ -155,28 +156,25 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } if (DECR(this->timer) == 0) { - Actor* grabbed; + Actor* grabbed = this->grabbed; Vec3f bodyDistDiffVec; Vec3f newPos; f32 bodyDistDiff; f32 phi_f16; s32 pad; - grabbed = this->grabbed; if (grabbed != NULL) { - if ((grabbed->update == NULL) || (grabbed->flags & 0x2000) != 0x2000) { + if ((grabbed->update == NULL) || !CHECK_FLAG_ALL(grabbed->flags, ACTOR_FLAG_2000)) { grabbed = NULL; this->grabbed = NULL; - } else { - if (this->actor.child != NULL) { - f32 sp94 = Actor_DistanceBetweenActors(&this->actor, grabbed); - f32 sp90 = sqrtf(SQXYZ(this->unk1FC)); + } else if (this->actor.child != NULL) { + f32 sp94 = Actor_DistanceBetweenActors(&this->actor, grabbed); + f32 sp90 = sqrtf(SQXYZ(this->unk1FC)); - Math_Vec3f_Diff(&grabbed->world.pos, &this->unk1FC, &this->actor.world.pos); - if (50.0f < (sp94 - sp90)) { - ArmsHook_DetachHookFromActor(this); - grabbed = NULL; - } + Math_Vec3f_Diff(&grabbed->world.pos, &this->unk1FC, &this->actor.world.pos); + if (50.0f < (sp94 - sp90)) { + ArmsHook_DetachHookFromActor(this); + grabbed = NULL; } } } @@ -218,7 +216,7 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { } } else { Math_Vec3f_Diff(&bodyDistDiffVec, &newPos, &player->actor.velocity); - player->actor.world.rot.x = Math_FAtan2F(sqrtf(SQXZ(bodyDistDiffVec)), -bodyDistDiffVec.y); + player->actor.world.rot.x = Math_Atan2S_XY(sqrtf(SQXZ(bodyDistDiffVec)), -bodyDistDiffVec.y); } if (phi_f16 < 50.0f) { ArmsHook_DetachHookFromActor(this); @@ -240,15 +238,15 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &prevFrameDiff); Math_Vec3f_Sum(&this->unk1E0, &prevFrameDiff, &this->unk1E0); - this->actor.shape.rot.x = Math_FAtan2F(this->actor.speedXZ, -this->actor.velocity.y); + this->actor.shape.rot.x = Math_Atan2S_XY(this->actor.speedXZ, -this->actor.velocity.y); 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,73 +254,70 @@ 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)) { - { - DynaPolyActor* dynaPolyActor; - if (bgId != BGCHECK_SCENE && - (dynaPolyActor = DynaPoly_GetActor(&globalCtx->colCtx, bgId)) != NULL) { - ArmsHook_AttachHookToActor(this, &dynaPolyActor->actor); - } + if (SurfaceType_IsHookshotSurface(&play->colCtx, poly, bgId)) { + DynaPolyActor* dynaPolyActor; + + 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, - BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) { - s32 pad; - this->timer = 1; - } + } else 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; } } } -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; } -static Vec3f D_808C1C10 = { 0.0f, 0.0f, 0.0f }; -static Vec3f D_808C1C1C = { 0.0f, 0.0f, 900.0f }; -static Vec3f D_808C1C28 = { 0.0f, 500.0f, -3000.0f }; -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 }; +Vec3f D_808C1C10 = { 0.0f, 0.0f, 0.0f }; +Vec3f D_808C1C1C = { 0.0f, 0.0f, 900.0f }; +Vec3f D_808C1C28 = { 0.0f, 500.0f, -3000.0f }; +Vec3f D_808C1C34 = { 0.0f, -500.0f, -3000.0f }; +Vec3f D_808C1C40 = { 0.0f, 500.0f, 0.0f }; +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) { + if ((player->actor.draw != NULL) && (player->rightHandType == PLAYER_MODELTYPE_RH_HOOKSHOT)) { Vec3f sp68; Vec3f sp5C; Vec3f sp50; f32 sp4C; f32 sp48; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { Matrix_MultVec3f(&D_808C1C10, &this->unk1E0); Matrix_MultVec3f(&D_808C1C28, &sp5C); Matrix_MultVec3f(&D_808C1C34, &sp50); - this->unk1C4.active = false; + this->weaponInfo.active = false; } else { Matrix_MultVec3f(&D_808C1C1C, &this->unk1E0); Matrix_MultVec3f(&D_808C1C40, &sp5C); Matrix_MultVec3f(&D_808C1C4C, &sp50); } - func_80126440(globalCtx, &this->collider, &this->unk1C4, &sp5C, &sp50); - func_8012C28C(globalCtx->state.gfxCtx); - func_80122868(globalCtx, player); + func_80126440(play, &this->collider, &this->weaponInfo, &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_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); @@ -332,10 +327,10 @@ void ArmsHook_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 527d37b61..31b675f41 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -5,21 +5,19 @@ struct ArmsHook; -typedef void (*ArmsHookActionFunc)(struct ArmsHook*, GlobalContext*); +typedef void (*ArmsHookActionFunc)(struct ArmsHook*, PlayState*); typedef struct ArmsHook { /* 0x000 */ Actor actor; /* 0x144 */ ColliderQuad collider; - /* 0x1C4 */ WeaponInfo unk1C4; + /* 0x1C4 */ WeaponInfo weaponInfo; /* 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 -extern const ActorInit Arms_Hook_InitVars; - #endif // Z_ARMS_HOOK_H diff --git a/src/overlays/actors/ovl_Arrow_Fire/overlay.cfg b/src/overlays/actors/ovl_Arrow_Fire/overlay.cfg deleted file mode 100644 index a2d1a6ad6..000000000 --- a/src/overlays/actors/ovl_Arrow_Fire/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Arrow_Fire -z_arrow_fire.c 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 6a2590259..41a3f25ec 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -11,17 +11,17 @@ #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" -const ActorInit Arrow_Fire_InitVars = { +ActorInit Arrow_Fire_InitVars = { ACTOR_ARROW_FIRE, ACTORCAT_ITEMACTION, FLAGS, @@ -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,23 +74,23 @@ 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); + Magic_Reset(play); + 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)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } if (this->radius < 10) { @@ -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; @@ -156,22 +156,22 @@ void FireArrow_Hit(ArrowFire* this, GlobalContext* globalCtx) { } if (this->timer == 0) { this->timer = 255; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); 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; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -194,21 +194,21 @@ void FireArrow_Fly(ArrowFire* this, GlobalContext* globalCtx) { } if (arrow->unk_260 < 34) { if (this->alpha < 35) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } this->alpha -= 25; } } -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)) { - Actor_MarkForDeath(&this->actor); + if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) { + Actor_Kill(&this->actor); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } void FireArrow_SetQuadVerticies(ArrowFire* this) { @@ -237,10 +237,10 @@ void FireArrow_SetQuadVerticies(ArrowFire* this) { 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,7 +248,7 @@ 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); + 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); @@ -266,7 +266,7 @@ 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); @@ -282,15 +282,14 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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..1d0c09dcb 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; @@ -21,6 +21,4 @@ typedef struct ArrowFire { } ArrowFire; // size = 0x264 -extern const ActorInit Arrow_Fire_InitVars; - #endif // Z_ARROW_FIRE_H diff --git a/src/overlays/actors/ovl_Arrow_Ice/overlay.cfg b/src/overlays/actors/ovl_Arrow_Ice/overlay.cfg deleted file mode 100644 index b95f23d3c..000000000 --- a/src/overlays/actors/ovl_Arrow_Ice/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Arrow_Ice -z_arrow_ice.c 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 6ae539178..5c5cd0c87 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -11,19 +11,19 @@ #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" s32 unused; // Needed for bss -const ActorInit Arrow_Ice_InitVars = { +ActorInit Arrow_Ice_InitVars = { ACTOR_ARROW_ICE, ACTORCAT_ITEMACTION, FLAGS, @@ -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,16 +56,16 @@ 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) { + Magic_Reset(play); (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)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -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; @@ -136,17 +136,17 @@ void ArrowIce_Hit(ArrowIce* this, GlobalContext* globalCtx) { if (this->timer == 0) { this->timer = 255; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) { +void ArrowIce_Fly(ArrowIce* this, PlayState* play) { EnArrow* arrow = (EnArrow*)this->actor.parent; f32 distanceScaled; s32 pad; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } // copy position and rotation from arrow @@ -166,35 +166,35 @@ void ArrowIce_Fly(ArrowIce* this, GlobalContext* globalCtx) { this->alpha = 255; } else if (arrow->unk_260 < 34) { if (this->alpha < 35) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->alpha -= 25; } } } -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)) { - Actor_MarkForDeath(&this->actor); + if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) { + Actor_Kill(&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_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); @@ -214,7 +214,7 @@ 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_RotateZYX(0x4000, 0, 0, MTXMODE_APPLY); @@ -225,13 +225,13 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_Scale(this->radius * 0.2f, this->height * 3.0f, this->radius * 0.2f, MTXMODE_APPLY); Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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..bf7a1ae51 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.h @@ -5,19 +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; - #endif // Z_ARROW_ICE_H diff --git a/src/overlays/actors/ovl_Arrow_Light/overlay.cfg b/src/overlays/actors/ovl_Arrow_Light/overlay.cfg deleted file mode 100644 index d5bda9b4c..000000000 --- a/src/overlays/actors/ovl_Arrow_Light/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Arrow_Light -z_arrow_light.c 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 1b25b8fbb..b7918b5b4 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -11,17 +11,17 @@ #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" -const ActorInit Arrow_Light_InitVars = { +ActorInit Arrow_Light_InitVars = { ACTOR_ARROW_LIGHT, ACTORCAT_ITEMACTION, FLAGS, @@ -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,16 +55,16 @@ 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) { + Magic_Reset(play); (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)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -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; @@ -129,17 +129,17 @@ void ArrowLight_Hit(ArrowLight* this, GlobalContext* globalCtx) { } if (this->timer == 0) { this->timer = 255; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } -void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { +void ArrowLight_Fly(ArrowLight* this, PlayState* play) { EnArrow* arrow = (EnArrow*)this->actor.parent; s32 pad[2]; if ((arrow == NULL) || (arrow->actor.update == NULL)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -162,33 +162,33 @@ void ArrowLight_Fly(ArrowLight* this, GlobalContext* globalCtx) { } if (arrow->unk_260 < 34) { if (this->alpha < 35) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } this->alpha -= 25; } } -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)) { - Actor_MarkForDeath(&this->actor); + if ((play->msgCtx.msgMode == 0xE) || (play->msgCtx.msgMode == 0x12)) { + Actor_Kill(&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_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); Matrix_RotateYS(transform->shape.rot.y, MTXMODE_APPLY); @@ -205,7 +205,7 @@ 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); @@ -219,12 +219,12 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(this->radius * 0.2f, this->height * 4.0f, this->radius * 0.2f, MTXMODE_APPLY); Matrix_Translate(0.0f, -700.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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..0f42435ca 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; @@ -19,6 +19,4 @@ typedef struct ArrowLight { } ArrowLight; // size = 0x164 -extern const ActorInit Arrow_Light_InitVars; - #endif // Z_ARROW_LIGHT_H diff --git a/src/overlays/actors/ovl_Bg_Astr_Bombwall/overlay.cfg b/src/overlays/actors/ovl_Bg_Astr_Bombwall/overlay.cfg deleted file mode 100644 index 735382ead..000000000 --- a/src/overlays/actors/ovl_Bg_Astr_Bombwall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Astr_Bombwall -z_bg_astr_bombwall.c 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..dcf37d848 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,18 +5,25 @@ */ #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); -#if 0 -const ActorInit Bg_Astr_Bombwall_InitVars = { +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); + +ActorInit Bg_Astr_Bombwall_InitVars = { ACTOR_BG_ASTR_BOMBWALL, ACTORCAT_BG, FLAGS, @@ -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_Kill(&this->dyna.actor); + return; + } + this->dyna.actor.flags |= ACTOR_FLAG_10000000; + if (!Collider_SetTris(play, &this->collider, &this->dyna.actor, &sTrisInit, this->colliderElements)) { + Actor_Kill(&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..4f42a8b3c 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,14 @@ 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 - -extern const ActorInit Bg_Astr_Bombwall_InitVars; - + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgAstrBombwallActionFunc actionFunc; + /* 0x160 */ ColliderTris collider; + /* 0x180 */ ColliderTrisElement colliderElements[2]; + /* 0x238 */ s16 cutscenes[1]; +} BgAstrBombwall; #endif // Z_BG_ASTR_BOMBWALL_H diff --git a/src/overlays/actors/ovl_Bg_Botihasira/overlay.cfg b/src/overlays/actors/ovl_Bg_Botihasira/overlay.cfg deleted file mode 100644 index 48da75cb3..000000000 --- a/src/overlays/actors/ovl_Bg_Botihasira/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Botihasira -z_bg_botihasira.c 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..a5168eb24 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c @@ -5,18 +5,20 @@ */ #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); -#if 0 -const ActorInit Bg_Botihasira_InitVars = { +void BgBotihasira_DoNothing(BgBotihasira* this, PlayState* play); + +ActorInit Bg_Botihasira_InitVars = { ACTOR_BG_BOTIHASIRA, ACTORCAT_ITEMACTION, FLAGS, @@ -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..6cb290f65 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h @@ -5,15 +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; - #endif // Z_BG_BOTIHASIRA_H diff --git a/src/overlays/actors/ovl_Bg_Breakwall/overlay.cfg b/src/overlays/actors/ovl_Bg_Breakwall/overlay.cfg deleted file mode 100644 index 77c1ecf0d..000000000 --- a/src/overlays/actors/ovl_Bg_Breakwall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Breakwall -z_bg_breakwall.c 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..4c73987ec 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.c @@ -19,33 +19,33 @@ #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 = { +ActorInit Bg_Breakwall_InitVars = { ACTOR_BG_BREAKWALL, ACTORCAT_ITEMACTION, FLAGS, GAMEPLAY_KEEP, sizeof(BgBreakwall), (ActorFunc)BgBreakwall_Init, (ActorFunc)NULL, (ActorFunc)BgBreakwall_Update, (ActorFunc)NULL, @@ -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) { - if ((gSaveContext.save.day >= 2) && !(gSaveContext.save.weekEventReg[22] & 1)) { +s32 func_808B7380(BgBreakwall* this, PlayState* play) { + if ((gSaveContext.save.day >= 2) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { return false; } return true; } -s32 func_808B73C4(BgBreakwall* this, GlobalContext* globalCtx) { - return (gSaveContext.save.weekEventReg[33] & 0x80) || (gSaveContext.save.weekEventReg[21] & 1); +s32 func_808B73C4(BgBreakwall* this, PlayState* play) { + return CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_21_01); } -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) { - if (gSaveContext.save.weekEventReg[55] & 0x80) { +s32 func_808B74A8(BgBreakwall* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { return false; } return true; } -s32 func_808B74D8(BgBreakwall* this, GlobalContext* globalCtx) { - if (!(gSaveContext.save.weekEventReg[9] & 0x80) || (gSaveContext.save.weekEventReg[23] & 0x20)) { +s32 func_808B74D8(BgBreakwall* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_09_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { 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,16 +207,16 @@ 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)) { - Actor_MarkForDeath(&this->dyna.actor); + if ((this->unk_15C < 0) || !sp24->unk_14(this, play)) { + Actor_Kill(&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) { - if (gSaveContext.save.weekEventReg[55] & 0x80) { - Actor_MarkForDeath(&this->dyna.actor); +void func_808B78A4(BgBreakwall* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&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..bcdda2327 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,13 +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; - #endif // Z_BG_BREAKWALL_H diff --git a/src/overlays/actors/ovl_Bg_Crace_Movebg/overlay.cfg b/src/overlays/actors/ovl_Bg_Crace_Movebg/overlay.cfg deleted file mode 100644 index ab8eb4405..000000000 --- a/src/overlays/actors/ovl_Bg_Crace_Movebg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Crace_Movebg -z_bg_crace_movebg.c 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..19cafc2bd 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 @@ -5,18 +5,43 @@ */ #include "z_bg_crace_movebg.h" +#include "overlays/actors/ovl_En_Dno/z_en_dno.h" #define FLAGS (ACTOR_FLAG_10) #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); -#if 0 -const ActorInit Bg_Crace_Movebg_InitVars = { +s32 BgCraceMovebg_GetRaceStatus(PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupIdle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_Idle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupOpen(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_Open(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_OpeningDoor_DoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupIdle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_Idle(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupWaitToClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_WaitToClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupClose(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_Close(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play); +void BgCraceMovebg_ClosingDoor_DoNothing(BgCraceMovebg* this, PlayState* play); + +typedef enum { + /* 0 */ BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT, + /* 1 */ BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE, + /* 2 */ BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE +} BgCraceMovebgRaceStatus; + +u8 sIsLoaded[32]; + +ActorInit Bg_Crace_Movebg_InitVars = { ACTOR_BG_CRACE_MOVEBG, ACTORCAT_BG, FLAGS, @@ -28,47 +53,303 @@ const ActorInit Bg_Crace_Movebg_InitVars = { (ActorFunc)BgCraceMovebg_Draw, }; -#endif +static u8 sHasInitializedIsLoaded = 0; +static u8 sLoadedDoorCount = 0; -extern UNK_TYPE D_060003A0; -extern UNK_TYPE D_06000E00; +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/BgCraceMovebg_Init.s") +static Vec3f sUnitVecZ = { 0.0f, 0.0f, 1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A7090C.s") +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/func_80A70970.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + if (!sHasInitializedIsLoaded) { + for (i = 0; i < ARRAY_COUNT(sIsLoaded); i++) { + sIsLoaded[i] = 0; + } + sHasInitializedIsLoaded = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A7099C.s") + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &gDekuShrineSlidingDoorCol); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A709E4.s") + this->index = BG_CRACE_MOVEBG_GET_INDEX(&this->dyna.actor); + this->openSpeed = BG_CRACE_MOVEBG_GET_OPEN_SPEED(&this->dyna.actor); + 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_80A70A08.s") + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + for (j = 0; j < sLoadedDoorCount; j++) { + if (sIsLoaded[j] == this->index) { + this->stateFlags |= BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED; + Actor_Kill(&this->dyna.actor); + return; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70A84.s") + if (sLoadedDoorCount < ARRAY_COUNT(sIsLoaded)) { + sIsLoaded[(s32)sLoadedDoorCount] = this->index; + sLoadedDoorCount++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70A9C.s") + this->dyna.actor.room = -1; + switch (BgCraceMovebg_GetRaceStatus(play)) { + case BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT: + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/BgCraceMovebg_Destroy.s") + case BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE: + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/BgCraceMovebg_Update.s") + case BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE: + // Makes sure no lingering switch flags are set from the last time the player did a race. + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + BgCraceMovebg_ClosingDoor_SetupIdle(this, play); + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70C04.s") + case BG_CRACE_MOVEBG_TYPE_OPENING: + BgCraceMovebg_OpeningDoor_SetupIdle(this, play); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70D74.s") + default: + Actor_Kill(&this->dyna.actor); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70DA8.s") +s32 BgCraceMovebg_GetRaceStatus(PlayState* play) { + s32 pad; + s32 raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_BUTLER_NOT_PRESENT; + Actor* butler = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNO); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70E2C.s") + if (butler != NULL) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(butler))) { + raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_SUBSEQUENT_RACE; + } else { + raceStatus = BG_CRACE_MOVEBG_RACE_STATUS_FIRST_RACE; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70E70.s") + return raceStatus; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70F14.s") +void BgCraceMovebg_OpeningDoor_SetupIdle(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 0.0f; + this->doorHeight = 0.0f; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + this->actionFunc = BgCraceMovebg_OpeningDoor_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70F2C.s") +/** + * Wait for this door's switch flag to be set, then start opening. + */ +void BgCraceMovebg_OpeningDoor_Idle(BgCraceMovebg* this, PlayState* play) { + if (Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor))) { + BgCraceMovebg_OpeningDoor_SetupOpen(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A70FF4.s") +void BgCraceMovebg_OpeningDoor_SetupOpen(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 180.0f; + this->actionFunc = BgCraceMovebg_OpeningDoor_Open; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/func_80A71040.s") +/** + * Silde open, then do nothing. + */ +void BgCraceMovebg_OpeningDoor_Open(BgCraceMovebg* this, PlayState* play) { + func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_OPEN_S - SFX_FLAG); + Math_SmoothStepToF(&this->doorHeight, this->targetDoorHeight, 2.0f, this->openSpeed, 0.01f); + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + if (this->doorHeight == this->targetDoorHeight) { + BgCraceMovebg_OpeningDoor_SetupDoNothing(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Crace_Movebg/BgCraceMovebg_Draw.s") +void BgCraceMovebg_OpeningDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = BgCraceMovebg_OpeningDoor_DoNothing; +} + +void BgCraceMovebg_OpeningDoor_DoNothing(BgCraceMovebg* this, PlayState* play) { +} + +void BgCraceMovebg_Destroy(Actor* thisx, PlayState* play) { + BgCraceMovebg* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + if (!(this->stateFlags & BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED)) { + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx)); + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx) + 1); + break; + + case BG_CRACE_MOVEBG_TYPE_OPENING: + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx)); + break; + } + } +} + +void BgCraceMovebg_Update(Actor* thisx, PlayState* play) { + BgCraceMovebg* this = THIS; + s32 pad; + Player* player = GET_PLAYER(play); + s16 yawDiff; + + switch (BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor)) { + case BG_CRACE_MOVEBG_TYPE_CLOSING: + case BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING: + yawDiff = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.home.rot.y; + if ((yawDiff >= -0x4000) && (yawDiff <= 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; + } + break; + + default: + break; + } + + this->actionFunc(this, play); + Math_Vec3f_Copy(&this->prevPlayerPos, &player->bodyPartsPos[0]); +} + +/** + * Updates this door's flags if the player has moved beyond it. If the door is of type + * BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING, then nothing happens here, so the door never + * knows the player has moved beyond it. + */ +void BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(BgCraceMovebg* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + Vec3f intersect; + Vec3f posDiff; + + if ((BG_CRACE_MOVEBG_GET_TYPE(&this->dyna.actor) != BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING) && + SubS_LineSegVsPlane(&this->dyna.actor.home.pos, &this->dyna.actor.home.rot, &sUnitVecZ, &this->prevPlayerPos, + &player->bodyPartsPos[PLAYER_BODYPART_WAIST], &intersect)) { + Matrix_RotateYS(-this->dyna.actor.home.rot.y, MTXMODE_NEW); + Math_Vec3f_Diff(&player->bodyPartsPos[PLAYER_BODYPART_WAIST], &this->dyna.actor.home.pos, &posDiff); + Matrix_MultVec3f(&posDiff, &this->intersectionOffsetFromHome); + + if (fabsf(this->intersectionOffsetFromHome.x) < 100.0f && this->intersectionOffsetFromHome.y >= -10.0f && + this->intersectionOffsetFromHome.y <= 180.0f) { + if (this->intersectionOffsetFromHome.z < 0.0f) { + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + this->stateFlags |= BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR; + } else { + Flags_UnsetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1); + this->stateFlags &= ~BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR; + } + } + } +} + +void BgCraceMovebg_ClosingDoor_SetupIdle(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 180.0f; + this->doorHeight = 180.0f; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 180.0f; + this->actionFunc = BgCraceMovebg_ClosingDoor_Idle; +} + +/** + * Wait for the Deku Butler to move beyond the door, or wait for this door's switch flag + * to be set. In either case, start closing; how long to wait before closing depends on + * what triggered it to close. + */ +void BgCraceMovebg_ClosingDoor_Idle(BgCraceMovebg* this, PlayState* play) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (this->stateFlags & BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR) { + BgCraceMovebg_ClosingDoor_SetupWaitToClose(this, play); + } + + if (Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor))) { + BgCraceMovebg_ClosingDoor_SetupClose(this, play); + } +} + +void BgCraceMovebg_ClosingDoor_SetupWaitToClose(BgCraceMovebg* this, PlayState* play) { + this->closeWaitTimer = BG_CRACE_MOVEBG_GET_CLOSE_WAIT_TIMER(&this->dyna.actor) * 10; + this->targetDoorHeight = 180.0f; + this->doorHeight = 180.0f; + this->actionFunc = BgCraceMovebg_ClosingDoor_WaitToClose; +} + +/** + * Wait until the closeWaitTimer reaches 0, then set the door's switch flag and start closing. + */ +void BgCraceMovebg_ClosingDoor_WaitToClose(BgCraceMovebg* this, PlayState* play) { + if (this->closeWaitTimer > 0) { + this->closeWaitTimer--; + } + + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (this->closeWaitTimer <= 0) { + this->doorHeight = 180.0f; + this->targetDoorHeight = 0.0f; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 180.0f; + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor)); + BgCraceMovebg_ClosingDoor_SetupClose(this, play); + } +} + +void BgCraceMovebg_ClosingDoor_SetupClose(BgCraceMovebg* this, PlayState* play) { + this->actionFunc = BgCraceMovebg_ClosingDoor_Close; +} + +/** + * Slowly slide closed, then check to see if the player is beyond the door. If the player has + * not moved beyond the door, trigger a voidout. Otherwise, do nothing. + */ +void BgCraceMovebg_ClosingDoor_Close(BgCraceMovebg* this, PlayState* play) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + this->doorHeight; + BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor(this, play); + + if (Math_StepToF(&this->doorHeight, 0.0f, 1.0f)) { + if (!(this->stateFlags & BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR) && + !Flags_GetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(&this->dyna.actor) + 1)) { + play->unk_18845 = 1; + func_80169FDC(&play->state); + play_sound(NA_SE_OC_ABYSS); + } + + BgCraceMovebg_ClosingDoor_SetupDoNothing(this, play); + } else { + func_800B9010(&this->dyna.actor, NA_SE_EV_STONEDOOR_CLOSE_S - SFX_FLAG); + } +} + +void BgCraceMovebg_ClosingDoor_SetupDoNothing(BgCraceMovebg* this, PlayState* play) { + this->targetDoorHeight = 0.0f; + this->doorHeight = 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 = BgCraceMovebg_ClosingDoor_DoNothing; +} + +void BgCraceMovebg_ClosingDoor_DoNothing(BgCraceMovebg* this, PlayState* play) { +} + +void BgCraceMovebg_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, gDekuShrineSlidingDoorDL); +} 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..8f3b1aabe 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,20 +2,40 @@ #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 BG_CRACE_MOVEBG_GET_TYPE(thisx) (((thisx)->params) & 0xF) +#define BG_CRACE_MOVEBG_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 4) & 0x7F) +#define BG_CRACE_MOVEBG_GET_CLOSE_WAIT_TIMER(thisx) (((thisx)->params >> 0xB) & 0x1F) +#define BG_CRACE_MOVEBG_GET_INDEX(thisx) ((thisx)->world.rot.x) +#define BG_CRACE_MOVEBG_GET_OPEN_SPEED(thisx) ((thisx)->world.rot.z) + +#define BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR (1 << 0) +#define BG_CRACE_MOVEBG_FLAG_PLAYER_IS_BEYOND_DOOR (1 << 1) +#define BG_CRACE_MOVEBG_FLAG_ALREADY_LOADED (1 << 3) + +typedef enum { + /* 0 */ BG_CRACE_MOVEBG_TYPE_CLOSING, + /* 1 */ BG_CRACE_MOVEBG_TYPE_OPENING, + /* 2 */ BG_CRACE_MOVEBG_TYPE_UNUSED_CLOSING // Not triggered to close by the Deku Butler, and triggers a voidout no matter which side of the door they're on. +} BgCraceMovebgType; 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 doorHeight; + /* 0x164 */ f32 targetDoorHeight; + /* 0x168 */ UNK_TYPE1 pad168[0x4]; + /* 0x16C */ f32 openSpeed; + /* 0x170 */ s32 stateFlags; + /* 0x174 */ s32 closeWaitTimer; + /* 0x178 */ Vec3f intersectionOffsetFromHome; + /* 0x184 */ u8 index; + /* 0x188 */ Vec3f prevPlayerPos; } BgCraceMovebg; // size = 0x194 -extern const ActorInit Bg_Crace_Movebg_InitVars; - #endif // Z_BG_CRACE_MOVEBG_H diff --git a/src/overlays/actors/ovl_Bg_Ctower_Gear/overlay.cfg b/src/overlays/actors/ovl_Bg_Ctower_Gear/overlay.cfg deleted file mode 100644 index 244f98e32..000000000 --- a/src/overlays/actors/ovl_Bg_Ctower_Gear/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ctower_Gear -z_bg_ctower_gear.c 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 6ac390ce5..68b2d77d2 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,15 +11,15 @@ #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 = { +ActorInit Bg_Ctower_Gear_InitVars = { ACTOR_BG_CTOWER_GEAR, ACTORCAT_PROP, FLAGS, @@ -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; @@ -78,7 +78,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { 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; @@ -86,7 +86,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { 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); } } } @@ -104,7 +104,7 @@ void BgCtowerGear_Splash(BgCtowerGear* this, GlobalContext* globalCtx) { 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,41 +156,41 @@ 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); + Actor_Kill(&this->dyna.actor); break; } } } -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..afea1bf0d 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,16 +9,14 @@ 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 { /* 0x000 */ DynaPolyActor dyna; } BgCtowerGear; // size = 0x15C -extern const ActorInit Bg_Ctower_Gear_InitVars; - #endif // Z_BG_CTOWER_GEAR_H diff --git a/src/overlays/actors/ovl_Bg_Ctower_Rot/overlay.cfg b/src/overlays/actors/ovl_Bg_Ctower_Rot/overlay.cfg deleted file mode 100644 index c41e36b27..000000000 --- a/src/overlays/actors/ovl_Bg_Ctower_Rot/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ctower_Rot -z_bg_ctower_rot.c 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 d562d1a7e..85dcb0aca 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,17 +11,17 @@ #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 = { +ActorInit Bg_Ctower_Rot_InitVars = { ACTOR_BG_CTOWER_ROT, ACTORCAT_BG, FLAGS, @@ -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,31 +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; Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &offset, &player->actor.world.pos); rotZ = CLAMP(1100.0f - offset.z, 0.0f, 1000.0f); - func_800DFAC8(globalCtx->cameraPtrs[CAM_ID_MAIN], 17); + Camera_ChangeSetting(play->cameraPtrs[CAM_ID_MAIN], CAM_SET_DUNGEON0); this->dyna.actor.shape.rot.z = rotZ * 16.384f; - if (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); @@ -112,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); @@ -124,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); @@ -135,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..52a905ed5 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, @@ -21,6 +21,4 @@ typedef struct BgCtowerRot { /* 0x164 */ f32 timer; } BgCtowerRot; // size = 0x168 -extern const ActorInit Bg_Ctower_Rot_InitVars; - #endif // Z_BG_CTOWER_ROT_H diff --git a/src/overlays/actors/ovl_Bg_Danpei_Movebg/overlay.cfg b/src/overlays/actors/ovl_Bg_Danpei_Movebg/overlay.cfg deleted file mode 100644 index beb2b3010..000000000 --- a/src/overlays/actors/ovl_Bg_Danpei_Movebg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Danpei_Movebg -z_bg_danpei_movebg.c 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..a5d01fe65 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,12 +10,12 @@ #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 = { +ActorInit Bg_Danpei_Movebg_InitVars = { ACTOR_BG_DANPEI_MOVEBG, ACTORCAT_BG, FLAGS, 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..c99bb813f 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,16 +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; - #endif // Z_BG_DANPEI_MOVEBG_H diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/overlay.cfg b/src/overlays/actors/ovl_Bg_Dblue_Balance/overlay.cfg deleted file mode 100644 index f0f5a4f1a..000000000 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Dblue_Balance -z_bg_dblue_balance.c 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 0c5b92496..c962cf8ef 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 @@ -1,9 +1,10 @@ /* * File: z_bg_dblue_balance.c * Overlay: ovl_Bg_Dblue_Balance - * Description: Great Bay Temple - See-Saw + * Description: Great Bay Temple - Seesaw and Waterwheel w/ Platforms */ +#include "prevent_bss_reordering.h" #include "z_bg_dblue_balance.h" #include "objects/object_dblue_object/object_dblue_object.h" @@ -11,25 +12,25 @@ #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; -const ActorInit Bg_Dblue_Balance_InitVars = { +ActorInit Bg_Dblue_Balance_InitVars = { ACTOR_BG_DBLUE_BALANCE, ACTORCAT_BG, FLAGS, @@ -42,19 +43,19 @@ const ActorInit Bg_Dblue_Balance_InitVars = { }; typedef struct { - /* 0x00 */ Gfx* unk_00; - /* 0x04 */ CollisionHeader* unk_04; + /* 0x00 */ Gfx* opaDList; + /* 0x04 */ CollisionHeader* colHeader; /* 0x08 */ u32 unk_08; /* 0x0C */ f32 unk_0C; /* 0x10 */ f32 unk_10; - /* 0x14 */ ActorFunc unk_14; - /* 0x18 */ ActorFunc unk_18; -} BgDblueBalanceStruct2; + /* 0x14 */ ActorFunc update; + /* 0x18 */ ActorFunc draw; +} BgDblueBalanceTypeInfo; // size = 0x1C -BgDblueBalanceStruct2 D_80B83A20[] = { +BgDblueBalanceTypeInfo sTypeInfo[] = { { - object_dblue_object_DL_00B8F8, - &object_dblue_object_Colheader_00BC08, + gGreatBayTempleObjectSeesawShaftDL, + &gGreatBayTempleObjectSeesawShaftCol, 0x10, 360.0f, 300.0f, @@ -62,8 +63,8 @@ BgDblueBalanceStruct2 D_80B83A20[] = { BgDblueBalance_Draw, }, { - object_dblue_object_DL_00BF48, - &object_dblue_object_Colheader_00C180, + gGreatBayTempleObjectLargeSeesawPlatformDL, + &gGreatBayTempleObjectLargeSeesawPlatformCol, 0x10, 210.0f, 190.0f, @@ -71,8 +72,8 @@ BgDblueBalanceStruct2 D_80B83A20[] = { BgDblueBalance_Draw, }, { - object_dblue_object_DL_00C4B8, - &object_dblue_object_Colheader_00C700, + gGreatBayTempleObjectSmallSeesawPlatformDL, + &gGreatBayTempleObjectSmallSeesawPlatformCol, 0x10, 180.0f, 180.0f, @@ -80,8 +81,8 @@ BgDblueBalanceStruct2 D_80B83A20[] = { BgDblueBalance_Draw, }, { - object_dblue_object_DL_001E68, - &object_dblue_object_Colheader_002E78, + gGreatBayTempleObjectWaterwheelWithPlatformsDL, + &gGreatBayTempleObjectWaterwheelWithPlatformsCol, 0x30, 1500.0f, 1500.0f, @@ -129,7 +130,7 @@ void func_80B823B0(BgDblueBalance* this) { } } -s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { +s32 func_80B82454(BgDblueBalance* this, PlayState* play) { s32 pad; s32 sp58 = true; BgDblueBalance* balance; @@ -147,8 +148,8 @@ s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { 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 { @@ -159,8 +160,8 @@ s32 func_80B82454(BgDblueBalance* this, GlobalContext* globalCtx) { sp48.x = 138.28f; 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)) { @@ -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,28 +302,28 @@ 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); - this->dyna.actor.flags = D_80B83A20[sp2C].unk_08; - this->dyna.actor.uncullZoneScale = D_80B83A20[sp2C].unk_0C; - this->dyna.actor.uncullZoneDownward = D_80B83A20[sp2C].unk_10; - this->dyna.actor.update = D_80B83A20[sp2C].unk_14; - this->dyna.actor.draw = D_80B83A20[sp2C].unk_18; + this->dyna.actor.flags = sTypeInfo[sp2C].unk_08; + this->dyna.actor.uncullZoneScale = sTypeInfo[sp2C].unk_0C; + this->dyna.actor.uncullZoneDownward = sTypeInfo[sp2C].unk_10; + this->dyna.actor.update = sTypeInfo[sp2C].update; + this->dyna.actor.draw = sTypeInfo[sp2C].draw; DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B83A20[sp2C].unk_04); + DynaPolyActor_LoadMesh(play, &this->dyna, sTypeInfo[sp2C].colHeader); if (sp2C == 3) { - D_80B83C70 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00CE00); + D_80B83C70 = Lib_SegmentedToVirtual(gGreatBayTempleObjectWaterwheelSplashTexAnim); } else if (sp2C == 0) { - D_80B83C74 = Lib_SegmentedToVirtual(object_dblue_object_Matanimheader_00D250); + D_80B83C74 = Lib_SegmentedToVirtual(gGreatBayTempleObjectSeesawSplashTexAnim); } if (sp2C == 0) { @@ -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; @@ -495,7 +496,7 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { 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); } @@ -520,7 +521,7 @@ void func_80B82DE0(BgDblueBalance* this, GlobalContext* globalCtx) { 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,46 +642,46 @@ 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)]; + BgDblueBalanceTypeInfo* ptr2 = &sTypeInfo[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; BgDblueBalance* sp38; Gfx* gfx; - Gfx_DrawDListOpa(globalCtx, ptr2->unk_00); + Gfx_DrawDListOpa(play, ptr2->opaDList); 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_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); + gSPDisplayList(gfx++, gGreatBayTempleObjectSeesawSplashDL); 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; Gfx* gfx; s32 i; BgDblueBalanceStruct* ptr; - BgDblueBalanceStruct2* ptr2; + BgDblueBalanceTypeInfo* ptr2; s32 temp; if (this->unk_178 != 0) { @@ -694,13 +695,13 @@ 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); + ptr2 = &sTypeInfo[BGDBLUEBALANCE_GET_300(&this->dyna.actor)]; + Gfx_DrawDListOpa(play, ptr2->opaDList); 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; @@ -715,15 +716,14 @@ void func_80B83758(Actor* thisx, GlobalContext* globalCtx) { temp = ptr->unk_0E * (f32)this->unk_183 * 0.003921569f; gDPSetEnvColor(gfx++, 0, 0, 0, temp); - gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, object_dblue_object_DL_00CD10); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gGreatBayTempleObjectWaterwheelSplashDL); } } 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..f2200e96f 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,32 +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; - #endif // Z_BG_DBLUE_BALANCE_H diff --git a/src/overlays/actors/ovl_Bg_Dblue_Elevator/overlay.cfg b/src/overlays/actors/ovl_Bg_Dblue_Elevator/overlay.cfg deleted file mode 100644 index 8193509f4..000000000 --- a/src/overlays/actors/ovl_Bg_Dblue_Elevator/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Dblue_Elevator -z_bg_dblue_elevator.c 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..a1d724b29 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,13 +10,13 @@ #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 = { +ActorInit Bg_Dblue_Elevator_InitVars = { ACTOR_BG_DBLUE_ELEVATOR, ACTORCAT_BG, FLAGS, 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..89a18dd0c 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,15 +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; - #endif // Z_BG_DBLUE_ELEVATOR_H diff --git a/src/overlays/actors/ovl_Bg_Dblue_Movebg/overlay.cfg b/src/overlays/actors/ovl_Bg_Dblue_Movebg/overlay.cfg deleted file mode 100644 index 7188cf2ea..000000000 --- a/src/overlays/actors/ovl_Bg_Dblue_Movebg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Dblue_Movebg -z_bg_dblue_movebg.c 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 857eb43cf..d6819aa00 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 @@ -1,9 +1,10 @@ /* * File: z_bg_dblue_movebg.c * Overlay: ovl_Bg_Dblue_Movebg - * Description: Great Bay Temple - Waterwheels and push switches + * Description: Great Bay Temple - Waterwheels, push switches, gear shafts, and whirlpools */ +#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* play2); -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; @@ -44,7 +45,7 @@ u8 D_80A2B870[][2] = { { 0x03, 0x03 }, { 0x03, 0x05 }, { 0x03, 0x01 }, { 0x03, 0x06 }, { 0x03, 0x02 }, { 0x03, 0x04 }, { 0x03, 0x00 }, }; -const ActorInit Bg_Dblue_Movebg_InitVars = { +ActorInit Bg_Dblue_Movebg_InitVars = { ACTOR_BG_DBLUE_MOVEBG, ACTORCAT_BG, FLAGS, @@ -56,42 +57,42 @@ const ActorInit Bg_Dblue_Movebg_InitVars = { (ActorFunc)BgDblueMovebg_Draw, }; -Gfx* D_80A2B8AC[] = { +static Gfx* sOpaDLists[] = { NULL, - object_dblue_object_DL_0069D8, + gGreatBayTempleObjectTwoWaySwitchDL, NULL, NULL, NULL, NULL, - object_dblue_object_DL_004848, - object_dblue_object_DL_0061B8, + gGreatBayTempleObjectGearShaftWithPlatformsDL, + gGreatBayTempleObjectOneWaySwitchDL, NULL, NULL, NULL, NULL, }; -Gfx* D_80A2B8DC[] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_DL_00CAA0, NULL, +static Gfx* sXluDLists[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, gGreatBayTempleObjectWhirlpoolDL, NULL, }; -CollisionHeader* D_80A2B90C[] = { +static CollisionHeader* sColHeaders[] = { NULL, - &object_dblue_object_Colheader_006EA8, + &gGreatBayTempleObjectTwoWaySwitchCol, NULL, NULL, NULL, - &object_dblue_object_Colheader_00D3DC, - &object_dblue_object_Colheader_005D28, - &object_dblue_object_Colheader_00714C, - &object_dblue_object_Colheader_00AED0, - &object_dblue_object_Colheader_00AED0, + &gGreatBayTempleObjectUnusedCol, + &gGreatBayTempleObjectGearShaftWithPlatformsCol, + &gGreatBayTempleObjectOneWaySwitchCol, + &gGreatBayTempleObjectWaterwheelCol, + &gGreatBayTempleObjectWaterwheelCol, NULL, NULL, }; -AnimatedMaterial* D_80A2B93C[] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, object_dblue_object_Matanimheader_00CC18, NULL, +static AnimatedMaterial* sTexAnims[] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, gGreatBayTempleObjectWhirlpoolTexAnim, NULL, }; s16 D_80A2B96C[] = { 0, 0x16C, -0x16C, 0 }; @@ -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; @@ -166,7 +167,7 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { if ((this->unk_160 == 9) || (this->unk_160 == 8)) { if (D_80A2BBF4.unk_00 != 0) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } this->unk_170 = this->dyna.actor.room; @@ -177,7 +178,7 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = 0; } else if (this->unk_160 == 6) { if (D_80A2BBF4.unk_01 != 0) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } this->unk_171 = this->dyna.actor.world.rot.z; @@ -188,13 +189,13 @@ void BgDblueMovebg_Init(Actor* thisx, GlobalContext* globalCtx) { D_80A2BBF4.unk_01 = 1; } - if (D_80A2B90C[this->unk_160] != NULL) { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80A2B90C[this->unk_160]); + if (sColHeaders[this->unk_160] != NULL) { + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[this->unk_160]); } - this->unk_164 = D_80A2B8AC[this->unk_160]; - this->unk_168 = D_80A2B8DC[this->unk_160]; - this->unk_16C = D_80A2B93C[this->unk_160]; + this->opaDList = sOpaDLists[this->unk_160]; + this->xluDList = sXluDLists[this->unk_160]; + this->texAnim = sTexAnims[this->unk_160]; SubS_FillCutscenesList(&this->dyna.actor, this->unk_1B6, ARRAY_COUNT(this->unk_1B6)); @@ -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,8 +237,8 @@ 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)) { - Actor_MarkForDeath(&this->dyna.actor); + if (Flags_GetSwitch(play, this->unk_1C0)) { + Actor_Kill(&this->dyna.actor); break; } this->unk_18C = 0; @@ -256,7 +257,7 @@ 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_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); @@ -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,25 +340,24 @@ 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) { - this->unk_164 = object_dblue_object_DL_004848; - } else if (globalCtx->roomCtx.currRoom.num == 8) { - this->unk_164 = NULL; + if (play->roomCtx.curRoom.num == 0) { + this->opaDList = gGreatBayTempleObjectGearShaftWithPlatformsDL; + } else if (play->roomCtx.curRoom.num == 8) { + this->opaDList = 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.curRoom.num != this->unk_170) { + if (play->roomCtx.curRoom.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); + Actor_Kill(&this->dyna.actor); } } } } -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; @@ -390,14 +390,14 @@ void func_80A2A32C(BgDblueMovebg* this, GlobalContext* globalCtx) { this->unk_172 |= 8; this->actionFunc = func_80A2A444; } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } } } -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; @@ -410,7 +410,7 @@ void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.y = (s32)((this->unk_18C + temp_v0) * 0.1f * (0x10000 / 360.0f)) + this->dyna.actor.home.rot.y; - if ((player->stateFlags2 & 0x10) && (this->unk_184 > 0.0f)) { + if ((player->stateFlags2 & PLAYER_STATE2_10) && (this->unk_184 > 0.0f)) { player->actor.world.pos.x = (Math_SinS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.x; player->actor.world.pos.z = @@ -420,12 +420,12 @@ void func_80A2A444(BgDblueMovebg* this, GlobalContext* globalCtx) { } if (sp20) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; 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]); @@ -452,12 +452,12 @@ void func_80A2A688(BgDblueMovebg* this, GlobalContext* globalCtx) { if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 60.0f, 2.0f) && (this->unk_180 <= 0)) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } } -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; @@ -498,7 +498,7 @@ void func_80A2A7F8(BgDblueMovebg* this, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.y = (s32)((this->unk_18C + sp26) * 0.1f * (0x10000 / 360.0f)) + this->dyna.actor.home.rot.y; - if ((player->stateFlags2 & 0x10) && (this->unk_184 > 0.0f)) { + if ((player->stateFlags2 & PLAYER_STATE2_10) && (this->unk_184 > 0.0f)) { player->actor.world.pos.x = (Math_SinS(this->dyna.actor.shape.rot.y - this->unk_18E) * this->unk_184) + this->dyna.actor.home.pos.x; player->actor.world.pos.z = @@ -511,13 +511,13 @@ 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; - player->stateFlags2 &= ~0x10; + player->stateFlags1 |= PLAYER_STATE1_20; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; this->unk_18C = (this->unk_18C + sp26 + 3600) % 3600; @@ -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) { @@ -565,18 +565,18 @@ void func_80A2AAB8(BgDblueMovebg* this, GlobalContext* globalCtx) { if (this->unk_1D0 == 1) { this->dyna.pushForce = 0.0f; - player->stateFlags1 |= 0x20; - player->stateFlags2 &= ~0x10; + player->stateFlags1 |= PLAYER_STATE1_20; + player->stateFlags2 &= ~PLAYER_STATE2_10; } if (this->unk_1D0 <= 0) { - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_20; this->actionFunc = func_80A2A714; } } } -void func_80A2ABD0(BgDblueMovebg* this, GlobalContext* globalCtx) { +void func_80A2ABD0(BgDblueMovebg* this, PlayState* play) { Vec3f spAC; f32 temp_f0; f32 temp_f20; @@ -586,7 +586,7 @@ 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; } @@ -624,22 +624,21 @@ 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.curRoom.num != this->unk_170) { + if (play->roomCtx.curRoom.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); + Actor_Kill(&this->dyna.actor); return; } } } - 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,43 +669,43 @@ 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.curRoom.num == 8) { + func_80A2ABD0(this, play); this->unk_172 |= 0x20; } else { this->unk_172 &= ~0x20; } } - if (globalCtx->roomCtx.currRoom.num == 0) { - this->unk_164 = object_dblue_object_DL_008778; - } else if (globalCtx->roomCtx.currRoom.num == 8) { - this->unk_164 = object_dblue_object_DL_00A528; + if (play->roomCtx.curRoom.num == 0) { + this->opaDList = gGreatBayTempleObjectWaterwheelDL; + } else if (play->roomCtx.curRoom.num == 8) { + this->opaDList = gGreatBayTempleObjectWaterwheelWithFakeGearDL; } if (this == D_80A2BBF0) { Vec3f sp54; f32 sp50; - if (Math3D_PointDistToLine2D(globalCtx->view.eye.x, globalCtx->view.eye.z, this->unk_190.x, this->unk_190.z, + 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,16 +728,16 @@ 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; if (this != D_80A2BBF0) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); 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,22 +747,22 @@ 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); - gSPDisplayList(POLY_OPA_DISP++, this->unk_164); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, this->opaDList); - 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; @@ -772,37 +771,37 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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)); + if (this->texAnim != NULL) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(this->texAnim)); } - if ((this->unk_164 != 0) || (this->unk_160 == 6)) { + if ((this->opaDList != NULL) || (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); - if (this->unk_164 != 0) { - gSPDisplayList(&gfx2[2], this->unk_164); + gSPDisplayList(&gfx2[1], gGreatBayTempleObjectGearShaftDL); + if (this->opaDList != NULL) { + gSPDisplayList(&gfx2[2], this->opaDList); POLY_OPA_DISP = &gfx2[3]; } else { POLY_OPA_DISP = &gfx2[2]; } } else { - gSPDisplayList(&gfx2[1], this->unk_164); + gSPDisplayList(&gfx2[1], this->opaDList); POLY_OPA_DISP = &gfx2[2]; } } - if (this->unk_168 != NULL) { + if (this->xluDList != NULL) { gfx = func_8012C2B4(POLY_XLU_DISP); - gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(&gfx[1], this->unk_168); + gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], this->xluDList); POLY_XLU_DISP = &gfx[2]; } @@ -810,12 +809,12 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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(gGreatBayTempleObjectWaterwheelSplashTexAnim)); - OPEN_DISPS(globalCtx->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); @@ -828,11 +827,10 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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_Push(); Matrix_RotateXS(i * 0x2000, MTXMODE_APPLY); @@ -844,10 +842,9 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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); + gSPDisplayList(gfx++, gGreatBayTempleObjectWaterwheelSplashDL); Matrix_Pop(); } @@ -855,7 +852,7 @@ void BgDblueMovebg_Draw(Actor* thisx, GlobalContext* globalCtx2) { } 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..8fc016585 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) @@ -17,9 +17,9 @@ typedef struct BgDblueMovebg { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgDblueMovebgActionFunc actionFunc; /* 0x160 */ s32 unk_160; - /* 0x164 */ Gfx* unk_164; - /* 0x168 */ Gfx* unk_168; - /* 0x16C */ TexturePtr unk_16C; + /* 0x164 */ Gfx* opaDList; + /* 0x168 */ Gfx* xluDList; + /* 0x16C */ AnimatedMaterial* texAnim; /* 0x170 */ s8 unk_170; /* 0x171 */ s8 unk_171; /* 0x172 */ u16 unk_172; @@ -55,6 +55,4 @@ typedef struct BgDblueMovebg { /* 0x310 */ UNK_TYPE1 unk310[0x60]; } BgDblueMovebg; // size = 0x370 -extern const ActorInit Bg_Dblue_Movebg_InitVars; - #endif // Z_BG_DBLUE_MOVEBG_H diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/overlay.cfg b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/overlay.cfg deleted file mode 100644 index 08aaa6100..000000000 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Dblue_Waterfall -z_bg_dblue_waterfall.c 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 fcec4ebb3..b4c97fdde 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 @@ -1,7 +1,7 @@ /* * File: z_bg_dblue_waterfall.c * Overlay: ovl_Bg_Dblue_Waterfall - * Description: Great Bay Temple - Freezable Geyser + * Description: Great Bay Temple - Freezable Waterfall */ #include "z_bg_dblue_waterfall.h" @@ -11,21 +11,21 @@ #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 = { +ActorInit Bg_Dblue_Waterfall_InitVars = { ACTOR_BG_DBLUE_WATERFALL, ACTORCAT_PROP, FLAGS, @@ -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) { @@ -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); + this->unk_190 = Lib_SegmentedToVirtual(gGreatBayTempleObjectWaterfallTexAnim); 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,58 +574,57 @@ 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); + gSPDisplayList(POLY_XLU_DISP++, gGreatBayTempleObjectWaterfallDL); } if (this->unk_19F > 0) { if (this->unk_19F < 255) { gSPSegment(POLY_XLU_DISP++, 0x09, D_801AEF88); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x9B, 255, 255, 255, this->unk_19F); - gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003358); + gSPDisplayList(POLY_XLU_DISP++, gGreatBayTempleObjectIceStalactiteDL); } 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); - gSPDisplayList(POLY_OPA_DISP++, object_dblue_object_DL_003358); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGreatBayTempleObjectIceStalactiteDL); } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_19F); - gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003250); + gSPDisplayList(POLY_XLU_DISP++, gGreatBayTempleObjectIceStalactiteRimDL); } if (this->unk_1A0 > 0) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->unk_1A0); - gSPDisplayList(POLY_XLU_DISP++, object_dblue_object_DL_003770); + gSPDisplayList(POLY_XLU_DISP++, gGreatBayTempleObjectFrozenWaterfallDL); } - 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..5ab64495e 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,29 +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; - #endif // Z_BG_DBLUE_WATERFALL_H diff --git a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/overlay.cfg b/src/overlays/actors/ovl_Bg_Dkjail_Ivy/overlay.cfg deleted file mode 100644 index 4a1aa8be1..000000000 --- a/src/overlays/actors/ovl_Bg_Dkjail_Ivy/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Dkjail_Ivy -z_bg_dkjail_ivy.c 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..6ec845e2c 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 @@ -5,18 +5,26 @@ */ #include "z_bg_dkjail_ivy.h" +#include "assets/objects/gameplay_keep/gameplay_keep.h" +#include "assets/objects/object_dkjail_obj/object_dkjail_obj.h" #define FLAGS 0x00000000 #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 = { +void BgDkjailIvy_SetupWaitForCut(BgDkjailIvy* this); +void BgDkjailIvy_WaitForCut(BgDkjailIvy* this, PlayState* play); +void BgDkjailIvy_SetupCutscene(BgDkjailIvy* this); +void BgDkjailIvy_BeginCutscene(BgDkjailIvy* this, PlayState* play); +void BgDkjailIvy_SetupFadeOut(BgDkjailIvy* this); +void BgDkjailIvy_FadeOut(BgDkjailIvy* this, PlayState* play); + +ActorInit Bg_Dkjail_Ivy_InitVars = { ACTOR_BG_DKJAIL_IVY, ACTORCAT_BG, FLAGS, @@ -28,47 +36,175 @@ const ActorInit Bg_Dkjail_Ivy_InitVars = { (ActorFunc)BgDkjailIvy_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80ADE950 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x01000200, 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 }, + { 0x01000200, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 20, 80, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ADE98C[] = { +void BgDkjailIvy_IvyCutEffects(BgDkjailIvy* this, PlayState* play) { + static Gfx* sLeafDlists[] = { gKakeraLeafMiddle, gKakeraLeafTip }; + static s16 sLeafScales[] = { 110, 80, 60, 40 }; + f32 phi_fs0; + s32 i; + Vec3f spD4; + Vec3f pos; + Vec3f vel; + Vec3f accel; + s16 angle; + + Matrix_RotateYS(this->dyna.actor.home.rot.y, MTXMODE_NEW); + + for (i = 0, angle = 0; i < 50; i++, angle += 0x4E20) { + spD4.y = (i * (90.0f / 49.0f)) + 2.0f; + if (spD4.y < 45.0f) { + phi_fs0 = ((1.0f / 180.0f) * spD4.y) + 0.75f; + } else if (spD4.y < 90.0f) { + phi_fs0 = ((-1.0f / 180.0f) * spD4.y) + 1.25f; + } else { + phi_fs0 = ((-1.0f / 30.0f) * spD4.y) + 3.75f; + } + + spD4.x = Math_SinS(angle) * 40.0f * phi_fs0; + spD4.z = (Rand_ZeroOne() * 6.0f) - 3.0f; + + Matrix_MultVec3f(&spD4, &pos); + + vel.x = (Rand_ZeroOne() - 0.5f) + (pos.x * 0.075f); + vel.y = 2.0f * Rand_ZeroOne(); + vel.z = (Rand_ZeroOne() - 0.5f) + (pos.z * 0.075f); + + pos.x += this->dyna.actor.world.pos.x; + pos.y += this->dyna.actor.world.pos.y; + pos.z += this->dyna.actor.world.pos.z; + + EffectSsKakera_Spawn(play, &pos, &vel, &pos, -0x82, 0x40, 0x28, 0, 0, sLeafScales[i & 3], 0, 0, 44, -1, + GAMEPLAY_KEEP, sLeafDlists[(s32)Rand_Next() > 0]); + + if ((i > 20) && ((i % 2) != 0)) { + accel.x = (Rand_ZeroOne() - 0.5f) * 0.2f; + accel.y = (Rand_ZeroOne() * 0.02f) - 0.1f; + accel.z = (Rand_ZeroOne() - 0.5f) * 0.2f; + + func_800B12F0(play, &pos, &gZeroVec3f, &accel, ((Rand_Next() >> 26) + 10), (Rand_Next() >> 28), 50); + } + } +} + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgDkjailIvy_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgDkjailIvy* this = THIS; -extern ColliderCylinderInit D_80ADE950; -extern InitChainEntry D_80ADE98C[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + Collider_InitCylinder(play, &this->collider); -extern UNK_TYPE D_06000080; -extern UNK_TYPE D_060011A8; + if (Flags_GetSwitch(play, BG_DKJAIL_GET_SWITCH(thisx))) { + Actor_Kill(&this->dyna.actor); + } else { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_dkjail_obj_Colheader_0011A8); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + this->alpha = 255; + BgDkjailIvy_SetupWaitForCut(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/func_80ADE230.s") +void BgDkjailIvy_Destroy(Actor* thisx, PlayState* play) { + BgDkjailIvy* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/BgDkjailIvy_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/BgDkjailIvy_Destroy.s") +void BgDkjailIvy_SetupWaitForCut(BgDkjailIvy* this) { + this->actionFunc = BgDkjailIvy_WaitForCut; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/func_80ADE6AC.s") +void BgDkjailIvy_WaitForCut(BgDkjailIvy* this, PlayState* play) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + BgDkjailIvy_SetupCutscene(this); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/func_80ADE6C0.s") +void BgDkjailIvy_SetupCutscene(BgDkjailIvy* this) { + this->actionFunc = BgDkjailIvy_BeginCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/func_80ADE734.s") +void BgDkjailIvy_BeginCutscene(BgDkjailIvy* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->fadeOutTimer = 50; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + Flags_SetSwitch(play, BG_DKJAIL_GET_SWITCH(&this->dyna.actor)); + BgDkjailIvy_IvyCutEffects(this, play); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_GRASS_WALL_BROKEN); + BgDkjailIvy_SetupFadeOut(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/func_80ADE748.s") +void BgDkjailIvy_SetupFadeOut(BgDkjailIvy* this) { + this->actionFunc = BgDkjailIvy_FadeOut; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/func_80ADE7E0.s") +void BgDkjailIvy_FadeOut(BgDkjailIvy* this, PlayState* play) { + if (this->alpha > 8) { + this->alpha -= 8; + } else { + this->alpha = 0; + this->dyna.actor.draw = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/func_80ADE7F4.s") + this->fadeOutTimer--; + if (this->fadeOutTimer <= 0) { + Actor_Kill(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/BgDkjailIvy_Update.s") +void BgDkjailIvy_Update(Actor* thisx, PlayState* play) { + BgDkjailIvy* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Dkjail_Ivy/BgDkjailIvy_Draw.s") + this->actionFunc(this, play); +} + +void BgDkjailIvy_Draw(Actor* thisx, PlayState* play) { + BgDkjailIvy* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0xFF, 255, 255, 255, this->alpha); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gDkjailIvyDL); + + CLOSE_DISPS(play->state.gfxCtx); +} 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..4835b7a0b 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 @@ -3,17 +3,18 @@ #include "global.h" +#define BG_DKJAIL_GET_SWITCH(thisx) ((thisx)->params & 0x7F) + 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 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgDkjailIvyActionFunc actionFunc; + /* 0x1AC */ s8 fadeOutTimer; + /* 0x1AD */ u8 alpha; } BgDkjailIvy; // size = 0x1B0 -extern const ActorInit Bg_Dkjail_Ivy_InitVars; - #endif // Z_BG_DKJAIL_IVY_H diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/overlay.cfg b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/overlay.cfg deleted file mode 100644 index 59c99de93..000000000 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Dy_Yoseizo -z_bg_dy_yoseizo.c 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..332e4e543 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,23 +10,23 @@ #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 = { +ActorInit Bg_Dy_Yoseizo_InitVars = { ACTOR_BG_DY_YOSEIZO, ACTORCAT_PROP, FLAGS, 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..bd06cdb38 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; @@ -13,6 +13,4 @@ typedef struct BgDyYoseizo { /* 0x0148 */ char unk_148[0x33BC]; } BgDyYoseizo; // size = 0x3504 -extern const ActorInit Bg_Dy_Yoseizo_InitVars; - #endif // Z_BG_DY_YOSEIZO_H diff --git a/src/overlays/actors/ovl_Bg_F40_Block/overlay.cfg b/src/overlays/actors/ovl_Bg_F40_Block/overlay.cfg deleted file mode 100644 index b5030fcaa..000000000 --- a/src/overlays/actors/ovl_Bg_F40_Block/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_F40_Block -z_bg_f40_block.c 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..71aa958dc 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,22 +11,22 @@ #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 = { +ActorInit Bg_F40_Block_InitVars = { ACTOR_BG_F40_BLOCK, ACTORCAT_BG, FLAGS, @@ -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..37a5c360e 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,20 +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; - #endif // Z_BG_F40_BLOCK_H diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/overlay.cfg b/src/overlays/actors/ovl_Bg_F40_Flift/overlay.cfg deleted file mode 100644 index f771926db..000000000 --- a/src/overlays/actors/ovl_Bg_F40_Flift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_F40_Flift -z_bg_f40_flift.c 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..4ae6a8ed7 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,18 +5,21 @@ */ #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); -#if 0 -const ActorInit Bg_F40_Flift_InitVars = { +void func_808D75F0(BgF40Flift* this, PlayState* play); +void func_808D7714(BgF40Flift* this, PlayState* play); + +ActorInit Bg_F40_Flift_InitVars = { ACTOR_BG_F40_FLIFT, ACTORCAT_BG, FLAGS, @@ -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..4bdb16e3e 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,15 +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; - #endif // Z_BG_F40_FLIFT_H diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/overlay.cfg b/src/overlays/actors/ovl_Bg_F40_Switch/overlay.cfg deleted file mode 100644 index b5e045459..000000000 --- a/src/overlays/actors/ovl_Bg_F40_Switch/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_F40_Switch -z_bg_f40_switch.c 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..3a7916e7d 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,25 +5,26 @@ */ #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 = { +ActorInit Bg_F40_Switch_InitVars = { ACTOR_BG_F40_SWITCH, ACTORCAT_SWITCH, FLAGS, @@ -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..cfa8c5462 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,19 +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; - #endif // Z_BG_F40_SWITCH_H diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/overlay.cfg b/src/overlays/actors/ovl_Bg_F40_Swlift/overlay.cfg deleted file mode 100644 index 83d9bffed..000000000 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_F40_Swlift -z_bg_f40_swlift.c 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..97fd3f068 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,13 +10,13 @@ #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 = { +ActorInit Bg_F40_Swlift_InitVars = { ACTOR_BG_F40_SWLIFT, ACTORCAT_BG, FLAGS, diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.h b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.h index 48a369e30..a687fc642 100644 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.h +++ b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.h @@ -10,6 +10,4 @@ typedef struct BgF40Swlift { /* 0x144 */ char unk_144[0x1C]; } BgF40Swlift; // size = 0x160 -extern const ActorInit Bg_F40_Swlift_InitVars; - #endif // Z_BG_F40_SWLIFT_H diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/overlay.cfg b/src/overlays/actors/ovl_Bg_Fire_Wall/overlay.cfg deleted file mode 100644 index 8405309d0..000000000 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Fire_Wall -z_bg_fire_wall.c 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..40b8c78a7 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,22 +5,23 @@ */ #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 = { +ActorInit Bg_Fire_Wall_InitVars = { ACTOR_BG_FIRE_WALL, ACTORCAT_BG, FLAGS, @@ -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_Kill(&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->timer != 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..af5a29923 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,14 +5,25 @@ struct BgFireWall; -typedef void (*BgFireWallActionFunc)(struct BgFireWall*, GlobalContext*); +typedef void (*BgFireWallActionFunc)(struct BgFireWall*, PlayState*); + +typedef enum { + /* 0 */ BGFIREWALL_PARAMS_0, + /* 1 */ BGFIREWALL_PARAMS_1, +} BgFireWallParams; 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; - #endif // Z_BG_FIRE_WALL_H diff --git a/src/overlays/actors/ovl_Bg_Fu_Kaiten/overlay.cfg b/src/overlays/actors/ovl_Bg_Fu_Kaiten/overlay.cfg deleted file mode 100644 index 30736ca5d..000000000 --- a/src/overlays/actors/ovl_Bg_Fu_Kaiten/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Fu_Kaiten -z_bg_fu_kaiten.c 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..40a981a6e 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,12 +11,12 @@ #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 = { +ActorInit Bg_Fu_Kaiten_InitVars = { ACTOR_BG_FU_KAITEN, ACTORCAT_BG, FLAGS, @@ -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_Kaiten/z_bg_fu_kaiten.h b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h index 6937fbf53..b09083519 100644 --- a/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h +++ b/src/overlays/actors/ovl_Bg_Fu_Kaiten/z_bg_fu_kaiten.h @@ -15,6 +15,4 @@ typedef struct BgFuKaiten { /* 0x16C */ s16 bounce; } BgFuKaiten; // size = 0x170 -extern const ActorInit Bg_Fu_Kaiten_InitVars; - #endif // Z_BG_FU_KAITEN_H diff --git a/src/overlays/actors/ovl_Bg_Fu_Mizu/overlay.cfg b/src/overlays/actors/ovl_Bg_Fu_Mizu/overlay.cfg deleted file mode 100644 index 295d23d04..000000000 --- a/src/overlays/actors/ovl_Bg_Fu_Mizu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Fu_Mizu -z_bg_fu_mizu.c 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..5cb337238 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,18 +5,18 @@ */ #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 = { +ActorInit Bg_Fu_Mizu_InitVars = { ACTOR_BG_FU_MIZU, ACTORCAT_BG, FLAGS, @@ -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..d17f64638 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,11 +6,9 @@ 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 -extern const ActorInit Bg_Fu_Mizu_InitVars; - #endif // Z_BG_FU_MIZU_H diff --git a/src/overlays/actors/ovl_Bg_Goron_Oyu/overlay.cfg b/src/overlays/actors/ovl_Bg_Goron_Oyu/overlay.cfg deleted file mode 100644 index cd6286ed1..000000000 --- a/src/overlays/actors/ovl_Bg_Goron_Oyu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Goron_Oyu -z_bg_goron_oyu.c 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..cfd9003ec 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,19 +11,19 @@ #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 = { +ActorInit Bg_Goron_Oyu_InitVars = { ACTOR_BG_GORON_OYU, ACTORCAT_BG, FLAGS, @@ -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/overlay.cfg b/src/overlays/actors/ovl_Bg_Haka_Bombwall/overlay.cfg deleted file mode 100644 index dd9b391ee..000000000 --- a/src/overlays/actors/ovl_Bg_Haka_Bombwall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Haka_Bombwall -z_bg_haka_bombwall.c 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..331a6dfe5 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,18 +5,26 @@ */ #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); -#if 0 -const ActorInit Bg_Haka_Bombwall_InitVars = { +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); + +ActorInit Bg_Haka_Bombwall_InitVars = { ACTOR_BG_HAKA_BOMBWALL, ACTORCAT_BG, FLAGS, @@ -28,50 +36,198 @@ 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 sRockScales[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), }; -#endif +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; +} -extern ColliderCylinderInit D_80BD64A0; -extern InitChainEntry D_80BD64D4[]; +void func_80BD5E6C(BgHakaBombwall* this, PlayState* play) { + u32 i; + Vec3f pos; + Vec3f vel; + Vec3f posOffset; + Vec3f velOffset; + f32 offsetPosX; + f32 offsetPosY; + s16 scale; + s16 phi_s0; + s16 phi_t0; + s16 gravity; -extern UNK_TYPE D_06000040; -extern UNK_TYPE D_06000148; -extern UNK_TYPE D_06001680; + Matrix_Push(); + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD5E00.s") + offsetPosX = 0.0f; + offsetPosY = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD5E6C.s") + for (i = 0; i < 30; i++) { + offsetPosX += 60.0f + (Rand_ZeroOne() * 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Init.s") + if (offsetPosX > 75.0f) { + offsetPosX -= 150.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Destroy.s") + offsetPosY += 5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6260.s") + posOffset.x = offsetPosX; + posOffset.y = offsetPosY; + posOffset.z = (Rand_ZeroOne() * 20.0f) - 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6274.s") + velOffset.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (offsetPosX * (4.0f / 75.0f)); + velOffset.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + velOffset.z = (Rand_ZeroOne() * 4.0f) - 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD62D0.s") + Matrix_MultVec3f(&posOffset, &pos); + Matrix_MultVec3f(&velOffset, &vel); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD6314.s") + pos.x += this->dyna.actor.world.pos.x; + pos.y += this->dyna.actor.world.pos.y; + pos.z += this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD63B4.s") + //! FAKE + if (1) {} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/func_80BD63D0.s") + if ((i & 3) == 0) { + phi_s0 = 32; + func_800BBFB0(play, &pos, 60.0f, 2, 100, 120, 1); + } else { + phi_s0 = 64; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Update.s") + if ((i % 2) != 0) { + phi_s0 |= 1; + phi_t0 = 1; + } else { + phi_t0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Haka_Bombwall/BgHakaBombwall_Draw.s") + scale = sRockScales[i & (ARRAY_COUNT(sRockScales) - 1)]; + + //! FAKE + fake_label:; + + if (scale >= 16) { + gravity = -550; + } else { + gravity = -450; + } + + EffectSsKakera_Spawn(play, &pos, &vel, &pos, gravity, phi_s0, 30, 0, 0, scale, phi_t0, 0, 50, -1, + OBJECT_HAKA_OBJ, object_haka_obj_DL_001680); + } + + Matrix_Pop(); +} + +void BgHakaBombwall_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgHakaBombwall* this = THIS; + + 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_Kill(&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); + } +} + +void BgHakaBombwall_Destroy(Actor* thisx, PlayState* play) { + BgHakaBombwall* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(play, &this->collider); +} + +void func_80BD6260(BgHakaBombwall* this) { + this->actionFunc = func_80BD6274; +} + +void func_80BD6274(BgHakaBombwall* this, PlayState* play) { + if (func_80BD5E00(this)) { + BgHakaBombwall_SetupPlayCutscene(this); + } else { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} + +void BgHakaBombwall_SetupPlayCutscene(BgHakaBombwall* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + this->actionFunc = BgHakaBombwall_PlayCutscene; +} + +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); + } +} + +void BgHakaBombwall_SetupEndCutscene(BgHakaBombwall* this) { + this->csTimer = 30; + this->actionFunc = BgHakaBombwall_EndCutscene; +} + +void BgHakaBombwall_EndCutscene(BgHakaBombwall* this, PlayState* play) { + this->csTimer--; + if (this->csTimer <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_Kill(&this->dyna.actor); + } +} + +void BgHakaBombwall_Update(Actor* thisx, PlayState* play) { + BgHakaBombwall* this = THIS; + + this->actionFunc(this, play); +} + +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..9e5bd1c43 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,17 +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; - #endif // Z_BG_HAKA_BOMBWALL_H diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/overlay.cfg b/src/overlays/actors/ovl_Bg_Haka_Curtain/overlay.cfg deleted file mode 100644 index eba48c872..000000000 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Haka_Curtain -z_bg_haka_curtain.c 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..412ea3a39 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,22 +11,22 @@ #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 = { +ActorInit Bg_Haka_Curtain_InitVars = { ACTOR_BG_HAKA_CURTAIN, ACTORCAT_BG, FLAGS, @@ -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..ab5ec0e89 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,13 +5,11 @@ struct BgHakaCurtain; -typedef void (*BgHakaCurtainActionFunc)(struct BgHakaCurtain*, GlobalContext*); +typedef void (*BgHakaCurtainActionFunc)(struct BgHakaCurtain*, PlayState*); typedef struct BgHakaCurtain { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgHakaCurtainActionFunc actionFunc; } BgHakaCurtain; // size = 0x160 -extern const ActorInit Bg_Haka_Curtain_InitVars; - #endif // Z_BG_HAKA_CURTAIN_H diff --git a/src/overlays/actors/ovl_Bg_Haka_Tomb/overlay.cfg b/src/overlays/actors/ovl_Bg_Haka_Tomb/overlay.cfg deleted file mode 100644 index 3e83b3fb6..000000000 --- a/src/overlays/actors/ovl_Bg_Haka_Tomb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Haka_Tomb -z_bg_haka_tomb.c 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 6985878fe..a8d63c309 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,19 +11,19 @@ #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 = { +ActorInit Bg_Haka_Tomb_InitVars = { ACTOR_BG_HAKA_TOMB, ACTORCAT_BG, FLAGS, @@ -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,15 +109,15 @@ 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); + 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); @@ -125,6 +125,6 @@ void BgHakaTomb_Update(Actor* thisx, GlobalContext* globalCtx) { 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..3c607e0e2 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; @@ -13,6 +13,4 @@ typedef struct BgHakaTomb { /* 0x160 */ s16 cutscenes[1]; } BgHakaTomb; // size = 0x164 -extern const ActorInit Bg_Haka_Tomb_InitVars; - #endif // Z_BG_HAKA_TOMB_H diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/overlay.cfg b/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/overlay.cfg deleted file mode 100644 index 9b4288e95..000000000 --- a/src/overlays/actors/ovl_Bg_Hakugin_Bombwall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Hakugin_Bombwall -z_bg_hakugin_bombwall.c 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 20d68e7a4..bde3c8540 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,22 +11,22 @@ #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 = { +ActorInit Bg_Hakugin_Bombwall_InitVars = { ACTOR_BG_HAKUGIN_BOMBWALL, ACTORCAT_BG, FLAGS, @@ -121,7 +121,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { +void func_80ABBFC0(BgHakuginBombwall* this, PlayState* play) { f32 temp; Vec3f spF0; Vec3f spE4; @@ -138,7 +138,7 @@ void func_80ABBFC0(BgHakuginBombwall* this, GlobalContext* globalCtx) { for (i = 0; i < 6; i++) { temp = (i + 1) * (80.0f / 3.0f); for (j = 0; j < ARRAY_COUNT(D_80ABD020); j++) { - spD8.x = D_80ABD020[j] + (s32)((u32)Rand_Next() >> 0x1C); + 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; @@ -159,23 +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); } } } -void func_80ABC2E0(BgHakuginBombwall* this, GlobalContext* globalCtx) { +void func_80ABC2E0(BgHakuginBombwall* this, PlayState* play) { s32 pad; s32 i; s16 phi_s2; @@ -219,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; @@ -269,12 +268,12 @@ void func_80ABC58C(BgHakuginBombwall* this, GlobalContext* globalCtx) { 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; @@ -303,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))) { - Actor_MarkForDeath(&this->dyna.actor); + if (Flags_GetSwitch(play, BGHAKUGIN_BOMBWALL_SWITCHFLAG(&this->dyna.actor))) { + Actor_Kill(&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; @@ -336,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; } } @@ -359,78 +357,75 @@ 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--; if (this->unk_1AC <= 0) { ActorCutscene_Stop(this->dyna.actor.cutscene); - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&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..24b04139e 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) @@ -19,6 +19,4 @@ typedef struct BgHakuginBombwall { /* 0x1AC */ s32 unk_1AC; } BgHakuginBombwall; // size = 0x1B0 -extern const ActorInit Bg_Hakugin_Bombwall_InitVars; - #endif // Z_BG_HAKUGIN_BOMBWALL_H diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/overlay.cfg b/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/overlay.cfg deleted file mode 100644 index cc7d95cdc..000000000 --- a/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Hakugin_Elvpole -z_bg_hakugin_elvpole.c 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..0b8d2490b 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,20 +5,20 @@ */ #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 = { +ActorInit Bg_Hakugin_Elvpole_InitVars = { ACTOR_BG_HAKUGIN_ELVPOLE, ACTORCAT_BG, FLAGS, @@ -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..ace71e7b3 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,14 +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; - #endif // Z_BG_HAKUGIN_ELVPOLE_H diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/overlay.cfg b/src/overlays/actors/ovl_Bg_Hakugin_Post/overlay.cfg deleted file mode 100644 index fc47ccb4f..000000000 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Hakugin_Post -z_bg_hakugin_post.c 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 a7f20b7b4..7f77b6645 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,39 +6,40 @@ #include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" +#include "z64quake.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; -const ActorInit Bg_Hakugin_Post_InitVars = { +ActorInit Bg_Hakugin_Post_InitVars = { ACTOR_BG_HAKUGIN_POST, ACTORCAT_BG, FLAGS, @@ -96,7 +97,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 +106,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 +115,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 +132,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 +157,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 +175,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 +184,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); } } } @@ -237,27 +238,27 @@ void func_80A9B384(Vec3f* arg0) { 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 +267,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 +344,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 +359,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 +387,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 +425,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 +491,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,12 +505,12 @@ 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; s32 pad2[2]; - s16 quake; + s16 quakeIndex; if (this->unk_170 == 0) { for (i = 0; i < unkStruct->count; i++) { @@ -519,11 +520,13 @@ 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); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 7, 0, 0, 0); - Quake_SetCountdown(quake, 12); + Rumble_Request(Math3D_Vec3fDistSq(&sp44, &GET_PLAYER(play)->actor.world.pos), 255, 20, 150); + + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 12); + if (this->unk_179 <= 0) { func_8019F128(NA_SE_EV_STONEDOOR_STOP); this->unk_179 = 40; @@ -534,22 +537,23 @@ 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); - s16 quake; + Player* player = GET_PLAYER(play); + Camera* activeCam = GET_ACTIVE_CAM(play); + s16 quakeIndex; - 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); - quake = Quake_Add(activeCam, 3); - Quake_SetSpeed(quake, 17232); - Quake_SetQuakeValues(quake, 6, 0, 0, 0); - Quake_SetCountdown(quake, 20); + 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); + + quakeIndex = Quake_Add(activeCam, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 6, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 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 +589,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 +614,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 +649,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 +662,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 +681,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 +704,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); - Actor_MarkForDeath(&this->dyna.actor); + func_80A9AFB4(this, play, &D_80A9E028); + Actor_Kill(&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 +726,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 +766,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 +780,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 +791,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 +811,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 +841,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 +858,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 +866,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 +897,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 +921,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 +942,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 +951,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 +979,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 +990,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,9 +1010,9 @@ 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); + 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); @@ -1022,8 +1025,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]); } } @@ -1036,12 +1038,12 @@ void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { &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..5a23fa070 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,28 +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; - #endif // Z_BG_HAKUGIN_POST_H diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Switch/overlay.cfg b/src/overlays/actors/ovl_Bg_Hakugin_Switch/overlay.cfg deleted file mode 100644 index 3887196c7..000000000 --- a/src/overlays/actors/ovl_Bg_Hakugin_Switch/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Hakugin_Switch -z_bg_hakugin_switch.c 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..aa22dd8af 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,39 +5,40 @@ */ #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; -const ActorInit Bg_Hakugin_Switch_InitVars = { +ActorInit Bg_Hakugin_Switch_InitVars = { ACTOR_BG_HAKUGIN_SWITCH, ACTORCAT_SWITCH, FLAGS, @@ -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..164220b29 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,23 +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; - #endif // Z_BG_HAKUGIN_SWITCH_H diff --git a/src/overlays/actors/ovl_Bg_Icefloe/overlay.cfg b/src/overlays/actors/ovl_Bg_Icefloe/overlay.cfg deleted file mode 100644 index f8da71e62..000000000 --- a/src/overlays/actors/ovl_Bg_Icefloe/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Icefloe -z_bg_icefloe.c 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..265490e52 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.c @@ -5,18 +5,25 @@ */ #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); -#if 0 -const ActorInit Bg_Icefloe_InitVars = { +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); + +ActorInit Bg_Icefloe_InitVars = { ACTOR_BG_ICEFLOE, ACTORCAT_BG, FLAGS, @@ -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_Kill(&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..0278089cf 100644 --- a/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h +++ b/src/overlays/actors/ovl_Bg_Icefloe/z_bg_icefloe.h @@ -5,15 +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; - #endif // Z_BG_ICEFLOE_H diff --git a/src/overlays/actors/ovl_Bg_Icicle/overlay.cfg b/src/overlays/actors/ovl_Bg_Icicle/overlay.cfg deleted file mode 100644 index 88c4deec0..000000000 --- a/src/overlays/actors/ovl_Bg_Icicle/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Icicle -z_bg_icicle.c 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..743213652 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 = { { @@ -42,7 +42,7 @@ static ColliderCylinderInit sCylinderInit = { { 13, 120, 0, { 0, 0, 0 } }, }; -const ActorInit Bg_Icicle_InitVars = { +ActorInit Bg_Icicle_InitVars = { ACTOR_BG_ICICLE, ACTORCAT_PROP, FLAGS, @@ -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,77 +171,76 @@ 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); - return; + Actor_Kill(&this->dyna.actor); } } 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); + Actor_Kill(&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..b8f432458 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, @@ -23,6 +23,4 @@ typedef struct BgIcicle { /* 0x164 */ ColliderCylinder collider; } BgIcicle; // size = 0x1B0 -extern const ActorInit Bg_Icicle_InitVars; - #endif // Z_BG_ICICLE_H diff --git a/src/overlays/actors/ovl_Bg_Ikana_Block/overlay.cfg b/src/overlays/actors/ovl_Bg_Ikana_Block/overlay.cfg deleted file mode 100644 index af448437b..000000000 --- a/src/overlays/actors/ovl_Bg_Ikana_Block/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ikana_Block -z_bg_ikana_block.c 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 b7ebb4f40..9d249314a 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 @@ -11,21 +11,21 @@ #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_80B7F00C(BgIkanaBlock* this); -void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F034(BgIkanaBlock* this, PlayState* play); void func_80B7F0A4(BgIkanaBlock* this); -void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F0D0(BgIkanaBlock* this, PlayState* play); void func_80B7F1A8(BgIkanaBlock* this); -void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx); +void func_80B7F290(BgIkanaBlock* this, PlayState* play); void func_80B7F360(BgIkanaBlock* this); -void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx); -void func_80B7F564(Actor* thisx, GlobalContext* globalCtx); +void func_80B7F398(BgIkanaBlock* this, PlayState* play); +void func_80B7F564(Actor* thisx, PlayState* play); -const ActorInit Bg_Ikana_Block_InitVars = { +ActorInit Bg_Ikana_Block_InitVars = { ACTOR_BG_IKANA_BLOCK, ACTORCAT_BG, FLAGS, @@ -78,15 +78,15 @@ void func_80B7EB30(BgIkanaBlock* this) { } } -s32 func_80B7EB64(BgIkanaBlock* this, GlobalContext* globalCtx) { +s32 func_80B7EB64(BgIkanaBlock* this, PlayState* play) { return !(this->unk_17C & 8); } -s32 func_80B7EB7C(BgIkanaBlock* this, GlobalContext* globalCtx) { +s32 func_80B7EB7C(BgIkanaBlock* this, PlayState* play) { return this->unk_17B > 10; } -s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { +s32 func_80B7EB94(BgIkanaBlock* this, PlayState* play) { s32 pad; Vec3f sp70; Vec3f sp64; @@ -125,12 +125,12 @@ s32 func_80B7EB94(BgIkanaBlock* this, GlobalContext* globalCtx) { sp64.y += this->dyna.actor.world.pos.y + this->unk_170 + 2.0f; sp64.z += this->dyna.actor.world.pos.z; - return !BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp70, &sp64, &sp58, &sp54, true, false, false, true, &sp50, + return !BgCheck_EntityLineTest3(&play->colCtx, &sp70, &sp64, &sp58, &sp54, true, false, false, true, &sp50, &this->dyna.actor, 0.0f); } -s32 func_80B7ECFC(BgIkanaBlock* this, GlobalContext* globalCtx) { - return func_80B7EB64(this, globalCtx) && func_80B7EB7C(this, globalCtx) && func_80B7EB94(this, globalCtx); +s32 func_80B7ECFC(BgIkanaBlock* this, PlayState* play) { + return func_80B7EB64(this, play) && func_80B7EB7C(this, play) && func_80B7EB94(this, play); } void func_80B7ED54(BgIkanaBlock* this) { @@ -144,7 +144,7 @@ void func_80B7ED54(BgIkanaBlock* this) { this->unk_170 = sp18.y - 30.0f; } -s32 func_80B7EDC4(BgIkanaBlock* this, GlobalContext* globalCtx) { +s32 func_80B7EDC4(BgIkanaBlock* this, PlayState* play) { s32 pad; Vec3f sp30; s32 sp2C; @@ -153,26 +153,26 @@ s32 func_80B7EDC4(BgIkanaBlock* this, GlobalContext* globalCtx) { sp30.y = this->dyna.actor.world.pos.y + this->unk_170 + 40.0f; sp30.z = this->dyna.actor.world.pos.z; - this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5_2( - globalCtx, &globalCtx->colCtx, &this->dyna.actor.floorPoly, &sp2C, &this->dyna.actor, &sp30); + this->dyna.actor.floorHeight = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &this->dyna.actor.floorPoly, + &sp2C, &this->dyna.actor, &sp30); this->dyna.actor.floorBgId = sp2C; return ((this->dyna.actor.world.pos.y + this->unk_170) - this->dyna.actor.floorHeight) < 2.0f; } -s32 func_80B7EE70(BgIkanaBlock* this, GlobalContext* globalCtx) { - if (func_80B7EDC4(this, globalCtx)) { +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, GlobalContext* globalCtx) { - func_80B7EDC4(this, globalCtx); +s32 func_80B7EEB4(BgIkanaBlock* this, PlayState* play) { + func_80B7EDC4(this, play); if (this->dyna.actor.floorHeight > (BGCHECK_Y_MIN + 1.0f)) { - if (DynaPoly_GetActor(&globalCtx->colCtx, this->dyna.actor.floorBgId)) { + if (DynaPoly_GetActor(&play->colCtx, this->dyna.actor.floorBgId)) { this->dyna.actor.world.pos.y = this->dyna.actor.floorHeight - this->unk_170; return true; } @@ -180,23 +180,23 @@ s32 func_80B7EEB4(BgIkanaBlock* this, GlobalContext* globalCtx) { return false; } -void BgIkanaBlock_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaBlock_Init(Actor* thisx, PlayState* play) { BgIkanaBlock* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + 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, GlobalContext* globalCtx) { +void BgIkanaBlock_Destroy(Actor* thisx, PlayState* play) { BgIkanaBlock* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80B7F00C(BgIkanaBlock* this) { @@ -205,13 +205,13 @@ void func_80B7F00C(BgIkanaBlock* this) { this->actionFunc = func_80B7F034; } -void func_80B7F034(BgIkanaBlock* this, GlobalContext* globalCtx) { +void func_80B7F034(BgIkanaBlock* this, PlayState* play) { if (this->unk_17D > 0) { this->unk_17D--; } - if (func_80B7EEB4(this, globalCtx)) { - func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (func_80B7EEB4(this, play)) { + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); this->dyna.actor.draw = func_80B7F564; func_80B7F0A4(this); } @@ -224,7 +224,7 @@ void func_80B7F0A4(BgIkanaBlock* this) { this->actionFunc = func_80B7F0D0; } -void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx) { +void func_80B7F0D0(BgIkanaBlock* this, PlayState* play) { s32 sp24 = 0; s32 phi_v1; @@ -233,14 +233,14 @@ void func_80B7F0D0(BgIkanaBlock* this, GlobalContext* globalCtx) { if (this->unk_17C & 4) { sp24 = 1; - } else if (func_80B7ECFC(this, globalCtx)) { + } else if (func_80B7ECFC(this, play)) { sp24 = 2; } if ((sp24 != 2) && (this->unk_17A & (0x8 | 0x4 | 0x2 | 0x1))) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } @@ -285,22 +285,22 @@ void func_80B7F1A8(BgIkanaBlock* this) { this->actionFunc = func_80B7F290; } -void func_80B7F290(BgIkanaBlock* this, GlobalContext* globalCtx) { +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(globalCtx); + Player* player = GET_PLAYER(play); - if (!func_80B7EB94(this, globalCtx)) { + if (!func_80B7EB94(this, play)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; - if (func_80B7EDC4(this, globalCtx)) { + if (func_80B7EDC4(this, play)) { func_80B7F0A4(this); } else { func_80B7F360(this); @@ -318,7 +318,7 @@ void func_80B7F360(BgIkanaBlock* this) { this->actionFunc = func_80B7F398; } -void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx) { +void func_80B7F398(BgIkanaBlock* this, PlayState* play) { if (this->unk_17D > 0) { this->unk_17D--; return; @@ -333,16 +333,16 @@ void func_80B7F398(BgIkanaBlock* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; - if (func_80B7EE70(this, globalCtx)) { + if (func_80B7EE70(this, play)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - Actor_PlaySfxAtPos( - &this->dyna.actor, - SurfaceType_GetSfx(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + SFX_FLAG); + 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, GlobalContext* globalCtx) { +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) || @@ -351,7 +351,7 @@ void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx) { func_80B7ED54(this); } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_SetFocus(&this->dyna.actor, 30.0f); @@ -369,18 +369,18 @@ void BgIkanaBlock_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void func_80B7F564(Actor* thisx, GlobalContext* globalCtx) { +void func_80B7F564(Actor* thisx, PlayState* play) { s32 pad; BgIkanaBlock* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - AnimatedMat_DrawStep(globalCtx, this->unk_15C, 0); + func_8012C28C(play->state.gfxCtx); + AnimatedMat_DrawStep(play, this->unk_15C, 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, 255, 255, 255, 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_Bg_Ikana_Block/z_bg_ikana_block.h b/src/overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h index 3ad797cba..416a1c2dc 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,25 +5,23 @@ struct BgIkanaBlock; -typedef void (*BgIkanaBlockActionFunc)(struct BgIkanaBlock*, GlobalContext*); +typedef void (*BgIkanaBlockActionFunc)(struct BgIkanaBlock*, PlayState*); typedef struct BgIkanaBlock { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ AnimatedMaterial* unk_15C; - /* 0x0160 */ BgIkanaBlockActionFunc actionFunc; - /* 0x0164 */ f32* unk_164; - /* 0x0168 */ f32 unk_168; - /* 0x016C */ f32 unk_16C; - /* 0x0170 */ f32 unk_170; - /* 0x0174 */ Vec3s unk_174; - /* 0x017A */ u8 unk_17A; - /* 0x017B */ s8 unk_17B; - /* 0x017C */ u8 unk_17C; - /* 0x017D */ s8 unk_17D; - /* 0x017E */ s8 unk_17E; - /* 0x017F */ s8 unk_17F; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ AnimatedMaterial* unk_15C; + /* 0x160 */ BgIkanaBlockActionFunc actionFunc; + /* 0x164 */ f32* unk_164; + /* 0x168 */ f32 unk_168; + /* 0x16C */ f32 unk_16C; + /* 0x170 */ f32 unk_170; + /* 0x174 */ Vec3s unk_174; + /* 0x17A */ u8 unk_17A; + /* 0x17B */ s8 unk_17B; + /* 0x17C */ u8 unk_17C; + /* 0x17D */ s8 unk_17D; + /* 0x17E */ s8 unk_17E; + /* 0x17F */ s8 unk_17F; } BgIkanaBlock; // size = 0x180 -extern const ActorInit Bg_Ikana_Block_InitVars; - #endif // Z_BG_IKANA_BLOCK_H diff --git a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/overlay.cfg b/src/overlays/actors/ovl_Bg_Ikana_Bombwall/overlay.cfg deleted file mode 100644 index 4888c9532..000000000 --- a/src/overlays/actors/ovl_Bg_Ikana_Bombwall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ikana_Bombwall -z_bg_ikana_bombwall.c 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 bc08c9451..04f7f514b 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 @@ -11,21 +11,21 @@ #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, GlobalContext* globalCtx); +void func_80BD4F2C(BgIkanaBombwall* this, PlayState* play); void func_80BD4F88(BgIkanaBombwall* this); -void func_80BD4F9C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD4F9C(BgIkanaBombwall* this, PlayState* play); void func_80BD4FF8(BgIkanaBombwall* this); -void func_80BD503C(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD503C(BgIkanaBombwall* this, PlayState* play); void func_80BD5118(BgIkanaBombwall* this); -void func_80BD5134(BgIkanaBombwall* this, GlobalContext* globalCtx); +void func_80BD5134(BgIkanaBombwall* this, PlayState* play); -const ActorInit Bg_Ikana_Bombwall_InitVars = { +ActorInit Bg_Ikana_Bombwall_InitVars = { ACTOR_BG_IKANA_BOMBWALL, ACTORCAT_BG, FLAGS, @@ -96,50 +96,53 @@ Gfx* D_80BD52E0[] = { object_ikana_obj_DL_000048, }; -#ifdef NON_MATCHING -void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { +void func_80BD4720(BgIkanaBombwall* this, PlayState* play) { s32 i; - Vec3f spE0; - Vec3f spD4; - Vec3f spC8; - Vec3f spBC; - f32 temp_fs0; - f32 phi_fs1; + Vec3f pos; + Vec3f vel; + Vec3f posOffset; + Vec3f velOffset; + f32 offsetPosX; + f32 offsetPosY; + s16 scale; s16 phi_s0; - s16 temp; s16 phi_t0; + s16 gravity; Matrix_Push(); Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); - temp_fs0 = 0.0f; - phi_fs1 = 0.0f; + offsetPosX = 0.0f; + offsetPosY = 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; + offsetPosX += 60.0f + (Rand_ZeroOne() * 20.0f); + if (offsetPosX > 75.0f) { + offsetPosX -= 150.0f; } - spC8.x = temp_fs0; - phi_fs1 += 5; - spC8.y = phi_fs1; + offsetPosY += 5; - spC8.z = (Rand_ZeroOne() * 20.0f) - 10.0f; + posOffset.x = offsetPosX; + posOffset.y = offsetPosY; + posOffset.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; + velOffset.x = ((Rand_ZeroOne() - 0.5f) * 5.0f) + (offsetPosX * (4.0f / 75.0f)); + velOffset.y = (Rand_ZeroOne() * 7.0f) - 2.0f; + velOffset.z = (Rand_ZeroOne() * 4.0f) - 2.0f; - Matrix_MultVec3f(&spC8, &spE0); - Matrix_MultVec3f(&spBC, &spD4); + Matrix_MultVec3f(&posOffset, &pos); + Matrix_MultVec3f(&velOffset, &vel); - spE0.x += this->dyna.actor.world.pos.x; - spE0.y += this->dyna.actor.world.pos.y; - spE0.z += this->dyna.actor.world.pos.z; + pos.x += this->dyna.actor.world.pos.x; + pos.y += this->dyna.actor.world.pos.y; + pos.z += this->dyna.actor.world.pos.z; + + //! FAKE + if (1) {} if ((i & 3) == 0) { phi_s0 = 32; - func_800BBFB0(globalCtx, &spE0, 50.0f, 2, 100, 120, 1); + func_800BBFB0(play, &pos, 50.0f, 2, 100, 120, 1); } else { phi_s0 = 64; } @@ -151,56 +154,57 @@ void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx) { phi_t0 = 0; } - if (D_80BD52C8[i & 3] >= 16) { - temp = -550; + scale = D_80BD52C8[i & (ARRAY_COUNT(D_80BD52C8) - 1)]; + + //! FAKE + fake_label:; + + if (scale >= 16) { + gravity = -550; } else { - temp = -450; + gravity = -450; } - EffectSsKakera_Spawn(globalCtx, &spE0, &spD4, &spE0, temp, phi_s0, 30, 0, 0, D_80BD52C8[i & 3], phi_t0, 0, 50, - -1, OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); + EffectSsKakera_Spawn(play, &pos, &vel, &pos, gravity, phi_s0, 30, 0, 0, scale, phi_t0, 0, 50, -1, + OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); } Matrix_Pop(); } -#else -void func_80BD4720(BgIkanaBombwall* this, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Ikana_Bombwall/func_80BD4720.s") -#endif -void func_80BD4A14(BgIkanaBombwall* this, GlobalContext* globalCtx) { +void func_80BD4A14(BgIkanaBombwall* this, PlayState* play) { s32 i; - Vec3f spD8; - Vec3f spCC; + Vec3f pos; + Vec3f vel; f32 temp_fs0; f32 temp_fs1; f32 temp_fs3; - s16 temp_v1; - s16 phi_s2; - s32 phi_t0; + s16 scale; + s16 angle; + s32 gravity; s16 phi_v0; s32 phi_v1; temp_fs3 = 0.0f; - for (i = 0, phi_s2 = 0; i < 28; i++, phi_s2 += 0x924) { + for (i = 0, angle = 0; i < 28; i++, angle += 0x924) { temp_fs3 += 20.0f + (Rand_ZeroOne() * 10.0f); if (temp_fs3 > 60.0f) { temp_fs3 -= 60.0f; } - temp_fs0 = Math_SinS(phi_s2); - temp_fs1 = Math_CosS(phi_s2); + temp_fs0 = Math_SinS(angle); + temp_fs1 = Math_CosS(angle); - 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; + pos.x = (temp_fs0 * temp_fs3) + this->dyna.actor.world.pos.x; + pos.y = this->dyna.actor.world.pos.y; + pos.z = (temp_fs1 * temp_fs3) + this->dyna.actor.world.pos.z; - 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); + vel.x = ((Rand_ZeroOne() - 0.5f) * 3.0f * temp_fs0) + ((temp_fs0 * temp_fs3) * (1.0f / 30.0f)); + vel.y = (Rand_ZeroOne() * 18.0f) + 4.0f; + vel.z = ((Rand_ZeroOne() - 0.5f) * 3.0f * temp_fs1) + ((temp_fs1 * temp_fs3) * (1.0f / 30.0f)); - temp_v1 = (Rand_Next() & 3) + (i >> 1) + 6; + scale = (Rand_Next() & 3) + (i >> 1) + 6; if ((i & 3) == 0) { phi_v0 = 32; @@ -208,51 +212,51 @@ void func_80BD4A14(BgIkanaBombwall* this, GlobalContext* globalCtx) { phi_v0 = 64; } - if (temp_v1 >= 15) { + if (scale >= 15) { phi_v0 |= 1; phi_v1 = 1; - phi_t0 = -550; + gravity = -550; } else { phi_v1 = 0; - phi_t0 = -400; + gravity = -400; } - EffectSsKakera_Spawn(globalCtx, &spD8, &spCC, &spD8, phi_t0, phi_v0, 30, 0, 0, temp_v1, phi_v1, 0, 50, -1, + EffectSsKakera_Spawn(play, &pos, &vel, &pos, gravity, phi_v0, 30, 0, 0, scale, phi_v1, 0, 50, -1, OBJECT_IKANA_OBJ, object_ikana_obj_DL_000288); if ((i & 3) == 0) { - spD8.y += 30.0f; - func_800BBFB0(globalCtx, &spD8, 50.0f, 2, 70, 110, 1); + pos.y += 30.0f; + func_800BBFB0(play, &pos, 50.0f, 2, 70, 110, 1); } } } -void BgIkanaBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaBombwall_Init(Actor* thisx, PlayState* play) { s32 pad; BgIkanaBombwall* this = THIS; s32 sp2C = BGIKANABOMBWALL_GET_100(&this->dyna.actor); - s32 sp28; - s32 sp24; + CollisionHeader* colHeader; + ColliderCylinderInit* cylinderInit; 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, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor))) { - Actor_MarkForDeath(&this->dyna.actor); + if (Flags_GetSwitch(play, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor))) { + Actor_Kill(&this->dyna.actor); return; } if (sp2C == 0) { - sp28 = &object_ikana_obj_Colheader_000488; - sp24 = &sCylinderInit1; + colHeader = &object_ikana_obj_Colheader_000488; + cylinderInit = &sCylinderInit1; } else { - sp28 = &object_ikana_obj_Colheader_000128; - sp24 = &sCylinderInit2; + colHeader = &object_ikana_obj_Colheader_000128; + cylinderInit = &sCylinderInit2; } - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, sp28); - Collider_SetCylinder(globalCtx, &this->collider, &this->dyna.actor, sp24); + DynaPolyActor_LoadMesh(play, &this->dyna, colHeader); + Collider_SetCylinder(play, &this->collider, &this->dyna.actor, cylinderInit); Collider_UpdateCylinder(&this->dyna.actor, &this->collider); if (sp2C == 0) { @@ -262,11 +266,11 @@ void BgIkanaBombwall_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void BgIkanaBombwall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaBombwall_Destroy(Actor* thisx, PlayState* play) { BgIkanaBombwall* 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_80BD4E44(BgIkanaBombwall* this) { @@ -293,11 +297,11 @@ void func_80BD4F18(BgIkanaBombwall* this) { this->actionFunc = func_80BD4F2C; } -void func_80BD4F2C(BgIkanaBombwall* this, GlobalContext* globalCtx) { +void func_80BD4F2C(BgIkanaBombwall* this, PlayState* play) { if (func_80BD4E44(this)) { func_80BD4FF8(this); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -305,11 +309,11 @@ void func_80BD4F88(BgIkanaBombwall* this) { this->actionFunc = func_80BD4F9C; } -void func_80BD4F9C(BgIkanaBombwall* this, GlobalContext* globalCtx) { +void func_80BD4F9C(BgIkanaBombwall* this, PlayState* play) { if (func_80BD4EAC(this)) { func_80BD4FF8(this); } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } @@ -319,19 +323,19 @@ void func_80BD4FF8(BgIkanaBombwall* this) { this->actionFunc = func_80BD503C; } -void func_80BD503C(BgIkanaBombwall* this, GlobalContext* globalCtx) { +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, globalCtx); + func_80BD4720(this, play); } else { - func_80BD4A14(this, globalCtx); + func_80BD4A14(this, play); } this->dyna.actor.draw = NULL; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->dyna.actor.world.pos, 60, NA_SE_EV_WALL_BROKEN); - Flags_SetSwitch(globalCtx, BGIKANABOMBWALL_GET_SWITCHFLAG(&this->dyna.actor)); + 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(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); } func_80BD5118(this); } else { @@ -344,28 +348,28 @@ void func_80BD5118(BgIkanaBombwall* this) { this->actionFunc = func_80BD5134; } -void func_80BD5134(BgIkanaBombwall* this, GlobalContext* globalCtx) { +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); + Actor_Kill(&this->dyna.actor); } } else if (this->dyna.actor.cutscene >= 0) { if (ActorCutscene_GetCurrentIndex() != this->dyna.actor.cutscene) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } } else { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } } -void BgIkanaBombwall_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaBombwall_Update(Actor* thisx, PlayState* play) { BgIkanaBombwall* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgIkanaBombwall_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, D_80BD52E0[BGIKANABOMBWALL_GET_100(thisx)]); +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 37921ba53..e9ff850ad 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,18 +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 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ BgIkanaBombwallActionFunc actionFunc; - /* 0x01AC */ s8 unk_1AC; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ BgIkanaBombwallActionFunc actionFunc; + /* 0x1AC */ s8 unk_1AC; } BgIkanaBombwall; // size = 0x1B0 -extern const ActorInit Bg_Ikana_Bombwall_InitVars; - #endif // Z_BG_IKANA_BOMBWALL_H diff --git a/src/overlays/actors/ovl_Bg_Ikana_Dharma/overlay.cfg b/src/overlays/actors/ovl_Bg_Ikana_Dharma/overlay.cfg deleted file mode 100644 index 13c58ba86..000000000 --- a/src/overlays/actors/ovl_Bg_Ikana_Dharma/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ikana_Dharma -z_bg_ikana_dharma.c 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..678080ae1 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,18 +5,26 @@ */ #include "z_bg_ikana_dharma.h" +#include "z64quake.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* play2); +void BgIkanaDharma_Destroy(Actor* thisx, PlayState* play); +void BgIkanaDharma_Update(Actor* thisx, PlayState* play); +void BgIkanaDharma_Draw(Actor* thisx, PlayState* play); -#if 0 -const ActorInit Bg_Ikana_Dharma_InitVars = { +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); + +ActorInit Bg_Ikana_Dharma_InitVars = { ACTOR_BG_IKANA_DHARMA, ACTORCAT_BG, FLAGS, @@ -28,47 +36,228 @@ 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)) { + Actor_Kill(&this->dyna.actor); + return; + } + + 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 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 21536); + Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 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..ac1bcadf0 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,17 +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; - #endif // Z_BG_IKANA_DHARMA_H diff --git a/src/overlays/actors/ovl_Bg_Ikana_Mirror/overlay.cfg b/src/overlays/actors/ovl_Bg_Ikana_Mirror/overlay.cfg deleted file mode 100644 index d735febc0..000000000 --- a/src/overlays/actors/ovl_Bg_Ikana_Mirror/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ikana_Mirror -z_bg_ikana_mirror.c 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..5fc28c5a5 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,21 +2,31 @@ * 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* play2); +void BgIkanaMirror_Destroy(Actor* thisx, PlayState* play); +void BgIkanaMirror_Update(Actor* thisx, PlayState* play); +void BgIkanaMirror_Draw(Actor* thisx, PlayState* play); -#if 0 -const ActorInit Bg_Ikana_Mirror_InitVars = { +void BgIkanaMirror_SetupWait(BgIkanaMirror* this); +void BgIkanaMirror_Wait(BgIkanaMirror* this, PlayState* play); +void BgIkanaMirror_SetupEmitLight(BgIkanaMirror* this); +void BgIkanaMirror_EmitLight(BgIkanaMirror* this, PlayState* play); + +ActorInit Bg_Ikana_Mirror_InitVars = { ACTOR_BG_IKANA_MIRROR, ACTORCAT_PROP, FLAGS, @@ -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/overlay.cfg b/src/overlays/actors/ovl_Bg_Ikana_Ray/overlay.cfg deleted file mode 100644 index b091b0a51..000000000 --- a/src/overlays/actors/ovl_Bg_Ikana_Ray/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ikana_Ray -z_bg_ikana_ray.c 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..6a08ba101 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,17 +11,17 @@ #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 = { +ActorInit Bg_Ikana_Ray_InitVars = { ACTOR_BG_IKANA_RAY, ACTORCAT_PROP, FLAGS, @@ -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..79d406fde 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) @@ -16,6 +16,4 @@ typedef struct BgIkanaRay { /* 0x194 */ BgIkanaRayActionFunc actionFunc; } BgIkanaRay; // size = 0x198 -extern const ActorInit Bg_Ikana_Ray_InitVars; - #endif // Z_BG_IKANA_RAY_H diff --git a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/overlay.cfg b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/overlay.cfg deleted file mode 100644 index c51c2a598..000000000 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ikana_Rotaryroom -z_bg_ikana_rotaryroom.c 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 d395fd6ee..27cecd05a 100644 --- a/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c +++ b/src/overlays/actors/ovl_Bg_Ikana_Rotaryroom/z_bg_ikana_rotaryroom.c @@ -5,34 +5,36 @@ */ #include "z_bg_ikana_rotaryroom.h" +#include "z64quake.h" #include "overlays/actors/ovl_Bg_Ikana_Block/z_bg_ikana_block.h" #include "overlays/actors/ovl_En_Torch2/z_en_torch2.h" +#include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" #include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #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 = { +ActorInit Bg_Ikana_Rotaryroom_InitVars = { ACTOR_BG_IKANA_ROTARYROOM, ACTORCAT_BG, FLAGS, @@ -78,7 +80,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -105,7 +107,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_NONE, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -160,14 +162,14 @@ 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_Push(); Matrix_SetTranslateRotateYXZ(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); - if (Flags_GetSwitch(globalCtx, BGIKANAROTARYROOM_GET_7F00(&this->dyna.actor))) { + 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_Translate(D_80B8216C.x, D_80B8216C.y, D_80B8216C.z, MTXMODE_APPLY); @@ -175,13 +177,13 @@ void func_80B80440(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { 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_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,13 +195,13 @@ 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; + 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; @@ -235,7 +237,7 @@ void func_80B80550(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { 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]; @@ -264,7 +266,7 @@ BgIkanaRotaryroomStruct4* func_80B80778(BgIkanaRotaryroom* this, GlobalContext* 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; @@ -293,10 +295,10 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { 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_Push(); @@ -317,7 +319,7 @@ 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))) { @@ -341,7 +343,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))) { @@ -363,7 +365,7 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { 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; @@ -381,7 +383,7 @@ void func_80B80894(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { 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; @@ -452,7 +454,7 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { } } - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); if (player != NULL) { Matrix_Push(); @@ -470,7 +472,7 @@ void func_80B80C88(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { Matrix_Pop(); } -s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { +s32 func_80B80F08(BgIkanaRotaryroom* this, PlayState* play) { s32 pad; BgIkanaBlock* ikanaBlock = (BgIkanaBlock*)this->unk_204.unk_00; Vec3f sp34; @@ -492,16 +494,16 @@ s32 func_80B80F08(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { 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 +540,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 +570,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; @@ -612,7 +614,7 @@ void func_80B81234(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { 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 +643,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_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->unk_92); - globalCtx->unk_18845 = 1; + func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->voiceSfxIdOffset); + func_80169EFC(&play->state); + func_800B8E58(player, NA_SE_VO_LI_TAKEN_AWAY + player->ageProperties->voiceSfxIdOffset); + play->unk_18845 = 1; play_sound(NA_SE_OC_ABYSS); this->actionFunc = NULL; } @@ -658,7 +660,7 @@ 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; @@ -679,7 +681,8 @@ void func_80B81570(BgIkanaRotaryroom* this, GlobalContext* globalCtx) { 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, + ENWATEREFFECT_TYPE_FALLING_ROCK_SPAWNER); } Matrix_Pop(); @@ -698,27 +701,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 +731,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 +773,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 +788,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, PLAYER_CSMODE_7); } func_80B81A64(this); } else { @@ -804,7 +807,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 +821,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,11 +832,11 @@ 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 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(sp26, 0x7B30); - Quake_SetQuakeValues(sp26, 6, 0, 100, 0); - Quake_SetCountdown(sp26, 22); + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, 6, 0, 100, 0); + Quake_SetCountdown(quakeIndex, 22); } } @@ -842,7 +845,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 +859,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 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quake, 0x7B30); - Quake_SetQuakeValues(quake, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); - Quake_SetCountdown(quake, 15); + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, (s32)(Rand_ZeroOne() * 2.5f) + 3, 0, 10, 0); + Quake_SetCountdown(quakeIndex, 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 +876,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 +916,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,15 +929,15 @@ 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 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quake, 0x4E20); - Quake_SetQuakeValues(quake, 5, 0, 40, 60); - Quake_SetCountdown(quake, 17); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 5, 0, 40, 60); + Quake_SetCountdown(quakeIndex, 17); } } -void BgIkanaRotaryroom_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgIkanaRotaryroom_Update(Actor* thisx, PlayState* play) { BgIkanaRotaryroom* this = THIS; BgIkanaRotaryroomStruct1* ptr; BgIkanaRotaryroomStruct1* ptr2; @@ -966,37 +969,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..4184220e0 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,22 +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; - #endif // Z_BG_IKANA_ROTARYROOM_H diff --git a/src/overlays/actors/ovl_Bg_Ikana_Shutter/overlay.cfg b/src/overlays/actors/ovl_Bg_Ikana_Shutter/overlay.cfg deleted file mode 100644 index e86cc272b..000000000 --- a/src/overlays/actors/ovl_Bg_Ikana_Shutter/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ikana_Shutter -z_bg_ikana_shutter.c 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..a7ba89cdc 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 @@ -5,37 +5,38 @@ */ #include "z_bg_ikana_shutter.h" +#include "z64quake.h" #include "objects/object_ikana_obj/object_ikana_obj.h" #define FLAGS (ACTOR_FLAG_10) #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 = { +ActorInit Bg_Ikana_Shutter_InitVars = { ACTOR_BG_IKANA_SHUTTER, ACTORCAT_SWITCH, FLAGS, @@ -54,38 +55,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 +94,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 +105,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 +119,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 +132,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,18 +143,19 @@ 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; + s16 quakeIndex; this->dyna.actor.velocity.y += -5.0f; 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_SetSpeed(quake, 0x5420); - Quake_SetQuakeValues(quake, 4, 0, 0, 0); - Quake_SetCountdown(quake, 12); + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 21536); + Quake_SetQuakeValues(quakeIndex, 4, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 12); + func_80BD5828(this); } } @@ -163,8 +165,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 +176,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 +190,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 +203,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..094334600 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,13 +5,11 @@ struct BgIkanaShutter; -typedef void (*BgIkanaShutterActionFunc)(struct BgIkanaShutter*, GlobalContext*); +typedef void (*BgIkanaShutterActionFunc)(struct BgIkanaShutter*, PlayState*); typedef struct BgIkanaShutter { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgIkanaShutterActionFunc actionFunc; } BgIkanaShutter; // size = 0x160 -extern const ActorInit Bg_Ikana_Shutter_InitVars; - #endif // Z_BG_IKANA_SHUTTER_H diff --git a/src/overlays/actors/ovl_Bg_Iknin_Susceil/overlay.cfg b/src/overlays/actors/ovl_Bg_Iknin_Susceil/overlay.cfg deleted file mode 100644 index e7df7599d..000000000 --- a/src/overlays/actors/ovl_Bg_Iknin_Susceil/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Iknin_Susceil -z_bg_iknin_susceil.c 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..f9a9fcc37 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,29 +5,31 @@ */ #include "z_bg_iknin_susceil.h" +#include "z64quake.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 = { +ActorInit Bg_Iknin_Susceil_InitVars = { ACTOR_BG_IKNIN_SUSCEIL, ACTORCAT_BG, FLAGS, @@ -49,45 +51,46 @@ 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 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 31536); + Quake_SetQuakeValues(quakeIndex, verticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); - 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 +111,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 +133,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 +149,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 +168,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 +178,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 +192,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 +210,26 @@ 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)) { + if ((this->unk168 == 0) && (this->unk166 > 0) && (player->stateFlags3 & PLAYER_STATE3_100) && + (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,11 +239,11 @@ 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; - } else if (player->stateFlags3 & 0x100) { + } else if (player->stateFlags3 & PLAYER_STATE3_100) { this->unk166 = 3; } else { if (this->unk166 > 0) { @@ -247,15 +251,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..2fa153ac0 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; @@ -19,6 +19,4 @@ typedef struct BgIkninSusceil { /* 0x16A */ UNK_TYPE2 unk16A; } BgIkninSusceil; // size = 0x16C -extern const ActorInit Bg_Iknin_Susceil_InitVars; - #endif // Z_BG_IKNIN_SUSCEIL_H diff --git a/src/overlays/actors/ovl_Bg_Ikninside/overlay.cfg b/src/overlays/actors/ovl_Bg_Ikninside/overlay.cfg deleted file mode 100644 index 43d45dac7..000000000 --- a/src/overlays/actors/ovl_Bg_Ikninside/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ikninside -z_bg_ikninside.c 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..6016b2e44 100644 --- a/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c +++ b/src/overlays/actors/ovl_Bg_Ikninside/z_bg_ikninside.c @@ -5,18 +5,20 @@ */ #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); -#if 0 -const ActorInit Bg_Ikninside_InitVars = { +void func_80C072D0(BgIkninside* this, PlayState* play); + +ActorInit Bg_Ikninside_InitVars = { ACTOR_BG_IKNINSIDE, ACTORCAT_BG, FLAGS, @@ -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_Kill(&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/overlay.cfg b/src/overlays/actors/ovl_Bg_Iknv_Doukutu/overlay.cfg deleted file mode 100644 index 0eca2bc55..000000000 --- a/src/overlays/actors/ovl_Bg_Iknv_Doukutu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Iknv_Doukutu -z_bg_iknv_doukutu.c 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..9cbfaec61 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,25 +5,29 @@ */ #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 = { +ActorInit Bg_Iknv_Doukutu_InitVars = { ACTOR_BG_IKNV_DOUKUTU, ACTORCAT_BG, FLAGS, @@ -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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { + Actor_Kill(&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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { + 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_Kill(&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..f36393869 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,14 +5,22 @@ 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 - -extern const ActorInit Bg_Iknv_Doukutu_InitVars; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 unk_15C; // set and not used + /* 0x15E */ u16 csAction; + /* 0x160 */ f32 unk_160; + /* 0x164 */ BgIknvDoukutuActionFunc actionFunc; +} BgIknvDoukutu;// size = 0x168 #endif // Z_BG_IKNV_DOUKUTU_H diff --git a/src/overlays/actors/ovl_Bg_Iknv_Obj/overlay.cfg b/src/overlays/actors/ovl_Bg_Iknv_Obj/overlay.cfg deleted file mode 100644 index 971c9f947..000000000 --- a/src/overlays/actors/ovl_Bg_Iknv_Obj/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Iknv_Obj -z_bg_iknv_obj.c 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..ba65baca4 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,17 +11,17 @@ #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 = { +ActorInit Bg_Iknv_Obj_InitVars = { ACTOR_BG_IKNV_OBJ, ACTORCAT_BG, FLAGS, @@ -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,30 +80,30 @@ 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; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_51_10); Actor_SetFocus(&this->dyna.actor, IREG(88)); break; default: - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } } -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); - gSaveContext.save.weekEventReg[51] &= (u8)~0x10; + Collider_DestroyCylinder(play, &this->collider); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_51_10); } 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) { - if (gSaveContext.save.weekEventReg[14] & 4) { +void BgIknvObj_UpdateWaterwheel(BgIknvObj* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { 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.sceneLayer == 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,66 +153,66 @@ 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; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_51_10); } - 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; } - if ((this->dyna.actor.home.rot.x == 1) && !(gSaveContext.save.weekEventReg[58] & 0x80)) { + if ((this->dyna.actor.home.rot.x == 1) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_58_80)) { 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; + SET_WEEKEVENTREG(WEEKEVENTREG_51_10); 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) { - if (gSaveContext.save.weekEventReg[58] & 0x80) { +void BgIknvObj_UpdateSakonDoor(BgIknvObj* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_58_80)) { this->actionFunc = func_80BD8040; - gSaveContext.save.weekEventReg[89] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_89_80); } - 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..a5c01165d 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) @@ -22,6 +22,4 @@ typedef enum { /* 2 */ IKNV_OBJ_SAKON_DOOR, // door to Sakon's Hideout } BgIknvObjType; -extern const ActorInit Bg_Iknv_Obj_InitVars; - #endif // Z_BG_IKNV_OBJ_H diff --git a/src/overlays/actors/ovl_Bg_Ingate/overlay.cfg b/src/overlays/actors/ovl_Bg_Ingate/overlay.cfg deleted file mode 100644 index 68501515e..000000000 --- a/src/overlays/actors/ovl_Bg_Ingate/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ingate -z_bg_ingate.c 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 11936a9d2..4ed78d458 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -11,22 +11,22 @@ #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* play2); +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 = { +ActorInit Bg_Ingate_InitVars = { ACTOR_BG_INGATE, ACTORCAT_BG, FLAGS, @@ -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; @@ -72,46 +72,48 @@ Actor* BgIngate_FindActor(BgIngate* this, GlobalContext* globalCtx, u8 actorCat, void func_80953B40(BgIngate* this) { s32 temp; - if (!(gSaveContext.eventInf[3] & 0x20)) { - this->unk180 = 0xFA0; - this->unk168 = 4; + if (!CHECK_EVENTINF(EVENTINF_35)) { + 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); + if (CHECK_EVENTINF(EVENTINF_35)) { + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_7); } else { - gSaveContext.eventInf[4] |= 2; + SET_EVENTINF(EVENTINF_41); } - 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; + if (!CHECK_EVENTINF(EVENTINF_35)) { + CLEAR_EVENTINF(EVENTINF_41); } - 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, PLAYER_CSMODE_58); player->unk_3A0.x = this->dyna.actor.world.pos.x; player->unk_3A0.z = this->dyna.actor.world.pos.z; this->unk160 &= ~0x4; @@ -155,84 +157,83 @@ 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 (!CHECK_EVENTINF(EVENTINF_40)) { - if (!(gSaveContext.eventInf[3] & 0x20) && (this->unk160 & 0x10) && (this->unk16C == 0)) { + if (!CHECK_EVENTINF(EVENTINF_35) && (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, PLAYER_CSMODE_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; + SET_WEEKEVENTREG(WEEKEVENTREG_90_40); this->actionFunc = func_809543D4; } else { - - if (!(gSaveContext.eventInf[3] & 0x20)) { - gSaveContext.eventInf[4] &= (u8)~2; + if (!CHECK_EVENTINF(EVENTINF_35)) { + CLEAR_EVENTINF(EVENTINF_41); } else { - gSaveContext.eventInf[4] |= 1; + SET_EVENTINF(EVENTINF_40); } 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); - player->stateFlags1 |= 0x20; - globalCtx->actorCtx.unk5 &= ~0x4; + Camera_ChangeSetting(mainCam, CAM_SET_NORMAL0); + player->stateFlags1 |= PLAYER_STATE1_20; + play->actorCtx.flags &= ~ACTORCTX_FLAG_PICTO_BOX_ON; } else { - func_800DFAC8(camera, 47); - player->stateFlags1 &= ~0x20; + Camera_ChangeSetting(mainCam, CAM_SET_BOAT_CRUISE); + player->stateFlags1 &= ~PLAYER_STATE1_20; } } 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, PLAYER_CSMODE_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,117 +242,117 @@ void func_809541B8(BgIngate* this, GlobalContext* globalCtx) { } } -void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { - if (gSaveContext.eventInf[5] & 1) { - globalCtx->nextEntranceIndex = 0xA820; - gSaveContext.eventInf[5] &= (u8)~1; +void func_809542A0(BgIngate* this, PlayState* play) { + if (CHECK_EVENTINF(EVENTINF_50)) { + play->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 2); + CLEAR_EVENTINF(EVENTINF_50); } 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(); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); + Environment_StartTime(); } -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); - func_800FE484(); + if (this->timePath != NULL) { + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); + this->timePath = &play->setupPathList[this->timePath->unk1]; + func_80953F14(this, play); + Environment_StopTime(); } } } -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, PLAYER_CSMODE_6); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; - func_800FE498(); + Environment_StartTime(); 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); - gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + func_80953F14(this, play); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); func_8019F230(); } - func_801477B4(globalCtx); + func_801477B4(play); break; case 0x9E6: - if (globalCtx->msgCtx.choiceIndex == 0) { - func_80953EA4(this, globalCtx); - gSaveContext.save.weekEventReg[90] &= (u8)~0x40; + if (play->msgCtx.choiceIndex == 0) { + func_80953EA4(this, play); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); func_8019F208(); } else { - func_800B7298(globalCtx, &this->dyna.actor, 6); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_6); this->unk160 &= ~0x4; this->actionFunc = func_809541B8; - func_800FE498(); + Environment_StartTime(); 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; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); } - if (!(gSaveContext.eventInf[3] & 0x20) && (gSaveContext.save.weekEventReg[90] & 0x40)) { + if (!CHECK_EVENTINF(EVENTINF_35) && CHECK_WEEKEVENTREG(WEEKEVENTREG_90_40)) { phi_a2 = 1; this->unk16C = 1; this->actionFunc = func_809541B8; } else { phi_a2 = 0; - if (globalCtx->curSpawn == 6) { - func_80953F14(this, globalCtx); - if (gSaveContext.eventInf[3] & 0x20) { - func_80112AFC(globalCtx); + if (play->curSpawn == 6) { + func_80953F14(this, play); + if (CHECK_EVENTINF(EVENTINF_35)) { + Interface_InitMinigame(play); } else { - gSaveContext.eventInf[4] |= 2; + SET_EVENTINF(EVENTINF_41); } } else { this->actionFunc = func_80953F8C; } } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); - if (this->unk164 != NULL) { - sp38 = Lib_SegmentedToVirtual(this->unk164->points); + 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); @@ -360,32 +361,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); + Actor_Kill(&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..cc0befd19 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,19 +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; - #endif // Z_BG_INGATE_H diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/overlay.cfg b/src/overlays/actors/ovl_Bg_Inibs_Movebg/overlay.cfg deleted file mode 100644 index 877787043..000000000 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Inibs_Movebg -z_bg_inibs_movebg.c 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..1b1deb6c2 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,11 +11,11 @@ #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 = { +ActorInit Bg_Inibs_Movebg_InitVars = { ACTOR_BG_INIBS_MOVEBG, ACTORCAT_BG, FLAGS, @@ -27,50 +27,49 @@ const ActorInit Bg_Inibs_Movebg_InitVars = { (ActorFunc)BgInibsMovebg_Draw, }; -Gfx* D_80B96560[] = { object_inibs_object_DL_0062D8, object_inibs_object_DL_001DC0 }; -Gfx* D_80B96568[] = { object_inibs_object_DL_006140, object_inibs_object_DL_001C10 }; -AnimatedMaterial* D_80B96570[] = { object_inibs_object_Matanimheader_006858, object_inibs_object_Matanimheader_002598 }; +Gfx* sOpaDLists[] = { gTwinmoldArenaNormalModeSandDL, gTwinmoldArenaGiantModeSandDL }; +Gfx* sXluDLists[] = { gTwinmoldArenaNormalModeCenterPlatformDL, gTwinmoldArenaGiantModeCenterPlatformDL }; +AnimatedMaterial* sSandTexAnims[] = { gTwinmoldArenaNormalModeSandTexAnim, gTwinmoldArenaGiantModeSandTexAnim }; 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); DynaPolyActor_Init(&this->dyna, 1); - this->unk_15C = D_80B96560[BGINIBSMOVEBG_GET_F(thisx)]; - this->unk_160 = D_80B96568[BGINIBSMOVEBG_GET_F(thisx)]; - this->unk_164 = D_80B96570[BGINIBSMOVEBG_GET_F(thisx)]; + this->opaDList = sOpaDLists[BG_INIBS_MOVEBG_GET_MODE(thisx)]; + this->xluDList = sXluDLists[BG_INIBS_MOVEBG_GET_MODE(thisx)]; + this->sandTexAnim = sSandTexAnims[BG_INIBS_MOVEBG_GET_MODE(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* sandTexAnim; + Gfx* opaDList; + Gfx* xluDList; - AnimatedMaterial* animMat; - Gfx* dl1; - Gfx* dl2; - - animMat = this->unk_164; - if (animMat != NULL) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(this->unk_164)); + sandTexAnim = this->sandTexAnim; + if (sandTexAnim != NULL) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(this->sandTexAnim)); } - dl1 = this->unk_15C; - if (dl1 != NULL) { - Gfx_DrawDListOpa(globalCtx, this->unk_15C); + opaDList = this->opaDList; + if (opaDList != NULL) { + Gfx_DrawDListOpa(play, this->opaDList); } - dl2 = this->unk_160; - if (dl2 != NULL) { - Gfx_DrawDListXlu(globalCtx, this->unk_160); + xluDList = this->xluDList; + if (xluDList != NULL) { + Gfx_DrawDListXlu(play, this->xluDList); } } diff --git a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h index 92494a35f..03ea34fc9 100644 --- a/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h +++ b/src/overlays/actors/ovl_Bg_Inibs_Movebg/z_bg_inibs_movebg.h @@ -5,15 +5,13 @@ struct BgInibsMovebg; -#define BGINIBSMOVEBG_GET_F(thisx) ((u16)((thisx)->params) & 0xF) +#define BG_INIBS_MOVEBG_GET_MODE(thisx) ((u16)((thisx)->params) & 0xF) typedef struct BgInibsMovebg { /* 0x000 */ DynaPolyActor dyna; - /* 0x15C */ Gfx* unk_15C; - /* 0x160 */ Gfx* unk_160; - /* 0x164 */ AnimatedMaterial* unk_164; + /* 0x15C */ Gfx* opaDList; + /* 0x160 */ Gfx* xluDList; + /* 0x164 */ AnimatedMaterial* sandTexAnim; } BgInibsMovebg; // size = 0x168 -extern const ActorInit Bg_Inibs_Movebg_InitVars; - #endif // Z_BG_INIBS_MOVEBG_H diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Saku/overlay.cfg b/src/overlays/actors/ovl_Bg_Keikoku_Saku/overlay.cfg deleted file mode 100644 index 78f2c7668..000000000 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Keikoku_Saku -z_bg_keikoku_saku.c 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..12bfc0f3c 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,18 +5,22 @@ */ #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); -#if 0 -const ActorInit Bg_Keikoku_Saku_InitVars = { +void func_80A5389C(BgKeikokuSaku* this, PlayState* play); +void func_80A538E0(BgKeikokuSaku* this, PlayState* play); +void func_80A53994(BgKeikokuSaku* this, PlayState* play); + +ActorInit Bg_Keikoku_Saku_InitVars = { ACTOR_BG_KEIKOKU_SAKU, ACTORCAT_ITEMACTION, FLAGS, @@ -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..6a3bad9c8 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h +++ b/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.h @@ -3,17 +3,17 @@ #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 - -extern const ActorInit Bg_Keikoku_Saku_InitVars; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgKeikokuSakuActionFunc actionFunc; + /* 0x160 */ s16 switchFlag; + /* 0x162 */ s16 timer; +} BgKeikokuSaku; // Size = 0x164 #endif // Z_BG_KEIKOKU_SAKU_H diff --git a/src/overlays/actors/ovl_Bg_Keikoku_Spr/overlay.cfg b/src/overlays/actors/ovl_Bg_Keikoku_Spr/overlay.cfg deleted file mode 100644 index 74d068ea4..000000000 --- a/src/overlays/actors/ovl_Bg_Keikoku_Spr/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Keikoku_Spr -z_bg_keikoku_spr.c 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..8afd5d730 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,12 +11,12 @@ #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 = { +ActorInit Bg_Keikoku_Spr_InitVars = { ACTOR_BG_KEIKOKU_SPR, ACTORCAT_PROP, FLAGS, @@ -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_Keikoku_Spr/z_bg_keikoku_spr.h b/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.h index ca72665b8..9686a44a1 100644 --- a/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.h +++ b/src/overlays/actors/ovl_Bg_Keikoku_Spr/z_bg_keikoku_spr.h @@ -9,6 +9,4 @@ typedef struct BgKeikokuSpr { /* 0x000 */ Actor actor; } BgKeikokuSpr; // size = 0x144 -extern const ActorInit Bg_Keikoku_Spr_InitVars; - #endif // Z_BG_KEIKOKU_SPR_H diff --git a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/overlay.cfg b/src/overlays/actors/ovl_Bg_Kin2_Bombwall/overlay.cfg deleted file mode 100644 index b61d1617f..000000000 --- a/src/overlays/actors/ovl_Bg_Kin2_Bombwall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Kin2_Bombwall -z_bg_kin2_bombwall.c 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..2da4ddcee 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,191 @@ 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_Kill(&this->dyna.actor); + return; + } -extern UNK_TYPE D_06000128; -extern UNK_TYPE D_06000360; -extern UNK_TYPE D_06000490; + 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); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E020.s") +void BgKin2Bombwall_Destroy(Actor* thisx, PlayState* play) { + BgKin2Bombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E090.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/BgKin2Bombwall_Init.s") +void BgKin2Bombwall_SetupWait(BgKin2Bombwall* this) { + this->actionFunc = BgKin2Bombwall_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Destroy.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/func_80B6E4B8.s") +void BgKin2Bombwall_SetupPlayCutscene(BgKin2Bombwall* this) { + this->actionFunc = BgKin2Bombwall_PlayCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E4CC.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_80B6E544.s") + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E558.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_80B6E5F8.s") +void BgKin2Bombwall_EndCutscene(BgKin2Bombwall* this, PlayState* play) { + this->timer--; + if (this->timer <= 0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Actor_Kill(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/func_80B6E614.s") +void BgKin2Bombwall_Update(Actor* thisx, PlayState* play) { + BgKin2Bombwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Update.s") + this->actionFunc(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Bombwall/BgKin2Bombwall_Draw.s") +void BgKin2Bombwall_Draw(Actor* thisx, PlayState* play) { + BgKin2Bombwall* this = THIS; + + 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/overlay.cfg b/src/overlays/actors/ovl_Bg_Kin2_Fence/overlay.cfg deleted file mode 100644 index d3984fea9..000000000 --- a/src/overlays/actors/ovl_Bg_Kin2_Fence/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Kin2_Fence -z_bg_kin2_fence.c 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 37d176f5a..dfb22deee 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,23 +11,23 @@ #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 = { +ActorInit Bg_Kin2_Fence_InitVars = { ACTOR_BG_KIN2_FENCE, ACTORCAT_BG, FLAGS, @@ -95,7 +95,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 4, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -120,24 +120,17 @@ static InitChainEntry sInitChain[] = { }; s32 BgKin2Fence_CheckHitMask(BgKin2Fence* this) { - ColliderJntSphElement* elements = this->collider.elements; + s32 i; - if (elements[0].info.bumperFlags & BUMP_HIT) { - return 0; - } - if (elements[1].info.bumperFlags & BUMP_HIT) { - return 1; - } - if (elements[2].info.bumperFlags & BUMP_HIT) { - return 2; - } - if (elements[3].info.bumperFlags & BUMP_HIT) { - return 3; + for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { + if (this->collider.elements[i].info.bumperFlags & BUMP_HIT) { + return i; + } } 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]; @@ -147,19 +140,19 @@ void BgKin2Fence_SpawnEyeSparkles(BgKin2Fence* this, GlobalContext* globalCtx, s for (i = 0; i < 2; i++) { Matrix_MultVec3f(&eyeSparkleSpawnPositions[mask][i], &sp58); - EffectSsKirakira_SpawnDispersed(globalCtx, &sp58, &gZeroVec3f, &gZeroVec3f, &primColor, &envColor, 6000, -10); + 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); + DynaPolyActor_LoadMesh(play, &this->dyna, &gOceanSpiderHouseFireplaceGrateCol); + 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); @@ -168,18 +161,18 @@ void BgKin2Fence_Init(Actor* thisx, GlobalContext* globalCtx) { 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 +180,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 +191,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 +208,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 +216,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 +231,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 +243,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 +253,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..98bb51243 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; @@ -17,6 +17,4 @@ typedef struct BgKin2Fence { /* 0x282 */ s8 waitBeforeOpenTimer; } BgKin2Fence; // size = 0x284 -extern const ActorInit Bg_Kin2_Fence_InitVars; - #endif // Z_BG_KIN2_FENCE_H diff --git a/src/overlays/actors/ovl_Bg_Kin2_Picture/overlay.cfg b/src/overlays/actors/ovl_Bg_Kin2_Picture/overlay.cfg deleted file mode 100644 index ddd62c823..000000000 --- a/src/overlays/actors/ovl_Bg_Kin2_Picture/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Kin2_Picture -z_bg_kin2_picture.c 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..5892376ba 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 @@ -5,24 +5,29 @@ */ #include "z_bg_kin2_picture.h" +#include "assets/objects/object_kin2_obj/object_kin2_obj.h" #define FLAGS 0x00000000 #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 BgKin2Picture_SetupWait(BgKin2Picture* this); +void BgKin2Picture_Wait(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupPlayCutscene(BgKin2Picture* this); +void BgKin2Picture_PlayCutscene(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupShiver(BgKin2Picture* this); +void BgKin2Picture_Shiver(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupFall(BgKin2Picture* this); +void BgKin2Picture_Fall(BgKin2Picture* this, PlayState* play); +void BgKin2Picture_SetupDoNothing(BgKin2Picture* this); +void BgKin2Picture_DoNothing(BgKin2Picture* this, PlayState* play); -#if 0 -const ActorInit Bg_Kin2_Picture_InitVars = { +ActorInit Bg_Kin2_Picture_InitVars = { ACTOR_BG_KIN2_PICTURE, ACTORCAT_PROP, FLAGS, @@ -34,73 +39,307 @@ const ActorInit Bg_Kin2_Picture_InitVars = { (ActorFunc)BgKin2Picture_Draw, }; -// static ColliderTrisElementInit sTrisElementsInit[2] = { -static ColliderTrisElementInit D_80B6F990[2] = { +static ColliderTrisElementInit sTrisElementsInit[] = { { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x000138B0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -20.0f, 53.29999923706055f, 9.0f }, { -20.0f, 3.0f, 9.0f }, { 20.0f, 3.0f, 9.0f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x000138B0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -20.0f, 53.3f, 9.0f }, { -20.0f, 3.0f, 9.0f }, { 20.0f, 3.0f, 9.0f } } }, }, { - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0x000138B0, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { { { -20.0f, 53.29999923706055f, 9.0f }, { 20.0f, 3.0f, 9.0f }, { 20.0f, 53.29999923706055f, 9.0f } } }, + { + ELEMTYPE_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0x000138B0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { -20.0f, 53.3f, 9.0f }, { 20.0f, 3.0f, 9.0f }, { 20.0f, 53.3f, 9.0f } } }, }, }; -// 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, +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_80B6FA24[] = { - 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_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +static Vec3f sDustBasePos = { 0.0f, 23.0f, 0.0f }; + +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_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +s32 BgKin2Picture_IsSkulltulaCollected(PlayState* play, s32 skulltulaParams) { + s32 flag = -1; -extern ColliderTrisElementInit D_80B6F990[2]; -extern ColliderTrisInit D_80B6FA08; -extern InitChainEntry D_80B6FA24[]; + if ((u8)skulltulaParams & 3) { + flag = BG_KIN2_PICTURE_GET_3FC(skulltulaParams); + } -extern UNK_TYPE D_06000658; -extern UNK_TYPE D_06000798; + return (flag >= 0) && Flags_GetTreasure(play, flag); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6EFA0.s") +void BgKin2Picture_SpawnSkulltula(BgKin2Picture* this, PlayState* play2) { + PlayState* play = play2; + s32 skulltulaSpawnParams; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6EFEC.s") + if (!BG_KIN2_PICTURE_SKULLTULA_COLLECTED(&this->dyna.actor)) { // Gold Skulltula is still here. + skulltulaSpawnParams = BG_KIN2_PICTURE_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); + if (!BgKin2Picture_IsSkulltulaCollected(play, skulltulaSpawnParams) && + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SW, this->dyna.actor.home.pos.x, + this->dyna.actor.home.pos.y + 23.0f, this->dyna.actor.home.pos.z, 0, + this->dyna.actor.home.rot.y, 0, skulltulaSpawnParams)) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F098.s") +#define DUST_COUNT 20 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/BgKin2Picture_Init.s") +void BgKin2Picture_SpawnDust(BgKin2Picture* this, PlayState* play) { + f32 offset; + Vec3f basePos; + Vec3f pos; + Vec3f velocity; + Vec3f accel; + s32 angle; + s32 scale; + s16 scaleStep; + s32 baseAngle; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/BgKin2Picture_Destroy.s") + 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_MultVec3f(&sDustBasePos, &basePos); + pos.y = basePos.y - 7.0f; + velocity.y = 0.0f; + accel.y = 0.2f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F4C0.s") + for (i = 0, baseAngle = 0; i < DUST_COUNT; i++, baseAngle += (0x10000 / DUST_COUNT)) { + angle = (s32)(Rand_ZeroOne() * (0x10000 / DUST_COUNT)) + baseAngle; + offset = (Rand_ZeroOne() * 14.0f) + 4.0f; + pos.x = Math_SinS(angle) * offset; + pos.z = Math_CosS(angle) * offset; + velocity.x = (Rand_ZeroOne() - 0.5f) + (pos.x * (1.0f / 6.0f)); + velocity.z = (Rand_ZeroOne() - 0.5f) + (pos.z * (1.0f / 6.0f)); + pos.x += basePos.x; + pos.z += basePos.z; + accel.x = velocity.x * -0.09f; + accel.z = velocity.z * -0.09f; + scale = (s32)(Rand_ZeroOne() * 10.0f) + 10; + scaleStep = (s32)(Rand_ZeroOne() * 10.0f) + 15; + func_800B1210(play, &pos, &velocity, &accel, scale, scaleStep); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F4D4.s") +void BgKin2Picture_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgKin2Picture* this = THIS; + s32 skulltulaParams; + Vec3f vertices[3]; + s32 i; + s32 j; + ColliderTrisElementInit* element; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F5A4.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &gOceanSpiderHouseSkullkidPaintingCol); + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_InitTris(play, &this->colliderTris); + Collider_SetTris(play, &this->colliderTris, &this->dyna.actor, &sTrisInit, this->colliderElement); + 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_Kin2_Picture/func_80B6F5B8.s") + for (i = 0; i < ARRAY_COUNT(sTrisElementsInit); i++) { + for (j = 0; j < ARRAY_COUNT(vertices); j++) { + element = &sTrisInit.elements[i]; + Matrix_MultVec3f(&element->dim.vtx[j], &vertices[j]); + } + Collider_SetTrisVertices(&this->colliderTris, i, &vertices[0], &vertices[1], &vertices[2]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F61C.s") + Actor_SetFocus(&this->dyna.actor, 23.0f); + skulltulaParams = BG_KIN2_PICTURE_SKULLTULA_SPAWN_PARAM(&this->dyna.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F640.s") + if (BG_KIN2_PICTURE_SKULLTULA_COLLECTED(&this->dyna.actor) || + BgKin2Picture_IsSkulltulaCollected(play, skulltulaParams)) { + this->skulltulaNoiseTimer = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F708.s") + BgKin2Picture_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F72C.s") +void BgKin2Picture_Destroy(Actor* thisx, PlayState* play) { + BgKin2Picture* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F8F8.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Collider_DestroyTris(play, &this->colliderTris); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/func_80B6F90C.s") +void BgKin2Picture_SetupWait(BgKin2Picture* this) { + this->actionFunc = BgKin2Picture_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/BgKin2Picture_Update.s") +void BgKin2Picture_Wait(BgKin2Picture* this, PlayState* play) { + // hit by projectile + if (this->colliderTris.base.acFlags & AC_HIT) { + this->colliderTris.base.acFlags &= ~AC_HIT; + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + BgKin2Picture_SetupPlayCutscene(this); + } else { // Gold Skulltula can be heard behind Skullkid's painting. + if (this->skulltulaNoiseTimer >= 0) { + if (this->skulltulaNoiseTimer == 0) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_STALGOLD_ROLL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Kin2_Picture/BgKin2Picture_Draw.s") + if (Rand_ZeroOne() < 0.1f) { + this->skulltulaNoiseTimer = Rand_S16Offset(40, 80); + } else { + this->skulltulaNoiseTimer = 8; + } + } else { + this->skulltulaNoiseTimer--; + } + } + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); + } +} + +void BgKin2Picture_SetupPlayCutscene(BgKin2Picture* this) { + this->actionFunc = BgKin2Picture_PlayCutscene; +} + +void BgKin2Picture_PlayCutscene(BgKin2Picture* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + this->cutsceneStarted = true; + BgKin2Picture_SetupShiver(this); + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} + +void BgKin2Picture_SetupShiver(BgKin2Picture* this) { + this->paintingTimer = 13; + this->xOffsetAngle = 0; + this->yOffsetAngle = 0; + this->actionFunc = BgKin2Picture_Shiver; +} + +void BgKin2Picture_Shiver(BgKin2Picture* this, PlayState* play) { + s32 pad; + Vec3f basePosOffset; + Vec3f posOffset; + + this->paintingTimer--; + if (this->paintingTimer <= 0) { + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + BgKin2Picture_SetupFall(this); + } else { + this->xOffsetAngle += 0x7BAC; + this->yOffsetAngle += 0x4E20; + basePosOffset.x = Math_CosS(this->xOffsetAngle); + basePosOffset.y = Math_CosS(this->yOffsetAngle) * 0.2f; + basePosOffset.z = 0.0f; + Matrix_RotateYS(this->dyna.actor.shape.rot.y, MTXMODE_NEW); + Matrix_MultVec3f(&basePosOffset, &posOffset); + Math_Vec3f_Sum(&this->dyna.actor.home.pos, &posOffset, &this->dyna.actor.world.pos); + } +} + +void BgKin2Picture_SetupFall(BgKin2Picture* this) { + this->landTimer = 0; + this->step = 0; + this->paintingTimer = 4; + this->actionFunc = BgKin2Picture_Fall; +} + +void BgKin2Picture_Fall(BgKin2Picture* this, PlayState* play) { + if (this->paintingTimer > 0) { + this->paintingTimer--; + + if (this->paintingTimer == 0) { + BgKin2Picture_SpawnSkulltula(this, play); + } + } + + Actor_MoveWithGravity(&this->dyna.actor); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4); + + if (this->dyna.actor.bgCheckFlags & 1) { + Math_StepToS(&this->step, 0x7D0, 0x78); + + if (this->landTimer < 3) { + this->landTimer++; + + if (this->dyna.actor.velocity.y <= 0.01f) { + this->dyna.actor.velocity.y *= -0.7f; + + if (this->dyna.actor.velocity.y > 6.0f) { + this->dyna.actor.velocity.y = 6.0f; + } + + if (this->landTimer < 3) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SMALL_WOODPLATE_BOUND_0); + } + } + } + } + + Actor_SetFocus(&this->dyna.actor, 23.0f); + + if (!this->hasSpawnedDust && (this->dyna.actor.shape.rot.x > 0x3300)) { + BgKin2Picture_SpawnDust(this, play); + this->hasSpawnedDust = true; + } + + if (Math_ScaledStepToS(&this->dyna.actor.shape.rot.x, 0x4000, this->step)) { // facing the floor + this->dyna.actor.shape.yOffset = 40.0f; + + if (this->cutsceneStarted) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + } + + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WOODPLATE_BROKEN); + BgKin2Picture_SetupDoNothing(this); + } else { + this->dyna.actor.shape.yOffset = Math_SinS(this->dyna.actor.shape.rot.x) * 40.0f; + } +} + +void BgKin2Picture_SetupDoNothing(BgKin2Picture* this) { + this->actionFunc = BgKin2Picture_DoNothing; +} + +void BgKin2Picture_DoNothing(BgKin2Picture* this, PlayState* play) { +} + +void BgKin2Picture_Update(Actor* thisx, PlayState* play) { + BgKin2Picture* this = THIS; + + this->actionFunc(this, play); +} + +void BgKin2Picture_Draw(Actor* thisx, PlayState* play) { + BgKin2Picture* this = THIS; + + Gfx_DrawDListOpa(play, gOceanSpiderHouseSkullkidPaintingDL); +} 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..ce7cf95fb 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 @@ -3,17 +3,27 @@ #include "global.h" +#define BG_KIN2_PICTURE_SKULLTULA_COLLECTED(thisx) (((thisx)->params >> 5) & 1) +#define BG_KIN2_PICTURE_GET_3FC(thisx) ((u8)(((thisx & 0x3FC)) >> 2)) +#define BG_KIN2_PICTURE_SKULLTULA_SPAWN_PARAM(thisx) ((((thisx)->params & 0x1F) << 2) | 0xFF03) + 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 */ DynaPolyActor dyna; + /* 0x15C */ ColliderTris colliderTris; + /* 0x17C */ ColliderTrisElement colliderElement[2]; + /* 0x234 */ BgKin2PictureActionFunc actionFunc; + /* 0x238 */ s16 step; + /* 0x23A */ s8 paintingTimer; // Used for when painting is shaking and for timing Gold Skulltula spawn. + /* 0x23B */ s8 landTimer; + /* 0x23C */ s16 xOffsetAngle; + /* 0x23E */ s16 yOffsetAngle; + /* 0x240 */ s8 cutsceneStarted; + /* 0x241 */ s8 hasSpawnedDust; + /* 0x242 */ s8 skulltulaNoiseTimer; } BgKin2Picture; // size = 0x244 -extern const ActorInit Bg_Kin2_Picture_InitVars; - #endif // Z_BG_KIN2_PICTURE_H diff --git a/src/overlays/actors/ovl_Bg_Kin2_Shelf/overlay.cfg b/src/overlays/actors/ovl_Bg_Kin2_Shelf/overlay.cfg deleted file mode 100644 index 84a84fd49..000000000 --- a/src/overlays/actors/ovl_Bg_Kin2_Shelf/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Kin2_Shelf -z_bg_kin2_shelf.c 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 499fb034a..6c30347ef 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 @@ -11,19 +11,19 @@ #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, GlobalContext* globalCtx); +void func_80B700C0(BgKin2Shelf* this, PlayState* play); void func_80B70214(BgKin2Shelf* this); -void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx); +void func_80B70230(BgKin2Shelf* this, PlayState* play); void func_80B70498(BgKin2Shelf* this); -void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx); +void func_80B704B4(BgKin2Shelf* this, PlayState* play); -const ActorInit Bg_Kin2_Shelf_InitVars = { +ActorInit Bg_Kin2_Shelf_InitVars = { ACTOR_BG_KIN2_SHELF, ACTORCAT_BG, FLAGS, @@ -51,11 +51,11 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), }; -CollisionHeader* D_80B70780[] = { &object_kin2_obj_Colheader_001328, &object_kin2_obj_Colheader_000F80 }; +CollisionHeader* D_80B70780[] = { &gOceanSpiderHouseChestOfDrawersCol, &gOceanSpiderHouseBookshelfCol }; -Gfx* D_80B70788[] = { object_kin2_obj_DL_0010F8, object_kin2_obj_DL_000CA8 }; +Gfx* D_80B70788[] = { gOceanSpiderHouseChestOfDrawersDL, gOceanSpiderHouseBookshelfDL }; -s32 func_80B6FB30(BgKin2Shelf* this, GlobalContext* globalCtx) { +s32 func_80B6FB30(BgKin2Shelf* this, PlayState* play) { s32 temp_v1 = BGKIN2SHELF_GET_1(&this->dyna.actor); f32 phi_f0; f32 spA4; @@ -94,11 +94,11 @@ s32 func_80B6FB30(BgKin2Shelf* this, GlobalContext* globalCtx) { Matrix_MultVec3f(&sp94, &sp7C); Matrix_MultVec3f(&sp88, &sp70); - return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp7C, &sp70, &sp64, &sp54, true, false, false, true, &sp50, + return BgCheck_EntityLineTest3(&play->colCtx, &sp7C, &sp70, &sp64, &sp54, true, false, false, true, &sp50, &this->dyna.actor, 0.0f); } -s32 func_80B6FCA4(BgKin2Shelf* this, GlobalContext* globalCtx) { +s32 func_80B6FCA4(BgKin2Shelf* this, PlayState* play) { s32 pad; f32 spA0; s16 sp9E; @@ -136,18 +136,18 @@ s32 func_80B6FCA4(BgKin2Shelf* this, GlobalContext* globalCtx) { Matrix_MultVec3f(&sp90, &sp78); Matrix_MultVec3f(&sp84, &sp6C); - return BgCheck_EntityLineTest3(&globalCtx->colCtx, &sp78, &sp6C, &sp60, &sp50, true, false, false, true, &sp4C, + return BgCheck_EntityLineTest3(&play->colCtx, &sp78, &sp6C, &sp60, &sp50, true, false, false, true, &sp4C, &this->dyna.actor, 0.0f); } -s32 func_80B6FE08(BgKin2Shelf* this, GlobalContext* globalCtx) { +s32 func_80B6FE08(BgKin2Shelf* this, PlayState* play) { if (this->unk_164 & (0x8 | 0x2)) { - return func_80B6FB30(this, globalCtx); + return func_80B6FB30(this, play); } - return func_80B6FCA4(this, globalCtx); + return func_80B6FCA4(this, play); } -s32 func_80B6FE48(BgKin2Shelf* this, GlobalContext* globalCtx) { +s32 func_80B6FE48(BgKin2Shelf* this, PlayState* play) { s32 params = BGKIN2SHELF_GET_1(&this->dyna.actor); u8 temp_v1 = D_80B70778[params] & this->unk_164; @@ -166,7 +166,7 @@ s32 func_80B6FE48(BgKin2Shelf* this, GlobalContext* globalCtx) { return temp_v1 & 5; } -s32 func_80B6FEBC(BgKin2Shelf* this, GlobalContext* globalCtx) { +s32 func_80B6FEBC(BgKin2Shelf* this, PlayState* play) { if (this->unk_164 & 1) { return this->unk_167 < 1; } @@ -185,12 +185,11 @@ s32 func_80B6FEBC(BgKin2Shelf* this, GlobalContext* globalCtx) { return false; } -s32 func_80B6FF28(BgKin2Shelf* this, GlobalContext* globalCtx) { - return (this->unk_165 > 8) && func_80B6FE48(this, globalCtx) && func_80B6FEBC(this, globalCtx) && - !func_80B6FE08(this, globalCtx); +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, GlobalContext* globalCtx) { +void BgKin2Shelf_Init(Actor* thisx, PlayState* play) { s32 pad; BgKin2Shelf* this = THIS; s32 sp24 = BGKIN2SHELF_GET_1(&this->dyna.actor); @@ -209,14 +208,14 @@ void BgKin2Shelf_Init(Actor* thisx, GlobalContext* globalCtx) { } DynaPolyActor_Init(&this->dyna, 1); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, D_80B70780[sp24]); + DynaPolyActor_LoadMesh(play, &this->dyna, D_80B70780[sp24]); func_80B700A8(this); } -void BgKin2Shelf_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgKin2Shelf_Destroy(Actor* thisx, PlayState* play) { BgKin2Shelf* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } void func_80B700A8(BgKin2Shelf* this) { @@ -224,7 +223,7 @@ void func_80B700A8(BgKin2Shelf* this) { this->actionFunc = func_80B700C0; } -void func_80B700C0(BgKin2Shelf* this, GlobalContext* globalCtx) { +void func_80B700C0(BgKin2Shelf* this, PlayState* play) { s16 temp_v0; u8 phi_v0_2; @@ -252,16 +251,16 @@ void func_80B700C0(BgKin2Shelf* this, GlobalContext* globalCtx) { this->unk_164 = 0; } - if (func_80B6FF28(this, globalCtx)) { + if (func_80B6FF28(this, play)) { if (this->unk_164 & (0x8 | 0x2)) { func_80B70214(this); } else { func_80B70498(this); } } else { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } } else { @@ -275,7 +274,7 @@ void func_80B70214(BgKin2Shelf* this) { this->actionFunc = func_80B70230; } -void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx) { +void func_80B70230(BgKin2Shelf* this, PlayState* play) { f32 phi_f20; s32 sp40 = BGKIN2SHELF_GET_1(&this->dyna.actor); f32 phi_f2; @@ -290,10 +289,10 @@ void func_80B70230(BgKin2Shelf* this, GlobalContext* globalCtx) { this->unk_160 += phi_f2; if (this->unk_160 >= 1.0f) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->unk_160 = 1.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; if (this->unk_164 & 8) { @@ -327,7 +326,7 @@ void func_80B70498(BgKin2Shelf* this) { this->actionFunc = func_80B704B4; } -void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx) { +void func_80B704B4(BgKin2Shelf* this, PlayState* play) { f32 temp_f20; s32 sp40 = BGKIN2SHELF_GET_1(&this->dyna.actor); f32 phi_f20; @@ -337,10 +336,10 @@ void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx) { this->unk_160 += (Math_SinS(this->unk_160 * 0x8000) * 0.022f) + 0.022f; if (this->unk_160 >= 1.0f) { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); this->unk_160 = 1.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; if (this->unk_164 & 4) { @@ -368,12 +367,12 @@ void func_80B704B4(BgKin2Shelf* this, GlobalContext* globalCtx) { } } -void BgKin2Shelf_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgKin2Shelf_Update(Actor* thisx, PlayState* play) { BgKin2Shelf* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void BgKin2Shelf_Draw(Actor* thisx, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, D_80B70788[BGKIN2SHELF_GET_1(thisx)]); +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 29a295851..bd5180c34 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,20 +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 */ DynaPolyActor dyna; - /* 0x015C */ BgKin2ShelfActionFunc actionFunc; - /* 0x0160 */ f32 unk_160; - /* 0x0164 */ u8 unk_164; - /* 0x0165 */ s8 unk_165; - /* 0x0166 */ s8 unk_166; - /* 0x0167 */ s8 unk_167; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgKin2ShelfActionFunc actionFunc; + /* 0x160 */ f32 unk_160; + /* 0x164 */ u8 unk_164; + /* 0x165 */ s8 unk_165; + /* 0x166 */ s8 unk_166; + /* 0x167 */ s8 unk_167; } BgKin2Shelf; // size = 0x168 -extern const ActorInit Bg_Kin2_Shelf_InitVars; - #endif // Z_BG_KIN2_SHELF_H diff --git a/src/overlays/actors/ovl_Bg_Ladder/overlay.cfg b/src/overlays/actors/ovl_Bg_Ladder/overlay.cfg deleted file mode 100644 index 6f88bdf1b..000000000 --- a/src/overlays/actors/ovl_Bg_Ladder/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Ladder -z_bg_ladder.c 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..f766fef78 100644 --- a/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c +++ b/src/overlays/actors/ovl_Bg_Ladder/z_bg_ladder.c @@ -11,16 +11,16 @@ #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 = { +ActorInit Bg_Ladder_InitVars = { ACTOR_BG_LADDER, ACTORCAT_PROP, FLAGS, @@ -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); + Actor_Kill(&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..e4cd15c15 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,12 +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; - #endif // Z_BG_LADDER_H diff --git a/src/overlays/actors/ovl_Bg_Last_Bwall/overlay.cfg b/src/overlays/actors/ovl_Bg_Last_Bwall/overlay.cfg deleted file mode 100644 index ec560aa15..000000000 --- a/src/overlays/actors/ovl_Bg_Last_Bwall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Last_Bwall -z_bg_last_bwall.c 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..d704adf86 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,13 +10,34 @@ #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 -#if 0 -const ActorInit Bg_Last_Bwall_InitVars = { +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* play2); + +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); + +ActorInit Bg_Last_Bwall_InitVars = { ACTOR_BG_LAST_BWALL, ACTORCAT_BG, FLAGS, @@ -28,57 +49,221 @@ 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_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/BgLastBwall_Destroy.s") + if (!Collider_SetTris(play, &this->colliderTris, &this->dyna.actor, &sTrisInit, this->colliderTrisElement)) { + Actor_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C184EC.s") + 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/func_80C187E4.s") +void BgLastBwall_Destroy(Actor* thisx, PlayState* play) { + BgLastBwall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C187F8.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C1886C.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_80C18884.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_80C188C4.s") +void func_80C187E4(BgLastBwall* this) { + this->actionFunc = func_80C187F8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/func_80C18928.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/BgLastBwall_Update.s") +void func_80C1886C(BgLastBwall* this, PlayState* play) { + this->actionFunc = func_80C18884; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Last_Bwall/BgLastBwall_Draw.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); + } +} + +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; +} + +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..3fafc71ea 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,18 +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; - #endif // Z_BG_LAST_BWALL_H diff --git a/src/overlays/actors/ovl_Bg_Lbfshot/overlay.cfg b/src/overlays/actors/ovl_Bg_Lbfshot/overlay.cfg deleted file mode 100644 index 520be10f0..000000000 --- a/src/overlays/actors/ovl_Bg_Lbfshot/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Lbfshot -z_bg_lbfshot.c 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..75e7b9e32 100644 --- a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c +++ b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.c @@ -11,11 +11,11 @@ #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 = { +ActorInit Bg_Lbfshot_InitVars = { ACTOR_BG_LBFSHOT, ACTORCAT_BG, FLAGS, @@ -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_Lbfshot/z_bg_lbfshot.h b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.h index 069bfa048..2874a2d13 100644 --- a/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.h +++ b/src/overlays/actors/ovl_Bg_Lbfshot/z_bg_lbfshot.h @@ -10,6 +10,4 @@ typedef struct BgLbfshot { /* 0x15C */ UNK_TYPE1 pad15C[0x4]; } BgLbfshot; // size = 0x160 -extern const ActorInit Bg_Lbfshot_InitVars; - #endif // Z_BG_LBFSHOT_H diff --git a/src/overlays/actors/ovl_Bg_Lotus/overlay.cfg b/src/overlays/actors/ovl_Bg_Lotus/overlay.cfg deleted file mode 100644 index 95702c51b..000000000 --- a/src/overlays/actors/ovl_Bg_Lotus/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Lotus -z_bg_lotus.c 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..20be54a2f 100644 --- a/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c +++ b/src/overlays/actors/ovl_Bg_Lotus/z_bg_lotus.c @@ -11,16 +11,16 @@ #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 = { +ActorInit Bg_Lotus_InitVars = { ACTOR_BG_LOTUS, ACTORCAT_BG, FLAGS, @@ -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, &gLilyPadCol); + 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, gLilyPadDL); } 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..540c21b0e 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; @@ -16,6 +16,4 @@ typedef struct BgLotus { /* 0x168 */ s16 timer2; } BgLotus; // size = 0x16C -extern const ActorInit Bg_Lotus_InitVars; - #endif // Z_BG_LOTUS_H diff --git a/src/overlays/actors/ovl_Bg_Market_Step/overlay.cfg b/src/overlays/actors/ovl_Bg_Market_Step/overlay.cfg deleted file mode 100644 index 07ff7cee8..000000000 --- a/src/overlays/actors/ovl_Bg_Market_Step/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Market_Step -z_bg_market_step.c 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..44d797b8e 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,10 +11,10 @@ #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 = { +ActorInit Bg_Market_Step_InitVars = { ACTOR_BG_MARKET_STEP, ACTORCAT_BG, FLAGS, OBJECT_MARKET_OBJ, sizeof(BgMarketStep), (ActorFunc)BgMarketStep_Init, (ActorFunc)Actor_Noop, (ActorFunc)Actor_Noop, (ActorFunc)BgMarketStep_Draw, @@ -27,17 +27,25 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 1000, ICHAIN_STOP), }; -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 }; +Gfx* sMarketDLs[] = { + gWestClockTownMarketDayDL, + gWestClockTownMarketNightDL, +}; -void BgMarketStep_Init(Actor* thisx, GlobalContext* globalCtx) { +Gfx* sBankAdvertisementsAndDoorDLs[] = { + gWestClockTownMarketBankAdvertisementsAndDoorDayDL, + gWestClockTownMarketBankAdvertisementsAndDoorNightDL, +}; + +void BgMarketStep_Init(Actor* thisx, PlayState* play) { BgMarketStep* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); } -void BgMarketStep_Draw(Actor* thisx, GlobalContext* globalCtx) { - s32 index = thisx->params & 1; - Gfx_DrawDListOpa(globalCtx, D_80AF0120[index]); - Gfx_DrawDListOpa(globalCtx, D_80AF0128[index]); +void BgMarketStep_Draw(Actor* thisx, PlayState* play) { + s32 timeOfDay = BG_MARKET_STEP_GET_TIME_OF_DAY(thisx); + + Gfx_DrawDListOpa(play, sMarketDLs[timeOfDay]); + Gfx_DrawDListOpa(play, sBankAdvertisementsAndDoorDLs[timeOfDay]); } diff --git a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.h b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.h index aa98c0aa1..9a957b742 100644 --- a/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.h +++ b/src/overlays/actors/ovl_Bg_Market_Step/z_bg_market_step.h @@ -3,12 +3,12 @@ #include "global.h" +#define BG_MARKET_STEP_GET_TIME_OF_DAY(thisx) ((thisx)->params & 1) + struct BgMarketStep; typedef struct BgMarketStep { /* 0x000 */ Actor actor; } BgMarketStep; // size = 0x144 -extern const ActorInit Bg_Market_Step_InitVars; - #endif // Z_BG_MARKET_STEP_H diff --git a/src/overlays/actors/ovl_Bg_Mbar_Chair/overlay.cfg b/src/overlays/actors/ovl_Bg_Mbar_Chair/overlay.cfg deleted file mode 100644 index 8cfa06dec..000000000 --- a/src/overlays/actors/ovl_Bg_Mbar_Chair/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Mbar_Chair -z_bg_mbar_chair.c 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..305c3084e 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,12 +11,12 @@ #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 = { +ActorInit Bg_Mbar_Chair_InitVars = { ACTOR_BG_MBAR_CHAIR, ACTORCAT_BG, FLAGS, @@ -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_Mbar_Chair/z_bg_mbar_chair.h b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.h index ee4854d07..0d9326464 100644 --- a/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.h +++ b/src/overlays/actors/ovl_Bg_Mbar_Chair/z_bg_mbar_chair.h @@ -9,6 +9,4 @@ typedef struct BgMbarChair { /* 0x000 */ DynaPolyActor dyna; } BgMbarChair; // size = 0x15C -extern const ActorInit Bg_Mbar_Chair_InitVars; - #endif // Z_BG_MBAR_CHAIR_H diff --git a/src/overlays/actors/ovl_Bg_Numa_Hana/overlay.cfg b/src/overlays/actors/ovl_Bg_Numa_Hana/overlay.cfg deleted file mode 100644 index 63ed804b1..000000000 --- a/src/overlays/actors/ovl_Bg_Numa_Hana/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Numa_Hana -z_bg_numa_hana.c 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 d30fd2d74..497ed10ab 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,25 +12,25 @@ #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* play2); 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 = { +ActorInit Bg_Numa_Hana_InitVars = { ACTOR_BG_NUMA_HANA, ACTORCAT_BG, FLAGS, @@ -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)) { - Actor_MarkForDeath(&this->dyna.actor); + if (!BgNumaHana_SpawnOpenFlowerCollisionChild(this, play)) { + Actor_Kill(&this->dyna.actor); return; } - if (gSaveContext.save.weekEventReg[12] & 1) { - func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_01)) { + 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)); + SET_WEEKEVENTREG(WEEKEVENTREG_12_01); + 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,31 +360,31 @@ 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++) { @@ -394,27 +394,27 @@ void BgNumaHana_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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_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))) { + 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..fd71577cd 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; @@ -40,6 +40,4 @@ typedef struct BgNumaHana { /* 0x33E */ s16 transitionTimer; } BgNumaHana; // size = 0x340 -extern const ActorInit Bg_Numa_Hana_InitVars; - #endif // Z_BG_NUMA_HANA_H diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/overlay.cfg b/src/overlays/actors/ovl_Bg_Open_Shutter/overlay.cfg deleted file mode 100644 index 8bf55bec2..000000000 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Open_Shutter -z_bg_open_shutter.c 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..c264b9775 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,22 +5,29 @@ */ #include "z_bg_open_shutter.h" +#include "objects/object_open_obj/object_open_obj.h" +#include "z64quake.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* play2); +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); -#if 0 -const ActorInit Bg_Open_Shutter_InitVars = { +typedef enum { + /* 0x1 */ BGOPENSHUTTER_DOOR_OPEN = 1, + /* 0x2 */ BGOPENSHUTTER_DOOR_CLOSED, +} BGOpenShutterDoorState; + +ActorInit Bg_Open_Shutter_InitVars = { ACTOR_BG_OPEN_SHUTTER, ACTORCAT_DOOR, FLAGS, @@ -32,35 +39,154 @@ 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 doorDirection; -#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); + + doorDirection = func_80ACABA8(this, play); + if (doorDirection > 0) { + player->doorType = PLAYER_DOORTYPE_SLIDING; + player->doorDirection = doorDirection; + 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 quakeIndex; + + 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); + + quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -32536); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 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..f6c6067d4 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,17 +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; - #endif // Z_BG_OPEN_SHUTTER_H diff --git a/src/overlays/actors/ovl_Bg_Open_Spot/overlay.cfg b/src/overlays/actors/ovl_Bg_Open_Spot/overlay.cfg deleted file mode 100644 index 757c3fbfd..000000000 --- a/src/overlays/actors/ovl_Bg_Open_Spot/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Open_Spot -z_bg_open_spot.c 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 48d2cd4f2..dbe935b3f 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 @@ -11,12 +11,12 @@ #define THIS ((BgOpenSpot*)thisx) -void BgOpenSpot_Init(Actor* thisx, GlobalContext* globalCtx); -void BgOpenSpot_Destroy(Actor* thisx, GlobalContext* globalCtx); -void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx); -void BgOpenSpot_Draw(Actor* thisx, GlobalContext* globalCtx); +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); -const ActorInit Bg_Open_Spot_InitVars = { +ActorInit Bg_Open_Spot_InitVars = { ACTOR_BG_OPEN_SPOT, ACTORCAT_PROP, FLAGS, @@ -35,22 +35,22 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -void BgOpenSpot_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgOpenSpot_Init(Actor* thisx, PlayState* play) { BgOpenSpot* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); this->texScrolls = Lib_SegmentedToVirtual(gSpotlightTexAnim); } -void BgOpenSpot_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgOpenSpot_Destroy(Actor* thisx, PlayState* play) { } -void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgOpenSpot_Update(Actor* thisx, PlayState* play) { BgOpenSpot* this = THIS; u32 action; - if (Cutscene_CheckActorAction(globalCtx, 0x7D)) { - action = globalCtx->csCtx.actorActions[Cutscene_GetActorActionIndex(globalCtx, 0x7D)]->action; + 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) { @@ -59,18 +59,18 @@ void BgOpenSpot_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void BgOpenSpot_Draw(Actor* thisx, GlobalContext* globalCtx) { +void BgOpenSpot_Draw(Actor* thisx, PlayState* play) { s32 pad; BgOpenSpot* this = (BgOpenSpot*)thisx; - AnimatedMat_Draw(globalCtx, this->texScrolls); - OPEN_DISPS(globalCtx->state.gfxCtx); + AnimatedMat_Draw(play, this->texScrolls); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + 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(globalCtx->state.gfxCtx); + 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 3a2b92125..0cc4d55b9 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 @@ -10,6 +10,4 @@ typedef struct BgOpenSpot { /* 0x144 */ AnimatedMaterial* texScrolls; } BgOpenSpot; // size = 0x148 -extern const ActorInit Bg_Open_Spot_InitVars; - #endif // Z_BG_OPEN_SPOT_H diff --git a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/overlay.cfg b/src/overlays/actors/ovl_Bg_Sinkai_Kabe/overlay.cfg deleted file mode 100644 index b2a92fdbf..000000000 --- a/src/overlays/actors/ovl_Bg_Sinkai_Kabe/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Sinkai_Kabe -z_bg_sinkai_kabe.c 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 e5bba655d..2ec37cb7e 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 @@ -18,13 +18,13 @@ #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, GlobalContext* globalCtx); +void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, PlayState* play); -const ActorInit Bg_Sinkai_Kabe_InitVars = { +ActorInit Bg_Sinkai_Kabe_InitVars = { ACTOR_BG_SINKAI_KABE, ACTORCAT_ITEMACTION, FLAGS, @@ -38,7 +38,7 @@ const ActorInit Bg_Sinkai_Kabe_InitVars = { static s32 sCurrentPythonIndex = 0; -void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { +void BgSinkaiKabe_Init(Actor* thisx, PlayState* play) { BgSinkaiKabe* this = THIS; s32 pad; CollisionHeader* colHeader = NULL; @@ -50,7 +50,7 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&gPinnacleRockPythonDenCol, &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); 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; @@ -67,10 +67,9 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { this->pythonIndex = sCurrentPythonIndex; sCurrentPythonIndex++; - if (!(gSaveContext.save.weekEventReg[13] & 1)) { - this->deepPython = - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_DRAGON, pos.x, pos.y, pos.z, - 0, this->dyna.actor.world.rot.y, 1, this->dyna.actor.params); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_13_01)) { + 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; @@ -83,14 +82,14 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { } } 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))) { + if (((this->dyna.actor.params == 0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_83_10)) || + ((this->dyna.actor.params == 1) && CHECK_WEEKEVENTREG(WEEKEVENTREG_83_20)) || + ((this->dyna.actor.params == 2) && CHECK_WEEKEVENTREG(WEEKEVENTREG_83_40)) || + ((this->dyna.actor.params == 3) && CHECK_WEEKEVENTREG(WEEKEVENTREG_83_80)) || + ((this->dyna.actor.params == 4) && CHECK_WEEKEVENTREG(WEEKEVENTREG_84_01)) || + ((this->dyna.actor.params == 5) && CHECK_WEEKEVENTREG(WEEKEVENTREG_84_02)) || + ((this->dyna.actor.params == 6) && CHECK_WEEKEVENTREG(WEEKEVENTREG_84_04)) || + ((this->dyna.actor.params == 7) && CHECK_WEEKEVENTREG(WEEKEVENTREG_84_08))) { shouldSpawnSeahorse = true; } @@ -99,33 +98,33 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) { pos.y += -100.0f; pos.z += (Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f); if (shouldSpawnSeahorse) { - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, pos.x, pos.y, pos.z, 0, + 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); + Actor_Kill(&this->dyna.actor); } this->actionFunc = BgSinkaiKabe_WaitForPlayer; } -void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void BgSinkaiKabe_Destroy(Actor* thisx, PlayState* play) { BgSinkaiKabe* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + 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, GlobalContext* globalCtx) { +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(globalCtx); + 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) && @@ -141,12 +140,12 @@ void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx) { } if (this->deepPython == NULL) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } } -void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx) { +void BgSinkaiKabe_Update(Actor* thisx, PlayState* play) { BgSinkaiKabe* this = THIS; - this->actionFunc(this, globalCtx); + 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 1a29f512f..abb341797 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 @@ -6,7 +6,7 @@ struct BgSinkaiKabe; -typedef void (*BgSinkaiKabeActionFunc)(struct BgSinkaiKabe*, GlobalContext*); +typedef void (*BgSinkaiKabeActionFunc)(struct BgSinkaiKabe*, PlayState*); typedef struct BgSinkaiKabe { /* 0x000 */ DynaPolyActor dyna; @@ -17,6 +17,4 @@ typedef struct BgSinkaiKabe { /* 0x16C */ s32 pythonIndex; } BgSinkaiKabe; // size = 0x170 -extern const ActorInit Bg_Sinkai_Kabe_InitVars; - #endif // Z_BG_SINKAI_KABE_H diff --git a/src/overlays/actors/ovl_Bg_Spdweb/overlay.cfg b/src/overlays/actors/ovl_Bg_Spdweb/overlay.cfg deleted file mode 100644 index 9411f4092..000000000 --- a/src/overlays/actors/ovl_Bg_Spdweb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Spdweb -z_bg_spdweb.c 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 5e3eed13b..fb8d464c8 100644 --- a/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c +++ b/src/overlays/actors/ovl_Bg_Spdweb/z_bg_spdweb.c @@ -11,20 +11,20 @@ #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 = { +ActorInit Bg_Spdweb_InitVars = { ACTOR_BG_SPDWEB, ACTORCAT_BG, FLAGS, @@ -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)) { - Actor_MarkForDeath(&this->dyna.actor); + if (Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&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) { @@ -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; @@ -230,7 +230,7 @@ void func_809CE234(BgSpdweb* this, GlobalContext* globalCtx) { if (this->unk_162 == 0) { ActorCutscene_Stop(this->dyna.actor.cutscene); - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } @@ -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; @@ -278,11 +278,11 @@ void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { sp40.x = this->dyna.actor.world.pos.x; sp40.y = this->dyna.actor.world.pos.y - 50.0f; sp40.z = this->dyna.actor.world.pos.z; - sp3A = player->unk_B6A; + sp3A = player->fallDistance; - 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; } @@ -311,7 +311,7 @@ void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { this->unk_164 = temp_f12; this->unk_162 = 12; if (sp3A > 50) { - player->stateFlags1 |= 0x20; + player->stateFlags1 |= PLAYER_STATE1_20; this->unk_161 = 1; } } else if (player->actor.speedXZ != 0.0f) { @@ -330,15 +330,15 @@ void func_809CE4C8(BgSpdweb* this, GlobalContext* globalCtx) { if ((this->unk_161 != 0) || ((DynaPolyActor_IsInRidingMovingState(&this->dyna) != 0) && (this->unk_164 > 2.0f))) { player->actor.velocity.y = this->unk_164 * 0.7f; - player->unk_B68 = (SQ(this->unk_164) * 0.15f) + this->dyna.actor.world.pos.y; + player->fallStartHeight = (SQ(this->unk_164) * 0.15f) + this->dyna.actor.world.pos.y; this->unk_161 = 0; - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_20; } } else if (this->unk_162 == 11) { if (this->unk_164 > 3.0f) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_WEB_VIBRATION); } else { - func_801A75E8(NA_SE_EV_WEB_VIBRATION); + 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--; @@ -376,59 +373,52 @@ void func_809CE830(BgSpdweb* this, GlobalContext* globalCtx) { if (ActorCutscene_GetLength(this->dyna.actor.cutscene) == -1) { ActorCutscene_Stop(this->dyna.actor.cutscene); } - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } if ((this->unk_162 % 3) == 0) { temp_s3 = Rand_ZeroOne() * 0x2AAA; - spB0 = Math_CosS(this->dyna.actor.shape.rot.x); - temp_f20 = Math_SinS(this->dyna.actor.shape.rot.x); - temp_f30 = Math_CosS(this->dyna.actor.shape.rot.y); - spA4 = Math_SinS(this->dyna.actor.shape.rot.y); - if (1) {} + 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; @@ -460,8 +450,8 @@ void func_809CEBC0(BgSpdweb* this, GlobalContext* globalCtx) { this->dyna.actor.world.pos.z; } func_809CEE74(this); - } else if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { - Math_Vec3f_Diff(&player->swordInfo[0].tip, &this->dyna.actor.world.pos, &sp3C); + } else if ((player->heldItemAction == PLAYER_IA_STICK) && (player->unk_B28 != 0)) { + 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_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..c57353ce0 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,17 +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; - #endif // Z_BG_SPDWEB_H diff --git a/src/overlays/actors/ovl_Bg_Spout_Fire/overlay.cfg b/src/overlays/actors/ovl_Bg_Spout_Fire/overlay.cfg deleted file mode 100644 index bad8eedab..000000000 --- a/src/overlays/actors/ovl_Bg_Spout_Fire/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Spout_Fire -z_bg_spout_fire.c 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..fdf56d87c 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,21 +5,24 @@ */ #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 = { +ActorInit Bg_Spout_Fire_InitVars = { ACTOR_BG_SPOUT_FIRE, ACTORCAT_BG, FLAGS, @@ -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..5cbf36a05 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,14 +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; - #endif // Z_BG_SPOUT_FIRE_H diff --git a/src/overlays/actors/ovl_Bg_Tobira01/overlay.cfg b/src/overlays/actors/ovl_Bg_Tobira01/overlay.cfg deleted file mode 100644 index 7b142082d..000000000 --- a/src/overlays/actors/ovl_Bg_Tobira01/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Tobira01 -z_bg_tobira01.c 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..d6617ef1c 100644 --- a/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c +++ b/src/overlays/actors/ovl_Bg_Tobira01/z_bg_tobira01.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Bg_Tobira01_InitVars = { ACTOR_BG_TOBIRA01, ACTORCAT_PROP, FLAGS, @@ -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; @@ -38,22 +38,21 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { ActorCutscene_Stop(0x7C); } else if (ActorCutscene_GetCanPlayNext(cutsceneId)) { ActorCutscene_StartAndSetUnkLinkFields(cutsceneId, &this->dyna.actor); - gSaveContext.save.weekEventReg[88] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_88_40); this->playCutscene = false; } 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40) && (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 } prevTimer = this->timer; - if (gSaveContext.save.weekEventReg[88] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40)) { this->timer++; } else { this->timer--; @@ -68,44 +67,45 @@ void BgTobira01_Open(BgTobira01* this, GlobalContext* globalCtx) { this->timer2 = 180; } - if (!(player->stateFlags1 & 0x40) && (gSaveContext.save.weekEventReg[88] & 0x40) && (DECR(this->timer2) == 0)) { - gSaveContext.save.weekEventReg[88] &= (u8)~0x40; + if (!(player->stateFlags1 & PLAYER_STATE1_40) && CHECK_WEEKEVENTREG(WEEKEVENTREG_88_40) && + (DECR(this->timer2) == 0)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_88_40); } } -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); - gSaveContext.save.weekEventReg[88] &= (u8)~0x40; + DynaPolyActor_LoadMesh(play, &this->dyna, &object_spot11_obj_Colheader_0011C0); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_88_40); Actor_SetScale(&this->dyna.actor, 1.0f); this->timer2 = gSaveContext.save.isNight; this->timer = 0; 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..14a5e1b8e 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; @@ -17,6 +17,4 @@ typedef struct BgTobira01 { /* 0x16C */ s32 unk_16C; // unused besides being set to 0 } BgTobira01; // size = 0x170 -extern const ActorInit Bg_Tobira01_InitVars; - #endif // Z_BG_TOBIRA01_H diff --git a/src/overlays/actors/ovl_Bg_Umajump/overlay.cfg b/src/overlays/actors/ovl_Bg_Umajump/overlay.cfg deleted file mode 100644 index 3678ab523..000000000 --- a/src/overlays/actors/ovl_Bg_Umajump/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Bg_Umajump -z_bg_umajump.c 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..bef32aedd 100644 --- a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c +++ b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.c @@ -5,17 +5,20 @@ */ #include "z_bg_umajump.h" +#include "assets/objects/object_umajump/object_umajump.h" #define FLAGS 0x00000000 #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); +void BgUmajump_Draw(Actor* thisx, PlayState* play); -#if 0 -const ActorInit Bg_Umajump_InitVars = { +void func_8091A5A0(Actor* thisx, PlayState* play); + +ActorInit Bg_Umajump_InitVars = { ACTOR_BG_UMAJUMP, ACTORCAT_PROP, FLAGS, @@ -27,34 +30,190 @@ const ActorInit Bg_Umajump_InitVars = { (ActorFunc)NULL, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8091A810[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 300, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80919F30(BgUmajump* this, PlayState* play) { + if (this->rotationTimer >= 90) { + this->rotationTimer = 0; + } -extern InitChainEntry D_8091A810[]; + this->rotationTimer++; + this->dyna.actor.shape.yOffset = + Math_SinS((this->rotationTimer / 90.0f) * 0x10000) * (20.0f / this->dyna.actor.scale.y); +} -extern UNK_TYPE D_06001220; -extern UNK_TYPE D_06001558; +void BgUmajump_StopCutscene(BgUmajump* this, PlayState* play) { + if ((play->csCtx.frames >= 6) && !this->hasSoundPlayed) { + this->hasSoundPlayed = true; + play_sound(NA_SE_EV_KID_HORSE_NEIGH); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/func_80919F30.s") + if (play->csCtx.state == CS_STATE_0) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + this->dyna.actor.update = Actor_Noop; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/func_80919FC8.s") +void BgUmajump_PlayCutscene(BgUmajump* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + SET_WEEKEVENTREG(WEEKEVENTREG_89_20); + this->actionFunc = BgUmajump_StopCutscene; + } else { + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/func_8091A044.s") +void BgUmajump_CheckDistance(BgUmajump* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/func_8091A0B8.s") + if ((this->horse != NULL) && (player != NULL) && + (Math3D_XZDistance(this->horse->world.pos.x, this->horse->world.pos.z, player->actor.world.pos.x, + player->actor.world.pos.z) < 1400.0f)) { + this->actionFunc = BgUmajump_PlayCutscene; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/BgUmajump_Init.s") +void BgUmajump_Init(Actor* thisx, PlayState* play) { + BgUmajump* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/BgUmajump_Destroy.s") + Actor_ProcessInitChain(thisx, sInitChain); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/BgUmajump_Update.s") + this->actionFunc = NULL; + this->horse = NULL; + this->hasSoundPlayed = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/func_8091A5A0.s") + DynaPolyActor_Init(&this->dyna, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Umajump/func_8091A7B0.s") + this->objectIndex = BG_UMAJUMP_GET_OBJECT_INDEX(thisx); + thisx->params = BG_UMAJUMP_GET_FF(thisx); + + if ((thisx->params == BG_UMAJUMP_TYPE_2)) { + if ((((play->sceneId == SCENE_F01) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_89_20)) && + !CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) && + (thisx->cutscene != -1)) { + this->actionFunc = BgUmajump_CheckDistance; + thisx->update = func_8091A5A0; + thisx->flags |= ACTOR_FLAG_10; + this->horse = SubS_FindActor(play, this->horse, ACTORCAT_BG, ACTOR_EN_HORSE); + } else { + thisx->update = Actor_Noop; + } + } else { + this->objectIndex = Object_GetIndex(&play->objectCtx, OBJECT_UMAJUMP); + + if (this->objectIndex < 0) { + Actor_Kill(thisx); + } + + if ((thisx->params == BG_UMAJUMP_TYPE_3) && CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_KANBAN, thisx->world.pos.x, thisx->world.pos.y, + thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, thisx->shape.rot.z, 0x3E); + Actor_Kill(thisx); + } + } +} + +void BgUmajump_Destroy(Actor* thisx, PlayState* play) { + BgUmajump* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void BgUmajump_Update(Actor* thisx, PlayState* play) { + BgUmajump* this = THIS; + + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->dyna.actor.objBankIndex = this->objectIndex; + this->dyna.actor.draw = BgUmajump_Draw; + + Actor_SetObjectDependency(play, &this->dyna.actor); + + if (this->dyna.actor.params == BG_UMAJUMP_TYPE_5) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001558); + } + } else if (this->dyna.actor.params == BG_UMAJUMP_TYPE_6) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001558); + } + } else if ((this->dyna.actor.params == BG_UMAJUMP_TYPE_4) || (this->dyna.actor.params == BG_UMAJUMP_TYPE_3)) { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001558); + } else { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001438); + } + + if (this->dyna.actor.params == BG_UMAJUMP_TYPE_1) { + this->rotationTimer = 0; + this->actionFunc = func_80919F30; + this->dyna.actor.update = func_8091A5A0; + } else if (this->dyna.actor.params == BG_UMAJUMP_TYPE_3) { + this->dyna.actor.update = func_8091A5A0; + } else if ((this->dyna.actor.params == BG_UMAJUMP_TYPE_5) || (this->dyna.actor.params == BG_UMAJUMP_TYPE_6)) { + if (this->dyna.actor.params == BG_UMAJUMP_TYPE_5) { + if ((this->dyna.bgId == BGACTOR_NEG_ONE) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001558); + } + } else if ((this->dyna.actor.params == BG_UMAJUMP_TYPE_6) && (this->dyna.bgId == BGACTOR_NEG_ONE) && + (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01) || + ((gSaveContext.save.day == 2) && (gSaveContext.save.isNight == true) && + ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && + (gSaveContext.save.time <= CLOCK_TIME(6, 0)))))) { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001558); + } + func_800C641C(play, &play->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.update = func_8091A5A0; + } else if (this->dyna.actor.params == BG_UMAJUMP_TYPE_4) { + func_800C641C(play, &play->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.update = Actor_Noop; + } else { + this->dyna.actor.update = Actor_Noop; + } + } +} + +void func_8091A5A0(Actor* thisx, PlayState* play) { + BgUmajump* this = THIS; + + if (this->actionFunc != NULL) { + this->actionFunc(this, play); + } + + if ((this->dyna.actor.params == BG_UMAJUMP_TYPE_3) && CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_KANBAN, 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, 0x3E); + Actor_Kill(&this->dyna.actor); + } + + if (this->dyna.actor.params == BG_UMAJUMP_TYPE_5) { + if ((this->dyna.bgId == BGACTOR_NEG_ONE) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001558); + } else if ((this->dyna.bgId != BGACTOR_NEG_ONE) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } + } else if (this->dyna.actor.params == BG_UMAJUMP_TYPE_6) { + if ((this->dyna.bgId == BGACTOR_NEG_ONE) && + (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01) || + ((gSaveContext.save.day == 2) && (gSaveContext.save.isNight == true) && + (gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= CLOCK_TIME(6, 0))))) { + DynaPolyActor_LoadMesh(play, &this->dyna, &object_umajump_Colheader_001558); + } else if ((this->dyna.bgId != BGACTOR_NEG_ONE) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01) && + ((gSaveContext.save.day != 2) || (gSaveContext.save.isNight != true) || + (gSaveContext.save.time < CLOCK_TIME(5, 30)) || (gSaveContext.save.time > CLOCK_TIME(6, 0)))) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } + } +} + +void BgUmajump_Draw(Actor* thisx, PlayState* play) { + BgUmajump* this = THIS; + + if (this->dyna.bgId != BGACTOR_NEG_ONE) { + Gfx_DrawDListOpa(play, gHorseJumpFenceDL); + } +} diff --git a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.h b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.h index 22fe9ca44..62aaf6cb7 100644 --- a/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.h +++ b/src/overlays/actors/ovl_Bg_Umajump/z_bg_umajump.h @@ -3,13 +3,31 @@ #include "global.h" +#define BG_UMAJUMP_GET_OBJECT_INDEX(thisx) (((thisx)->params >> 8) & 0xFF) +#define BG_UMAJUMP_GET_FF(thisx) ((thisx)->params & 0xFF) + +typedef enum { + BG_UMAJUMP_TYPE_1 = 1, + BG_UMAJUMP_TYPE_2, + BG_UMAJUMP_TYPE_3, + BG_UMAJUMP_TYPE_4, + BG_UMAJUMP_TYPE_5, + BG_UMAJUMP_TYPE_6, +} BgUmaJumpType; + struct BgUmajump; +typedef void (*BgUmajumpActionFunc)(struct BgUmajump*, PlayState*); + typedef struct BgUmajump { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x28]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgUmajumpActionFunc actionFunc; + /* 0x160 */ union { + s32 objectIndex; + s32 rotationTimer; // y rotation + }; + /* 0x164 */ s32 hasSoundPlayed; + /* 0x168 */ Actor* horse; } BgUmajump; // size = 0x16C -extern const ActorInit Bg_Umajump_InitVars; - #endif // Z_BG_UMAJUMP_H diff --git a/src/overlays/actors/ovl_Boss_01/overlay.cfg b/src/overlays/actors/ovl_Boss_01/overlay.cfg deleted file mode 100644 index d11a70ed1..000000000 --- a/src/overlays/actors/ovl_Boss_01/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Boss_01 -z_boss_01.c 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..8d13ab6d3 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,39 @@ */ #include "z_boss_01.h" +#include "z64rumble.h" +#include "z64shrink_window.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 +131,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 +145,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 +199,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 +217,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 = { @@ -232,7 +234,7 @@ static ColliderCylinderInit D_809D7CA0 = { { 8, 15, 10, { 0, 0, 0 } }, }; -const ActorInit Boss_01_InitVars = { +ActorInit Boss_01_InitVars = { ACTOR_BOSS_01, ACTORCAT_BOSS, FLAGS, 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..37c8d4b00 100644 --- a/src/overlays/actors/ovl_Boss_01/z_boss_01.h +++ b/src/overlays/actors/ovl_Boss_01/z_boss_01.h @@ -5,15 +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; - #endif // Z_BOSS_01_H diff --git a/src/overlays/actors/ovl_Boss_02/overlay.cfg b/src/overlays/actors/ovl_Boss_02/overlay.cfg deleted file mode 100644 index 6bf46fe21..000000000 --- a/src/overlays/actors/ovl_Boss_02/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Boss_02 -z_boss_02.c 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 12d59b530..f28c3cd34 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -6,43 +6,44 @@ #include "prevent_bss_reordering.h" #include "z_boss_02.h" +#include "z64rumble.h" +#include "z64shrink_window.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/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* play2); -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 +78,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), @@ -112,7 +113,7 @@ static DamageTable sDamageTable2 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -const ActorInit Boss_02_InitVars = { +ActorInit Boss_02_InitVars = { ACTOR_BOSS_02, ACTORCAT_BOSS, FLAGS, @@ -120,21 +121,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 +389,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 +427,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -450,88 +451,88 @@ 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) { - MREG(64) = 1; - MREG(65) = arg1; - MREG(66) = arg2; - MREG(67) = arg3; - MREG(68) = arg4; +void func_809DA1D0(PlayState* play, u8 red, u8 green, u8 blue, u8 alpha) { + R_PLAY_FILL_SCREEN_ON = true; + R_PLAY_FILL_SCREEN_R = red; + R_PLAY_FILL_SCREEN_G = green; + R_PLAY_FILL_SCREEN_B = blue; + R_PLAY_FILL_SCREEN_ALPHA = alpha; } -void func_809DA22C(GlobalContext* globalCtx, u8 arg1) { - MREG(68) = arg1; +void func_809DA22C(PlayState* play, u8 alpha) { + R_PLAY_FILL_SCREEN_ALPHA = alpha; } -void func_809DA24C(GlobalContext* globalCtx) { - MREG(64) = 0; +void func_809DA24C(PlayState* play) { + R_PLAY_FILL_SCREEN_ON = false; } -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 +546,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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) && (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) || CHECK_EVENTINF(EVENTINF_55) || (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; + R_MAGIC_CONSUME_TIMER_GIANTS_MASK = 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; + this->actor.hintId = TATL_HINT_ID_TWINMOLD; } 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, &gTwinmoldHeadSkel, &gTwinmoldHeadFlyAnim, this->jointTable, + SkelAnime_Init(play, &this->skelAnime, &gTwinmoldHeadSkel, &gTwinmoldHeadFlyAnim, this->jointTable, this->morphTable, TWINMOLD_HEAD_LIMB_MAX); - Collider_InitAndSetJntSph(globalCtx, &this->colliderSphere1, &this->actor, &sJntSphInit1, + 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 +620,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, &gTwinmoldHeadFlyAnim, 0.0f); - if (D_809E042C->unk_1D20 != 0) { + if (sTwinmoldStatic->unk_1D20 != 0) { this->unk_0144 = 10; } else { this->unk_0144 = 100; this->unk_01A8 = 25.0f; - D_809E042C->unk_1D7E = 100; + sTwinmoldStatic->unk_1D7E = 100; this->actor.world.pos.x = 0.0f; - if (D_809E0424 == this) { + if (sRedTwinmold == this) { this->actor.world.pos.z = -1000.0f; } else { this->actor.world.pos.z = 1400.0f; @@ -654,10 +655,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 +670,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 +697,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 +720,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 +756,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 +778,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 +811,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 +828,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 +850,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 +868,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 +898,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; @@ -917,7 +919,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { 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 +937,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 +952,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 +978,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 +994,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 +1002,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; @@ -1028,8 +1030,8 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { 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); + 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; @@ -1038,7 +1040,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); } @@ -1050,17 +1052,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; @@ -1080,7 +1082,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; @@ -1088,7 +1090,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; @@ -1096,23 +1098,23 @@ void func_809DBFB4(Boss02* this, GlobalContext* globalCtx) { } while (0); if ((s8)this->actor.colChkInfo.health <= 0) { - Actor_MarkForDeath(this->actor.child); + Actor_Kill(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; } @@ -1120,12 +1122,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; } } } @@ -1134,24 +1136,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; @@ -1159,19 +1160,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]--; @@ -1196,7 +1197,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)) { @@ -1208,25 +1209,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) { @@ -1277,27 +1278,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); @@ -1306,36 +1307,38 @@ 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[] = { - gTwinmoldBodySegment1DL, gTwinmoldBodySegment2DL, gTwinmoldBodySegment3DL, gTwinmoldBodySegment4DL, - gTwinmoldBodySegment5DL, gTwinmoldBodySegment6DL, gTwinmoldBodySegment7DL, gTwinmoldBodySegment8DL, - gTwinmoldBodySegment9DL, gTwinmoldBodySegment10DL, gTwinmoldBodySegment11DL, gTwinmoldBodySegment12DL, - gTwinmoldBodySegment13DL, gTwinmoldBodySegment14DL, gTwinmoldBodySegment15DL, gTwinmoldBodySegment16DL, - gTwinmoldBodySegment17DL, gTwinmoldBodySegment18DL, gTwinmoldBodySegment19DL, gTwinmoldBodySegment20DL, - gTwinmoldBodySegment21DL, gTwinmoldBodyTailDL, - }; - static Vec3f D_809DFAF4 = { -10000.0f, -100000.0f, -100000.0f }; - 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; - Mtx* mtx; - Mtx* mtxIter; + Mtx* mtxHead = GRAPH_ALLOC(play->state.gfxCtx, 23 * sizeof(Mtx)); + Mtx* mtx = mtxHead; s32 phi_v0; f32 phi_f12; f32 spAC; @@ -1345,11 +1348,9 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { f32 sp9C; f32 sp98; - mtxIter = mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 23); + OPEN_DISPS(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); - - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->actor.params == 0) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldRedSkinTex)); @@ -1357,9 +1358,9 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldBlueSkinTex)); } - gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtxHead); - if (D_809E0422 == 0) { + if (!sIsInGiantMode) { sp98 = -500.0f; } else { sp98 = 3100.0f; @@ -1389,12 +1390,12 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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; - for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++, mtxIter++) { + for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++, mtx++) { if (this->unk_0195 != 0) { phi_v0 = (D_809DF5E4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } else { @@ -1413,9 +1414,9 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_RotateYF(M_PI / 2, MTXMODE_APPLY); Matrix_RotateXFApply(-(M_PI / 2)); - Matrix_ToMtx(mtxIter); + Matrix_ToMtx(mtx); - gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if ((this->unk_0156 & 1) && (i >= this->unk_0158) && (this->unk_015A >= i)) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); @@ -1425,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) { @@ -1444,16 +1445,16 @@ void Boss02_Draw(Actor* thisx, GlobalContext* globalCtx2) { } 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 { @@ -1462,186 +1463,184 @@ 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++, 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_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + 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++, 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_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_RotateYS(effect->unk_30, MTXMODE_APPLY); - Matrix_RotateXS(effect->unk_2E, MTXMODE_APPLY); - Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, + + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYS(effect->rotY, MTXMODE_APPLY); + Matrix_RotateXS(effect->rotX, MTXMODE_APPLY); + Matrix_Scale(effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, effect->scale * D_809DF5B0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(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); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbMaterial1DL); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 128); } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->unk_2C); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)effect->alpha); - Matrix_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&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++, gLightOrbVtxDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbModelDL); } } - 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++, 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_Translate(effect->unk_00.x, effect->unk_00.y, effect->unk_00.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(effect->unk_34 * D_809DF5B0, effect->unk_34 * D_809DF5B0, 1.0f, MTXMODE_APPLY); + 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++, 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; u8 sp57 = 0; f32 phi_f0_2; - s16 phi_v1; + s16 alpha; this->unk_1D14++; 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); + if (player->stateFlags1 & PLAYER_STATE1_100) { + 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; @@ -1663,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; } @@ -1705,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; @@ -1722,40 +1721,40 @@ 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; + player->stateFlags1 &= ~PLAYER_STATE1_100; this->unk_1D70 = 0.01f; func_80165690(); break; @@ -1767,178 +1766,178 @@ 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; player->actor.world.pos.y -= 3150.0f; player->actor.world.pos.y *= 10.0f; - player->unk_B68 = player->actor.world.pos.y; + player->fallStartHeight = 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; player->actor.world.pos.y *= 0.1f; player->actor.world.pos.y += 3150.0f; - player->unk_B68 = player->actor.world.pos.y; + player->fallStartHeight = 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); + Actor_Kill(temp_a0_5); break; } 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; @@ -1986,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); @@ -1995,11 +1994,9 @@ void func_809DD934(Boss02* this, GlobalContext* globalCtx) { if (this->unk_1D7A >= 400) { this->unk_1D78 = 3; } - phi_v1 = this->unk_1D7A; - if (phi_v1 > 255) { - phi_v1 = 255; - } - func_809DA22C(globalCtx, phi_v1); + alpha = this->unk_1D7A; + alpha = CLAMP_MAX(alpha, 255); + func_809DA22C(play, alpha); break; case 3: @@ -2007,48 +2004,46 @@ 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); + alpha = this->unk_1D7A; + alpha = CLAMP_MAX(alpha, 255); + func_809DA22C(play, alpha); } break; } - if ((this->unk_1D18 != 0) && (this->unk_1D22 != 0)) { + if ((this->unk_1D18 != 0) && (this->subCamId != SUB_CAM_ID_DONE)) { Matrix_RotateYS(player->actor.shape.rot.y, MTXMODE_NEW); Matrix_MultVecZ(this->unk_1D64, &sp58); - this->unk_1D24.x = player->actor.world.pos.x + sp58.x; - this->unk_1D24.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; - this->unk_1D24.z = player->actor.world.pos.z + sp58.z; + this->subCamEye.x = player->actor.world.pos.x + sp58.x; + this->subCamEye.y = player->actor.world.pos.y + sp58.y + this->unk_1D68; + this->subCamEye.z = player->actor.world.pos.z + sp58.z; - this->unk_1D30.x = player->actor.world.pos.x; - this->unk_1D30.y = player->actor.world.pos.y + this->unk_1D6C; - this->unk_1D30.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = player->actor.world.pos.y + this->unk_1D6C; + this->subCamAt.z = player->actor.world.pos.z; this->unk_1D54 = Math_SinS(this->unk_1D14 * 1512) * this->unk_1D58; Matrix_RotateZF(this->unk_1D54, MTXMODE_APPLY); - Matrix_MultVecY(1.0f, &this->unk_1D3C); - Play_CameraSetAtEyeUp(globalCtx, this->unk_1D22, &this->unk_1D30, &this->unk_1D24, &this->unk_1D3C); - ShrinkWindow_SetLetterboxTarget(27); + Matrix_MultVecY(1.0f, &this->subCamUp); + Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); + ShrinkWindow_Letterbox_SetSizeTarget(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) { @@ -2056,34 +2051,34 @@ void func_809DEAC4(Boss02* this, GlobalContext* globalCtx) { break; case 1: - if ((gSaveContext.save.weekEventReg[52] & 0x20) || ((u32)(KREG(13) + 15) >= this->unk_1D1C)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) || ((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_RotateZF(Math_SinS(this->unk_1D1C * 0x3000) * ((KREG(28) * 0.001f) + 0.017f), MTXMODE_NEW); - Matrix_MultVecY(1.0f, &this->unk_1D3C); + Matrix_MultVecY(1.0f, &this->subCamUp); func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG); } @@ -2092,21 +2087,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, PLAYER_CSMODE_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, PLAYER_CSMODE_115); } if (this->unk_1D1C == 112) { @@ -2117,53 +2112,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, + 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, PLAYER_CSMODE_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; - gSaveContext.eventInf[5] |= 0x20; + sRedTwinmold->unk_0144 = sBlueTwinmold->unk_0144 = 3; + sRedTwinmold->unk_0146[0] = sBlueTwinmold->unk_0146[0] = 60; + SET_EVENTINF(EVENTINF_55); } 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; } @@ -2172,30 +2167,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: @@ -2203,47 +2198,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, PLAYER_CSMODE_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; - ShrinkWindow_SetLetterboxTarget(27); + 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_Letterbox_SetSizeTarget(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 6c20814fb..e7efc1199 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.h +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.h @@ -6,21 +6,36 @@ 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; @@ -60,7 +75,7 @@ typedef struct Boss02 { /* 0x15D4 */ Vec3s jointTable[TWINMOLD_HEAD_LIMB_MAX]; /* 0x1622 */ Vec3s morphTable[TWINMOLD_HEAD_LIMB_MAX]; /* 0x1670 */ Boss02ActionFunc actionFunc; - /* 0x1674 */ struct Boss02* unk_1674; // points to the other's instance + /* 0x1674 */ struct Boss02* otherTwinmold; // points to the other's instance /* 0x1678 */ s32 unk_1678; /* 0x167C */ Vec3f unk_167C; /* 0x1688 */ ColliderJntSph colliderSphere1; @@ -73,14 +88,14 @@ typedef struct Boss02 { /* 0x1D1A */ s16 unk_1D1A; /* 0x1D1C */ u32 unk_1D1C; /* 0x1D20 */ s16 unk_1D20; - /* 0x1D22 */ s16 unk_1D22; - /* 0x1D24 */ Vec3f unk_1D24; - /* 0x1D30 */ Vec3f unk_1D30; - /* 0x1D3C */ Vec3f unk_1D3C; - /* 0x1D48 */ Vec3f unk_1D48; + /* 0x1D22 */ s16 subCamId; + /* 0x1D24 */ Vec3f subCamEye; + /* 0x1D30 */ Vec3f subCamAt; + /* 0x1D3C */ Vec3f subCamUp; + /* 0x1D48 */ Vec3f subCamAtNext; /* 0x1D54 */ f32 unk_1D54; /* 0x1D58 */ f32 unk_1D58; - /* 0x1D5C */ f32 unk_1D5C; + /* 0x1D5C */ f32 subCamAtVel; /* 0x1D60 */ UNK_TYPE1 unk1D60[0x4]; /* 0x1D64 */ f32 unk_1D64; /* 0x1D68 */ f32 unk_1D68; @@ -93,6 +108,4 @@ typedef struct Boss02 { /* 0x1D7E */ s16 unk_1D7E; } Boss02; // size = 0x1D80 -extern const ActorInit Boss_02_InitVars; - #endif // Z_BOSS_02_H diff --git a/src/overlays/actors/ovl_Boss_03/overlay.cfg b/src/overlays/actors/ovl_Boss_03/overlay.cfg deleted file mode 100644 index 285cc5587..000000000 --- a/src/overlays/actors/ovl_Boss_03/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Boss_03 -z_boss_03.c 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 1959ba26b..4c3b34fbb 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -7,10 +7,6 @@ /** * Some notes: * - * Global flags: - * - gSaveContext.eventInf[5] & 0x40: Enabled when Gyorg's intro cutscene has been watched - * - gSaveContext.save.weekEventReg[55] & 0x80: Checked to know if Gyorg has been defeated - * * Seaweed: * - Refers to the seaweed at the bottom of the stage where Player fights Gyorg * - The default Gyorg actor will spawn 5 other Gyorg instances using the parameter GYORG_PARAM_SEAWEED to spawn them @@ -52,7 +48,7 @@ * - Effect Update/Draw * - Seaweed */ - +#include "prevent_bss_reordering.h" #include "z_boss_03.h" #include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h" #include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h" @@ -77,37 +73,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* play2); +void Boss03_Destroy(Actor* thisx, PlayState* play); +void Boss03_Update(Actor* thisx, PlayState* play2); +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 +126,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 +147,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 +171,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 +195,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 +259,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) { @@ -278,7 +274,7 @@ Actor* Boss03_FindActorDblueMovebg(GlobalContext* globalCtx) { /* Start of Gyorg's Init and actionFuncs section */ -const ActorInit Boss_03_InitVars = { +ActorInit Boss_03_InitVars = { ACTOR_BOSS_03, ACTORCAT_BOSS, FLAGS, @@ -421,7 +417,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,23 +437,23 @@ 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_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + 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_Kill(&this->actor); return; } @@ -497,13 +493,13 @@ void Boss03_Init(Actor* thisx, GlobalContext* globalCtx2) { 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,21 +509,19 @@ 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 - if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x40)) { + // CHECK_EVENTINF(EVENTINF_56): intro cutscene already watched + if ((KREG(64) != 0) || CHECK_EVENTINF(EVENTINF_56)) { this->actionFunc = func_809E344C; D_809E9842 = false; Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); } else { - Boss03_SetupIntroCutscene(this, globalCtx); + Boss03_SetupIntroCutscene(this, play); D_809E9842 = true; } @@ -535,14 +529,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 +550,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); @@ -581,10 +575,10 @@ void func_809E34B8(Boss03* this, GlobalContext* globalCtx) { yDiff = this->unk_268.y - this->actor.world.pos.y; zDiff = this->unk_268.z - this->actor.world.pos.z; - Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.x, Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); bodyYRotTarget = - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Atan2S_XY(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); @@ -626,18 +620,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 +644,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; @@ -670,9 +664,9 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { yDiff = (player->actor.world.pos.y - this->actor.world.pos.y) + 50.0f; zDiff = player->actor.world.pos.z - this->actor.world.pos.z; - Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.x, Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); bodyYRotTarget = - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Atan2S_XY(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f; Math_ApproachS(&this->bodyYRot, bodyYRotTarget, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); @@ -690,10 +684,10 @@ void Boss03_ChasePlayer(Boss03* this, GlobalContext* globalCtx) { if (&this->actor == player->actor.parent) { player->unk_AE8 = 101; player->actor.parent = NULL; - player->csMode = 0; + player->csMode = 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) { @@ -722,11 +716,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_TYPE_GYORG_RIPPLES); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_SINK_OLD); } @@ -734,10 +728,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; @@ -746,8 +740,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; @@ -766,9 +760,9 @@ void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { yDiff = player->actor.world.pos.y - this->actor.world.pos.y; zDiff = player->actor.world.pos.z - this->actor.world.pos.z; - Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.x, Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); Math_ApproachS(&this->bodyYRot, - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Atan2S_XY(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); @@ -785,11 +779,11 @@ void Boss03_CatchPlayer(Boss03* this, GlobalContext* globalCtx) { if (&this->actor == player->actor.parent) { player->unk_AE8 = 101; player->actor.parent = NULL; - player->csMode = 0; + player->csMode = PLAYER_CSMODE_0; func_80165690(); } - func_809E344C(this, globalCtx); + func_809E344C(this, play); // WORK_TIMER_UNK1_A wasn't set } else { f32 phi_f0; @@ -807,11 +801,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); @@ -823,16 +817,16 @@ 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); + pitchAngle = Math_Atan2S_XY(this->actor.world.pos.z, this->actor.world.pos.x); Matrix_RotateYS(pitchAngle, MTXMODE_NEW); out.x = 0.0f; @@ -846,9 +840,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; @@ -870,9 +864,9 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { yDiff = this->unk_268.y - this->actor.world.pos.y; zDiff = this->unk_268.z - this->actor.world.pos.z; - Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.x, Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); Math_ApproachS(&this->bodyYRot, - Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274, 0) * + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Atan2S_XY(zDiff, xDiff), 0xA, this->unk_274, 0) * -0.5f, 5, 0x100); Math_ApproachS(&this->unk_274, this->unk_276, 1, 0x100); @@ -913,12 +907,12 @@ void Boss03_ChewPlayer(Boss03* this, GlobalContext* globalCtx) { if (&this->actor == player->actor.parent) { player->unk_AE8 = 101; player->actor.parent = NULL; - player->csMode = 0; + player->csMode = 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; @@ -945,7 +939,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; @@ -966,9 +960,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); @@ -994,10 +988,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; } @@ -1006,8 +1000,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); @@ -1017,11 +1011,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; @@ -1032,9 +1026,9 @@ void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { yDiff = (this->unk_268.y - this->actor.world.pos.y) - 50.0f; zDiff = this->unk_268.z - this->actor.world.pos.z; - Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, 0x1000); + Math_ApproachS(&this->actor.world.rot.y, Math_Atan2S_XY(zDiff, xDiff), 0xA, 0x1000); - rotXTarget = Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff); + rotXTarget = Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff); Math_ApproachS(&this->actor.world.rot.x, rotXTarget, 0xA, 0x1000); this->actor.shape.rot = this->actor.world.rot; @@ -1047,7 +1041,7 @@ void Boss03_Charge(Boss03* this, GlobalContext* globalCtx) { // 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; } } @@ -1055,23 +1049,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_TYPE_GYORG_SHOCKWAVE); // 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_Atan2S_XY(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; @@ -1079,7 +1073,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); @@ -1095,7 +1089,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 { @@ -1106,7 +1100,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); } } } @@ -1115,7 +1109,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; @@ -1127,7 +1121,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; @@ -1139,7 +1133,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++; @@ -1150,11 +1144,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, PLAYER_CSMODE_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; @@ -1167,34 +1161,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); @@ -1203,9 +1197,9 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { yDiff = D_809E9104[this->unk_242].y - this->actor.world.pos.y; zDiff = D_809E9104[this->unk_242].z - this->actor.world.pos.z; - Math_ApproachS(&this->actor.world.rot.x, Math_FAtan2F(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), - 0xA, this->unk_274); - Math_ApproachS(&this->actor.world.rot.y, Math_FAtan2F(zDiff, xDiff), 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.x, + Math_Atan2S_XY(sqrtf(SQ(xDiff) + SQ(zDiff)), -yDiff), 0xA, this->unk_274); + Math_ApproachS(&this->actor.world.rot.y, Math_Atan2S_XY(zDiff, xDiff), 0xA, this->unk_274); Math_ApproachS(&this->unk_274, 0x200, 1, 0x10); if ((this->csTimer > 30) && (this->csTimer < 50)) { @@ -1262,23 +1256,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, PLAYER_CSMODE_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; @@ -1295,13 +1289,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; @@ -1321,7 +1315,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); } @@ -1344,42 +1338,42 @@ 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, PLAYER_CSMODE_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; + SET_EVENTINF(EVENTINF_56); } break; } @@ -1397,26 +1391,26 @@ void Boss03_IntroCutscene(Boss03* this, GlobalContext* globalCtx) { Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); Matrix_RotateYF(sp5C, MTXMODE_APPLY); Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); - Matrix_MultVecZ(100.0f, &this->csCamAt); + Matrix_MultVecZ(100.0f, &this->subCamAt); - this->csCamEye = this->actor.world.pos; + this->subCamEye = this->actor.world.pos; for (i = 0; i < bubblesToSpawnNum; i++) { - effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.x; - effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.y) - 150.0f; - effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->csCamAt.z; + effectPos.x = randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.x; + effectPos.y = (randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.y) - 150.0f; + effectPos.z = randPlusMinusPoint5Scaled(100.0f) + this->subCamAt.z; - Boss03_SpawnEffectBubble(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); @@ -1427,7 +1421,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; @@ -1437,12 +1431,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++; @@ -1450,12 +1444,12 @@ 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); - this->unk_2BE = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x); + Cutscene_Start(play, &play->csCtx); + func_800B7298(play, &this->actor, PLAYER_CSMODE_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_Atan2S_XY(this->actor.world.pos.z, this->actor.world.pos.x); // Player is above water && Player is standing on ground if ((this->waterHeight < player->actor.world.pos.y) && (player->actor.bgCheckFlags & 1)) { @@ -1466,15 +1460,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_Atan2F_XY(this->subCamEye.z - this->actor.world.pos.z, aux); this->unk_570 = 0.0f; this->unk_56C = 0.0f; @@ -1484,26 +1478,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_RotateYF(this->unk_568, MTXMODE_NEW); - Matrix_MultVec3f(&sp90, &this->csCamTargetEye); + Matrix_MultVec3f(&sp90, &this->subCamEyeNext); - this->csCamTargetEye.x += this->actor.world.pos.x; - this->csCamTargetEye.y += this->waterHeight; - this->csCamTargetEye.z += this->actor.world.pos.z; + this->subCamEyeNext.x += this->actor.world.pos.x; + this->subCamEyeNext.y += this->waterHeight; + this->subCamEyeNext.z += this->actor.world.pos.z; sp4C = 40.0f + aux2; - Math_ApproachF(&this->csCamEye.x, this->csCamTargetEye.x, 0.1f, sp4C); - Math_ApproachF(&this->csCamEye.y, this->csCamTargetEye.y, 0.1f, sp4C); - Math_ApproachF(&this->csCamEye.z, this->csCamTargetEye.z, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.x, this->subCamEyeNext.x, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.y, this->subCamEyeNext.y, 0.1f, sp4C); + Math_ApproachF(&this->subCamEye.z, this->subCamEyeNext.z, 0.1f, sp4C); sp4C = 70.0f + aux2; - Math_ApproachF(&this->csCamAt.x, this->csCamTargetAt.x, 0.1f, sp4C); - Math_ApproachF(&this->csCamAt.y, this->csCamTargetAt.y, 0.1f, sp4C); - Math_ApproachF(&this->csCamAt.z, this->csCamTargetAt.z, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.x, this->subCamAtNext.x, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.y, this->subCamAtNext.y, 0.1f, sp4C); + Math_ApproachF(&this->subCamAt.z, this->subCamAtNext.z, 0.1f, sp4C); } break; } @@ -1529,8 +1523,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_TYPE_GYORG_RIPPLES); if (this->actionFunc == Boss03_DeathCutscene) { if ((D_809E9840 % 2) != 0) { @@ -1588,7 +1582,7 @@ void Boss03_DeathCutscene(Boss03* this, GlobalContext* globalCtx) { this->shapeRotTargetY = Rand_ZeroFloat(65536.0f); } - this->actor.world.rot.y = Math_FAtan2F(-this->actor.world.pos.z, -this->actor.world.pos.x); + this->actor.world.rot.y = Math_Atan2S_XY(-this->actor.world.pos.z, -this->actor.world.pos.x); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND_OLD); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_BOUND2_OLD); @@ -1605,33 +1599,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, PLAYER_CSMODE_6); this->csState = 3; func_80165690(); Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_KONB_INIT_OLD); @@ -1644,31 +1638,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, PLAYER_CSMODE_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; @@ -1685,7 +1679,7 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { this->actor.shape.rot.x = this->actor.shape.rot.z; this->actor.shape.rot.y = this->actor.world.rot.y = - Math_FAtan2F(-this->actor.world.pos.x, -this->actor.world.pos.x); + Math_Atan2S_XY(-this->actor.world.pos.x, -this->actor.world.pos.x); this->unk_260 = 0.0f; player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x8000; @@ -1693,11 +1687,11 @@ void Boss03_SpawnSmallFishesCutscene(Boss03* this, GlobalContext* globalCtx) { Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_RotateYS(this->actor.shape.rot.y + this->unk_2BE, MTXMODE_APPLY); - Matrix_MultVecZ(340.0f, &this->csCamEye); + Matrix_MultVecZ(340.0f, &this->subCamEye); - this->csCamAt.x = this->actor.world.pos.x; - this->csCamAt.y = this->actor.world.pos.y; - this->csCamAt.z = this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.y = this->actor.world.pos.y; + this->subCamAt.z = this->actor.world.pos.z; Math_ApproachS(&this->unk_2BE, -4000, 10, 70); @@ -1705,7 +1699,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++; @@ -1717,27 +1711,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, PLAYER_CSMODE_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); } } @@ -1745,8 +1738,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); @@ -1757,15 +1750,15 @@ void Boss03_SetupStunned(Boss03* this, GlobalContext* globalCtx) { if (&this->actor == player->actor.parent) { player->unk_AE8 = 101; player->actor.parent = NULL; - player->csMode = 0; + player->csMode = PLAYER_CSMODE_0; func_80165690(); } this->unk_240 = 0; } -void Boss03_Stunned(Boss03* this, GlobalContext* globalCtx) { - this->actor.hintId = 0x29; +void Boss03_Stunned(Boss03* this, PlayState* play) { + this->actor.hintId = TATL_HINT_ID_GYORG_STUNNED; if (this->unk_240 >= 16) { Boss03_PlayUnderwaterSfx(&this->actor.projectedPos, NA_SE_EN_COMMON_WEAKENED - SFX_FLAG); @@ -1778,7 +1771,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); @@ -1791,12 +1784,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; @@ -1805,7 +1798,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); @@ -1817,22 +1810,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; @@ -1885,10 +1878,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; @@ -1903,13 +1896,13 @@ 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) { player->unk_AE8 = 101; player->actor.parent = NULL; - player->csMode = 0; + player->csMode = PLAYER_CSMODE_0; func_80165690(); } @@ -1933,10 +1926,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); } } @@ -1946,11 +1939,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; @@ -1958,7 +1951,7 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { s16 j; f32 yRot; - this->actor.hintId = 0x28; + this->actor.hintId = TATL_HINT_ID_GYORG; if (!D_809E9842 && (player->actor.world.pos.y < (PLATFORM_HEIGHT + 5.0f))) { D_809E9842 = true; @@ -1992,13 +1985,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; } @@ -2014,8 +2007,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_TYPE_GYORG_RIPPLES); this->unk_280 = 27; this->unk_284 = this->actor.world.pos.x; @@ -2031,29 +2024,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; } @@ -2079,12 +2072,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--; @@ -2110,7 +2103,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); } } @@ -2137,7 +2130,7 @@ void Boss03_Update(Actor* thisx, GlobalContext* globalCtx2) { 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++; } @@ -2153,21 +2146,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] = VIRTUAL_TO_PHYSICAL(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) || @@ -2226,12 +2218,12 @@ 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_MultVec3f(&D_809E9148, &this->actor.focus.pos); @@ -2262,12 +2254,12 @@ void Boss03_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } } -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) { @@ -2276,24 +2268,24 @@ void Boss03_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateYF(this->unk_260, MTXMODE_APPLY); Matrix_Translate(0.0f, -600.0f, 0.0f, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, - this->skelAnime.dListCount, Boss03_OverrideLimbDraw, Boss03_PostLimbDraw, &this->actor); - POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP); + 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; @@ -2330,7 +2322,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; @@ -2349,7 +2341,7 @@ void Boss03_UpdateEffects(GlobalContext* globalCtx) { sp94.y = Rand_ZeroFloat(4.0f) + 2.0f; sp94.z = Rand_ZeroFloat(1.5f) + 1.5f; Matrix_MultVec3f(&sp94, &velocity); - Boss03_SpawnEffectSplash(globalCtx, &eff->pos, &velocity); + Boss03_SpawnEffectSplash(play, &eff->pos, &velocity); } } } else if (eff->type == GYORG_EFFECT_SPLASH) { @@ -2388,17 +2380,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,17 +2405,16 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); Matrix_Scale(eff->unk_34.x, eff->unk_34.x, 1.0f, MTXMODE_APPLY); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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; @@ -2433,7 +2424,7 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { if (!flag) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); @@ -2445,10 +2436,9 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { Matrix_Translate(eff->pos.x, eff->pos.y, eff->pos.z, MTXMODE_NEW); if (eff->type == GYORG_EFFECT_DROPLET) { - Matrix_RotateYF(Camera_GetInputDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) * (M_PI / 0x8000), - MTXMODE_APPLY); + Matrix_RotateYF(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)) * (M_PI / 0x8000), MTXMODE_APPLY); } else { // GYORG_EFFECT_SPLASH - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); } Matrix_Scale(eff->unk_34.x, eff->unk_34.y, 1.0f, MTXMODE_APPLY); @@ -2468,7 +2458,7 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { if (!flag) { func_8012C448(gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); @@ -2488,7 +2478,7 @@ void Boss03_DrawEffects(GlobalContext* globalCtx) { } } - Boss03_SetObject(globalCtx, OBJECT_BOSS03); + Boss03_SetObject(play, OBJECT_BOSS03); CLOSE_DISPS(gfxCtx); } @@ -2501,13 +2491,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; @@ -2546,7 +2536,7 @@ void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx) { } if (flag & SEAWEED_FLAG_INTERACT_PLAYER) { - Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + Math_ApproachS(&this->actor.shape.rot.y, Math_Atan2S_XY(zDiff, xDiff), 0x14, 0x800); } if (sGyorgBossInstance->actor.world.pos.y - 40.0f < sGyorgBossInstance->waterHeight) { @@ -2579,7 +2569,7 @@ void Boss03_SeaweedUpdate(Actor* thisx, GlobalContext* globalCtx) { } if (flag & SEAWEED_FLAG_INTERACT_GYORG) { - Math_ApproachS(&this->actor.shape.rot.y, Math_FAtan2F(zDiff, xDiff), 0x14, 0x800); + Math_ApproachS(&this->actor.shape.rot.y, Math_Atan2S_XY(zDiff, xDiff), 0x14, 0x800); } } @@ -2595,15 +2585,15 @@ 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, 10 * sizeof(Mtx)); - 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); @@ -2630,7 +2620,7 @@ void Boss03_SeaweedDraw(Actor* thisx, GlobalContext* globalCtx) { 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/overlay.cfg b/src/overlays/actors/ovl_Boss_04/overlay.cfg deleted file mode 100644 index 16d818a43..000000000 --- a/src/overlays/actors/ovl_Boss_04/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Boss_04 -z_boss_04.c 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 659fdbe3f..0b59ff9ed 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,25 @@ */ #include "z_boss_04.h" -#include "objects/object_boss04/object_boss04.h" +#include "z64shrink_window.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* play2); +void Boss04_Destroy(Actor* thisx, PlayState* play); +void Boss04_Update(Actor* thisx, PlayState* play2); +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; @@ -62,7 +62,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -const ActorInit Boss_04_InitVars = { +ActorInit Boss_04_InitVars = { ACTOR_BOSS_04, ACTORCAT_BOSS, FLAGS, @@ -97,7 +97,7 @@ static ColliderJntSphInit sJntSphInit1 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit1), sJntSphElementsInit1, }; @@ -124,7 +124,7 @@ static ColliderJntSphInit sJntSphInit2 = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit2), sJntSphElementsInit2, }; @@ -136,14 +136,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,30 +156,30 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { s16 phi_s0_2; s32 pad; - if (Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num)) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { + Actor_Kill(&this->actor); return; } this->actor.params = 0x64; Actor_SetScale(&this->actor, 0.1f); this->actor.targetMode = 5; - this->actor.hintId = 0x19; + this->actor.hintId = TATL_HINT_ID_WART; this->actor.colChkInfo.health = 20; this->actor.colChkInfo.damageTable = &sDamageTable; this->unk_700 = 1.0f; this->unk_6FC = 1.0f; this->unk_6F8 = 1.0f; - Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); - Collider_InitAndSetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_boss04_Skel_0045E8, &object_boss04_Anim_00004C, - this->jointTable, this->morphtable, 9); + 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 +197,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); + if ((KREG(64) != 0) || CHECK_EVENTINF(EVENTINF_60)) { + func_809ECD00(this, play); this->actor.world.pos.y = this->actor.floorHeight + 160.0f; phi_f24 = this->actor.floorHeight; D_809EE4D0 = KREG(41) + 50; @@ -216,17 +216,17 @@ void Boss04_Init(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < 82; i++) { Matrix_RotateYS(phi_s0_2, MTXMODE_NEW); Matrix_MultVecZ(phi_f20, &sp90); - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TANRON2, this->unk_6E8 + sp90.x, - phi_f24, this->unk_6F0 + sp90.z, 0, 0, 0, i); + 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 +234,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; @@ -252,32 +252,32 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 0: this->unk_2C8 = 50; this->unk_2D0 = 2000.0f; - if ((player->stateFlags1 & 0x100000) && (this->actor.projectedPos.z > 0.0f) && + if ((player->stateFlags1 & PLAYER_STATE1_100000) && (this->actor.projectedPos.z > 0.0f) && (fabsf(this->actor.projectedPos.x) < 300.0f) && (fabsf(this->actor.projectedPos.y) < 300.0f)) { if ((this->unk_704 >= 15) && (ActorCutscene_GetCurrentIndex() == -1)) { Actor* boss; 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, PLAYER_CSMODE_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); + Actor_Kill(boss); } boss = boss->next; } @@ -294,7 +294,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 +313,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, PLAYER_CSMODE_21); 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_MultVecZ(-100.0f, &this->unk_70C); + Matrix_MultVecZ(-100.0f, &this->subCamEye); - this->unk_70C.x += player->actor.world.pos.x; - this->unk_70C.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; - this->unk_70C.z += player->actor.world.pos.z; + this->subCamEye.x += player->actor.world.pos.x; + this->subCamEye.y = Player_GetHeight(player) + player->actor.world.pos.y + 36.0f; + this->subCamEye.z += player->actor.world.pos.z; - this->unk_718.x = player->actor.world.pos.x; - this->unk_718.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 4.0f; - this->unk_718.z = player->actor.world.pos.z; + this->subCamAt.x = player->actor.world.pos.x; + this->subCamAt.y = (Player_GetHeight(player) + player->actor.world.pos.y) - 4.0f; + this->subCamAt.z = player->actor.world.pos.z; if (this->unk_704 >= 35) { this->unk_704 = 0; @@ -358,13 +358,13 @@ void func_809EC568(Boss04* this, GlobalContext* globalCtx) { case 2: case 3: - Matrix_MultVecZ(500.0f, &this->unk_70C); - this->unk_70C.x += this->actor.world.pos.x; - this->unk_70C.y += this->actor.world.pos.y - 50.0f; - this->unk_70C.z += this->actor.world.pos.z; - this->unk_718.x = this->actor.world.pos.x; - this->unk_718.z = this->actor.world.pos.z; - this->unk_718.y = (this->actor.world.pos.y - 70.0f) + this->unk_728; + Matrix_MultVecZ(500.0f, &this->subCamEye); + this->subCamEye.x += this->actor.world.pos.x; + this->subCamEye.y += this->actor.world.pos.y - 50.0f; + this->subCamEye.z += this->actor.world.pos.z; + this->subCamAt.x = this->actor.world.pos.x; + this->subCamAt.z = this->actor.world.pos.z; + this->subCamAt.y = (this->actor.world.pos.y - 70.0f) + this->unk_728; Math_ApproachZeroF(&this->unk_728, 0.05f, this->unk_73C); Math_ApproachF(&this->unk_73C, 3.0f, 1.0f, 0.05f); if (this->unk_704 == 20) { @@ -380,35 +380,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, PLAYER_CSMODE_6); func_80165690(); - gSaveContext.eventInf[6] |= 1; + SET_EVENTINF(EVENTINF_60); } 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--; + ShrinkWindow_Letterbox_SetSizeTarget(27); + 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 +417,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 +464,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 +481,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 +500,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); } } @@ -522,11 +522,11 @@ void func_809ED224(Boss04* this) { this->unk_2C8 = 200; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ME_DEAD); this->actor.flags &= ~ACTOR_FLAG_1; - func_801A2ED8(); + Audio_RestorePrevBgm(); 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 +549,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) { @@ -559,11 +559,11 @@ void func_809ED2A0(Boss04* this, GlobalContext* globalCtx) { } if (this->unk_1FA == 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -void func_809ED45C(Boss04* this, GlobalContext* globalCtx) { +void func_809ED45C(Boss04* this, PlayState* play) { ColliderJntSphElement* temp_v0; u8 damage; @@ -576,7 +576,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; @@ -669,8 +669,8 @@ void func_809ED50C(Boss04* this) { 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 +704,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,23 +744,23 @@ 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); } if (D_809EE4D0 != 0) { D_809EE4D0--; if (D_809EE4D0 == 0) { - func_801A2E54(0x38); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } } @@ -769,8 +769,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 +781,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,13 +797,13 @@ 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) { + if (limbIndex == WART_LIMB_ROOT) { Matrix_MultVecY(-500.0f, &this->actor.focus.pos); Matrix_MultVec3f(&D_809EE228, &sp18); func_809EC040(0, &this->collider1, &sp18); @@ -813,12 +812,12 @@ void Boss04_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } } -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); @@ -826,25 +825,25 @@ void Boss04_Draw(Actor* thisx, GlobalContext* globalCtx) { 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_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..6aa153597 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -2,79 +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; - #endif // Z_BOSS_04_H diff --git a/src/overlays/actors/ovl_Boss_05/overlay.cfg b/src/overlays/actors/ovl_Boss_05/overlay.cfg deleted file mode 100644 index db19abb80..000000000 --- a/src/overlays/actors/ovl_Boss_05/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Boss_05 -z_boss_05.c 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..314370079 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 = { @@ -147,7 +147,7 @@ static DamageTable D_809F1C20 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -const ActorInit Boss_05_InitVars = { +ActorInit Boss_05_InitVars = { ACTOR_BOSS_05, ACTORCAT_ENEMY, FLAGS, 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..8f46476ea 100644 --- a/src/overlays/actors/ovl_Boss_05/z_boss_05.h +++ b/src/overlays/actors/ovl_Boss_05/z_boss_05.h @@ -5,15 +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; - #endif // Z_BOSS_05_H diff --git a/src/overlays/actors/ovl_Boss_06/overlay.cfg b/src/overlays/actors/ovl_Boss_06/overlay.cfg deleted file mode 100644 index 3f5b0e7d5..000000000 --- a/src/overlays/actors/ovl_Boss_06/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Boss_06 -z_boss_06.c 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 07016aff9..5dce58c4e 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -4,8 +4,8 @@ * Description: Igos du Ikana window - curtains and ray effects */ -#include "prevent_bss_reordering.h" #include "z_boss_06.h" +#include "z64shrink_window.h" #include "overlays/actors/ovl_En_Knight/z_en_knight.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_knight/object_knight.h" @@ -14,25 +14,25 @@ #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* play2); 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; -static s32 D_809F4974; -static s32 D_809F4978; -static s32 D_809F497C; +Vec3f D_809F4370[128]; +EnKnight* D_809F4970; +s32 D_809F4974; +s32 D_809F4978; +s32 D_809F497C; static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0xF), @@ -69,7 +69,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0xF), }; -const ActorInit Boss_06_InitVars = { +ActorInit Boss_06_InitVars = { ACTOR_BOSS_06, ACTORCAT_BOSS, FLAGS, @@ -101,7 +101,7 @@ static ColliderCylinderInit sCylinderInit = { { 90, 140, 10, { 0, 0, 0 } }, }; -static Vec3f D_809F40EC[] = { +Vec3f D_809F40EC[] = { { 1081.0f, 235.0f, 3224.0f }, { 676.0f, 235.0f, 3224.0f }, }; @@ -127,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; @@ -135,7 +135,7 @@ void Boss06_Init(Actor* thisx, GlobalContext* globalCtx) { D_809F4970 = (EnKnight*)this->actor.parent; this->actor.colChkInfo.damageTable = &sDamageTable; - if ((KREG(64) != 0) || (gSaveContext.eventInf[5] & 0x80)) { + if ((KREG(64) != 0) || CHECK_EVENTINF(EVENTINF_57)) { this->actionFunc = func_809F2E14; } else { this->actionFunc = func_809F2B64; @@ -144,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++) { @@ -154,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,10 +182,10 @@ void func_809F24A8(Boss06* this) { } #ifdef NON_MATCHING -// Weird loading of 1 -void func_809F24C8(Boss06* this, GlobalContext* globalCtx) { +// The 1 constant from the switch branch is reused in case 2 for some reason. +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; @@ -198,21 +198,21 @@ 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, PLAYER_CSMODE_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); + Actor_Kill(temp_s0); } temp_s0 = temp_s0->next; } @@ -220,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); } @@ -233,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, PLAYER_CSMODE_132); 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; @@ -287,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; @@ -318,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, PLAYER_CSMODE_6); D_809F4970->unk_151 = 0; } break; } - if (this->unk_A00 != 0) { - ShrinkWindow_SetLetterboxTarget(27); - Play_CameraSetAtEye(globalCtx, this->unk_A00, &this->unk_A10, &this->unk_A04); + if (this->subCamId != SUB_CAM_ID_DONE) { + ShrinkWindow_Letterbox_SetSizeTarget(27); + 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; @@ -357,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); @@ -382,36 +381,36 @@ void func_809F2C44(Boss06* this, GlobalContext* globalCtx) { } if (D_809F4970->unk_153 == 2) { - Actor_MarkForDeath(this->actor.child); + Actor_Kill(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; @@ -419,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--; @@ -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; @@ -514,10 +513,10 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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)) { @@ -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)); + 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_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); @@ -594,7 +593,7 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, 0.0f, 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) { @@ -611,8 +610,8 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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_Translate((D_809F4370[i].x - 32.0f) * -2.4f, (D_809F4370[i].y - 32.0f) * -2.4f, 0.0f, MTXMODE_APPLY); @@ -624,9 +623,9 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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_Pop(); } @@ -642,16 +641,16 @@ void Boss06_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbMaterial1DL); 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_RotateZS(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); - gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbModelDL); } - 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..f7b4d3ec0 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.h +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.h @@ -5,51 +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; - #endif // Z_BOSS_06_H diff --git a/src/overlays/actors/ovl_Boss_07/overlay.cfg b/src/overlays/actors/ovl_Boss_07/overlay.cfg deleted file mode 100644 index 79c564ccc..000000000 --- a/src/overlays/actors/ovl_Boss_07/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Boss_07 -z_boss_07.c 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..824c70fa2 100644 --- a/src/overlays/actors/ovl_Boss_07/z_boss_07.c +++ b/src/overlays/actors/ovl_Boss_07/z_boss_07.c @@ -5,52 +5,53 @@ */ #include "z_boss_07.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #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 = { @@ -233,7 +234,7 @@ static DamageTable D_80A07A00 = { /* Powder Keg */ DMG_ENTRY(2, 0xB), }; -const ActorInit Boss_07_InitVars = { +ActorInit Boss_07_InitVars = { ACTOR_BOSS_07, ACTORCAT_BOSS, FLAGS, @@ -296,7 +297,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 +318,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 +386,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..d17e3b172 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; @@ -13,6 +13,4 @@ typedef struct Boss07 { /* 0x0148 */ char unk_148[0xAAD8]; } Boss07; // size = 0xAC20 -extern const ActorInit Boss_07_InitVars; - #endif // Z_BOSS_07_H diff --git a/src/overlays/actors/ovl_Boss_Hakugin/overlay.cfg b/src/overlays/actors/ovl_Boss_Hakugin/overlay.cfg deleted file mode 100644 index 059dde381..000000000 --- a/src/overlays/actors/ovl_Boss_Hakugin/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Boss_Hakugin -z_boss_hakugin.c 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..d9a7cb348 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.c @@ -5,34 +5,36 @@ */ #include "z_boss_hakugin.h" +#include "z64quake.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 = { +ActorInit Boss_Hakugin_InitVars = { ACTOR_BOSS_HAKUGIN, ACTORCAT_BOSS, FLAGS, @@ -127,7 +129,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 +143,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..10a01989a 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h @@ -5,26 +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; - #endif // Z_BOSS_HAKUGIN_H diff --git a/src/overlays/actors/ovl_Demo_Effect/overlay.cfg b/src/overlays/actors/ovl_Demo_Effect/overlay.cfg deleted file mode 100644 index 8f2105acf..000000000 --- a/src/overlays/actors/ovl_Demo_Effect/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Demo_Effect -z_demo_effect.c 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 48ef3cd3d..cb34f8ff8 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.c @@ -12,20 +12,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_808CD998(DemoEffect* this, GlobalContext* globalCtx); -void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx); -void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx); -void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx); -void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx); -void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx); -void func_808CE078(Actor* thisx, GlobalContext* globalCtx2); +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); -const ActorInit Demo_Effect_InitVars = { +ActorInit Demo_Effect_InitVars = { ACTOR_DEMO_EFFECT, ACTORCAT_BG, FLAGS, @@ -37,60 +37,65 @@ const ActorInit Demo_Effect_InitVars = { (ActorFunc)NULL, }; -void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { - static s16 D_808CE2C0[] = { +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 sp3C = DEMOEFFECT_GET_FF(&this->actor); - s32 phi_v1; + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); + s32 objectIndex; s32 pad2; - Color_RGB8 sp24[] = { + Color_RGB8 colors[] = { { 200, 200, 0 }, { 255, 40, 100 }, { 50, 255, 0 }, { 0, 0, 255 }, { 255, 255, 80 }, }; - if (D_808CE2C0[sp3C] == 1) { - phi_v1 = 0; + if (sEffectTypeObjects[type] == GAMEPLAY_KEEP) { + objectIndex = 0; } else { - phi_v1 = Object_GetIndex(&globalCtx->objectCtx, D_808CE2C0[sp3C]); + objectIndex = Object_GetIndex(&play->objectCtx, sEffectTypeObjects[type]); } - if (phi_v1 >= 0) { - this->unk_164 = phi_v1; + if (objectIndex < 0) { + // assert on debug + } else { + this->initObjectIndex = objectIndex; } Actor_SetScale(&this->actor, 0.2f); - switch (sp3C) { - case 0: - case 1: + switch (type) { + case DEMO_EFFECT_TYPE_0: + case DEMO_EFFECT_TYPE_1: this->actor.flags |= ACTOR_FLAG_2000000; - case 2: - case 3: - this->unk_174 = func_808CDFF8; - this->unk_170 = func_808CD998; - this->unk_168[0] = 0; - this->unk_168[1] = 100; - this->unk_168[2] = 255; + 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->unk_16C = 0; + this->timer = 0; break; - case 4: - case 5: - case 6: - case 7: - case 8: - this->unk_168[0] = sp24[sp3C - 4].r; - this->unk_168[1] = sp24[sp3C - 4].g; - this->unk_168[2] = sp24[sp3C - 4].b; + 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->unk_174 = func_808CE078; - this->unk_170 = func_808CDDE0; - this->unk_16C = 0; + this->initDrawFunc = func_808CE078; + this->initActionFunc = func_808CDDE0; + this->timer = 0; + break; + + default: break; } @@ -98,54 +103,53 @@ void DemoEffect_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808CD940; } -u8 D_808CE2D4[] = { - 1, 1, 2, 0, 1, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0, -}; - -void DemoEffect_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void DemoEffect_Destroy(Actor* thisx, PlayState* play) { DemoEffect* this = THIS; - switch (DEMOEFFECT_GET_FF(&this->actor)) { - case 0: - case 1: - case 2: - case 3: - SkelCurve_Destroy(globalCtx, &this->skelCurve); + 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; + + default: break; } } -void func_808CD940(DemoEffect* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->unk_164)) { - this->actor.objBankIndex = this->unk_164; - this->actor.draw = this->unk_174; - this->actionFunc = this->unk_170; +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; } } -void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { - s32 sp34 = DEMOEFFECT_GET_FF(&this->actor); +void func_808CD998(DemoEffect* this, PlayState* play) { + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); - if (SkelCurve_Init(globalCtx, &this->skelCurve, &object_efc_tw_Skel_0012E8, &object_efc_tw_CurveAnim_000050)) {} + 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(globalCtx, &this->skelCurve); + SkelCurve_Update(play, &this->skelCurve); this->actionFunc = func_808CDCEC; - switch (sp34) { - case 0: + switch (type) { + case DEMO_EFFECT_TYPE_0: Actor_SetScale(&this->actor, 0.16800001f); break; - case 1: + case DEMO_EFFECT_TYPE_1: Actor_SetScale(&this->actor, 0.08400001f); break; - case 2: + case DEMO_EFFECT_TYPE_2: Actor_SetScale(&this->actor, 0.16800001f); break; - case 3: + case DEMO_EFFECT_TYPE_3: Actor_SetScale(&this->actor, 0.28f); break; @@ -155,124 +159,127 @@ void func_808CD998(DemoEffect* this, GlobalContext* globalCtx) { } } -void func_808CDAD0(f32 arg0) { +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; - Vtx* temp_v0 = Lib_SegmentedToVirtual(object_efc_tw_Vtx_000060); - u8 sp24[3]; + u8 alphas[3]; - sp24[0] = 0; - sp24[1] = (s8)(202.0f * arg0); - sp24[2] = (s8)(255.0f * arg0); + alphas[0] = 0; + alphas[1] = (s32)(202.0f * alphaScale); + alphas[2] = (s32)(255.0f * alphaScale); - for (i = 0; i < ARRAY_COUNT(D_808CE2D4); i++) { - if (D_808CE2D4[i] != 0) { - temp_v0[i].v.cn[3] = sp24[D_808CE2D4[i]]; + for (i = 0; i < ARRAY_COUNT(sAlphaTypes); i++) { + if (sAlphaTypes[i] != 0) { + vtx[i].v.cn[3] = alphas[sAlphaTypes[i]]; } } } -void func_808CDBDC(DemoEffect* this, GlobalContext* globalCtx) { - s32 params = DEMOEFFECT_GET_FF(&this->actor); - f32 temp_f0; - f32 temp_f12; +void func_808CDBDC(DemoEffect* this, PlayState* play) { + s32 type = DEMO_EFFECT_GET_TYPE(&this->actor); + f32 scale; + f32 alphaScale; - this->unk_16C++; - if (this->unk_16C <= 100) { - temp_f12 = (100 - this->unk_16C) * 0.01f; - temp_f0 = temp_f12 * 0.14f; + this->timer++; + if (this->timer <= 100) { + alphaScale = (100 - this->timer) * 0.01f; + scale = alphaScale * 0.14f; - switch (params) { - case 0: - temp_f0 *= 1.2f; + switch (type) { + case DEMO_EFFECT_TYPE_0: + scale *= 1.2f; break; - case 1: - temp_f0 *= 0.6f; + case DEMO_EFFECT_TYPE_1: + scale *= 0.6f; break; - case 2: - temp_f0 *= 1.2f; + case DEMO_EFFECT_TYPE_2: + scale *= 1.2f; break; - case 3: - temp_f0 *= 2.0f; + case DEMO_EFFECT_TYPE_3: + scale *= 2.0f; + break; + + default: break; } - this->actor.scale.x = temp_f0; - this->actor.scale.z = temp_f0; - func_808CDAD0(temp_f12); + 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); + Actor_Kill(&this->actor); } } -void func_808CDCEC(DemoEffect* this, GlobalContext* globalCtx) { +void func_808CDCEC(DemoEffect* this, PlayState* play) { func_800B8FE8(&this->actor, NA_SE_EV_TIMETRIP_LIGHT - SFX_FLAG); - if (SkelCurve_Update(globalCtx, &this->skelCurve)) { + 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->unk_16C = 0; + this->timer = 0; } } -void func_808CDD70(DemoEffect* this, GlobalContext* globalCtx) { +void func_808CDD70(DemoEffect* this, PlayState* play) { Actor_SetScale(&this->actor, this->actor.scale.x - 0.02f); - this->unk_16C++; + this->timer++; if (this->actor.scale.x < 0.02f) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -void func_808CDDE0(DemoEffect* this, GlobalContext* globalCtx) { +void func_808CDDE0(DemoEffect* this, PlayState* play) { Actor_SetScale(&this->actor, (this->actor.scale.x * 0.5f) + 0.2f); - this->unk_16C++; - if (this->unk_16C >= 3) { + this->timer++; + if (this->timer >= 3) { this->actionFunc = func_808CDD70; } } -void DemoEffect_Update(Actor* thisx, GlobalContext* globalCtx) { +void DemoEffect_Update(Actor* thisx, PlayState* play) { DemoEffect* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -s32 func_808CDE78(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, Actor* thisx) { +s32 func_808CDE78(PlayState* play, SkelCurve* skelCurve, s32 limbIndex, Actor* thisx) { s32 pad; DemoEffect* this = THIS; - u32 sp4C = globalCtx->gameplayFrames; + u32 frames = play->gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (sp4C * 6) % 1024, 255 - ((sp4C * 16) % 256), 0x100, 0x40, - 1, (sp4C * 4) % 512, 127 - ((sp4C * 12) % 128), 0x80, 0x20)); + 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(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); if (limbIndex == 0) { - LimbTransform* transform = skelCuve->transforms; + s16* transform = skelCurve->jointTable[0]; - transform->scale.x = 0x400; - transform->scale.y = 0x400; - transform->scale.z = transform->scale.x; + transform[2] = transform[0] = 1024; + transform[1] = 1024; } return true; } -void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void func_808CDFF8(Actor* thisx, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; DemoEffect* this = THIS; OPEN_DISPS(gfxCtx); @@ -280,37 +287,37 @@ void func_808CDFF8(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 25); Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); - SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, func_808CDE78, NULL, 1, &this->actor); + SkelCurve_Draw(&this->actor, play, &this->skelCurve, func_808CDE78, NULL, 1, &this->actor); CLOSE_DISPS(gfxCtx); } -void func_808CE078(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_808CE078(Actor* thisx, PlayState* play2) { + PlayState* play = play2; DemoEffect* this = THIS; - s16 sp46 = (this->unk_16C * 0x400) & 0xFFFF; + s16 zRot = (this->timer * 0x400) & 0xFFFF; - 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, 255, 255, 255); - gDPSetEnvColor(POLY_XLU_DISP++, this->unk_168[0], this->unk_168[1], this->unk_168[2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, this->envXluColor[0], this->envXluColor[1], this->envXluColor[2], 255); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_Push(); - Matrix_RotateZS(sp46, MTXMODE_APPLY); + Matrix_RotateZS(zRot, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFlash2DL); Matrix_Pop(); - Matrix_RotateZS(sp46 * -1, MTXMODE_APPLY); + Matrix_RotateZS(-zRot, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023288); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFlash2DL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); D_801F4E32 = 1; D_801F4E38.x = thisx->world.pos.x; 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 8216708c5..9901a3189 100644 --- a/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h +++ b/src/overlays/actors/ovl_Demo_Effect/z_demo_effect.h @@ -2,27 +2,36 @@ #define Z_DEMO_EFFECT_H #include "global.h" +#include "z64curve.h" struct DemoEffect; -typedef void (*DemoEffectActionFunc)(struct DemoEffect*, GlobalContext*); -typedef void (*DemoEffectUnkFunc)(struct DemoEffect*, GlobalContext*); -typedef void (*DemoEffectUnkFunc2)(Actor*, GlobalContext*); +typedef void (*DemoEffectActionFunc)(struct DemoEffect*, PlayState*); -#define DEMOEFFECT_GET_FF(thisx) ((thisx)->params & 0xFF) +#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 */ SkelAnimeCurve skelCurve; - /* 0x0164 */ u8 unk_164; - /* 0x0165 */ UNK_TYPE1 unk_165[3]; - /* 0x0168 */ u8 unk_168[3]; - /* 0x016C */ s16 unk_16C; - /* 0x0170 */ DemoEffectUnkFunc unk_170; - /* 0x0174 */ DemoEffectUnkFunc2 unk_174; - /* 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; - #endif // Z_DEMO_EFFECT_H diff --git a/src/overlays/actors/ovl_Demo_Getitem/overlay.cfg b/src/overlays/actors/ovl_Demo_Getitem/overlay.cfg deleted file mode 100644 index df09fe2ea..000000000 --- a/src/overlays/actors/ovl_Demo_Getitem/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Demo_Getitem -z_demo_getitem.c 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..aa37e7b85 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,12 +10,15 @@ #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); -#if 0 -const ActorInit Demo_Getitem_InitVars = { +void func_80A4FB10(DemoGetitem* this, PlayState* play); +void func_80A4FB68(DemoGetitem* this, PlayState* play2); +void DemoGetitem_Draw(Actor* thisx, PlayState* play); + +ActorInit Demo_Getitem_InitVars = { ACTOR_DEMO_GETITEM, ACTORCAT_BG, FLAGS, @@ -27,16 +30,90 @@ 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_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/DemoGetitem_Update.s") + this->objectIndex = objectIndex; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Getitem/func_80A4FCF0.s") +void DemoGetitem_Destroy(Actor* thisx, PlayState* play) { +} + +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; + break; + + case 3: + Actor_Kill(&this->actor); + break; + + 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; + break; + + default: + this->actor.draw = NULL; + break; + } + } 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..91c7dc97e 100644 --- a/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h +++ b/src/overlays/actors/ovl_Demo_Getitem/z_demo_getitem.h @@ -3,16 +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; - #endif // Z_DEMO_GETITEM_H diff --git a/src/overlays/actors/ovl_Demo_Kankyo/overlay.cfg b/src/overlays/actors/ovl_Demo_Kankyo/overlay.cfg deleted file mode 100644 index b9c10f311..000000000 --- a/src/overlays/actors/ovl_Demo_Kankyo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Demo_Kankyo -z_demo_kankyo.c 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 2c676abbf..c1303efab 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,17 +12,17 @@ #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; -const ActorInit Demo_Kankyo_InitVars = { +ActorInit Demo_Kankyo_InitVars = { ACTOR_DEMO_KANKYO, ACTORCAT_ITEMACTION, FLAGS, @@ -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); + Actor_Kill(&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,154 +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); @@ -302,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; @@ -317,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; @@ -331,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; @@ -454,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) {}; @@ -467,13 +454,13 @@ void DemoKankyo_Init(Actor* thisx, GlobalContext* globalCtx) { DemoKankyo_SetupAction(this, DemoKakyo_LostWoodsSparkleActionFunc); sLostWoodsSparklesMutex = true; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } break; 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; @@ -494,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); + Actor_Kill(&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; @@ -515,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); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); - 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) { + 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->particles[i].alpha / 50.0f; + 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_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(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); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } } - 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; @@ -607,64 +594,64 @@ 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) { + // 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->particles[i].alpha / 50.0f; + 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); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbMaterial1DL); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(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) { - gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); + gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); } else { - gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbModelDL); } } } @@ -673,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..971adb3bd 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; @@ -48,6 +48,4 @@ typedef enum { /* 3 */ DEMO_KANKYO_STATE_DISABLED, } DemoKankyoStateType; -extern const ActorInit Demo_Kankyo_InitVars; - #endif // Z_DEMO_KANKYO_H diff --git a/src/overlays/actors/ovl_Demo_Moonend/overlay.cfg b/src/overlays/actors/ovl_Demo_Moonend/overlay.cfg deleted file mode 100644 index 3d2793e42..000000000 --- a/src/overlays/actors/ovl_Demo_Moonend/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Demo_Moonend -z_demo_moonend.c 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..76a4230f5 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c @@ -10,13 +10,13 @@ #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 = { +ActorInit Demo_Moonend_InitVars = { ACTOR_DEMO_MOONEND, ACTORCAT_ITEMACTION, FLAGS, 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..d36dcb284 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h @@ -5,14 +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; - #endif // Z_DEMO_MOONEND_H diff --git a/src/overlays/actors/ovl_Demo_Shd/overlay.cfg b/src/overlays/actors/ovl_Demo_Shd/overlay.cfg deleted file mode 100644 index 0cf96d92a..000000000 --- a/src/overlays/actors/ovl_Demo_Shd/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Demo_Shd -z_demo_shd.c 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..f5e20a509 100644 --- a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c +++ b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.c @@ -10,12 +10,12 @@ #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 = { +ActorInit Demo_Shd_InitVars = { ACTOR_DEMO_SHD, ACTORCAT_ENEMY, FLAGS, @@ -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_Shd/z_demo_shd.h b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.h index 4e375a243..05707f073 100644 --- a/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.h +++ b/src/overlays/actors/ovl_Demo_Shd/z_demo_shd.h @@ -10,6 +10,4 @@ typedef struct DemoShd { /* 0x0144 */ char unk_0144[0x118C]; } DemoShd; // size = 0x12D0 -extern const ActorInit Demo_Shd_InitVars; - #endif // Z_DEMO_SHD_H diff --git a/src/overlays/actors/ovl_Demo_Syoten/overlay.cfg b/src/overlays/actors/ovl_Demo_Syoten/overlay.cfg deleted file mode 100644 index 8fde4e6f6..000000000 --- a/src/overlays/actors/ovl_Demo_Syoten/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Demo_Syoten -z_demo_syoten.c 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 72f101d18..60f9e898b 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -11,21 +11,21 @@ #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 = { +ActorInit Demo_Syoten_InitVars = { ACTOR_DEMO_SYOTEN, ACTORCAT_ITEMACTION, FLAGS, @@ -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; + Mtx* mtx; - 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)); + mtx = GRAPH_ALLOC(play->state.gfxCtx, this->unk_144.unk_18->unk_1 * sizeof(Mtx)); - if (matrix != NULL) { - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - func_8018450C(globalCtx, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); + if (mtx != NULL) { + func_8012C2DC(play->state.gfxCtx); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + func_8018450C(play, &this->unk_144, mtx, (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_RotateZS(-this->actor.shape.rot.z, MTXMODE_APPLY); - Matrix_Mult(&globalCtx->billboardMtxF, 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_Mult(&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_RotateYS(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..7b60ae951 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,22 +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; - #endif // Z_DEMO_SYOTEN_H diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/overlay.cfg b/src/overlays/actors/ovl_Demo_Tre_Lgt/overlay.cfg deleted file mode 100644 index a063264ea..000000000 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Demo_Tre_Lgt -z_demo_tre_lgt.c 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..b2b8e0077 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,18 +5,37 @@ */ #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); -#if 0 -const ActorInit Demo_Tre_Lgt_InitVars = { +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 }, +}; + +ActorInit Demo_Tre_Lgt_InitVars = { ACTOR_DEMO_TRE_LGT, ACTORCAT_ITEMACTION, FLAGS, @@ -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_Kill(&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..e6d5d568c 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,14 +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; - #endif // Z_DEMO_TRE_LGT_H diff --git a/src/overlays/actors/ovl_Dm_Ah/overlay.cfg b/src/overlays/actors/ovl_Dm_Ah/overlay.cfg deleted file mode 100644 index 22f1cf7a3..000000000 --- a/src/overlays/actors/ovl_Dm_Ah/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Ah -z_dm_ah.c 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..1a1f4ae22 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.c @@ -10,16 +10,12 @@ #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 = { +ActorInit Dm_Ah_InitVars = { ACTOR_DM_AH, ACTORCAT_NPC, FLAGS, @@ -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, PlayState* play) { + 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->sceneId == 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..df179c6f6 100644 --- a/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h +++ b/src/overlays/actors/ovl_Dm_Ah/z_dm_ah.h @@ -2,18 +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; - #endif // Z_DM_AH_H diff --git a/src/overlays/actors/ovl_Dm_Al/overlay.cfg b/src/overlays/actors/ovl_Dm_Al/overlay.cfg deleted file mode 100644 index 92999ffdd..000000000 --- a/src/overlays/actors/ovl_Dm_Al/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Al -z_dm_al.c 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..f81713731 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.c +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.c @@ -10,15 +10,12 @@ #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 = { +ActorInit Dm_Al_InitVars = { ACTOR_EN_AL, ACTORCAT_NPC, FLAGS, @@ -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..57e462de1 100644 --- a/src/overlays/actors/ovl_Dm_Al/z_dm_al.h +++ b/src/overlays/actors/ovl_Dm_Al/z_dm_al.h @@ -2,18 +2,28 @@ #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; +typedef enum { + /* 0x0 */ MADAME_AROMA_ANIMATION_0, + /* 0x1 */ MADAME_AROMA_ANIMATION_1 +} DmAlAnimations; #endif // Z_DM_AL_H diff --git a/src/overlays/actors/ovl_Dm_An/overlay.cfg b/src/overlays/actors/ovl_Dm_An/overlay.cfg deleted file mode 100644 index 03f82edfa..000000000 --- a/src/overlays/actors/ovl_Dm_An/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_An -z_dm_an.c 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 19f7844ac..d536425b0 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.c +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.c @@ -12,16 +12,16 @@ #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* thisx, PlayState* play); -const ActorInit Dm_An_InitVars = { +ActorInit Dm_An_InitVars = { ACTOR_DM_AN, ACTORCAT_NPC, FLAGS, @@ -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,19 +148,19 @@ 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; } tempActor = foundActor->next; - if (tempActor == NULL || NULL) { + if (tempActor == NULL || false) { foundActor = 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->sceneId == 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,72 +225,72 @@ 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_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_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == OBJECT_AN1_LIMB_09) { @@ -299,7 +299,7 @@ void func_80C1CD80(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -void func_80C1CEFC(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void func_80C1CEFC(PlayState* play, s32 limbIndex, Actor* thisx) { DmAn* this = THIS; s16 stepRot; s16 overrideRot; @@ -351,18 +351,18 @@ TexturePtr D_80C1D2F4[] = { 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..2001a8ba6 100644 --- a/src/overlays/actors/ovl_Dm_An/z_dm_an.h +++ b/src/overlays/actors/ovl_Dm_An/z_dm_an.h @@ -6,36 +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; - #endif // Z_DM_AN_H diff --git a/src/overlays/actors/ovl_Dm_Bal/overlay.cfg b/src/overlays/actors/ovl_Dm_Bal/overlay.cfg deleted file mode 100644 index fa51bac6a..000000000 --- a/src/overlays/actors/ovl_Dm_Bal/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Bal -z_dm_bal.c 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..b9c4cb33c 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -10,15 +10,15 @@ #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 DmBal_SetupDoNothing(DmBal* this); +void DmBal_DoNothing(DmBal* this, PlayState* play); -#if 0 -const ActorInit Dm_Bal_InitVars = { +ActorInit Dm_Bal_InitVars = { ACTOR_DM_BAL, ACTORCAT_NPC, FLAGS, @@ -30,31 +30,174 @@ 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->keepEyesShut = false; + DmBal_SetupDoNothing(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 DmBal_SetupDoNothing(DmBal* this) { + this->actionFunc = DmBal_DoNothing; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAD8.s") +void DmBal_DoNothing(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->keepEyesShut = false; + this->eyeIndex = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + break; + case 2: + this->keepEyesShut = true; + 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->keepEyesShut = true; + } else if (Animation_OnFrame(&this->skelAnime, 29.0f)) { + this->keepEyesShut = false; + this->eyeIndex = 0; + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + this->actor.home.pos = this->actor.world.pos; + } else { + this->keepEyesShut = false; + 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 scaleX; -#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; + scaleX = (Math_SinS(this->unk_338) * 0.1f) + 1.0f; + this->scale.x = SQ(scaleX); + 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 DmBal_UpdateEyes(DmBal* this) { + if (this->keepEyesShut == true) { + 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 DmBal_SpawnPaper(DmBal* this, PlayState* play, Vec3f* pos, Vec3f* vel, f32 gravity) { + Actor* paper = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_PAPER, pos->x, pos->y, pos->z, 0, 0, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Draw.s") + if (paper != NULL) { + paper->velocity = *vel; + paper->gravity = gravity; + } +} + +void DmBal_Update(Actor* thisx, PlayState* play) { + s32 pad; + DmBal* this = THIS; + + // Throw confetti + if (Animation_OnFrame(&this->skelAnime, 29.0f) && (this->skelAnime.animation == &object_bal_Anim_001804)) { + Vec3f pos = this->actor.world.pos; + Vec3f vel = { 0.0f, 9.0f, 0.0f }; + + pos.x += 7.0f * Math_SinS(this->actor.shape.rot.y); + pos.y += 2.5f; + pos.z += 7.0f * Math_CosS(this->actor.shape.rot.y); + vel.x = Math_SinS(this->actor.shape.rot.y) * 5.0f; + vel.z = Math_CosS(this->actor.shape.rot.y) * 5.0f; + DmBal_SpawnPaper(this, play, &pos, &vel, -0.4f); + DmBal_SpawnPaper(this, play, &pos, &vel, -0.5f); + } + this->actionFunc(this, play); + func_80C1EAE8(this, play); + func_80C1EC60(this, play); + DmBal_UpdateEyes(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) * (0x10000 / 18); + rots.z = Math_CosS(this->unk_33A) * (0x10000 / 18); + 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) { +} + +static 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..01f10d4c9 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.h @@ -2,18 +2,25 @@ #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 - -extern const ActorInit Dm_Bal_InitVars; + /* 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 keepEyesShut; + /* 0x338 */ s16 unk_338; + /* 0x33A */ s16 unk_33A; +} DmBal; /* size = 0x33C */ #endif // Z_DM_BAL_H diff --git a/src/overlays/actors/ovl_Dm_Char00/overlay.cfg b/src/overlays/actors/ovl_Dm_Char00/overlay.cfg deleted file mode 100644 index 0d49d3bbc..000000000 --- a/src/overlays/actors/ovl_Dm_Char00/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char00 -z_dm_char00.c 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 ce9f844d0..43cc62603 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -12,15 +12,15 @@ #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* play2); -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 = { +ActorInit Dm_Char00_InitVars = { ACTOR_DM_CHAR00, ACTORCAT_ITEMACTION, FLAGS, @@ -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,88 +447,88 @@ 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->sceneId) { case SCENE_LOST_WOODS: - if (gSaveContext.sceneSetupIndex == 1) { - func_80AA561C(this, globalCtx); + if (gSaveContext.sceneLayer == 1) { + 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 (gSaveContext.sceneLayer == 0) { + 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 (gSaveContext.sceneLayer == 0) { + 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); + } else if (gSaveContext.sceneLayer == 2) { + 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 (gSaveContext.sceneLayer == 3) { + 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); + } else if (gSaveContext.sceneLayer == 7) { + 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.sceneLayer == 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.sceneLayer == 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.sceneLayer == 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)) { - Actor_MarkForDeath(thisx); + if ((play->sceneId == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { + Actor_Kill(thisx); } this->unk_240 = D_80AA77A8[DMCHAR00_GET(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; @@ -648,7 +648,7 @@ void func_80AA62FC(DmChar00* this, GlobalContext* globalCtx) { break; case 0x16: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; case 0x17: @@ -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.sceneLayer == 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,26 +880,26 @@ 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); + 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); @@ -908,23 +907,22 @@ s32 DmChar00_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi 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, 4 * sizeof(Gfx)); - 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->sceneId != SCENE_OPENINGDAN) || (gSaveContext.sceneLayer != 0) || (play->roomCtx.curRoom.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..62ee0cb40 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,28 +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; - #endif // Z_DM_CHAR00_H diff --git a/src/overlays/actors/ovl_Dm_Char01/overlay.cfg b/src/overlays/actors/ovl_Dm_Char01/overlay.cfg deleted file mode 100644 index babdfc2f2..000000000 --- a/src/overlays/actors/ovl_Dm_Char01/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char01 -z_dm_char01.c 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 375edda4a..069d829c1 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* play2); +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; @@ -34,7 +35,7 @@ s16 D_80AAAE26; #include "overlays/ovl_Dm_Char01/ovl_Dm_Char01.c" -const ActorInit Dm_Char01_InitVars = { +ActorInit Dm_Char01_InitVars = { ACTOR_DM_CHAR01, ACTORCAT_ITEMACTION, FLAGS, @@ -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; @@ -66,27 +67,27 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { switch (DMCHAR01_GET(&this->dyna.actor)) { case DMCHAR01_0: - if (gSaveContext.save.weekEventReg[20] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { this->unk_34C = 2; this->actionFunc = func_80AA8F1C; break; } - if (gSaveContext.sceneSetupIndex == 0) { - globalCtx->envCtx.unk_1F = 5; - globalCtx->envCtx.unk_20 = 5; + if (gSaveContext.sceneLayer == 0) { + play->envCtx.unk_1F = 5; + play->envCtx.unk_20 = 5; } this->unk_348 = 255.0f; for (i = 0; i < ARRAY_COUNT(this->unk_1AC); i++) { - this->unk_1AC[i] = ovl_dm_char01_Vtx_1BE0[i].v.ob[1] * 409.6f; + this->unk_1AC[i] = gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[1] * 409.6f; } DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_009E4C); + DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodfallSceneryPoisonWaterDamageCol); this->unk_34D = true; - if (gSaveContext.sceneSetupIndex == 1) { + if (gSaveContext.sceneLayer == 1) { this->unk_34C = 1; this->actionFunc = func_80AA8C28; } else { @@ -96,7 +97,7 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { break; case DMCHAR01_1: - if ((gSaveContext.save.weekEventReg[20] & 2) || (gSaveContext.sceneSetupIndex == 1)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02) || (gSaveContext.sceneLayer == 1)) { this->unk_34C = 1; this->actionFunc = func_80AA8F1C; } else { @@ -106,14 +107,14 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { case DMCHAR01_2: this->unk_34C = 0; - if (!(gSaveContext.save.weekEventReg[20] & 1)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_01)) { this->unk_34C = 1; this->dyna.actor.world.pos.y -= 400.0f; } this->dyna.actor.world.rot.y += 0x8000; this->dyna.actor.shape.rot.y += 0x8000; DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_mtoride_Colheader_010C3C); + DynaPolyActor_LoadMesh(play, &this->dyna, &gWoodfallSceneryTempleCol); this->unk_34D = true; this->unk_348 = 200.0f; this->actionFunc = func_80AA8F2C; @@ -122,17 +123,18 @@ void DmChar01_Init(Actor* thisx, GlobalContext* globalCtx) { case DMCHAR01_3: this->dyna.actor.world.rot.y += 0x8000; this->dyna.actor.shape.rot.y += 0x8000; - if (!(gSaveContext.save.weekEventReg[20] & 1)) { - Actor_MarkForDeath(&this->dyna.actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_01)) { + Actor_Kill(&this->dyna.actor); 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, &gWoodfallSceneryTempleRampAndPlatformCol); this->unk_34D = true; - if (!(gSaveContext.save.weekEventReg[20] & 2)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { this->actionFunc = func_80AA9020; this->dyna.actor.world.pos.y -= 120.0f; } else { @@ -146,23 +148,23 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_01)) { return; } - if ((player->stateFlags2 & 0x8000000) && (player2->actor.world.pos.x > -40.0f) && + if ((player->stateFlags2 & PLAYER_STATE2_8000000) && (player2->actor.world.pos.x > -40.0f) && (player2->actor.world.pos.x < 40.0f) && (player2->actor.world.pos.z > 1000.0f) && (player2->actor.world.pos.z < 1078.0f)) { if (!D_80AAAAB4) { @@ -173,18 +175,18 @@ 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)) { - gSaveContext.save.weekEventReg[20] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_20_01); this->actionFunc = func_80AA884C; } } } -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; @@ -251,8 +252,9 @@ void func_80AA892C(DmChar01* this, GlobalContext* globalCtx) { this->unk_34C = 0; } - for (i = 0; i < ARRAY_COUNT(ovl_dm_char01_Vtx_1BE0); i++) { - s32 temp_s2 = sqrtf(SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[2]) + SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[0])); + for (i = 0; i < ARRAY_COUNT(gWoodfallSceneryDynamicPoisonWaterVtx); i++) { + s32 temp_s2 = sqrtf(SQ((f32)gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[2]) + + SQ((f32)gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[0])); f32 cos = Math_CosS((temp_s2 / 1892.0f) * 0x4000); f32 temp_f20 = (1.0f - (ABS_ALT(temp_s2 - D_80AAAE22) / 1892.0f)) * D_80AAAE20 * cos; @@ -264,11 +266,11 @@ void func_80AA892C(DmChar01* this, GlobalContext* globalCtx) { temp_f20 += temp_f18; this->unk_1AC[i] += 1600; - ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[1] = temp_f20; } } -void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx) { +void func_80AA8C28(DmChar01* this, PlayState* play) { f32 temp_f18; s32 temp_v0_4; s32 i; @@ -296,8 +298,9 @@ void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx) { break; } - for (i = 0; i < ARRAY_COUNT(ovl_dm_char01_Vtx_1BE0); i++) { - s32 temp_s2 = sqrtf(SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[2]) + SQ((f32)ovl_dm_char01_Vtx_1BE0[i].v.ob[0])); + for (i = 0; i < ARRAY_COUNT(gWoodfallSceneryDynamicPoisonWaterVtx); i++) { + s32 temp_s2 = sqrtf(SQ((f32)gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[2]) + + SQ((f32)gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[0])); f32 cos = Math_CosS((temp_s2 / 1892.0f) * 0x4000); f32 temp_f20 = (1.0f - (ABS_ALT(temp_s2 - D_80AAAE22) / 1892.0f)) * D_80AAAE20 * cos; @@ -309,7 +312,7 @@ void func_80AA8C28(DmChar01* this, GlobalContext* globalCtx) { temp_f20 += temp_f18; this->unk_1AC[i] += 1600; - ovl_dm_char01_Vtx_1BE0[i].v.ob[1] = temp_f20; + gWoodfallSceneryDynamicPoisonWaterVtx[i].v.ob[1] = temp_f20; } Math_SmoothStepToF(&this->unk_348, 0.0f, 0.02f, 0.6f, 0.4f); @@ -320,72 +323,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)) { - gSaveContext.save.weekEventReg[20] |= 2; + if ((temp_v1->startFrame == play->csCtx.frames) && (temp_v1->action == 2)) { + SET_WEEKEVENTREG(WEEKEVENTREG_20_02); 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 +406,54 @@ 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(gWoodfallSceneryPoisonWaterTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryPoisonWaterDL); 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); + if (gSaveContext.sceneLayer == 1) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWoodfallSceneryPurifiedWaterTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryFloorDL); + Gfx_DrawDListXlu(play, gWoodfallSceneryPurifiedWaterDL); Matrix_Translate(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); } - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_009D70)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWoodfallSceneryDynamicPoisonWaterTexAnim)); - 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), + gSPSegment(POLY_OPA_DISP++, 0x0B, + Lib_SegmentedToVirtual(gWoodfallSceneryDynamicPoisonWaterVtx)); + 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); + gSPDisplayList(POLY_OPA_DISP++, gWoodfallSceneryDynamicPoisonWaterDL); } 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), + gSPSegment(POLY_XLU_DISP++, 0x0B, + Lib_SegmentedToVirtual(gWoodfallSceneryDynamicPoisonWaterVtx)); + 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); + gSPDisplayList(POLY_XLU_DISP++, gWoodfallSceneryDynamicPoisonWaterDL); } - 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(gWoodfallSceneryPurifiedWaterTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryFloorDL); + Gfx_DrawDListXlu(play, gWoodfallSceneryPurifiedWaterDL); break; } break; @@ -455,36 +461,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(gWoodfallSceneryPoisonWallsTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryPoisonWallsDL); break; case 1: - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00B1A0)); - Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00AF98); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWoodfallSceneryPurifiedWallsTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryPurifiedWallsDL); 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(gWoodfallSceneryTempleTexAnim)); + Gfx_DrawDListOpa(play, gWoodfallSceneryTempleDL); if ((this->unk_34C != 0) && ((u8)this->unk_348 != 0)) { - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&object_mtoride_Matanimheader_00F768)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWoodfallSceneryWaterFlowingOverTempleTexAnim)); - 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); + gSPDisplayList(POLY_XLU_DISP++, gWoodfallSceneryWaterFlowingOverTempleDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (D_80AAAE24 != 0) { @@ -517,29 +523,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, gWoodfallSceneryTempleEntrancesDL); break; case DMCHAR01_3: if (thisx->world.pos.y > -120.0f) { - Gfx_DrawDListOpa(globalCtx, object_mtoride_DL_00FAE8); + Gfx_DrawDListOpa(play, gWoodfallSceneryTempleRampAndPlatformDL); } 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..6f29531a0 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,17 +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; - #endif // Z_DM_CHAR01_H diff --git a/src/overlays/actors/ovl_Dm_Char02/overlay.cfg b/src/overlays/actors/ovl_Dm_Char02/overlay.cfg deleted file mode 100644 index b5c165061..000000000 --- a/src/overlays/actors/ovl_Dm_Char02/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char02 -z_dm_char02.c 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..b618281c2 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -1,24 +1,24 @@ /* * 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 = { +ActorInit Dm_Char02_InitVars = { ACTOR_DM_CHAR02, ACTORCAT_ITEMACTION, FLAGS, @@ -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->sceneId == 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_Kill(&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_Kill(&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..7a9722554 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h @@ -5,15 +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; - #endif // Z_DM_CHAR02_H diff --git a/src/overlays/actors/ovl_Dm_Char03/overlay.cfg b/src/overlays/actors/ovl_Dm_Char03/overlay.cfg deleted file mode 100644 index dd50d58fa..000000000 --- a/src/overlays/actors/ovl_Dm_Char03/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char03 -z_dm_char03.c 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..714913231 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -1,26 +1,26 @@ /* * 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 = { +ActorInit Dm_Char03_InitVars = { ACTOR_DM_CHAR03, ACTORCAT_ITEMACTION, FLAGS, @@ -32,34 +32,159 @@ const ActorInit Dm_Char03_InitVars = { (ActorFunc)DmChar03_Draw, }; -#endif +AnimationInfo sAnimationInfo[] = { + { &gDekuMaskFallOverAnim, 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_Kill(&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..5b4a2e621 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.h @@ -5,15 +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; - #endif // Z_DM_CHAR03_H diff --git a/src/overlays/actors/ovl_Dm_Char04/overlay.cfg b/src/overlays/actors/ovl_Dm_Char04/overlay.cfg deleted file mode 100644 index a8f5bd501..000000000 --- a/src/overlays/actors/ovl_Dm_Char04/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char04 -z_dm_char04.c 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..5c835152d 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -5,18 +5,20 @@ */ #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); -#if 0 -const ActorInit Dm_Char04_InitVars = { +void func_80AABE34(DmChar04* this, PlayState* play); + +ActorInit Dm_Char04_InitVars = { ACTOR_DM_CHAR04, ACTORCAT_ITEMACTION, FLAGS, @@ -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, 4 * sizeof(Gfx)); + 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..0f0fcb6a1 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.h @@ -5,15 +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; - #endif // Z_DM_CHAR04_H diff --git a/src/overlays/actors/ovl_Dm_Char05/overlay.cfg b/src/overlays/actors/ovl_Dm_Char05/overlay.cfg deleted file mode 100644 index cb8b10bcc..000000000 --- a/src/overlays/actors/ovl_Dm_Char05/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char05 -z_dm_char05.c 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 94935db3c..7e368b9e3 100644 --- a/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c +++ b/src/overlays/actors/ovl_Dm_Char05/z_dm_char05.c @@ -11,31 +11,31 @@ #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 = { +ActorInit Dm_Char05_InitVars = { ACTOR_DM_CHAR05, ACTORCAT_ITEMACTION, FLAGS, @@ -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,14 +331,14 @@ 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; case 5: sp2F = false; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; default: @@ -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,14 +375,14 @@ 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; case 5: sp2F = false; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; default: @@ -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,14 +418,14 @@ 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; case 5: sp2F = false; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; default: @@ -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 (gSaveContext.sceneSetupIndex == 2) { - if (globalCtx->csCtx.currentCsIndex == 0) { - func_80AAD3F8(this, globalCtx); - } else if (globalCtx->csCtx.currentCsIndex == 1) { - func_80AAD450(this, globalCtx); + if (play->sceneId == SCENE_OKUJOU) { + if (gSaveContext.sceneLayer == 2) { + 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) { - if (gSaveContext.sceneSetupIndex == 9) { - if ((globalCtx->csCtx.currentCsIndex == 0) && (globalCtx->csCtx.frames == 255)) { + } else if (play->sceneId == SCENE_SPOT00) { + if (gSaveContext.sceneLayer == 9) { + 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.sceneLayer == 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) { + if (play->csCtx.actorActions[actionIndex]->action == 4) { Matrix_Translate(-600.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Gfx_DrawDListOpa(globalCtx, object_dmask_DL_001E70); + 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,80 +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_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_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_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_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_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_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_Translate(this->unk_190.x, this->unk_190.y, this->unk_190.z, MTXMODE_NEW); - Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_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_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_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..3bff39f6a 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,22 +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; - #endif // Z_DM_CHAR05_H diff --git a/src/overlays/actors/ovl_Dm_Char06/overlay.cfg b/src/overlays/actors/ovl_Dm_Char06/overlay.cfg deleted file mode 100644 index 8c0666c9b..000000000 --- a/src/overlays/actors/ovl_Dm_Char06/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char06 -z_dm_char06.c 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..0385a82d4 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.c @@ -10,17 +10,15 @@ #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 = { +ActorInit Dm_Char06_InitVars = { ACTOR_DM_CHAR06, ACTORCAT_ITEMACTION, FLAGS, @@ -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") + SET_WEEKEVENTREG(WEEKEVENTREG_33_80); + 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..fd08c83ff 100644 --- a/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h +++ b/src/overlays/actors/ovl_Dm_Char06/z_dm_char06.h @@ -2,18 +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; - #endif // Z_DM_CHAR06_H diff --git a/src/overlays/actors/ovl_Dm_Char07/overlay.cfg b/src/overlays/actors/ovl_Dm_Char07/overlay.cfg deleted file mode 100644 index 5b5ad5acd..000000000 --- a/src/overlays/actors/ovl_Dm_Char07/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char07 -z_dm_char07.c 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..844be223e 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c @@ -11,14 +11,14 @@ #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 = { +ActorInit Dm_Char07_InitVars = { ACTOR_DM_CHAR07, ACTORCAT_ITEMACTION, FLAGS, @@ -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..ce54f1be1 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,13 +25,11 @@ 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 -extern const ActorInit Dm_Char07_InitVars; - #endif // Z_DM_CHAR07_H diff --git a/src/overlays/actors/ovl_Dm_Char08/overlay.cfg b/src/overlays/actors/ovl_Dm_Char08/overlay.cfg deleted file mode 100644 index 5f69d0c82..000000000 --- a/src/overlays/actors/ovl_Dm_Char08/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char08 -z_dm_char08.c 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..4129adfbe 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.c @@ -5,18 +5,53 @@ */ #include "z_dm_char08.h" +#include "objects/object_kamejima/object_kamejima.h" #define FLAGS (ACTOR_FLAG_2000000) #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* play2); +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 = { +void func_80AAFAC4(DmChar08* this, PlayState* play); +void DmChar08_WaitForSong(DmChar08* this, PlayState* play); +void func_80AAF8F4(DmChar08* this, PlayState* play); +void func_80AAFAE4(DmChar08* this, PlayState* play); +void DmChar08_DoNothing(DmChar08* this, PlayState* play); +void func_80AAFA18(DmChar08* this, PlayState* play); +void DmChar08_SetupAppearCs(DmChar08* this, PlayState* play); +void func_80AAF884(DmChar08* this, PlayState* play); +void func_80AAFB04(DmChar08* this, PlayState* play); +void func_80AAFB94(DmChar08* this, PlayState* play); +void func_80AAFE88(DmChar08* this, PlayState* play); +void func_80AB023C(DmChar08* this, PlayState* play); +void func_80AB01E8(DmChar08* this, PlayState* play); +void DmChar08_SpawnBubbles(DmChar08* this, PlayState* play); +void func_80AAFCCC(DmChar08* this, PlayState* play); + +typedef enum { + /* 0 */ TURTLE_EYEMODE_BLINK_LEFT, + /* 1 */ TURTLE_EYEMODE_BLINK_STRAIGHT, + /* 2 */ TURTLE_EYEMODE_CLOSED, + /* 3 */ TURTLE_EYEMODE_LOOK_STRAIGHT, + /* 4 */ TURTLE_EYEMODE_UNUSED, + /* 5 */ TURTLE_EYEMODE_LOOK_RIGHT, +} EyeMode; + +typedef enum { + /* 0 */ TURTLE_ANIM_IDLE, + /* 1 */ TURTLE_ANIM_SWIM, + /* 2 */ TURTLE_ANIM_FLOAT, + /* 3 */ TURTLE_ANIM_SPEAK1, + /* 4 */ TURTLE_ANIM_COUGH, + /* 5 */ TURTLE_ANIM_SPEAK2, + /* 6 */ TURTLE_ANIM_YAWN, +} TurtleAnimation; + +ActorInit Dm_Char08_InitVars = { ACTOR_DM_CHAR08, ACTORCAT_BG, FLAGS, @@ -28,71 +63,1061 @@ const ActorInit Dm_Char08_InitVars = { (ActorFunc)DmChar08_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AB1764[] = { +#include "overlays/ovl_Dm_Char08/ovl_Dm_Char08.c" + +static AnimationInfo sAnimationInfo[] = { + { &gTurtleIdleAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -24.0f }, + { &gTurtleSwimAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -24.0f }, + { &gTurtleFloatAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -24.0f }, + { &gTurtleSpeak1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -24.0f }, + { &gTurtleCoughAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -24.0f }, + { &gTurtleSpeak2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -24.0f }, + { &gTurtleYawnAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -24.0f }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 4000, ICHAIN_STOP), }; -#endif +void DmChar08_UpdateEyes(DmChar08* this) { + switch (this->eyeMode) { + case TURTLE_EYEMODE_BLINK_LEFT: + this->eyeIndex = 0; + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else { + this->blinkTimer = 0; + } + if (this->blinkTimer < 4) { + this->eyeIndex = this->blinkTimer; + } + if (this->blinkTimer == 0) { + this->blinkTimer = Rand_S16Offset(30, 30); + } + break; -extern InitChainEntry D_80AB1764[]; + case TURTLE_EYEMODE_BLINK_STRAIGHT: + this->eyeIndex = 4; + if (this->blinkTimer > 0) { + this->blinkTimer--; + } else { + this->blinkTimer = 0; + } + if (this->blinkTimer < 4) { + this->eyeIndex = this->blinkTimer + 4; + } + if (this->blinkTimer == 0) { + this->blinkTimer = Rand_S16Offset(30, 30); + } + break; -extern UNK_TYPE D_06002470; -extern UNK_TYPE D_06004E70; -extern UNK_TYPE D_0600E748; + case TURTLE_EYEMODE_CLOSED: + this->eyeIndex = 2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAF050.s") + case TURTLE_EYEMODE_LOOK_STRAIGHT: + this->eyeIndex = 4; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAF15C.s") + case TURTLE_EYEMODE_LOOK_RIGHT: + this->eyeIndex = 8; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/DmChar08_Init.s") + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/DmChar08_Destroy.s") +void DmChar08_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animationInfo, u16 animIndex) { + f32 endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAF610.s") + animationInfo += animIndex; + if (animationInfo->frameCount < 0.0f) { + endFrame = Animation_GetLastFrame(animationInfo->animation); + } else { + endFrame = animationInfo->frameCount; + } + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, endFrame, + animationInfo->mode, animationInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAF79C.s") +void DmChar08_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + DmChar08* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAF884.s") + thisx->targetMode = 5; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + thisx->targetArrowOffset = 120.0f; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gTurtleSkel, NULL, NULL, NULL, 0); + Actor_ProcessInitChain(thisx, sInitChain); + Actor_SetScale(thisx, 0.1f); + this->unk_1F4 = 0; + this->bubbleCount = 0; + this->unk_1FF = 0; + this->alpha = 0; + this->animIndex = TURTLE_ANIM_IDLE; + this->unk_1FC = 0xFFFF; + this->dynapolyInitialized = false; + this->targetYPos = thisx->world.pos.y; + this->unk_1F0 = 0.0f; + if (play->sceneId == SCENE_31MISAKI) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_20)) { + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(play, &this->dyna, &gTurtleZoraCapeAwakeCol); + } else { + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(play, &this->dyna, &gTurtleZoraCapeAsleepCol); + } + this->dynapolyInitialized = true; + } else if (play->sceneId == SCENE_SEA) { + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(play, &this->dyna, &sTurtleGreatBayTempleCol); + this->dynapolyInitialized = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAF8F4.s") + this->palmTree1 = Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_YASI, thisx->world.pos.x + -80.0f, + thisx->world.pos.y + 390.0f, thisx->world.pos.z, 0, 0, 0, 1); + this->palmTree2 = Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_YASI, thisx->world.pos.x + 68.0f, + thisx->world.pos.y + 368.0f, thisx->world.pos.z - 174.0f, 0, 0x7530, 0, 1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFA18.s") + switch (play->sceneId) { + case SCENE_31MISAKI: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_20)) { + thisx->world.pos.x = -6480.0f; + this->targetYPos = -120.0f; + thisx->world.pos.z = 1750.0f; + thisx->world.rot.x = 0; + thisx->world.rot.y = -0x7234; + thisx->world.rot.z = 0; + thisx->shape.rot.x = 0; + thisx->shape.rot.y = -0x7234; + thisx->shape.rot.z = 0; + this->unk_1F0 = 1.0f; + this->unk_1FF = 2; + this->animIndex = TURTLE_ANIM_FLOAT; + this->unk_203 = 0x63; + this->eyeMode = TURTLE_EYEMODE_BLINK_STRAIGHT; + this->unk_207 = 0; + this->unk_208 = 0; + thisx->flags |= ACTOR_FLAG_1; + if (gSaveContext.save.entrance == ENTRANCE(ZORA_CAPE, 8)) { + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->actionFunc = func_80AAFAC4; + } else { + this->actionFunc = func_80AAF8F4; + } + } else { + this->actionFunc = DmChar08_WaitForSong; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFAC4.s") + case SCENE_SEA: + this->unk_1FF = 2; + this->animIndex = TURTLE_ANIM_FLOAT; + this->unk_203 = 0x63; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + thisx->flags |= ACTOR_FLAG_1; + this->actionFunc = func_80AAFAE4; + this->unk_1F0 = 1.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFAE4.s") + case SCENE_KONPEKI_ENT: + this->unk_1FF = 2; + this->animIndex = TURTLE_ANIM_FLOAT; + this->unk_203 = 0x63; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + this->actionFunc = DmChar08_DoNothing; + this->unk_1F0 = 1.0f; + break; + } + DmChar08_ChangeAnim(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFB04.s") +void DmChar08_Destroy(Actor* thisx, PlayState* play) { + DmChar08* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFB94.s") + if (this->dynapolyInitialized) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFBA4.s") +static s16 sSuccessSoundAlreadyPlayed = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFCCC.s") +void DmChar08_WaitForSong(DmChar08* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Player* player2 = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFE78.s") + if ((player2->stateFlags2 & PLAYER_STATE2_8000000) && + ((player2->actor.world.pos.x > -5780.0f) && (player2->actor.world.pos.x < -5385.0f) && + (player2->actor.world.pos.z > 1120.0f) && (player2->actor.world.pos.z < 2100.0f))) { + if (!sSuccessSoundAlreadyPlayed) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + sSuccessSoundAlreadyPlayed = true; + } + } else { + sSuccessSoundAlreadyPlayed = false; + } + if ((player->transformation == PLAYER_FORM_ZORA) && (play->msgCtx.ocarinaMode == 3) && + (play->msgCtx.lastPlayedSong == OCARINA_SONG_NEW_WAVE)) { + if ((player2->actor.world.pos.x > -5780.0f) && (player2->actor.world.pos.x < -5385.0f)) { + if ((player2->actor.world.pos.z > 1120.0f) && (player2->actor.world.pos.z < 2100.0f)) { + this->actionFunc = DmChar08_SetupAppearCs; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AAFE88.s") +void DmChar08_SetupAppearCs(DmChar08* this, PlayState* play) { + s16 cs1 = this->dyna.actor.cutscene; + s16 cs = ActorCutscene_GetAdditionalCutscene( + ActorCutscene_GetAdditionalCutscene(ActorCutscene_GetAdditionalCutscene(cs1))); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AB01E8.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_93_08)) { + cs1 = cs; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AB023C.s") + if (ActorCutscene_GetCanPlayNext(cs1)) { + ActorCutscene_Start(cs1, &this->dyna.actor); + SET_WEEKEVENTREG(WEEKEVENTREG_53_20); + SET_WEEKEVENTREG(WEEKEVENTREG_93_08); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80AAF884; + } else { + ActorCutscene_SetIntentToPlay(cs1); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AB032C.s") +void func_80AAF884(DmChar08* this, PlayState* play) { + if (play->csCtx.state == CS_STATE_0) { + DynaPolyActor_Init(&this->dyna, 3); + DynaPolyActor_LoadMesh(play, &this->dyna, &gTurtleZoraCapeAwakeCol); + this->dyna.actor.flags |= ACTOR_FLAG_1; + this->actionFunc = func_80AAF8F4; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AB096C.s") +void func_80AAF8F4(DmChar08* this, PlayState* play) { + s32 pad; + f32 yOffset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AB0A10.s") + if (fabsf(this->dyna.actor.xzDistToPlayer) < 200.0f) { + this->actionFunc = func_80AAFA18; + } + this->unk_1FA += 200; + yOffset = 50.0f; + yOffset *= Math_SinS(this->unk_1FA); + Math_SmoothStepToF(&this->dyna.actor.world.pos.x, -6400.0f, 0.2f, 2.0f, 0.1f); + Math_SmoothStepToF(&this->targetYPos, -180.0f + yOffset, 0.5f, 5.0f, 0.1f); + Math_SmoothStepToF(&this->dyna.actor.world.pos.z, 1750.0f, 0.5f, 20.0f, 0.1f); + Math_SmoothStepToS(&this->dyna.actor.world.rot.y, -0x7234, 0xA, 0xDC, 1); + Math_SmoothStepToS(&this->dyna.actor.shape.rot.y, -0x7234, 0xA, 0xDC, 1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/DmChar08_Update.s") +void func_80AAFA18(DmChar08* this, PlayState* play) { + s16 nextCs; + s16 nextCs2; + s16 nextCs1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AB0E3C.s") + nextCs1 = ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene); + nextCs2 = nextCs1; + nextCs1 = ActorCutscene_GetAdditionalCutscene(nextCs1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AB0E7C.s") + nextCs = CHECK_WEEKEVENTREG(WEEKEVENTREG_53_40) ? nextCs1 : nextCs2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/func_80AB0F90.s") + if (ActorCutscene_GetCanPlayNext(nextCs) != 0) { + SET_WEEKEVENTREG(WEEKEVENTREG_53_40); + ActorCutscene_Start(nextCs, &this->dyna.actor); + this->actionFunc = DmChar08_DoNothing; + } else { + ActorCutscene_SetIntentToPlay(nextCs); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char08/DmChar08_Draw.s") +void func_80AAFAC4(DmChar08* this, PlayState* play) { + if (play->csCtx.state == 0) { + this->actionFunc = func_80AAF8F4; + } +} + +void func_80AAFAE4(DmChar08* this, PlayState* play) { + if (play->csCtx.state == 0) { + this->actionFunc = func_80AAFB04; + } +} + +void func_80AAFB04(DmChar08* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if ((fabsf(this->dyna.actor.xzDistToPlayer) < 200.0f) && (player->actor.world.pos.y > 0.0f)) { + play->nextEntrance = ENTRANCE(ZORA_CAPE, 7); + play->transitionTrigger = TRANS_TRIGGER_START; + Scene_SetExitFade(play); + this->actionFunc = func_80AAFB94; + } +} + +void func_80AAFB94(DmChar08* this, PlayState* play) { +} + +Color_RGBA8 sLargeTurtleBubblePrimColor = { 250, 200, 250, 100 }; +Color_RGBA8 sLargeTurtleBubbleEnvColor = { 80, 80, 80, 0 }; +Vec3f sLargeTurtleBubbleAccel = { 0.0f, -0.8f, 0.0f }; + +void DmChar08_SpawnBubbles(DmChar08* this, PlayState* play) { + s32 i; + Vec3f velocity; + + velocity.x = (Rand_ZeroOne() - 0.5f) * 24.0f; + velocity.y = -5.2f; + velocity.z = 4.0f; + sLargeTurtleBubbleAccel.x = 0.0f; + sLargeTurtleBubbleAccel.y = 1.18f; + sLargeTurtleBubbleAccel.z = 0.0f; + for (i = 0; i < this->bubbleCount; i++) { + EffectSsDtBubble_SpawnCustomColor(play, &this->bubblePos, &velocity, &sLargeTurtleBubbleAccel, + &sLargeTurtleBubblePrimColor, &sLargeTurtleBubbleEnvColor, + Rand_S16Offset(80, 130), 30, 0); + } +} + +void func_80AAFCCC(DmChar08* this, PlayState* play) { + switch (play->sceneId) { + case SCENE_31MISAKI: + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + switch (this->unk_206) { + case 0: + break; + + case 1: + // Fire hookshot + Message_StartTextbox(play, 0x102A, &this->dyna.actor); + this->unk_206++; + break; + + case 2: + // I know your name + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + Message_StartTextbox(play, 0x102B, &this->dyna.actor); + this->unk_206 = 0; + } + break; + } + } else { + switch (this->unk_206) { + case 0: + break; + + case 1: + // Going to the temple again + Message_StartTextbox(play, 0x103B, &this->dyna.actor); + this->unk_206++; + break; + + case 2: + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + func_801477B4(play); + this->unk_206 = 0; + } + break; + } + } + return; + + case SCENE_SEA: + switch (this->unk_206) { + case 0: + break; + + case 1: + Message_StartTextbox(play, 0x102E, &this->dyna.actor); + this->unk_206++; + break; + + case 2: + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + Message_StartTextbox(play, 0x102F, &this->dyna.actor); + this->unk_206 = 0; + } + break; + } + break; + } +} + +void DmChar08_DoNothing(DmChar08* this, PlayState* play) { +} + +void func_80AAFE88(DmChar08* this, PlayState* play) { + s32 actorActionIndex; + CsCmdActorAction* csAction; + f32 phi_f12; + + if (Cutscene_CheckActorAction(play, 474)) { + actorActionIndex = Cutscene_GetActorActionIndex(play, 474); + if (this->unk_1F6 != play->csCtx.actorActions[actorActionIndex]->action) { + this->unk_1F6 = play->csCtx.actorActions[actorActionIndex]->action; + switch (play->csCtx.actorActions[actorActionIndex]->action) { + case 1: + this->animIndex = TURTLE_ANIM_IDLE; + break; + + case 3: + this->bubbleCount = 2; + break; + + case 4: + this->animIndex = TURTLE_ANIM_FLOAT; + break; + + case 5: + this->animIndex = TURTLE_ANIM_SWIM; + break; + + case 6: + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + break; + + case 7: + this->eyeMode = TURTLE_EYEMODE_CLOSED; + break; + + case 8: + this->animIndex = TURTLE_ANIM_YAWN; + break; + + case 9: + this->animIndex = TURTLE_ANIM_FLOAT; + break; + + case 10: + this->animIndex = TURTLE_ANIM_COUGH; + break; + + case 12: + this->animIndex = TURTLE_ANIM_SPEAK2; + break; + + case 13: + this->bubbleCount = 0; + break; + + case 14: + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIG_TORTOISE_ROLL); + this->animIndex = TURTLE_ANIM_FLOAT; + break; + } + } + switch (play->csCtx.actorActions[actorActionIndex]->action) { + case 2: + this->unk_1FF = 1; + phi_f12 = 2.0f * Environment_LerpWeight(play->csCtx.actorActions[actorActionIndex]->endFrame, + play->csCtx.actorActions[actorActionIndex]->startFrame, + play->csCtx.frames); + if (phi_f12 > 1.0f) { + phi_f12 = 1.0f; + } + + this->alpha = (1.0f - phi_f12) * 255.0f; + if (this->alpha < 6) { + this->unk_1FF = 2; + } + + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, actorActionIndex); + break; + + case 5: + Cutscene_ActorTranslateAndYawSmooth(&this->dyna.actor, play, actorActionIndex); + break; + + case 14: + Cutscene_ActorTranslate(&this->dyna.actor, play, actorActionIndex); + Math_SmoothStepToS(&this->dyna.actor.world.rot.y, play->csCtx.actorActions[actorActionIndex]->rot.y, + 0xA, 0xDC, 1); + this->dyna.actor.shape.rot.y = this->dyna.actor.world.rot.y; + break; + + default: + Cutscene_ActorTranslateAndYaw(&this->dyna.actor, play, actorActionIndex); + break; + } + this->targetYPos = this->dyna.actor.world.pos.y; + if ((this->unk_1FF >= 2) || (play->csCtx.actorActions[actorActionIndex]->action == 2)) { + Math_SmoothStepToF(&this->unk_1F0, 1.0f, 0.02f, 0.1f, 0.00001f); + } + } else { + this->unk_1F6 = 99; + } +} + +void func_80AB01E8(DmChar08* this, PlayState* play) { + if (this->animIndex != this->unk_203) { + this->unk_203 = this->animIndex; + DmChar08_ChangeAnim(&this->skelAnime, &sAnimationInfo[this->animIndex], 0); + } +} + +void func_80AB023C(DmChar08* this, PlayState* play) { + if ((play->msgCtx.currentTextId != this->unk_1FC) && (play->msgCtx.currentTextId != 0)) { + this->unk_1FC = play->msgCtx.currentTextId; + this->unk_208 = 0; + switch (play->msgCtx.currentTextId) { + case 0x1025: // Slept well + this->unk_207 = 1; + break; + + case 0x1026: // Time Flies + this->unk_207 = 2; + break; + + case 0x1027: // See Everything + this->unk_207 = 3; + break; + + case 0x1028: // No time + this->unk_207 = 4; + break; + + case 0x1029: // Quick lets go + this->unk_207 = 10; + break; + + case 0x102C: // Having trouble + this->unk_207 = 5; + break; + + case 0x102D: // Ready, climb + this->unk_207 = 8; + break; + + case 0x102A: // Fire hookshot + this->unk_207 = 6; + break; + + case 0x102B: // I know your name + this->unk_207 = 2; + break; + + case 0x102E: // Returning to shore + this->unk_207 = 9; + break; + + case 0x102F: // It is okay to retreat + this->unk_207 = 7; + break; + + case 0x103B: // Going to the temple again + this->unk_207 = 6; + + break; + case 0x1030: // Return to sleep + this->unk_207 = 4; + break; + } + } +} + +void func_80AB032C(DmChar08* this, PlayState* play) { + switch (this->unk_207) { + case 1: + switch (this->unk_208) { + case 0: + this->animIndex = TURTLE_ANIM_YAWN; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + this->unk_208++; + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } + break; + } + break; + + case 2: + switch (this->unk_208) { + case 0: + this->animIndex = TURTLE_ANIM_COUGH; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + this->unk_208++; + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_SPEAK1; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_208++; + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } + break; + } + break; + + case 3: + case 4: + case 8: + switch (this->unk_208) { + case 0: + this->animIndex = TURTLE_ANIM_SPEAK1; + if (this->unk_207 >= 5) { + this->eyeMode = TURTLE_EYEMODE_CLOSED; + } else { + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + } + this->unk_208 = 2; + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_SPEAK2; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + this->unk_208++; + } + break; + + case 3: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->unk_207 != 4) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } else { + this->animIndex = TURTLE_ANIM_SPEAK1; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_208++; + } + } + break; + + case 4: + case 5: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_208++; + } + break; + + case 6: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } + break; + } + break; + + case 5: + switch (this->unk_208) { + case 0: + this->animIndex = TURTLE_ANIM_SPEAK1; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_208++; + break; + + case 2: + case 3: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_208++; + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_SPEAK2; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + this->unk_208++; + } + break; + + case 5: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } + break; + } + break; + + case 6: + switch (this->unk_208) { + case 0: + this->animIndex = TURTLE_ANIM_SPEAK1; + this->eyeMode = TURTLE_EYEMODE_LOOK_RIGHT; + this->unk_208++; + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_208++; + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } + break; + } + break; + + case 7: + switch (this->unk_208) { + case 0: + this->animIndex = TURTLE_ANIM_SPEAK2; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + this->unk_208++; + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_SPEAK1; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + this->unk_208++; + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } + break; + } + break; + + case 9: + switch (this->unk_208) { + case 0: + this->animIndex = TURTLE_ANIM_SPEAK1; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_208++; + break; + + case 1: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->unk_208++; + } + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + this->unk_208 = 3; + } + break; + + case 2: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_208++; + } + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + this->unk_208 = 3; + } + break; + + case 3: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_COUGH; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + this->unk_208++; + } + break; + + case 4: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } + break; + } + break; + case 10: + switch (this->unk_208) { + case 0: + this->animIndex = TURTLE_ANIM_SPEAK1; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_208++; + break; + case 1: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_SPEAK2; + this->eyeMode = TURTLE_EYEMODE_CLOSED; + this->unk_208++; + } + break; + case 2: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_SPEAK1; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_208++; + } + break; + case 3: + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->animIndex = TURTLE_ANIM_FLOAT; + this->eyeMode = TURTLE_EYEMODE_BLINK_LEFT; + this->unk_207 = 0; + this->unk_208 = 0; + } + break; + } + break; + } +} + +void func_80AB096C(DmChar08* this, PlayState* play) { + if ((play->csCtx.state != 0) && (play->sceneId == SCENE_31MISAKI) && (gSaveContext.sceneLayer == 0) && + (play->csCtx.currentCsIndex == 0)) { + if ((play->csCtx.frames >= 890) && (play->csCtx.frames < 922)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); + } + } + if ((this->animIndex == TURTLE_ANIM_SWIM) && Animation_OnFrame(&this->skelAnime, 16.0f)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIG_TORTOISE_SWIM); + } +} + +void DmChar08_UpdateCollision(DmChar08* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 curFrame; + f32 phi_f2; + f32 phi_f0; + f32 phi_f12; + s32 i; + + if (player->actor.world.pos.x > 0.0f) { + curFrame = this->skelAnime.curFrame; + if (curFrame <= 19.0f) { + phi_f12 = 19.0f; + phi_f2 = curFrame / 19.0f; + } else { + phi_f2 = (29.0f - curFrame) / 9.0f; + phi_f12 = 29.0f; + } + + sTurtleGreatBayTempleCol.polyList = sTurtleGreatBayTempleColPolygons; + + for (i = 0; i < ARRAY_COUNT(sTurtleGreatBayTempleColVertices); i++) { + sTurtleGreatBayTempleColVertices[i].x = sTurtleGreatBayTempleColVertices2[i].x; + } + + sTurtleGreatBayTempleColVertices[0].y = (100.0f * phi_f2) + 900.0f; + sTurtleGreatBayTempleColVertices[1].y = (100.0f * phi_f2) + 900.0f; + sTurtleGreatBayTempleColVertices[2].y = (500.0f * phi_f2) + -200.0f; + sTurtleGreatBayTempleColVertices[3].y = (900.0f * phi_f2) + -800.0f; + sTurtleGreatBayTempleColVertices[5].y = 0x4B0; + sTurtleGreatBayTempleColVertices[9].y = 0x6A4; + } else { + phi_f0 = this->skelAnime.curFrame + 26.0f; + if (phi_f0 > 29.0f) { + phi_f12 = 29.0f; + phi_f0 -= 29.0f; + } + + if (phi_f0 <= 18.0f) { + phi_f2 = phi_f0 / 18.0f; + } else { + phi_f2 = (29.0f - phi_f0) / 10.0f; + } + + sTurtleGreatBayTempleCol.polyList = sTurtleGreatBayTempleColPolygons2; + + for (i = 0; i < ARRAY_COUNT(sTurtleGreatBayTempleColVertices); i++) { + sTurtleGreatBayTempleColVertices[i].x = -sTurtleGreatBayTempleColVertices2[i].x; + } + + sTurtleGreatBayTempleColVertices[0].y = (500.0f * phi_f2) + 720.0f; + sTurtleGreatBayTempleColVertices[1].y = (660.0f * phi_f2) + 420.0f; + sTurtleGreatBayTempleColVertices[2].y = (1130.0f * phi_f2) + -430.0f; + sTurtleGreatBayTempleColVertices[3].y = (1430.0f * phi_f2) + -1060.0f; + sTurtleGreatBayTempleColVertices[5].y = 0x4B0; + sTurtleGreatBayTempleColVertices[9].y = 0x6A4; + } + func_800C6554(play, &play->colCtx.dyna); +} + +void DmChar08_Update(Actor* thisx, PlayState* play) { + DmChar08* this = THIS; + + this->dyna.actor.focus.pos.x = this->focusPos.x; + this->dyna.actor.focus.pos.y = this->focusPos.y + this->dyna.actor.targetArrowOffset; + this->dyna.actor.focus.pos.z = this->focusPos.z; + this->dyna.actor.focus.rot.x = this->dyna.actor.world.rot.x; + this->dyna.actor.focus.rot.y = this->dyna.actor.world.rot.y; + this->dyna.actor.focus.rot.z = this->dyna.actor.world.rot.z; + + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { + this->unk_206 = 1; + } + + DmChar08_UpdateEyes(this); + this->actionFunc(this, play); + func_80AAFE88(this, play); + func_80AB023C(this, play); + func_80AB032C(this, play); + func_80AB01E8(this, play); + SkelAnime_Update(&this->skelAnime); + DmChar08_SpawnBubbles(this, play); + this->dyna.actor.world.pos.y = this->targetYPos; + if (play->sceneId == SCENE_31MISAKI) { + if (this->dyna.actor.xzDistToPlayer > 1300.0f) { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } else { + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + } + } + if (this->unk_1FF != 0) { + func_80AAFCCC(this, play); + func_800B8614(&this->dyna.actor, play, 400.0f); + } + func_80AB096C(this, play); + DmChar08_UpdateCollision(this, play); +} + +s32 DmChar08_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + if ((play->csCtx.state == 0) && (play->sceneId == SCENE_31MISAKI) && + (limbIndex == TURTLE_LIMB_FRONT_RIGHT_UPPER_FLIPPER)) { + rot->z = -0x5E24; + } + return false; +} + +void DmChar08_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + DmChar08* this = THIS; + Vec3f src; + + if (limbIndex == TURTLE_LIMB_SHELL) { + src.x = 800.0f; + src.y = 2600.0f; + src.z = -800.0f; + Matrix_MultVec3f(&src, &this->tree1Pos); + src.x = 2600.0f; + src.y = 2500.0f; + src.z = 700.0f; + Matrix_MultVec3f(&src, &this->tree2Pos); + } else if (limbIndex == TURTLE_LIMB_LOWER_MOUTH) { + src.x = 1600.0f; + src.y = -200.0f; + src.z = 0.0f; + Matrix_MultVec3f(&src, &this->bubblePos); + } else if (limbIndex == TURTLE_LIMB_UPPER_MOUTH) { + src.x = 600.0f; + src.y = 700.0f; + src.z = 0.0f; + Matrix_MultVec3f(&src, &this->focusPos); + } +} + +void DmChar08_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { + DmChar08* this = THIS; + f32 one; + + switch (limbIndex) { + case TURTLE_LIMB_SHELL: + break; + + case TURTLE_LIMB_NECK: + Matrix_Pop(); + one = 1.0f; + Matrix_Scale(((one - 0.7f) * this->unk_1F0) + 0.7f, ((one - 0.7f) * this->unk_1F0) + 0.7f, 1.0f, + MTXMODE_APPLY); + Matrix_Push(); + break; + + case TURTLE_LIMB_FRONT_LEFT_UPPER_FLIPPER: + case TURTLE_LIMB_FRONT_LEFT_LOWER_FLIPPER: + case TURTLE_LIMB_FRONT_RIGHT_UPPER_FLIPPER: + case TURTLE_LIMB_FRONT_RIGHT_LOWER_FLIPPER: + Matrix_Pop(); + Matrix_Scale((this->unk_1F0 * 0.4f) + 0.6f, (this->unk_1F0 * 0.4f) + 0.6f, (this->unk_1F0 * 0.4f) + 0.6f, + MTXMODE_APPLY); + Matrix_Push(); + break; + + case TURTLE_LIMB_FRONT_LEFT_END_FLIPPER: + case TURTLE_LIMB_FRONT_RIGHT_END_FLIPPER: + Matrix_Scale((this->unk_1F0 * 0.4f) + 0.6f, (this->unk_1F0 * 0.4f) + 0.6f, (this->unk_1F0 * 0.4f) + 0.6f, + MTXMODE_APPLY); + break; + + case TURTLE_TAIL_LIMB: + Matrix_Pop(); + Matrix_Scale((this->unk_1F0 * 0.52f) + 0.48f, (this->unk_1F0 * 0.52f) + 0.48f, + (this->unk_1F0 * 0.52f) + 0.48f, MTXMODE_APPLY); + Matrix_Push(); + break; + + case TURTLE_LIMB_BACK_LEFT_FLIPPER: + case TURTLE_LIMB_BACK_RIGHT_FLIPPER: + Matrix_Scale((this->unk_1F0 * 0.55f) + 0.45f, (this->unk_1F0 * 0.2f) + 0.8f, + (this->unk_1F0 * 0.55f) + 0.45f, MTXMODE_APPLY); + break; + } +} + +TexturePtr sBigTurtleEyeTextures[] = { + gTurtleEyeOpenLeftTex, gTurtleEyeHalfLeftTex, gTurtleEyeClosedTex, + gTurtleEyeHalfLeftTex, gTurtleEyeOpenStraightTex, gTurtleEyeHalfStraightTex, + gTurtleEyeClosedTex, gTurtleEyeHalfStraightTex, gTurtleEyeOpenRightTex, +}; + +void DmChar08_Draw(Actor* thisx, PlayState* play) { + s32 pad; + DmChar08* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sBigTurtleEyeTextures[this->eyeIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sBigTurtleEyeTextures[this->eyeIndex])); + if ((this->unk_1FF > 0) || (play->csCtx.state != CS_STATE_0)) { + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, DmChar08_OverrideLimbDraw, DmChar08_PostLimbDraw, + DmChar08_TransformLimbDraw, &this->dyna.actor); + this->palmTree1->world.pos.x = this->tree1Pos.x; + this->palmTree1->world.pos.y = this->tree1Pos.y; + this->palmTree1->world.pos.z = this->tree1Pos.z; + this->palmTree2->world.pos.x = this->tree2Pos.x; + this->palmTree2->world.pos.y = this->tree2Pos.y; + this->palmTree2->world.pos.z = this->tree2Pos.z; + } + if (this->unk_1FF == 0) { + Scene_SetRenderModeXlu(play, 0, 1); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gTurtleAsleepDL); + } else if (this->unk_1FF == 1) { + func_8012C2DC(play->state.gfxCtx); + Scene_SetRenderModeXlu(play, 2, 2); + 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++, gTurtleAsleepDL); + } + CLOSE_DISPS(play->state.gfxCtx); +} 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..f339bceaa 100644 --- a/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h +++ b/src/overlays/actors/ovl_Dm_Char08/z_dm_char08.h @@ -5,15 +5,39 @@ 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 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ DmChar08ActionFunc actionFunc; + /* 0x1A4 */ Actor* palmTree1; + /* 0x1A8 */ Actor* palmTree2; + /* 0x1AC */ Vec3f tree1Pos; + /* 0x1B8 */ Vec3f tree2Pos; + /* 0x1C4 */ Vec3f bubblePos; + /* 0x1D0 */ Vec3f focusPos; + /* 0x1DC */ UNK_TYPE1 unk_1DC[8]; + /* 0x1E4 */ f32 targetYPos; + /* 0x1E8 */ UNK_TYPE1 unk_1E8[8]; + /* 0x1F0 */ f32 unk_1F0; + /* 0x1F4 */ s16 unk_1F4; + /* 0x1F6 */ s16 unk_1F6; + /* 0x1F6 */ s16 blinkTimer; + /* 0x1FA */ s16 unk_1FA; + /* 0x1FC */ u16 unk_1FC; + /* 0x1FE */ u8 bubbleCount; + /* 0x1FF */ u8 unk_1FF; + /* 0x200 */ u8 eyeMode; + /* 0x201 */ u8 eyeIndex; + /* 0x202 */ u8 animIndex; + /* 0x203 */ u8 unk_203; + /* 0x204 */ UNK_TYPE1 unk_204; + /* 0x205 */ u8 alpha; + /* 0x206 */ u8 unk_206; + /* 0x207 */ u8 unk_207; + /* 0x208 */ u8 unk_208; + /* 0x209 */ u8 dynapolyInitialized; } DmChar08; // size = 0x20C -extern const ActorInit Dm_Char08_InitVars; - #endif // Z_DM_CHAR08_H diff --git a/src/overlays/actors/ovl_Dm_Char09/overlay.cfg b/src/overlays/actors/ovl_Dm_Char09/overlay.cfg deleted file mode 100644 index 99eda9b12..000000000 --- a/src/overlays/actors/ovl_Dm_Char09/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Char09 -z_dm_char09.c 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..654bc6c07 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c @@ -10,17 +10,15 @@ #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 = { +ActorInit Dm_Char09_InitVars = { ACTOR_DM_CHAR09, ACTORCAT_ITEMACTION, FLAGS, @@ -32,28 +30,197 @@ const ActorInit Dm_Char09_InitVars = { (ActorFunc)DmChar09_Draw, }; -#endif +static AnimationInfo sAnimationInfo[] = { + { &gBeeFlyingAnim, 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, &gBeeSkel, &gBeeFlyingAnim, 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..dffe65975 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.h @@ -2,18 +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; - #endif // Z_DM_CHAR09_H diff --git a/src/overlays/actors/ovl_Dm_Gm/overlay.cfg b/src/overlays/actors/ovl_Dm_Gm/overlay.cfg deleted file mode 100644 index e12011867..000000000 --- a/src/overlays/actors/ovl_Dm_Gm/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Gm -z_dm_gm.c 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 a6970e050..5321abc92 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.c @@ -1,7 +1,7 @@ /* * File: z_dm_gm.c * Overlay: ovl_Dm_Gm - * Description: Anju (cutscene) (duplicate of Dm_An?) + * Description: Complete duplicate of Dm_An */ #include "z_dm_gm.h" @@ -12,16 +12,16 @@ #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 = { +ActorInit Dm_Gm_InitVars = { ACTOR_DM_GM, ACTORCAT_NPC, FLAGS, @@ -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->sceneId == 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,72 +225,72 @@ 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_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_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == OBJECT_AN1_LIMB_09) { @@ -299,7 +299,7 @@ void DmGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void DmGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void DmGm_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { DmGm* this = THIS; s16 stepRot; s16 overrideRot; @@ -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..54db8d30f 100644 --- a/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h +++ b/src/overlays/actors/ovl_Dm_Gm/z_dm_gm.h @@ -6,36 +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; - #endif // Z_DM_GM_H diff --git a/src/overlays/actors/ovl_Dm_Hina/overlay.cfg b/src/overlays/actors/ovl_Dm_Hina/overlay.cfg deleted file mode 100644 index 824085b3e..000000000 --- a/src/overlays/actors/ovl_Dm_Hina/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Hina -z_dm_hina.c 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..a2a2589fb 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.c @@ -10,18 +10,18 @@ #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 = { +ActorInit Dm_Hina_InitVars = { ACTOR_DM_HINA, ACTORCAT_ITEMACTION, FLAGS, 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..21c9e55dc 100644 --- a/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h +++ b/src/overlays/actors/ovl_Dm_Hina/z_dm_hina.h @@ -5,17 +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; - #endif // Z_DM_HINA_H diff --git a/src/overlays/actors/ovl_Dm_Nb/overlay.cfg b/src/overlays/actors/ovl_Dm_Nb/overlay.cfg deleted file mode 100644 index 7af01c8cc..000000000 --- a/src/overlays/actors/ovl_Dm_Nb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Nb -z_dm_nb.c 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..98f7bac48 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.c @@ -5,18 +5,17 @@ */ #include "z_dm_nb.h" -#include "objects/object_nb/object_nb.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #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 = { +ActorInit Dm_Nb_InitVars = { ACTOR_DM_NB, ACTORCAT_NPC, FLAGS, @@ -28,37 +27,39 @@ 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[] = { + { &gNbIdleAnim, 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 +67,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, &gNbSkel, NULL, this->jointTable, this->morphTable, NB_LIMB_MAX); this->unk1F0 = -1; func_80C1DED0(this, 0); this->actor.flags &= ~ACTOR_FLAG_1; @@ -79,24 +79,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..3f35beea0 100644 --- a/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h +++ b/src/overlays/actors/ovl_Dm_Nb/z_dm_nb.h @@ -2,23 +2,22 @@ #define Z_DM_NB_H #include "global.h" +#include "objects/object_nb/object_nb.h" struct DmNb; -typedef void (*DmNbActionFunc)(struct DmNb*, GlobalContext*); +typedef void (*DmNbActionFunc)(struct DmNb*, PlayState*); typedef struct DmNb { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ DmNbActionFunc actionFunc; - /* 0x18C */ Vec3s jointTable[8]; - /* 0x1BC */ Vec3s morphTable[8]; + /* 0x18C */ Vec3s jointTable[NB_LIMB_MAX]; + /* 0x1BC */ Vec3s morphTable[NB_LIMB_MAX]; /* 0x1EC */ u8 unk1EC; /* 0x1F0 */ s32 unk1F0; /* 0x1F4 */ s32 unk1F4; /* 0x1F8 */ s32 unk1F8; } DmNb; // size = 0x1FC -extern const ActorInit Dm_Nb_InitVars; - #endif // Z_DM_NB_H diff --git a/src/overlays/actors/ovl_Dm_Opstage/overlay.cfg b/src/overlays/actors/ovl_Dm_Opstage/overlay.cfg deleted file mode 100644 index 17e40ea81..000000000 --- a/src/overlays/actors/ovl_Dm_Opstage/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Opstage -z_dm_opstage.c 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..db76db278 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.c @@ -1,26 +1,24 @@ /* * 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 = { +ActorInit Dm_Opstage_InitVars = { ACTOR_DM_OPSTAGE, ACTORCAT_ITEMACTION, FLAGS, @@ -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->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 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..3d9195413 100644 --- a/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h +++ b/src/overlays/actors/ovl_Dm_Opstage/z_dm_opstage.h @@ -3,17 +3,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; - #endif // Z_DM_OPSTAGE_H diff --git a/src/overlays/actors/ovl_Dm_Ravine/overlay.cfg b/src/overlays/actors/ovl_Dm_Ravine/overlay.cfg deleted file mode 100644 index a3287c407..000000000 --- a/src/overlays/actors/ovl_Dm_Ravine/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Ravine -z_dm_ravine.c 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 25a68056e..25fee11db 100644 --- a/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c +++ b/src/overlays/actors/ovl_Dm_Ravine/z_dm_ravine.c @@ -10,13 +10,13 @@ #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 = { +ActorInit Dm_Ravine_InitVars = { ACTOR_DM_RAVINE, ACTORCAT_ITEMACTION, FLAGS, @@ -28,30 +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; - if (((((void)0, gSaveContext.save.weekEventReg[0]) & 0x10) | cREG(0)) != 0) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG_ALT(WEEKEVENTREG_00_10) | cREG(0)) { + Actor_Kill(&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; @@ -60,21 +60,21 @@ 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 } } break; case DM_RAVINE_STATE_PENDING_DEATH: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; } } -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..01b9b52af 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, @@ -20,6 +20,4 @@ typedef struct DmRavine { /* 0x149 */ u8 isActive; } DmRavine; // size = 0x14C -extern const ActorInit Dm_Ravine_InitVars; - #endif // Z_DM_RAVINE_H diff --git a/src/overlays/actors/ovl_Dm_Sa/overlay.cfg b/src/overlays/actors/ovl_Dm_Sa/overlay.cfg deleted file mode 100644 index 3916c7965..000000000 --- a/src/overlays/actors/ovl_Dm_Sa/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Sa -z_dm_sa.c 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..dc6d8bcef 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -11,14 +11,14 @@ #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 = { +ActorInit Dm_Sa_InitVars = { ACTOR_DM_SA, ACTORCAT_ITEMACTION, FLAGS, @@ -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,82 +45,80 @@ 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) { - Gfx* dList; - Gfx* dListHead; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); //! @bug this does not allocate enough for 3 Gfx commands; + Gfx* gfx = gfxHead; - dList = dListHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); //! @bug this does not allocate enough for 3 Gfx commands - gDPSetRenderMode(dListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); - gDPSetEnvColor(dListHead++, 0, 0, 0, alpha); - gSPEndDisplayList(dListHead++); + gDPSetRenderMode(gfx++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(gfx++, 0, 0, 0, alpha); + gSPEndDisplayList(gfx++); - return dList; + return gfxHead; } Gfx* func_80A2EBB0(GraphicsContext* gfxCtx, u32 alpha) { - Gfx* dList; - Gfx* dListHead; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; - dList = dListHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); - gDPSetEnvColor(dListHead++, 0, 0, 0, alpha); - gSPEndDisplayList(dListHead++); + gDPSetEnvColor(gfx++, 0, 0, 0, alpha); + gSPEndDisplayList(gfx++); - return dList; + return gfxHead; } -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..3dd827a15 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; @@ -20,6 +20,4 @@ typedef struct DmSa { /* 0x2F0 */ u32 alpha; } DmSa; // size = 0x2F4 -extern const ActorInit Dm_Sa_InitVars; - #endif // Z_DM_SA_H diff --git a/src/overlays/actors/ovl_Dm_Statue/overlay.cfg b/src/overlays/actors/ovl_Dm_Statue/overlay.cfg deleted file mode 100644 index d01c4284e..000000000 --- a/src/overlays/actors/ovl_Dm_Statue/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Statue -z_dm_statue.c 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..11f2724de 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Dm_Statue_InitVars = { ACTOR_DM_STATUE, ACTORCAT_ITEMACTION, FLAGS, @@ -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_Statue/z_dm_statue.h b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.h index 1ad123523..eb06acd01 100644 --- a/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.h +++ b/src/overlays/actors/ovl_Dm_Statue/z_dm_statue.h @@ -10,6 +10,4 @@ typedef struct DmStatue { /* 0x144 */ char unk_144[0x50]; } DmStatue; // size = 0x194 -extern const ActorInit Dm_Statue_InitVars; - #endif // Z_DM_STATUE_H diff --git a/src/overlays/actors/ovl_Dm_Stk/overlay.cfg b/src/overlays/actors/ovl_Dm_Stk/overlay.cfg deleted file mode 100644 index 628231122..000000000 --- a/src/overlays/actors/ovl_Dm_Stk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Stk -z_dm_stk.c 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 782ef8679..4f9d7d702 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,27 +16,141 @@ #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); -const ActorInit Dm_Stk_InitVars = { +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; + +ActorInit Dm_Stk_InitVars = { ACTOR_DM_STK, ACTORCAT_ITEMACTION, FLAGS, @@ -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] = VIRTUAL_TO_PHYSICAL(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,10 +662,15 @@ 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); + Audio_PlayAmbience(AMBIENCE_ID_0C); break; case 660: @@ -505,12 +679,16 @@ 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); + Audio_PlayAmbience(AMBIENCE_ID_0C); break; case 45: @@ -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->sceneId) { case SCENE_LOST_WOODS: - if (gSaveContext.sceneSetupIndex == 1) { - func_80A9FED8(this, globalCtx); - } else if (gSaveContext.sceneSetupIndex == 0) { - func_80AA0100(this, globalCtx); - } else if ((gSaveContext.sceneSetupIndex == 2) && (globalCtx->csCtx.currentCsIndex == 0)) { - func_80AA0158(this, globalCtx); + if (gSaveContext.sceneLayer == 1) { + DmStk_PlaySfxForIntroCutsceneFirstPart(this, play); + } else if (gSaveContext.sceneLayer == 0) { + DmStk_PlaySfxForIntroCutsceneSecondPart(this, play); + } else if ((gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) { + DmStk_PlaySfxForObtainingMajorasMaskCutscene(this, play); } break; case SCENE_CLOCKTOWER: - if (gSaveContext.sceneSetupIndex == 1) { - func_80AA00CC(this, globalCtx); + if (gSaveContext.sceneLayer == 1) { + 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 (gSaveContext.sceneLayer == 0) { + 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 (gSaveContext.sceneLayer == 0) { + 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); + } else if (gSaveContext.sceneLayer == 2) { + 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 (gSaveContext.sceneLayer == 3) { + 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); + } else if (gSaveContext.sceneLayer == 7) { + 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,236 +1006,252 @@ 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) { - Actor_MarkForDeath(&this->actor); + 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_Kill(&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->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1)) { + this->alpha = 0; + this->fogN = 0; + this->fogF = 1000; + this->fogScale = 1.0f; + this->actionFunc = DmStk_DoNothing; + } else if (play->sceneId == 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.sceneSetupIndex == 0) { - if (gSaveContext.unk_3DD0[3] == 0) { - func_8010E9F0(3, 300); - XREG(80) = 200; - XREG(81) = 115; + if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_ROOFTOP, 0)) { + if (gSaveContext.sceneLayer == 0) { + if (gSaveContext.timerStates[TIMER_ID_MOON_CRASH] == TIMER_STATE_OFF) { + // Starts a 5 minute (300 second) timer until the moon falls. + Interface_StartTimer(TIMER_ID_MOON_CRASH, 300); + R_MOON_CRASH_TIMER_Y = 200; + R_MOON_CRASH_TIMER_X = 115; } 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; - if (gSaveContext.unk_3DD0[3] == 0) { - func_8010E9F0(3, 60); - XREG(80) = 200; - XREG(81) = 115; + } else if (gSaveContext.sceneLayer == 3) { + this->animIndex = SK_ANIM_FLOATING_ARMS_CROSSED; + if (gSaveContext.timerStates[TIMER_ID_MOON_CRASH] == TIMER_STATE_OFF) { + // This code is called when the Giants fail to stop the moon. + // Starts a 1 minute (60 second) timer until the moon falls. + Interface_StartTimer(TIMER_ID_MOON_CRASH, 60); + R_MOON_CRASH_TIMER_Y = 200; + R_MOON_CRASH_TIMER_X = 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)) { - Actor_MarkForDeath(&this->actor); + } else if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 0)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + Actor_Kill(&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)) { - Actor_MarkForDeath(&this->actor); + if ((play->sceneId == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { + Actor_Kill(&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->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 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)) { - func_800FE484(); - this->actionFunc = func_80AA17F8; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_74_20)) { + 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))) { + Environment_StopTime(); + 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; - } else if ((gSaveContext.save.weekEventReg[8] & 0x40) || + cutscene = dayOneAndTwoCutscene; + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40) || ((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; + Environment_StartTime(); + 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,298 +1261,311 @@ 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; - if (!(player->stateFlags2 & 0x8000000)) { - Message_StartTextbox(globalCtx, 0x2013, &this->actor); + DmStk_ClockTower_AdjustHeightAndRotation(this, play); + this->deflectCount++; + if (this->deflectCount >= 3) { + this->deflectCount = 0; + if (!(player->stateFlags2 & PLAYER_STATE2_8000000)) { + // 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->sceneId == 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; case 25: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); 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,470 +1573,488 @@ 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; - gSaveContext.save.weekEventReg[12] |= 4; - if (!(globalCtx->actorCtx.unk5 & 2)) { - Actor_MarkForDeath(&this->actor); + this->fadeOutTimer++; + if (this->fadeOutTimer >= 44) { + this->alpha -= 35; + if (this->alpha < 0) { + this->alpha = 0; + this->fadeOutState = SK_FADE_OUT_STATE_NONE; + SET_WEEKEVENTREG(WEEKEVENTREG_12_04); + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + Actor_Kill(&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->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 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; - if (!(player->stateFlags2 & 0x8000000)) { - Message_StartTextbox(globalCtx, 0x2014, &this->actor); + this->tatlMessageTimer++; + if (this->tatlMessageTimer > 800) { + this->tatlMessageTimer = 0; + if (!(player->stateFlags2 & PLAYER_STATE2_8000000)) { + // 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; - 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->sceneId == 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)) { - 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); + // 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.flags & ACTORCTX_FLAG_1) && (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)R_TIME_SPEED; + if (R_TIME_SPEED != 0) { + gSaveContext.save.time = + ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset); } } } - if ((globalCtx->sceneNum == SCENE_00KEIKOKU) && (gSaveContext.sceneSetupIndex == 3) && - (globalCtx->csCtx.currentCsIndex > 0)) { - globalCtx->envCtx.unk_17 = 15; - globalCtx->envCtx.unk_18 = 15; + if ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 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_MultZero(&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->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 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)) { + 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] = VIRTUAL_TO_PHYSICAL(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] = VIRTUAL_TO_PHYSICAL(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_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->sceneId == SCENE_LOST_WOODS) && (gSaveContext.sceneLayer == 1)) { + gSPDisplayList(POLY_OPA_DISP++, gSkullKidOcarinaOfTimeDL); } break; - case 5: + 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->sceneId != SCENE_LOST_WOODS) || (gSaveContext.sceneLayer != 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] = VIRTUAL_TO_PHYSICAL(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..f55321ef7 100644 --- a/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h +++ b/src/overlays/actors/ovl_Dm_Stk/z_dm_stk.h @@ -2,46 +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; - #endif // Z_DM_STK_H diff --git a/src/overlays/actors/ovl_Dm_Tag/overlay.cfg b/src/overlays/actors/ovl_Dm_Tag/overlay.cfg deleted file mode 100644 index e1895969e..000000000 --- a/src/overlays/actors/ovl_Dm_Tag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Tag -z_dm_tag.c 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..ce1cc98f3 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.c @@ -10,16 +10,15 @@ #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 = { +ActorInit Dm_Tag_InitVars = { ACTOR_DM_TAG, ACTORCAT_ITEMACTION, FLAGS, @@ -31,30 +30,236 @@ const ActorInit Dm_Tag_InitVars = { (ActorFunc)NULL, }; -#endif +s32 D_80C22BF0[] = { + 0x0E28F00C, + 0x15090000, + 0x10000000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22350.s") +s32 D_80C22BFC[] = { + 0x0900000E, 0x28F10C09, 0x00000E28, 0xF20C0900, 0x000E28F3, 0x0C090000, 0x0E28F40C, + 0x0900000E, 0x28F50C09, 0x00000E28, 0xF60C1511, 0x55040900, 0x00100000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22400.s") +s32 D_80C22C30[] = { + 0x0E28EF0C, + 0x10000000, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C2247C.s") +Actor* func_80C22350(DmTag* this, PlayState* play, u8 actorCat, s16 actorId) { + Actor* foundActor = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C224D8.s") + while (true) { + foundActor = SubS_FindActor(play, foundActor, actorCat, actorId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C227E8.s") + if ((foundActor == NULL) || (((this != (DmTag*)foundActor)) && (foundActor->update != NULL))) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C22880.s") + if (foundActor->next == NULL) { + foundActor = NULL; + break; + } + foundActor = foundActor->next; + } + return foundActor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C2291C.s") +s32 func_80C22400(DmTag* this, s16 arg1) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C229AC.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(arg1); + } else if (ActorCutscene_GetCanPlayNext(arg1)) { + ActorCutscene_StartAndSetUnkLinkFields(arg1, &this->actor); + ret = true; + } else { + ActorCutscene_SetIntentToPlay(arg1); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C229EC.s") +s16 func_80C2247C(DmTag* this, s32 arg1) { + s32 i; + s16 cs = this->actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/func_80C229FC.s") + for (i = 0; i < arg1; i++) { + cs = ActorCutscene_GetAdditionalCutscene(cs); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Init.s") + return cs; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Destroy.s") +s32 func_80C224D8(DmTag* this, PlayState* play) { + s32 pad; + Actor* sp30; + Actor* sp2C; + s16 sp2A = this->actor.cutscene; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Tag/DmTag_Update.s") + sp30 = func_80C22350(this, play, ACTORCAT_NPC, ACTOR_EN_AN); + sp2C = func_80C22350(this, play, ACTORCAT_NPC, ACTOR_EN_AH); + + switch (this->unk_1A4) { + case 0: + if (func_80C22400(this, sp2A)) { + if ((sp2C != NULL) && (sp2C->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(sp2A)), sp2C); + } + this->unk_1A4++; + ret = true; + } + break; + + case 1: + if ((sp30 != NULL) && (sp30->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(func_80C2247C(this, 0))), + sp30); + } + this->unk_1A4++; + ret = true; + break; + + case 2: + ActorCutscene_Stop(func_80C2247C(this, 0)); + if (func_80C22400(this, func_80C2247C(this, 1))) { + this->unk_1A4++; + ret = true; + } + break; + + case 3: + ActorCutscene_Stop(func_80C2247C(this, 1)); + if (func_80C22400(this, func_80C2247C(this, 2))) { + this->unk_1A4++; + ret = true; + } + break; + + case 4: + ActorCutscene_Stop(func_80C2247C(this, 2)); + if (func_80C22400(this, func_80C2247C(this, 3))) { + this->unk_1A4++; + ret = true; + } + break; + + case 5: + ActorCutscene_Stop(func_80C2247C(this, 3)); + if (func_80C22400(this, func_80C2247C(this, 4))) { + this->unk_1A4++; + ret = true; + } + break; + + case 6: + func_800B7298(play, &this->actor, 7); + play->nextEntrance = ENTRANCE(STOCK_POT_INN, 5); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_06; + this->unk_1A4++; + break; + } + return ret; +} + +s32 func_80C227E8(DmTag* this, PlayState* play) { + if (this->unk_1A4 == 0) { + func_800B7298(play, &this->actor, 7); + play->nextEntrance = ENTRANCE(STOCK_POT_INN, 4); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_06; + this->unk_1A4++; + } + return false; +} + +s32* func_80C22880(DmTag* this, PlayState* play) { + s32 time; + + switch (this->unk_18E) { + case 1: + time = gSaveContext.save.time - 0x3FFC; + if ((time >= 0xA54B) && (time < 0xB54A) && (gSaveContext.save.day == 2)) { + this->msgEventCallback = func_80C227E8; + return D_80C22BF0; + } + return D_80C22C30; + case 2: + this->msgEventCallback = func_80C224D8; + return D_80C22BFC; + } + return NULL; +} + +s32 func_80C2291C(DmTag* this, PlayState* play) { + s32 ret = false; + + if (this->unk_18C & 7) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->unk_18C |= 8; + SubS_UpdateFlags(&this->unk_18C, 0, 7); + this->msgEventScript = func_80C22880(this, play); + this->actionFunc = func_80C229FC; + ret = true; + } + } + return ret; +} + +void func_80C229AC(DmTag* this, PlayState* play) { + SubS_UpdateFlags(&this->unk_18C, 3, 7); + this->actor.flags |= ACTOR_FLAG_1; +} + +void func_80C229EC(DmTag* this, PlayState* play) { +} + +void func_80C229FC(DmTag* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, this->msgEventScript, this->msgEventCallback, &this->msgEventArg4)) { + this->actionFunc = func_80C229AC; + } +} + +void DmTag_Init(Actor* thisx, PlayState* play) { + DmTag* this = (DmTag*)thisx; + Player* player = GET_PLAYER(play); + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_85_04)) { + Actor_Kill(&this->actor); + return; + } + + if ((play->sceneId == SCENE_YADOYA) && (play->curSpawn == 4)) { + player->stateFlags1 |= PLAYER_STATE1_20; + this->unk_18E = 2; + this->unk_18C = 0; + SubS_UpdateFlags(&this->unk_18C, 4, 7); + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80C229EC; + } else if (this->actor.room == 2) { + Actor_Kill(&this->actor); + } else { + this->actor.targetMode = 1; + this->unk_18E = 1; + this->unk_18C = 0; + this->actionFunc = func_80C229AC; + } +} + +void DmTag_Destroy(Actor* thisx, PlayState* play) { +} + +void DmTag_Update(Actor* thisx, PlayState* play) { + DmTag* this = THIS; + + func_80C2291C(this, play); + this->actionFunc(this, play); + func_8013C964(&this->actor, play, 40.0f, fabsf(this->actor.playerHeightRel) + 1.0f, 0, this->unk_18C & 7); + Actor_SetFocus(&this->actor, 0.0f); +} 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..eec741df6 100644 --- a/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h +++ b/src/overlays/actors/ovl_Dm_Tag/z_dm_tag.h @@ -5,15 +5,20 @@ struct DmTag; -typedef void (*DmTagActionFunc)(struct DmTag*, GlobalContext*); +typedef void (*DmTagActionFunc)(struct DmTag*, PlayState*); +typedef s32 (*DmTagMsgEventFunc)(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 */ UNK_TYPE1 pad144[0x44]; + /* 0x188 */ DmTagActionFunc actionFunc; + /* 0x18C */ u16 unk_18C; + /* 0x18E */ u8 unk_18E; + /* 0x190 */ s32* msgEventScript; + /* 0x194 */ s32 msgEventArg4; + /* 0x198 */ UNK_TYPE1 pad198[0xC]; + /* 0x1A4 */ s16 unk_1A4; + /* 0x1A8 */ DmTagMsgEventFunc msgEventCallback; } DmTag; // size = 0x1AC -extern const ActorInit Dm_Tag_InitVars; - #endif // Z_DM_TAG_H diff --git a/src/overlays/actors/ovl_Dm_Tsg/overlay.cfg b/src/overlays/actors/ovl_Dm_Tsg/overlay.cfg deleted file mode 100644 index cf5632fbb..000000000 --- a/src/overlays/actors/ovl_Dm_Tsg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Tsg -z_dm_tsg.c 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..7dec0540e 100644 --- a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c +++ b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.c @@ -10,13 +10,13 @@ #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 = { +ActorInit Dm_Tsg_InitVars = { ACTOR_DM_TSG, ACTORCAT_ITEMACTION, FLAGS, diff --git a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.h b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.h index e1263ef2d..e8e62b6c2 100644 --- a/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.h +++ b/src/overlays/actors/ovl_Dm_Tsg/z_dm_tsg.h @@ -10,6 +10,4 @@ typedef struct DmTsg { /* 0x144 */ char unk_144[0x7DC]; } DmTsg; // size = 0x920 -extern const ActorInit Dm_Tsg_InitVars; - #endif // Z_DM_TSG_H diff --git a/src/overlays/actors/ovl_Dm_Zl/overlay.cfg b/src/overlays/actors/ovl_Dm_Zl/overlay.cfg deleted file mode 100644 index 541103127..000000000 --- a/src/overlays/actors/ovl_Dm_Zl/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Dm_Zl -z_dm_zl.c 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..a671fe3f2 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,15 +10,14 @@ #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 = { +ActorInit Dm_Zl_InitVars = { ACTOR_DM_ZL, ACTORCAT_ITEMACTION, FLAGS, @@ -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..cae6ce74e 100644 --- a/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h +++ b/src/overlays/actors/ovl_Dm_Zl/z_dm_zl.h @@ -2,18 +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; - #endif // Z_DM_ZL_H diff --git a/src/overlays/actors/ovl_Door_Ana/overlay.cfg b/src/overlays/actors/ovl_Door_Ana/overlay.cfg deleted file mode 100644 index cb3d1a5fd..000000000 --- a/src/overlays/actors/ovl_Door_Ana/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Door_Ana -z_door_ana.c 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..9086a052d 100644 --- a/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -11,16 +11,16 @@ #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 = { +ActorInit Door_Ana_InitVars = { ACTOR_DOOR_ANA, ACTORCAT_ITEMACTION, FLAGS, @@ -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,26 @@ 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 & PLAYER_STATE1_80000000) && + (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, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_4)); 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,15 +153,15 @@ 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 & (PLAYER_STATE1_8000000 | PLAYER_STATE1_800000)) && (this->actor.xzDistToPlayer <= 20.0f) && (this->actor.playerHeightRel >= -50.0f) && (this->actor.playerHeightRel <= 15.0f)) { - player->stateFlags1 |= 0x80000000; + player->stateFlags1 |= PLAYER_STATE1_80000000; this->actor.targetMode = 1; } else { @@ -170,7 +172,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 +185,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..8e016824d 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; @@ -13,8 +13,6 @@ typedef struct DoorAna { /* 0x190 */ DoorAnaActionFunc actionFunc; } DoorAna; // size = 0x194 -extern const ActorInit Door_Ana_InitVars; - #define DOORANA_TYPE_BITMASK 0x300 #define DOORANA_TYPE_VISIBLE 0x000 #define DOORANA_TYPE_HIDDEN_STORMS 0x100 // Incomplete, leftover from OoT diff --git a/src/overlays/actors/ovl_Door_Shutter/overlay.cfg b/src/overlays/actors/ovl_Door_Shutter/overlay.cfg deleted file mode 100644 index f3b63c1cc..000000000 --- a/src/overlays/actors/ovl_Door_Shutter/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Door_Shutter -z_door_shutter.c 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 fe52a8288..db564f3f2 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,8 @@ */ #include "z_door_shutter.h" +#include "z64quake.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,23 +24,23 @@ #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* play2); +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 = { +ActorInit Door_Shutter_InitVars = { ACTOR_DOOR_SHUTTER, ACTORCAT_DOOR, FLAGS, @@ -73,11 +75,11 @@ typedef struct { } ShutterInfo; // size = 0xC ShutterInfo D_808A21B0[] = { - { object_bdoor_DL_0000C0, NULL, 130, 12, 50, 15 }, + { gBossDoorDL, NULL, 130, 12, 50, 15 }, { gameplay_keep_DL_077990, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, { object_numa_obj_DL_007150, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, { object_hakugin_obj_DL_000128, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, - { object_dblue_object_DL_017D00, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, + { gGreatBayTempleObjectDoorDL, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, { object_ikana_obj_DL_014A40, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, { object_redead_obj_DL_0001A0, gameplay_keep_DL_078A80, 130, 12, 20, 15 }, { object_ikninside_obj_DL_004440, object_ikninside_obj_DL_005260, 130, 0, 20, 15 }, @@ -99,7 +101,7 @@ static InitChainEntry sInitChain[] = { }; typedef struct { - /* 0x00 */ s16 sceneNum; + /* 0x00 */ s16 sceneId; /* 0x02 */ u8 index; } ShutterSceneInfo; // size = 0x4 @@ -113,8 +115,8 @@ ShutterSceneInfo D_808A2258[] = { }; typedef struct { - /* 0x00 */ s16 dungeonScene; - /* 0x02 */ s16 bossScene; + /* 0x00 */ s16 dungeonSceneId; + /* 0x02 */ s16 bossSceneId; /* 0x04 */ u8 index; } BossDoorInfo; // size = 0x6 @@ -128,8 +130,7 @@ Vec3f D_808A22C4 = { 120.0f, 0.0f, 0.0f }; Vec3f D_808A22D0 = { -90.0f, 0.0f, 0.0f }; TexturePtr D_808A22DC[] = { - object_bdoor_Tex_006BA0, object_bdoor_Tex_005BA0, object_bdoor_Tex_0005C0, - object_bdoor_Tex_004BA0, object_bdoor_Tex_003BA0, + gBossDoorDefaultTex, gBossDoorWoodfallTex, gBossDoorSnowheadTex, gBossDoorGreatBayTex, gBossDoorStoneTowerTex, }; void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc) { @@ -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,12 +195,11 @@ 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; - s8 objId; Actor_ProcessInitChain(&this->actor, sInitChain); this->doorType = DOORSHUTTER_GET_380(&this->actor); @@ -209,7 +209,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->sceneId == shutterSceneInfo->sceneId) { break; } } @@ -222,8 +222,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->sceneId == bossDoorInfo->dungeonSceneId) || (play->sceneId == bossDoorInfo->bossSceneId)) { break; } } @@ -233,15 +232,16 @@ void DoorShutter_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.room = -1; } - // clang-format off - objId = Object_GetIndex(&globalCtx->objectCtx, D_808A2180[sp24].objectId); this->requiredObjBankIndex = objId; if (objId < 0) { Actor_MarkForDeath(&this->actor); return; } - // clang-format on + if ((this->requiredObjBankIndex = Object_GetIndex(&play->objectCtx, D_808A2180[sp24].objectId)) < 0) { + Actor_Kill(&this->actor); + return; + } 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,28 @@ 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) && + (!R_PLAY_FILL_SCREEN_ON || (R_PLAY_FILL_SCREEN_ALPHA == 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 +286,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 +308,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,31 +319,31 @@ 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->doorType = PLAYER_DOORTYPE_TALKING; player->doorActor = &this->actor; this->actor.textId = 0x1801; func_80122F28(player); } } -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,12 +352,12 @@ 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->doorType = PLAYER_DOORTYPE_SLIDING; player->doorDirection = doorDirection; player->doorActor = &this->actor; @@ -368,18 +369,18 @@ void func_808A1090(DoorShutter* this, GlobalContext* globalCtx) { if (this->doorType == 6) { if (gSaveContext.save.playerData.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { - player->doorType = -1; + player->doorType = PLAYER_DOORTYPE_TALKING; this->actor.textId = 0x14FC; } } else if (this->unk_166 != 0) { if (this->doorType == 5) { - if (!CHECK_DUNGEON_ITEM(0, gSaveContext.mapIndex)) { - player->doorType = -1; + if (!CHECK_DUNGEON_ITEM(DUNGEON_BOSS_KEY, gSaveContext.mapIndex)) { + player->doorType = PLAYER_DOORTYPE_TALKING; this->actor.textId = 0x1803; } player->doorTimer += 10; } else if (DUNGEON_KEY_COUNT(gSaveContext.mapIndex) <= 0) { - player->doorType = -1; + player->doorType = PLAYER_DOORTYPE_TALKING; this->actor.textId = 0x1802; } else { player->doorTimer += 10; @@ -390,13 +391,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 +406,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 +444,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 +455,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, PLAYER_CSMODE_1); } } @@ -464,9 +465,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,10 +476,10 @@ 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->doorType = PLAYER_DOORTYPE_TALKING; player->doorActor = &this->actor; this->actor.textId = 0x1800; func_80122F28(player); @@ -486,18 +487,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 +509,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,61 +519,60 @@ 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); } - func_801A2ED8(); + Audio_RestorePrevBgm(); } } -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.curRoom; - globalCtx->roomCtx.currRoom = globalCtx->roomCtx.prevRoom; - globalCtx->roomCtx.prevRoom = temp; - globalCtx->roomCtx.activeMemPage ^= 1; + play->roomCtx.curRoom = 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 & PLAYER_STATE1_800)) { DoorShutter_SetupAction(this, func_808A1C50); if (ActorCutscene_GetCurrentIndex() == 0x7D) { - func_801226E0(globalCtx, ((void)0, gSaveContext.respawn[RESTART_MODE_DOWN].data)); + func_801226E0(play, ((void)0, gSaveContext.respawn[RESPAWN_MODE_DOWN].data)); player->unk_A86 = -1; - func_800B7298(globalCtx, NULL, 0x73); + func_800B7298(play, NULL, PLAYER_CSMODE_115); } } } @@ -600,39 +600,43 @@ s32 func_808A1A70(DoorShutter* this) { return false; } -void func_808A1B48(DoorShutter* this, GlobalContext* globalCtx) { - s16 quake; +void func_808A1B48(DoorShutter* this, PlayState* play) { + s16 quakeIndex; 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_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); + + quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, -32536); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 10); + + 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 == PLAYER_CSMODE_115) { + func_800B7298(play, NULL, PLAYER_CSMODE_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); + if (!(player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_400 | PLAYER_STATE1_10000000)) || + (this->actionFunc == DoorShutter_SetupType)) { + 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; @@ -640,15 +644,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); @@ -660,17 +664,17 @@ 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_Translate(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); @@ -680,11 +684,11 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { 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_RotateYF(M_PI, MTXMODE_APPLY); @@ -696,22 +700,21 @@ void DoorShutter_Draw(Actor* thisx, GlobalContext* globalCtx) { 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_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..c64d3d523 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; @@ -28,6 +28,4 @@ typedef struct DoorShutter { /* 0x016C */ DoorShutterActionFunc actionFunc; } DoorShutter; // size = 0x170 -extern const ActorInit Door_Shutter_InitVars; - #endif // Z_DOOR_SHUTTER_H diff --git a/src/overlays/actors/ovl_Door_Spiral/overlay.cfg b/src/overlays/actors/ovl_Door_Spiral/overlay.cfg deleted file mode 100644 index f33e851b5..000000000 --- a/src/overlays/actors/ovl_Door_Spiral/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Door_Spiral -z_door_spiral.c 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..541e3de23 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, @@ -58,20 +54,20 @@ typedef struct { // Maps scenes to SpiralObjectType typedef struct { - /* 0x00 */ s16 sceneNum; + /* 0x00 */ s16 sceneId; /* 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 = { +ActorInit Door_Spiral_InitVars = { ACTOR_DOOR_SPIRAL, ACTORCAT_DOOR, FLAGS, @@ -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.curRoom.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->sceneId == sceneInfo->sceneId) { 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,26 +172,26 @@ 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) { - Actor_MarkForDeath(&this->actor); + if (this->actor.room != play->doorCtx.transitionActorList[transition].sides[0].room) { + Actor_Kill(&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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -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->doorType = PLAYER_DOORTYPE_STAIRCASE; 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,26 +287,27 @@ 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)) { + if (!(player->stateFlags1 & PLAYER_STATE1_20000000)) { DoorSpiral_SetupAction(this, DoorSpiral_WaitForObject); this->shouldClimb = 0; } } -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); + if (!(player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_400 | PLAYER_STATE1_10000000)) || + (this->actionFunc == DoorSpiral_WaitForObject)) { + 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 +319,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..0f3e32a39 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; @@ -19,6 +23,4 @@ typedef struct DoorSpiral { /* 0x14C */ DoorSpiralActionFunc actionFunc; } DoorSpiral; // size = 0x150 -extern const ActorInit Door_Spiral_InitVars; - #endif // Z_DOOR_SPIRAL_H diff --git a/src/overlays/actors/ovl_Door_Warp1/overlay.cfg b/src/overlays/actors/ovl_Door_Warp1/overlay.cfg deleted file mode 100644 index 764603654..000000000 --- a/src/overlays/actors/ovl_Door_Warp1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Door_Warp1 -z_door_warp1.c 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 6217361f2..bc168d534 100644 --- a/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c +++ b/src/overlays/actors/ovl_Door_Warp1/z_door_warp1.c @@ -1,7 +1,7 @@ /* * File: z_door_warp1.c * Overlay: ovl_Door_Warp1 - * Description: Blue Warp + * Description: Blue warp portal and crystal, and the Majora's Mask-shaped boss warp platform */ #include "z_door_warp1.h" @@ -11,45 +11,45 @@ #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; -const ActorInit Door_Warp1_InitVars = { +ActorInit Door_Warp1_InitVars = { ACTOR_DOOR_WARP1, ACTORCAT_ITEMACTION, FLAGS, @@ -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->sceneId == SCENE_MITURIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) { ret = 1; - } else if ((globalCtx->sceneNum == SCENE_HAKUGIN_BS) && !CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { + } else if ((play->sceneId == 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->sceneId == 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->sceneId == 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, &gWarpBossWarpPlatformCol); + 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)) { - func_800FE484(); - globalCtx->interfaceCtx.restrictions.unk_312 = 1; - globalCtx->interfaceCtx.restrictions.songOfSoaring = 1; + if ((play->sceneId == SCENE_MITURIN_BS) || (play->sceneId == SCENE_HAKUGIN_BS) || + (play->sceneId == SCENE_INISIE_BS) || (play->sceneId == SCENE_SEA_BS)) { + Environment_StopTime(); + play->interfaceCtx.restrictions.songOfTime = 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,9 +209,9 @@ 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); - Animation_ChangeImpl(&this->skelAnime, &object_warp1_Anim_001374, 1.0f, 1.0f, 1.0f, 2, 40.0f, 1); +void func_808B8A7C(DoorWarp1* this, PlayState* play) { + SkelAnime_Init(play, &this->skelAnime, &gWarpCrystalSkel, &gWarpCrystalAnim, NULL, NULL, 0); + Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, 1.0f, 1.0f, 2, 40.0f, 1); this->unk_1C4 = 0; this->unk_1C6 = -140; this->unk_1C8 = -80; @@ -232,31 +232,31 @@ 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, this->dyna.actor.world.pos.z, 200, 255, 255, 255); Lights_PointNoGlowSetInfo(&this->unk_1F4, this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 200, 255, 255, 255); - if (((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_2) && CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) || + if (((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_2) && CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) || ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_3) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) || ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_4) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) || ((DOORWARP1_GET_FF(&this->dyna.actor) == ENDOORWARP1_FF_5) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD))) { s16 params = DOORWARP1_GET_FF00_2(&this->dyna.actor); params |= 6; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_DOOR_WARP1, - this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 10.0f, - this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, this->dyna.actor.world.rot.y, - this->dyna.actor.world.rot.z, params); + 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,9 +268,9 @@ 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->sceneId == SCENE_INISIE_N) { DoorWarp1_SetupAction(this, func_808B96A0); - } else if (gSaveContext.save.weekEventReg[86] & 0x80) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_80)) { this->unk_1D4 = 0; DoorWarp1_SetupAction(this, func_808B921C); } else { @@ -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->sceneId == SCENE_MITURIN) { sp2E = -10; phi_f0 = -5.0f; - } else if (globalCtx->sceneNum == SCENE_HAKUGIN) { + } else if (play->sceneId == SCENE_HAKUGIN) { sp2E = -20; - } else if (globalCtx->sceneNum == SCENE_SEA) { + } else if (play->sceneId == 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, PLAYER_CSMODE_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, PLAYER_CSMODE_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, PLAYER_CSMODE_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, PLAYER_CSMODE_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->sceneId) { 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); + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + func_800B7298(play, &this->dyna.actor, PLAYER_CSMODE_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,44 +607,44 @@ 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); - 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); + ActorCutscene_Start(play->playerActorCsIds[9], NULL); + AudioSfx_PlaySfx(NA_SE_EV_LINK_WARP, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + Animation_ChangeImpl(&this->skelAnime, &gWarpCrystalAnim, 1.0f, Animation_GetLastFrame(&gWarpCrystalAnim), + Animation_GetLastFrame(&gWarpCrystalAnim), 2, 40.0f, 1); this->unk_1CA = 50; D_808BC004 = player2->actor.world.pos.y; DoorWarp1_SetupAction(this, func_808BA550); } } -void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { +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->sceneId == SCENE_MITURIN_BS) || (play->sceneId == SCENE_HAKUGIN_BS) || + (play->sceneId == SCENE_INISIE_BS) || (play->sceneId == SCENE_SEA_BS)) { + D_801F4DE2 = play->sceneId; + if (play->sceneId == SCENE_MITURIN_BS) { phi_v0_2 = 0; - } else if (globalCtx->sceneNum == SCENE_HAKUGIN_BS) { + } else if (play->sceneId == SCENE_HAKUGIN_BS) { phi_v0_2 = 1; - } else if (globalCtx->sceneNum == SCENE_INISIE_BS) { + } else if (play->sceneId == SCENE_INISIE_BS) { phi_v0_2 = 2; - } else if (globalCtx->sceneNum == SCENE_SEA_BS) { + } else if (play->sceneId == SCENE_SEA_BS) { phi_v0_2 = 3; } else { phi_v0_2 = 0; @@ -652,7 +652,7 @@ void func_808BA10C(DoorWarp1* this, GlobalContext* globalCtx) { if (this->unk_202 != 0) { if (phi_v0_2 > 0) { - gSaveContext.save.weekEventReg[7] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_07_80); } switch (phi_v0_2) { @@ -699,64 +699,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; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + SET_WEEKEVENTREG(WEEKEVENTREG_07_80); + 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; + SET_WEEKEVENTREG(WEEKEVENTREG_33_80); + 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; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + 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; + SET_WEEKEVENTREG(WEEKEVENTREG_55_80); + 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; + SET_WEEKEVENTREG(WEEKEVENTREG_52_20); + 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 +764,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 +829,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,36 +864,36 @@ 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.curRoom.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->sceneId == SCENE_SEA) { phi_f2 = 85.0f; } - if (!(gSaveContext.save.weekEventReg[86] & 0x80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_86_80) && (fabsf(this->dyna.actor.xzDistToPlayer) < phi_f2) && ((player->actor.world.pos.y - 20.0f) < this->dyna.actor.world.pos.y) && (this->dyna.actor.world.pos.y < (player->actor.world.pos.y + 20.0f))) { cutscene = this->dyna.actor.cutscene; if (ActorCutscene_GetCanPlayNext(cutscene)) { ActorCutscene_Start(cutscene, &this->dyna.actor); - gSaveContext.save.weekEventReg[86] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_86_80); DoorWarp1_SetupAction(this, func_808BABF4); } else { ActorCutscene_SetIntentToPlay(cutscene); @@ -901,10 +901,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 +917,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,11 +963,11 @@ 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); @@ -980,18 +980,18 @@ void func_808BAE9C(DoorWarp1* this, GlobalContext* globalCtx) { } Matrix_Scale(phi_f12, phi_f12, phi_f12, MTXMODE_APPLY); - gSPSegment(POLY_XLU_DISP++, 0x0A, Matrix_NewMtx(globalCtx->state.gfxCtx)); + 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_Translate(0.0f, this->unk_1A4 * 230.0f, 0.0f, MTXMODE_APPLY); Matrix_Scale(((this->unk_1C6 * sp90) / 100.0f) + 1.0f, 1.0f, ((this->unk_1C6 * sp90) / 100.0f) + 1.0f, MTXMODE_APPLY); - gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(globalCtx->state.gfxCtx)); - gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(play->state.gfxCtx)); + gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); Matrix_Pop(); @@ -1001,26 +1001,26 @@ 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_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)); - gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0001A0); + gSPSegment(POLY_XLU_DISP++, 0x09, Matrix_NewMtx(play->state.gfxCtx)); + gSPDisplayList(POLY_XLU_DISP++, gWarpPortalDL); } - 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, gWarpBossWarpPlatformDL); } -void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void func_808BB4F4(DoorWarp1* this, PlayState* play2) { + PlayState* play = play2; s32 pad; Color_RGB8 sp64[] = { { 50, 150, 0 }, @@ -1034,17 +1034,17 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { 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(gWarpBossWarpActivationBeamTexAnim)); + Gfx_DrawDListXlu(play, gWarpBossWarpActivationBeamDL); return; } - if (globalCtx->sceneNum != SCENE_MITURIN) { - if (globalCtx->sceneNum == SCENE_HAKUGIN) { + if (play->sceneId != SCENE_MITURIN) { + if (play->sceneId == SCENE_HAKUGIN) { sp60 = 1; - } else if (globalCtx->sceneNum == SCENE_SEA) { + } else if (play->sceneId == SCENE_SEA) { sp60 = 2; - } else if (globalCtx->sceneNum == SCENE_INISIE_R) { + } else if (play->sceneId == SCENE_INISIE_R) { sp60 = 3; } } @@ -1053,64 +1053,64 @@ void func_808BB4F4(DoorWarp1* this, GlobalContext* globalCtx2) { 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(gWarpBossWarpLightShaftsTexAnim)); - 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); - gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_004690); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWarpBossWarpLightShaftsDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_warp1_Matanimheader_007238)); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWarpBossWarpGlowTexAnim)); Matrix_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, MTXMODE_NEW); Matrix_RotateYS(this->dyna.actor.world.rot.y, MTXMODE_APPLY); Matrix_Scale(1.0f, 0.0f, 1.0f, MTXMODE_APPLY); - func_8012C2DC(globalCtx->state.gfxCtx); + 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); - gSPDisplayList(POLY_XLU_DISP++, object_warp1_DL_0058C8); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWarpBossWarpGlowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -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; } } -void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2) { +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; @@ -1148,6 +1148,6 @@ void func_808BB8D4(DoorWarp1* this, GlobalContext* globalCtx, s32 arg2) { sVelocity.x = -Math_SinS(rand - 0x8000) * 5.0f; sVelocity.z = Math_CosS(rand - 0x8000) * 5.0f; } - EffectSsKirakira_SpawnDispersed(globalCtx, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); + EffectSsKirakira_SpawnDispersed(play, &pos, &sVelocity, &sAccel, &primColor, &envColor, scale, life); } } 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..076999e57 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,38 +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; - #endif // Z_DOOR_WARP1_H diff --git a/src/overlays/actors/ovl_Eff_Change/overlay.cfg b/src/overlays/actors/ovl_Eff_Change/overlay.cfg deleted file mode 100644 index 6ab11cfbd..000000000 --- a/src/overlays/actors/ovl_Eff_Change/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Eff_Change -z_eff_change.c 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..9174fafc0 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -10,12 +10,15 @@ #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); -#if 0 -const ActorInit Eff_Change_InitVars = { +void EffChange_SetColors(EffChange* this, s32 arg1); +void func_80A4C5CC(EffChange* this, PlayState* play); + +ActorInit Eff_Change_InitVars = { ACTOR_EFF_CHANGE, ACTORCAT_ITEMACTION, FLAGS, @@ -27,16 +30,119 @@ 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_Kill(&this->actor); + ActorCutscene_Stop(0x7B); + func_800FD2B4(play, 0.0f, 850.0f, 0.2f, 0.0f); + return; + } + + 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, 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..194ae3ee2 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.h +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.h @@ -2,17 +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; - #endif // Z_EFF_CHANGE_H diff --git a/src/overlays/actors/ovl_Eff_Dust/overlay.cfg b/src/overlays/actors/ovl_Eff_Dust/overlay.cfg deleted file mode 100644 index 2833a83d0..000000000 --- a/src/overlays/actors/ovl_Eff_Dust/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Eff_Dust -z_eff_dust.c 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 211b32412..2833477e4 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -12,19 +12,19 @@ #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* play2); +void func_809199FC(Actor* thisx, PlayState* play2); -const ActorInit Eff_Dust_InitVars = { +ActorInit Eff_Dust_InitVars = { ACTOR_EFF_DUST, ACTORCAT_NPC, FLAGS, @@ -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; @@ -71,7 +71,7 @@ void EffDust_Init(Actor* thisx, GlobalContext* globalCtx) { this->dz = 0.8f; this->scalingFactor = 0.5f; break; - case EFF_DUST_TYPE_2: + case EFF_DUST_TYPE_SPIN_ATTACK_CHARGE: case EFF_DUST_TYPE_3: this->actionFunc = func_80919230; this->actor.draw = func_809199FC; @@ -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,19 +163,19 @@ 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; s32 j; - if (parent == NULL || parent->update == NULL || !(player->stateFlags1 & 0x1000)) { + if (parent == NULL || parent->update == NULL || !(player->stateFlags1 & PLAYER_STATE1_1000)) { if (this->life != 0) { this->life--; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } for (i = 0; i < ARRAY_COUNT(this->distanceTraveled); i++) { @@ -203,7 +203,7 @@ void func_80919230(EffDust* this, GlobalContext* globalCtx) { if (this->distanceTraveled[i] >= 1.0f) { theta = randPlusMinusPoint5Scaled(0x10000); switch (this->actor.params) { - case EFF_DUST_TYPE_2: + case EFF_DUST_TYPE_SPIN_ATTACK_CHARGE: this->initialPositions[i].x = (Rand_ZeroOne() * 4500.0f) + 700.0f; if (this->initialPositions[i].x > 3000.0f) { this->initialPositions[i].y = (3000.0f * Rand_ZeroOne()) * Math_SinS(theta); @@ -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); @@ -290,7 +290,7 @@ void func_80919768(Actor* thisx, GlobalContext* globalCtx2) { initialPositions->z * ((this->dz * aux) + (1.0f - this->dz)), MTXMODE_APPLY); Matrix_Scale(this->scalingFactor, this->scalingFactor, this->scalingFactor, MTXMODE_APPLY); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -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); @@ -347,7 +347,7 @@ void func_809199FC(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(*distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor, MTXMODE_APPLY); - Matrix_ReplaceRotation(&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); @@ -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..38b724865 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.h @@ -5,31 +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_SPIN_ATTACK_CHARGE, + /* 0x3 */ EFF_DUST_TYPE_3, + /* 0x4 */ EFF_DUST_TYPE_4, + /* 0x5 */ EFF_DUST_TYPE_5 } EffDustType; -extern const ActorInit Eff_Dust_InitVars; - #endif // Z_EFF_DUST_H diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/overlay.cfg b/src/overlays/actors/ovl_Eff_Kamejima_Wave/overlay.cfg deleted file mode 100644 index 7decfb871..000000000 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Eff_Kamejima_Wave -z_eff_kamejima_wave.c 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..75ff275a1 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 @@ -4,18 +4,26 @@ * Description: Wave Created by Turtle Awakening */ +#include "prevent_bss_reordering.h" #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); -#if 0 -const ActorInit Eff_Kamejima_Wave_InitVars = { +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); + +ActorInit Eff_Kamejima_Wave_InitVars = { ACTOR_EFF_KAMEJIMA_WAVE, ACTORCAT_ITEMACTION, FLAGS, @@ -27,26 +35,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(gTurtleWaveTexAnim); +} -#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(&gTurtleWaveVtx); + + 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++, gTurtleWaveDL); + + 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..c79537363 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,22 @@ #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 -extern const ActorInit Eff_Kamejima_Wave_InitVars; +typedef enum params { + /* 0x0 */ EFFKAMEJIMAWAVE_PARAMS_0, + /* 0x1 */ EFFKAMEJIMAWAVE_PARAMS_1 +} EffKamejimaWaveParams; #endif // Z_EFF_KAMEJIMA_WAVE_H diff --git a/src/overlays/actors/ovl_Eff_Lastday/overlay.cfg b/src/overlays/actors/ovl_Eff_Lastday/overlay.cfg deleted file mode 100644 index 8e1cc8e1d..000000000 --- a/src/overlays/actors/ovl_Eff_Lastday/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Eff_Lastday -z_eff_lastday.c 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..0041f1e99 100644 --- a/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c +++ b/src/overlays/actors/ovl_Eff_Lastday/z_eff_lastday.c @@ -5,23 +5,30 @@ */ #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); -#if 0 -const ActorInit Eff_Lastday_InitVars = { +typedef enum EffLastDayAction { + /* 0x0 */ EFFLASTDAY_ACTION_NONE, + /* 0x1 */ EFFLASTDAY_ACTION_1, + /* 0x2 */ EFFLASTDAY_ACTION_2, + /* 0x3 */ EFFLASTDAY_ACTION_3 +} EffLastDayAction; + +ActorInit Eff_Lastday_InitVars = { ACTOR_EFF_LASTDAY, ACTORCAT_ITEMACTION, FLAGS, @@ -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..89266d744 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,27 @@ #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 -extern const ActorInit Eff_Lastday_InitVars; +typedef enum EffLastDayParams { + /* 0x0 */ EFFLASTDAY_PARAMS_0, + /* 0x1 */ EFFLASTDAY_PARAMS_1, + /* 0x2 */ EFFLASTDAY_PARAMS_2, + /* 0x3 */ EFFLASTDAY_PARAMS_3 +} EffLastDayParams; #endif // Z_EFF_LASTDAY_H diff --git a/src/overlays/actors/ovl_Eff_Stk/overlay.cfg b/src/overlays/actors/ovl_Eff_Stk/overlay.cfg deleted file mode 100644 index 725fd80b3..000000000 --- a/src/overlays/actors/ovl_Eff_Stk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Eff_Stk -z_eff_stk.c 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..4d66cc827 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.c @@ -10,13 +10,13 @@ #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 = { +ActorInit Eff_Stk_InitVars = { ACTOR_EFF_STK, ACTORCAT_ITEMACTION, FLAGS, 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..4b2b84783 100644 --- a/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h +++ b/src/overlays/actors/ovl_Eff_Stk/z_eff_stk.h @@ -5,14 +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; - #endif // Z_EFF_STK_H diff --git a/src/overlays/actors/ovl_Eff_Zoraband/overlay.cfg b/src/overlays/actors/ovl_Eff_Zoraband/overlay.cfg deleted file mode 100644 index 57858dabd..000000000 --- a/src/overlays/actors/ovl_Eff_Zoraband/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Eff_Zoraband -z_eff_zoraband.c 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..842ae4b9e 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.c @@ -5,20 +5,20 @@ */ #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 = { +ActorInit Eff_Zoraband_InitVars = { ACTOR_EFF_ZORABAND, ACTORCAT_ITEMACTION, FLAGS, @@ -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..4fdb977d8 100644 --- a/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h +++ b/src/overlays/actors/ovl_Eff_Zoraband/z_eff_zoraband.h @@ -3,16 +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; - #endif // Z_EFF_ZORABAND_H diff --git a/src/overlays/actors/ovl_Elf_Msg/overlay.cfg b/src/overlays/actors/ovl_Elf_Msg/overlay.cfg deleted file mode 100644 index 91ab17157..000000000 --- a/src/overlays/actors/ovl_Elf_Msg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Elf_Msg -z_elf_msg.c 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..3d7df7c27 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.c @@ -5,19 +5,20 @@ */ #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 = { +ActorInit Elf_Msg_InitVars = { ACTOR_ELF_MSG, ACTORCAT_ITEMACTION, FLAGS, @@ -29,30 +30,122 @@ 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_Kill(&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_Kill(&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_Kill(&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_Kill(&this->actor); + return; + } + + 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..51a3ddda3 100644 --- a/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h +++ b/src/overlays/actors/ovl_Elf_Msg/z_elf_msg.h @@ -3,15 +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; - #endif // Z_ELF_MSG_H diff --git a/src/overlays/actors/ovl_Elf_Msg2/overlay.cfg b/src/overlays/actors/ovl_Elf_Msg2/overlay.cfg deleted file mode 100644 index 15a73db5d..000000000 --- a/src/overlays/actors/ovl_Elf_Msg2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Elf_Msg2 -z_elf_msg2.c 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..a29b226b0 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.c @@ -10,16 +10,15 @@ #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 = { +ActorInit Elf_Msg2_InitVars = { ACTOR_ELF_MSG2, ACTORCAT_BG, FLAGS, @@ -31,32 +30,122 @@ 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_Kill(&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_Kill(&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_Kill(&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); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EE64.s") + if (this->actor.home.rot.z != 1) { + Actor_Kill(&this->actor); + if (ELFMSG2_GET_SWITCHFLAG(&this->actor) != 0x7F) { + Flags_SetSwitch(play, ELFMSG2_GET_SWITCHFLAG(&this->actor)); + } + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Elf_Msg2/func_8096EF98.s") + 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_8096EFD0.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/ElfMsg2_Update.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); + } +} + +void ElfMsg2_Update(Actor* thisx, PlayState* play) { + ElfMsg2* this = THIS; + + 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..4d9583d20 100644 --- a/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h +++ b/src/overlays/actors/ovl_Elf_Msg2/z_elf_msg2.h @@ -3,15 +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; - #endif // Z_ELF_MSG2_H diff --git a/src/overlays/actors/ovl_Elf_Msg3/overlay.cfg b/src/overlays/actors/ovl_Elf_Msg3/overlay.cfg deleted file mode 100644 index e39f7e290..000000000 --- a/src/overlays/actors/ovl_Elf_Msg3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Elf_Msg3 -z_elf_msg3.c 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..da6b29180 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.c @@ -5,19 +5,19 @@ */ #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 = { +ActorInit Elf_Msg3_InitVars = { ACTOR_ELF_MSG3, ACTORCAT_ITEMACTION, FLAGS, @@ -29,28 +29,121 @@ 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_Kill(&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_Kill(&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_Kill(&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_Kill(&this->actor); + return; + } + + 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..615cde1eb 100644 --- a/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h +++ b/src/overlays/actors/ovl_Elf_Msg3/z_elf_msg3.h @@ -3,15 +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; - #endif // Z_ELF_MSG3_H diff --git a/src/overlays/actors/ovl_Elf_Msg4/overlay.cfg b/src/overlays/actors/ovl_Elf_Msg4/overlay.cfg deleted file mode 100644 index 2bfe9ff86..000000000 --- a/src/overlays/actors/ovl_Elf_Msg4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Elf_Msg4 -z_elf_msg4.c 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..7fbf402fa 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.c @@ -5,20 +5,24 @@ */ #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 = { +ActorInit Elf_Msg4_InitVars = { ACTOR_ELF_MSG4, ACTORCAT_ITEMACTION, FLAGS, @@ -30,30 +34,143 @@ 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_Kill(&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_Kill(&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_Kill(&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_Kill(&this->actor); + return; + } + + if ((bgActor != NULL) && (Actor_ProcessTalkRequest(bgActor, &play->state))) { + if (ELFMSG4_GET_SWITCHFLAG(thisx) != 0x7F) { + Flags_SetSwitch(play, ELFMSG4_GET_SWITCHFLAG(thisx)); + } + Actor_Kill(&this->actor); + return; + } + + 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..e9ccbc906 100644 --- a/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h +++ b/src/overlays/actors/ovl_Elf_Msg4/z_elf_msg4.h @@ -3,16 +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; - #endif // Z_ELF_MSG4_H diff --git a/src/overlays/actors/ovl_Elf_Msg5/overlay.cfg b/src/overlays/actors/ovl_Elf_Msg5/overlay.cfg deleted file mode 100644 index d528de342..000000000 --- a/src/overlays/actors/ovl_Elf_Msg5/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Elf_Msg5 -z_elf_msg5.c 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..db97a0f74 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.c @@ -10,14 +10,14 @@ #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 = { +ActorInit Elf_Msg5_InitVars = { ACTOR_ELF_MSG5, ACTORCAT_BG, FLAGS, @@ -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_Kill(&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_Kill(&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_Kill(&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..36daecca1 100644 --- a/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h +++ b/src/overlays/actors/ovl_Elf_Msg5/z_elf_msg5.h @@ -3,15 +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; - #endif // Z_ELF_MSG5_H diff --git a/src/overlays/actors/ovl_Elf_Msg6/overlay.cfg b/src/overlays/actors/ovl_Elf_Msg6/overlay.cfg deleted file mode 100644 index 9ded97384..000000000 --- a/src/overlays/actors/ovl_Elf_Msg6/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Elf_Msg6 -z_elf_msg6.c 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..0ffb5c758 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.c @@ -11,19 +11,19 @@ #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 = { +ActorInit Elf_Msg6_InitVars = { ACTOR_ELF_MSG6, ACTORCAT_ITEMACTION, FLAGS, @@ -41,19 +41,19 @@ static InitChainEntry sInitChain[] = { }; s32 func_80BA15A0(void) { - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && !(gSaveContext.save.weekEventReg[87] & 0x10)) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_87_10)) { return true; } - if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && !(gSaveContext.save.weekEventReg[87] & 0x20)) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_87_20)) { return true; } - if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && !(gSaveContext.save.weekEventReg[87] & 0x40)) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_87_40)) { return true; } - if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD) && !(gSaveContext.save.weekEventReg[87] & 0x80)) { + if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_87_80)) { return true; } @@ -61,25 +61,25 @@ s32 func_80BA15A0(void) { } void func_80BA165C(void) { - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { - gSaveContext.save.weekEventReg[87] |= 0x10; + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) { + SET_WEEKEVENTREG(WEEKEVENTREG_87_10); } if (CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { - gSaveContext.save.weekEventReg[87] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_87_20); } if (CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { - gSaveContext.save.weekEventReg[87] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_87_40); } if (CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - gSaveContext.save.weekEventReg[87] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_87_80); } } -s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { - if (!(gSaveContext.save.weekEventReg[31] & 4) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { +s32 func_80BA16F4(ElfMsg6* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_31_04) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { this->actor.textId = 0x216; return false; } @@ -88,13 +88,13 @@ s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { return true; } - if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) { this->actor.textId = 0x256; return false; } if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT)) { - if (gSaveContext.save.weekEventReg[31] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_31_01)) { this->actor.textId = 0x257; } else { this->actor.textId = 0x231; @@ -103,7 +103,7 @@ s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { } if (!CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG)) { - if (gSaveContext.save.weekEventReg[31] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_31_02)) { this->actor.textId = 0x258; } else { this->actor.textId = 0x232; @@ -112,7 +112,7 @@ s32 func_80BA16F4(ElfMsg6* this, GlobalContext* globalCtx) { } if (!CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - if (gSaveContext.save.weekEventReg[80] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_80_04)) { this->actor.textId = 0x259; } else { this->actor.textId = 0x233; @@ -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,8 +146,8 @@ void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ELFMSG6_GET_F(&this->actor)) { case 0: this->actionFunc = func_80BA1E30; - if (func_80BA16F4(this, globalCtx)) { - Actor_MarkForDeath(&this->actor); + if (func_80BA16F4(this, play)) { + Actor_Kill(&this->actor); return; } break; @@ -155,22 +155,22 @@ 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)))) { - Actor_MarkForDeath(&this->actor); + Flags_GetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)))) { + Actor_Kill(&this->actor); return; } switch (ELFMSG6_GET_F0(&this->actor)) { case 0: if (gSaveContext.save.inventory.items[ITEM_HOOKSHOT] != ITEM_HOOKSHOT) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } break; case 1: - if (gSaveContext.save.weekEventReg[83] & 2) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_83_02)) { + Actor_Kill(&this->actor); return; } break; @@ -179,19 +179,19 @@ void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { case 2: if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - if (gSaveContext.save.weekEventReg[8] & 0x40) { - if (gSaveContext.save.weekEventReg[88] & 0x20) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_88_20)) { + Actor_Kill(&this->actor); return; } this->actor.textId = 0x25B; } else { - if (!(gSaveContext.save.weekEventReg[74] & 0x20) || (gSaveContext.save.weekEventReg[79] & 0x10)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_74_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_79_10)) { + Actor_Kill(&this->actor); return; } this->actor.textId = 0x224; @@ -201,10 +201,10 @@ void ElfMsg6_Init(Actor* thisx, GlobalContext* globalCtx) { case 3: if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && - Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || - (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + Flags_GetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor))) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_88_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_91_01) || (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } this->actionFunc = func_80BA2048; @@ -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,29 +254,29 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_79_10); break; case 0x25B: - gSaveContext.save.weekEventReg[88] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_88_20); break; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - if ((this->actor.textId == 0x224) && (gSaveContext.save.weekEventReg[8] & 0x40)) { + if ((this->actor.textId == 0x224) && CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40)) { this->actor.textId = 0x25B; } else if (func_80BA1C00(this) && (player->actor.speedXZ > 1.0f)) { player->tatlTextId = -this->actor.textId; @@ -288,34 +288,34 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_31_04); break; case 0x231: - gSaveContext.save.weekEventReg[31] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_31_01); break; case 0x232: - gSaveContext.save.weekEventReg[31] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_31_02); break; case 0x233: - gSaveContext.save.weekEventReg[80] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_80_04); break; } func_80BA165C(); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -329,86 +329,87 @@ void func_80BA1E30(ElfMsg6* this, GlobalContext* globalCtx) { } } -void func_80BA1F80(ElfMsg6* this, GlobalContext* globalCtx) { - if (((ELFMSG6_GET_F0(&this->actor)) == 1) && (gSaveContext.save.weekEventReg[83] & 2)) { - Actor_MarkForDeath(&this->actor); +void func_80BA1F80(ElfMsg6* this, PlayState* play) { + if ((ELFMSG6_GET_F0(&this->actor) == 1) && CHECK_WEEKEVENTREG(WEEKEVENTREG_83_02)) { + Actor_Kill(&this->actor); return; } if (func_80BA1C00(this)) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, NULL); - Flags_SetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor)); - Actor_MarkForDeath(&this->actor); - } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + Flags_SetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor)); + Actor_Kill(&this->actor); + return; } + + ActorCutscene_SetIntentToPlay(this->actor.cutscene); } } -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); + Actor_Kill(&this->actor); return; } - if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(globalCtx, ELFMSG6_SWITCHFLAG(&this->actor))) || - (gSaveContext.save.weekEventReg[88] & 0x10) || (gSaveContext.save.weekEventReg[91] & 1) || + if (((ELFMSG6_SWITCHFLAG(&this->actor) != 0x7F) && Flags_GetSwitch(play, ELFMSG6_SWITCHFLAG(&this->actor))) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_88_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_91_01) || (INV_CONTENT(ITEM_MASK_ZORA) == ITEM_MASK_ZORA)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } 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)) { - Actor_MarkForDeath(&this->actor); +void func_80BA215C(ElfMsg6* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + Actor_Kill(&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); + Actor_Kill(&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); + Actor_Kill(&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..8e9a5d0ed 100644 --- a/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h +++ b/src/overlays/actors/ovl_Elf_Msg6/z_elf_msg6.h @@ -5,17 +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; - #endif // Z_ELF_MSG6_H diff --git a/src/overlays/actors/ovl_En_Ah/overlay.cfg b/src/overlays/actors/ovl_En_Ah/overlay.cfg deleted file mode 100644 index 694256c53..000000000 --- a/src/overlays/actors/ovl_En_Ah/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ah -z_en_ah.c 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 dd719d6fb..5ea851023 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -11,13 +11,13 @@ #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); static u8 D_80BD3DB0[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x21 - 0x04), @@ -25,7 +25,7 @@ static u8 D_80BD3DB0[] = { /* 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), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_50_20, 0x1C - 0x19), /* 0x19 */ SCHEDULE_CMD_RET_VAL_L(1), /* 0x1C */ SCHEDULE_CMD_RET_NONE(), /* 0x1D */ SCHEDULE_CMD_RET_VAL_L(3), @@ -47,7 +47,7 @@ s32 D_80BD3DF8[] = { 0x00330100, 0x050E28FE, 0x0C100E28, -0x03F3F000 }; s32 D_80BD3E08[] = { 0x0E28FD0C, 0x0F29540C, 0x10000000 }; -const ActorInit En_Ah_InitVars = { +ActorInit En_Ah_InitVars = { ACTOR_EN_AH, ACTORCAT_NPC, FLAGS, @@ -81,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 }, @@ -105,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) { +Actor* 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; @@ -146,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; @@ -211,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; } @@ -254,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) { @@ -280,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); @@ -293,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++; @@ -303,11 +303,11 @@ 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 (player->stateFlags1 & PLAYER_STATE1_40) { if (this->unk_2DA != temp) { if (temp == 0x2954) { this->unk_18C = func_80BD3118; @@ -334,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; @@ -364,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; @@ -376,7 +376,7 @@ s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId return ret; } -s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BD3374(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); @@ -388,7 +388,7 @@ s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return true; } -s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BD33FC(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); @@ -400,10 +400,10 @@ s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return true; } -s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, ScheduleResult* 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); @@ -419,32 +419,32 @@ s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BD3548(EnAh* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->unk_2D8 = 0; - switch (arg2->result) { + switch (scheduleOutput->result) { default: ret = false; break; case 1: - ret = func_80BD3374(this, 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; @@ -464,18 +464,18 @@ 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) { - ScheduleResult sp18; +void func_80BD36B8(EnAh* this, PlayState* play) { + ScheduleOutput sp18; - if (!Schedule_RunScript(globalCtx, D_80BD3DB0, &sp18) || - ((this->unk_1DC != sp18.result) && !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.result = 0; @@ -484,15 +484,15 @@ void func_80BD36B8(EnAh* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; } this->unk_1DC = sp18.result; - func_80BD3658(this, globalCtx); + 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; @@ -508,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)) { - Actor_MarkForDeath(&this->actor); + if (func_80BD2A30(this, play, ACTORCAT_NPC, ACTOR_EN_AH)) { + Actor_Kill(&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); @@ -529,42 +528,42 @@ 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, EXCH_ITEM_NONE, this->unk_2D8 & 7); + func_8013C964(&this->actor, play, radius, height, PLAYER_IA_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 EnAh_PostLimbDraw(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) { @@ -573,7 +572,7 @@ void EnAh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnAh_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnAh_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnAh* this = THIS; s32 stepRot; s32 overrideRot; @@ -614,21 +613,21 @@ void EnAh_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this } } -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, + 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..d361a8358 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.h +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.h @@ -5,39 +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; - #endif // Z_EN_AH_H diff --git a/src/overlays/actors/ovl_En_Akindonuts/overlay.cfg b/src/overlays/actors/ovl_En_Akindonuts/overlay.cfg deleted file mode 100644 index a3e371656..000000000 --- a/src/overlays/actors/ovl_En_Akindonuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Akindonuts -z_en_akindonuts.c 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 22b2a0228..d2bdf0cee 100644 --- a/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c +++ b/src/overlays/actors/ovl_En_Akindonuts/z_en_akindonuts.c @@ -11,27 +11,27 @@ #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 = { +ActorInit En_Akindonuts_InitVars = { ACTOR_EN_AKINDONUTS, ACTORCAT_NPC, FLAGS, @@ -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,73 +221,73 @@ 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; - gSaveContext.save.weekEventReg[63] &= (u8)~0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_63_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_10); } else if (player->transformation == PLAYER_FORM_ZORA) { - gSaveContext.save.weekEventReg[63] &= (u8)~8; - gSaveContext.save.weekEventReg[63] |= 0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_08); + SET_WEEKEVENTREG(WEEKEVENTREG_63_10); } else if (player->transformation == PLAYER_FORM_GORON) { - gSaveContext.save.weekEventReg[63] |= 8; - gSaveContext.save.weekEventReg[63] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_63_08); + SET_WEEKEVENTREG(WEEKEVENTREG_63_10); } else if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.save.weekEventReg[63] &= (u8)~8; - gSaveContext.save.weekEventReg[63] &= (u8)~0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_10); } } -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)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_63_10)) { return true; } } else if (player->transformation == PLAYER_FORM_ZORA) { - if (!(gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_08) && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_10)) { return true; } } else if (player->transformation == PLAYER_FORM_GORON) { - if ((gSaveContext.save.weekEventReg[63] & 8) && (gSaveContext.save.weekEventReg[63] & 0x10)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_08) && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_10)) { return true; } } else if (player->transformation == PLAYER_FORM_HUMAN) { - if (!(gSaveContext.save.weekEventReg[63] & 8) && !(gSaveContext.save.weekEventReg[63] & 0x10)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_63_10)) { return true; } } @@ -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: @@ -384,8 +384,8 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x15E7: - if (!(gSaveContext.save.weekEventReg[61] & 0x20)) { - gSaveContext.save.weekEventReg[61] |= 0x20; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_61_20)) { + SET_WEEKEVENTREG(WEEKEVENTREG_61_20); this->unk_33C = 0x15E8; break; } @@ -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,8 +445,8 @@ void func_80BED3BC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15E5: this->unk_33C = 0x15E6; - func_80BED090(globalCtx); - gSaveContext.save.weekEventReg[61] |= 0x10; + func_80BED090(play); + SET_WEEKEVENTREG(WEEKEVENTREG_61_10); this->unk_32C |= 0x20; break; @@ -455,14 +455,14 @@ 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)) { - gSaveContext.save.weekEventReg[61] |= 0x40; + if (func_80BED140(play) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_61_40)) { + SET_WEEKEVENTREG(WEEKEVENTREG_61_40); 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: @@ -562,8 +562,8 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x15FE: - if (!(gSaveContext.save.weekEventReg[62] & 1)) { - gSaveContext.save.weekEventReg[62] |= 1; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_62_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_62_01); this->unk_33C = 0x15FF; break; } @@ -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; @@ -623,7 +623,7 @@ void func_80BED8A4(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x15FB; - gSaveContext.save.weekEventReg[61] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_61_80); this->unk_32C |= 0x20; break; @@ -632,16 +632,16 @@ 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: - if ((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[62] & 2)) { - gSaveContext.save.weekEventReg[62] |= 2; + if ((player->transformation == PLAYER_FORM_DEKU) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_62_02)) { + SET_WEEKEVENTREG(WEEKEVENTREG_62_02); this->unk_33C = 0x15F0; break; } @@ -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: @@ -740,8 +740,8 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x1610: - if (!(gSaveContext.save.weekEventReg[62] & 8)) { - gSaveContext.save.weekEventReg[62] |= 8; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_62_08)) { + SET_WEEKEVENTREG(WEEKEVENTREG_62_08); this->unk_33C = 0x1611; break; } @@ -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; @@ -796,7 +796,7 @@ void func_80BEDDAC(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x15FA: this->unk_33C = 0x160D; - gSaveContext.save.weekEventReg[62] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_62_04); this->unk_32C |= 0x20; break; @@ -805,16 +805,16 @@ 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: - if ((player->transformation == PLAYER_FORM_GORON) && !(gSaveContext.save.weekEventReg[62] & 0x10)) { - gSaveContext.save.weekEventReg[62] |= 0x10; + if ((player->transformation == PLAYER_FORM_GORON) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_62_10)) { + SET_WEEKEVENTREG(WEEKEVENTREG_62_10); this->unk_33C = 0x1614; break; } @@ -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: @@ -900,8 +900,8 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { break; case 0x1624: - if (!(gSaveContext.save.weekEventReg[62] & 0x40)) { - gSaveContext.save.weekEventReg[62] |= 0x40; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_62_40)) { + SET_WEEKEVENTREG(WEEKEVENTREG_62_40); this->unk_33C = 0x1625; break; } @@ -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; @@ -957,7 +957,7 @@ void func_80BEE274(EnAkindonuts* this, GlobalContext* globalCtx) { case 0x1622: this->unk_33C = 0x1623; - gSaveContext.save.weekEventReg[62] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_62_20); this->unk_32C |= 0x20; break; @@ -966,16 +966,16 @@ 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: - if ((player->transformation == PLAYER_FORM_ZORA) && !(gSaveContext.save.weekEventReg[62] & 0x80)) { - gSaveContext.save.weekEventReg[62] |= 0x80; + if ((player->transformation == PLAYER_FORM_ZORA) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_62_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_62_80); this->unk_33C = 0x162A; break; } @@ -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,48 +1033,48 @@ 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); + PlayerItemAction itemAction = func_80123810(play); - if (itemActionParam > PLAYER_AP_NONE) { - if (itemActionParam == PLAYER_AP_DEED_LAND) { + if (itemAction > PLAYER_IA_NONE) { + if (itemAction == PLAYER_IA_DEED_LAND) { player->actor.textId = D_80BF048C[params]; this->unk_33C = player->actor.textId; if (this->unk_33C == 0x15E4) { - player->exchangeItemId = itemActionParam; + player->exchangeItemId = itemAction; this->actionFunc = func_80BEF20C; } else { this->actionFunc = func_80BEF18C; } - } else if (itemActionParam == PLAYER_AP_DEED_SWAMP) { + } else if (itemAction == PLAYER_IA_DEED_SWAMP) { player->actor.textId = D_80BF0494[params]; this->unk_33C = player->actor.textId; if (this->unk_33C == 0x15F9) { - player->exchangeItemId = itemActionParam; + player->exchangeItemId = itemAction; this->actionFunc = func_80BEF20C; } else { this->actionFunc = func_80BEF18C; } - } else if (itemActionParam == PLAYER_AP_DEED_MOUNTAIN) { + } else if (itemAction == PLAYER_IA_DEED_MOUNTAIN) { player->actor.textId = D_80BF049C[params]; this->unk_33C = player->actor.textId; if (this->unk_33C == 0x160C) { - player->exchangeItemId = itemActionParam; + player->exchangeItemId = itemAction; this->actionFunc = func_80BEF20C; } else { this->actionFunc = func_80BEF18C; } - } else if (itemActionParam == PLAYER_AP_DEED_OCEAN) { + } else if (itemAction == PLAYER_IA_DEED_OCEAN) { player->actor.textId = D_80BF04A4[params]; this->unk_33C = player->actor.textId; if (this->unk_33C == 0x1621) { - player->exchangeItemId = itemActionParam; + player->exchangeItemId = itemAction; this->actionFunc = func_80BEF20C; } else { this->actionFunc = func_80BEF18C; @@ -1084,67 +1084,67 @@ void func_80BEE73C(EnAkindonuts* this, GlobalContext* globalCtx) { this->unk_33C = player->actor.textId; this->actionFunc = func_80BEF18C; } - func_801477B4(globalCtx); - } else if (itemActionParam < PLAYER_AP_NONE) { + func_801477B4(play); + } else if (itemAction <= PLAYER_IA_MINUS1) { 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_61_10)) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BED680; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else if (ENAKINDONUTS_GET_4(&this->actor)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->unk_2DC = func_80BED3BC; } break; case 1: - if (gSaveContext.save.weekEventReg[61] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_61_80)) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEDB88; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else if (ENAKINDONUTS_GET_4(&this->actor)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->unk_2DC = func_80BED8A4; } break; case 2: - if (gSaveContext.save.weekEventReg[62] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_62_04)) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEE070; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else if (ENAKINDONUTS_GET_4(&this->actor)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->unk_2DC = func_80BEDDAC; } break; case 3: - if (gSaveContext.save.weekEventReg[62] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_62_20)) { if (ENAKINDONUTS_GET_4(&this->actor)) { this->unk_2DC = func_80BEE530; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else if (ENAKINDONUTS_GET_4(&this->actor)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->unk_2DC = func_80BEE274; } @@ -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) { - Actor_MarkForDeath(&this->actor); +void func_80BEFD74(EnAkindonuts* this, PlayState* play) { + Actor_Kill(&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); + Actor_Kill(&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))) { @@ -1703,11 +1702,11 @@ void EnAkindonuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Act } } -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..72c932d0c 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,38 +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; - #endif // Z_EN_AKINDONUTS_H diff --git a/src/overlays/actors/ovl_En_Al/overlay.cfg b/src/overlays/actors/ovl_En_Al/overlay.cfg deleted file mode 100644 index ccd80736f..000000000 --- a/src/overlays/actors/ovl_En_Al/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Al -z_en_al.c 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 a14b2e106..da1cc7d7e 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -11,13 +11,13 @@ #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); static u8 D_80BDFC70[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x11 - 0x04), @@ -85,7 +85,7 @@ s32 D_80BDFF24[] = { 0x11390411, 0x390819FF, 0xB10E2B3C, 0x2D00080C, 0x19FFA700, }; -const ActorInit En_Al_InitVars = { +ActorInit En_Al_InitVars = { ACTOR_EN_AL, ACTORCAT_NPC, FLAGS, @@ -119,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 }, @@ -129,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; @@ -177,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); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_89_08) && CHECK_WEEKEVENTREG(WEEKEVENTREG_85_80)) { + actor = func_80BDE1A0(this, play, ACTORCAT_NPC, ACTOR_EN_PM); } else { - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; } break; @@ -211,7 +212,7 @@ Actor* func_80BDE384(EnAl* this, GlobalContext* globalCtx) { break; default: - actor = &GET_PLAYER(globalCtx)->actor; + actor = &GET_PLAYER(play)->actor; break; } @@ -314,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; @@ -331,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; @@ -342,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; @@ -356,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++; @@ -403,14 +403,14 @@ 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; switch (this->unk_4E6) { case 0: case 1: - if ((gSaveContext.save.weekEventReg[75] & 2)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_02)) { sp18 = true; } else if (func_80BDE4E0(this, &this->unk_4E6, 0)) { sp18 = true; @@ -427,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; @@ -445,19 +445,19 @@ 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; case 2: - if (!(gSaveContext.save.weekEventReg[89] & 8) && (gSaveContext.save.weekEventReg[85] & 0x80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_89_08) && CHECK_WEEKEVENTREG(WEEKEVENTREG_85_80)) { this->unk_4EC = func_80BDE7FC; return D_80BDFCBC; } this->unk_4EC = func_80BDEA14; - if (Player_GetMask(globalCtx) != PLAYER_MASK_KAFEIS_MASK) { + if (Player_GetMask(play) != PLAYER_MASK_KAFEIS_MASK) { return D_80BDFDE8; } @@ -473,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; @@ -490,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; @@ -545,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; @@ -559,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; @@ -569,13 +569,13 @@ 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) { + if (player->stateFlags1 & PLAYER_STATE1_40) { this->unk_4C2 |= 0x400; if (this->unk_4C4 != sp22) { switch (sp22) { @@ -629,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, ScheduleResult* 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); @@ -650,16 +650,16 @@ s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BDF308(EnAl* this, PlayState* play, ScheduleOutput* scheduleOutput) { SubS_UpdateFlags(&this->unk_4C2, 3, 7); - switch (arg2->result) { + switch (scheduleOutput->result) { case 1: func_80BDE27C(this, 0); break; case 2: - this->unk_4F0 = EXCH_ITEM_NONE; + this->unk_4F0 = PLAYER_IA_NONE; this->unk_4EA = 0; func_80BDE27C(this, 2); break; @@ -667,23 +667,23 @@ s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return true; } -s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, ScheduleResult* 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 = EXCH_ITEM_NONE; + this->unk_4F0 = PLAYER_IA_NONE; this->unk_4C2 = 0; this->unk_4D4 = 40.0f; - switch (arg2->result) { + 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: @@ -693,21 +693,21 @@ s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -void func_80BDF414(EnAl* this, GlobalContext* globalCtx) { +void func_80BDF414(EnAl* this, PlayState* play) { s16 temp_v0; switch (this->unk_4EA) { case 0: case 1: - if (!(gSaveContext.save.weekEventReg[89] & 8)) { - if (gSaveContext.save.weekEventReg[85] & 0x80) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_89_08)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_85_80)) { func_80BDE4E0(this, &this->unk_4EA, 0); } } break; case 2: - if (gSaveContext.save.weekEventReg[89] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_89_08)) { this->unk_4EA++; } break; @@ -727,30 +727,30 @@ 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) { - ScheduleResult sp20; +void func_80BDF5E8(EnAl* this, PlayState* play) { + ScheduleOutput sp20; - this->unk_4E0 = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BDFC70, &sp20) || - ((this->unk_35C != sp20.result) && !func_80BDF390(this, globalCtx, &sp20))) { + this->unk_4E0 = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); + 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.result = 0; @@ -759,12 +759,12 @@ void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; } this->unk_35C = sp20.result; - this->unk_368 = func_80BDE384(this, globalCtx); - func_80BDF578(this, globalCtx); + 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; @@ -777,99 +777,99 @@ 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: + case MADAME_AROMA_LIMB_SHAWL_MIDDLE: Matrix_Get(&this->unk_190[0]); break; - case 11: + case MADAME_AROMA_LIMB_SHAWL_UPPER: Matrix_Get(&this->unk_190[1]); break; - case 12: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER_MIDDLE: Matrix_Get(&this->unk_190[2]); break; - case 13: + case MADAME_AROMA_LIMB_SHAWL_LEFT_LOWER: Matrix_Get(&this->unk_190[3]); break; - case 14: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER_MIDDLE: Matrix_Get(&this->unk_190[4]); break; - case 15: + case MADAME_AROMA_LIMB_SHAWL_RIGHT_LOWER: Matrix_Get(&this->unk_190[5]); break; - case 16: + case MADAME_AROMA_LIMB_HEAD: Matrix_MultVec3f(&D_80BE0070, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); break; } } -void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnAl_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnAl* this = THIS; s32 stepRot; s32 overrideRot; @@ -899,27 +899,26 @@ void EnAl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this } } -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); + func_8012C28C(play->state.gfxCtx); Matrix_Translate(0.0f, 0.0f, 850.0f, MTXMODE_APPLY); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + 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_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..77e1011bf 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.h +++ b/src/overlays/actors/ovl_En_Al/z_en_al.h @@ -5,46 +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; - #endif // Z_EN_AL_H diff --git a/src/overlays/actors/ovl_En_Am/overlay.cfg b/src/overlays/actors/ovl_En_Am/overlay.cfg deleted file mode 100644 index 8f03945db..000000000 --- a/src/overlays/actors/ovl_En_Am/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Am -z_en_am.c 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 00c07327e..f76ebc4f3 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -12,32 +12,32 @@ #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* thisx); -const ActorInit En_Am_InitVars = { +ActorInit En_Am_InitVars = { ACTOR_EN_AM, ACTORCAT_ENEMY, FLAGS, @@ -128,7 +128,7 @@ static CollisionCheckInfoInit sColChkInfoInit = { 1, 23, 98, MASS_HEAVY }; static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 19, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_ARMOS, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -4000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; @@ -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,32 +412,32 @@ 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); + Actor_Kill(&this->actor); return; } else if (!(this->explodeTimer & 3)) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 4); @@ -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; @@ -555,18 +555,18 @@ void EnAm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -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..e482e2cba 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.h +++ b/src/overlays/actors/ovl_En_Am/z_en_am.h @@ -6,27 +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; - #endif // Z_EN_AM_H diff --git a/src/overlays/actors/ovl_En_An/overlay.cfg b/src/overlays/actors/ovl_En_An/overlay.cfg deleted file mode 100644 index 14a6d7d5f..000000000 --- a/src/overlays/actors/ovl_En_An/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_An -z_en_an.c 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..6b85ffc53 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.c +++ b/src/overlays/actors/ovl_En_An/z_en_an.c @@ -10,16 +10,16 @@ #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 = { +ActorInit En_An_InitVars = { ACTOR_EN_AN, ACTORCAT_NPC, FLAGS, 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..7f1a11930 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.h +++ b/src/overlays/actors/ovl_En_An/z_en_an.h @@ -5,15 +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; - #endif // Z_EN_AN_H diff --git a/src/overlays/actors/ovl_En_And/overlay.cfg b/src/overlays/actors/ovl_En_And/overlay.cfg deleted file mode 100644 index f62d705f0..000000000 --- a/src/overlays/actors/ovl_En_And/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_And -z_en_and.c 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..5c888ba45 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.c +++ b/src/overlays/actors/ovl_En_And/z_en_and.c @@ -10,15 +10,15 @@ #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 = { +ActorInit En_And_InitVars = { ACTOR_EN_AND, ACTORCAT_NPC, FLAGS, 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..a0610a408 100644 --- a/src/overlays/actors/ovl_En_And/z_en_and.h +++ b/src/overlays/actors/ovl_En_And/z_en_and.h @@ -5,15 +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; - #endif // Z_EN_AND_H diff --git a/src/overlays/actors/ovl_En_Ani/overlay.cfg b/src/overlays/actors/ovl_En_Ani/overlay.cfg deleted file mode 100644 index f0622d0c0..000000000 --- a/src/overlays/actors/ovl_En_Ani/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ani -z_en_ani.c 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 098d91be4..8e98ae8a3 100644 --- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c +++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c @@ -6,6 +6,7 @@ */ #include "z_en_ani.h" +#include "z64quake.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -19,27 +20,27 @@ #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 = { +ActorInit En_Ani_InitVars = { ACTOR_EN_ANI, ACTORCAT_NPC, FLAGS, @@ -110,17 +111,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 +129,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; @@ -137,8 +138,7 @@ void EnAni_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = 0.0f; this->actor.flags |= ACTOR_FLAG_10; this->stateFlags |= ANI_STATE_CLIMBING; - gSaveContext.eventInf[1] &= (u8)~0x10; - + CLEAR_EVENTINF(EVENTINF_14); } else { // ANI_TYPE_STANDING // ( unused code ) // for some reason standing he has a large collider @@ -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,9 +207,9 @@ 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; + s16 quakeIndex; if (this->actor.bgCheckFlags & 1) { // hit the ground this->actor.flags &= ~ACTOR_FLAG_10; @@ -219,10 +219,12 @@ 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); - Quake_SetSpeed(quakeValue, 0x6978); - Quake_SetQuakeValues(quakeValue, 7, 0, 0, 0); - Quake_SetCountdown(quakeValue, 0x14); + + quakeIndex = Quake_Add(play->cameraPtrs[CAM_ID_MAIN], QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 27000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_HAMMER_HIT); } @@ -230,7 +232,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)) { @@ -241,11 +243,11 @@ void EnAni_LoseBalance(EnAni* this, GlobalContext* globalCtx) { // frame count : 0.0f, only first frame, rest is handled in next action func Animation_Change(&this->skelAnime, &gAniLandingThenStandingUpAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 5.0f); this->actionFunc = EnAni_FallToGround; - gSaveContext.eventInf[1] |= 0x10; + SET_EVENTINF(EVENTINF_14); } } -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 +273,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 +291,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 +310,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 +318,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,7 +329,7 @@ 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) { @@ -335,20 +337,20 @@ void EnAni_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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_Translate(0.0f, 0.0f, -1000.0f, MTXMODE_APPLY); - func_8012C5B0(globalCtx->state.gfxCtx); + 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/overlay.cfg b/src/overlays/actors/ovl_En_Aob_01/overlay.cfg deleted file mode 100644 index 592d6a834..000000000 --- a/src/overlays/actors/ovl_En_Aob_01/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Aob_01 -z_en_aob_01.c 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 1d74c45ae..a6624dc38 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,27 +12,29 @@ #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); +//! TODO: this file require macros for its uses of weekEventReg -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 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); -const ActorInit En_Aob_01_InitVars = { +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); + +ActorInit En_Aob_01_InitVars = { ACTOR_EN_AOB_01, ACTORCAT_NPC, FLAGS, @@ -44,7 +46,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,56 +102,56 @@ void func_809C10B0(EnAob01* this, s32 arg1) { } void func_809C1124(void) { - 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); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset); } -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) { @@ -160,18 +162,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) { @@ -182,12 +184,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 { @@ -197,16 +199,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: @@ -218,15 +220,15 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { switch (gSaveContext.save.day) { case 1: if (!gSaveContext.save.isNight) { - if (!(gSaveContext.save.weekEventReg[64] & 0x80)) { - gSaveContext.save.weekEventReg[64] |= 0x80; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_64_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_64_80); this->unk_210 = 0x3520; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.save.weekEventReg[65] & 1)) { - gSaveContext.save.weekEventReg[65] |= 1; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_65_01); this->unk_210 = 0x3530; } else { this->unk_210 = 0x352F; @@ -236,15 +238,15 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { case 2: if (!gSaveContext.save.isNight) { - if (!(gSaveContext.save.weekEventReg[65] & 2)) { - gSaveContext.save.weekEventReg[65] |= 2; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_02)) { + SET_WEEKEVENTREG(WEEKEVENTREG_65_02); this->unk_210 = 0x3531; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.save.weekEventReg[65] & 4)) { - gSaveContext.save.weekEventReg[65] |= 4; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_04)) { + SET_WEEKEVENTREG(WEEKEVENTREG_65_04); this->unk_210 = 0x3532; } else { this->unk_210 = 0x352F; @@ -254,15 +256,15 @@ void func_809C16DC(EnAob01* this, GlobalContext* globalCtx) { case 3: if (!gSaveContext.save.isNight) { - if (!(gSaveContext.save.weekEventReg[65] & 8)) { - gSaveContext.save.weekEventReg[65] |= 8; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_08)) { + SET_WEEKEVENTREG(WEEKEVENTREG_65_08); this->unk_210 = 0x3533; } else { this->unk_210 = 0x352F; } } else { - if (!(gSaveContext.save.weekEventReg[65] & 0x10)) { - gSaveContext.save.weekEventReg[65] |= 0x10; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_10)) { + SET_WEEKEVENTREG(WEEKEVENTREG_65_10); this->unk_210 = 0x3534; } else { this->unk_210 = 0x352F; @@ -329,7 +331,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: @@ -344,7 +346,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; } @@ -359,7 +361,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: @@ -371,7 +373,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; } @@ -379,22 +381,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, PLAYER_CSMODE_7); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; this->actionFunc = func_809C1C9C; return; } @@ -407,41 +409,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; + SET_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); 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; @@ -449,83 +451,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 TurnOptionsSet sTurnOptions = { +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(globalCtx); + Player* player = GET_PLAYER(play); Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer)) { point.x = player->actor.world.pos.x; - point.y = player->bodyPartsPos[7].y + 3.0f; + point.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } func_809C10B0(this, 3); - SubS_FillLimbRotTables(globalCtx, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); - func_809C165C(this, globalCtx); - if (player->stateFlags1 & 0x20) { + SubS_FillLimbRotTables(play, this->unk_2F8, this->unk_318, ARRAY_COUNT(this->unk_2F8)); + func_809C165C(this, play); + if (player->stateFlags1 & PLAYER_STATE1_20) { 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->turnTarget; + this->unk_2E6 = this->trackTarget; this->unk_2EC = this->headRot; this->unk_2F2 = this->torsoRot; - func_809C16DC(this, globalCtx); + 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; @@ -546,58 +548,58 @@ 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)->currentPoint)) { @@ -612,8 +614,8 @@ 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)->index == ((EnRacedog*)npc)->selectedDogIndex)) { @@ -626,8 +628,8 @@ 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) { @@ -655,33 +657,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)) { - if (func_801A8A50(0) != 0x41) { - globalCtx->nextEntranceIndex = 0x7C10; + if (func_809C25E4(this, play)) { + if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) != NA_BGM_HORSE_GOAL) { + 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)) { @@ -701,111 +703,111 @@ 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->turnTarget = this->unk_2E6; + 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_20)) { this->actionFunc = func_809C2BE4; } else { - gSaveContext.save.weekEventReg[8] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_08_20); this->actionFunc = func_809C2BE4; } - } else if (gSaveContext.save.weekEventReg[8] & 0x20) { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 300.0f, 300.0f); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_20)) { + 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 (gSaveContext.save.weekEventReg[63] & 2) { - gSaveContext.save.weekEventReg[63] &= (u8)~2; + if (((talkState == TEXT_STATE_5) || (talkState == TEXT_STATE_DONE)) && Message_ShouldAdvance(play)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); } - if (gSaveContext.save.weekEventReg[63] & 1) { - gSaveContext.save.weekEventReg[63] &= (u8)~1; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_01)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); } 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); @@ -819,38 +821,38 @@ 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->turnTarget = this->unk_2E6; + this->trackTarget = this->unk_2E6; this->headRot = this->unk_2EC; this->torsoRot = this->unk_2F2; this->unk_434 = 0; this->actor.shape.rot.y = this->actor.world.rot.y; - if (gSaveContext.save.weekEventReg[63] & 2) { - gSaveContext.save.weekEventReg[63] &= (u8)~2; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); } - if (gSaveContext.save.weekEventReg[63] & 1) { - gSaveContext.save.weekEventReg[63] &= (u8)~1; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_01)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); } 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) { @@ -869,14 +871,14 @@ 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; player->actor.shape.rot.y = player->actor.world.rot.y; player->actor.draw = NULL; - player->stateFlags1 |= 0x20; + player->stateFlags1 |= PLAYER_STATE1_20; this->actor.world.pos.x = -4308.0f; this->actor.world.pos.z = 1620.0f; this->actor.prevPos = this->actor.world.pos; @@ -920,42 +922,42 @@ void func_809C2FA0(void) { } } -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; @@ -963,24 +965,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; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); } - 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, @@ -989,13 +990,13 @@ 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) { @@ -1018,7 +1019,7 @@ 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; @@ -1027,35 +1028,35 @@ void EnAob01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } -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 d4ed3e71e..2507b1728 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,7 +21,7 @@ typedef struct EnAob01 { /* 0x212 */ Vec3s jointTable[MAMAMU_YAN_LIMB_MAX]; /* 0x272 */ Vec3s morphTable[MAMAMU_YAN_LIMB_MAX]; /* 0x2D2 */ u16 unk_2D2; - /* 0x2D4 */ Vec3s turnTarget; + /* 0x2D4 */ Vec3s trackTarget; /* 0x2DA */ Vec3s headRot; /* 0x2E0 */ Vec3s torsoRot; /* 0x2E6 */ Vec3s unk_2E6; @@ -42,6 +42,4 @@ typedef struct EnAob01 { /* 0x440 */ s16 unk_440; } EnAob01; // size = 0x444 -extern const ActorInit En_Aob_01_InitVars; - #endif // Z_EN_AOB_01_H diff --git a/src/overlays/actors/ovl_En_Arrow/overlay.cfg b/src/overlays/actors/ovl_En_Arrow/overlay.cfg deleted file mode 100644 index 5ae277d22..000000000 --- a/src/overlays/actors/ovl_En_Arrow/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Arrow -z_en_arrow.c 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 0a8eeffce..b07e65de3 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -12,17 +12,17 @@ #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 = { +ActorInit En_Arrow_InitVars = { ACTOR_EN_ARROW, ACTORCAT_ITEMACTION, FLAGS, @@ -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); + Magic_Reset(play); } } @@ -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,15 +162,15 @@ 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); + Magic_Reset(play); } } } else { if ((this->actor.params != ENARROW_8) && (player->unk_D57 == 0)) { if (this->actor.params == ENARROW_7) { - func_80115D5C(&globalCtx->state); + Magic_Reset(play); } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&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); + Magic_Reset(play); } 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,19 +286,19 @@ 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_MarkForDeath(&this->actor); + Actor_Spawn(&play->actorCtx, play, ACTOR_BG_ICEFLOE, sp44.x, sp44.y, sp44.z, 0, 0, 0, 300); + Actor_Kill(&this->actor); return; } @@ -307,19 +306,16 @@ void func_8088AA98(EnArrow* this, GlobalContext* globalCtx) { this->collider.info.toucher.dmgFlags = 0x20; if (this->actor.child != NULL) { - Actor_MarkForDeath(this->actor.child); + Actor_Kill(this->actor.child); return; } - func_80115D5C(&globalCtx->state); + Magic_Reset(play); } } } -#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,20 +344,20 @@ 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.pos, &this->actor.world.pos); sp84.colPoly = this->actor.wallPoly; sp84.scale = this->bubble.unk_144; - EffectSs_Spawn(globalCtx, EFFECT_SS_SBN, 128, &sp84); + EffectSs_Spawn(play, EFFECT_SS_SBN, 128, &sp84); } } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -380,26 +374,27 @@ 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); - Actor_MarkForDeath(&this->actor); + EffectSsStone1_Spawn(play, &this->actor.world.pos, 0); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, sp82); + Actor_Kill(&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)) { + if ((sp7C->update != NULL) && !(this->collider.base.atFlags & AT_BOUNCED) && + (sp7C->flags & ACTOR_FLAG_4000)) { 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; + sp7C->flags |= ACTOR_FLAG_8000; this->collider.base.atFlags &= ~AT_HIT; this->actor.speedXZ *= 0.5f; this->actor.velocity.y *= 0.5f; @@ -407,7 +402,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 +421,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,41 +466,40 @@ 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; } if (this->actor.params < ENARROW_6) { - this->actor.shape.rot.x = Math_FAtan2F(this->actor.speedXZ, -this->actor.velocity.y); + this->actor.shape.rot.x = Math_Atan2S_XY(this->actor.speedXZ, -this->actor.velocity.y); } } 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,56 +507,53 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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); + Actor_Kill(&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,7 +564,7 @@ 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; @@ -584,14 +575,14 @@ void func_8088B88C(GlobalContext* globalCtx, EnArrow* this, EnArrowUnkStruct* ar 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_MultVec3f(&sp4C[0], &sp40); Matrix_MultVec3f(&sp4C[1], &sp34); if (this->actor.params < ENARROW_8) { sp30 = this->actor.params < ENARROW_6; - if (this->unk_264 == 0) { - sp30 &= func_80126440(globalCtx, &this->collider, &this->unk_244, &sp40, &sp34); + 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)) { @@ -604,7 +595,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[] = { { { @@ -645,20 +636,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; @@ -669,7 +660,7 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); @@ -679,32 +670,30 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); @@ -719,34 +708,34 @@ void EnArrow_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_Push(); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + 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_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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffSparklesDL); Matrix_Pop(); Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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_Mult(&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 654e8bea6..d16dbd380 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, @@ -53,6 +53,4 @@ typedef struct EnArrow { /* 0x274 */ EnArrowActionFunc actionFunc; } EnArrow; // size = 0x278 -extern const ActorInit En_Arrow_InitVars; - #endif // Z_EN_ARROW_H diff --git a/src/overlays/actors/ovl_En_Attack_Niw/overlay.cfg b/src/overlays/actors/ovl_En_Attack_Niw/overlay.cfg deleted file mode 100644 index 2b4aa71be..000000000 --- a/src/overlays/actors/ovl_En_Attack_Niw/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Attack_Niw -z_en_attack_niw.c 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 548e1e68d..b4501ffa0 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 @@ -11,16 +11,16 @@ #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 EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* globalCtx); -void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx); -void EnAttackNiw_FlyAway(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 = { +ActorInit En_Attack_Niw_InitVars = { ACTOR_EN_ATTACK_NIW, ACTORCAT_ENEMY, FLAGS, @@ -38,12 +38,12 @@ 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, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + 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 @@ -64,7 +64,7 @@ void EnAttackNiw_Init(Actor* thisx, GlobalContext* globalCtx) { 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; @@ -80,7 +80,7 @@ void EnAttackNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { * * EnNiw has its own version of this function, probably copy paste since AttackNiw only uses two animationState (2/5) */ -void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s16 animationState) { +void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, PlayState* play, s16 animationState) { if (this->unkTimer24C == 0) { if (animationState == 0) { this->targetBodyRotY = 0.0f; @@ -103,12 +103,12 @@ void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s1 this->unkToggle28A &= 1; switch (animationState) { // only case 2 and 5 are ever called in AttackNiw - case NIW_ANIMATION_STILL: + case NIW_ANIM_STILL: this->targetLeftWingRotZ = 0.0f; this->targetRightWingRotZ = 0.0f; break; - case NIW_ANIMATION_HEAD_PECKING: + case NIW_ANIM_HEAD_PECKING: this->unkTimer250 = 3; this->targetLeftWingRotZ = 7000.0f; this->targetRightWingRotZ = 7000.0f; @@ -118,7 +118,7 @@ void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s1 } break; - case NIW_ANIMATION_PECKING_AND_WAVING: + case NIW_ANIM_PECKING_AND_WAVING: this->unkTimer250 = 2; this->targetLeftWingRotZ = -10000.0f; this->targetRightWingRotZ = -10000.0f; @@ -132,7 +132,7 @@ void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s1 } break; - case NIW_ANIMATION_PECKING_AND_FORFLAPPING: + case NIW_ANIM_PECKING_AND_FORFLAPPING: this->unkTimer250 = 2; this->targetRightWingRotY = 10000.0f; this->targetLeftWingRotY = 10000.0f; @@ -142,12 +142,12 @@ void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s1 } break; - case NIW_ANIMATION_FREEZE: + case NIW_ANIM_FREEZE: this->unusedTimer24E = 5; this->unkTimer24C = this->unusedTimer24E; break; - case NIW_ANIMATION_PECKING_SLOW_FORFLAPPING: + case NIW_ANIM_PECKING_SLOW_FORFLAPPING: this->unkTimer250 = 5; this->targetRightWingRotY = 14000.0f; this->targetLeftWingRotY = 14000.0f; @@ -192,12 +192,12 @@ void EnAttackNiw_AnimateWingHead(EnAttackNiw* this, GlobalContext* globalCtx, s1 } } -s32 EnAttackNiw_IsOnScreen(EnAttackNiw* this, GlobalContext* globalCtx) { +s32 EnAttackNiw_IsOnScreen(EnAttackNiw* this, PlayState* play) { s16 posX; s16 posY; Actor_SetFocus(&this->actor, this->targetHeight); - Actor_GetScreenPos(globalCtx, &this->actor, &posX, &posY); + Actor_GetScreenPos(play, &this->actor, &posX, &posY); if ((this->actor.projectedPos.z < -20.0f) || (posX < 0) || (posX > SCREEN_WIDTH) || (posY < 0) || (posY > SCREEN_HEIGHT)) { @@ -206,7 +206,7 @@ s32 EnAttackNiw_IsOnScreen(EnAttackNiw* this, GlobalContext* globalCtx) { return true; } -void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* globalCtx) { +void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, PlayState* play) { s16 posX; s16 posY; Vec3f viewOffset; @@ -217,14 +217,14 @@ void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* global // randomTargetCenterOffset is set in _Init, only needs to be set once // but the view is moving, so now we need to re-calculate the spot in space - viewOffset.x = this->randomTargetCenterOffset.x + globalCtx->view.at.x - globalCtx->view.eye.x; - viewOffset.y = this->randomTargetCenterOffset.y + globalCtx->view.at.y - globalCtx->view.eye.y; - viewOffset.z = this->randomTargetCenterOffset.z + globalCtx->view.at.z - globalCtx->view.eye.z; + 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; // this is the 3D spot in space where the cucco is trying to fly into (until it lands or gets close) - flightTarget.x = globalCtx->view.at.x + viewOffset.x; - flightTarget.y = globalCtx->view.at.y + viewOffset.y; - flightTarget.z = globalCtx->view.at.z + viewOffset.z; + 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->targetRotY = Math_Vec3f_Yaw(&this->actor.world.pos, &flightTarget); this->targetRotX = Math_Vec3f_Pitch(&this->actor.world.pos, &flightTarget) * -1.0f; @@ -234,7 +234,7 @@ void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* global Math_ApproachF(&this->rotStep, 5000.0f, 1.0f, 100.0f); Actor_SetFocus(&this->actor, this->targetHeight); - Actor_GetScreenPos(globalCtx, &this->actor, &posX, &posY); + Actor_GetScreenPos(play, &this->actor, &posX, &posY); if (this->actor.bgCheckFlags & 8) { // touching a wall this->targetRotY = this->actor.yawTowardsPlayer; @@ -276,13 +276,13 @@ void EnAttackNiw_EnterViewFromOffscreen(EnAttackNiw* this, GlobalContext* global this->unkTimer24C = 10; this->targetBodyRotY = -10000.0f; this->targetHeadRotZ = -3000.0f; - EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + EnAttackNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } } -void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!EnAttackNiw_IsOnScreen(this, globalCtx)) { - Actor_MarkForDeath(&this->actor); +void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, PlayState* play) { + if (!EnAttackNiw_IsOnScreen(this, play)) { + Actor_Kill(&this->actor); return; } @@ -325,30 +325,30 @@ void EnAttackNiw_AimAtPlayer(EnAttackNiw* this, GlobalContext* globalCtx) { this->actionFunc = EnAttackNiw_FlyAway; } else if (this->actor.bgCheckFlags & 1) { // touching floor - EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_SLOW_FORFLAPPING); + EnAttackNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_SLOW_FORFLAPPING); } else { - EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + EnAttackNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } } -void EnAttackNiw_FlyAway(EnAttackNiw* this, GlobalContext* globalCtx) { - if (!EnAttackNiw_IsOnScreen(this, globalCtx)) { - Actor_MarkForDeath(&this->actor); +void EnAttackNiw_FlyAway(EnAttackNiw* this, PlayState* play) { + if (!EnAttackNiw_IsOnScreen(this, play)) { + Actor_Kill(&this->actor); return; } Math_SmoothStepToS(&this->actor.world.rot.x, this->targetRotX, 5, this->rotStep, 0); Math_ApproachF(&this->rotStep, 5000.0f, 1.0f, 100.0f); Math_ApproachF(&this->actor.velocity.y, 5.0f, 0.3f, 1.0f); - EnAttackNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + 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 splashPos; @@ -365,9 +365,9 @@ void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { 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 == EnAttackNiw_EnterViewFromOffscreen) { Actor_MoveWithoutGravity(&this->actor); @@ -376,13 +376,15 @@ void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.floorHeight <= BGCHECK_Y_MIN) { // under the world - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); + return; + } - } else if ((this->actor.bgCheckFlags & 0x20) && // on or below water - (this->actionFunc != EnAttackNiw_FlyAway)) { + if ((this->actor.bgCheckFlags & 0x20) && // on or below water + (this->actionFunc != EnAttackNiw_FlyAway)) { Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); splashPos.y += this->actor.depthInWater; - EffectSsGSplash_Spawn(globalCtx, &splashPos, NULL, NULL, 0, 400); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, 400); this->rotStep = 0.0f; this->actor.gravity = 0.0f; this->targetXZSpeed = 0.0f; @@ -399,7 +401,7 @@ void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { if ((this->actor.parent->update != NULL) && (this->actor.parent != NULL) && (parent != NULL) && (parent->unkAttackNiwTimer == 0) && (player->invincibilityTimer == 0)) { // this updates some player values based on what we pass, need player decomp to know what this is doing - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); + func_800B8D50(play, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); parent->unkAttackNiwTimer = 70; } } @@ -416,8 +418,7 @@ void EnAttackNiw_Update(Actor* thisx, GlobalContext* globalCtx) { } } -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 == NIW_LIMB_UPPER_BODY) { @@ -442,10 +443,10 @@ s32 EnAttackNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** 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 c4dcaf8d0..f49778d9a 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,7 +6,7 @@ struct EnAttackNiw; -typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, GlobalContext*); +typedef void (*EnAttackNiwActionFunc)(struct EnAttackNiw*, PlayState*); typedef struct EnAttackNiw { /* 0x000 */ Actor actor; @@ -54,8 +54,6 @@ typedef struct EnAttackNiw { /* 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 diff --git a/src/overlays/actors/ovl_En_Az/overlay.cfg b/src/overlays/actors/ovl_En_Az/overlay.cfg deleted file mode 100644 index e929d9380..000000000 --- a/src/overlays/actors/ovl_En_Az/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Az -z_en_az.c 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..bfefb5a85 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.c +++ b/src/overlays/actors/ovl_En_Az/z_en_az.c @@ -5,29 +5,94 @@ */ #include "z_en_az.h" +#include "objects/object_az/object_az.h" +#include "overlays/actors/ovl_En_Twig/z_en_twig.h" +#include "overlays/actors/ovl_En_Fish/z_en_fish.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_80000000) #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); +typedef struct { + /* 0x0 */ s16 unk_0; + /* 0x4 */ f32 unk_4; +} struct_80A98F94; // size = 0x8 -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 EnAz_Init(Actor* thisx, PlayState* play2); +void EnAz_Destroy(Actor* thisx, PlayState* play2); +void EnAz_Update(Actor* thisx, PlayState* play2); +void EnAz_Draw(Actor* thisx, PlayState* play2); -#if 0 -const ActorInit En_Az_InitVars = { +void func_80A982E0(PlayState* play, ActorPathing* actorPathing); +void func_80A98414(EnAz* this, PlayState* play); +s32 func_80A98DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); +void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); +void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 animIndex, s32 brotherAnimIndex); +void func_80A98F94(struct_80A98F94* yData, f32 frame, f32* yInterp); + +void func_80A95C5C(EnAz* this, PlayState* play); +void func_80A95CEC(EnAz* this, PlayState* play); + +void func_80A95DA0(EnAz* this, PlayState* play); +void func_80A95E88(EnAz* this, PlayState* play); + +void func_80A95F94(EnAz* this, PlayState* play); +void func_80A95FE8(EnAz* this, PlayState* play); + +void func_80A979DC(EnAz* this, PlayState* play); +void func_80A979F4(EnAz* this, PlayState* play); + +void func_80A97A28(EnAz* this, PlayState* play); +void func_80A97A40(EnAz* this, PlayState* play); + +void func_80A97A9C(EnAz* this, PlayState* play); +void func_80A97AB4(EnAz* this, PlayState* play); + +void func_80A97C0C(EnAz* this, PlayState* play); +void func_80A97C24(EnAz* this, PlayState* play); +void func_80A97C4C(EnAz* this, PlayState* play); + +void func_80A97D5C(EnAz* this, PlayState* play); +void func_80A97E48(EnAz* this, PlayState* play); + +void func_80A97EAC(EnAz* this, PlayState* play); +void func_80A97F9C(EnAz* this, PlayState* play); + +typedef enum { + /* 0 */ BEAVER_ANIM_IDLE, + /* 1 */ BEAVER_ANIM_WALK, + /* 2 */ BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, + /* 3 */ BEAVER_ANIM_SWIM_WITH_RAISED_TAIL, // Unused + /* 4 */ BEAVER_ANIM_TALK, + /* 5 */ BEAVER_ANIM_TALK_WAVE_ARMS, + /* 6 */ BEAVER_ANIM_LAUGH_RIGHT, + /* 7 */ BEAVER_ANIM_LAUGH_LEFT, + /* 8 */ BEAVER_ANIM_SWIM, + /* 9 */ BEAVER_ANIM_TALK_TO_LEFT, + /* 10 */ BEAVER_ANIM_TALK_TO_RIGHT, + /* 11 */ BEAVER_ANIM_BOW, + /* 12 */ BEAVER_ANIM_IDLE_FACE_LEFT, + /* 13 */ BEAVER_ANIM_IDLE_FACE_RIGHT, +} BeaverAnimation; + +static AnimationSpeedInfo sAnimationInfo[] = { + { &gBeaverIdleAnim, 1.0f, ANIMMODE_LOOP, -10.0f }, + { &gBeaverWalkAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverSwimWithSpinningTail, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverSwimWithRaisedTail, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverTalkAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverTalkWaveArmsAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverLaughRightAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverLaughLeftAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverSwimAnim, 2.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverTalkToLeftAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverTalkToRightAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverBowAnim, 1.0f, ANIMMODE_ONCE, -5.0f }, + { &gBeaverIdleFaceLeftAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, + { &gBeaverIdleFaceRightAnim, 1.0f, ANIMMODE_LOOP, -5.0f }, +}; + +ActorInit En_Az_InitVars = { ACTOR_EN_AZ, ACTORCAT_NPC, FLAGS, @@ -39,108 +104,1823 @@ const ActorInit En_Az_InitVars = { (ActorFunc)EnAz_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A99110 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 46, 0, { 0, 0, 0 } }, }; -#endif +static EnAz* D_80A9913C = NULL; -extern ColliderCylinderInit D_80A99110; +Vec3f D_80A99E80; // path point? +f32 D_80A99E8C; // player distance to path point? +f32 D_80A99E90[2]; // unused? -extern UNK_TYPE D_0600C94C; -extern UNK_TYPE D_0601ABF0; +void func_80A94A30(EnAz* this) { + this->actor.velocity.y += this->actor.gravity; + if (this->actor.velocity.y < this->actor.terminalVelocity) { + this->actor.velocity.y = this->actor.terminalVelocity; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94A30.s") +void func_80A94A64(EnAz* this) { + func_80A94A30(this); + Actor_UpdatePos(&this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94A64.s") +s32 func_80A94A90(PlayState* play, ActorPathing* actorPathing) { + func_80A94A64((EnAz*)actorPathing->actor); + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94A90.s") +void func_80A94AB8(EnAz* this, PlayState* play, s32 spawnIndex) { + play->nextEntrance = Entrance_CreateFromSpawn(spawnIndex); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94AB8.s") +void func_80A94B20(PlayState* play) { + Actor* ring = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94B20.s") + do { + ring = SubS_FindActor(play, ring, ACTORCAT_MISC, ACTOR_EN_TWIG); + if (ring != NULL) { + if (RACERING_GET_PARAM_F(ring) == 1) { + Actor_Kill(ring); + } + ring = ring->next; + } + } while (ring != NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A94B98.s") +s32 func_80A94B98(EnAz* this, PlayState* play) { + EnTwig* ring; + s32 ret = false; + Actor* misc = NULL; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Init.s") + do { + if (1) {} + ring = (EnTwig*)SubS_FindActor(play, misc, ACTORCAT_MISC, ACTOR_EN_TWIG); + if ((ring != NULL) && (RACERING_GET_PARAM_F(&ring->dyna.actor) == 1) && !(ring->unk_16C & 1)) { + ret = true; + break; + } + misc = ring->dyna.actor.next; + } while (misc != NULL); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Destroy.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A954AC.s") +static InitChainEntry sInitChain[3] = { + ICHAIN_F32(uncullZoneScale, 80, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneDownward, 80, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95534.s") +void EnAz_Init(Actor* thisx, PlayState* play2) { + static s16 D_80A9914C[] = { 1, 0, 3, 2, 5, 4, -1 }; + static s16 D_80A9915C[] = { 0, 1, 0, 1, 0, 1, 1 }; + EnAz* this = THIS; + PlayState* play = play2; + s16 sp4E; + s32 phi_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A9565C.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_374 = 0; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 1; + switch (BEAVER_GET_PARAM_F00(thisx)) { + case 0: + phi_v1 = + (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && CHECK_WEEKEVENTREG(WEEKEVENTREG_93_01); + phi_v1 = !phi_v1; + break; + case 2: + phi_v1 = (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) || + !CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04); + break; + case 4: + phi_v1 = gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 2); + break; + case 1: + phi_v1 = + (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && CHECK_WEEKEVENTREG(WEEKEVENTREG_93_01); + phi_v1 = !phi_v1; + break; + case 3: + phi_v1 = + (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04); + break; + case 5: + phi_v1 = gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 2); + break; + case 6: + phi_v1 = (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 0)) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_93_01); + phi_v1 = !phi_v1; + break; + default: + phi_v1 = true; + break; + } + if (phi_v1) { + Actor_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95730.s") + this->unk_2F8 = D_80A9915C[BEAVER_GET_PARAM_F00(thisx)]; + if (BEAVER_GET_PARAM_F00(thisx) >= 0) { + sp4E = D_80A9914C[BEAVER_GET_PARAM_F00(thisx)]; + } else { + sp4E = -1; + } + if (this->unk_2F8 == 0) { + this->unk_374 |= 2; + } + SubS_FillCutscenesList(&this->actor, this->unk_3D0, ARRAY_COUNT(this->unk_3D0)); + if (D_80A9913C == NULL) { + D_80A9913C = THIS; + this->unk_374 |= 1; + } + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + if (this->unk_374 & 2) { + SkelAnime_InitFlex(play, &this->skelAnime, &gBeaverOlderBrotherSkel, &gBeaverWalkAnim, this->jointTable, + this->morphTable, BEAVER_OLDER_BROTHER_LIMB_MAX); + Actor_SetScale(&this->actor, 0.012f); + } else { + SkelAnime_InitFlex(play, &this->skelAnime, &gBeaverYoungerBrotherSkel, &gBeaverWalkAnim, this->jointTable, + this->morphTable, BEAVER_YOUNGER_BROTHER_LIMB_MAX); + } + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + if (this->unk_374 & 2) { + this->collider.dim.radius *= 1.2f; + this->collider.dim.height *= 1.2f; + this->collider.dim.yShift *= 1.2f; + } + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 5); + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 22.0f)) { + this->unk_374 |= 0x100; + this->unk_376 |= 0x100; + } + Animation_Change(&this->skelAnime, sAnimationInfo[BEAVER_ANIM_IDLE].animation, 1.0f, + Animation_GetLastFrame(sAnimationInfo[BEAVER_ANIM_IDLE].animation) * Rand_ZeroOne(), + Animation_GetLastFrame(sAnimationInfo[BEAVER_ANIM_IDLE].animation), + sAnimationInfo[BEAVER_ANIM_IDLE].mode, sAnimationInfo[BEAVER_ANIM_IDLE].morphFrames); + this->unk_37E = 0; + this->unk_380 = 0; + this->unk_384 = 0; + this->actor.gravity = -1.0f; + this->unk_376 = this->unk_374; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); + this->skelAnime.curFrame = Rand_ZeroOne() * this->skelAnime.endFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A958B0.s") + switch (gSaveContext.save.entrance) { + case ENTRANCE(WATERFALL_RAPIDS, 0): + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_93_01)) { + this->unk_2FA = 5; + if (this->unk_374 & 2) { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_374 |= 0x20; + } + } else { + this->unk_2FA = 0; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->unk_374 |= 0x20; + } + func_80A94B20(play); + if (this->unk_2FA == 5) { + func_80A97C0C(this, play); + } else { + func_80A95DA0(this, play); + } + break; + case ENTRANCE(WATERFALL_RAPIDS, 3): + this->unk_2FA = 0; + if (!(this->unk_374 & 2)) { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + } + if (gSaveContext.save.entrance == ENTRANCE(WATERFALL_RAPIDS, 3)) { + this->unk_2FA = 0xA; + } + func_80A97C0C(this, play); + break; + case ENTRANCE(WATERFALL_RAPIDS, 1): + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_93_01)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { + this->unk_2FA = 8; + } else { + this->unk_2FA = 6; + } + } else { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { + this->unk_2FA = 3; + } else { + this->unk_2FA = 1; + } + } + if (this->unk_374 & 1) { + SubS_CopyPointFromPathList(play->setupPathList, BEAVER_GET_PARAM_FF(thisx), + play->setupPathList[BEAVER_GET_PARAM_FF(thisx)].count - 1, &D_80A99E80); + } + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { + if (this->unk_374 & 2) { + func_80A97D5C(this, play); + } else { + func_80A979DC(this, play); + } + } else if (this->unk_374 & 2) { + func_80A979DC(this, play); + } else { + func_80A97D5C(this, play); + } + break; + case ENTRANCE(WATERFALL_RAPIDS, 2): + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_93_01)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { + this->unk_2FA = 9; + } else { + this->unk_2FA = 7; + } + } else { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { + this->unk_2FA = 4; + } else { + this->unk_2FA = 2; + } + } + if (this->unk_2FA == 2) { + if (!(this->unk_374 & 2)) { + this->unk_374 |= 0x20; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + this->actionFunc = func_80A97C24; + } else { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + func_80A95C5C(this, play); + } + } else { + if (this->unk_374 & 2) { + this->unk_374 |= 0x20; + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10000); + } else { + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } + this->actionFunc = func_80A97C24; + } + break; + } + if (sp4E >= 0) { + this->brother = NULL; + do { + this->brother = (EnAz*)SubS_FindActor(play, &this->brother->actor, ACTORCAT_NPC, ACTOR_EN_AZ); + if (this->brother != NULL) { + if (sp4E == BEAVER_GET_PARAM_F00(&this->brother->actor)) { + break; + } + this->brother = (EnAz*)this->brother->actor.next; + } + } while (this->brother != NULL); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95B34.s") +void EnAz_Destroy(Actor* thisx, PlayState* play2) { + EnAz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95C5C.s") + if (gSaveContext.save.entrance != ENTRANCE(WATERFALL_RAPIDS, 1)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; + } + Collider_DestroyCylinder(play2, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95CEC.s") +f32 func_80A954AC(EnAz* this) { + ActorPathing* pathing = &this->unk_300; + Vec3f sp28; + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95DA0.s") + sp28.x = pathing->curPoint.x - this->actor.world.pos.x; + sp28.y = pathing->curPoint.y - this->actor.world.pos.y; + sp28.z = pathing->curPoint.z - this->actor.world.pos.z; + sp1C.x = pathing->curPoint.x - pathing->prevPoint.x; + sp1C.y = pathing->curPoint.y - pathing->prevPoint.y; + sp1C.z = pathing->curPoint.z - pathing->prevPoint.z; + return Math3D_Parallel(&sp28, &sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95E88.s") +s32 func_80A95534(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95F94.s") + this->actor.world.rot.x = 0; + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, 0x71C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 2, 0x71C, 0); + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, 0xE38, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x71C, 0); + this->actor.gravity = -1.0f; + this->unk_36C = 1.5f; + if (actorPathing->curPointIndex == actorPathing->endPointIndex) { + if (actorPathing->distSqToCurPointXZ < this->unk_36C) { + this->unk_36C = actorPathing->distSqToCurPointXZ; + } + } + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_36C, 0.8f, 2.0f, 0.0f); + actorPathing->moveFunc = SubS_ActorPathing_MoveWithGravity; + if (actorPathing->distSqToCurPointXZ <= this->actor.speedXZ) { + ret = true; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A95FE8.s") +s32 func_80A9565C(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp_f0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A9617C.s") + this->actor.gravity = -1.0f; + actorPathing->moveFunc = func_80A94A90; + this->unk_374 |= 0x2000; + temp_f0 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp_f0 <= 0.0f)) { + ret = true; + } else { + this->unk_39E = this->actor.world.rot.x = + Math_Atan2S(-this->actor.velocity.y, Math_CosS(-this->actor.world.rot.x) * this->actor.speedXZ); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97114.s") +s32 func_80A95730(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp_f0; + f32 sp40; + s32 sp3C; + s32 sp38; + s32 sp34; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97274.s") + this->actor.gravity = 0.0f; + temp_f0 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp_f0 <= 0.0f)) { + ret = true; + } else { + sp40 = SQ(this->actor.speedXZ) / actorPathing->distSqToCurPoint; + sp34 = ABS(actorPathing->rotToCurPoint.x - this->actor.world.rot.x); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A973B4.s") + sp3C = (s32)(sp34 * sp40) + 0xAAA; + sp34 = ABS(actorPathing->rotToCurPoint.y - this->actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97410.s") + Math_SmoothStepToS(&this->actor.world.rot.x, actorPathing->rotToCurPoint.x, 1, sp3C, 0); + sp38 = (s32)(sp34 * sp40) + 0xAAA; + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, sp38, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A979DC.s") + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, sp3C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, sp38, 0); + } + actorPathing->moveFunc = SubS_ActorPathing_MoveWithoutGravityReverse; + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A979F4.s") +s32 func_80A958B0(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret = false; + f32 temp; + f32 phi_f0; + f32 temp1; + f32 temp2; + f32 sp3C; + s32 sp2C; + s32 sp28; + s32 sp30; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A28.s") + this->actor.gravity = 0.0f; + temp2 = D_80A99E8C; + temp = D_80A99E90[this->unk_2F8]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A40.s") + if (temp <= temp2) { + phi_f0 = (this->unk_374 & 2) ? 480.0f : 240.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97A9C.s") + if (this->actor.xzDistToPlayer < phi_f0) { + Math_SmoothStepToF(&this->unk_36C, 12.0f, 0.8f, 0.5f, 0.01f); + } else { + Math_SmoothStepToF(&this->unk_36C, 6.0f, 0.8f, 0.5f, 0.01f); + } + } else { + Math_SmoothStepToF(&this->unk_36C, 26.0f, 0.5f, 1.0f, 0.01f); + } + Math_SmoothStepToF(&this->actor.speedXZ, this->unk_36C, 0.8f, 2.0f, 0.0f); + temp1 = func_80A954AC(this); + if ((actorPathing->distSqToCurPointXZ < SQ(this->actor.speedXZ)) || (temp1 <= 0.0f)) { + ret = true; + } else { + sp3C = SQ(this->actor.speedXZ) / actorPathing->distSqToCurPoint; + sp30 = ABS(actorPathing->rotToCurPoint.x - this->actor.world.rot.x); + sp2C = (s32)(sp30 * sp3C) + 0xAAA; + sp30 = ABS(actorPathing->rotToCurPoint.y - this->actor.world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97AB4.s") + Math_SmoothStepToS(&this->actor.world.rot.x, actorPathing->rotToCurPoint.x, 1, sp2C, 0); + sp28 = (s32)(sp30 * sp3C) + 0xAAA; + Math_SmoothStepToS(&this->actor.world.rot.y, actorPathing->rotToCurPoint.y, 1, sp28, 0); + Math_SmoothStepToS(&this->unk_39E, this->actor.world.rot.x, 2, sp2C, 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, sp28, 0); + } + actorPathing->moveFunc = SubS_ActorPathing_MoveWithoutGravityReverse; + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C0C.s") +s32 func_80A95B34(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + s32 ret; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C24.s") + if (this->unk_374 & 0x100) { + if (!(this->unk_374 & 8)) { + if (this->unk_374 & 2) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM, &this->animIndex); + } else { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, + &this->animIndex); + } + this->unk_374 |= 8; + } + if (this->unk_2FA == 0) { + ret = func_80A95730(play, actorPathing); + } else { + ret = func_80A958B0(play, actorPathing); + } + } else if (this->actor.bgCheckFlags & 1) { + if (this->unk_374 & 8) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_WALK, &this->animIndex); + this->unk_374 &= ~8; + } + ret = func_80A95534(play, actorPathing); + } else { + ret = func_80A9565C(play, actorPathing); + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97C4C.s") +void func_80A95C5C(EnAz* this, PlayState* play) { + this->actor.draw = NULL; + this->actor.world.pos.y = this->actor.home.pos.y + 120.0f; + this->actor.gravity = -1.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_3C0 = 0; + this->actionFunc = func_80A95CEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97D5C.s") +void func_80A95CEC(EnAz* this, PlayState* play) { + if (this->unk_374 & 0x8000) { + if (!(this->actor.bgCheckFlags & 1)) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.draw = EnAz_Draw; + Actor_MoveWithGravity(&this->actor); + func_800B9010(&this->actor, NA_SE_EV_HONEYCOMB_FALL - SFX_FLAG); + } else { + if (this->actor.bgCheckFlags & 2) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + } + if (SubS_StartActorCutscene(&this->actor, 0x7C, this->unk_3D0[0], SUBS_CUTSCENE_NORMAL)) { + func_80A97C0C(this, play); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97E48.s") +void func_80A95DA0(EnAz* this, PlayState* play) { + ActorPathing* sp40 = &this->unk_300; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97EAC.s") + SubS_ActorPathing_Init(play, &this->actor.world.pos, &this->actor, sp40, play->setupPathList, + BEAVER_GET_PARAM_FF(&this->actor), 0, 0, 1, 1); + this->unk_36C = 4.0f; + this->actor.speedXZ = 4.0f; + this->actor.gravity = 0.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, + &this->animIndex); + this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_374 |= 0x1000; + Math_Vec3f_Copy(&this->actor.world.pos, &sp40->curPoint); + this->actionFunc = func_80A95E88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A97F9C.s") +void func_80A95E88(EnAz* this, PlayState* play) { + SubS_ActorPathing_Update(play, &this->unk_300, func_80A982E0, func_80A95B34, SubS_ActorPathing_MoveWithGravity, + SubS_ActorPathing_SetNextPoint); + if (this->actor.depthInWater > 8.0f) { + if (this->unk_374 & 2) { + if ((this->skelAnime.curFrame < this->skelAnime.playSpeed) && (this->skelAnime.curFrame >= 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); + } + } else { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + } + } + if (!(this->unk_374 & 0x2000)) { + SkelAnime_Update(&this->skelAnime); + } + this->unk_374 &= ~0x2000; + if (this->actor.isTargeted) { + func_80A95F94(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A982E0.s") +void func_80A95F94(EnAz* this, PlayState* play) { + func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, 0); + this->unk_39E = 0; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80A95FE8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98414.s") +void func_80A95FE8(EnAz* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (ActorCutscene_GetCanPlayNext(this->unk_3D0[0])) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_3D0[0], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->unk_3D0[0]); + } + if (Actor_DistanceToPoint(&this->actor, &this->actor.home.pos) > 20.0f) { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + func_800BE33C(&this->actor.world.pos, &this->actor.home.pos, &this->actor.world.rot, 0); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 3, 0xE38, 0x38E); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0xE38, 0x38E); + this->actor.shape.rot.z = 0; + Actor_MoveWithoutGravityReverse(&this->actor); + } else { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); + this->unk_374 &= ~0x1000; + this->actor.gravity = -1.0f; + this->actor.speedXZ = 0.0f; + Math_SmoothStepToS(&this->actor.shape.rot.x, 0, 3, 0x1000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x1038, 0x100); + if (this->actor.bgCheckFlags & 1) { + this->actor.shape.rot.x = 0; + this->actor.gravity = 0.0f; + func_80A97C0C(this, play); + ActorCutscene_Stop(this->unk_3D0[0]); + } + Actor_MoveWithGravity(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Update.s") +s32 func_80A9617C(EnAz* this, PlayState* play) { + s32 pad[2]; + s32 ret = 2; + EnAz* brother = this->brother; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/EnAz_Draw.s") + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if ((play->msgCtx.currentTextId == 0x10DD) && (this->unk_374 & 0x8000)) { + if (SubS_StartActorCutscene(&brother->actor, brother->unk_3D0[0], 0x7C, SUBS_CUTSCENE_NORMAL)) { + brother->unk_374 |= 0x8000; + play->msgCtx.msgMode = 0x44; + ret = 0; + } + } else if (Message_ShouldAdvance(play)) { + ret = 3; + switch (play->msgCtx.currentTextId) { + case 0x70: + case 0xCD: + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_01); + this->actor.textId = 0x10F2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &brother->animIndex); + break; + case 0x10CE: + this->actor.textId = 0x10CF; + SET_WEEKEVENTREG(WEEKEVENTREG_16_40); + break; + case 0x10CF: + this->actor.textId = 0x10D0; + break; + case 0x10D0: + this->actor.textId = 0x10D1; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_WAVE_ARMS, + &this->animIndex); + break; + case 0x10D1: + this->actor.textId = 0x10D2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + break; + case 0x10D2: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x10D6; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, + BEAVER_ANIM_TALK_WAVE_ARMS, &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10D3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &this->animIndex); + } + break; + case 0x10D3: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10D4: + this->actor.textId = 0x10D2; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + break; + case 0x10D6: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + func_80A979DC(this, play); + this->unk_2FA = 1; + ret = 0; + break; + case 0x10D7: + this->actor.textId = 0x10D8; + break; + case 0x10D8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + switch (this->unk_2FA) { + case 2: + this->unk_2FA = 1; + break; + case 4: + this->unk_2FA = 3; + break; + case 7: + this->unk_2FA = 6; + break; + case 9: + this->unk_2FA = 8; + break; + } + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10D9; + } + break; + case 0x10D9: + if ((this->unk_2FA == 3) || (this->unk_2FA == 8)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + } + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10DA: + this->actor.textId = 0x10DB; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + break; + case 0x10DB: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + play->msgCtx.msgMode = 0x44; + this->unk_2FA = 1; + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10DC; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &this->animIndex); + } + break; + case 0x10DC: + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10DD: + func_80A98EFC(this, play, 0x10DE, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); + this->unk_374 |= 0x8000; + ret = 2; + break; + case 0x10DE: + func_80A98EFC(this, play, 0x10DF, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x10DF: + func_80A98EFC(this, play, 0x10E0, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); + ret = 0; + break; + case 0x10E0: + func_80A98EFC(this, play, 0x10E1, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x10E1: + func_80A98EFC(this, play, 0x10E2, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); + ret = 0; + break; + case 0x10E2: + this->actor.textId = 0x10E3; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + break; + case 0x10E3: + func_80A98EFC(this, play, 0x10E4, BEAVER_ANIM_IDLE, BEAVER_ANIM_TALK); + ret = 0; + break; + case 0x10E4: + func_80A98EFC(this, play, 0x10E5, BEAVER_ANIM_IDLE, BEAVER_ANIM_TALK); + ret = 0; + break; + case 0x10E5: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + this->actor.textId = 0x10E8; + } else { + func_8019F230(); + this->actor.textId = 0x10E6; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_TO_LEFT, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, + BEAVER_ANIM_IDLE_FACE_RIGHT, &brother->animIndex); + } + break; + case 0x10E6: + this->actor.textId = 0x10E7; + func_80A98EFC(this, play, 0x10E7, BEAVER_ANIM_IDLE, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x10E7: + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + func_80A94AB8(this, play, 0); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10E8: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + this->unk_2FA = 3; + ret = 0; + break; + case 0x10E9: + func_80A98EFC(this, play, 0x10EA, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK); + ret = 0; + break; + case 0x10EA: + func_80A98EFC(this, play, 0x10EB, BEAVER_ANIM_IDLE, BEAVER_ANIM_TALK); + ret = 0; + break; + case 0x10EB: + if (play->msgCtx.choiceIndex == 0) { + play->msgCtx.msgMode = 0x44; + func_8019F208(); + switch (this->unk_2FA) { + case 4: + this->unk_2FA = 3; + break; + case 7: + this->unk_2FA = 6; + break; + case 9: + default: + this->unk_2FA = 8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98DA4.s") + break; + } + ret = 0; + } else { + func_8019F230(); + this->actor.textId = 0x10EC; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_LAUGH_LEFT, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, + BEAVER_ANIM_IDLE_FACE_RIGHT, &brother->animIndex); + } + break; + case 0x10EC: + func_80A98EFC(this, play, 0x10ED, -1, BEAVER_ANIM_LAUGH_RIGHT); + ret = 0; + break; + case 0x10ED: + if ((this->unk_2FA == 4) || (this->unk_2FA == 9)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + } + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10EE: + func_80A98EFC(this, play, 0x10EF, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x10EF: + func_80A98EFC(this, play, 0x10F0, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); + ret = 0; + break; + case 0x10F0: + func_80A98EFC(this, play, 0x10F1, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x10F1: + SET_WEEKEVENTREG(WEEKEVENTREG_93_01); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_80)) { + this->getItemId = GI_RUPEE_RED; + } else { + this->getItemId = GI_BOTTLE; + SET_WEEKEVENTREG(WEEKEVENTREG_23_80); + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + ret = 7; + break; + case 0x10F2: + case 0x1109: + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10F3: + func_80A98EFC(this, play, 0x10F4, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x10F4: + func_80A98EFC(this, play, 0x10F5, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); + ret = 0; + break; + case 0x10F5: + func_80A98EFC(this, play, 0x10F6, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x10F6: + func_80A98EFC(this, play, 0x10F7, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_WAVE_ARMS); + ret = 0; + break; + case 0x10F7: + this->actor.textId = 0x10F8; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + break; + case 0x10F8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_01)) { + this->actor.textId = 0x1107; + } else { + this->actor.textId = 0x10FA; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, + BEAVER_ANIM_TALK_WAVE_ARMS, &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10F9; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &brother->animIndex); + } + break; + case 0x10F9: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + case 0x10FA: + case 0x1107: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + this->unk_2FA = 6; + ret = 0; + break; + case 0x10FB: + func_80A98EFC(this, play, 0x10FC, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x10FC: + func_80A98EFC(this, play, 0x10FD, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK); + ret = 0; + break; + case 0x10FD: + this->actor.textId = 0x10FE; + ret = 3; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + break; + case 0x10FE: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_01)) { + this->actor.textId = 0x1108; + } else { + this->actor.textId = 0x1101; + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + } else { + func_8019F230(); + this->actor.textId = 0x10FF; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_TO_LEFT, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, + BEAVER_ANIM_IDLE_FACE_RIGHT, &brother->animIndex); + } + break; + case 0x10FF: + func_80A98EFC(this, play, 0x1100, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x1100: + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x1101: + case 0x1108: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + this->unk_2FA = 8; + ret = 0; + break; + case 0x1102: + func_80A98EFC(this, play, 0x1103, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x1103: + func_80A98EFC(this, play, 0x1104, BEAVER_ANIM_IDLE_FACE_RIGHT, BEAVER_ANIM_TALK_TO_LEFT); + ret = 0; + break; + case 0x1104: + func_80A98EFC(this, play, 0x1105, BEAVER_ANIM_IDLE_FACE_LEFT, BEAVER_ANIM_TALK_TO_RIGHT); + ret = 0; + break; + case 0x1105: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_01)) { + this->getItemId = GI_RUPEE_PURPLE; + } else { + this->getItemId = GI_HEART_PIECE; + SET_WEEKEVENTREG(WEEKEVENTREG_25_01); + } + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + ret = 7; + break; + case 0x1106: + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &brother->animIndex); + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + ret = 0; + break; + case 0x10D5: + default: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, + &this->animIndex); + this->unk_374 |= 0x20; + ret = 0; + break; + } + } + break; + case TEXT_STATE_NONE: + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98E48.s") +void func_80A97114(EnAz* this, PlayState* play) { + EnAz* brother = this->brother; + s32 sp20 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98EFC.s") + this->actor.flags &= ~ACTOR_FLAG_10000; + switch (this->actor.textId) { + case 0x10DA: + case 0x10DD: + case 0x10E9: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, &this->animIndex); + break; + case 0x10EE: + case 0x10F3: + case 0x10FB: + case 0x1102: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_TO_LEFT, + &this->animIndex); + sp20 = true; + break; + case 0x10F2: + case 0x1106: + case 0x1109: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, &this->animIndex); + if (brother != NULL) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_BOW, + &brother->animIndex); + } + break; + } + if ((brother != NULL) && sp20) { + if (this->unk_374 & 2) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE_FACE_RIGHT, + &brother->animIndex); + } else { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE_FACE_LEFT, + &brother->animIndex); + } + } + this->unk_374 &= ~0x20; + this->unk_378 = 2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Az/func_80A98F94.s") +s32 func_80A97274(EnAz* this, PlayState* play) { + s32 textId; + + if (this->unk_374 & 0x4000) { + return 0x10D7; + } + switch (this->unk_2FA) { + case 0: + default: + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + if (!(CHECK_WEEKEVENTREG(WEEKEVENTREG_16_40))) { + textId = 0x10CE; + } else { + textId = 0x10D4; + } + break; + case 2: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_24_04); + this->unk_3C0 = 0; + textId = 0x10DD; + } else { + textId = 0x10DA; + } + break; + case 4: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_01)) { + textId = 0x10EE; + } else { + textId = 0x10E9; + } + break; + case 5: + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + textId = 0x10F3; + break; + case 7: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_24_04); + textId = 0x10FB; + } else { + textId = 0x10E9; + } + break; + case 9: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_01)) { + textId = 0x1102; + } else { + textId = 0x10E9; + } + break; + } + return textId; +} + +s32 func_80A973B4(EnAz* this, PlayState* play) { + s32 ret = 0; + + if (this->getItemId != GI_RUPEE_RED) { + if ((this->getItemId != GI_RUPEE_PURPLE) && (this->getItemId != GI_HEART_PIECE)) { + if (this->getItemId == GI_BOTTLE) { + ret = 0x10F2; + } + } else { + ret = 0x1106; + } + } else { + ret = 0x1109; + } + this->unk_374 |= 0x20; + + return ret; +} + +void func_80A97410(EnAz* this, PlayState* play) { + s16 sp56; + s16 sp54; + s32 temp_a0; + + if (this->unk_378 != 0) { + Vec3f* thisPos = &this->actor.world.pos; + + if ((this->unk_2FA == 0) && !(this->unk_374 & 2)) { + Math_SmoothStepToS(&this->unk_3D4, 0, 2, 0x71C, 0xA); + Math_SmoothStepToS(&this->unk_3D6, 0, 3, 0x71C, 0xA); + } + if (this->brother != NULL) { + Vec3f* broPos = &this->brother->actor.world.pos; + + if (this->unk_374 & 0x40) { + this->actor.focus.pos.x = (thisPos->x * 0.5f) + (broPos->x * 0.5f); + this->actor.focus.pos.y = (thisPos->y * 0.5f) + (broPos->y * 0.5f) + 45.0f; + this->actor.focus.pos.z = (thisPos->z * 0.5f) + (broPos->z * 0.5f); + } else { + this->actor.focus.pos.x = (thisPos->x * 0.7f) + (broPos->x * 0.3f); + this->actor.focus.pos.y = (thisPos->y * 0.7f) + (broPos->y * 0.3f) + 45.0f; + this->actor.focus.pos.z = (thisPos->z * 0.7f) + (broPos->z * 0.3f); + } + } else { + this->actor.focus.pos.x = thisPos->x; + this->actor.focus.pos.y = thisPos->y; + this->actor.focus.pos.z = thisPos->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; + } + if (this->unk_378 == 2) { + this->unk_378 = func_80A9617C(this, play); + if (this->unk_378 == 0) { + this->actor.flags &= ~ACTOR_FLAG_10000; + } + } + if (this->unk_378 == 3) { + func_80151938(play, this->actor.textId); + this->unk_378 = 2; + } else if (this->unk_378 == 5) { + Message_StartTextbox(play, this->actor.textId, &this->actor); + this->unk_378 = 2; + } else { + if ((this->unk_378 == 6) || (this->unk_378 == 7)) { + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + if (this->unk_378 == 7) { + this->unk_378 = 1; + this->unk_374 |= 0x20; + } else { + this->unk_378 = 0; + } + } else { + Actor_PickUp(&this->actor, play, this->getItemId, this->actor.xzDistToPlayer, + this->actor.playerHeightRel); + } + } + if (this->unk_378 == 9) { + temp_a0 = Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xE38, 0x222); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (temp_a0 == 0) { + switch (this->unk_3D2) { + case 0x10CE: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK, + &this->animIndex); + break; + case 0x10D4: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_TALK_WAVE_ARMS, + &this->animIndex); + break; + } + Message_StartTextbox(play, this->unk_3D2, &this->actor); + this->actor.textId = this->unk_3D2; + this->unk_378 = 2; + } + } else if (((this->unk_378 == 0) || (this->unk_378 == 1)) && (this->unk_374 & 0x20)) { + if (this->unk_378 == 1) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A97114(this, play); + this->unk_378 = 2; + } else if (func_800B8500(&this->actor, play, this->actor.xzDistToPlayer, this->actor.playerHeightRel, + PLAYER_IA_MINUS1)) { + this->actor.textId = func_80A973B4(this, play); + } + } else { + if ((this->unk_2FA == 0) && !(this->unk_374 & 2)) { + Player* player = GET_PLAYER(play); + Vec3f sp38; + s16 temp_a1_2 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + s16 temp_v0_7; + + if (ABS(temp_a1_2) < 0x1800) { + Math_SmoothStepToS(&this->unk_3D4, temp_a1_2, 2, 0x71C, 0); + } else { + Math_SmoothStepToS(&this->unk_3D4, 0, 2, 0x71C, 0); + } + Math_Vec3f_Copy(&sp38, &player->actor.world.pos); + sp38.y = player->bodyPartsPos[7].y + 3.0f; + temp_v0_7 = Math_Vec3f_Pitch(&this->actor.focus.pos, &sp38); + if (ABS(temp_v0_7) < 0x800) { + Math_SmoothStepToS(&this->unk_3D6, temp_v0_7, 3, 0x71C, 0); + } else { + Math_SmoothStepToS(&this->unk_3D6, 0, 3, 0x71C, 0); + } + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80A97114(this, play); + this->unk_378 = 2; + if ((this->unk_3D2 == 0x10CE) || (this->unk_3D2 == 0x10D4)) { + this->unk_378 = 9; + } + } else { + Actor_GetScreenPos(play, &this->actor, &sp56, &sp54); + if ((sp56 >= 0) && (sp56 <= SCREEN_WIDTH) && (sp54 >= 0) && (sp54 <= SCREEN_HEIGHT) && + func_800B8500(&this->actor, play, 120.0f, 120.0f, 0)) { + this->unk_3D2 = func_80A97274(this, play); + if ((this->unk_3D2 == 0x10CE) || (this->unk_3D2 == 0x10D4)) { + this->actor.textId = 0; + } else { + this->actor.textId = this->unk_3D2; + } + } + } + } + } + } +} + +void func_80A979DC(EnAz* this, PlayState* play) { + this->actionFunc = func_80A979F4; +} + +void func_80A979F4(EnAz* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + Actor_MoveWithGravity(&this->actor); +} + +void func_80A97A28(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97A40; +} + +void func_80A97A40(EnAz* this, PlayState* play) { + if (SubS_StartActorCutscene(&this->actor, 0, -1, SUBS_CUTSCENE_SET_UNK_LINK_FIELDS)) { + play->msgCtx.msgMode = 0; + play->msgCtx.msgLength = 0; + func_80A97A9C(this, play); + } +} + +void func_80A97A9C(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97AB4; +} + +void func_80A97AB4(EnAz* this, PlayState* play) { + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_NONE: + Message_StartTextbox(play, 0x10D7, NULL); + break; + case TEXT_STATE_CHOICE: + case TEXT_STATE_5: + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x10D7: + func_80151938(play, 0x10D8); + break; + case 0x10D8: + if (play->msgCtx.choiceIndex == 0) { + func_8019F208(); + play->msgCtx.msgMode = 0x44; + func_800FD750(NA_BGM_TIMED_MINI_GAME); + func_80A94AB8(this, play, 1); + func_80A979DC(this, play); + } else { + func_8019F230(); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_04); + } + func_80151938(play, 0x10D9); + } + break; + case 0x10D9: + func_80A94AB8(this, play, 0); + func_80A979DC(this, play); + break; + } + } + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + break; + } +} + +void func_80A97C0C(EnAz* this, PlayState* play) { + this->actionFunc = func_80A97C4C; +} + +void func_80A97C24(EnAz* this, PlayState* play) { + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc = func_80A97C4C; +} + +void func_80A97C4C(EnAz* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime) && (this->animIndex == BEAVER_ANIM_BOW)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_IDLE, &this->animIndex); + } + func_80A97410(this, play); + if ((this->unk_2FA == 1) || (this->unk_2FA == 3) || (this->unk_2FA == 6) || (this->unk_2FA == 8)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_01); + func_800FD750(NA_BGM_TIMED_MINI_GAME); + play->nextEntrance = Entrance_CreateFromSpawn(1); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + func_80A979DC(this, play); + } else { + Actor_MoveWithGravity(&this->actor); + } +} + +void func_80A97D5C(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + player->stateFlags1 |= PLAYER_STATE1_20; + Interface_InitMinigame(play); + gSaveContext.minigameScore = (this->unk_374 & 2) ? 25 : 20; + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; + if ((this->unk_2FA == 1) || (this->unk_2FA == 3)) { + Interface_StartTimer(TIMER_ID_MINIGAME_2, 120); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_01)) { + Interface_StartTimer(TIMER_ID_MINIGAME_2, 100); + } else { + Interface_StartTimer(TIMER_ID_MINIGAME_2, 110); + } + this->actionFunc = func_80A97E48; +} + +void func_80A97E48(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (play->interfaceCtx.minigameState >= MINIGAME_STATE_COUNTDOWN_GO) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80A97EAC(this, play); + } + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); +} + +void func_80A97EAC(EnAz* this, PlayState* play) { + SubS_ActorPathing_Init(play, &this->actor.world.pos, &this->actor, &this->unk_300, play->setupPathList, + BEAVER_GET_PARAM_FF(&this->actor), 0, 0, 1, 0); + this->unk_36C = 8.0f; + this->actor.speedXZ = 8.0f; + this->actor.gravity = 0.0f; + this->actor.velocity.y = 6.0f; + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, BEAVER_ANIM_SWIM_WITH_SPINNING_TAIL, + &this->animIndex); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->actor.bgCheckFlags &= ~0x21; + this->unk_374 |= 0x1000; + this->unk_3C2 = 0; + this->unk_3C4 = 0; + this->actionFunc = func_80A97F9C; +} + +void func_80A97F9C(EnAz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + D_80A99E8C = + Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, D_80A99E80.x, D_80A99E80.z); + if (Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, D_80A99E80.x, D_80A99E80.z) >= + SQ(1000.0f)) { + this->unk_374 |= 0x1000; + } + if (!(this->unk_300.flags & ACTOR_PATHING_REACHED_END_PERMANENT)) { + SubS_ActorPathing_Update(play, &this->unk_300, func_80A982E0, func_80A95B34, SubS_ActorPathing_MoveWithGravity, + SubS_ActorPathing_SetNextPoint); + } + if (!(this->unk_374 & 0x10) && + SurfaceType_IsHorseBlocked(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + this->unk_374 |= 0x10; + } + if (SurfaceType_IsHorseBlocked(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + if (func_80A94B98(this, play)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_24_01); + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_24_01); + } + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; + this->unk_374 &= ~0x10; + play->nextEntrance = Entrance_CreateFromSpawn(2); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_03; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + this->actor.speedXZ = 0.0f; + func_80A979DC(this, play); + } else { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; + this->unk_374 |= 0x4000; + func_80A97A28(this, play); + } + if (this->unk_374 & 0x100) { + if (this->actor.flags & ACTOR_FLAG_40) { + func_80A98414(this, play); + } + if ((DECR(this->unk_37A) == 0) && (this->actor.flags & ACTOR_FLAG_40)) { + EffectSsBubble_Spawn(play, &this->actor.world.pos, 0.0f, 20.0f, 20.0f, 0.35f); + this->unk_37A = (Rand_ZeroOne() * 70.0f) + 10.0f; + } + } + if (this->actor.depthInWater > 8.0f) { + if (this->unk_374 & 2) { + if ((this->skelAnime.curFrame < this->skelAnime.playSpeed) && (this->skelAnime.curFrame >= 0.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BEAVER_SWIM_HAND); + } + } else { + func_800B9010(&this->actor, NA_SE_EV_BEAVER_SWIM_MOTOR - SFX_FLAG); + } + } + SkelAnime_Update(&this->skelAnime); + } +} + +void func_80A982E0(PlayState* play, ActorPathing* actorPathing) { + EnAz* this = (EnAz*)actorPathing->actor; + Vec3f sp28; + + actorPathing->curPoint.x = actorPathing->points[actorPathing->curPointIndex].x; + if (this->actor.bgCheckFlags & 1) { + actorPathing->curPoint.y = actorPathing->points[actorPathing->curPointIndex].y; + } else { + actorPathing->curPoint.y = actorPathing->points[actorPathing->curPointIndex].y - this->unk_3A4; + } + actorPathing->curPoint.z = actorPathing->points[actorPathing->curPointIndex].z; + sp28.x = actorPathing->curPoint.x - actorPathing->worldPos->x; + sp28.y = actorPathing->curPoint.y - actorPathing->worldPos->y; + sp28.z = actorPathing->curPoint.z - actorPathing->worldPos->z; + actorPathing->distSqToCurPointXZ = Math3D_XZLengthSquared(sp28.x, sp28.z); + actorPathing->distSqToCurPoint = Math3D_LengthSquared(&sp28); + actorPathing->rotToCurPoint.y = Math_Atan2S_XY(sp28.z, sp28.x); + actorPathing->rotToCurPoint.x = Math_Atan2S_XY(sqrtf(actorPathing->distSqToCurPointXZ), -sp28.y); + actorPathing->rotToCurPoint.z = 0; +} + +void func_80A98414(EnAz* this, PlayState* play) { + Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; + + while (itemAction != NULL) { + if (itemAction->id == ACTOR_EN_FISH) { + EnFish* fish = (EnFish*)itemAction; + + if ((fish->actor.params < 0) && (fish->actor.room == this->actor.room) && + (Math3D_Vec3fDistSq(&this->actor.world.pos, &fish->actor.world.pos) < SQ(200.0f))) { + fish->unk_276 = 0x14; + fish->unk_274 = Actor_YawBetweenActors(&fish->actor, &this->actor); + } + } + itemAction = itemAction->next; + } +} + +void EnAz_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnAz* this = THIS; + + this->unk_374 &= ~0x100; + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.depthInWater > 22.0f)) { + if (!(this->unk_376 & 0x100)) { + this->unk_374 |= 0x200; + } + this->unk_374 |= 0x100; + } else if (this->unk_376 & 0x100) { + this->unk_374 |= 0x400; + } + this->actionFunc(this, play); + Actor_SetFocus(&this->actor, 40.0f); + if (this->unk_374 & 0x200) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER); + } + if (this->unk_374 & 0x400) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + } + this->unk_37E++; + if (this->unk_37E >= 4) { + this->unk_37E = 0; + } + this->unk_380++; + if (this->unk_380 >= 3) { + this->unk_380 = 0; + } + this->unk_384--; + if (this->unk_384 < 0) { + this->unk_384 = 2; + } + this->unk_39C++; + if (this->unk_39C >= 16) { + this->unk_39C = 0; + } + if (!(this->unk_374 & 0x1000)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 5); + } else { + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 20.0f, 0x400); + this->unk_374 &= ~0x1000; + } + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + + this->unk_376 = this->unk_374; + this->unk_374 &= ~0x600; + + if (GET_ACTIVE_CAM(play)->stateFlags & CAM_STATE_UNDERWATER) { + this->unk_374 |= 0x800; + } else { + this->unk_374 &= ~0x800; + } +} + +static Gfx* D_80A9916C[] = { + gBeaverOlderBrotherTailVortex1DL, gBeaverOlderBrotherTailVortex2DL, gBeaverOlderBrotherTailVortex3DL, + gBeaverOlderBrotherTailVortex4DL, gBeaverOlderBrotherTailVortex5DL, +}; +static AnimatedMaterial* D_80A99180[] = { + gBeaverOlderBrotherTailVortex1TexAnim, gBeaverOlderBrotherTailVortex2TexAnim, gBeaverOlderBrotherTailVortex3TexAnim, + gBeaverOlderBrotherTailVortex4TexAnim, gBeaverOlderBrotherTailVortex5TexAnim, +}; +static u8 D_80A99194[] = { + 95, 135, 175, 215, 255, +}; +static u8 D_80A9919C[] = { + 31, 45, 58, 73, 85, +}; +static struct_80124618 D_80A991A4[5][9] = { + { + { 0, { 200, 160, 160 } }, + { 2, { 250, 210, 210 } }, + { 4, { 200, 160, 160 } }, + { 6, { 250, 210, 210 } }, + { 8, { 200, 160, 160 } }, + { 10, { 250, 210, 210 } }, + { 12, { 200, 160, 160 } }, + { 14, { 250, 210, 210 } }, + { 16, { 200, 160, 160 } }, + }, + { + { 0, { 330, 200, 200 } }, + { 2, { 280, 150, 150 } }, + { 4, { 330, 200, 200 } }, + { 6, { 280, 150, 150 } }, + { 8, { 330, 200, 200 } }, + { 10, { 280, 150, 150 } }, + { 12, { 330, 200, 200 } }, + { 14, { 280, 150, 150 } }, + { 16, { 330, 200, 200 } }, + }, + { + { 0, { 350, 170, 120 } }, + { 2, { 400, 220, 170 } }, + { 4, { 350, 170, 120 } }, + { 6, { 400, 220, 170 } }, + { 8, { 350, 170, 120 } }, + { 10, { 400, 220, 170 } }, + { 12, { 350, 170, 120 } }, + { 14, { 400, 220, 170 } }, + { 16, { 350, 170, 120 } }, + }, + { + { 0, { 480, 216, 156 } }, + { 2, { 540, 216, 156 } }, + { 4, { 450, 300, 216 } }, + { 6, { 540, 216, 156 } }, + { 8, { 450, 300, 216 } }, + { 10, { 540, 216, 156 } }, + { 12, { 450, 300, 216 } }, + { 14, { 540, 300, 156 } }, + { 16, { 450, 250, 216 } }, + }, + { + { 0, { 600, 375, 160 } }, + { 2, { 640, 510, 200 } }, + { 4, { 600, 375, 160 } }, + { 6, { 640, 510, 200 } }, + { 8, { 600, 375, 160 } }, + { 10, { 640, 510, 200 } }, + { 12, { 600, 375, 160 } }, + { 14, { 640, 510, 200 } }, + { 16, { 600, 375, 160 } }, + }, +}; +static struct_80A98F94 D_80A9930C[5][4] = { + { { 0, 2100.0f }, { 7, 1500.0f }, { 16, 2100.0f }, { 0, 0.0f } }, + { { 0, 1900.0f }, { 7, 2200.0f }, { 10, 1600.0f }, { 16, 1900.0f } }, + { { 0, 1700.0f }, { 7, 2200.0f }, { 16, 1700.0f }, { 0, 0.0f } }, + { { 0, 1900.0f }, { 4, 1600.0f }, { 10, 2200.0f }, { 16, 1900.0f } }, + { { 0, 1900.0f }, { 7, 1400.0f }, { 16, 1900.0f }, { 0, 0.0f } }, +}; +static Vec3f D_80A993AC[] = { + { 1.0f, 1.0f, 0.0f }, + { 0.9f, 0.9f, 120.0f }, + { 0.95f, 0.95f, 240.0f }, +}; +static Vec3f D_80A993D0[] = { + { 1.5f, 1.5f, 0.0f }, + { 1.2f, 1.2f, 120.0f }, + { 1.35f, 1.35f, 240.0f }, +}; +static TexturePtr sYoungerBrotherEyeTextures[] = { + gBeaverYoungerBrotherEye1Tex, + gBeaverYoungerBrotherEye2Tex, + gBeaverYoungerBrotherEye3Tex, + gBeaverYoungerBrotherEye4Tex, +}; +static TexturePtr sYoungerBrotherBeltTextures[] = { + gBeaverYoungerBrotherBeltRedTex, + gBeaverYoungerBrotherBeltGreenTex, + gBeaverYoungerBrotherBeltBlueTex, +}; + +void EnAz_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnAz* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x19); + CLOSE_DISPS(play->state.gfxCtx); + + if (this->unk_374 & 2) { + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80A98DA4, func_80A98E48, &this->actor); + } else { + OPEN_DISPS(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sYoungerBrotherEyeTextures[this->unk_37E])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sYoungerBrotherBeltTextures[this->unk_380])); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + func_80A98DA4, func_80A98E48, &this->actor); + CLOSE_DISPS(play->state.gfxCtx); + } + OPEN_DISPS(play->state.gfxCtx); + if ((this->actor.depthInWater >= 28.0f) && (this->actor.speedXZ > 0.5f)) { + Matrix_Translate(this->unk_3B4.x, this->unk_3B4.y, this->unk_3B4.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_RotateXS(this->unk_39E, MTXMODE_APPLY); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + func_8012C2DC(play->state.gfxCtx); + if (this->unk_374 & 2) { + s32 i; + Vec3f sp98; + f32 sp94; + + Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); + for (i = 0; i < ARRAY_COUNT(D_80A99180); i++) { + Matrix_Push(); + func_80A98F94(D_80A9930C[i], this->unk_39C, &sp94); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(D_80A99180[i])); + Matrix_Translate(0.0f, sp94 * 100.0f, i * -930.0f, MTXMODE_APPLY); + Matrix_Scale(1.1f, 0.95f, 1.0f, MTXMODE_APPLY); + func_80124618(D_80A991A4[i], this->unk_39C, &sp98); + Matrix_Scale(sp98.x, sp98.y, sp98.z, MTXMODE_APPLY); + if (this->unk_374 & 0x800) { + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, D_80A99194[i])); + } else { + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, D_80A9919C[i])); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_80A9916C[i]); + Matrix_Pop(); + } + } else { + Matrix_Push(); + Matrix_Translate(0.0f, 2000.0f, -2000.0f, MTXMODE_APPLY); + Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); + Matrix_Scale(D_80A993AC[this->unk_384].x, D_80A993AC[this->unk_384].y, 0.0f, MTXMODE_APPLY); + if (this->unk_374 & 0x800) { + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 255)); + } else { + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_PrimColor(play->state.gfxCtx, 0x80, 255, 255, 255, 85)); + } + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBeaverYoungerBrotherTailVortexDL); + Matrix_Pop(); + Matrix_Translate(0.0f, 2000.0f, -2100.0f, MTXMODE_APPLY); + Matrix_RotateZS(D_80A993D0[this->unk_384].z * (0x10000 / 360.0f), MTXMODE_APPLY); + Matrix_Scale(D_80A993D0[this->unk_384].x, D_80A993D0[this->unk_384].y, 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++, gBeaverYoungerBrotherTailSplashDL); + } + } + CLOSE_DISPS(play->state.gfxCtx); +} + +s32 func_80A98DA4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnAz* this = THIS; + + if ((limbIndex == BEAVER_OLDER_BROTHER_LIMB_NONE) && ((play->gameplayFrames % 2) != 0)) { + *dList = NULL; + } + if (limbIndex == BEAVER_OLDER_BROTHER_LIMB_NONE) { + rot->x = rot->x; + rot->y = rot->y; + rot->z = rot->z; + } + if (limbIndex == BEAVER_OLDER_BROTHER_LIMB_PELVIS) { + rot->y -= this->unk_39E; + } else { + // this space intentionally left blank + } + if (limbIndex == BEAVER_OLDER_BROTHER_LIMB_HEAD_ROOT) { + rot->x += this->unk_3D4; + rot->y -= this->unk_3D6; + } + return false; +} + +void func_80A98E48(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80A99410 = { 700.0f, 0.0f, 0.0f }; + static Vec3f D_80A9941C = { -500.0f, 0.0f, 0.0f }; + static Vec3f D_80A99428 = { -1200.0f, 0.0f, 1000.0f }; + EnAz* this = THIS; + + if (limbIndex == BEAVER_OLDER_BROTHER_LIMB_PELVIS) { + Matrix_MultVec3f(&D_80A99410, &this->unk_3A8); + Math_SmoothStepToF(&this->unk_3A4, this->unk_3A8.y - this->actor.world.pos.y, 0.8f, 10.0f, 0.01f); + if (this->unk_374 & 2) { + Matrix_MultVec3f(&D_80A9941C, &this->unk_3B4); + } else { + Matrix_MultVec3f(&D_80A99428, &this->unk_3B4); + } + } +} + +void func_80A98EFC(EnAz* this, PlayState* play, u16 textId, s32 animIndex, s32 brotherAnimIndex) { + EnAz* brother = this->brother; + + Actor_ChangeFocus(&this->actor, play, &brother->actor); + if (animIndex >= 0) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimationInfo, animIndex, &this->animIndex); + } + this->actor.textId = 0; + brother->actor.textId = textId; + brother->unk_378 = 5; + if ((brotherAnimIndex >= 0) && (brotherAnimIndex != brother->animIndex)) { + SubS_ChangeAnimationBySpeedInfo(&brother->skelAnime, sAnimationInfo, brotherAnimIndex, &brother->animIndex); + } + this->unk_378 = 0; +} + +void func_80A98F94(struct_80A98F94* yData, f32 frame, f32* yInterp) { + f32 nextFrame; + f32 prevFrame; + f32 weight; + + do { + yData++; + nextFrame = yData[0].unk_0; + } while (nextFrame < frame); + prevFrame = yData[-1].unk_0; + weight = LERPWEIGHT(frame, prevFrame, nextFrame); + *yInterp = LERPIMP(yData[-1].unk_4, yData[0].unk_4, weight) * 0.01f; +} 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..2a219eb24 100644 --- a/src/overlays/actors/ovl_En_Az/z_en_az.h +++ b/src/overlays/actors/ovl_En_Az/z_en_az.h @@ -5,14 +5,50 @@ struct EnAz; -typedef void (*EnAzActionFunc)(struct EnAz*, GlobalContext*); +typedef void (*EnAzActionFunc)(struct EnAz*, PlayState*); + +#define BEAVER_GET_PARAM_F00(thisx) (((thisx)->params >> 8) & 0xF) +#define BEAVER_GET_PARAM_FF(thisx) ((thisx)->params & 0xFF) typedef struct EnAz { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnAzActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x290]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnAzActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ Vec3s jointTable[24]; + /* 0x268 */ Vec3s morphTable[24]; + /* 0x2F8 */ s16 unk_2F8; + /* 0x2FA */ s16 unk_2FA; // cutscene state? + /* 0x2FC */ s32 animIndex; + /* 0x300 */ ActorPathing unk_300; + /* 0x36C */ f32 unk_36C; + /* 0x370 */ UNK_TYPE1 unk370[4]; + /* 0x374 */ u16 unk_374; // flags of some sort + /* 0x376 */ u16 unk_376; // flags of some sort + /* 0x378 */ u8 unk_378; // cutscene state? + /* 0x37A */ s16 unk_37A; + /* 0x37C */ s16 unk_37C; + /* 0x37E */ s16 unk_37E; + /* 0x380 */ s16 unk_380; + /* 0x382 */ s16 unk_382; + /* 0x384 */ s16 unk_384; + /* 0x388 */ struct EnAz* brother; + /* 0x38C */ UNK_TYPE1 unk38C[0x10]; + /* 0x39C */ s16 unk_39C; + /* 0x39E */ s16 unk_39E; // some sort of rotation + /* 0x3A0 */ UNK_TYPE1 unk3A0[4]; + /* 0x3A4 */ f32 unk_3A4; + /* 0x3A8 */ Vec3f unk_3A8; + /* 0x3B4 */ Vec3f unk_3B4; // translation + /* 0x3C0 */ s16 unk_3C0; // seems to do nothing + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 unk_3C4; + /* 0x3C6 */ UNK_TYPE1 unk3C6[6]; + /* 0x3CC */ s32 getItemId; + /* 0x3D0 */ s16 unk_3D0[1]; + /* 0x3D2 */ u16 unk_3D2; + /* 0x3D4 */ s16 unk_3D4; + /* 0x3D6 */ s16 unk_3D6; } EnAz; // size = 0x3D8 -extern const ActorInit En_Az_InitVars; - #endif // Z_EN_AZ_H diff --git a/src/overlays/actors/ovl_En_Baba/overlay.cfg b/src/overlays/actors/ovl_En_Baba/overlay.cfg deleted file mode 100644 index 8d3dddae0..000000000 --- a/src/overlays/actors/ovl_En_Baba/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Baba -z_en_baba.c 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 e6dd15a32..6040076f4 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -5,31 +5,52 @@ */ #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); -const ActorInit En_Baba_InitVars = { +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; + +ActorInit En_Baba_InitVars = { ACTOR_EN_BABA, ACTORCAT_NPC, FLAGS, @@ -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,632 +128,669 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static u8 D_80BAA488[] = { +static u8 sSchedule[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1D - 0x04), /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1C - 0x08), /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 30, 0x16 - 0x0E), /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x15 - 0x12), - /* 0x12 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_L(BOMB_SHOP_LADY_SCH_KNOCKED_OVER), /* 0x15 */ SCHEDULE_CMD_RET_NONE(), - /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, 2), + /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH), /* 0x1C */ SCHEDULE_CMD_RET_NONE(), /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; -s32 D_80BAA4A8[] = { -1, -1, 0 }; +static s32 sSearchTimePathLimit[] = { -1, -1, 0 }; -static TurnOptionsSet sTurnOptions = { +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 (gSaveContext.save.weekEventReg[33] & 8) { - this->unk_1E0 = 0x2A34; + if (this->stateFlags & BOMB_SHOP_LADY_STATE_AUTOTALK) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08)) { + // Thanks. Can stock Bomb Bags tomorrow + this->textId = 0x2A34; break; } - if (gSaveContext.save.weekEventReg[79] & 0x40) { - this->unk_40A |= 1; - this->unk_1E0 = 0x2A33; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40)) { + 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; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_79_20)) { + SET_WEEKEVENTREG(WEEKEVENTREG_79_20); + 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; + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_73_01)) { + // 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; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_73_02)) { + // 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; - gSaveContext.save.weekEventReg[73] |= 1; - this->unk_40A |= 1; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // I'll go next time + this->textId = 0x663; + SET_WEEKEVENTREG(WEEKEVENTREG_73_01); + 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; - gSaveContext.save.weekEventReg[73] |= 2; - this->unk_40A |= 1; + Actor_ChangeFocus(&this->actor, play, &this->bombShopkeeper->actor); + // I worry about you + this->textId = 0x65D; + SET_WEEKEVENTREG(WEEKEVENTREG_73_02); + 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); +void EnBaba_UpdateModel(EnBaba* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x36B0, this->actor.yawTowardsPlayer) && - !(this->unk_40A & 4)) { + !(this->stateFlags & BOMB_SHOP_LADY_STATE_KNOCKED_OVER)) { point.x = player->actor.world.pos.x; - point.y = player->bodyPartsPos[7].y + 3.0f; + point.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.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->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, ScheduleResult* 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->result] >= 0) { - this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); + 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->time0; + startTime = scheduleOutput->time0; } - if (arg2->time1 < temp) { - this->unk_424 = (temp - arg2->time1) + 0xFFFF; + if (scheduleOutput->time1 < startTime) { + this->timePathTotalTime = (startTime - scheduleOutput->time1) + (DAY_LENGTH - 1); } else { - this->unk_424 = arg2->time1 - 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, ScheduleResult* arg2) { - s32 ret; +s32 EnBaba_ProcessScheduleOutput(EnBaba* this, PlayState* play, ScheduleOutput* scheduleOutput) { + s32 success; - switch (arg2->result) { + switch (scheduleOutput->result) { default: - ret = false; + success = false; break; - case 2: - ret = func_80BA8F88(this, 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 (SubS_InCsMode(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 (SubS_InCsMode(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) { - 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; +void EnBaba_HandleSchedule(EnBaba* this, PlayState* play) { + switch (this->scheduleResult) { + case BOMB_SHOP_LADY_SCH_FOLLOW_TIME_PATH: + SET_WEEKEVENTREG(WEEKEVENTREG_58_40); + 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 ((gSaveContext.save.weekEventReg[58] & 0x40) || - (!(gSaveContext.save.time < CLOCK_TIME(0, 20)) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { - Actor_MarkForDeath(&this->actor); + if (play->sceneId == 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->sceneId == 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_58_40) || + (gSaveContext.save.time >= CLOCK_TIME(0, 20) && (gSaveContext.save.time < CLOCK_TIME(6, 0)))) { + Actor_Kill(&this->actor); return; } - this->unk_404 = 50; - this->unk_40C = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_80BA9B80; - } else if ((ENBABA_GET_C000(&this->actor) == ENBABA_C000_1) && (gSaveContext.save.entranceIndex == 0xD670)) { - if (gSaveContext.save.weekEventReg[81] & 2) { - Actor_MarkForDeath(&this->actor); + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_81_02)) { + Actor_Kill(&this->actor); return; } - this->unk_40A |= 2; - if (gSaveContext.save.weekEventReg[33] & 8) { - this->unk_40C = 0; + this->stateFlags |= BOMB_SHOP_LADY_STATE_VISIBLE; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08)) { + 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); + Actor_Kill(&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) { - gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(globalCtx, 0xD670); + if (play->msgCtx.unk120B1 == 0) { + SET_WEEKEVENTREG(WEEKEVENTREG_81_02); + EnBaba_TriggerTransition(play, ENTRANCE(NORTH_CLOCK_TOWN, 7)); return; } } else { - gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(globalCtx, 0xD670); + SET_WEEKEVENTREG(WEEKEVENTREG_81_02); + 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)) { - gSaveContext.save.weekEventReg[81] |= 2; - func_80BA8C4C(globalCtx, 0xD670); + } else if (talkState == TEXT_STATE_DONE) { + if (Message_ShouldAdvance(play) && (play->msgCtx.unk120B1 == 0)) { + SET_WEEKEVENTREG(WEEKEVENTREG_81_02); + 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_IA_MINUS1); } } -void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { - ScheduleResult sp20; +void EnBaba_FollowSchedule(EnBaba* this, PlayState* play) { + ScheduleOutput scheduleOutput; - this->unk_436 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); - if (!Schedule_RunScript(globalCtx, D_80BAA488, &sp20) || - ((this->unk_434 != sp20.result) && !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.result = false; + scheduleOutput.result = BOMB_SHOP_LADY_SCH_NONE; } else { - this->unk_40A |= 0x80; + this->stateFlags |= BOMB_SHOP_LADY_STATE_DRAW_SHADOW; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_434 = sp20.result; + this->scheduleResult = scheduleOutput.result; - func_80BA93AC(this, 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40) && (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) { + if (limbIndex == BBA_LIMB_NECK) { Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if (limbIndex == 5) { + if (limbIndex == BBA_LIMB_UPPER_ROOT) { Matrix_RotateXS(-this->torsoRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->torsoRot.x, MTXMODE_APPLY); } - if ((limbIndex == 6) && (this->unk_1E2 != 0) && ((globalCtx->state.frames % 2) == 0)) { + if ((limbIndex == BBA_LIMB_NECK) && (this->inMsgState3 != 0) && ((play->state.frames % 2) == 0)) { Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } - if ((limbIndex == 5) || (limbIndex == 10) || (limbIndex == 14)) { - rot->y += (s16)(Math_SinS(this->unk_302[limbIndex]) * 200.0f); - rot->z += (s16)(Math_CosS(this->unk_326[limbIndex]) * 200.0f); + if ((limbIndex == BBA_LIMB_UPPER_ROOT) || (limbIndex == BBA_LIMB_LEFT_UPPER_ARM) || + (limbIndex == BBA_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)(Math_SinS(this->limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotTableZ[limbIndex]) * 200.0f); } - if (((this->unk_40C == 1) || (this->unk_40C == 3) || (this->unk_40C == 4) || - (ENBABA_GET_C000(&this->actor) == ENBABA_C000_2)) && - (limbIndex == 8)) { + if (((this->animIndex == BOMB_SHOP_LADY_ANIM_IDLE) || (this->animIndex == BOMB_SHOP_LADY_ANIM_KNOCKED_OVER) || + (this->animIndex == BOMB_SHOP_LADY_ANIM_LYING_DOWN) || + (BOMB_SHOP_LADY_GET_TYPE(&this->actor) == BOMB_SHOP_LADY_TYPE_SWAY)) && + (limbIndex == BBA_LIMB_BAG)) { *dList = NULL; } - return 0; + return false; } -void EnBaba_PostLimbDraw(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; @@ -740,40 +798,41 @@ void EnBaba_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } } -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 6a21168b6..7da0ed054 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -2,60 +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 turnTarget; - /* 0x02E4 */ Vec3s headRot; - /* 0x02EA */ Vec3s torsoRot; - /* 0x02F0 */ UNK_TYPE1 unk2F0[0x12]; - /* 0x0302 */ s16 unk_302[18]; - /* 0x0326 */ s16 unk_326[18]; - /* 0x034A */ UNK_TYPE1 unk34A[0xBA]; - /* 0x0404 */ s16 unk_404; - /* 0x0406 */ UNK_TYPE1 unk406[4]; - /* 0x040A */ u16 unk_40A; - /* 0x040C */ s32 unk_40C; - /* 0x0410 */ Path* 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; - #endif // Z_EN_BABA_H diff --git a/src/overlays/actors/ovl_En_Baguo/overlay.cfg b/src/overlays/actors/ovl_En_Baguo/overlay.cfg deleted file mode 100644 index 19e80c5e0..000000000 --- a/src/overlays/actors/ovl_En_Baguo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Baguo -z_en_baguo.c 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 88fc11072..9017e0f89 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 @@ -42,7 +41,7 @@ typedef enum { /* 0x1 */ NEJIRON_DIRECTION_LEFT } NejironRollDirection; -const ActorInit En_Baguo_InitVars = { +ActorInit En_Baguo_InitVars = { ACTOR_EN_BAGUO, ACTORCAT_ENEMY, FLAGS, @@ -77,7 +76,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -122,13 +121,12 @@ 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); - this->actor.hintId = 0xB; + SkelAnime_Init(play, &this->skelAnime, &gNejironSkel, NULL, this->jointTable, this->morphTable, NEJIRON_LIMB_MAX); + this->actor.hintId = TATL_HINT_ID_NEJIRON; this->maxDistanceFromHome = 240.0f; this->maxDistanceFromHome += this->actor.world.rot.z * 40.0f; this->actor.world.rot.z = 0; @@ -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); + Actor_Kill(&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_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); - Matrix_RotateZS(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..d6eb2173c 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,9 +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; - #endif // Z_EN_BAGUO_H diff --git a/src/overlays/actors/ovl_En_Baisen/overlay.cfg b/src/overlays/actors/ovl_En_Baisen/overlay.cfg deleted file mode 100644 index e1ba96f41..000000000 --- a/src/overlays/actors/ovl_En_Baisen/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Baisen -z_en_baisen.c 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..8812ae6d3 100644 --- a/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c +++ b/src/overlays/actors/ovl_En_Baisen/z_en_baisen.c @@ -11,19 +11,19 @@ #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 = { +ActorInit En_Baisen_InitVars = { ACTOR_EN_BAISEN, ACTORCAT_NPC, FLAGS, @@ -57,36 +57,34 @@ 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; if (this->actor.params == 0) { this->unk290 = true; - if (!(gSaveContext.save.weekEventReg[63] & 0x80) && - ((gSaveContext.save.day != 3) || !gSaveContext.save.isNight)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_80) && ((gSaveContext.save.day != 3) || !gSaveContext.save.isNight)) { + Actor_Kill(&this->actor); } } else { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - if ((gSaveContext.save.weekEventReg[63] & 0x80) || - ((gSaveContext.save.day == 3) && (gSaveContext.save.isNight))) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_80) || ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_Kill(&this->actor); } } 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 +92,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 +120,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 +136,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 +147,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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_60_08)) { 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 +184,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 +206,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; @@ -249,12 +247,12 @@ void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) { } this->actor.shape.rot.y = this->actor.world.rot.y; if ((this->paramCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&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 +261,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 +276,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..4c0ced24f 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; @@ -32,6 +32,4 @@ typedef struct EnBaisen { /* 0x2B0 */ ColliderCylinder collider; } EnBaisen; // size = 0x2FC -extern const ActorInit En_Baisen_InitVars; - #endif // Z_EN_BAISEN_H diff --git a/src/overlays/actors/ovl_En_Bal/overlay.cfg b/src/overlays/actors/ovl_En_Bal/overlay.cfg deleted file mode 100644 index 53fdf3ee5..000000000 --- a/src/overlays/actors/ovl_En_Bal/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bal -z_en_bal.c 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..779373a9d 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.c +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.c @@ -10,13 +10,13 @@ #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 = { +ActorInit En_Bal_InitVars = { ACTOR_EN_BAL, ACTORCAT_NPC, FLAGS, @@ -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..a64ef195d 100644 --- a/src/overlays/actors/ovl_En_Bal/z_en_bal.h +++ b/src/overlays/actors/ovl_En_Bal/z_en_bal.h @@ -2,18 +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; - #endif // Z_EN_BAL_H diff --git a/src/overlays/actors/ovl_En_Bat/overlay.cfg b/src/overlays/actors/ovl_En_Bat/overlay.cfg deleted file mode 100644 index 1d11f79a3..000000000 --- a/src/overlays/actors/ovl_En_Bat/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bat -z_en_bat.c 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..cee109c70 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.c +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.c @@ -5,23 +5,30 @@ */ #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); -#if 0 -const ActorInit En_Bat_InitVars = { +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); + +ActorInit En_Bat_InitVars = { ACTOR_EN_BAT, ACTORCAT_ENEMY, FLAGS, @@ -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[] = { - ICHAIN_S8(hintId, 96, ICHAIN_CONTINUE), +static InitChainEntry sInitChain[] = { + ICHAIN_S8(hintId, TATL_HINT_ID_BAD_BAT, 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_Kill(thisx); + } else if (EnBat_IsGraveyardOnSecondDay(play)) { + if (Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(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->sceneId == 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_Kill(&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..479cfa24d 100644 --- a/src/overlays/actors/ovl_En_Bat/z_en_bat.h +++ b/src/overlays/actors/ovl_En_Bat/z_en_bat.h @@ -3,16 +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; - #endif // Z_EN_BAT_H diff --git a/src/overlays/actors/ovl_En_Bb/overlay.cfg b/src/overlays/actors/ovl_En_Bb/overlay.cfg deleted file mode 100644 index 048245caf..000000000 --- a/src/overlays/actors/ovl_En_Bb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bb -z_en_bb.c 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 f48976cd6..c5657e385 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, @@ -35,7 +35,7 @@ typedef enum { /* 1 */ BB_BODY_PART_DRAW_STATUS_DEAD, } EnBbBodyPartDrawStatus; -const ActorInit En_Bb_InitVars = { +ActorInit En_Bb_InitVars = { ACTOR_EN_BB, ACTORCAT_ENEMY, FLAGS, @@ -114,7 +114,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 28, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BLUE_BUBBLE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; @@ -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,7 +514,7 @@ 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); @@ -525,10 +524,10 @@ void EnBb_UpdateDamage(EnBb* this, GlobalContext* globalCtx) { 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; @@ -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_GetCurrent(); currentMatrixState->mf[3][0] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].x; currentMatrixState->mf[3][1] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].y; currentMatrixState->mf[3][2] = this->bodyPartsPos[sLimbIndexToBodyPartsIndex[limbIndex]].z; Matrix_RotateZS(thisx->world.rot.z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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_GetCurrent(); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateYS( - ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), - MTXMODE_APPLY); + 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..c852397d4 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; @@ -37,6 +37,4 @@ typedef struct EnBb { /* 0x2F4 */ ColliderSphere collider; } EnBb; // size = 0x34C -extern const ActorInit En_Bb_InitVars; - #endif // Z_EN_BB_H diff --git a/src/overlays/actors/ovl_En_Bba_01/overlay.cfg b/src/overlays/actors/ovl_En_Bba_01/overlay.cfg deleted file mode 100644 index e26bcdd36..000000000 --- a/src/overlays/actors/ovl_En_Bba_01/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bba_01 -z_en_bba_01.c 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 f2c70dac8..1b9538146 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,16 +19,16 @@ #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 = { +ActorInit En_Bba_01_InitVars = { ACTOR_EN_BBA_01, ACTORCAT_NPC, FLAGS, @@ -97,72 +97,72 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -static TurnOptionsSet sTurnOptions = { +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); +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)) { point.x = player->actor.world.pos.x; - point.y = player->bodyPartsPos[7].y + 3.0f; + point.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, - &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); + 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.turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.turnTarget.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.tmpTurnTarget = this->enHy.turnTarget; - 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_IA_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; @@ -170,85 +170,86 @@ 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->turnTarget = this->tmpTurnTarget; - 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); + Actor_Kill(&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 }; @@ -259,11 +260,11 @@ s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } 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] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.headObjIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); @@ -277,8 +278,7 @@ s32 EnBba01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_RotateZS(-this->enHy.torsoRot.x, MTXMODE_APPLY); } - if ((limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) && this->enHy.inMsgState3 && - ((globalCtx->state.frames % 2) == 0)) { + 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); } @@ -290,16 +290,16 @@ 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] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == BBA_LIMB_RIGHT_LOWER_ARM_ROOT) { @@ -307,22 +307,22 @@ void EnBba01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } -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, SUBS_SHADOW_TEX_SIZE); + 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_RotateXS(0, MTXMODE_NEW); @@ -334,7 +334,7 @@ void EnBba01_Draw(Actor* thisx, GlobalContext* globalCtx) { SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); + 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..7160594d8 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,16 +5,13 @@ 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; /* 0x3EC */ UNK_TYPE1 unk_3EC[0x230]; } EnBba01; // size = 0x61C -extern const ActorInit En_Bba_01_InitVars; - #endif // Z_EN_BBA_01_H diff --git a/src/overlays/actors/ovl_En_Bbfall/overlay.cfg b/src/overlays/actors/ovl_En_Bbfall/overlay.cfg deleted file mode 100644 index 711e74e29..000000000 --- a/src/overlays/actors/ovl_En_Bbfall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bbfall -z_en_bbfall.c 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 9e55e8508..1dfc74a22 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.c @@ -11,23 +11,23 @@ #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* play2); void EnBbfall_SetupWaitForPlayer(EnBbfall* this); -void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_WaitForPlayer(EnBbfall* this, PlayState* play); void EnBbfall_SetupEmerge(EnBbfall* this); -void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Emerge(EnBbfall* this, PlayState* play); void EnBbfall_SetupFly(EnBbfall* this); -void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx); +void EnBbfall_Fly(EnBbfall* this, PlayState* play); void EnBbfall_SetupSinkIntoLava(EnBbfall* this); -void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx); -void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx); -void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx); -void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx); -void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx); +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, @@ -35,7 +35,7 @@ typedef enum { /* 1 */ BBFALL_BODY_PART_DRAW_STATUS_DEAD, } EnBbfallBodyPartDrawStatus; -const ActorInit En_Bbfall_InitVars = { +ActorInit En_Bbfall_InitVars = { ACTOR_EN_BBFALL, ACTORCAT_ENEMY, FLAGS, @@ -143,7 +143,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 2, 20, 40, 50 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 36, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_RED_BUBBLE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 10, ICHAIN_STOP), }; @@ -163,15 +163,15 @@ static s8 sLimbIndexToBodyPartsIndex[] = { */ static Vec3f sDuplicateCraniumBodyPartOffset = { 1000.0f, -700.0f, 0.0f }; -void EnBbfall_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnBbfall_Init(Actor* thisx, PlayState* play) { EnBbfall* this = THIS; s32 i; 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); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + 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); @@ -181,10 +181,10 @@ void EnBbfall_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnBbfall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBbfall_Destroy(Actor* thisx, PlayState* play) { EnBbfall* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } void EnBbfall_Freeze(EnBbfall* this) { @@ -197,12 +197,11 @@ void EnBbfall_Freeze(EnBbfall* this) { Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); } -void EnBbfall_Thaw(EnBbfall* this, GlobalContext* globalCtx) { +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(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; } } @@ -210,9 +209,9 @@ void EnBbfall_Thaw(EnBbfall* this, GlobalContext* globalCtx) { /** * Returns true if the Bubble is touching a floor that it should "sink into" (i.e., if it's touching lava). */ -s32 EnBbfall_IsTouchingLava(EnBbfall* this, GlobalContext* globalCtx) { - if (!SurfaceType_IsWallDamage(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { - u32 floorType = func_800C99D4(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); +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); if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { return true; @@ -289,10 +288,10 @@ void EnBbfall_SetupWaitForPlayer(EnBbfall* this) { this->actionFunc = EnBbfall_WaitForPlayer; } -void EnBbfall_WaitForPlayer(EnBbfall* this, GlobalContext* globalCtx) { +void EnBbfall_WaitForPlayer(EnBbfall* this, PlayState* play) { if (this->timer != 0) { this->timer--; - } else if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (this->actor.xyzDistToPlayerSq <= SQ(250.0f))) { + } else if ((Player_GetMask(play) != PLAYER_MASK_STONE) && (this->actor.xyzDistToPlayerSq <= SQ(250.0f))) { EnBbfall_SetupEmerge(this); } } @@ -311,7 +310,7 @@ void EnBbfall_SetupEmerge(EnBbfall* this) { this->actionFunc = EnBbfall_Emerge; } -void EnBbfall_Emerge(EnBbfall* this, GlobalContext* globalCtx) { +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); @@ -329,13 +328,13 @@ void EnBbfall_SetupFly(EnBbfall* this) { this->actionFunc = EnBbfall_Fly; } -void EnBbfall_Fly(EnBbfall* this, GlobalContext* globalCtx) { +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, globalCtx)) { + if (EnBbfall_IsTouchingLava(this, play)) { EnBbfall_SetupSinkIntoLava(this); } else { // Bounce upwards off the ground @@ -357,7 +356,7 @@ void EnBbfall_SetupSinkIntoLava(EnBbfall* this) { this->actionFunc = EnBbfall_SinkIntoLava; } -void EnBbfall_SinkIntoLava(EnBbfall* this, GlobalContext* globalCtx) { +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; @@ -382,12 +381,12 @@ void EnBbfall_SetupDown(EnBbfall* this) { this->actionFunc = EnBbfall_Down; } -void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx) { +void EnBbfall_Down(EnBbfall* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnBbfall_CheckForWall(this); if (this->actor.bgCheckFlags & 1) { - if (EnBbfall_IsTouchingLava(this, globalCtx)) { + if (EnBbfall_IsTouchingLava(this, play)) { EnBbfall_SetupSinkIntoLava(this); return; } @@ -408,7 +407,7 @@ void EnBbfall_Down(EnBbfall* 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); } @@ -422,7 +421,7 @@ void EnBbfall_Down(EnBbfall* this, GlobalContext* globalCtx) { } } -void EnBbfall_SetupDead(EnBbfall* this, GlobalContext* globalCtx) { +void EnBbfall_SetupDead(EnBbfall* this, PlayState* play) { Vec3f* bodyPartVelocity; Vec3f posDiff; f32 magnitude; @@ -432,8 +431,8 @@ void EnBbfall_SetupDead(EnBbfall* 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 = BBFALL_BODY_PART_DRAW_STATUS_DEAD; @@ -455,7 +454,7 @@ void EnBbfall_SetupDead(EnBbfall* this, GlobalContext* globalCtx) { this->actionFunc = EnBbfall_Dead; } -void EnBbfall_Dead(EnBbfall* this, GlobalContext* globalCtx) { +void EnBbfall_Dead(EnBbfall* this, PlayState* play) { s32 i; this->timer--; @@ -463,16 +462,17 @@ void EnBbfall_Dead(EnBbfall* 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); } - 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; - } + Actor_Kill(&this->actor); + return; + } + + 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; } } @@ -499,10 +499,10 @@ void EnBbfall_SetupDamage(EnBbfall* this) { this->actionFunc = EnBbfall_Damage; } -void EnBbfall_Damage(EnBbfall* this, GlobalContext* globalCtx) { +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, globalCtx)) { + if (EnBbfall_IsTouchingLava(this, play)) { EnBbfall_SetupSinkIntoLava(this); } else { EnBbfall_SetupDown(this); @@ -520,20 +520,20 @@ void EnBbfall_SetupFrozen(EnBbfall* this) { this->actionFunc = EnBbfall_Frozen; } -void EnBbfall_Frozen(EnBbfall* this, GlobalContext* globalCtx) { +void EnBbfall_Frozen(EnBbfall* this, PlayState* play) { DECR(this->timer); if (this->timer == 0) { - EnBbfall_Thaw(this, globalCtx); + EnBbfall_Thaw(this, play); if (this->actor.colChkInfo.health == 0) { - EnBbfall_SetupDead(this, globalCtx); + EnBbfall_SetupDead(this, play); } else { EnBbfall_SetupDown(this); } } } -void EnBbfall_UpdateDamage(EnBbfall* this, GlobalContext* globalCtx) { +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); @@ -545,10 +545,10 @@ void EnBbfall_UpdateDamage(EnBbfall* this, GlobalContext* globalCtx) { this->flameScaleY = 0.0f; this->flameScaleX = 0.0f; EnBbfall_DisableColliders(this); - EnBbfall_Thaw(this, globalCtx); + EnBbfall_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_BBFALL_DMGEFF_ICE_ARROW) { @@ -560,7 +560,7 @@ void EnBbfall_UpdateDamage(EnBbfall* this, GlobalContext* globalCtx) { EnBbfall_SetupFrozen(this); } else if (this->actor.colChkInfo.health == 0) { - EnBbfall_SetupDead(this, globalCtx); + EnBbfall_SetupDead(this, play); } else { EnBbfall_SetupDamage(this); } @@ -569,8 +569,7 @@ void EnBbfall_UpdateDamage(EnBbfall* 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.elements[0].info.bumper.hitPos.x, + 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); } @@ -588,7 +587,7 @@ void EnBbfall_UpdateDamage(EnBbfall* this, GlobalContext* globalCtx) { } } -void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBbfall_Update(Actor* thisx, PlayState* play) { EnBbfall* this = THIS; Sphere16* sphere; Vec3f diff; @@ -596,12 +595,12 @@ void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx) { f32 scale; s32 pad[2]; - EnBbfall_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); + EnBbfall_UpdateDamage(this, play); + this->actionFunc(this, play); if (this->actionFunc != EnBbfall_Dead) { Actor_MoveWithGravity(&this->actor); if (this->isBgCheckCollisionEnabled) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 25.0f, 20.0f, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 20.0f, 7); } for (i = ARRAY_COUNT(this->flamePos) - 1; i >= 2; i--) { @@ -631,15 +630,15 @@ void EnBbfall_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) { @@ -654,8 +653,7 @@ void EnBbfall_Update(Actor* thisx, GlobalContext* globalCtx) { } } -s32 EnBbfall_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +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) { @@ -666,7 +664,7 @@ s32 EnBbfall_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi return false; } -void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnBbfall_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnBbfall* this = THIS; MtxF* currentMatrixState; @@ -692,24 +690,23 @@ void EnBbfall_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } else { if (sLimbIndexToBodyPartsIndex[limbIndex] != -1) { - OPEN_DISPS(globalCtx->state.gfxCtx); + 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(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->limbDList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } -void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnBbfall_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; EnBbfall* this = THIS; MtxF* currentMatrixState; Gfx* gfx; @@ -717,19 +714,18 @@ void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { Vec3f* pos; s32 i; - 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, EnBbfall_OverrideLimbDraw, + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnBbfall_OverrideLimbDraw, EnBbfall_PostLimbDraw, &this->actor); if (this->flameOpacity > 0) { - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateYS( - ((Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) - this->actor.shape.rot.y) + 0x8000), - MTXMODE_APPLY); + 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(); @@ -739,15 +735,14 @@ void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { for (i = 0; i < ARRAY_COUNT(this->flamePos); i++, pos++) { gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, - ((globalCtx->gameplayFrames + (i * 10)) * (-20 + i * 2)) & 0x1FF, 32, 128)); + 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(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); opacity -= 35; if (opacity < 0) { @@ -758,9 +753,9 @@ void EnBbfall_Draw(Actor* thisx, GlobalContext* globalCtx2) { } } - 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_Bbfall/z_en_bbfall.h b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h index 411c4b17f..19c643ea7 100644 --- a/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h +++ b/src/overlays/actors/ovl_En_Bbfall/z_en_bbfall.h @@ -6,7 +6,7 @@ struct EnBbfall; -typedef void (*EnBbfallActionFunc)(struct EnBbfall*, GlobalContext*); +typedef void (*EnBbfallActionFunc)(struct EnBbfall*, PlayState*); typedef struct EnBbfall { /* 0x000 */ Actor actor; @@ -33,6 +33,4 @@ typedef struct EnBbfall { /* 0x3A4 */ ColliderJntSphElement colliderElements[3]; } EnBbfall; // size = 0x464 -extern const ActorInit En_Bbfall_InitVars; - #endif // Z_EN_BBFALL_H diff --git a/src/overlays/actors/ovl_En_Bee/overlay.cfg b/src/overlays/actors/ovl_En_Bee/overlay.cfg deleted file mode 100644 index ef6192fc4..000000000 --- a/src/overlays/actors/ovl_En_Bee/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bee -z_en_bee.c 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..cf8c5f68a 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -10,16 +10,19 @@ #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 EnBee_SetupFlyIdle(EnBee* this); +void EnBee_FlyIdle(EnBee* this, PlayState* play); +void EnBee_SetupAttack(EnBee* this); +void EnBee_Attack(EnBee* this, PlayState* play); -#if 0 -const ActorInit En_Bee_InitVars = { +s32 sNumLoadedBees = 0; + +ActorInit En_Bee_InitVars = { ACTOR_EN_BEE, ACTORCAT_ENEMY, FLAGS, @@ -31,8 +34,7 @@ const ActorInit En_Bee_InitVars = { (ActorFunc)EnBee_Draw, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B5B214 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(1, 0xF), /* Deku Stick */ DMG_ENTRY(1, 0xF), /* Horse trample */ DMG_ENTRY(1, 0xF), @@ -67,34 +69,220 @@ static DamageTable D_80B5B214 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B5B234 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_ON, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x08, 0x02 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_ON, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x08, 0x02 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 6, 13, -4, { 0, 0, 0 } }, }; -#endif +void EnBee_Init(Actor* thisx, PlayState* play) { + EnBee* this = THIS; -extern DamageTable D_80B5B214; -extern ColliderCylinderInit D_80B5B234; + this->actor.colChkInfo.mass = 10; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); + SkelAnime_Init(play, &this->skelAnime, &gBeeSkel, &gBeeFlyingAnim, this->morphTable, this->jointTable, + OBJECT_BEE_LIMB_MAX); + this->actor.colChkInfo.health = 1; + this->actor.colChkInfo.damageTable = &sDamageTable; + this->actor.targetMode = 6; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->instanceId = sNumLoadedBees; + sNumLoadedBees++; + this->actor.shape.shadowScale = 12.0f; -extern UNK_TYPE D_0600005C; + if (ActorCutscene_GetCurrentIndex() != -1) { + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ITEMACTION); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/EnBee_Init.s") + this->actor.hintId = TATL_HINT_ID_GIANT_BEE; + EnBee_SetupFlyIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/EnBee_Destroy.s") +void EnBee_Destroy(Actor* thisx, PlayState* play) { + EnBee* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5A854.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5A9E8.s") +void EnBee_SetupFlyIdle(EnBee* this) { + s32 pad; + Vec3f tempPos; + s16 yawOffset; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5ABC4.s") + Animation_Change(&this->skelAnime, &gBeeFlyingAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBeeFlyingAnim), 0, -10.0f); + Math_Vec3f_Copy(&tempPos, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5AC3C.s") + yawOffset = (this->instanceId * 0x700) + 0x2000; + tempPos.x += Math_SinS(yawOffset) * 50.0f; + tempPos.y = Rand_ZeroFloat(50.0f) + (this->actor.floorHeight + 30.0f); + tempPos.z += Math_CosS(yawOffset) * 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/func_80B5AF80.s") + Math_Vec3f_Copy(&this->targetPos[0], &tempPos); + Math_Vec3f_Copy(&tempPos, &this->actor.home.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/EnBee_Update.s") + tempPos.x += Math_SinS(yawOffset - 0x4000) * 50.0f; + tempPos.y = Rand_ZeroFloat(50.0f) + (this->actor.floorHeight + 30.0f); + tempPos.z += Math_CosS(yawOffset - 0x4000) * 50.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bee/EnBee_Draw.s") + Math_Vec3f_Copy(&this->targetPos[1], &tempPos); + + this->attackDelayTimer = Rand_S16Offset(20, 30); + this->isHostile = false; + this->actionFunc = EnBee_FlyIdle; +} + +void EnBee_FlyIdle(EnBee* this, PlayState* play) { + Vec3f nextPos; + s32 pad[2]; + + if ((this->actor.category != ACTORCAT_ENEMY) && (ActorCutscene_GetCurrentIndex() == -1)) { + func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ENEMY); + } + + Math_Vec3f_Copy(&nextPos, &this->targetPos[this->posIndex]); + nextPos.x += Math_SinS(this->targetYaw) * 30.0f; + nextPos.z += Math_CosS(this->targetYaw) * 30.0f; + + if ((this->instanceId % 2) == 0) { + this->targetYaw += (s16)((s32)randPlusMinusPoint5Scaled(1000.0f) + 4000); + } else { + this->targetYaw -= (s16)((s32)randPlusMinusPoint5Scaled(1000.0f) + 4000); + } + + this->flightHoverOffset += 1000; + this->actor.velocity.y = Math_SinS(this->flightHoverOffset); + + if (this->targetYaw > 0x10000) { + this->targetYaw = 0; + this->posIndex++; + this->posIndex &= 1; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &nextPos), 1, 0x7D0, 0); + Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.3f, 1.0f); + + if ((this->attackDelayTimer == 0) && (this->actor.params != BEE_BEHAVIOR_IDLE)) { + EnBee_SetupAttack(this); + } +} + +void EnBee_SetupAttack(EnBee* this) { + Animation_Change(&this->skelAnime, &gBeeFlyingAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBeeFlyingAnim), 0, -10.0f); + this->isHostile = true; + this->actionFunc = EnBee_Attack; +} + +void EnBee_Attack(EnBee* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f nextPos; + f32 rand; + f32 yawOffset; + s32 i; + + Math_Vec3f_Copy(&nextPos, &player->actor.world.pos); + yawOffset = (this->instanceId * 0x700) + 0x2000; + + for (i = 0; i < 2; i++) { + rand = randPlusMinusPoint5Scaled(20.0f); + nextPos.x += Math_SinS((f32)this->actor.yawTowardsPlayer + this->targetYaw + yawOffset) * (rand + 30.0f); + nextPos.y = (Math_SinS(this->flightHoverOffset) * 10.0f) + (player->actor.floorHeight + 40.0f); + rand = randPlusMinusPoint5Scaled(20.0f); + + nextPos.z += Math_CosS((f32)this->actor.yawTowardsPlayer + this->targetYaw + yawOffset) * (rand + 30.0f); + Math_Vec3f_Copy(&this->targetPos[i], &nextPos); + yawOffset -= 0x4000; + } + + Math_Vec3f_Copy(&nextPos, &this->targetPos[this->posIndex]); + + if ((this->instanceId % 2) == 0) { + this->targetYaw += + (this->instanceId * 0x700) + (s32)randPlusMinusPoint5Scaled((this->instanceId * 0x700) * 0.5f); + } else { + this->targetYaw -= + (this->instanceId * 0x700) + (s32)randPlusMinusPoint5Scaled((this->instanceId * 0x700) * 0.5f); + } + + this->flightHoverOffset += (s32)randPlusMinusPoint5Scaled(500.0f) + 1000; + + if (this->targetYaw > 0x10000) { + this->targetYaw = 0; + this->posIndex++; + this->posIndex &= 1; + } + + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &nextPos), 1, 0x1388, 0); + Math_ApproachF(&this->actor.world.pos.y, nextPos.y, 0.3f, 3.0f); + Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); +} + +void EnBee_UpdateDamage(EnBee* this, PlayState* play) { + if ((this->sfxHitTimer == 0) && (this->collider.base.atFlags & AT_HIT)) { + AudioSfx_StopByPosAndId(&this->actor.projectedPos, NA_SE_EN_BEE_FLY - SFX_FLAG); + this->sfxHitTimer = 5; + } + + if (this->collider.base.acFlags & AC_HIT) { + Enemy_StartFinishingBlow(play, &this->actor); + this->actor.speedXZ = 0.0f; + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 10, NA_SE_EN_CUTBODY); + this->actor.colChkInfo.health = 0; + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EN_EXTINCT); + func_800B3030(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 100, 0, 2); + Actor_Kill(&this->actor); + } +} + +void EnBee_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnBee* this = THIS; + + SkelAnime_Update(&this->skelAnime); + + if (this->actor.category == ACTORCAT_ENEMY) { + if (this->attackDelayTimer != 0) { + this->attackDelayTimer--; + } + if (this->sfxHitTimer != 0) { + this->sfxHitTimer--; + } + } + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BEE_FLY - SFX_FLAG); + EnBee_UpdateDamage(this, play); + Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); + Actor_SetFocus(&this->actor, 0.0f); + Actor_SetScale(&this->actor, 0.01f); + + this->actionFunc(this, play); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 40.0f, 40.0f, 0x1D); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); +} + +void EnBee_Draw(Actor* thisx, PlayState* play) { + EnBee* this = THIS; + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, NULL, &this->actor); +} 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..09d9ef931 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.h +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.h @@ -2,18 +2,33 @@ #define Z_EN_BEE_H #include "global.h" +#include "assets/objects/object_bee/object_bee.h" struct EnBee; -typedef void (*EnBeeActionFunc)(struct EnBee*, GlobalContext*); +typedef void (*EnBeeActionFunc)(struct EnBee*, PlayState*); + +typedef enum { + /* 0 */ BEE_BEHAVIOR_IDLE = 0, + /* 1 */ BEE_BEHAVIOR_ATTACK, +} BeeBehaviorType; typedef struct EnBee { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xBC]; - /* 0x0200 */ EnBeeActionFunc actionFunc; - /* 0x0204 */ char unk_204[0x84]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s morphTable[OBJECT_BEE_LIMB_MAX]; + /* 0x1C4 */ Vec3s jointTable[OBJECT_BEE_LIMB_MAX]; + /* 0x200 */ EnBeeActionFunc actionFunc; + /* 0x204 */ s16 attackDelayTimer; + /* 0x206 */ s16 sfxHitTimer; + /* 0x208 */ s16 isHostile; // set and not used + /* 0x20C */ s32 targetYaw; + /* 0x210 */ s32 flightHoverOffset; + /* 0x214 */ s32 posIndex; + /* 0x218 */ s32 instanceId; + /* 0x21C */ Vec3f targetPos[2]; + /* 0x234 */ UNK_TYPE1 pad234[8]; + /* 0x23C */ ColliderCylinder collider; } EnBee; // size = 0x288 -extern const ActorInit En_Bee_InitVars; - #endif // Z_EN_BEE_H diff --git a/src/overlays/actors/ovl_En_Bh/overlay.cfg b/src/overlays/actors/ovl_En_Bh/overlay.cfg deleted file mode 100644 index 2fea0e1e5..000000000 --- a/src/overlays/actors/ovl_En_Bh/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bh -z_en_bh.c 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..2aff9891d 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.c +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.c @@ -10,13 +10,14 @@ #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); -#if 0 -const ActorInit En_Bh_InitVars = { +void func_80C22DEC(EnBh* this, PlayState* play); + +ActorInit En_Bh_InitVars = { ACTOR_EN_BH, ACTORCAT_ITEMACTION, FLAGS, @@ -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..a3c88fb58 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.h +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.h @@ -2,17 +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; - #endif // Z_EN_BH_H diff --git a/src/overlays/actors/ovl_En_Bigokuta/overlay.cfg b/src/overlays/actors/ovl_En_Bigokuta/overlay.cfg deleted file mode 100644 index 40f093987..000000000 --- a/src/overlays/actors/ovl_En_Bigokuta/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bigokuta -z_en_bigokuta.c 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 e25d1e02a..b995d77ea 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.c @@ -5,33 +5,32 @@ */ #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 = { +ActorInit En_Bigokuta_InitVars = { ACTOR_EN_BIGOKUTA, ACTORCAT_BOSS, FLAGS, @@ -89,159 +88,161 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 2500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 89, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BIG_OCTO, ICHAIN_CONTINUE), 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02) || + ((this->picto.actor.params != 0xFF) && Flags_GetSwitch(play, this->picto.actor.params))) { + Actor_Kill(&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,27 +361,27 @@ 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); + if (!CHECK_EVENTINF(EVENTINF_41) && !CHECK_EVENTINF(EVENTINF_35)) { + func_800B724C(play, &this->picto.actor, PLAYER_CSMODE_7); } else { - player = GET_PLAYER(globalCtx); - player->stateFlags1 |= 0x20; + player = GET_PLAYER(play); + player->stateFlags1 |= PLAYER_STATE1_20; } if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { @@ -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, - &D_80AC45B8, Rand_S16Offset(150, 50), 25, 0); + EffectSsDtBubble_SpawnCustomColor(play, &bubblePos, &bubbleVel, &D_80AC45A4, &D_80AC45B0, + &D_80AC45B8, Rand_S16Offset(150, 50), 25, false); } - 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_Kill(&this->picto.actor); - if (!(gSaveContext.eventInf[4] & 2) && !(gSaveContext.eventInf[3] & 0x20)) { - func_800B724C(globalCtx, &this->actor, 6); + if (!CHECK_EVENTINF(EVENTINF_41) && !CHECK_EVENTINF(EVENTINF_35)) { + func_800B724C(play, &this->picto.actor, PLAYER_CSMODE_6); } else { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_20; } } 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->sceneId == SCENE_20SICHITAI || play->sceneId == 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_Kill(&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, }; @@ -647,32 +650,32 @@ void EnBigokuta_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } } -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..6bcfa79fb 100644 --- a/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h +++ b/src/overlays/actors/ovl_En_Bigokuta/z_en_bigokuta.h @@ -2,59 +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; - #endif // Z_EN_BIGOKUTA_H diff --git a/src/overlays/actors/ovl_En_Bigpamet/overlay.cfg b/src/overlays/actors/ovl_En_Bigpamet/overlay.cfg deleted file mode 100644 index df083a170..000000000 --- a/src/overlays/actors/ovl_En_Bigpamet/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bigpamet -z_en_bigpamet.c 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..2c27a1801 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.c @@ -5,33 +5,48 @@ */ #include "z_en_bigpamet.h" +#include "z64quake.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 = { +ActorInit En_Bigpamet_InitVars = { ACTOR_EN_BIGPAMET, ACTORCAT_BOSS, FLAGS, @@ -43,18 +58,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 +115,764 @@ 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 quakeIndex; + + 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) { + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + this->actor.velocity.y = this->unk_29E * 0.375f; + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 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_Kill(&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..bb9d29280 100644 --- a/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h +++ b/src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h @@ -2,20 +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; - #endif // Z_EN_BIGPAMET_H diff --git a/src/overlays/actors/ovl_En_Bigpo/overlay.cfg b/src/overlays/actors/ovl_En_Bigpo/overlay.cfg deleted file mode 100644 index 1519b5573..000000000 --- a/src/overlays/actors/ovl_En_Bigpo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bigpo -z_en_bigpo.c 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 acf465f83..5398418f2 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* play2); +void EnBigpo_Destroy(Actor* thisx, PlayState* play2); +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,66 +25,64 @@ 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; - -const ActorInit En_Bigpo_InitVars = { +ActorInit En_Bigpo_InitVars = { ACTOR_EN_BIGPO, ACTORCAT_ENEMY, FLAGS, @@ -154,7 +152,7 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 90, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BIG_POE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), }; @@ -173,35 +171,35 @@ 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)) { - Actor_MarkForDeath(&this->actor); - } else { - thisx->update = Actor_Noop; - EnBigpo_InitHiddenFire(this); + if (Flags_GetSwitch(play, this->switchFlags)) { + Actor_Kill(&this->actor); + return; } + + thisx->update = Actor_Noop; + EnBigpo_InitHiddenFire(this); 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,21 +213,21 @@ 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))) { - Actor_MarkForDeath(&this->actor); + if ((this->switchFlags != 0xFF) && (Flags_GetSwitch(play, this->switchFlags))) { + Actor_Kill(&this->actor); } if (thisx->params == ENBIGPO_REGULAR) { // the well poe, starts immediately - thisx->flags &= ~0x10; // always update OFF - this->unkBool204 = true; + thisx->flags &= ~ACTOR_FLAG_10; // always update OFF + this->storePrevBgm = true; EnBigpo_InitWellBigpo(this); } else if (thisx->params == ENBIGPO_SUMMONED) { // dampe type EnBigpo_InitDampeMainPo(this); } } -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 +236,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 +266,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 +286,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 +297,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, PLAYER_CSMODE_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 +315,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 +330,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 +344,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 +365,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 +381,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 +403,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 +424,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); @@ -440,9 +438,9 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { */ void EnBigpo_SpawnCutsceneStage7(EnBigpo* this) { this->idleTimer = 15; - if (this->unkBool204 == false) { - func_801A2E54(NA_BGM_MINI_BOSS); - this->unkBool204 = true; + if (this->storePrevBgm == false) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + this->storePrevBgm = true; } this->actionFunc = EnBigpo_SpawnCutsceneStage8; } @@ -452,18 +450,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 +471,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, PLAYER_CSMODE_6); EnBigpo_SetupIdleFlying(this); // setup idle flying } } @@ -489,7 +487,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 +496,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 +513,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) { @@ -526,9 +524,9 @@ void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx) { this->mainColor.a = this->idleTimer * (255.0f / 32.0f); if (this->idleTimer == 32) { this->mainColor.a = 255; // fully visible - if (this->unkBool204 == false) { - func_801A2E54(NA_BGM_MINI_BOSS); - this->unkBool204 = true; + if (this->storePrevBgm == false) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + this->storePrevBgm = true; } EnBigpo_SetupIdleFlying(this); } @@ -548,8 +546,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 +563,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 +583,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 +598,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 +623,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 +655,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) { @@ -672,7 +670,7 @@ void EnBigpo_SetupDeath(EnBigpo* this) { this->idleTimer = 0; this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; this->collider.base.ocFlags1 &= ~OC1_ON; this->actionFunc = EnBigpo_BurnAwayDeath; } @@ -680,7 +678,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 +687,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 +704,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,7 +729,7 @@ 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.xw; @@ -744,19 +742,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); } @@ -801,7 +799,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 @@ -817,16 +815,19 @@ 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)) { - Actor_MarkForDeath(&this->actor); - } else if (this->idleTimer == 0) { + if (Actor_HasParent(&this->actor, play)) { + Actor_Kill(&this->actor); + return; + } + + 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; } } @@ -836,10 +837,10 @@ 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); + Actor_Kill(&this->actor); } } @@ -851,7 +852,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; @@ -859,7 +860,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++; } @@ -869,7 +870,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; @@ -877,7 +878,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) { @@ -888,7 +889,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 @@ -910,7 +911,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; @@ -929,7 +930,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; @@ -944,7 +945,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; @@ -953,18 +954,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) { @@ -976,14 +976,14 @@ 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) { - Actor_MarkForDeath(&this->actor); +void EnBigpo_Die(EnBigpo* this, PlayState* play) { + Actor_Kill(&this->actor); } void EnBigpo_SetupFireRevealed(EnBigpo* this) { @@ -992,7 +992,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) { @@ -1008,7 +1008,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 @@ -1038,16 +1038,16 @@ 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); + Actor_Kill(&this->actor); if (this->unk20C == 0) { parentPoh->actor.draw = EnBigpo_DrawCircleFlames; Actor_SetScale(&parentPoh->actor, 0.01f); @@ -1113,7 +1113,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; @@ -1124,9 +1124,9 @@ 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(); + Audio_RestorePrevBgm(); } } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_PO_DAMAGE); @@ -1136,7 +1136,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); } @@ -1146,7 +1146,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; @@ -1156,7 +1156,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++; @@ -1169,12 +1169,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) { @@ -1190,13 +1190,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) { @@ -1214,14 +1214,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 @@ -1232,7 +1232,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 @@ -1240,10 +1240,10 @@ 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); } @@ -1279,14 +1279,14 @@ void EnBigpo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } } - 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 @@ -1294,9 +1294,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 { @@ -1304,37 +1304,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_Put(&this->drawMtxF); - EnBigpo_DrawLantern(&this->actor, globalCtx); + 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); @@ -1344,23 +1344,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_RotateYS(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); @@ -1371,20 +1371,20 @@ 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_MultVecY(1400.0f, &vec2); Lights_PointGlowSetInfo(&this->fires[0].info, vec2.x + vec1.x, vec2.y + vec1.y, vec2.z + vec1.z, @@ -1392,7 +1392,7 @@ void EnBigpo_DrawLantern(Actor* thisx, GlobalContext* globalCtx) { 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); @@ -1405,10 +1405,10 @@ 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; @@ -1416,10 +1416,10 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { s32 i; mtfxPtr = Matrix_GetCurrent(); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_RotateYS(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; @@ -1428,8 +1428,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); @@ -1443,26 +1443,26 @@ void EnBigpo_DrawCircleFlames(Actor* thisx, GlobalContext* globalCtx) { 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); @@ -1470,9 +1470,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..9b84784f4 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; @@ -30,12 +30,12 @@ typedef struct EnBigpo { /* 0x188 */ Vec3s jointTable[ENBIGPO_LIMBCOUNT]; /* 0x1C4 */ Vec3s morphTable[ENBIGPO_LIMBCOUNT]; /* 0x200 */ EnBigPoActionFunc actionFunc; - /* 0x204 */ u8 unkBool204; // need to know what func_801A2E54 does to know what this is + /* 0x204 */ u8 storePrevBgm; /* 0x206 */ s16 idleTimer; // frame counter /* 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/overlay.cfg b/src/overlays/actors/ovl_En_Bigslime/overlay.cfg deleted file mode 100644 index c7441440e..000000000 --- a/src/overlays/actors/ovl_En_Bigslime/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bigslime -z_en_bigslime.c 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 1a507b5b6..9cf4b425b 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,8 @@ */ #include "z_en_bigslime.h" +#include "z64quake.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 +15,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* play2); +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 +154,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 }, @@ -209,7 +211,7 @@ static EnBigslimeTri sEnbigslimeTri[BIGSLIME_NUM_FACES] = { { 142, 126, 127 }, { 130, 111, 145 }, }; -const ActorInit En_Bigslime_InitVars = { +ActorInit En_Bigslime_InitVars = { ACTOR_EN_BIGSLIME, ACTORCAT_BOSS, FLAGS, @@ -302,94 +304,91 @@ static AnimationHeader* sGekkoAttackAnimations[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 95, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GEKKO_GIANT_SLIME, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(targetArrowOffset, -13221, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 5, ICHAIN_STOP), }; -void EnBigslime_Init(Actor* thisx, GlobalContext* globalCtx2) { - // gSaveContext.save.weekEventReg[KEY] = VALUE - // KEY | VALUE +void EnBigslime_Init(Actor* thisx, PlayState* play2) { static s32 isFrogReturnedFlags[] = { - (32 << 8) | 0x40, // Woodfall Temple Frog Returned - (32 << 8) | 0x80, // Great Bay Temple Frog Returned - (33 << 8) | 0x01, // Southern Swamp Frog Returned - (33 << 8) | 0x02, // Laundry Pool Frog Returned + WEEKEVENTREG_32_40, + WEEKEVENTREG_32_80, + WEEKEVENTREG_33_01, + WEEKEVENTREG_33_02, }; - 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)) { - 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); + if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { + Actor_Kill(&this->actor); + if (!CHECK_WEEKEVENTREG(isFrogReturnedFlags[this->actor.params - 1])) { + 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; - this->actor.scale.x = this->actor.scale.z = 0.15f; - this->actor.scale.y = 0.075f; - this->vtxScaleX = this->vtxScaleZ = 0.015000001f; - this->actor.home.pos.x = GBT_ROOM_5_CENTER_X; - this->actor.home.pos.y = GBT_ROOM_5_MAX_Y - 75.0f; - this->actor.home.pos.z = GBT_ROOM_5_CENTER_Z; - for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { - this->minislime[i] = (EnMinislime*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, - ACTOR_EN_MINISLIME, 0.0f, 0.0f, 0.0f, 0, 0, 0, i); - if (this->minislime[i] == NULL) { - for (i = i - 1; i >= 0; i--) { - Actor_MarkForDeath(&this->minislime[i]->actor); - } - - Actor_MarkForDeath(&this->actor); - return; - } - } - - this->minislimeFrozenTexAnim = Lib_SegmentedToVirtual(&gMinislimeFrozenTexAnim); - this->bigslimeFrozenTexAnim = Lib_SegmentedToVirtual(&gBigslimeFrozenTexAnim); - this->iceShardTexAnim = Lib_SegmentedToVirtual(&gBigslimeIceShardTexAnim); - this->actor.world.pos.y = GBT_ROOM_5_MIN_Y; - this->actor.flags &= ~ACTOR_FLAG_1; - this->actor.shape.shadowAlpha = 255; - this->gekkoScale = 0.007f; - this->actor.shape.rot.y = 0; - this->minislimeToThrow = this->minislime[0]; - EnBigslime_SetupInitEntrance(this); + return; } + + this->cutscene = this->actor.cutscene; + this->actor.scale.x = this->actor.scale.z = 0.15f; + this->actor.scale.y = 0.075f; + this->vtxScaleX = this->vtxScaleZ = 0.015000001f; + this->actor.home.pos.x = GBT_ROOM_5_CENTER_X; + this->actor.home.pos.y = GBT_ROOM_5_MAX_Y - 75.0f; + this->actor.home.pos.z = GBT_ROOM_5_CENTER_Z; + for (i = 0; i < MINISLIME_NUM_SPAWN; i++) { + this->minislime[i] = (EnMinislime*)Actor_SpawnAsChild(&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--) { + Actor_Kill(&this->minislime[i]->actor); + } + + Actor_Kill(&this->actor); + return; + } + } + + this->minislimeFrozenTexAnim = Lib_SegmentedToVirtual(gMinislimeFrozenTexAnim); + this->bigslimeFrozenTexAnim = Lib_SegmentedToVirtual(gBigslimeFrozenTexAnim); + this->iceShardTexAnim = Lib_SegmentedToVirtual(gBigslimeIceShardTexAnim); + this->actor.world.pos.y = GBT_ROOM_5_MIN_Y; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.shape.shadowAlpha = 255; + this->gekkoScale = 0.007f; + this->actor.shape.rot.y = 0; + this->minislimeToThrow = this->minislime[0]; + EnBigslime_SetupInitEntrance(this); } -void EnBigslime_Destroy(Actor* thisx, GlobalContext* globalCtx) { +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 +435,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 +449,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 +582,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 +628,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 +723,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) { + if (player->stateFlags2 & PLAYER_STATE2_80) { 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 +740,16 @@ 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 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 15, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 15); + + Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 15, 0, 0, 0); - Quake_SetCountdown(quake, 15); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); this->bigslimeCollider[0].base.atFlags &= ~AT_ON; this->gekkoCollider.base.acFlags &= ~(AC_ON | AC_HIT); @@ -760,17 +761,17 @@ 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; - this->actor.hintId = 95; + this->actor.hintId = TATL_HINT_ID_GEKKO_GIANT_SLIME; this->gekkoRot.x = 0; 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 +780,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 +796,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 +804,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 +819,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 +829,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, PLAYER_CSMODE_6); } } @@ -862,8 +862,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 +916,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, PLAYER_CSMODE_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 +967,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, PLAYER_CSMODE_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 +998,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); - func_801A2E54(0x38); + EnBigslime_UpdateCameraIntroCs(this, play, 25); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); 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, PLAYER_CSMODE_4); } } @@ -1019,7 +1019,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 +1034,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 +1043,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 +1064,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 +1232,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 +1262,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 +1431,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 +1492,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 +1519,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 +1529,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 +1572,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 +1595,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,8 +1623,8 @@ void EnBigslime_AttackPlayerInBigslime(EnBigslime* this, GlobalContext* globalCt return; } - globalCtx->damagePlayer(globalCtx, -4); - func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + play->damagePlayer(play, -4); + func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); this->gekkoRot.y += (s16)(Rand_S16Offset(0x4000, 0x4000) * (Rand_ZeroOne() < 0.5f ? -1 : 1)); this->gekkoPosOffset.x = Math_SinS(this->gekkoRot.y) * -50.0f; this->gekkoPosOffset.z = Math_CosS(this->gekkoRot.y) * -50.0f; @@ -1679,8 +1679,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 +1689,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; @@ -1707,14 +1707,14 @@ void EnBigslime_WindupThrowPlayer(EnBigslime* this, GlobalContext* globalCtx) { scale = 0.5f - cos_rad(-this->windupPunchTimer * (M_PI / 5)) * 0.5f; if (this->windupPunchTimer == -5) { - if (player->stateFlags2 & 0x80) { + if (player->stateFlags2 & PLAYER_STATE2_80) { player->actor.parent = NULL; player->unk_AE8 = 100; } player->actor.velocity.y = 0.0f; - func_800B8D50(globalCtx, &this->actor, 10.0f, this->actor.world.rot.y, 10.0f, 4); - EnBigslime_SetupSetDynamicVtxThrowPlayer(this, globalCtx); + 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 +1765,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 +1861,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 +1900,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 +1921,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 +1963,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 +1977,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 +1988,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 +2006,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 +2016,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 +2033,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 +2089,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 +2111,9 @@ void EnBigslime_IdleLookAround(EnBigslime* this, GlobalContext* globalCtx) { if ((this->skelAnime.animation == &gGekkoNervousIdleAnim) && Math_ScaledStepToS(&this->gekkoRot.y, this->gekkoYaw, 0x400)) { if (BINANG_SUB(Actor_YawToPoint(&this->actor, &this->actor.home.pos), this->gekkoRot.y) > 0) { - this->gekkoYaw = this->gekkoRot.y + ((u32)Rand_Next() >> 20) + 0x2000; + this->gekkoYaw = this->gekkoRot.y + (Rand_Next() >> 20) + 0x2000; } else { - this->gekkoYaw = this->gekkoRot.y - ((u32)Rand_Next() >> 20) - 0x2000; + this->gekkoYaw = this->gekkoRot.y - (Rand_Next() >> 20) - 0x2000; } } @@ -2130,7 +2130,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 +2148,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 +2186,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 +2208,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 +2230,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 +2267,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)) { @@ -2309,19 +2309,19 @@ void EnBigslime_FormBigslime(EnBigslime* this, GlobalContext* globalCtx) { if (this->minislimeCounter == MINISLIME_NUM_SPAWN) { this->minislimeState = MINISLIME_INACTIVE_STATE; - this->actor.hintId = 3; + this->actor.hintId = TATL_HINT_ID_MAD_JELLY; EnBigslime_SetupMoveOnCeiling(this); } } -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 +2344,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 +2364,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 +2396,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 +2404,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 +2437,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 +2455,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 +2467,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 +2487,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 +2498,7 @@ void EnBigslime_Despawn(EnBigslime* this, GlobalContext* globalCtx) { } if (!this->isDespawned) { - Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num); + Flags_SetClearTemp(play, play->roomCtx.curRoom.num); this->isDespawned = true; } @@ -2507,7 +2507,7 @@ void EnBigslime_Despawn(EnBigslime* this, GlobalContext* globalCtx) { this->minislime[i]->actor.params = MINISLIME_DESPAWN; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -2515,8 +2515,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 +2536,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, PLAYER_CSMODE_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 +2571,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 +2582,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 +2597,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 +2612,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) || @@ -2621,10 +2621,10 @@ void EnBigslime_ApplyDamageEffectGekko(EnBigslime* this, GlobalContext* globalCt if (this->actor.colChkInfo.damageEffect != BIGSLIME_DMGEFF_HOOKSHOT) { if (Actor_ApplyDamage(&this->actor) == 0) { func_800BE504(&this->actor, &this->gekkoCollider); - func_801A2ED8(); - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Audio_RestorePrevBgm(); + 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 +2633,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 +2659,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 +2668,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 +2684,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 +2700,10 @@ void EnBigslime_AddIceShardEffect(EnBigslime* this, GlobalContext* globalCtx) { iceShardEffect->pos.x = (targetVtx->n.ob[0] * this->actor.scale.x) + this->actor.world.pos.x; iceShardEffect->pos.y = (targetVtx->n.ob[1] * this->actor.scale.y) + this->actor.world.pos.y; iceShardEffect->pos.z = (targetVtx->n.ob[2] * this->actor.scale.z) + this->actor.world.pos.z; - iceShardEffect->rotation.x = Rand_Next() >> 0x10; - iceShardEffect->rotation.y = Rand_Next() >> 0x10; - iceShardEffect->rotation.z = Rand_Next() >> 0x10; - iceShardEffect->isActive = true; + iceShardEffect->rot.x = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.y = (s32)Rand_Next() >> 0x10; + iceShardEffect->rot.z = (s32)Rand_Next() >> 0x10; + iceShardEffect->isEnabled = true; randPitch = Rand_S16Offset(0x1000, 0x3000); vtxZ = targetVtx->n.ob[2]; vtxX = targetVtx->n.ob[0]; @@ -2715,15 +2715,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 +2736,15 @@ void EnBigslime_UpdateEffects(EnBigslime* this) { // Update ice shards for (i = 0; i < BIGSLIME_NUM_ICE_SHARD; i++) { iceShardEffect = &this->iceShardEffect[i]; - if (iceShardEffect->isActive > false) { - iceShardEffect->vel.y += -1.0f; - Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->vel, &iceShardEffect->pos); + if (iceShardEffect->isEnabled > false) { + iceShardEffect->velocity.y += -1.0f; + Math_Vec3f_Sum(&iceShardEffect->pos, &iceShardEffect->velocity, &iceShardEffect->pos); if (iceShardEffect->pos.y < (GBT_ROOM_5_MIN_Y - 20.0f)) { - iceShardEffect->isActive = false; + iceShardEffect->isEnabled = false; } - iceShardEffect->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - iceShardEffect->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - iceShardEffect->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + iceShardEffect->rot.x += (s16)((Rand_Next() >> 0x17) + 0x700); + iceShardEffect->rot.y += (s16)((Rand_Next() >> 0x17) + 0x900); + iceShardEffect->rot.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } @@ -2767,14 +2767,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 +2782,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 +2802,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 +2812,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 +2854,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,7 +2870,7 @@ 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 zx; @@ -2880,7 +2880,7 @@ void EnBigslime_SetSysMatrix(Vec3f* pos, GlobalContext* globalCtx, Gfx* shadowDL yDistMinY = CLAMP((yDistMinY), 0.0f, (GBT_ROOM_5_CENTER_Y - GBT_ROOM_5_MIN_Y) / 2); 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 = zx; sysMatrix->yy = 1.0f; @@ -2902,14 +2902,14 @@ void EnBigslime_SetSysMatrix(Vec3f* pos, GlobalContext* globalCtx, Gfx* shadowDL } gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(alpha * zx)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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 +2932,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); + 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_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,28 +2977,28 @@ 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); - gSPDisplayList(POLY_XLU_DISP++, &gBigslimeNormalDL); - gSPDisplayList(POLY_XLU_DISP++, &gBigslimeVtxDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBigslimeNormalMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, gBigslimeModelDL); // 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); + gSPDisplayList(POLY_XLU_DISP++, gBigslimeFrozenMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, gBigslimeModelDL); } // Draw bubbles inside Bigslime if (this->actor.scale.x > 0.0f) { - Matrix_Put(&globalCtx->billboardMtxF); + Matrix_Put(&play->billboardMtxF); Matrix_Scale(0.0050000003f, 0.0050000003f, 0.0050000003f, MTXMODE_APPLY); billboardMtxF = Matrix_GetCurrent(); @@ -3012,19 +3011,18 @@ void EnBigslime_DrawBigslime(Actor* thisx, GlobalContext* globalCtx) { dynamicVtx->n.ob[1] * this->actor.scale.y * bubblesInfoPtr->scaleVtx + this->actor.world.pos.y; 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); - gSPDisplayList(POLY_XLU_DISP++, &gBigslimeBubbleDL); + 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 @@ -3056,102 +3054,100 @@ void EnBigslime_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_MultZero(&this->limbPos[limbPosIndex[limbIndex]]); } - if (limbIndex == GEKKO_LIMB_R_ANKLE) { + 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_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)); + 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); - gSPDisplayList(POLY_XLU_DISP++, &gBigslimeShockwaveDL); + 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); - gSPDisplayList(POLY_XLU_DISP++, &gBigslimeIceShardDL); + 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) { + if (iceShardEffect->isEnabled > false) { Matrix_SetTranslateRotateYXZ(iceShardEffect->pos.x, iceShardEffect->pos.y, iceShardEffect->pos.z, - &iceShardEffect->rotation); + &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); - gSPDisplayList(POLY_XLU_DISP++, &gBigslimeIceShardVtxDL); + 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 579ec5d50..52a29013c 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 @@ -125,6 +125,4 @@ typedef struct EnBigslime { /* 0x0A54 */ EnBigslimeIceShardEffect iceShardEffect[BIGSLIME_NUM_ICE_SHARD]; // 312 = 162 (bigslime) + 10 * 15 (minislime) } EnBigslime; // size = 0x3634 -extern const ActorInit En_Bigslime_InitVars; - #endif // Z_EN_BIGSLIME_H diff --git a/src/overlays/actors/ovl_En_Bji_01/overlay.cfg b/src/overlays/actors/ovl_En_Bji_01/overlay.cfg deleted file mode 100644 index 6455065bd..000000000 --- a/src/overlays/actors/ovl_En_Bji_01/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bji_01 -z_en_bji_01.c 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 c60971034..ed7b8c194 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,33 +5,31 @@ */ #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 = { +ActorInit En_Bji_01_InitVars = { ACTOR_EN_BJI_01, ACTORCAT_NPC, FLAGS, @@ -64,107 +62,107 @@ 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); +void func_809CCDE0(EnBji01* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f pitchTarget; s32 pad[2]; Math_Vec3f_Copy(&pitchTarget, &player->actor.world.pos); - pitchTarget.y = player->bodyPartsPos[7].y + 3.0f; - SubS_TurnToPointStep(&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); + pitchTarget.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].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_IA_NONE); } } -void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { - f32 timeBeforeMoonCrash; +void func_809CD028(EnBji01* this, PlayState* play) { + f32 timeUntilMoonCrash; 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) { - if (gSaveContext.save.weekEventReg[74] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_17_10)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_74_80)) { this->textId = 0x5F4; } else { this->textId = 0x5E2; } } else { this->textId = 0x5EC; - gSaveContext.save.weekEventReg[17] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_17_10); } 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) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_74_10)) { this->textId = 0x5F6; } else { this->textId = 0x5F5; - gSaveContext.save.weekEventReg[74] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_74_10); } break; case PLAYER_FORM_GORON: case PLAYER_FORM_ZORA: - if (gSaveContext.save.weekEventReg[75] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_08)) { this->textId = 0x5E4; } else { this->textId = 0x5DC; - gSaveContext.save.weekEventReg[75] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_75_08); } 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_74_80)) { this->textId = 0x5F2; } 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_IA_NONE); break; case PLAYER_FORM_HUMAN: this->textId = 0x5F7; @@ -179,11 +177,8 @@ void func_809CD028(EnBji01* this, GlobalContext* globalCtx) { this->textId = 0x5EA; break; case 3: - // 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)) { + timeUntilMoonCrash = TIME_UNTIL_MOON_CRASH; + if (timeUntilMoonCrash < CLOCK_TIME_F(1, 0)) { this->textId = 0x5E8; } else { this->textId = 0x5EB; @@ -193,63 +188,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)) { + 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)) { + 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 +254,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,107 +270,108 @@ 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); + Actor_Kill(&this->actor); break; } } -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,27 +385,26 @@ 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: + case SHIKASHI_LIMB_TORSO: rot->x += this->torsoXRotStep; rot->z += this->torsoZRotStep; break; - case BJI_LIMB_HEAD: + case SHIKASHI_LIMB_HEAD: rot->x += this->headXRotStep; rot->z += this->headZRotStep; break; @@ -417,13 +412,13 @@ s32 EnBji01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis 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; @@ -432,14 +427,14 @@ void EnBji01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } -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 c49da8bd2..29afaf533 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,45 +3,26 @@ #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; @@ -54,6 +35,4 @@ typedef struct EnBji01 { /* 0x2B0 */ ObjMoonStone* moonsTear; } EnBji01; // size = 0x2B4 -extern const ActorInit En_Bji_01_InitVars; - #endif // Z_EN_BJI_01_H diff --git a/src/overlays/actors/ovl_En_Bjt/overlay.cfg b/src/overlays/actors/ovl_En_Bjt/overlay.cfg deleted file mode 100644 index ab6f05a54..000000000 --- a/src/overlays/actors/ovl_En_Bjt/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bjt -z_en_bjt.c 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..08070b61d 100644 --- a/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c +++ b/src/overlays/actors/ovl_En_Bjt/z_en_bjt.c @@ -10,16 +10,43 @@ #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); -#if 0 -const ActorInit En_Bjt_InitVars = { +#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, +}; + +ActorInit En_Bjt_InitVars = { ACTOR_EN_BJT, ACTORCAT_NPC, FLAGS, @@ -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_IA_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_IA_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_IA_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_IA_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_IA_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_IA_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; + PlayerItemAction itemAction; + 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: + itemAction = func_80123810(play); + + if ((itemAction == PLAYER_IA_DEED_LAND) || (itemAction == PLAYER_IA_LETTER_TO_KAFEI) || + (itemAction == PLAYER_IA_DEED_SWAMP) || (itemAction == PLAYER_IA_DEED_MOUNTAIN) || + (itemAction == PLAYER_IA_DEED_OCEAN) || (itemAction == PLAYER_IA_LETTER_MAMA)) { + EnBjt_ChangeAnim(this, TOILET_HAND_ANIM_WAITING_MORPH); + this->playedSfx = false; + this->behaviour++; + scriptBranch = 1; // Right item + } else if (itemAction <= PLAYER_IA_MINUS1) { + this->playedSfx = false; + this->behaviour++; + scriptBranch = 3; // Not showing item + } else if (itemAction != PLAYER_IA_NONE) { + this->playedSfx = false; + this->behaviour++; + scriptBranch = 2; // Wrong item + } + break; + + default: + break; + } + break; + + case TOILET_HAND_BEHAVIOUR_TAKE_ITEM: + if (player->exchangeItemId != PLAYER_IA_NONE) { + EnBjt_TakeItem(player->exchangeItemId); + player->exchangeItemId = PLAYER_IA_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; + + if (func_8010BF58(&this->actor, play, 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) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_90_80)) { + 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) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_90_80)) { + 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_IA_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..9ce5adf0e 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,34 @@ #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/overlay.cfg b/src/overlays/actors/ovl_En_Boj_01/overlay.cfg deleted file mode 100644 index 01b4cce6e..000000000 --- a/src/overlays/actors/ovl_En_Boj_01/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Boj_01 -z_en_boj_01.c 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..bd4b0e499 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,12 +10,12 @@ #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 = { +ActorInit En_Boj_01_InitVars = { ACTOR_EN_BOJ_01, ACTORCAT_NPC, FLAGS, @@ -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_01/z_en_boj_01.h b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.h index cfee748df..78f4968c2 100644 --- a/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.h +++ b/src/overlays/actors/ovl_En_Boj_01/z_en_boj_01.h @@ -10,6 +10,4 @@ typedef struct EnBoj01 { /* 0x144 */ char unk_144[0x1D0]; } EnBoj01; // size = 0x314 -extern const ActorInit En_Boj_01_InitVars; - #endif // Z_EN_BOJ_01_H diff --git a/src/overlays/actors/ovl_En_Boj_02/overlay.cfg b/src/overlays/actors/ovl_En_Boj_02/overlay.cfg deleted file mode 100644 index 7deb95ef2..000000000 --- a/src/overlays/actors/ovl_En_Boj_02/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Boj_02 -z_en_boj_02.c 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..89f6ba0cb 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,12 +10,12 @@ #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 = { +ActorInit En_Boj_02_InitVars = { ACTOR_EN_BOJ_02, ACTORCAT_NPC, FLAGS, @@ -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_02/z_en_boj_02.h b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.h index 1ef9785ef..c27d05d38 100644 --- a/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.h +++ b/src/overlays/actors/ovl_En_Boj_02/z_en_boj_02.h @@ -10,6 +10,4 @@ typedef struct EnBoj02 { /* 0x144 */ char unk_144[0x4D8]; } EnBoj02; // size = 0x61C -extern const ActorInit En_Boj_02_InitVars; - #endif // Z_EN_BOJ_02_H diff --git a/src/overlays/actors/ovl_En_Boj_03/overlay.cfg b/src/overlays/actors/ovl_En_Boj_03/overlay.cfg deleted file mode 100644 index 90f393836..000000000 --- a/src/overlays/actors/ovl_En_Boj_03/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Boj_03 -z_en_boj_03.c 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..0c55b79a6 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,12 +10,12 @@ #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 = { +ActorInit En_Boj_03_InitVars = { ACTOR_EN_BOJ_03, ACTORCAT_NPC, FLAGS, @@ -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_03/z_en_boj_03.h b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.h index eac4fc691..12776093d 100644 --- a/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.h +++ b/src/overlays/actors/ovl_En_Boj_03/z_en_boj_03.h @@ -10,6 +10,4 @@ typedef struct EnBoj03 { /* 0x144 */ char unk_144[0x4D8]; } EnBoj03; // size = 0x61C -extern const ActorInit En_Boj_03_InitVars; - #endif // Z_EN_BOJ_03_H diff --git a/src/overlays/actors/ovl_En_Boj_04/overlay.cfg b/src/overlays/actors/ovl_En_Boj_04/overlay.cfg deleted file mode 100644 index fd93a1079..000000000 --- a/src/overlays/actors/ovl_En_Boj_04/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Boj_04 -z_en_boj_04.c 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..7fe308520 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,12 +10,12 @@ #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 = { +ActorInit En_Boj_04_InitVars = { ACTOR_EN_BOJ_04, ACTORCAT_NPC, FLAGS, @@ -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_04/z_en_boj_04.h b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.h index 9681073e8..4b05014fb 100644 --- a/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.h +++ b/src/overlays/actors/ovl_En_Boj_04/z_en_boj_04.h @@ -10,6 +10,4 @@ typedef struct EnBoj04 { /* 0x144 */ char unk_144[0x4D8]; } EnBoj04; // size = 0x61C -extern const ActorInit En_Boj_04_InitVars; - #endif // Z_EN_BOJ_04_H diff --git a/src/overlays/actors/ovl_En_Boj_05/overlay.cfg b/src/overlays/actors/ovl_En_Boj_05/overlay.cfg deleted file mode 100644 index 038e0e91c..000000000 --- a/src/overlays/actors/ovl_En_Boj_05/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Boj_05 -z_en_boj_05.c 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..da6816840 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,12 +10,12 @@ #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 = { +ActorInit En_Boj_05_InitVars = { ACTOR_EN_BOJ_05, ACTORCAT_NPC, FLAGS, @@ -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_Boj_05/z_en_boj_05.h b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.h index bed1ad78e..b2e5e7c7e 100644 --- a/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.h +++ b/src/overlays/actors/ovl_En_Boj_05/z_en_boj_05.h @@ -10,6 +10,4 @@ typedef struct EnBoj05 { /* 0x144 */ char unk_144[0x4D8]; } EnBoj05; // size = 0x61C -extern const ActorInit En_Boj_05_InitVars; - #endif // Z_EN_BOJ_05_H diff --git a/src/overlays/actors/ovl_En_Bom/overlay.cfg b/src/overlays/actors/ovl_En_Bom/overlay.cfg deleted file mode 100644 index c75252039..000000000 --- a/src/overlays/actors/ovl_En_Bom/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bom -z_en_bom.c 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 48550b656..a25a33904 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -5,33 +5,34 @@ */ #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 = { +ActorInit En_Bom_InitVars = { ACTOR_EN_BOM, ACTORCAT_EXPLOSIVES, FLAGS, @@ -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.flags |= ACTORCTX_FLAG_0; 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.flags &= ~ACTORCTX_FLAG_0; } } -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,9 +227,9 @@ 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); - Vec3f sp48; - s16 sp46; + u32 sp54 = func_800C99D4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + Vec3f slopeNormal; + s16 downwardSlopeYaw; f32 sp40; f32 sp3C; f32 sp38; @@ -252,20 +253,20 @@ void func_80871058(EnBom* this, GlobalContext* globalCtx) { sp40 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; sp3C = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; - func_800B75A0(this->actor.floorPoly, &sp48, &sp46); + Actor_GetSlopeDirection(this->actor.floorPoly, &slopeNormal, &downwardSlopeYaw); - sp40 += 3.0f * sp48.x; - sp3C += 3.0f * sp48.z; + sp40 += 3.0f * slopeNormal.x; + sp3C += 3.0f * slopeNormal.z; 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 { this->actor.speedXZ = sp38; } - this->actor.world.rot.y = Math_FAtan2F(sp3C, sp40); + this->actor.world.rot.y = Math_Atan2S_XY(sp3C, sp40); } if (!Math_StepToF(&this->actor.speedXZ, 0.0f, sp58->x)) { @@ -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.curRoom.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,36 +348,36 @@ 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); - Actor_MarkForDeath(&this->actor); + func_80123590(play, &this->actor); + Actor_Kill(&this->actor); } if ((this->timer & 1) == 0) { @@ -388,9 +389,9 @@ void func_808715B8(EnBom* this, GlobalContext* globalCtx) { 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) { @@ -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,14 +431,14 @@ 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) { + if (player->stateFlags1 & PLAYER_STATE1_2) { return; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_GIANT) { - Actor_MarkForDeath(thisx); + if (Player_GetMask(play) == PLAYER_MASK_GIANT) { + Actor_Kill(thisx); return; } @@ -445,17 +446,17 @@ 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; } - Actor_MarkForDeath(thisx); + Actor_Kill(thisx); } } 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,20 +528,20 @@ 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); + thisx->flags |= (ACTOR_FLAG_20 | ACTOR_FLAG_100000); this->actionFunc = func_808715B8; if (this->isPowderKeg) { gSaveContext.powderKegTimer = 0; @@ -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); + 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_ReplaceRotation(&globalCtx->billboardMtxF); + 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; @@ -640,53 +639,52 @@ void EnBom_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 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); + fuseSegmentPtr->rotY = Math_Atan2S_XY(spCC.z, spCC.x); distXZ = sqrtf(SQXZ(spCC)); - ptr->unk_1A = Math_FAtan2F(distXZ, spCC.y); + fuseSegmentPtr->rotX = Math_Atan2S_XY(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); + fuseSegmentPtr2->rotY = Math_Atan2S_XY(spCC.z, spCC.x); distXZ = sqrtf(SQXZ(spCC)); - ptr2->unk_1A = Math_FAtan2F(distXZ, spCC.y); + fuseSegmentPtr2->rotX = Math_Atan2S_XY(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_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_RotateZYX(ptr->unk_1A, ptr->unk_18, 0, MTXMODE_APPLY); + Matrix_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_Translate(ptr2->unk_00.x, ptr2->unk_00.y, ptr2->unk_00.z, MTXMODE_NEW); - Matrix_RotateZYX(ptr2->unk_1A, ptr2->unk_18, 0, MTXMODE_APPLY); + 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..23218a183 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) @@ -31,6 +31,4 @@ typedef struct EnBom { /* 0x200 */ EnBomActionFunc actionFunc; } EnBom; // size = 0x204 -extern const ActorInit En_Bom_InitVars; - #endif // Z_EN_BOM_H diff --git a/src/overlays/actors/ovl_En_Bom_Bowl_Man/overlay.cfg b/src/overlays/actors/ovl_En_Bom_Bowl_Man/overlay.cfg deleted file mode 100644 index 2d762ca9b..000000000 --- a/src/overlays/actors/ovl_En_Bom_Bowl_Man/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bom_Bowl_Man -z_en_bom_bowl_man.c 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..4a9876c79 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,33 +11,33 @@ #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; s32 D_809C6104 = 0; -const ActorInit En_Bom_Bowl_Man_InitVars = { +ActorInit En_Bom_Bowl_Man_InitVars = { ACTOR_EN_BOM_BOWL_MAN, ACTORCAT_NPC, FLAGS, @@ -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,22 +94,22 @@ 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)) && CHECK_WEEKEVENTREG(WEEKEVENTREG_73_80) && + !CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { this->unk_2D6 = this->actor.cutscene; if (this->unk_2D6 == 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } func_809C52B4(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -void EnBomBowlMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBomBowlMan_Destroy(Actor* thisx, PlayState* play) { } void func_809C493C(EnBomBowlMan* this, s32 arg1, f32 arg2) { @@ -158,12 +158,12 @@ void func_809C4B50(EnBomBowlMan* this) { void func_809C4B6C(EnBomBowlMan* this) { if ((this->unk_29A != ENBOMBOWLMAN_FF00_MINUS1) && (this->path != NULL)) { if (!SubS_CopyPointFromPath(this->path, this->unk_298, &this->unk_2A0)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } -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; @@ -203,17 +202,17 @@ void func_809C4BC4(EnBomBowlMan* this, GlobalContext* globalCtx) { func_809C493C(this, 3, 1.0f); this->unk_2D4 = this->actor.yawTowardsPlayer; this->unk_290 = this->actor.yawTowardsPlayer; - gSaveContext.save.weekEventReg[73] &= (u8)~0x10; - gSaveContext.save.weekEventReg[85] &= (u8)~2; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_73_10); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_85_02); this->unk_29C = 0; 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,31 +319,31 @@ 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; - gSaveContext.save.weekEventReg[75] &= (u8)~0x40; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_86; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_75_40); if (player->transformation == PLAYER_FORM_HUMAN) { - gSaveContext.save.weekEventReg[84] |= 0x80; - gSaveContext.save.weekEventReg[77] &= (u8)~2; + SET_WEEKEVENTREG(WEEKEVENTREG_84_80); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_77_02); } else { - gSaveContext.save.weekEventReg[73] |= 0x20; - gSaveContext.save.weekEventReg[85] &= (u8)~1; + SET_WEEKEVENTREG(WEEKEVENTREG_73_20); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_85_01); } } } @@ -360,17 +359,17 @@ 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, PLAYER_CSMODE_7); func_809C53A4(this); } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } @@ -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)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { 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, PLAYER_CSMODE_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, PLAYER_CSMODE_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) { @@ -484,25 +483,26 @@ void func_809C5738(EnBomBowlMan* this, GlobalContext* globalCtx) { (this->path != NULL)) { this->unk_298++; if (this->unk_298 >= this->path->count) { - gSaveContext.save.weekEventReg[84] |= 0x80; - gSaveContext.save.weekEventReg[83] &= (u8)~4; + SET_WEEKEVENTREG(WEEKEVENTREG_84_80); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_83_04); ActorCutscene_Stop(this->unk_2D6); - Actor_MarkForDeath(&this->actor); - } else { - func_809C4B6C(this); + Actor_Kill(&this->actor); + return; } + + func_809C4B6C(this); } } } -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 +510,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_IA_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_IA_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 +551,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; + Camera* subCam; if ((D_809C6104 != 0) && (this->unk_2F8 != 15)) { func_809C493C(this, 15, 1.0f); @@ -574,34 +574,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 +617,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 +630,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 +671,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..fc911dd04 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) @@ -57,6 +57,4 @@ typedef struct EnBomBowlMan { /* 0x02F8 */ s32 unk_2F8; } EnBomBowlMan; // size = 0x2FC -extern const ActorInit En_Bom_Bowl_Man_InitVars; - #endif // Z_EN_BOM_BOWL_MAN_H diff --git a/src/overlays/actors/ovl_En_Bom_Chu/overlay.cfg b/src/overlays/actors/ovl_En_Bom_Chu/overlay.cfg deleted file mode 100644 index d1b0f7dc2..000000000 --- a/src/overlays/actors/ovl_En_Bom_Chu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bom_Chu -z_en_bom_chu.c 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 541fc071c..cbcc40211 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,18 +14,18 @@ #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 = { +ActorInit En_Bom_Chu_InitVars = { ACTOR_EN_BOM_CHU, ACTORCAT_EXPLOSIVES, FLAGS, @@ -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,9 +128,8 @@ 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; } @@ -143,7 +141,7 @@ s32 EnBomChu_UpdateFloorPoly(EnBomChu* this, CollisionPoly* floorPoly, GlobalCon magnitude = Math3D_Vec3fMagnitude(&this->axisForwards); if (magnitude < 0.001f) { - EnBomChu_Explode(this, globalCtx); + EnBomChu_Explode(this, play); return false; } @@ -171,19 +169,19 @@ void EnBomChu_UpdateRotation(EnBomChu* this) { 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; } @@ -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); + Actor_Kill(&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; @@ -565,8 +564,8 @@ void EnBomChu_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_OPA_DISP++, (s32)(colorIntensity * 209.0f) + 9, (s32)(colorIntensity * 34.0f) + 9, (s32)(colorIntensity * -35.0f) + 35, 255); Matrix_Translate(this->visualJitter * (1.0f / BOMBCHU_SCALE), 0.0f, 0.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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..686bbb384 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; @@ -25,6 +25,4 @@ typedef struct EnBomChu { /* 0x188 */ ColliderSphere collider; } EnBomChu; // size = 0x1E0 -extern const ActorInit En_Bom_Chu_InitVars; - #endif // Z_EN_BOM_CHU_H diff --git a/src/overlays/actors/ovl_En_Bombal/overlay.cfg b/src/overlays/actors/ovl_En_Bombal/overlay.cfg deleted file mode 100644 index a715cfbf5..000000000 --- a/src/overlays/actors/ovl_En_Bombal/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bombal -z_en_bombal.c 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..bcb7cb534 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.c @@ -5,22 +5,27 @@ */ #include "z_en_bombal.h" +#include "assets/objects/object_fusen/object_fusen.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) #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); +void func_80C05B24(EnBombal* this); +void EnBombal_InitEffects(EnBombal* this, Vec3f* pos, s16 fadeDelay); +void EnBombal_UpdateEffects(EnBombal* this, PlayState* play); +void EnBombal_DrawEffects(EnBombal*, PlayState*); -#if 0 -const ActorInit En_Bombal_InitVars = { +ActorInit En_Bombal_InitVars = { ACTOR_EN_BOMBAL, ACTORCAT_PROP, FLAGS, @@ -32,37 +37,243 @@ const ActorInit En_Bombal_InitVars = { (ActorFunc)EnBombal_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80C06460 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x004138B0, 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 }, + { 0x004138B0, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 60, 90, -50, { 0, 0, 0 } }, }; -#endif +void EnBombal_Init(Actor* thisx, PlayState* play) { + EnBombal* this = THIS; -extern ColliderCylinderInit D_80C06460; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + this->actor.colChkInfo.mass = 0; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.targetMode = 6; + this->actor.colChkInfo.health = 1; + this->scale = 0.1f; + this->cutscene = this->actor.cutscene; + func_80C05B24(this); +} -extern UNK_TYPE D_06000A00; +void EnBombal_Destroy(Actor* thisx, PlayState* play) { + EnBombal* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/EnBombal_Init.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/EnBombal_Destroy.s") +void func_80C05B24(EnBombal* this) { + this->isPopped = false; + this->actionFunc = func_80C05B3C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05B24.s") +void func_80C05B3C(EnBombal* this, PlayState* play) { + Player* player; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05B3C.s") + this->oscillationAngle += 1500.0f; + this->actor.velocity.y = Math_SinS(this->oscillationAngle); + Math_ApproachF(&this->scale, 0.1f, 0.3f, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05C44.s") + if (play->msgCtx.msgLength == 0) { + if (this->collider.base.acFlags & AC_HIT) { + player = GET_PLAYER(play); + this->collider.base.acFlags &= ~AC_HIT; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_40) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { + player->stateFlags1 |= ACTOR_FLAG_20; + this->actor.flags |= ACTOR_FLAG_100000; + } + this->actionFunc = func_80C05C44; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05DE8.s") +void func_80C05C44(EnBombal* this, PlayState* play) { + s32 phi_s0 = false; + s32 i; + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/EnBombal_Update.s") + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_40) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->cutscene); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/EnBombal_Draw.s") + if (!ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_SetIntentToPlay(this->cutscene); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->cutscene, &this->actor); + phi_s0 = true; + } + } else { + phi_s0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C05F90.s") + if (phi_s0) { + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.y += 60.0f; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, pos.x, pos.y, pos.z, 255, 255, 200, + CLEAR_TAG_LARGE_EXPLOSION); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C060B8.s") + for (i = 0; i < 100; i++) { + EnBombal_InitEffects(this, &pos, 10); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bombal/func_80C06208.s") + SET_WEEKEVENTREG(WEEKEVENTREG_83_04); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_MUJURA_BALLOON_BROKEN); + this->timer = 30; + this->isPopped = true; + this->actionFunc = func_80C05DE8; + } +} + +void func_80C05DE8(EnBombal* this, PlayState* play) { + if (this->timer == 0) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_40) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { + ActorCutscene_Stop(this->cutscene); + } + Actor_Kill(&this->actor); + return; + } + + if (this->timer < 10) { + this->actor.colChkInfo.health = 0; + } +} + +void EnBombal_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnBombal* this = THIS; + + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + + Actor_SetFocus(&this->actor, 30.0f); + Actor_SetScale(&this->actor, this->scale); + + this->actionFunc(this, play); + + Actor_MoveWithGravity(&this->actor); + EnBombal_UpdateEffects(this, play); + + if (!this->isPopped) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } +} + +void EnBombal_Draw(Actor* thisx, PlayState* play) { + EnBombal* this = THIS; + + if (this->isPopped != true) { + Gfx_DrawDListOpa(play, gMajoraBalloonDL); + Gfx_DrawDListOpa(play, gMajoraBalloonKnotDL); + } + EnBombal_DrawEffects(this, play); +} + +void EnBombal_InitEffects(EnBombal* this, Vec3f* pos, s16 fadeDelay) { + s16 i; + EnBombalEffect* sPtr = this->effects; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (!sPtr->isEnabled) { + sPtr->isEnabled = true; + sPtr->pos = *pos; + sPtr->alphaFadeDelay = fadeDelay; + sPtr->alpha = 255; + + sPtr->accel.x = (Rand_ZeroOne() - 0.5f) * 10.0f; + sPtr->accel.y = (Rand_ZeroOne() - 0.5f) * 10.0f; + sPtr->accel.z = (Rand_ZeroOne() - 0.5f) * 10.0f; + + 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; + } + } +} + +void EnBombal_UpdateEffects(EnBombal* this, PlayState* play) { + s32 i; + EnBombalEffect* sPtr = this->effects; + + 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->isEnabled = 0; + } + } + } + } +} + +void EnBombal_DrawEffects(EnBombal* this, PlayState* play) { + s16 i; + GraphicsContext* gfxCtx = play->state.gfxCtx; + EnBombalEffect* sPtr = this->effects; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, sPtr++) { + if (sPtr->isEnabled != 0) { + 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, 0x14); + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(&gSun1Tex)); + + gSPDisplayList(POLY_XLU_DISP++, &gSunSparkleMaterialDL); + + gDPPipeSync(POLY_XLU_DISP++); + + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); + + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(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++, &gSunSparkleModelDL); + } + } + CLOSE_DISPS(gfxCtx); +} 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..7c72f3eea 100644 --- a/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h +++ b/src/overlays/actors/ovl_En_Bombal/z_en_bombal.h @@ -5,19 +5,29 @@ struct EnBombal; -typedef void (*EnBombalActionFunc)(struct EnBombal*, GlobalContext*); +typedef void (*EnBombalActionFunc)(struct EnBombal*, PlayState*); + +typedef struct EnBombalEffect { + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; + /* 0x10 */ UNK_TYPE4 unk10; + /* 0x14 */ s16 alpha; + /* 0x16 */ s16 alphaFadeDelay; + /* 0x18 */ Vec3f velocity; + /* 0x24 */ Vec3f accel; + /* 0x30 */ f32 scale; +} EnBombalEffect; typedef struct EnBombal { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnBombalActionFunc actionFunc; - /* 0x0148 */ char unk148[0x4]; - /* 0x014C */ s16 unk_14C; - /* 0x0150 */ f32 unk_150; - /* 0x0154 */ char unk154[0x150]; - /* 0x02A4 */ Vec3f unk_2A4; - /* 0x02B0 */ char unk2B0[0x2794]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnBombalActionFunc actionFunc; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 isPopped; + /* 0x14C */ s16 cutscene; + /* 0x150 */ f32 scale; + /* 0x154 */ f32 oscillationAngle; + /* 0x158 */ ColliderCylinder collider; + /* 0x1A4 */ EnBombalEffect effects[200]; } EnBombal; // size = 0x2A44 -extern const ActorInit En_Bombal_InitVars; - #endif // Z_EN_BOMBAL_H diff --git a/src/overlays/actors/ovl_En_Bombers/overlay.cfg b/src/overlays/actors/ovl_En_Bombers/overlay.cfg deleted file mode 100644 index 95cb0c1f8..000000000 --- a/src/overlays/actors/ovl_En_Bombers/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bombers -z_en_bombers.c 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..2ca62ef0a 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -12,20 +12,20 @@ #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 = { +ActorInit En_Bombers_InitVars = { ACTOR_EN_BOMBERS, ACTORCAT_NPC, FLAGS, @@ -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); @@ -104,23 +104,24 @@ void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2BE = ENBOMBERS_GET_F(&this->actor); if (this->unk_2BC == ENBOMBERS_F0_0) { - if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { - Actor_MarkForDeath(&this->actor); - } else { - this->unk_2BE++; - func_80C03ACC(this); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { + Actor_Kill(&this->actor); + return; } - } else if (((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) && - (((this->unk_2BE == ENBOMBERS_F_0) && (gSaveContext.save.weekEventReg[76] & 1)) || - ((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[76] & 2)) || - ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[76] & 4)) || - ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[76] & 8)) || - ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[76] & 0x10)))) { - if (gSaveContext.save.weekEventReg[75] & 0x40) { + + this->unk_2BE++; + func_80C03ACC(this); + } else if ((CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) && + (((this->unk_2BE == ENBOMBERS_F_0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_76_01)) || + ((this->unk_2BE == ENBOMBERS_F_1) && CHECK_WEEKEVENTREG(WEEKEVENTREG_76_02)) || + ((this->unk_2BE == ENBOMBERS_F_2) && CHECK_WEEKEVENTREG(WEEKEVENTREG_76_04)) || + ((this->unk_2BE == ENBOMBERS_F_3) && CHECK_WEEKEVENTREG(WEEKEVENTREG_76_08)) || + ((this->unk_2BE == ENBOMBERS_F_4) && CHECK_WEEKEVENTREG(WEEKEVENTREG_76_10)))) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_40)) { 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; @@ -130,26 +131,27 @@ void EnBombers_Init(Actor* thisx, GlobalContext* globalCtx) { while (cs != -1) { bomBowlMan->unk_2CC[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; } // clang-format on - gSaveContext.save.weekEventReg[76] &= (u8)~1; - gSaveContext.save.weekEventReg[76] &= (u8)~2; - gSaveContext.save.weekEventReg[76] &= (u8)~4; - gSaveContext.save.weekEventReg[76] &= (u8)~8; - gSaveContext.save.weekEventReg[76] &= (u8)~0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_10); } } - Actor_MarkForDeath(&this->actor); - } else { - func_80C042F8(this); + Actor_Kill(&this->actor); + return; } + + func_80C042F8(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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,14 +175,14 @@ 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: this->actor.textId = 0x73D; - if (gSaveContext.save.weekEventReg[84] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_80)) { this->actor.textId = 0x74B; } break; @@ -194,14 +196,14 @@ void func_80C039A8(EnBombers* this, GlobalContext* globalCtx) { break; case PLAYER_FORM_DEKU: - if (gSaveContext.save.weekEventReg[73] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_20)) { this->actor.textId = 0x75A; - } else if (gSaveContext.save.weekEventReg[73] & 0x40) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_40)) { this->actor.textId = 0x749; - if (((this->unk_2BE == ENBOMBERS_F_1) && (gSaveContext.save.weekEventReg[74] & 1)) || - ((this->unk_2BE == ENBOMBERS_F_2) && (gSaveContext.save.weekEventReg[74] & 2)) || - ((this->unk_2BE == ENBOMBERS_F_3) && (gSaveContext.save.weekEventReg[74] & 4)) || - ((this->unk_2BE == ENBOMBERS_F_4) && (gSaveContext.save.weekEventReg[74] & 8))) { + if (((this->unk_2BE == ENBOMBERS_F_1) && CHECK_WEEKEVENTREG(WEEKEVENTREG_74_01)) || + ((this->unk_2BE == ENBOMBERS_F_2) && CHECK_WEEKEVENTREG(WEEKEVENTREG_74_02)) || + ((this->unk_2BE == ENBOMBERS_F_3) && CHECK_WEEKEVENTREG(WEEKEVENTREG_74_04)) || + ((this->unk_2BE == ENBOMBERS_F_4) && CHECK_WEEKEVENTREG(WEEKEVENTREG_74_08))) { this->actor.textId = 0x74A; } } else { @@ -218,7 +220,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 +240,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 +261,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 +295,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 +319,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 +336,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 +363,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; @@ -393,22 +395,22 @@ void func_80C03FAC(EnBombers* this, GlobalContext* globalCtx) { } else if (this->actor.textId == 0x748) { switch (this->unk_2BE) { case ENBOMBERS_F_1: - gSaveContext.save.weekEventReg[74] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_74_01); break; case ENBOMBERS_F_2: - gSaveContext.save.weekEventReg[74] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_74_02); break; case ENBOMBERS_F_3: - gSaveContext.save.weekEventReg[74] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_74_04); break; case ENBOMBERS_F_4: - gSaveContext.save.weekEventReg[74] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_74_08); break; } - gSaveContext.save.weekEventReg[73] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_73_40); } switch (sp2A) { @@ -418,7 +420,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 +436,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 +474,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 +487,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 +512,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..85c5ecdb3 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,35 +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; - #endif // Z_EN_BOMBERS_H diff --git a/src/overlays/actors/ovl_En_Bombers2/overlay.cfg b/src/overlays/actors/ovl_En_Bombers2/overlay.cfg deleted file mode 100644 index 6cbb956fe..000000000 --- a/src/overlays/actors/ovl_En_Bombers2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bombers2 -z_en_bombers2.c 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..74575628f 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.c @@ -10,20 +10,20 @@ #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 = { +ActorInit En_Bombers2_InitVars = { ACTOR_EN_BOMBERS2, ACTORCAT_NPC, FLAGS, @@ -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,18 @@ 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_80) || (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; @@ -102,15 +103,15 @@ void EnBombers2_Init(Actor* thisx, GlobalContext* globalCtx) { } this->cutscene = this->actor.cutscene; if (this->cutscene == 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } 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 +121,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 +134,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 +160,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; + SET_WEEKEVENTREG(WEEKEVENTREG_86_02); func_80C04D00(this); return; } if (yawDiffAbs < 0x3BB5) { - func_800B8614(&this->actor, globalCtx, 70.0f); + func_800B8614(&this->actor, play, 70.0f); } } @@ -189,8 +190,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 +214,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 +233,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 +252,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 +268,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 +306,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,17 +324,17 @@ 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; this->unk_2C0 = 1; - gSaveContext.save.weekEventReg[73] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_73_80); 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 +344,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 +375,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 +398,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 +421,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..4a79e6615 100644 --- a/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h +++ b/src/overlays/actors/ovl_En_Bombers2/z_en_bombers2.h @@ -7,40 +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; - #endif // Z_EN_BOMBERS2_H diff --git a/src/overlays/actors/ovl_En_Bombf/overlay.cfg b/src/overlays/actors/ovl_En_Bombf/overlay.cfg deleted file mode 100644 index 831b98c2f..000000000 --- a/src/overlays/actors/ovl_En_Bombf/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bombf -z_en_bombf.c 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 d4633c02d..0b5ffff54 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -5,25 +5,26 @@ */ #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* play2); +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 = { +ActorInit En_Bombf_InitVars = { ACTOR_EN_BOMBF, ACTORCAT_PROP, FLAGS, @@ -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); @@ -162,7 +163,7 @@ void func_808AEAE0(EnBombf* this, GlobalContext* globalCtx) { player->heldActor = NULL; player->interactRangeActor = NULL; this->actor.parent = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_800; } } else if ((this->colliderCylinder.base.acFlags & AC_HIT) && ((this->colliderCylinder.info.acHitInfo->toucher.dmgFlags & 0x13828) || @@ -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,15 +192,15 @@ 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; player->heldActor = NULL; player->interactRangeActor = NULL; this->actor.parent = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_800; this->actor.world.pos = this->actor.home.pos; } } @@ -211,19 +212,19 @@ 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; this->actor.parent = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_800; this->actor.world.pos = this->actor.home.pos; } } } -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,77 +239,77 @@ 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)) { + if ((player->stateFlags1 & PLAYER_STATE1_800) && (&this->actor == player->heldActor)) { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_800; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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,46 +431,48 @@ 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); - Actor_MarkForDeath(&this->actor); - } else if (this->actor.bgCheckFlags & 0x40) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_IT_BOMB_UNEXPLOSION); + Actor_Kill(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 0x40) { this->actor.bgCheckFlags &= ~0x40; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMB_DROP_WATER); } } } -Gfx* func_808AF86C(GraphicsContext* gfxCtx, GlobalContext* globalCtx) { - Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); - Gfx* gfx = head; +Gfx* func_808AF86C(GraphicsContext* gfxCtx, PlayState* play) { + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 5 * sizeof(Gfx)); + Gfx* gfx = gfxHead; - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPEndDisplayList(gfx++); - return head; + return gfxHead; } -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); @@ -480,10 +483,10 @@ void EnBombf_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 +496,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..55b7f7bae 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,19 +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; - #endif // Z_EN_BOMBF_H diff --git a/src/overlays/actors/ovl_En_Bomjima/overlay.cfg b/src/overlays/actors/ovl_En_Bomjima/overlay.cfg deleted file mode 100644 index 61e77897f..000000000 --- a/src/overlays/actors/ovl_En_Bomjima/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bomjima -z_en_bomjima.c 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..126c293c3 100644 --- a/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c +++ b/src/overlays/actors/ovl_En_Bomjima/z_en_bomjima.c @@ -12,37 +12,48 @@ #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); + +typedef enum EN_BOMJIMA_ACTION { + /* 0 */ EN_BOMJIMA_ACTION_0, + /* 1 */ EN_BOMJIMA_ACTION_1, + /* 2 */ EN_BOMJIMA_ACTION_2, + /* 3 */ EN_BOMJIMA_ACTION_3, + /* 4 */ EN_BOMJIMA_ACTION_4, + /* 5 */ EN_BOMJIMA_ACTION_5, + /* 6 */ EN_BOMJIMA_ACTION_6, + /* 7 */ EN_BOMJIMA_ACTION_7, +} EN_BOMJIMA_ACTION; static s32 D_80C009F0 = 0; static s32 D_80C009F4 = 0; -const ActorInit En_Bomjima_InitVars = { +ActorInit En_Bomjima_InitVars = { ACTOR_EN_BOMJIMA, ACTORCAT_NPC, FLAGS, @@ -106,7 +117,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,10 +125,10 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -3.0f; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_cs_Skel_00F82C, &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); - gSaveContext.save.weekEventReg[83] &= (u8)~4; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_83_04); this->actor.targetMode = 0; this->unk_2E6 = ENBOMJIMA_GET_F0(&this->actor); this->unk_2E4 = ENBOMJIMA_GET_F(&this->actor); @@ -129,7 +140,7 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { while (cs != -1) { // clang-format off - this->unk_2D4[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); + this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); // clang-format on i++; } @@ -139,20 +150,20 @@ void EnBomjima_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BFFCFC(this); } - if ((gSaveContext.save.weekEventReg[75] & 0x40) || (gSaveContext.save.weekEventReg[73] & 0x10) || - (gSaveContext.save.weekEventReg[85] & 2)) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_40) || CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { + Actor_Kill(&this->actor); } } -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) { @@ -166,12 +177,12 @@ void func_80BFE32C(EnBomjima* this, GlobalContext* globalCtx, s32 arg2) { case 0: if (player->transformation == PLAYER_FORM_DEKU) { this->actor.textId = 0x759; - if (!(gSaveContext.save.weekEventReg[73] & 0x20)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_73_20)) { this->actor.textId = 0x708; } } else if (player->transformation == PLAYER_FORM_HUMAN) { this->actor.textId = 0x75A; - if (!(gSaveContext.save.weekEventReg[84] & 0x80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_84_80)) { this->actor.textId = 0x719; } } else if ((this->unk_2C8 == 1) || (this->unk_2C8 == 2)) { @@ -197,31 +208,31 @@ void func_80BFE32C(EnBomjima* this, GlobalContext* globalCtx, s32 arg2) { } } -void func_80BFE494(EnBomjima* this, s32 arg1, f32 arg2) { - this->unk_2EC = arg1; - this->unk_2CC = Animation_GetLastFrame(sAnimations[arg1]); - Animation_Change(&this->skelAnime, sAnimations[this->unk_2EC], arg2, 0.0f, this->unk_2CC, D_80C00AE4[this->unk_2EC], - -4.0f); +void func_80BFE494(EnBomjima* this, s32 animIndex, f32 playSpeed) { + this->animIndex = animIndex; + this->animLastFrame = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], playSpeed, 0.0f, this->animLastFrame, + D_80C00AE4[this->animIndex], -4.0f); } void func_80BFE524(EnBomjima* this) { - if ((this->unk_2EC == 5) && + if ((this->animIndex == 5) && (Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 10.0f) || Animation_OnFrame(&this->skelAnime, 17.0f) || Animation_OnFrame(&this->skelAnime, 18.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); } - if ((this->unk_2EC == 18) && + if ((this->animIndex == 18) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 2.0f) || Animation_OnFrame(&this->skelAnime, 4.0f) || Animation_OnFrame(&this->skelAnime, 6.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_WALK); } - if ((this->unk_2EC == 15) && Animation_OnFrame(&this->skelAnime, 15.0f)) { + if ((this->animIndex == 15) && Animation_OnFrame(&this->skelAnime, 15.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); } - if ((this->unk_2EC == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { + if ((this->animIndex == 6) && Animation_OnFrame(&this->skelAnime, 8.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_LAND); } } @@ -235,7 +246,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 +270,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 +293,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 +328,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) { @@ -326,10 +337,11 @@ void func_80BFEA94(EnBomjima* this, GlobalContext* globalCtx) { continue; } - this->unk_2F0 = (EnBombal*)actor; + this->bombal = (EnBombal*)actor; Math_Vec3f_Copy(&this->unk_2B0, &actor->world.pos); - if (this->unk_2F4 == 0) { - this->unk_2F4 = this->unk_2F0->actor.cutscene; + + if (this->bombalCutscene == 0) { + this->bombalCutscene = this->bombal->actor.cutscene; } func_80BFEB1C(this); break; @@ -339,49 +351,49 @@ void func_80BFEA94(EnBomjima* this, GlobalContext* globalCtx) { void func_80BFEB1C(EnBomjima* this) { func_80BFE494(this, 1, 1.0f); func_80BFE65C(this); - this->unk_2A0 = 0; + this->action = EN_BOMJIMA_ACTION_0; 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_20)) { this->unk_2C8 = 3; - func_80BFE32C(this, globalCtx, 3); - } else if (gSaveContext.save.weekEventReg[77] & 2) { + func_80BFE32C(this, play, 3); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_02)) { 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_80)) { this->unk_2C8 = 0; - func_80BFE32C(this, globalCtx, 3); - } else if (gSaveContext.save.weekEventReg[85] & 1) { + func_80BFE32C(this, play, 3); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_85_01)) { 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)) { + if ((this->bombal->actor.update == NULL) || (this->bombal->actor.colChkInfo.health == 0)) { func_80BFEFF0(this); return; } @@ -394,14 +406,14 @@ void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { break; case 1: - this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2F0->actor.world.pos); + this->unk_2DC = Math_Vec3f_Yaw(&this->actor.world.pos, &this->bombal->actor.world.pos); if (Animation_OnFrame(&this->skelAnime, 19.0f)) { this->unk_2C0 = 5; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BOMBERS_SHOT_BREATH); } if (this->unk_2C0 == 1) { - s16 sp3E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_2F0->actor.world.pos); + s16 sp3E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->bombal->actor.world.pos); if (Rand_ZeroOne() < 0.5f) { sp3E += 0x4000; @@ -409,12 +421,12 @@ void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { sp3E += 0xC000; } - sp40.x = (Math_SinS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.x; - sp40.y = this->unk_2F0->actor.world.pos.y - randPlusMinusPoint5Scaled(40.0f); - sp40.z = (Math_CosS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->unk_2F0->actor.world.pos.z; + sp40.x = (Math_SinS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->bombal->actor.world.pos.x; + sp40.y = this->bombal->actor.world.pos.y - randPlusMinusPoint5Scaled(40.0f); + sp40.z = (Math_CosS(sp3E) * (Rand_ZeroFloat(20.0f) + 40.0f)) + this->bombal->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) { @@ -443,54 +455,54 @@ void func_80BFEB64(EnBomjima* this, GlobalContext* globalCtx) { } void func_80BFEFF0(EnBomjima* this) { - this->unk_2F0 = NULL; + this->bombal = NULL; func_80BFE494(this, 19, 1.0f); func_80BFE65C(this); - this->unk_2A0 = 1; + this->action = EN_BOMJIMA_ACTION_1; 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); - ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); - } else if (!ActorCutscene_GetCanPlayNext(this->unk_2D4[0])) { - ActorCutscene_SetIntentToPlay(this->unk_2D4[0]); + ActorCutscene_SetIntentToPlay(this->cutscenes[0]); + } else if (!ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { + ActorCutscene_SetIntentToPlay(this->cutscenes[0]); } 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)); - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[0], &this->actor); + player->stateFlags1 &= ~PLAYER_STATE1_20; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_83_04); + this->actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); + this->unk_2DC = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); + ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[0], &this->actor); func_80BFF120(this); } } void func_80BFF120(EnBomjima* this) { func_80BFE65C(this); - this->unk_2C4 = 30; + this->cutsceneTimer = 30; func_80BFE494(this, 6, 1.0f); - this->unk_2DE = 0; - this->unk_2A0 = 2; + this->cutsceneEnded = false; + this->action = EN_BOMJIMA_ACTION_2; 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 (this->cutsceneTimer == 1) { + ActorCutscene_Stop(this->cutscenes[0]); + this->cutsceneEnded = true; } - 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; @@ -498,19 +510,19 @@ void func_80BFF174(EnBomjima* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_2DC, 1, 5000, 0); - if ((this->unk_2CC <= sp2C) && (this->unk_2BC < 5)) { + if ((this->animLastFrame <= sp2C) && (this->unk_2BC < 5)) { this->unk_2BC++; - if (this->unk_2EC != 19) { + if (this->animIndex != 19) { func_80BFE494(this, 19, 1.0f); } } if (player->transformation == PLAYER_FORM_DEKU) { - if (gSaveContext.save.weekEventReg[73] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_20)) { this->unk_2C8 = 3; - func_80BFE32C(this, globalCtx, 3); + func_80BFE32C(this, play, 3); } else { - if (!(gSaveContext.save.weekEventReg[77] & 2)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_77_02)) { if (this->unk_2E8 == 0) { this->unk_2C8 = 4; } else { @@ -519,14 +531,14 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_80)) { this->unk_2C8 = 0; - func_80BFE32C(this, globalCtx, 3); + func_80BFE32C(this, play, 3); } else { - if (!(gSaveContext.save.weekEventReg[85] & 1)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_85_01)) { if (this->unk_2EA == 0) { this->unk_2C8 = 4; } else { @@ -535,40 +547,40 @@ 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->cutsceneEnded != false) { 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); } } void func_80BFF3F0(EnBomjima* this) { func_80BFE494(this, 15, 1.0f); - this->unk_2A0 = 3; + this->action = EN_BOMJIMA_ACTION_3; 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, + if (this->animLastFrame <= curFrame) { + 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); - gSaveContext.save.weekEventReg[83] &= (u8)~4; + bombal->scale = 0.0f; + bombal->cutscene = this->bombalCutscene; + Actor_ChangeFocus(&this->actor, play, &bombal->actor); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_83_04); func_80BFE65C(this); - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80BFEA94; } } @@ -576,15 +588,15 @@ void func_80BFF430(EnBomjima* this, GlobalContext* globalCtx) { void func_80BFF4F4(EnBomjima* this) { func_80BFE65C(this); - this->unk_2A0 = 4; + this->action = EN_BOMJIMA_ACTION_4; 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 +608,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->action = EN_BOMJIMA_ACTION_5; this->actionFunc = func_80BFF6CC; } else { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); func_8019F230(); func_80BFE65C(this); @@ -614,28 +626,28 @@ 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 (this->animLastFrame <= curFrame) { + 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; + EnBomjima* bomjima; s32 i; f32 x; f32 y; @@ -643,12 +655,12 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); - ActorCutscene_SetIntentToPlay(this->unk_2D4[1]); + ActorCutscene_SetIntentToPlay(this->cutscenes[1]); return; } - if (!ActorCutscene_GetCanPlayNext(this->unk_2D4[1])) { - ActorCutscene_SetIntentToPlay(this->unk_2D4[1]); + if (!ActorCutscene_GetCanPlayNext(this->cutscenes[1])) { + ActorCutscene_SetIntentToPlay(this->cutscenes[1]); return; } @@ -663,9 +675,9 @@ 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); - if (temp_s3 != NULL) { + bomjima = (EnBomjima*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_BOMJIMA, spA0.x, spA0.y, + spA0.z, 0, 0, 0, i + 32); + if (bomjima != NULL) { s32 index = (i * 2) - 2; Math_Vec3f_Copy(&spA0, &this->actor.world.pos); @@ -673,40 +685,40 @@ void func_80BFF754(EnBomjima* this, GlobalContext* globalCtx) { spA0.x += Math_SinS(D_80C00AF8[(i * 2) - 2] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; spA0.z += Math_CosS(D_80C00AF8[index] + this->actor.world.rot.y) * D_80C00AF8[index + 1]; - Math_Vec3f_Copy(&temp_s3->unk_2A4, &spA0); + Math_Vec3f_Copy(&bomjima->unk_2A4, &spA0); } } D_80C009F0 = 0; - ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D4[1], &this->actor); + ActorCutscene_StartAndSetUnkLinkFields(this->cutscenes[1], &this->actor); 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; if (player->transformation == PLAYER_FORM_DEKU) { - gSaveContext.save.weekEventReg[73] |= 0x10; - gSaveContext.save.weekEventReg[77] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_73_10); + SET_WEEKEVENTREG(WEEKEVENTREG_77_02); } else { - gSaveContext.save.weekEventReg[85] |= 2; - gSaveContext.save.weekEventReg[85] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_85_02); + SET_WEEKEVENTREG(WEEKEVENTREG_85_01); } - gSaveContext.save.weekEventReg[11] &= (u8)~1; - gSaveContext.save.weekEventReg[11] &= (u8)~2; - gSaveContext.save.weekEventReg[11] &= (u8)~4; - gSaveContext.save.weekEventReg[11] &= (u8)~8; - gSaveContext.save.weekEventReg[11] &= (u8)~0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_11_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_11_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_11_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_11_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_11_10); - gSaveContext.save.weekEventReg[76] &= (u8)~1; - gSaveContext.save.weekEventReg[76] &= (u8)~2; - gSaveContext.save.weekEventReg[76] &= (u8)~4; - gSaveContext.save.weekEventReg[76] &= (u8)~8; - gSaveContext.save.weekEventReg[76] &= (u8)~0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_76_10); gSaveContext.save.bombersCaughtNum = 0; gSaveContext.save.bombersCaughtOrder[0] = 0; @@ -723,14 +735,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,10 +750,10 @@ 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)) { + if ((this->animIndex != 1) && (this->animLastFrame <= curFrame)) { func_80BFE494(this, 1, 1.0f); } @@ -756,24 +768,24 @@ 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; - ActorCutscene_Stop(this->unk_2D4[1]); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_86; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + ActorCutscene_Stop(this->cutscenes[1]); } } void func_80BFFCFC(EnBomjima* this) { func_80BFE65C(this); func_80BFE494(this, 18, 1.0f); - this->unk_2A0 = 6; + this->action = EN_BOMJIMA_ACTION_6; 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 +800,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 +823,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); @@ -825,22 +837,22 @@ void func_80BFFF54(EnBomjima* this, GlobalContext* globalCtx) { } if (this->unk_2E4 != 4) { - if ((this->unk_2EC != 0) && (this->unk_2CC <= curFrame)) { + if ((this->animIndex != 0) && (this->animLastFrame <= curFrame)) { D_80C009F0++; func_80BFE494(this, 0, 1.0f); } - } else if ((this->unk_2EC != 8) && (this->unk_2CC <= curFrame)) { + } else if ((this->animIndex != 8) && (this->animLastFrame <= curFrame)) { func_80BFE494(this, 8, 1.0f); D_80C009F4 = 1; } - if (this->unk_2EC == 8) { + if (this->animIndex == 8) { if ((D_80C009F4 == 1) && Animation_OnFrame(&this->skelAnime, 7.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HUMAN_BOUND); D_80C009F4 = 2; } - if ((this->unk_2CC <= curFrame) && (this->unk_2C0 == 0)) { + if ((this->animLastFrame <= curFrame) && (this->unk_2C0 == 0)) { this->unk_2C0 = 10; } @@ -853,12 +865,12 @@ void func_80BFFF54(EnBomjima* this, GlobalContext* globalCtx) { void func_80C0011C(EnBomjima* this) { func_80BFE65C(this); func_80BFE494(this, 0, 1.0f); - this->unk_2A0 = 7; + this->action = EN_BOMJIMA_ACTION_7; 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 +878,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,13 +901,14 @@ 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); - if (((this->unk_2A0 == 0) || (this->unk_2C8 == 10) || (this->unk_2C8 == 11) || (this->unk_2CA == 1)) && - (this->unk_2CC <= sp28)) { + if (((this->action == EN_BOMJIMA_ACTION_0) || (this->unk_2C8 == 10) || (this->unk_2C8 == 11) || + (this->unk_2CA == 1)) && + (this->animLastFrame <= sp28)) { if (!(this->unk_2BC & 1)) { func_80BFE494(this, 3, 1.0f); } else { @@ -916,32 +929,33 @@ 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))) { + if ((this->action == EN_BOMJIMA_ACTION_4) || (this->unk_2CA == 1) || + ((this->unk_2CA == 3) && (this->unk_2C8 >= 2))) { this->unk_28E = 0; - if (player->stateFlags1 & 0x20) { - player->stateFlags1 &= ~0x20; + if (player->stateFlags1 & PLAYER_STATE1_20) { + player->stateFlags1 &= ~PLAYER_STATE1_20; } - if ((this->unk_2F0 == 0) || (this->unk_2F0->actor.update == NULL) || - (this->unk_2F0->actor.colChkInfo.health <= 0)) { + if ((this->bombal == 0) || (this->bombal->actor.update == NULL) || + (this->bombal->actor.colChkInfo.health <= 0)) { 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: this->unk_28E = 0; - if (this->unk_2A0 == 7) { + if (this->action == EN_BOMJIMA_ACTION_7) { func_80C0011C(this); } else { func_80BFEB1C(this); @@ -953,7 +967,7 @@ void func_80C00284(EnBomjima* this, GlobalContext* globalCtx) { func_80BFE65C(this); this->unk_28E = 0; func_80BFE494(this, 1, 1.0f); - this->unk_2A0 = 2; + this->action = EN_BOMJIMA_ACTION_2; this->actionFunc = func_80BFF174; return; } @@ -970,7 +984,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 +993,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 +1002,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; @@ -1008,15 +1022,15 @@ void EnBomjima_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_2C6--; } - if (this->unk_2C4 != 0) { - this->unk_2C4--; + if (this->cutsceneTimer != 0) { + this->cutsceneTimer--; } SkelAnime_Update(&this->skelAnime); this->actor.shape.rot.y = this->actor.world.rot.y; func_80BFE524(this); Actor_SetFocus(&this->actor, 20.0f); - this->actionFunc(this, globalCtx); + 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 +1044,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 +1079,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 +1094,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..6a434be42 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]; @@ -26,7 +26,7 @@ typedef struct EnBomjima { /* 0x296 */ UNK_TYPE1 unk296[4]; /* 0x29A */ s16 unk_29A; /* 0x29C */ UNK_TYPE1 unk29C[4]; - /* 0x2A0 */ s16 unk_2A0; + /* 0x2A0 */ s16 action; /* 0x2A2 */ s16 unk_2A2; /* 0x2A4 */ Vec3f unk_2A4; /* 0x2B0 */ Vec3f unk_2B0; @@ -34,28 +34,26 @@ typedef struct EnBomjima { /* 0x2BE */ s16 unk_2BE; /* 0x2C0 */ s16 unk_2C0; /* 0x2C2 */ s16 unk_2C2; - /* 0x2C4 */ s16 unk_2C4; + /* 0x2C4 */ s16 cutsceneTimer; /* 0x2C6 */ s16 unk_2C6; /* 0x2C8 */ s16 unk_2C8; /* 0x2CA */ s16 unk_2CA; - /* 0x2CC */ f32 unk_2CC; + /* 0x2CC */ f32 animLastFrame; /* 0x2D0 */ f32 unk_2D0; - /* 0x2D4 */ s16 unk_2D4[2]; + /* 0x2D4 */ s16 cutscenes[2]; /* 0x2D8 */ UNK_TYPE1 unk2D8[4]; // maybe a part of the above? /* 0x2DC */ s16 unk_2DC; - /* 0x2DE */ s16 unk_2DE; + /* 0x2DE */ s16 cutsceneEnded; /* 0x2E0 */ s16 unk_2E0; /* 0x2E2 */ s16 unk_2E2; /* 0x2E4 */ s16 unk_2E4; /* 0x2E6 */ s16 unk_2E6; /* 0x2E8 */ s16 unk_2E8; /* 0x2EA */ s16 unk_2EA; - /* 0x2EC */ s32 unk_2EC; - /* 0x2F0 */ EnBombal* unk_2F0; - /* 0x2F4 */ s16 unk_2F4; + /* 0x2EC */ s32 animIndex; + /* 0x2F0 */ EnBombal* bombal; + /* 0x2F4 */ s16 bombalCutscene; /* 0x2F8 */ ColliderCylinder collider; } EnBomjima; // size = 0x344 -extern const ActorInit En_Bomjima_InitVars; - #endif // Z_EN_BOMJIMA_H diff --git a/src/overlays/actors/ovl_En_Bomjimb/overlay.cfg b/src/overlays/actors/ovl_En_Bomjimb/overlay.cfg deleted file mode 100644 index 3b2ee6496..000000000 --- a/src/overlays/actors/ovl_En_Bomjimb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bomjimb -z_en_bomjimb.c 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 1657e031c..c0033b103 100644 --- a/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c +++ b/src/overlays/actors/ovl_En_Bomjimb/z_en_bomjimb.c @@ -12,35 +12,35 @@ #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* play2); +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; -const ActorInit En_Bomjimb_InitVars = { +ActorInit En_Bomjimb_InitVars = { ACTOR_EN_BOMJIMB, ACTORCAT_NPC, FLAGS, @@ -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); @@ -99,48 +115,48 @@ void EnBomjimb_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_2C6 = ENBOMJIMB_F0_0; } - if ((gSaveContext.save.weekEventReg[73] & 0x10) || (gSaveContext.save.weekEventReg[85] & 2)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) { switch (this->unk_2C8) { case ENBOMJIMB_F_0: - if (gSaveContext.save.weekEventReg[11] & 1) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_11_01)) { + Actor_Kill(&this->actor); return; } break; case ENBOMJIMB_F_1: - if (gSaveContext.save.weekEventReg[11] & 2) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_11_02)) { + Actor_Kill(&this->actor); return; } break; case ENBOMJIMB_F_2: - if (gSaveContext.save.weekEventReg[11] & 4) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_11_04)) { + Actor_Kill(&this->actor); return; } break; case ENBOMJIMB_F_3: - if (gSaveContext.save.weekEventReg[11] & 8) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_11_08)) { + Actor_Kill(&this->actor); return; } break; case ENBOMJIMB_F_4: - if (gSaveContext.save.weekEventReg[11] & 0x10) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_11_10)) { + Actor_Kill(&this->actor); return; } break; } } - if ((!(gSaveContext.save.weekEventReg[73] & 0x10) && !(gSaveContext.save.weekEventReg[85] & 2)) || - (gSaveContext.save.weekEventReg[75] & 0x40)) { - Actor_MarkForDeath(&this->actor); + if ((!CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02)) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_75_40)) { + Actor_Kill(&this->actor); return; } @@ -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); @@ -329,7 +333,7 @@ void func_80C014E4(EnBomjimb* this, GlobalContext* globalCtx) { break; } - if (player->stateFlags3 != 0x1000000) { + if (player->stateFlags3 != PLAYER_STATE3_1000000) { phi_f0 = 200.0f; abs = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y)); @@ -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,21 +524,21 @@ 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; } - if (player->stateFlags3 == 0x1000000) { + if (player->stateFlags3 == PLAYER_STATE3_1000000) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 3000, 0); func_80C01494(this); 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; } @@ -627,7 +631,7 @@ void func_80C02570(EnBomjimb* this, GlobalContext* globalCtx) { this->unk_2D6 = BINANG_ROT180(this->actor.yawTowardsPlayer); func_80C0113C(this, 19, 2.0f); this->actionFunc = func_80C0217C; - } else if ((player->stateFlags3 == 0x1000000) || (this->actor.xzDistToPlayer > 410.0f)) { + } else if ((player->stateFlags3 == PLAYER_STATE3_1000000) || (this->actor.xzDistToPlayer > 410.0f)) { Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 1, 3000, 0); func_80C01494(this); } @@ -645,24 +649,24 @@ 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); + 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); - player->stateFlags1 |= 0x10000000; + Message_StartTextbox(play, 0x72E, &this->actor); + player->stateFlags1 |= PLAYER_STATE1_10000000; player->actor.freezeTimer = 3; func_80C012E0(this); this->unk_2CA = 9; @@ -670,11 +674,11 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - if (((player->transformation == PLAYER_FORM_DEKU) && !(gSaveContext.save.weekEventReg[73] & 0x10)) || - ((player->transformation == PLAYER_FORM_HUMAN) && !(gSaveContext.save.weekEventReg[85] & 2))) { + if (((player->transformation == PLAYER_FORM_DEKU) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_73_10)) || + ((player->transformation == PLAYER_FORM_HUMAN) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_85_02))) { func_80C0113C(this, 17, 1.0f); - Message_StartTextbox(globalCtx, 0x72E, &this->actor); - player->stateFlags1 |= 0x10000000; + Message_StartTextbox(play, 0x72E, &this->actor); + player->stateFlags1 |= PLAYER_STATE1_10000000; player->actor.freezeTimer = 3; func_80C012E0(this); this->unk_2CA = 9; @@ -682,55 +686,55 @@ void func_80C02740(EnBomjimb* this, GlobalContext* globalCtx) { return; } - Message_StartTextbox(globalCtx, D_80C03230[((void)0, gSaveContext.save.bombersCaughtNum)], &this->actor); + 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) { - func_801A3098(0x922); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); } switch (this->unk_2C8) { case ENBOMJIMB_F_0: - gSaveContext.save.weekEventReg[76] |= 1; - gSaveContext.save.weekEventReg[11] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_76_01); + SET_WEEKEVENTREG(WEEKEVENTREG_11_01); break; case ENBOMJIMB_F_1: - gSaveContext.save.weekEventReg[76] |= 2; - gSaveContext.save.weekEventReg[11] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_76_02); + SET_WEEKEVENTREG(WEEKEVENTREG_11_02); break; case ENBOMJIMB_F_2: - gSaveContext.save.weekEventReg[76] |= 4; - gSaveContext.save.weekEventReg[11] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_76_04); + SET_WEEKEVENTREG(WEEKEVENTREG_11_04); break; case ENBOMJIMB_F_3: - gSaveContext.save.weekEventReg[76] |= 8; - gSaveContext.save.weekEventReg[11] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_76_08); + SET_WEEKEVENTREG(WEEKEVENTREG_11_08); break; case ENBOMJIMB_F_4: - gSaveContext.save.weekEventReg[76] |= 0x10; - gSaveContext.save.weekEventReg[11] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_76_10); + SET_WEEKEVENTREG(WEEKEVENTREG_11_10); break; } - if (!Play_InCsMode(globalCtx)) { - Player* player = GET_PLAYER(globalCtx); + if (!Play_InCsMode(play)) { + Player* player = GET_PLAYER(play); - player->stateFlags1 |= 0x10000000; + player->stateFlags1 |= PLAYER_STATE1_10000000; player->actor.freezeTimer = 3; } this->unk_2CA = 8; 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) { @@ -755,61 +759,61 @@ 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; + player->stateFlags1 &= ~PLAYER_STATE1_10000000; } func_80C01FD4(this); } } } -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; + player->stateFlags1 &= ~PLAYER_STATE1_10000000; } } else if (this->actor.xzDistToPlayer > 200.0f) { func_80C01494(this); } } -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; + SET_WEEKEVENTREG(WEEKEVENTREG_75_40); + SET_WEEKEVENTREG(WEEKEVENTREG_83_04); 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) { @@ -829,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); @@ -854,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) { @@ -889,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, @@ -904,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..f411f21a2 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) @@ -61,6 +61,4 @@ typedef struct EnBomjimb { /* 0x2E8 */ ColliderCylinder collider; } EnBomjimb; // size = 0x334 -extern const ActorInit En_Bomjimb_InitVars; - #endif // Z_EN_BOMJIMB_H diff --git a/src/overlays/actors/ovl_En_Boom/overlay.cfg b/src/overlays/actors/ovl_En_Boom/overlay.cfg deleted file mode 100644 index d0ff420fd..000000000 --- a/src/overlays/actors/ovl_En_Boom/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Boom -z_en_boom.c 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 4c3f6b241..33af85b3e 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -11,15 +11,15 @@ #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 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, GlobalContext* globalCtx); +void func_808A2918(EnBoom* this, PlayState* play); -const ActorInit En_Boom_InitVars = { +ActorInit En_Boom_InitVars = { ACTOR_EN_BOOM, ACTORCAT_ITEMACTION, FLAGS, @@ -60,13 +60,12 @@ void EnBoom_SetupAction(EnBoom* this, EnBoomActionFunc actionFunc) { this->actionFunc = actionFunc; } -void func_808A24DC(EnBoom* this, GlobalContext* globalCtx) { +void func_808A24DC(EnBoom* this, PlayState* play) { WaterBox* sp54; f32 sp50 = this->actor.world.pos.y; u16 sp4E = this->actor.bgCheckFlags & 0x20; - 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)) { Vec3f sp40; @@ -74,7 +73,7 @@ void func_808A24DC(EnBoom* this, GlobalContext* globalCtx) { sp40.x = this->actor.world.pos.x; sp40.y = this->actor.world.pos.y - 20.0f; sp40.z = this->actor.world.pos.z; - EffectSsBubble_Spawn(globalCtx, &sp40, 20.0f, 10.0f, 20.0f, 0.13f); + EffectSsBubble_Spawn(play, &sp40, 20.0f, 10.0f, 20.0f, 0.13f); } else { this->actor.bgCheckFlags &= ~0x20; } @@ -93,20 +92,20 @@ void func_808A24DC(EnBoom* this, GlobalContext* globalCtx) { sp34.x = this->actor.prevPos.x + (sp34.x * temp_fv0); sp34.y = sp50; sp34.z = this->actor.prevPos.z + (sp34.z * temp_fv0); - EffectSsGSplash_Spawn(globalCtx, &sp34, NULL, NULL, 0, 300); + EffectSsGSplash_Spawn(play, &sp34, NULL, NULL, 0, 300); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DIVE_INTO_WATER_L); - EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 0); - EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 4); - EffectSsGRipple_Spawn(globalCtx, &sp34, 100, 500, 8); + 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, GlobalContext* globalCtx) { +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 }; @@ -130,21 +129,21 @@ void EnBoom_Init(Actor* thisx, GlobalContext* globalCtx) { sp30.unkFlag = 0; sp30.calcMode = 0; - Effect_Add(globalCtx, &this->effectIndex, 1, 0, 0, &sp30); + Effect_Add(play, &this->effectIndex, 1, 0, 0, &sp30); - 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); EnBoom_SetupAction(this, func_808A2918); } -void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnBoom_Destroy(Actor* thisx, PlayState* play) { EnBoom* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor* temp; if (player != NULL) { - Effect_Destroy(globalCtx, this->effectIndex); - Collider_DestroyQuad(globalCtx, &this->collider); + Effect_Destroy(play, this->effectIndex); + Collider_DestroyQuad(play, &this->collider); temp = this->actor.child; if (temp != NULL) { @@ -156,16 +155,16 @@ void EnBoom_Destroy(Actor* thisx, GlobalContext* globalCtx) { temp->child = NULL; } else { player->boomerangActor = NULL; - player->stateFlags1 &= ~0x2000000; + player->stateFlags1 &= ~PLAYER_STATE1_2000000; } } - player->stateFlags3 |= 0x800000; + player->stateFlags3 |= PLAYER_STATE3_800000; } } -void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { +void func_808A2918(EnBoom* this, PlayState* play) { Actor* sp7C; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 sp74; s16 sp72; s16 sp70; @@ -211,7 +210,7 @@ void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { Actor_SetSpeeds(&this->actor, 12.0f); Actor_MoveWithGravity(&this->actor); - func_808A24DC(this, globalCtx); + 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) && @@ -220,7 +219,7 @@ void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { (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; + this->collider.base.at->flags |= ACTOR_FLAG_2000; } } @@ -229,13 +228,13 @@ void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { Vec3f sp50; s32 pad; - sp74 = BgCheck_EntityLineTest1(&globalCtx->colCtx, &this->actor.prevPos, &this->actor.world.pos, &sp50, + 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(globalCtx, &this->actor, this->actor.wallPoly, sp5C, &sp50)) { + if (func_800B90AC(play, &this->actor, this->actor.wallPoly, sp5C, &sp50)) { sp74 = 0; } else { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, &sp50); + CollisionCheck_SpawnShieldParticlesMetal(play, &sp50); } } @@ -265,10 +264,10 @@ void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { sp7C->gravity = -0.9f; sp7C->bgCheckFlags &= ~3; } else { - sp7C->flags &= -0x2001; + sp7C->flags &= ~ACTOR_FLAG_2000; } } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -282,13 +281,13 @@ void func_808A2918(EnBoom* this, GlobalContext* globalCtx) { } } -void EnBoom_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnBoom_Update(Actor* thisx, PlayState* play) { EnBoom* this = THIS; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); Actor* actor; - if (!(player->stateFlags1 & 0x20000000)) { - this->actionFunc(this, globalCtx); + if (!(player->stateFlags1 & PLAYER_STATE1_20000000)) { + 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; @@ -317,13 +316,13 @@ EnBoomStruct D_808A3078[] = { { gameplay_keep_DL_06FF68, { -960.0f, 0.0f, 0.0f }, { 960.0f, 0.0f, 0.0f } }, }; -void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnBoom_Draw(Actor* thisx, PlayState* play) { EnBoom* this = THIS; EnBoomStruct* sp58 = &D_808A3078[this->actor.params]; Vec3f sp4C; Vec3f sp40; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); Matrix_RotateZS((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); @@ -331,15 +330,15 @@ void EnBoom_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_MultVec3f(&sp58->unk_04, &sp4C); Matrix_MultVec3f(&sp58->unk_10, &sp40); - if (func_80126440(globalCtx, &this->collider, &this->weaponInfo, &sp4C, &sp40)) { + if (func_80126440(play, &this->collider, &this->weaponInfo, &sp4C, &sp40)) { EffectBlure_AddVertex(Effect_GetByIndex(this->effectIndex), &sp4C, &sp40); } - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); Matrix_RotateYS(this->unk_1CD * 0x2EE0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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(globalCtx->state.gfxCtx); + 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 0aa09f15b..e5e3fa2b3 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -5,22 +5,20 @@ struct EnBoom; -typedef void (*EnBoomActionFunc)(struct EnBoom*, GlobalContext*); +typedef void (*EnBoomActionFunc)(struct EnBoom*, PlayState*); typedef struct EnBoom { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderQuad collider; - /* 0x01C4 */ Actor* player; - /* 0x01C8 */ Actor* unk_1C8; - /* 0x01CC */ u8 unk_1CC; - /* 0x01CD */ u8 unk_1CD; - /* 0x01CE */ u8 unk_1CE; - /* 0x01CF */ s8 unk_1CF; - /* 0x01D0 */ s32 effectIndex; - /* 0x01D4 */ WeaponInfo weaponInfo; - /* 0x01F0 */ EnBoomActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderQuad collider; + /* 0x1C4 */ Actor* player; + /* 0x1C8 */ Actor* unk_1C8; + /* 0x1CC */ u8 unk_1CC; + /* 0x1CD */ u8 unk_1CD; + /* 0x1CE */ u8 unk_1CE; + /* 0x1CF */ s8 unk_1CF; + /* 0x1D0 */ s32 effectIndex; + /* 0x1D4 */ WeaponInfo weaponInfo; + /* 0x1F0 */ EnBoomActionFunc actionFunc; } EnBoom; // size = 0x1F4 -extern const ActorInit En_Boom_InitVars; - #endif // Z_EN_BOOM_H diff --git a/src/overlays/actors/ovl_En_Box/overlay.cfg b/src/overlays/actors/ovl_En_Box/overlay.cfg deleted file mode 100644 index bdbd8b754..000000000 --- a/src/overlays/actors/ovl_En_Box/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Box -z_en_box.c 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..33dd4f69f 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -5,18 +5,58 @@ */ #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); -#if 0 -const ActorInit En_Box_InitVars = { +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(struct_80867BDC_a0* arg0, PlayState* play, s32 arg2); +void func_80867FE4(struct_80867BDC_a0* arg0, PlayState* play); + +ActorInit En_Box_InitVars = { ACTOR_EN_BOX, ACTORCAT_CHEST, FLAGS, @@ -28,66 +68,655 @@ 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(struct_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(struct_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(struct_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++, gEffFlash1DL); + } + 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(struct_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(struct_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, PLAYER_CSMODE_4); + } else if (this->unk_1A0 == 22) { + func_800B724C(play, &this->dyna.actor, PLAYER_CSMODE_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); + Audio_PlayFanfare(NA_BGM_OPEN_CHEST | 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.flags |= ACTORCTX_FLAG_3; + } + 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* gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + Gfx* gfx = gfxHead; + + gSPEndDisplayList(gfx++); + + return gfxHead; +} + +Gfx* EnBox_SetRenderMode2(GraphicsContext* gfxCtx) { + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; + + gDPSetRenderMode( + gfx++, 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(gfx++); + return gfxHead; +} + +Gfx* EnBox_SetRenderMode3(GraphicsContext* gfxCtx) { + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; + + gDPSetRenderMode(gfx++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPEndDisplayList(gfx++); + return gfxHead; +} + +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..9cb5af18d 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,69 @@ #define Z_EN_BOX_H #include "global.h" +#include "objects/object_box/object_box.h" struct EnBox; +struct struct_80867BDC_a0; -typedef void (*EnBoxActionFunc)(struct EnBox*, GlobalContext*); +typedef void (*EnBoxActionFunc)(struct EnBox*, PlayState*); +typedef void (*EnBoxUnkFunc)(struct struct_80867BDC_a0* arg0, PlayState* play); + +typedef struct struct_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; +} struct_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 */ struct_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/overlay.cfg b/src/overlays/actors/ovl_En_Bsb/overlay.cfg deleted file mode 100644 index 8542407fe..000000000 --- a/src/overlays/actors/ovl_En_Bsb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bsb -z_en_bsb.c 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..6c6e832c8 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,37 @@ */ #include "z_en_bsb.h" +#include "z64rumble.h" +#include "z64shrink_window.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 +73,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 = { @@ -110,7 +112,7 @@ static DamageTable D_80C0F9E0 = { /* Powder Keg */ DMG_ENTRY(1, 0xD), }; -const ActorInit En_Bsb_InitVars = { +ActorInit En_Bsb_InitVars = { ACTOR_EN_BSB, ACTORCAT_PROP, FLAGS, 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..f3cd4b7d6 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h @@ -5,15 +5,15 @@ struct EnBsb; -typedef void (*EnBsbActionFunc)(struct EnBsb*, GlobalContext*); +typedef void (*EnBsbActionFunc)(struct EnBsb*, PlayState*); typedef struct EnBsb { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x140]; /* 0x0284 */ EnBsbActionFunc actionFunc; - /* 0x0288 */ char unk_288[0xED0]; + /* 0x0288 */ char unk_288[0x54]; + /* 0x02DC */ s32 unk2DC; + /* 0x02E0 */ char unk2E0[0xE78]; } EnBsb; // size = 0x1158 -extern const ActorInit En_Bsb_InitVars; - #endif // Z_EN_BSB_H diff --git a/src/overlays/actors/ovl_En_Bu/overlay.cfg b/src/overlays/actors/ovl_En_Bu/overlay.cfg deleted file mode 100644 index 970a005fb..000000000 --- a/src/overlays/actors/ovl_En_Bu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bu -z_en_bu.c 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 ec0a0a6c2..043f1ebb7 100644 --- a/src/overlays/actors/ovl_En_Bu/z_en_bu.c +++ b/src/overlays/actors/ovl_En_Bu/z_en_bu.c @@ -10,14 +10,14 @@ #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 = { +ActorInit En_Bu_InitVars = { ACTOR_EN_BU, ACTORCAT_ENEMY, FLAGS, @@ -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_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..05149742f 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; @@ -14,6 +14,4 @@ typedef struct EnBu { /* 0x18C */ Gfx* displayListPtr; } EnBu; // size = 0x190 -extern const ActorInit En_Bu_InitVars; - #endif // Z_EN_BU_H diff --git a/src/overlays/actors/ovl_En_Bubble/overlay.cfg b/src/overlays/actors/ovl_En_Bubble/overlay.cfg deleted file mode 100644 index 9c86d2e3f..000000000 --- a/src/overlays/actors/ovl_En_Bubble/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Bubble -z_en_bubble.c 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..cbf9e9f3c 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -10,17 +10,16 @@ #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 EnBubble_Wait(EnBubble* this, PlayState* play); +void EnBubble_Pop(EnBubble* this, PlayState* play); +void EnBubble_Regrow(EnBubble* this, PlayState* play); -#if 0 -const ActorInit En_Bubble_InitVars = { +ActorInit En_Bubble_InitVars = { ACTOR_EN_BUBBLE, ACTORCAT_ENEMY, FLAGS, @@ -32,73 +31,396 @@ const ActorInit En_Bubble_InitVars = { (ActorFunc)EnBubble_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_808A0700[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x04 }, { 0xF7CFD757, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x04 }, + { 0xF7CFD757, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 0, { { 0, 0, 0 }, 16 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00002820, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00002820, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_NO_AT_INFO | BUMP_NO_DAMAGE | BUMP_NO_SWORD_SFX | BUMP_NO_HITMARK, + OCELEM_NONE, + }, { 0, { { 0, 0, 0 }, 16 }, 100 }, }, }; -// 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, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT6, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_808A0758 = { 1, 2, 25, 25, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 2, 25, 25, MASS_IMMOVABLE }; -#endif +void EnBubble_SetDimensions(EnBubble* this, f32 dim) { + f32 x; + f32 y; + f32 z; + f32 norm; -extern ColliderJntSphElementInit D_808A0700[2]; -extern ColliderJntSphInit D_808A0748; -extern CollisionCheckInfoInit2 D_808A0758; + this->actor.flags |= ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 1.0f); + this->actor.shape.yOffset = 16.0f; + this->modelRotSpeed = 16.0f; + this->modelEllipticity = 0.08f; + this->modelWidth = dim; + this->modelHeight = dim; + x = Rand_ZeroOne(); + y = Rand_ZeroOne(); + z = Rand_ZeroOne(); + this->unk_210 = 1.0f; + this->unk_214 = 1.0f; + norm = SQ(x) + SQ(y) + SQ(z); + this->unk1F8.x = x / norm; + this->unk1F8.y = y / norm; + this->unk1F8.z = z / norm; +} -extern UNK_TYPE D_06001000; +s32 func_8089F59C(EnBubble* this) { + ColliderInfo* info = &this->colliderSphere.elements[0].info; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F4E0.s") + info->toucher.dmgFlags = DMG_EXPLOSIVES; + info->toucher.effect = 0; + info->toucher.damage = 4; + info->toucherFlags = TOUCH_ON; + this->actor.velocity.y = 0.0f; + return 6; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F59C.s") +s32 func_8089F5D0(EnBubble* this) { + EnBubble_SetDimensions(this, -1.0f); + return 12; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F5D0.s") +void EnBubble_DamagePlayer(EnBubble* this, PlayState* play) { + play->damagePlayer(play, -this->colliderSphere.elements[0].info.toucher.damage); + func_800B8E1C(play, &this->actor, 6.0f, this->actor.yawTowardsPlayer, 6.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F5F4.s") +s32 EnBubble_Explosion(EnBubble* this, PlayState* play) { + static Color_RGBA8 sEffectPrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 sEffectEnvColor = { 150, 150, 150, 0 }; + s32 i; + Vec3f effectAccel = { 0.0f, -0.5f, 0.0f }; + Vec3f effectVel; + Vec3f effectPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F660.s") + Math_SmoothStepToF(&this->modelWidth, 4.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->modelHeight, 4.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->modelRotSpeed, 54.0f, 0.1f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->modelEllipticity, 0.2f, 0.1f, 1000.0f, 0.0f); + this->actor.shape.yOffset = (this->modelHeight + 1.0f) * 16.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F8BC.s") + if (DECR(this->explosionCountdown) != 0) { + return -1; + } + effectPos.x = this->actor.world.pos.x; + effectPos.y = this->actor.world.pos.y + this->actor.shape.yOffset; + effectPos.z = this->actor.world.pos.z; + for (i = 0; i < 20; i++) { + effectVel.x = (Rand_ZeroOne() - 0.5f) * 7.0f; + effectVel.y = Rand_ZeroOne() * 7.0f; + effectVel.z = (Rand_ZeroOne() - 0.5f) * 7.0f; + EffectSsDtBubble_SpawnCustomColor(play, &effectPos, &effectVel, &effectAccel, &sEffectPrimColor, + &sEffectEnvColor, Rand_S16Offset(100, 50), 25, 0); + } + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0x50); + this->actor.flags &= ~ACTOR_FLAG_1; + return Rand_S16Offset(90, 60); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F908.s") +s32 func_8089F8BC(EnBubble* this) { + if (DECR(this->explosionCountdown) != 0) { + return -1; + } else { + return func_8089F5D0(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F95C.s") +s32 func_8089F908(EnBubble* this) { + this->modelWidth += 1.0f / 12.0f; + this->modelHeight += 1.0f / 12.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089F9E4.s") + if (DECR(this->explosionCountdown) != 0) { + return false; + } else { + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089FA54.s") +void EnBubble_Vec3fNormalizedReflect(Vec3f* vec1, Vec3f* vec2, Vec3f* dest) { + f32 norm; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089FF30.s") + func_80179F64(vec1, vec2, dest); + norm = sqrtf(SQ(dest->x) + SQ(dest->y) + SQ(dest->z)); + if (norm != 0.0f) { + dest->x /= norm; + dest->y /= norm; + dest->z /= norm; + } else { + dest->x = dest->y = dest->z = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_8089FFCC.s") +void EnBubble_Vec3fNormalize(Vec3f* vec) { + f32 norm = sqrtf(SQ(vec->x) + SQ(vec->y) + SQ(vec->z)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A005C.s") + if (norm != 0.0f) { + vec->x /= norm; + vec->y /= norm; + vec->z /= norm; + } else { + vec->x = vec->y = vec->z = 0.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/EnBubble_Init.s") +void EnBubble_Fly(EnBubble* this, PlayState* play) { + CollisionPoly* poly; + Actor* bumpActor; + Vec3f sp84; + Vec3f sp78; + Vec3f sp6C; + Vec3f normal; + Vec3f bounceDirection; + f32 bounceSpeed; + s32 bgId; + u8 bounceCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/EnBubble_Destroy.s") + if (this->colliderSphere.elements[1].info.bumperFlags & BUMP_HIT) { + bumpActor = this->colliderSphere.base.ac; + this->normalizedBumpVelocity = bumpActor->velocity; + EnBubble_Vec3fNormalize(&this->normalizedBumpVelocity); + this->velocityFromBump.x += this->normalizedBumpVelocity.x * 3.0f; + this->velocityFromBump.y += this->normalizedBumpVelocity.y * 3.0f; + this->velocityFromBump.z += this->normalizedBumpVelocity.z * 3.0f; + } + this->yVelocity -= 0.1f; + if (this->yVelocity < this->actor.terminalVelocity) { + this->yVelocity = this->actor.terminalVelocity; + } + bounceDirection.x = this->velocityFromBounce.x + this->velocityFromBump.x; + bounceDirection.y = this->velocityFromBounce.y + this->velocityFromBump.y + this->yVelocity; + bounceDirection.z = this->velocityFromBounce.z + this->velocityFromBump.z; + EnBubble_Vec3fNormalize(&bounceDirection); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A029C.s") + sp78.x = this->actor.world.pos.x; + sp78.y = this->actor.world.pos.y + this->actor.shape.yOffset; + sp78.z = this->actor.world.pos.z; + sp6C = sp78; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A0350.s") + sp6C.x += (bounceDirection.x * 24.0f); + sp6C.y += (bounceDirection.y * 24.0f); + sp6C.z += (bounceDirection.z * 24.0f); + if (BgCheck_EntityLineTest1(&play->colCtx, &sp78, &sp6C, &sp84, &poly, true, true, true, false, &bgId)) { + normal.x = COLPOLY_GET_NORMAL(poly->normal.x); + normal.y = COLPOLY_GET_NORMAL(poly->normal.y); + normal.z = COLPOLY_GET_NORMAL(poly->normal.z); + EnBubble_Vec3fNormalizedReflect(&bounceDirection, &normal, &bounceDirection); + this->bounceDirection = bounceDirection; + bounceCount = this->bounceCount; + this->bounceCount = ++bounceCount; + if (bounceCount > (s16)(Rand_ZeroOne() * 10.0f)) { + this->bounceCount = 0; + } + bounceSpeed = (this->bounceCount == 0) ? 3.6000001f : 3.0f; + this->velocityFromBump.x = this->velocityFromBump.y = this->velocityFromBump.z = 0.0f; + this->velocityFromBounce.x = this->bounceDirection.x * bounceSpeed; + this->velocityFromBounce.y = this->bounceDirection.y * bounceSpeed; + this->velocityFromBounce.z = this->bounceDirection.z * bounceSpeed; + this->yVelocity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AWA_BOUND); + this->modelRotSpeed = 128.0f; + this->modelEllipticity = 0.48f; + } else if ((this->actor.bgCheckFlags & 0x20) && (bounceDirection.y < 0.0f)) { + normal.x = normal.z = 0.0f; + normal.y = 1.0f; + EnBubble_Vec3fNormalizedReflect(&bounceDirection, &normal, &bounceDirection); + this->bounceDirection = bounceDirection; + bounceCount = this->bounceCount; + this->bounceCount = ++bounceCount; + if (bounceCount > (s16)(Rand_ZeroOne() * 10.0f)) { + this->bounceCount = 0; + } + bounceSpeed = (this->bounceCount == 0) ? 3.6000001f : 3.0f; + this->velocityFromBump.x = this->velocityFromBump.y = this->velocityFromBump.z = 0.0f; + this->velocityFromBounce.x = (this->bounceDirection.x * bounceSpeed); + this->velocityFromBounce.y = (this->bounceDirection.y * bounceSpeed); + this->velocityFromBounce.z = (this->bounceDirection.z * bounceSpeed); + this->yVelocity = 0.0f; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AWA_BOUND); + this->modelRotSpeed = 128.0f; + this->modelEllipticity = 0.48f; + } + this->actor.velocity.x = this->velocityFromBounce.x + this->velocityFromBump.x; + this->actor.velocity.y = this->velocityFromBounce.y + this->velocityFromBump.y + this->yVelocity; + this->actor.velocity.z = this->velocityFromBounce.z + this->velocityFromBump.z; + Math_ApproachF(&this->velocityFromBump.x, 0.0f, 0.3f, 0.1f); + Math_ApproachF(&this->velocityFromBump.y, 0.0f, 0.3f, 0.1f); + Math_ApproachF(&this->velocityFromBump.z, 0.0f, 0.3f, 0.1f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A03A0.s") +s32 func_8089FF30(EnBubble* this) { + if (((this->colliderSphere.base.acFlags & AC_HIT) != 0) == false) { + return false; + } + this->colliderSphere.base.acFlags &= ~AC_HIT; + if (this->colliderSphere.elements[1].info.bumperFlags & BUMP_HIT) { + this->unk1F4.x = this->colliderSphere.base.ac->velocity.x / 10.0f; + this->unk1F4.y = this->colliderSphere.base.ac->velocity.y / 10.0f; + this->unk1F4.z = this->colliderSphere.base.ac->velocity.z / 10.0f; + this->modelRotSpeed = 128.0f; + this->modelEllipticity = 0.48f; + return false; + } + this->timer = 8; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/func_808A03E8.s") +s32 EnBubble_IsPopped(EnBubble* this, PlayState* play) { + if ((DECR(this->timer) != 0) || (this->actionFunc == EnBubble_Pop)) { + return false; + } + if (this->colliderSphere.base.ocFlags2 & OC2_HIT_PLAYER) { + this->colliderSphere.base.ocFlags2 &= ~OC2_HIT_PLAYER; + EnBubble_DamagePlayer(this, play); + this->timer = 8; + return true; + } + return func_8089FF30(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/EnBubble_Update.s") +void func_808A005C(EnBubble* this) { + ColliderJntSphElementDim* dim = &this->colliderSphere.elements[0].dim; + Vec3f src; + Vec3f dest; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bubble/EnBubble_Draw.s") + src.x = dim->modelSphere.center.x; + src.y = dim->modelSphere.center.y; + src.z = dim->modelSphere.center.z; + + Matrix_MultVec3f(&src, &dest); + dim->worldSphere.center.x = dest.x; + dim->worldSphere.center.y = dest.y; + dim->worldSphere.center.z = dest.z; + dim->worldSphere.radius = dim->modelSphere.radius * (1.0f + this->modelWidth); + this->colliderSphere.elements[1].dim = *dim; +} + +void EnBubble_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnBubble* this = THIS; + + ActorShape_Init(&this->actor.shape, 16.0f, ActorShadow_DrawCircle, 0.2f); + Collider_InitJntSph(play, &this->colliderSphere); + Collider_SetJntSph(play, &this->colliderSphere, &this->actor, &sJntSphInit, this->colliderElements); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(9), &sColChkInfoInit); + this->actor.hintId = 0x16; + this->bounceDirection.x = Rand_ZeroOne(); + this->bounceDirection.y = Rand_ZeroOne(); + this->bounceDirection.z = Rand_ZeroOne(); + EnBubble_Vec3fNormalize(&this->bounceDirection); + this->velocityFromBounce.x = this->bounceDirection.x * 3.0f; + this->velocityFromBounce.y = this->bounceDirection.y * 3.0f; + this->velocityFromBounce.z = this->bounceDirection.z * 3.0f; + EnBubble_SetDimensions(this, 0); + this->actionFunc = EnBubble_Wait; +} + +void EnBubble_Destroy(Actor* thisx, PlayState* play) { + EnBubble* this = (EnBubble*)thisx; + + Collider_DestroyJntSph(play, &this->colliderSphere); +} + +void EnBubble_Wait(EnBubble* this, PlayState* play) { + if (EnBubble_IsPopped(this, play)) { + this->explosionCountdown = func_8089F59C(this); + this->actionFunc = EnBubble_Pop; + } else { + EnBubble_Fly(this, play); + this->actor.shape.yOffset = (this->modelHeight + 1.0f) * 16.0f; + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); + } +} + +void EnBubble_Pop(EnBubble* this, PlayState* play) { + if (EnBubble_Explosion(this, play) > -1) { + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); + Actor_Kill(&this->actor); + } +} + +void EnBubble_Disappear(EnBubble* this, PlayState* play) { + s32 temp_v0 = func_8089F8BC(this); + + if (temp_v0 >= 0) { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->explosionCountdown = temp_v0; + this->actionFunc = EnBubble_Regrow; + } +} + +void EnBubble_Regrow(EnBubble* this, PlayState* play) { + if (func_8089F908(this)) { + this->actionFunc = EnBubble_Wait; + } + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderSphere.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->colliderSphere.base); +} + +void EnBubble_Update(Actor* thisx, PlayState* play) { + EnBubble* this = (EnBubble*)thisx; + + Actor_UpdatePos(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 16.0f, 16.0f, 0.0f, 7); + this->actionFunc(this, play); + Actor_SetFocus(&this->actor, this->actor.shape.yOffset); +} + +void EnBubble_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnBubble* this = (EnBubble*)thisx; + + OPEN_DISPS(play->state.gfxCtx); + + if (this->actionFunc != EnBubble_Disappear) { + func_8012C2DC(play->state.gfxCtx); + Math_SmoothStepToF(&this->modelRotSpeed, 16.0f, 0.2f, 1000.0f, 0.0f); + Math_SmoothStepToF(&this->modelEllipticity, 0.08f, 0.2f, 1000.0f, 0.0f); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(this->modelWidth + 1.0f, this->modelHeight + 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF((f32)play->state.frames) * this->modelRotSpeed, MTXMODE_APPLY); + Matrix_Scale(this->modelEllipticity + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(-(f32)play->state.frames) * this->modelRotSpeed, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); + } + + CLOSE_DISPS(play->state.gfxCtx); + + if (this->actionFunc != EnBubble_Disappear) { + this->actor.shape.shadowScale = (this->modelWidth + 1.0f) * 0.2f; + func_808A005C(this); + } +} 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..86e2358b4 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.h @@ -2,17 +2,34 @@ #define Z_EN_BUBBLE_H #include "global.h" +#include "objects/object_bubble/object_bubble.h" 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 */ ColliderJntSph colliderSphere; + /* 0x168 */ ColliderJntSphElement colliderElements[2]; + /* 0x1F4 */ Vec3f unk1F4; // set but never used + /* 0x1F4 */ Vec3f unk1F8; // randomly generated, set but never used + /* 0x200 */ s16 timer; // set to 8 when about to pop + /* 0x202 */ s16 explosionCountdown; + /* 0x204 */ UNK_TYPE1 pad204[4]; // unused + /* 0x208 */ f32 modelRotSpeed; + /* 0x20C */ f32 modelEllipticity; + /* 0x210 */ f32 unk_210; // set to 1.0f, never used + /* 0x214 */ f32 unk_214; // set to 1.0f, never used + /* 0x218 */ f32 modelWidth; + /* 0x21C */ f32 modelHeight; + /* 0x220 */ u8 bounceCount; + /* 0x224 */ Vec3f bounceDirection; + /* 0x230 */ Vec3f velocityFromBounce; + /* 0x23C */ Vec3f normalizedBumpVelocity; + /* 0x248 */ Vec3f velocityFromBump; + /* 0x254 */ f32 yVelocity; } EnBubble; // size = 0x258 -extern const ActorInit En_Bubble_InitVars; - #endif // Z_EN_BUBBLE_H diff --git a/src/overlays/actors/ovl_En_Butte/overlay.cfg b/src/overlays/actors/ovl_En_Butte/overlay.cfg deleted file mode 100644 index 04a22c108..000000000 --- a/src/overlays/actors/ovl_En_Butte/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Butte -z_en_butte.c 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 0042442ff..eb3365b83 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,11 +49,11 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; -const ActorInit En_Butte_InitVars = { +ActorInit En_Butte_InitVars = { ACTOR_EN_BUTTE, ACTORCAT_ITEMACTION, FLAGS, @@ -132,18 +132,18 @@ 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)); + 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); @@ -152,15 +152,15 @@ void func_8091C178(EnButte* this, GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); - 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; @@ -284,7 +287,8 @@ void func_8091C794(EnButte* this, GlobalContext* globalCtx) { func_8091C0A0(this, &D_8091D324[this->unk_24E]); } - if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (player->itemActionParam == 7) && (this->unk_252 <= 0) && + if ((ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) && (player->heldItemAction == PLAYER_IA_STICK) && + (this->unk_252 <= 0) && ((Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, this->actor.home.pos.x, this->actor.home.pos.z) < SQ(120.0f)) || (this->actor.xzDistToPlayer < 60.0f))) { @@ -302,9 +306,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 +322,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 +336,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); @@ -352,11 +356,11 @@ void func_8091CBB4(EnButte* this, GlobalContext* globalCtx) { distSq = Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, this->actor.home.pos.x, this->actor.home.pos.z); - if ((player->itemActionParam != 7) || !(fabsf(player->actor.speedXZ) < 1.8f) || (this->unk_252 > 0) || + if ((player->heldItemAction != PLAYER_IA_STICK) || !(fabsf(player->actor.speedXZ) < 1.8f) || (this->unk_252 > 0) || !(distSq < SQ(320.0f))) { func_8091C748(this); } else if ((distSq > SQ(240.0f)) && - (Math3D_XZDistanceSquared(player->swordInfo[0].tip.x, player->swordInfo[0].tip.z, + (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 +374,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 +395,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); + Actor_Kill(&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 +417,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 +426,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 +437,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..4bcaf440c 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,24 +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; - #endif // Z_EN_BUTTE_H diff --git a/src/overlays/actors/ovl_En_Cha/overlay.cfg b/src/overlays/actors/ovl_En_Cha/overlay.cfg deleted file mode 100644 index a409e7d55..000000000 --- a/src/overlays/actors/ovl_En_Cha/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Cha -z_en_cha.c 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 ae704672d..d32fe32ac 100644 --- a/src/overlays/actors/ovl_En_Cha/z_en_cha.c +++ b/src/overlays/actors/ovl_En_Cha/z_en_cha.c @@ -11,14 +11,14 @@ #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* play2); +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 = { +ActorInit En_Cha_InitVars = { ACTOR_EN_CHA, ACTORCAT_PROP, FLAGS, @@ -50,28 +50,28 @@ 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); this->actor.home.rot.z = 0; this->actionFunc = EnCha_Idle; this->actor.home.rot.x = this->actor.home.rot.z; - gSaveContext.save.weekEventReg[60] &= (u8)~4; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_60_04); } -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,17 +82,17 @@ void EnCha_Ring(EnCha* this, GlobalContext* globalCtx) { } } -void EnCha_Idle(EnCha* this, GlobalContext* globalCtx) { - if (gSaveContext.save.weekEventReg[60] & 4) { +void EnCha_Idle(EnCha* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_60_04)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); - gSaveContext.save.weekEventReg[60] &= (u8)~4; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_60_04); this->actor.home.rot.z = 0x7D0; } if (this->collider.base.acFlags & AC_HIT) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_DOOR_BELL); this->actor.home.rot.z = 0x7D0; - if (!(gSaveContext.save.weekEventReg[51] & 4)) { - gSaveContext.save.weekEventReg[51] |= 4; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_51_04)) { + SET_WEEKEVENTREG(WEEKEVENTREG_51_04); this->actionFunc = EnCha_Ring; } } @@ -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); + 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(globalCtx, object_cha_DL_000958); + 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..845ebc163 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; @@ -13,6 +13,4 @@ typedef struct EnCha { /* 0x190 */ EnChaActionFunc actionFunc; } EnCha; // size = 0x194 -extern const ActorInit En_Cha_InitVars; - #endif // Z_EN_CHA_H diff --git a/src/overlays/actors/ovl_En_Clear_Tag/overlay.cfg b/src/overlays/actors/ovl_En_Clear_Tag/overlay.cfg deleted file mode 100644 index edfefada0..000000000 --- a/src/overlays/actors/ovl_En_Clear_Tag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Clear_Tag -z_en_clear_tag.c 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 beb2f2d17..bfc828194 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,15 +11,27 @@ #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); -const ActorInit En_Clear_Tag_InitVars = { +void EnClearTag_UpdateEffects(EnClearTag* this, PlayState* play); +void EnClearTag_DrawEffects(Actor* thisx, PlayState* play); + +ActorInit En_Clear_Tag_InitVars = { ACTOR_EN_CLEAR_TAG, ACTORCAT_ITEMACTION, FLAGS, @@ -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; @@ -272,8 +284,8 @@ void EnClearTag_CreateLightRayEffect(EnClearTag* this, Vec3f* position, Vec3f* v effect->actionTimer = Rand_ZeroFloat(10.0f); - effect->rotationY = Math_Acot2F(effect->velocity.z, effect->velocity.x); - effect->rotationX = -Math_Acot2F(sqrtf(SQXZ(effect->velocity)), effect->velocity.y); + effect->rotationY = Math_Atan2F_XY(effect->velocity.z, effect->velocity.x); + effect->rotationX = -Math_Atan2F_XY(sqrtf(SQXZ(effect->velocity)), effect->velocity.y); effect->envColor.r = 255.0f; effect->envColor.g = 255.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; @@ -314,8 +326,8 @@ void EnClearTag_CreateIsolatedLightRayEffect(EnClearTag* this, Vec3f* position, effect->actionTimer = Rand_ZeroFloat(10.0f); - effect->rotationY = Math_Acot2F(effect->velocity.z, effect->velocity.x); - effect->rotationX = -Math_Acot2F(sqrtf(SQXZ(effect->velocity)), effect->velocity.y); + effect->rotationY = Math_Atan2F_XY(effect->velocity.z, effect->velocity.x); + effect->rotationX = -Math_Atan2F_XY(sqrtf(SQXZ(effect->velocity)), effect->velocity.y); effect->envColor.r = sLightRayEnvColor[colorIndex].x; effect->envColor.g = sLightRayEnvColor[colorIndex].y; @@ -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; @@ -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); @@ -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, PLAYER_CSMODE_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, PLAYER_CSMODE_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,11 +611,11 @@ 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); + Actor_Kill(&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,7 +820,7 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { } // Draw the debris effect. - Matrix_Translate(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_RotateYF(effect->rotationY, MTXMODE_APPLY); Matrix_RotateXFApply(effect->rotationX); @@ -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); + 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,8 +862,7 @@ 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); + 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); @@ -878,11 +888,10 @@ 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_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&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_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); @@ -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_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&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_Translate(effect->position.x, effect->position.y, effect->position.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&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,7 +962,7 @@ 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_Translate(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_RotateYF(effect->rotationY, MTXMODE_APPLY); Matrix_RotateXFApply(effect->rotationX); Matrix_RotateZF(effect->rotationZ, MTXMODE_APPLY); @@ -972,7 +980,7 @@ 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++; @@ -986,22 +994,22 @@ void EnClearTag_DrawEffects(Actor* thisx, GlobalContext* globalCtx) { * 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_Translate(effect->position.x + vec.x, ySurface, effect->position.z + vec.z, MTXMODE_NEW); + 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..677fcc698 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]; @@ -51,6 +41,4 @@ typedef struct EnClearTag { /* 0x2E78 */ Vec3f subCamAt; } EnClearTag; // size = 0x2E84 -extern const ActorInit En_Clear_Tag_InitVars; - #endif // Z_EN_CLEAR_TAG_H diff --git a/src/overlays/actors/ovl_En_Cne_01/overlay.cfg b/src/overlays/actors/ovl_En_Cne_01/overlay.cfg deleted file mode 100644 index 7678c1374..000000000 --- a/src/overlays/actors/ovl_En_Cne_01/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Cne_01 -z_en_cne_01.c 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 1a35e8e50..876914a2a 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,16 +11,16 @@ #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 = { +ActorInit En_Cne_01_InitVars = { ACTOR_EN_CNE_01, ACTORCAT_NPC, FLAGS, @@ -89,70 +89,70 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0), }; -static TurnOptionsSet sTurnOptions = { +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); +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)) { point.x = player->actor.world.pos.x; - point.y = player->bodyPartsPos[7].y + 3.0f; + point.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->enHy.actor.focus.pos, &this->enHy.actor.shape.rot, &this->enHy.turnTarget, - &this->enHy.headRot, &this->enHy.torsoRot, &sTurnOptions); + 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.turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->enHy.turnTarget.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.tmpTurnTarget = this->enHy.turnTarget; - 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_IA_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; @@ -160,85 +160,86 @@ 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->turnTarget = this->tmpTurnTarget; - 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); + Actor_Kill(&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 }; @@ -249,12 +250,12 @@ s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } 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] = VIRTUAL_TO_PHYSICAL(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] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.skelLowerObjIndex].segment); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == CNE_LIMB_HEAD) { Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); @@ -268,7 +269,7 @@ s32 EnCne01_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_RotateZS(-this->enHy.torsoRot.x, MTXMODE_APPLY); } - if ((limbIndex == CNE_LIMB_HEAD) && this->enHy.inMsgState3 && ((globalCtx->state.frames % 2) == 0)) { + if ((limbIndex == CNE_LIMB_HEAD) && this->enHy.inMsgState3 && ((play->state.frames % 2) == 0)) { Matrix_Translate(40.0f, 0.0f, 0.0f, MTXMODE_APPLY); } @@ -281,16 +282,16 @@ 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] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->enHy.skelUpperObjIndex].segment); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == CNE_LIMB_HEAD) { @@ -298,23 +299,23 @@ void EnCne01_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } -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, SUBS_SHADOW_TEX_SIZE); + 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_RotateXS(0, MTXMODE_NEW); @@ -326,7 +327,7 @@ void EnCne01_Draw(Actor* thisx, GlobalContext* globalCtx) { SubS_GenShadowTex(this->enHy.bodyPartsPos, &this->enHy.actor.world.pos, shadowTex, i / 5.0f, ARRAY_COUNT(this->enHy.bodyPartsPos), gEnHyShadowSizes, gEnHyParentBodyParts); } - SubS_DrawShadowTex(&this->enHy.actor, &globalCtx->state, shadowTex); + 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..253025760 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,16 +5,13 @@ 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; /* 0x3EC */ UNK_TYPE1 unk_3EC[0x230]; } EnCne01; // size = 0x61C -extern const ActorInit En_Cne_01_InitVars; - #endif // Z_EN_CNE_01_H diff --git a/src/overlays/actors/ovl_En_Col_Man/overlay.cfg b/src/overlays/actors/ovl_En_Col_Man/overlay.cfg deleted file mode 100644 index 4f2df34a6..000000000 --- a/src/overlays/actors/ovl_En_Col_Man/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Col_Man -z_en_col_man.c 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..63c83f0ea 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 = { { @@ -47,7 +47,7 @@ static ColliderCylinderInit sCylinderInit = { { 10, 11, 1, { 0, 0, 0 } }, }; -const ActorInit En_Col_Man_InitVars = { +ActorInit En_Col_Man_InitVars = { ACTOR_EN_COL_MAN, ACTORCAT_MISC, FLAGS, @@ -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,14 +87,14 @@ 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) { - if (!(gSaveContext.save.weekEventReg[56] & 2)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_56_02)) { this->actor.draw = func_80AFE414; this->actor.shape.yOffset = 700.0f; if (this->actor.params == EN_COL_MAN_HEART_PIECE) { @@ -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; @@ -123,24 +123,24 @@ void func_80AFDE00(EnColMan* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; } } - if (!(gSaveContext.save.weekEventReg[56] & 2)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_56_02)) { 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); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_56_02)) { + 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)) { - gSaveContext.save.weekEventReg[56] |= 2; - Actor_MarkForDeath(&this->actor); +void EnColMan_SetHeartPieceCollectedAndKill(EnColMan* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + SET_WEEKEVENTREG(WEEKEVENTREG_56_02); + Actor_Kill(&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,11 +179,11 @@ 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); } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -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) { @@ -211,65 +211,65 @@ void func_80AFE25C(EnColMan* this, GlobalContext* globalCtx) { } Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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++, gHeartPieceInteriorDL); + 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); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); + 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); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropBombTex)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); + 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..977bf2473 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; @@ -24,6 +24,4 @@ typedef enum { /* 4 */ EN_COL_MAN_GAMEPLAY_BOMB, } EnColManType; -extern const ActorInit En_Col_Man_InitVars; - #endif // Z_EN_COL_MAN_H diff --git a/src/overlays/actors/ovl_En_Cow/overlay.cfg b/src/overlays/actors/ovl_En_Cow/overlay.cfg deleted file mode 100644 index d7215aa84..000000000 --- a/src/overlays/actors/ovl_En_Cow/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Cow -z_en_cow.c 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 c3396fe29..4e9040d83 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -10,24 +10,24 @@ #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* play2); +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* thisx, PlayState* play); +void EnCow_DrawTail(Actor* thisx, PlayState* play); -const ActorInit En_Cow_InitVars = { +ActorInit En_Cow_InitVars = { ACTOR_EN_COW, ACTORCAT_NPC, FLAGS, @@ -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,23 +106,23 @@ 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; - if (!(gSaveContext.save.weekEventReg[22] & 1) && (CURRENT_DAY != 1) && + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01) && (CURRENT_DAY != 1) && (EN_COW_TYPE(thisx) == EN_COW_TYPE_ABDUCTED)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); 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); @@ -153,19 +153,19 @@ void EnCow_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); this->flags = 0; - gSaveContext.save.weekEventReg[87] &= (u8)~1; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_87_01); } -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; @@ -289,26 +289,26 @@ void EnCow_Idle(EnCow* this, GlobalContext* globalCtx) { if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { if (func_801A5100() == 4) { - if (!(gSaveContext.save.weekEventReg[87] & 1)) { - gSaveContext.save.weekEventReg[87] |= 1; - if (Interface_HasEmptyBottle()) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_87_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_87_01); + 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 { - gSaveContext.save.weekEventReg[87] &= (u8)~1; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_87_01); } } - 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,7 +410,7 @@ 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) { @@ -418,18 +418,18 @@ void EnCow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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..3c73b747f 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; @@ -32,6 +32,4 @@ typedef struct EnCow { /* 0x0274 */ EnCowActionFunc actionFunc; } EnCow; // size = 0x278 -extern const ActorInit En_Cow_InitVars; - #endif // Z_EN_COW_H diff --git a/src/overlays/actors/ovl_En_Crow/overlay.cfg b/src/overlays/actors/ovl_En_Crow/overlay.cfg deleted file mode 100644 index deb12c01d..000000000 --- a/src/overlays/actors/ovl_En_Crow/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Crow -z_en_crow.c 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 3ab93e1be..b9e1071fe 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -10,24 +10,24 @@ #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 = { +ActorInit En_Crow_InitVars = { ACTOR_EN_CROW, ACTORCAT_ENEMY, FLAGS, @@ -62,77 +62,90 @@ 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), - ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GUAY, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), 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,23 +334,22 @@ 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); + Actor_Kill(&this->actor); return; } EnCrow_SetupDie(this); @@ -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_MultVecX(2500.0f, this->bodyPartsPos); - return; - } - if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || - (limbIndex == OBJECT_CROW_LIMB_TAIL)) { + } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || + (limbIndex == OBJECT_CROW_LIMB_TAIL)) { Matrix_MultZero(&this->bodyPartsPos[(limbIndex >> 1) - 1]); } } -void EnCrow_Draw(Actor* thisx, 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..527f822f6 100644 --- a/src/overlays/actors/ovl_En_Crow/z_en_crow.h +++ b/src/overlays/actors/ovl_En_Crow/z_en_crow.h @@ -4,28 +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; - #endif // Z_EN_CROW_H diff --git a/src/overlays/actors/ovl_En_Dai/overlay.cfg b/src/overlays/actors/ovl_En_Dai/overlay.cfg deleted file mode 100644 index 6a1c6a929..000000000 --- a/src/overlays/actors/ovl_En_Dai/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dai -z_en_dai.c 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 184a8b81b..2f2496f57 100644 --- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c +++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c @@ -11,15 +11,15 @@ #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 = { +ActorInit En_Dai_InitVars = { ACTOR_EN_DAI, ACTORCAT_NPC, FLAGS, @@ -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) { @@ -76,61 +75,60 @@ void func_80B3E168(EnDaiParticle* particle, GlobalContext* globalCtx2) { 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_Translate(particle->unk_10.x, particle->unk_10.y, particle->unk_10.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&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_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 != CS_STATE_0) && (play->sceneId == SCENE_12HAKUGINMAE) && + (play->csCtx.currentCsIndex == 0) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_30_01)) { 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; @@ -194,18 +192,18 @@ s32 func_80B3E69C(EnDai* this, GlobalContext* globalCtx) { } else if (this->unk_1CE & 0x10) { this->unk_1CE &= ~0x10; this->unk_1CE |= 0x200; - gSaveContext.save.weekEventReg[30] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_30_01); this->actionFunc = func_80B3F00C; } 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); + } else if (!(player->stateFlags2 & PLAYER_STATE2_8000000)) { + 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); @@ -525,7 +522,7 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_1CE = 0; this->unk_1D6 = 0; - if (gSaveContext.save.weekEventReg[33] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { SubS_UpdateFlags(&this->unk_1CE, 3, 7); this->unk_1CE |= 0x80; this->unk_1CD = 0xFF; @@ -533,8 +530,8 @@ void EnDai_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (gSaveContext.save.weekEventReg[30] & 1) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_30_01)) { + Actor_Kill(&this->actor); return; } @@ -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); - if (!(player->stateFlags2 & 0x8000000)) { + this->actionFunc(this, play); + if (!(player->stateFlags2 & PLAYER_STATE2_8000000)) { SkelAnime_Update(&this->skelAnime); func_80B3E834(this); if (!(this->unk_1CE & 0x200)) { - func_8013C964(&this->actor, globalCtx, 0.0f, 0.0f, EXCH_ITEM_NONE, this->unk_1CE & 7); + func_8013C964(&this->actor, play, 0.0f, 0.0f, PLAYER_IA_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; @@ -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; @@ -615,7 +612,7 @@ void EnDai_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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.lensActorsDrawn) { 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_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_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_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..4dc059c39 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,11 +41,9 @@ 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 -extern const ActorInit En_Dai_InitVars; - #endif // Z_EN_DAI_H diff --git a/src/overlays/actors/ovl_En_Daiku/overlay.cfg b/src/overlays/actors/ovl_En_Daiku/overlay.cfg deleted file mode 100644 index cde668b4b..000000000 --- a/src/overlays/actors/ovl_En_Daiku/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Daiku -z_en_daiku.c 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..263b22ada 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -11,17 +11,17 @@ #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 = { +ActorInit En_Daiku_InitVars = { ACTOR_EN_DAIKU, ACTORCAT_NPC, FLAGS, @@ -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; } @@ -77,12 +88,11 @@ void EnDaiku_Init(Actor* thisx, GlobalContext* globalCtx) { this->collider.dim.height = 60; this->collider.dim.yShift = 0; this->actor.flags |= ACTOR_FLAG_8000000; - if ((gSaveContext.save.weekEventReg[63] & 0x80) || - ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_80) || ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_Kill(&this->actor); } } else if ((gSaveContext.save.day == 3) && gSaveContext.save.isNight) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } Math_Vec3f_Copy(&this->unk_26C, &this->actor.world.pos); @@ -94,17 +104,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,30 +122,21 @@ 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) { if ((this->unk_288 != -1) && (this->unk_258 != 0)) { if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_26C)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } @@ -165,13 +166,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 +183,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 +222,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 +232,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 +243,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; @@ -257,11 +258,11 @@ void EnDaiku_Update(Actor* thisx, GlobalContext* globalCtx) { } if ((this->unk_278 == ENDAIKU_PARAMS_FF_0) && (gSaveContext.save.day == 3) && (gSaveContext.save.isNight)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); if (this->unk_27C != 0) { this->unk_27C--; @@ -277,14 +278,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 +295,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 +304,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 +314,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 +346,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..fa161e9fd 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); @@ -45,6 +45,4 @@ typedef struct EnDaiku { /* 0x29C */ ColliderCylinder collider; } EnDaiku; // size = 0x2E8 -extern const ActorInit En_Daiku_InitVars; - #endif // Z_EN_DAIKU_H diff --git a/src/overlays/actors/ovl_En_Daiku2/overlay.cfg b/src/overlays/actors/ovl_En_Daiku2/overlay.cfg deleted file mode 100644 index c5eafa2b8..000000000 --- a/src/overlays/actors/ovl_En_Daiku2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Daiku2 -z_en_daiku2.c 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 167c11835..0e5e7a3ea 100644 --- a/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c +++ b/src/overlays/actors/ovl_En_Daiku2/z_en_daiku2.c @@ -13,26 +13,26 @@ #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 = { +ActorInit En_Daiku2_InitVars = { ACTOR_EN_DAIKU2, ACTORCAT_NPC, FLAGS, @@ -71,53 +71,53 @@ static ColliderCylinderInit sCylinderInit = { void func_80BE61D0(EnDaiku2* this) { if ((this->unk_27A != -1) && (this->unk_258 != 0)) { if (!SubS_CopyPointFromPath(this->unk_258, this->unk_25C, &this->unk_268)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } -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) { if (day == 3) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } 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); } } else if (day != 3) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } 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,11 +163,11 @@ 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; - if (gSaveContext.save.weekEventReg[64] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_64_02)) { this->unk_28A = 6; } func_80BE6408(this, 8); @@ -174,7 +175,7 @@ void func_80BE65B4(EnDaiku2* this, GlobalContext* globalCtx) { case 1: this->unk_28A = 2; - if (gSaveContext.save.weekEventReg[64] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_64_04)) { this->unk_28A = 7; } func_80BE6408(this, 8); @@ -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,18 +305,18 @@ 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: - gSaveContext.save.weekEventReg[64] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_64_02); break; case 1: - gSaveContext.save.weekEventReg[64] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_64_04); 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,87 +476,87 @@ 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) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { Matrix_Push(); - Matrix_Translate(particle->unk_04.x, particle->unk_04.y, particle->unk_04.z, MTXMODE_NEW); - Matrix_RotateXS(particle->unk_28.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->unk_28.y, MTXMODE_APPLY); - Matrix_RotateZS(particle->unk_28.z, MTXMODE_APPLY); - Matrix_Scale(particle->unk_30, particle->unk_30, particle->unk_30, MTXMODE_APPLY); + 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); @@ -564,5 +566,5 @@ void func_80BE7718(EnDaiku2* this, GlobalContext* globalCtx) { } } - 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..f13b89611 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,10 +49,8 @@ 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 -extern const ActorInit En_Daiku2_InitVars; - #endif // Z_EN_DAIKU2_H diff --git a/src/overlays/actors/ovl_En_Death/overlay.cfg b/src/overlays/actors/ovl_En_Death/overlay.cfg deleted file mode 100644 index 17c27c850..000000000 --- a/src/overlays/actors/ovl_En_Death/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Death -z_en_death.c 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..dd05c2d48 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.c +++ b/src/overlays/actors/ovl_En_Death/z_en_death.c @@ -5,39 +5,40 @@ */ #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 = { +ActorInit En_Death_InitVars = { ACTOR_EN_DEATH, ACTORCAT_ENEMY, FLAGS, @@ -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 = { @@ -130,7 +131,7 @@ static CollisionCheckInfoInit2 D_808C9A30 = { 20, 28, 90, 20, 100 }; // static InitChainEntry sInitChain[] = { static InitChainEntry D_808C9A60[] = { ICHAIN_VEC3F(scale, 0, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 26, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GOMESS, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6000, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 5, ICHAIN_STOP), }; 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..16863cf83 100644 --- a/src/overlays/actors/ovl_En_Death/z_en_death.h +++ b/src/overlays/actors/ovl_En_Death/z_en_death.h @@ -5,15 +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; - #endif // Z_EN_DEATH_H diff --git a/src/overlays/actors/ovl_En_Dekubaba/overlay.cfg b/src/overlays/actors/ovl_En_Dekubaba/overlay.cfg deleted file mode 100644 index cb209dea4..000000000 --- a/src/overlays/actors/ovl_En_Dekubaba/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dekubaba -z_en_dekubaba.c 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..93d495267 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.c @@ -10,29 +10,29 @@ #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 = { +ActorInit En_Dekubaba_InitVars = { ACTOR_EN_DEKUBABA, ACTORCAT_ENEMY, FLAGS, @@ -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..848f056bf 100644 --- a/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h +++ b/src/overlays/actors/ovl_En_Dekubaba/z_en_dekubaba.h @@ -5,15 +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; - #endif // Z_EN_DEKUBABA_H diff --git a/src/overlays/actors/ovl_En_Dekunuts/overlay.cfg b/src/overlays/actors/ovl_En_Dekunuts/overlay.cfg deleted file mode 100644 index dbbc3d2ed..000000000 --- a/src/overlays/actors/ovl_En_Dekunuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dekunuts -z_en_dekunuts.c 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 9486507bc..6bc0fd8d1 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.c @@ -5,40 +5,41 @@ */ #include "z_en_dekunuts.h" +#include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4) #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 = { +ActorInit En_Dekunuts_InitVars = { ACTOR_EN_DEKUNUTS, ACTORCAT_ENEMY, FLAGS, @@ -108,19 +109,19 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_MAD_SCRUB, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), 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, &gDekuScrubSkel, &gDekuScrubIdleAnim, this->jointTable, - this->morphTable, DEKU_SCRUB_LIMB_MAX); - 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; @@ -139,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) { @@ -155,12 +156,12 @@ 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); } } @@ -173,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) { @@ -192,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) { @@ -225,7 +226,7 @@ void func_808BD78C(EnDekunuts* this) { 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) { @@ -233,8 +234,7 @@ 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); } } @@ -249,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) { @@ -264,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); @@ -284,7 +284,7 @@ void func_808BDA08(EnDekunuts* this) { this->actionFunc = func_808BDA4C; } -void func_808BDA4C(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BDA4C(EnDekunuts* this, PlayState* play) { Player* player; Vec3f sp58; s16 pitch; @@ -294,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; @@ -318,8 +318,8 @@ 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)) { @@ -345,7 +345,7 @@ void func_808BDCF0(EnDekunuts* this) { 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--; @@ -376,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; @@ -393,7 +393,7 @@ void func_808BDF60(EnDekunuts* this) { this->actionFunc = func_808BDFB8; } -void func_808BDFB8(EnDekunuts* this, GlobalContext* globalCtx) { +void func_808BDFB8(EnDekunuts* this, PlayState* play) { s16 yaw; s16 yaw2; @@ -452,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) { @@ -482,7 +482,7 @@ void func_808BE294(EnDekunuts* this, s32 arg1) { 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); @@ -499,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) { @@ -524,7 +524,7 @@ void func_808BE484(EnDekunuts* this) { 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; @@ -534,16 +534,17 @@ 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, + 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); + Actor_Kill(&this->actor); } } @@ -552,9 +553,9 @@ void func_808BE680(EnDekunuts* this) { 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); } @@ -563,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) { @@ -606,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; @@ -620,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); @@ -628,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); @@ -661,8 +662,7 @@ 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; @@ -694,7 +694,7 @@ s32 EnDekunuts_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d 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, }; @@ -727,18 +727,18 @@ void EnDekunuts_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } } -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_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, gDekuScrubFlowerDL); - 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 39d0dd954..c6672b06e 100644 --- a/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h +++ b/src/overlays/actors/ovl_En_Dekunuts/z_en_dekunuts.h @@ -6,7 +6,7 @@ struct EnDekunuts; -typedef void (*EnDekunutsActionFunc)(struct EnDekunuts*, GlobalContext*); +typedef void (*EnDekunutsActionFunc)(struct EnDekunuts*, PlayState*); #define ENDEKUNUTS_GET_FF00(thisx) (((thisx)->params >> 8) & 0xFF); @@ -36,6 +36,4 @@ typedef struct EnDekunuts { /* 0x27C */ ColliderCylinder collider; } EnDekunuts; // size = 0x2C8 -extern const ActorInit En_Dekunuts_InitVars; - #endif // Z_EN_DEKUNUTS_H diff --git a/src/overlays/actors/ovl_En_Demo_heishi/overlay.cfg b/src/overlays/actors/ovl_En_Demo_heishi/overlay.cfg deleted file mode 100644 index bff118f72..000000000 --- a/src/overlays/actors/ovl_En_Demo_heishi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Demo_heishi -z_en_demo_heishi.c 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..2a4eb1553 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,34 +5,32 @@ */ #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 = { +ActorInit En_Demo_heishi_InitVars = { ACTOR_EN_DEMO_HEISHI, ACTORCAT_NPC, FLAGS, @@ -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..9d9714b95 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; @@ -46,8 +26,6 @@ typedef struct EnDemoheishi { /* 0x270 */ s16 isTalking; /* 0x272 */ s16 textIdIndex; /* 0x274 */ ColliderCylinder colliderCylinder; -} EnDemoheishi; //size = 0x2C0 - -extern const ActorInit En_Demo_heishi_InitVars; +} EnDemoheishi; // size = 0x2C0 #endif // Z_EN_DEMO_HEISHI_H diff --git a/src/overlays/actors/ovl_En_Dg/overlay.cfg b/src/overlays/actors/ovl_En_Dg/overlay.cfg deleted file mode 100644 index b9e928116..000000000 --- a/src/overlays/actors/ovl_En_Dg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dg -z_en_dg.c 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 b56063880..d9bebb404 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.c +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.c @@ -10,33 +10,35 @@ #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); +//! TODO: this file require macros for its uses of weekEventReg -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_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); -const ActorInit En_Dg_InitVars = { +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); + +ActorInit En_Dg_InitVars = { ACTOR_EN_DG, ACTORCAT_ENEMY, FLAGS, @@ -48,14 +50,37 @@ const ActorInit En_Dg_InitVars = { (ActorFunc)EnDg_Draw, }; -static u8 D_8098C2A0 = 0; +#define DOG_FLAG_NONE 0 +#define DOG_FLAG_HELD (1 << 0) +#define DOG_FLAG_JUMP_ATTACKING (1 << 1) +#define DOG_FLAG_SWIMMING (1 << 2) +#define DOG_FLAG_BOUNCED (1 << 3) +#define DOG_FLAG_THROWN (1 << 4) +#define DOG_FLAG_FOLLOWING_BREMEN_MASK (1 << 5) -typedef struct { - s16 unk_00; - s16 unk_02; -} D_8098C2A4_s; +#define ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER 99 -static D_8098C2A4_s D_8098C2A4 = { 0x0063, 0x0000 }; +typedef enum { + /* 0 */ DOG_GRAB_STATE_NONE, + /* 1 */ DOG_GRAB_STATE_HELD, + /* 2 */ DOG_GRAB_STATE_THROWN_OR_SITTING_AFTER_THROW, +} DogGrabState; + +typedef enum { + /* 0 */ DOG_BEHAVIOR_INITIAL, // Gets immediately replaced by DOG_BEHAVIOR_DEFAULT in EnDg_Update + /* 1 */ DOG_BEHAVIOR_HUMAN, // Gets immediately replaced by DOG_BEHAVIOR_DEFAULT in EnDg_Update + /* 2 */ DOG_BEHAVIOR_GORON, + /* 3 */ DOG_BEHAVIOR_GORON_WAIT, + /* 4 */ DOG_BEHAVIOR_ZORA, + /* 5 */ DOG_BEHAVIOR_ZORA_WAIT, + /* 6 */ DOG_BEHAVIOR_DEKU, + /* 7 */ DOG_BEHAVIOR_DEKU_WAIT, + /* 8 */ DOG_BEHAVIOR_DEFAULT, +} DogBehavior; + +static u8 sIsAnyDogHeld = false; + +static s16 sBremenMaskFollowerIndex = ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER; /** * Stores the state for the dogs milling about at the Doggy Racetrack. @@ -80,7 +105,7 @@ static RacetrackDogInfo sRacetrackDogInfo[] = { /** * Stores the RacetrackDogInfo for the dog that is selected by the player. These values are just - * placeholders, and the actual value gets grabbed from sRacetrackDogInfo in func_80989E18. + * placeholders, and the actual value gets grabbed from sRacetrackDogInfo in EnDg_TryPickUp. */ static RacetrackDogInfo sSelectedRacetrackDogInfo = { DOG_COLOR_DEFAULT, -1, 0x353E }; @@ -141,7 +166,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 }, @@ -149,106 +194,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); + floorRot->x = -Math_Atan2F_XY(1.0f, -nz * ny); + floorRot->z = Math_Atan2F_XY(1.0f, -nx * ny); } } -s32 func_80989418(EnDg* this, Path* arg1, s32 arg2) { - Vec3s* sp5C = Lib_SegmentedToVirtual(arg1->points); - s32 count = arg1->count; - s32 idx = arg2; - s32 sp50 = false; - f32 phi_f12; - f32 phi_f14; - f32 sp44; - f32 sp40; - f32 sp3C; - Vec3f sp30; +s32 EnDg_HasReachedPoint(EnDg* this, Path* path, s32 pointIndex) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 pathCount = path->count; + s32 currentPoint = pointIndex; + s32 reached = false; + f32 diffX; + f32 diffZ; + f32 px; + f32 pz; + f32 d; + Vec3f point; - Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); - if (idx == 0) { - phi_f12 = sp5C[1].x - sp5C[0].x; - phi_f14 = sp5C[1].z - sp5C[0].z; - } else if (idx == count - 1) { - phi_f12 = sp5C[count - 1].x - sp5C[count - 2].x; - phi_f14 = sp5C[count - 1].z - sp5C[count - 2].z; + Math_Vec3s_ToVec3f(&point, &points[currentPoint]); + if (currentPoint == 0) { + diffX = points[1].x - points[0].x; + diffZ = points[1].z - points[0].z; + } else if (currentPoint == pathCount - 1) { + diffX = points[pathCount - 1].x - points[pathCount - 2].x; + diffZ = points[pathCount - 1].z - points[pathCount - 2].z; } else { - phi_f12 = sp5C[idx + 1].x - sp5C[idx - 1].x; - phi_f14 = sp5C[idx + 1].z - sp5C[idx - 1].z; + diffX = points[currentPoint + 1].x - points[currentPoint - 1].x; + diffZ = points[currentPoint + 1].z - points[currentPoint - 1].z; } - func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(phi_f12, phi_f14)), &sp44, &sp40, &sp3C); - if (((this->actor.world.pos.x * sp44) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { - sp50 = true; + func_8017B7F8(&point, RADF_TO_BINANG(func_80086B30(diffX, diffZ)), &px, &pz, &d); + + if (((this->actor.world.pos.x * px) + (pz * this->actor.world.pos.z) + d) > 0.0f) { + reached = true; } - return sp50; + return reached; } -s16 func_809895B4(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { +/** + * Returns the Y-rotation the dog should have to move to the next point along its path. + */ +s16 EnDg_GetYRotation(Path* path, s32 index, Vec3f* pos, f32* distSq) { Vec3s* points; f32 diffX; f32 diffZ; if (path != NULL) { points = Lib_SegmentedToVirtual(path->points); - points = &points[idx]; + points = &points[index]; diffX = points->x - pos->x; diffZ = points->z - pos->z; } else { @@ -256,36 +308,40 @@ 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)); + return RADF_TO_BINANG(Math_Atan2F_XY(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->path != NULL) { - phi_a1 = func_809895B4(this->path, this->unk_1E0, &this->actor.world.pos, &sp30); + yRotation = EnDg_GetYRotation(this->path, this->currentPoint, &this->actor.world.pos, &distSq); if (this->actor.bgCheckFlags & 8) { - phi_a1 = this->actor.wallYaw; + yRotation = this->actor.wallYaw; } - Math_SmoothStepToS(&this->actor.world.rot.y, phi_a1, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->actor.world.rot.y, yRotation, 4, 0x3E8, 1); this->actor.shape.rot.y = this->actor.world.rot.y; - if (func_80989418(this, this->path, this->unk_1E0)) { - if (this->unk_1E0 >= (this->path->count - 1)) { - this->unk_1E0 = 0; + if (EnDg_HasReachedPoint(this, this->path, this->currentPoint)) { + if (this->currentPoint >= (this->path->count - 1)) { + this->currentPoint = 0; } else { - this->unk_1E0++; + this->currentPoint++; } } - if ((this->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { + if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || + ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneId == SCENE_OMOYA))) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); - } else if (this->index == 20) { + } else if (this->index == ENDG_INDEX_ROMANI_RANCH) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); - } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { + } else if (play->sceneId == SCENE_CLOCKTOWER) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } else if (sRacetrackDogInfo[this->index].textId & 0x11) { Math_ApproachF(&this->actor.speedXZ, 1.0f, 0.2f, 1.0f); @@ -293,202 +349,237 @@ void func_80989674(EnDg* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.speedXZ, 3.5f, 0.2f, 1.0f); } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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->index + frame) % mod) == 0) { - sp38.x = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.x; - sp38.y = this->actor.world.pos.y; - sp38.z = randPlusMinusPoint5Scaled(15.0f) + this->actor.world.pos.z; - Actor_SpawnFloorDustRing(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->index == 21) || ((this->index == 20) && (globalCtx->sceneNum == SCENE_OMOYA))) { - func_80989140(&this->skelAnime, sAnimations, 1); - } else if (this->index == 20) { - func_80989140(&this->skelAnime, sAnimations, 2); - } else if (globalCtx->sceneNum == SCENE_CLOCKTOWER) { - func_80989140(&this->skelAnime, sAnimations, 2); + if ((this->index == ENDG_INDEX_SWAMP_SPIDER_HOUSE) || + ((this->index == ENDG_INDEX_ROMANI_RANCH) && (play->sceneId == 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->sceneId == SCENE_CLOCKTOWER) { + EnDg_ChangeAnim(&this->skelAnime, sAnimationInfo, DOG_ANIM_RUN); } else if (sRacetrackDogInfo[this->index].textId & 0x11) { - func_80989140(&this->skelAnime, sAnimations, 1); + 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) { +/** + * Updates the text ID in sRacetrackDogInfo based on what was set in the weekEventRegs by + * En_Aob_01. This makes it sp the proper message can be displayed when the player picks up + * the dog with the Mask of Truth equipped. + */ +void EnDg_UpdateTextId(EnDg* this) { if (this->index < 14) { + // Assuming that the weekEventRegs haven't been tampered with, then this will produce a text ID in + // the range of 0x3538 to 0x3545. if (this->index % 2) { sRacetrackDogInfo[this->index].textId = - 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (0x10 | 0x20 | 0x40 | 0x80)) >> 4); + 0x3538 + ((gSaveContext.save.weekEventReg[42 + (this->index / 2)] & 0xF0) >> 4); } else { sRacetrackDogInfo[this->index].textId = - 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & (1 | 2 | 4 | 8)); + 0x3538 + (gSaveContext.save.weekEventReg[42 + (this->index / 2)] & 0x0F); } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } - if ((sRacetrackDogInfo[this->index].textId >= 0x3547) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { + // As a sanity check, this makes sure the text ID is something in the expected range of 0x3538 to 0x3546. + if ((sRacetrackDogInfo[this->index].textId > 0x3546) || (sRacetrackDogInfo[this->index].textId < 0x3538)) { sRacetrackDogInfo[this->index].textId = 0x353E; } + // Text ID 0x353D is the text for the Romani Ranch dog, which is in the middle of the race dog block. If + // the dog ends up with this text ID, adjust it so the dog says a different message indcating it's in + // good condition. if (sRacetrackDogInfo[this->index].textId == 0x353D) { sRacetrackDogInfo[this->index].textId = 0x3538; } } -void func_80989D38(EnDg* this, GlobalContext* globalCtx) { - if (this->index == 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->index >= 0) && (this->index < 14)) { - Message_StartTextbox(globalCtx, sRacetrackDogInfo[this->index].textId, NULL); - } else if (this->index == 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) { - RacetrackDogInfo* temp; - - if ((D_8098C2A0 != 0) && !(this->unk_280 & 1)) { +/** + * Checks to see if the player picked up the dog and sets the appropriate state if they did. + */ +void EnDg_TryPickUp(EnDg* this, PlayState* play) { + if (sIsAnyDogHeld && !(this->dogFlags & DOG_FLAG_HELD)) { this->actor.flags |= ACTOR_FLAG_8000000; - this->unk_280 |= 1; - } else if ((D_8098C2A0 == 0) && (this->unk_280 & 1)) { + this->dogFlags |= DOG_FLAG_HELD; + } else if (!sIsAnyDogHeld && (this->dogFlags & DOG_FLAG_HELD)) { this->actor.flags &= ~ACTOR_FLAG_8000000; - this->unk_280 &= ~1; + this->dogFlags &= ~DOG_FLAG_HELD; } - if (Actor_HasParent(&this->actor, globalCtx)) { + if (Actor_HasParent(&this->actor, play)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_SMALL_DOG_BARK); - this->unk_290 = 1; + this->grabState = DOG_GRAB_STATE_HELD; sSelectedRacetrackDogInfo = sRacetrackDogInfo[this->index]; - if (D_8098C2A0 == 0) { + if (!sIsAnyDogHeld) { this->actor.flags |= ACTOR_FLAG_8000000; - D_8098C2A0 = 1; - this->unk_280 |= 1; + sIsAnyDogHeld = true; + this->dogFlags |= DOG_FLAG_HELD; } - func_80989140(&this->skelAnime, sAnimations, 5); + EnDg_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->index; + if (enemy->id == ACTOR_EN_DG) { + if (enemy->isTargeted) { + sBremenMaskFollowerIndex = ((EnDg*)enemy)->index; return true; } - dist = enemy->actor.xzDistToPlayer; + dist = enemy->xzDistToPlayer; if (dist < minDist) { - D_8098C2A4.unk_00 = enemy->index; + sBremenMaskFollowerIndex = ((EnDg*)enemy)->index; minDist = dist; } } - enemy = (EnDg*)enemy->actor.next; + + enemy = enemy->next; } - if (D_8098C2A4.unk_00 != 99) { + if (sBremenMaskFollowerIndex != ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER) { return true; } return false; } -void func_8098A064(EnDg* this, 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 & PLAYER_STATE3_20000000) { + if (sBremenMaskFollowerIndex == ENDG_INDEX_NO_BREMEN_MASK_FOLLOWER) { + EnDg_FindFollowerForBremenMask(play); } - if (this->index == D_8098C2A4.unk_00) { - if (!(this->unk_280 & 0x20)) { - this->unk_280 |= 0x20; - func_80989140(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_8098AF44; - } else if ((this->actionFunc == func_8098B004) || (this->actionFunc == func_8098AB48)) { - if (DECR(this->unk_292) == 0) { - this->unk_292 = 10; + if (this->index == sBremenMaskFollowerIndex) { + if (!(this->dogFlags & DOG_FLAG_FOLLOWING_BREMEN_MASK)) { + this->dogFlags |= DOG_FLAG_FOLLOWING_BREMEN_MASK; + EnDg_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->index == 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: @@ -496,7 +587,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; @@ -507,144 +598,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); @@ -652,8 +766,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) { @@ -661,7 +775,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)) { @@ -669,21 +784,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; @@ -695,16 +813,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 { @@ -713,102 +831,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 & PLAYER_STATE3_20000000) { + 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; @@ -816,30 +953,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; @@ -851,9 +992,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 & PLAYER_STATE3_20000000) { if ((this->actor.xzDistToPlayer > 40.0f) && (player->linearVelocity == 0.0f)) { Math_ApproachF(&this->actor.speedXZ, 1.5f, 0.2f, 1.0f); } else { @@ -863,41 +1004,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) { @@ -909,69 +1063,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) { @@ -980,52 +1151,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) { @@ -1035,19 +1217,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); @@ -1056,153 +1238,156 @@ 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->selectedDogIndex = -1; sSelectedRacetrackDogInfo.index = this->selectedDogIndex; - this->unk_28A = 100; + this->sitAfterThrowTimer = 100; Actor_MoveWithGravity(&this->actor); - this->unk_280 |= 0x10; - this->actionFunc = func_8098BB10; + this->dogFlags |= DOG_FLAG_THROWN; + this->actionFunc = EnDg_Thrown; } } -void func_8098BB10(EnDg* this, 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->path = SubS_GetPathByIndex(globalCtx, ENDG_GET_PATH(&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->timer = Rand_S16Offset(60, 60); + this->dogFlags = DOG_FLAG_NONE; + this->attackTimer = 20; + this->swimTimer = 10; this->index = ENDG_GET_INDEX(&this->actor); - this->unk_28C = 0; - this->unk_290 = 0; - if (globalCtx->sceneNum == SCENE_F01_B) { - this->unk_28A = 100; - func_80989BF8(this); + this->behavior = DOG_BEHAVIOR_INITIAL; + this->grabState = DOG_GRAB_STATE_NONE; + if (play->sceneId == 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->selectedDogIndex = sSelectedRacetrackDogInfo.index; - 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); + if (!(player->stateFlags1 & PLAYER_STATE1_20) || (play->sceneId != 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_MultVec3f(&sp20, &this->actor.focus.pos); - } else if (this->actionFunc != func_8098BC54) { - Matrix_MultVec3f(&sp20, &this->actor.focus.pos); + if (this->actionFunc == EnDg_SetupTalk) { + sFocusOffset.x = 5000.0f; + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); + } else if (this->actionFunc != EnDg_Talk) { + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } } } -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++); @@ -1237,12 +1422,12 @@ void EnDg_Draw(Actor* thisx, GlobalContext* globalCtx) { } Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_RotateXFApply(this->unk_294.x); - Matrix_RotateZF(this->unk_294.z, MTXMODE_APPLY); + Matrix_RotateXFApply(this->curRot.x); + Matrix_RotateZF(this->curRot.z, MTXMODE_APPLY); Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - SkelAnime_DrawFlexOpa(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 ca85d4a4d..62c01a011 100644 --- a/src/overlays/actors/ovl_En_Dg/z_en_dg.h +++ b/src/overlays/actors/ovl_En_Dg/z_en_dg.h @@ -16,10 +16,31 @@ typedef enum { struct EnDg; -typedef void (*EnDgActionFunc)(struct EnDg*, GlobalContext*); +typedef void (*EnDgActionFunc)(struct EnDg*, PlayState*); #define ENDG_GET_INDEX(thisx) (((thisx)->params & 0x3E0) >> 5) -#define ENDG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 0xA) +#define ENDG_GET_PATH(thisx) (((thisx)->params & 0xFC00) >> 10) +#define ENDG_PARAMS(path, index) ((path << 10) | (index << 5)) + +typedef enum { + /* 0 */ ENDG_INDEX_RACETRACK_0, + /* 1 */ ENDG_INDEX_RACETRACK_1, + /* 2 */ ENDG_INDEX_RACETRACK_2, + /* 3 */ ENDG_INDEX_RACETRACK_3, + /* 4 */ ENDG_INDEX_RACETRACK_4, + /* 5 */ ENDG_INDEX_RACETRACK_5, + /* 6 */ ENDG_INDEX_RACETRACK_6, + /* 7 */ ENDG_INDEX_RACETRACK_7, + /* 8 */ ENDG_INDEX_RACETRACK_8, + /* 9 */ ENDG_INDEX_RACETRACK_9, + /* 10 */ ENDG_INDEX_RACETRACK_10, + /* 11 */ ENDG_INDEX_RACETRACK_11, + /* 12 */ ENDG_INDEX_RACETRACK_12, + /* 13 */ ENDG_INDEX_RACETRACK_13, + /* 20 */ ENDG_INDEX_ROMANI_RANCH = 20, + /* 21 */ ENDG_INDEX_SWAMP_SPIDER_HOUSE, + /* 31 */ ENDG_INDEX_SOUTH_CLOCK_TOWN = 31 +} EnDgIndex; typedef struct EnDg { /* 0x000 */ Actor actor; @@ -28,22 +49,20 @@ typedef struct EnDg { /* 0x14C */ SkelAnime skelAnime; /* 0x190 */ ColliderCylinder collider; /* 0x1DC */ Path* path; - /* 0x1E0 */ s32 unk_1E0; + /* 0x1E0 */ s32 currentPoint; /* 0x1E4 */ Vec3s jointTable[DOG_LIMB_MAX]; /* 0x232 */ Vec3s morphTable[DOG_LIMB_MAX]; - /* 0x280 */ u16 unk_280; - /* 0x282 */ s16 unk_282; - /* 0x284 */ s16 unk_284; + /* 0x280 */ u16 dogFlags; + /* 0x282 */ s16 timer; + /* 0x284 */ s16 swimTimer; /* 0x286 */ s16 index; /* 0x288 */ s16 selectedDogIndex; - /* 0x28A */ s16 unk_28A; - /* 0x28C */ s16 unk_28C; - /* 0x28E */ s16 unk_28E; - /* 0x290 */ s16 unk_290; - /* 0x292 */ s16 unk_292; - /* 0x294 */ Vec3f unk_294; + /* 0x28A */ s16 sitAfterThrowTimer; + /* 0x28C */ s16 behavior; + /* 0x28E */ s16 attackTimer; + /* 0x290 */ s16 grabState; + /* 0x292 */ s16 bremenBarkTimer; + /* 0x294 */ Vec3f curRot; } EnDg; // size = 0x2A0 -extern const ActorInit En_Dg_InitVars; - #endif // Z_EN_DG_H diff --git a/src/overlays/actors/ovl_En_Dinofos/overlay.cfg b/src/overlays/actors/ovl_En_Dinofos/overlay.cfg deleted file mode 100644 index 61af26795..000000000 --- a/src/overlays/actors/ovl_En_Dinofos/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dinofos -z_en_dinofos.c 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 d093f29ff..643c167f0 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* play2); +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); @@ -57,7 +57,7 @@ void func_8089C398(EnDinofos* this); void func_8089C164(EnDinofos* this); void func_8089C244(EnDinofos* this); -const ActorInit En_Dinofos_InitVars = { +ActorInit En_Dinofos_InitVars = { ACTOR_EN_DINOFOS, ACTORCAT_ENEMY, FLAGS, @@ -180,7 +180,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 9, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -253,12 +253,12 @@ static s32 D_8089E350 = 0; static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 16, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_DINOLFOS, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -2000, ICHAIN_CONTINUE), 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, PLAYER_CSMODE_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,14 +504,14 @@ 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); this->unk_290++; if (this->unk_290 == 10) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } subCamAt.x = this->actor.world.pos.x; @@ -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); } @@ -531,7 +530,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B4A4(EnDinofos* this) { if (this->unk_290 < 10) { - func_801A2E54(NA_BGM_MINI_BOSS); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); } Animation_PlayOnce(&this->skelAnime, &object_dinofos_Anim_00C974); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; @@ -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->sceneId == 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->sceneId == 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->sceneId == 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->sceneId == 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,17 +1135,17 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); this->unk_288 = 0; } else { this->unk_288 = temp_v0; @@ -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, PLAYER_CSMODE_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) { @@ -1279,14 +1279,14 @@ s32 func_8089D60C(EnDinofos* this, GlobalContext* globalCtx) { } if (this->actor.cutscene != -1) { - func_801A2ED8(); + Audio_RestorePrevBgm(); } } - func_8089ACEC(this, globalCtx); + func_8089ACEC(this, play); func_8089AD70(this); - if (globalCtx->sceneNum == SCENE_MITURIN) { - globalCtx->envCtx.lightSettingOverride = 255; + if (play->sceneId == 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 }; @@ -1461,43 +1460,43 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* sp4C.x -= sp48->mf[3][0]; sp4C.y -= sp48->mf[3][1]; sp4C.z -= sp48->mf[3][2]; - EffectSsDFire_Spawn(globalCtx, &this->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..4284d5595 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; @@ -39,6 +39,4 @@ typedef struct EnDinofos { /* 0x5C4 */ ColliderQuad colliderQuad; } EnDinofos; // size = 0x644 -extern const ActorInit En_Dinofos_InitVars; - #endif // Z_EN_DINOFOS_H diff --git a/src/overlays/actors/ovl_En_Dnb/overlay.cfg b/src/overlays/actors/ovl_En_Dnb/overlay.cfg deleted file mode 100644 index 074d3340a..000000000 --- a/src/overlays/actors/ovl_En_Dnb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dnb -z_en_dnb.c 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 914e0f355..615383a27 100644 --- a/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c +++ b/src/overlays/actors/ovl_En_Dnb/z_en_dnb.c @@ -12,16 +12,16 @@ #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* play2); -const ActorInit En_Dnb_InitVars = { +ActorInit En_Dnb_InitVars = { ACTOR_EN_DNB, ACTORCAT_BG, FLAGS, @@ -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++) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { Matrix_Push(); - Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); + 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_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++) { + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { Matrix_Push(); - Matrix_Translate(this->particles[i].unk_0C.x, this->particles[i].unk_0C.y, this->particles[i].unk_0C.z, - MTXMODE_NEW); - Matrix_RotateXS(this->particles[i].unk_18.x, MTXMODE_APPLY); - Matrix_RotateYS(this->particles[i].unk_18.y, MTXMODE_APPLY); - Matrix_RotateZS(this->particles[i].unk_18.z, MTXMODE_APPLY); + 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_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.lensMaskSize != 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) { - static TexturePtr D_80A50CBC[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, +s32 func_80A50950(EnDnbUnkStruct* arg0, PlayState* play2) { + static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; - 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) { @@ -284,12 +282,11 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { 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_ReplaceRotation(&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])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[idx])); gSPDisplayList(POLY_XLU_DISP++, object_hanareyama_obj_DL_000020); Matrix_Pop(); @@ -297,7 +294,7 @@ s32 func_80A50950(EnDnbUnkStruct* arg0, GlobalContext* globalCtx2) { } } - 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..aa17663bf 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,16 +29,16 @@ 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; /* 0x0D38 */ EnDnbUnkStruct unk_0D38[256]; } EnDnb; // size = 0x3538 -extern const ActorInit En_Dnb_InitVars; - #endif // Z_EN_DNB_H diff --git a/src/overlays/actors/ovl_En_Dnh/overlay.cfg b/src/overlays/actors/ovl_En_Dnh/overlay.cfg deleted file mode 100644 index 85a45176f..000000000 --- a/src/overlays/actors/ovl_En_Dnh/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dnh -z_en_dnh.c 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..9413b046c 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.c @@ -10,16 +10,16 @@ #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 = { +ActorInit En_Dnh_InitVars = { ACTOR_EN_DNH, ACTORCAT_NPC, FLAGS, 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..c2331d777 100644 --- a/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h +++ b/src/overlays/actors/ovl_En_Dnh/z_en_dnh.h @@ -5,14 +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; - #endif // Z_EN_DNH_H diff --git a/src/overlays/actors/ovl_En_Dnk/overlay.cfg b/src/overlays/actors/ovl_En_Dnk/overlay.cfg deleted file mode 100644 index 93ce82d2c..000000000 --- a/src/overlays/actors/ovl_En_Dnk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dnk -z_en_dnk.c 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 62b040c9e..ee035f06b 100644 --- a/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c +++ b/src/overlays/actors/ovl_En_Dnk/z_en_dnk.c @@ -13,18 +13,18 @@ #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; -const ActorInit En_Dnk_InitVars = { +ActorInit En_Dnk_InitVars = { ACTOR_EN_DNK, ACTORCAT_NPC, FLAGS, @@ -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 }, @@ -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] = VIRTUAL_TO_PHYSICAL(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, DEKU_PALACE_GUARD_LIMB_MAX); + 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, &gDekuScrubSkel, NULL, this->jointTable, this->morphTable, + 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,64 +212,64 @@ 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; } if (this->unk_28E >= 0) { this->actionFunc = func_80A51648; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } this->unk_2A2 = D_80A521A0; 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; @@ -316,15 +316,15 @@ void func_80A51AA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* 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; @@ -393,37 +393,37 @@ void func_80A51DA4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* 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) && - (gSaveContext.sceneSetupIndex == 2)) { - func_80A52074(this, globalCtx); +void func_80A52134(EnDnk* this, PlayState* play) { + if ((play->csCtx.state != 0) && (ENDNK_GET_3C(&this->actor) == 4) && (play->sceneId == SCENE_SPOT00) && + (gSaveContext.sceneLayer == 2)) { + 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..f0665f1b5 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) @@ -40,6 +40,4 @@ typedef struct EnDnk { /* 0x2A2 */ s16 unk_2A2; } EnDnk; // size = 0x2A4 -extern const ActorInit En_Dnk_InitVars; - #endif // Z_EN_DNK_H diff --git a/src/overlays/actors/ovl_En_Dno/overlay.cfg b/src/overlays/actors/ovl_En_Dno/overlay.cfg deleted file mode 100644 index 9aa2bd93c..000000000 --- a/src/overlays/actors/ovl_En_Dno/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dno -z_en_dno.c 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 326f3fbf2..12e048955 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -2,62 +2,98 @@ * File: z_en_dno.c * Overlay: ovl_En_Dno * Description: Deku Butler + * + * This actor's name is probably short for "Dekunuts Ou (king)". This is likely a misnamed actor, + * since it uses assets from object_dnj (probably short for "Dekunuts Jii (grandfather, elderly + * person"). Note that the Deku Princess and King both call the Butler "Jii" in the Japanese text. */ #include "z_en_dno.h" #include "overlays/actors/ovl_Bg_Crace_Movebg/z_bg_crace_movebg.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_dno/object_dno.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #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); + +typedef enum { + /* 0 */ EN_DNO_ANIM_START_RACE_START, + /* 1 */ EN_DNO_ANIM_START_RACE_END, + /* 2 */ EN_DNO_ANIM_FLY, + /* 3 */ EN_DNO_ANIM_FAREWELL, + /* 4 */ EN_DNO_ANIM_GREETING, + /* 5 */ EN_DNO_ANIM_GREETING_WITH_CANDLE, + /* 6 */ EN_DNO_ANIM_PRAYER_LOOP, + /* 7 */ EN_DNO_ANIM_CLOSE_PARASOL, + /* 8 */ EN_DNO_ANIM_OPEN_PARASOL, + /* 9 */ EN_DNO_ANIM_IMPLORE_LOOP, + /* 10 */ EN_DNO_ANIM_IMPLORE_END, + /* 11 */ EN_DNO_ANIM_TALK, + /* 12 */ EN_DNO_ANIM_TALK_WITH_PARSOL_AND_CANDLE, + /* 13 */ EN_DNO_ANIM_IDLE, + /* 14 */ EN_DNO_ANIM_IDLE_WITH_CANDLE, + /* 15 */ EN_DNO_ANIM_PRAYER_START, + /* 16 */ EN_DNO_ANIM_IMPLORE_START, + /* 17 */ EN_DNO_ANIM_SHOCK_START, + /* 18 */ EN_DNO_ANIM_SHOCK_LOOP, + /* 19 */ EN_DNO_ANIM_GRIEVE, +} EnDnoAnimation; static AnimationSpeedInfo sAnimations[] = { - { &object_dno_Anim_000470, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0008F0, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dno_Anim_000F6C, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_001A50, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dno_Anim_002530, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_003320, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dno_Anim_0036D0, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_0041CC, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dno_Anim_004DD8, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_005F98, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dno_Anim_006488, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0073E4, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dno_Anim_0077A8, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_007CA4, 1.0f, ANIMMODE_LOOP, 0.0f }, - { &object_dno_Anim_008324, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_008AE4, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dno_Anim_009100, 1.0f, ANIMMODE_ONCE, 0.0f }, { &object_dno_Anim_0051E4, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_dno_Anim_005E20, 1.0f, ANIMMODE_LOOP, 0.0f }, { &object_dno_Anim_006F84, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerStartRaceStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerStartRaceEndAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerFlyAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerFarewellAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerGreetingAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerGreetingWithCandleAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerPrayerLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerCloseParasolAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerOpenParasolAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerImploreLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerImploreEndAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerTalkAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerTalkWithParasolAndCandleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerIdleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerIdleWithCandleAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerPrayerStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerImploreStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerShockStartAnim, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gDekuButlerShockLoopAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, + { &gDekuButlerGrieveAnim, 1.0f, ANIMMODE_LOOP, 0.0f }, }; -const ActorInit En_Dno_InitVars = { +ActorInit En_Dno_InitVars = { ACTOR_EN_DNO, ACTORCAT_NPC, FLAGS, - OBJECT_DNO, + OBJECT_DNJ, sizeof(EnDno), (ActorFunc)EnDno_Init, (ActorFunc)EnDno_Destroy, @@ -92,7 +128,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 +148,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)); + if (BG_CRACE_MOVEBG_GET_TYPE(actor) == BG_CRACE_MOVEBG_TYPE_OPENING) { + Flags_SetSwitch(play, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(actor)); } actor = actor->next; } @@ -138,7 +174,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,46 +182,47 @@ 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 (SubS_LineSegVsPlane(&crace->actor.home.pos, &crace->actor.home.rot, &D_80A73B2C, + if (BG_CRACE_MOVEBG_GET_TYPE(&crace->dyna.actor) == BG_CRACE_MOVEBG_TYPE_CLOSING && + !(crace->stateFlags & BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR)) { + 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->actor.home.pos, &sp7C); - Matrix_RotateYS(-crace->actor.home.rot.y, MTXMODE_NEW); + 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->stateFlags |= BG_CRACE_MOVEBG_FLAG_BUTLER_IS_BEYOND_DOOR; } } } - 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, BG_CRACE_MOVEBG_GET_SWITCH_FLAG(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); + Actor_Kill(thisx); break; } actor = actor->next; @@ -194,44 +231,47 @@ 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, - 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); - Animation_Change(&this->skelAnime, sAnimations[14].animation, 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[14].animation), sAnimations[14].mode, - sAnimations[14].morphFrames); + SkelAnime_InitFlex(play, &this->skelAnime, &gDekuButlerSkel, &gDekuButlerIdleAnim, this->jointTable, + this->morphTable, DEKU_BUTLER_LIMB_MAX); + 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[EN_DNO_ANIM_IDLE_WITH_CANDLE].animation, 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].animation), + sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].mode, + sAnimations[EN_DNO_ANIM_IDLE_WITH_CANDLE].morphFrames); this->unk_3BE = 0x3E93; this->unk_3C0 = 60.0f; this->unk_3B0 = 0; this->unk_468 = 99; this->skelAnime.playSpeed = 0.0f; - switch (ENDNO_GET_C000(thisx)) { - case ENDNO_GET_C000_0: - func_80A71788(this, globalCtx); - if (!(gSaveContext.save.weekEventReg[23] & 0x20) || (gSaveContext.save.weekEventReg[93] & 2)) { - Actor_MarkForDeath(thisx); + switch (EN_DNO_GET_C000(thisx)) { + case EN_DNO_GET_C000_0: + func_80A71788(this, play); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_93_02)) { + Actor_Kill(thisx); } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 14, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); thisx->room = -1; - gSaveContext.unk_3DD0[1] = 5; - this->lightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lightInfo); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); this->unk_3B0 |= 1; this->actionFunc = func_80A72438; this->unk_454 = 0.0f; } break; - case ENDNO_GET_C000_1: - if (gSaveContext.save.weekEventReg[23] & 0x20) { - Actor_MarkForDeath(thisx); + case EN_DNO_GET_C000_1: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { + Actor_Kill(thisx); } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); - this->unk_460 = SubS_FindActor(globalCtx, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); + this->unk_460 = SubS_FindActor(play, NULL, ACTORCAT_NPC, ACTOR_EN_DNQ); if (this->unk_460 == NULL) { - Actor_MarkForDeath(thisx); + Actor_Kill(thisx); } else { this->actionFunc = func_80A71B68; } @@ -247,101 +287,104 @@ 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); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_GRIEVE, &this->animIndex); 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)) { - if (gSaveContext.save.weekEventReg[27] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_27_01)) { if (!(this->unk_3B0 & 0x20)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); this->actor.shape.rot.y = Actor_YawBetweenActors(&this->actor, this->unk_460); } } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } } else { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } this->actionFunc = func_80A71C3C; } -void func_80A71C3C(EnDno* this, GlobalContext* globalCtx) { - switch (this->unk_32C) { - case 9: - case 16: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); +void func_80A71C3C(EnDno* this, PlayState* play) { + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_LOOP: + case EN_DNO_ANIM_IMPLORE_START: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_END, &this->animIndex); break; - case 3: - case 10: + case EN_DNO_ANIM_FAREWELL: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, &this->animIndex); } break; - case 11: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); + case EN_DNO_ANIM_TALK: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_START, &this->animIndex); break; - case 15: + case EN_DNO_ANIM_PRAYER_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); } - case 6: + case EN_DNO_ANIM_PRAYER_LOOP: Math_SmoothStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 2, 0xE38, 0x222); break; } - if ((this->unk_32C == 13) && (this->actor.xzDistToPlayer <= 120.0f)) { + if ((this->animIndex == EN_DNO_ANIM_IDLE) && (this->actor.xzDistToPlayer <= 120.0f)) { func_80A71424(&this->unk_466, 0, this->actor.yawTowardsPlayer, this->actor.shape.rot.y, 0x2000, 0x16C); } else { Math_ScaledStepToS(&this->unk_466, 0, 0x16C); } - if ((this->unk_32C != 3) && (this->unk_32C != 15) && (this->unk_32C != 6)) { + if ((this->animIndex != EN_DNO_ANIM_FAREWELL) && (this->animIndex != EN_DNO_ANIM_PRAYER_START) && + (this->animIndex != EN_DNO_ANIM_PRAYER_LOOP)) { 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_27_01)) { this->textId = 0x811; } else { this->textId = 0x80F; - gSaveContext.save.weekEventReg[27] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_27_01); } - } else if (gSaveContext.save.weekEventReg[26] & 0x80) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_26_80)) { this->textId = 0x80B; } else { this->textId = 0x80C; - gSaveContext.save.weekEventReg[26] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_26_80); } if (this->textId != 0x811) { @@ -353,140 +396,153 @@ 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) { case 0x80B: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 16, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_START, + &this->animIndex); case 0x811: - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); break; case 0x80C: case 0x80F: - if (this->unk_32C == 13) { - 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); + if (this->animIndex == EN_DNO_ANIM_IDLE) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_GREETING, + &this->animIndex); + } else if ((this->animIndex == EN_DNO_ANIM_GREETING) && + (this->skelAnime.curFrame == this->skelAnime.endFrame)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_TALK, + &this->animIndex); + Message_StartTextbox(play, this->textId, &this->actor); } break; } } break; - case 3: - if (globalCtx->msgCtx.currentTextId == 0x80B) { - switch (this->unk_32C) { - case 16: + case TEXT_STATE_3: + if (play->msgCtx.currentTextId == 0x80B) { + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_LOOP, + &this->animIndex); } Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, this->unk_460), 0x71C); break; - case 10: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_801477B4(globalCtx); - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); - func_80A71B68(this, globalCtx); + func_801477B4(play); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); + 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: + switch (this->animIndex) { + case EN_DNO_ANIM_IMPLORE_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 9, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_LOOP, + &this->animIndex); } break; - case 9: - if (Message_ShouldAdvance(globalCtx)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 10, &this->unk_32C); - globalCtx->msgCtx.msgMode = 0x44; + case EN_DNO_ANIM_IMPLORE_LOOP: + if (Message_ShouldAdvance(play)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IMPLORE_END, + &this->animIndex); + play->msgCtx.msgMode = 0x44; } break; - case 10: + case EN_DNO_ANIM_IMPLORE_END: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - func_801477B4(globalCtx); - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); - func_80A71B68(this, globalCtx); + func_801477B4(play); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); + 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; case 0x80E: - if (this->unk_32C == 11) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 3, &this->unk_32C); - } else if (this->unk_32C == 3) { + if (this->animIndex == EN_DNO_ANIM_TALK) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_FAREWELL, + &this->animIndex); + } else if (this->animIndex == EN_DNO_ANIM_FAREWELL) { if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 13, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE, + &this->animIndex); } - } else if ((this->unk_32C == 13) && Message_ShouldAdvance(globalCtx)) { - func_801477B4(globalCtx); - func_80A71B68(this, globalCtx); + } else if ((this->animIndex == EN_DNO_ANIM_IDLE) && 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; } - switch (this->unk_32C) { - case 11: - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 15, &this->unk_32C); + switch (this->animIndex) { + case EN_DNO_ANIM_TALK: + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_START, + &this->animIndex); break; - case 15: + case EN_DNO_ANIM_PRAYER_START: if (this->skelAnime.curFrame == this->skelAnime.endFrame) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 6, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_PRAYER_LOOP, + &this->animIndex); } break; } 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,86 +550,89 @@ 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); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, &this->animIndex); this->actor.textId = 0; - if (Flags_GetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor))) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&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_IA_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) { + if (this->animIndex == EN_DNO_ANIM_IDLE_WITH_CANDLE) { if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x2D8)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_GREETING_WITH_CANDLE, &this->animIndex); } - } 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); + } else if ((this->animIndex == EN_DNO_ANIM_GREETING_WITH_CANDLE) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (Flags_GetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&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); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); } break; 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); + SET_WEEKEVENTREG(WEEKEVENTREG_93_02); + 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)) && - (this->unk_32C == 8)) { + case TEXT_STATE_1: + case TEXT_STATE_CLOSING: + case TEXT_STATE_3: + if (((play->msgCtx.currentTextId == 0x800) || (play->msgCtx.currentTextId == 0x801)) && + (this->animIndex == EN_DNO_ANIM_OPEN_PARASOL)) { Math_SmoothStepToF(&this->unk_454, 1.0f, 1.0f, 0.1f, 0.01f); if (this->skelAnime.curFrame <= 23.0f) { this->unk_452 = 3; @@ -587,124 +646,128 @@ 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); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_TALK_WITH_PARSOL_AND_CANDLE, &this->animIndex); + 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); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_OPEN_PARASOL, + &this->animIndex); } 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)) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 5, &this->unk_32C); + if (this->animIndex == EN_DNO_ANIM_IDLE_WITH_CANDLE) { + if (Message_ShouldAdvance(play)) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, + EN_DNO_ANIM_GREETING_WITH_CANDLE, &this->animIndex); 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); + } else if ((this->animIndex == EN_DNO_ANIM_GREETING_WITH_CANDLE) && + (this->skelAnime.curFrame == this->skelAnime.endFrame)) { + 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) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); - func_80A714B4(this, globalCtx); +void func_80A72AE4(EnDno* this, PlayState* play) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_START_RACE_START, &this->animIndex); + 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) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 0, &this->unk_32C); +void func_80A72C04(EnDno* this, PlayState* play) { + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_START_RACE_START, &this->animIndex); 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, - ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); - SubS_ActorPathing_ComputePointInfo(globalCtx, &this->actorPath); + SubS_ActorPathing_Init(play, &this->unk_334, &this->actor, &this->actorPath, play->setupPathList, + EN_DNO_GET_7F(&this->actor), 1, 0, 1, 0); + 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, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&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 +807,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,32 +824,31 @@ s32 EnDno_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { return false; } -void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { - f32 temp_f10; +void func_80A730A0(EnDno* this, PlayState* play) { s32 phi_a2; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { phi_a2 = -1; - switch (this->unk_32C) { - case 0: + switch (this->animIndex) { + case EN_DNO_ANIM_START_RACE_START: if (this->unk_44E >= 20) { - phi_a2 = 1; + phi_a2 = EN_DNO_ANIM_START_RACE_END; } else { this->unk_44E = 20; } break; - case 1: - phi_a2 = 2; + case EN_DNO_ANIM_START_RACE_END: + phi_a2 = EN_DNO_ANIM_FLY; break; } if (phi_a2 >= 0) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->animIndex); } } - 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; @@ -794,12 +856,11 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->actorPath.pointOffset.y = 0.0f; this->actorPath.pointOffset.z = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_334); - temp_f10 = (4.0f + Math_SinS(this->unk_3AE)) * Math_SinS(this->unk_3AC); - this->actor.world.pos.y += temp_f10; + this->actor.world.pos.y += Math_SinS(this->unk_3AC) * (4.0f + Math_SinS(this->unk_3AE)); 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,34 +868,35 @@ 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)); - gSaveContext.unk_3DD0[1] = 5; + Flags_UnsetSwitch(play, EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(&this->actor)); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; 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) { if (Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x71C)) { this->unk_3B0 |= 4; this->unk_44E = 3; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 7, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_CLOSE_PARASOL, &this->animIndex); } } 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); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_IDLE_WITH_CANDLE, + &this->animIndex); + 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 +913,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; @@ -875,41 +937,42 @@ void func_80A73408(EnDno* this, GlobalContext* globalCtx) { } if (sp33) { - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, phi_a2, &this->animIndex); } } - 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)) { + if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && + (this->animIndex == EN_DNO_ANIM_SHOCK_START)) { if (0) {}; - SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 18, &this->unk_32C); + SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, EN_DNO_ANIM_SHOCK_LOOP, &this->animIndex); } } -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 +982,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 +1028,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_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); + POLY_OPA_DISP = &gfxOpa[2]; + 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_Push(); - frames = globalCtx->gameplayFrames; + frames = play->gameplayFrames; Matrix_MultVec3f(&D_80A73B40, &sp84); - func_80A711D0(this, globalCtx, &sp84); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + func_80A711D0(this, play, &sp84); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(0.15f, 0.15f, 1.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; + POLY_XLU_DISP = &gfxXlu[5]; 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..470c82ee8 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -2,36 +2,30 @@ #define Z_EN_DNO_H #include "global.h" +#include "objects/object_dnj/object_dnj.h" 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) -#define ENDNO_GET_7F0(thisx) (((thisx)->params >> 4) & 0x7F) -#define ENDNO_GET_3F80(thisx) (((thisx)->params >> 7) & 0x7F) -#define ENDNO_GET_C000(thisx) (((thisx)->params >> 0xE) & 0x3) +#define EN_DNO_GET_7F(thisx) ((thisx)->params & 0x7F) +#define EN_DNO_GET_RACE_STARTED_SWITCH_FLAG(thisx) (((thisx)->params >> 7) & 0x7F) +#define EN_DNO_GET_C000(thisx) (((thisx)->params >> 0xE) & 0x3) -enum { - /* 0x0 */ ENDNO_GET_F_0, - /* 0x1 */ ENDNO_GET_F_1, -}; - -enum { - /* 0x0 */ ENDNO_GET_C000_0, - /* 0x1 */ ENDNO_GET_C000_1, -}; +typedef enum { + /* 0x0 */ EN_DNO_GET_C000_0, + /* 0x1 */ EN_DNO_GET_C000_1, +} EnDnoUnkC000; typedef struct EnDno { /* 0x000 */ Actor actor; /* 0x144 */ EnDnoActionFunc actionFunc; /* 0x148 */ SkelAnime skelAnime; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ Vec3s jointTable[28]; - /* 0x280 */ Vec3s morphTable[28]; + /* 0x1D8 */ Vec3s jointTable[DEKU_BUTLER_LIMB_MAX]; + /* 0x280 */ Vec3s morphTable[DEKU_BUTLER_LIMB_MAX]; /* 0x328 */ s32 unk_328; - /* 0x32C */ s32 unk_32C; + /* 0x32C */ s32 animIndex; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; /* 0x340 */ ActorPathing actorPath; @@ -48,7 +42,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; @@ -56,6 +50,4 @@ typedef struct EnDno { /* 0x468 */ u8 unk_468; } EnDno; // size = 0x46C -extern const ActorInit En_Dno_InitVars; - #endif // Z_EN_DNO_H diff --git a/src/overlays/actors/ovl_En_Dnp/overlay.cfg b/src/overlays/actors/ovl_En_Dnp/overlay.cfg deleted file mode 100644 index ea78e5340..000000000 --- a/src/overlays/actors/ovl_En_Dnp/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dnp -z_en_dnp.c 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 a4ea26f37..b504e9a11 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c @@ -2,31 +2,41 @@ * File: z_en_dnp.c * Overlay: ovl_En_Dnp * Description: Deku Princess + * + * This actor's name is probably short for "Dekunuts Princess". It uses assets from object_dnq, + * which is probably short for "Dekunuts Queen". */ #include "z_en_dnp.h" -#include "objects/object_dnp/object_dnp.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #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 = { +typedef enum { + /* 0 */ EN_DNP_EYE_OPEN, + /* 1 */ EN_DNP_EYE_HALF, + /* 2 */ EN_DNP_EYE_CLOSED, + /* 3 */ EN_DNP_EYE_ANGRY, + /* 4 */ EN_DNP_EYE_MAX, +} EnDnpEyeIndex; + +ActorInit En_Dnp_InitVars = { ACTOR_EN_DNP, ACTORCAT_NPC, FLAGS, - OBJECT_DNP, + OBJECT_DNQ, sizeof(EnDnp), (ActorFunc)EnDnp_Init, (ActorFunc)EnDnp_Destroy, @@ -56,33 +66,63 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimations[] = { - { &object_dnp_Anim_0007D8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnp_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dnp_Anim_0021DC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_0026B8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnp_Anim_004D08, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnp_Anim_0071F4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnp_Anim_007960, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_008588, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnp_Anim_00A900, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_00AEB8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_00B754, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnp_Anim_00674C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_00BAD8, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnp_Anim_006B74, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_012428, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dnp_Anim_00B324, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_0115B8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dnp_Anim_00923C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnp_Anim_009AA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_00125C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnp_Anim_0017F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnp_Anim_001C1C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnp_Anim_0057AC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnp_Anim_00625C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, +typedef enum { + /* -1 */ EN_DNP_ANIM_NONE = -1, + /* 0 */ EN_DNP_ANIM_JUMP_KICK, // Can be triggered by a cutscene, but no cutscene in the final game does so + /* 1 */ EN_DNP_ANIM_HURRY, + /* 2 */ EN_DNP_ANIM_CUTSCENE_HURRY, + /* 3 */ EN_DNP_ANIM_HURRY_END, + /* 4 */ EN_DNP_ANIM_SCOLD, // Unused + /* 5 */ EN_DNP_ANIM_LAUGH_START, + /* 6 */ EN_DNP_ANIM_LAUGH_LOOP, + /* 7 */ EN_DNP_ANIM_TURN_AROUND, + /* 8 */ EN_DNP_ANIM_BOW, + /* 9 */ EN_DNP_ANIM_RUN, // Unused + /* 10 */ EN_DNP_ANIM_THINK_START, + /* 11 */ EN_DNP_ANIM_THINK_LOOP, + /* 12 */ EN_DNP_ANIM_ARMS_TOGETHER_START, + /* 13 */ EN_DNP_ANIM_ARMS_TOGETHER_LOOP, + /* 14 */ EN_DNP_ANIM_GREETING, + /* 15 */ EN_DNP_ANIM_IDLE, + /* 16 */ EN_DNP_ANIM_CUTSCENE_IDLE, + /* 17 */ EN_DNP_ANIM_UNUSED_WALK, // Unused + /* 18 */ EN_DNP_ANIM_WALK, // Can be triggered by a cutscene, but no cutscene in the final game does so + /* 19 */ EN_DNP_ANIM_ANGRY_START, + /* 20 */ EN_DNP_ANIM_ANGRY_LOOP, + /* 21 */ EN_DNP_ANIM_JUMP, + /* 22 */ EN_DNP_ANIM_BOUNCE_START, + /* 23 */ EN_DNP_ANIM_BOUNCE_LOOP, + /* 24 */ EN_DNP_ANIM_GLARE_START, + /* 25 */ EN_DNP_ANIM_GLARE_LOOP +} EnDnpAnimation; + +static AnimationInfoS sAnimationInfo[] = { + { &gDekuPrincessJumpKickAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPrincessHurryAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuPrincessHurryAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessHurryEndAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPrincessScoldAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPrincessLaughStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPrincessLaughLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessTurnAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPrincessBowAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessRunAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessThinkStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPrincessThinkLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessArmsTogetherStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPrincessArmsTogetherLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessGreetingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuPrincessIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuPrincessAngryStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPrincessAngryLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessJumpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuPrincessBounceStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPrincessBounceLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuPrincessGlareStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuPrincessGlareLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, }; static s32 D_80B3DE58[] = { @@ -90,38 +130,38 @@ static s32 D_80B3DE58[] = { }; s32 func_80B3CA20(EnDnp* this) { - if ((this->unk_340 == 2) || (this->unk_340 == 9)) { + if ((this->animIndex == EN_DNP_ANIM_CUTSCENE_HURRY) || (this->animIndex == EN_DNP_ANIM_RUN)) { if (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 9.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_TURN); } - } else if ((this->unk_340 == 24) || (this->unk_340 == 7)) { + } else if ((this->animIndex == EN_DNP_ANIM_GLARE_START) || (this->animIndex == EN_DNP_ANIM_TURN_AROUND)) { if (Animation_OnFrame(&this->skelAnime, 1.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_TURN); } - } else if (this->unk_340 == 14) { + } else if (this->animIndex == EN_DNP_ANIM_GREETING) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET); } if (Animation_OnFrame(&this->skelAnime, 22.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } - } else if (this->unk_340 == 8) { + } else if (this->animIndex == EN_DNP_ANIM_BOW) { if (Animation_OnFrame(&this->skelAnime, 9.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET); } if (Animation_OnFrame(&this->skelAnime, 18.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_GREET2); } - } else if ((this->unk_340 == 17) && (this->unk_340 == 18)) { + } else if ((this->animIndex == EN_DNP_ANIM_UNUSED_WALK) && (this->animIndex == EN_DNP_ANIM_WALK)) { if (Animation_OnFrame(&this->skelAnime, 7.0f) || Animation_OnFrame(&this->skelAnime, 15.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } - } else if (this->unk_340 == 21) { + } else if (this->animIndex == EN_DNP_ANIM_JUMP) { if (Animation_OnFrame(&this->skelAnime, 17.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } - } else if (this->unk_340 == 23) { + } else if (this->animIndex == EN_DNP_ANIM_BOUNCE_LOOP) { if (Animation_OnFrame(&this->skelAnime, 3.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DEKUHIME_WALK); } @@ -130,38 +170,38 @@ s32 func_80B3CA20(EnDnp* this) { return 0; } -s32 func_80B3CC38(EnDnp* this, s32 arg1) { +s32 EnDnp_ChangeAnim(EnDnp* this, s32 animIndex) { s32 ret = false; - if (arg1 != this->unk_340) { - this->unk_340 = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, arg1); + if (animIndex != this->animIndex) { + this->animIndex = animIndex; + ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); } 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) { - if ((this->unk_322 & 0x80) && (DECR(this->unk_334) == 0)) { - this->unk_336++; - if (this->unk_336 >= 4) { - this->unk_334 = Rand_S16Offset(30, 30); - this->unk_336 = 0; + if ((this->unk_322 & 0x80) && (DECR(this->blinkTimer) == 0)) { + this->eyeIndex++; + if (this->eyeIndex >= EN_DNP_EYE_MAX) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeIndex = EN_DNP_EYE_OPEN; } } } -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; @@ -171,19 +211,21 @@ s32 func_80B3CDA4(EnDnp* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->unk_332, temp_s0, 3, 0x2AA8, 0x1); sp30 = player->actor.world.pos; - sp30.y = player->bodyPartsPos[7].y + 3.0f; + sp30.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; sp3C = this->actor.world.pos; sp3C.y += 10.0f; pitch = Math_Vec3f_Pitch(&sp3C, &sp30); + + //! FAKE if (1) {}; Math_SmoothStepToS(&this->unk_330, pitch, 3, 0x2AA8, 0x1); 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 +240,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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20) && Actor_HasParent(&this->actor, play)) { SubS_UpdateFlags(&this->unk_322, 0, 7); this->unk_322 &= ~0x500; this->actor.parent = NULL; @@ -218,10 +260,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,52 +282,57 @@ s32 func_80B3D044(EnDnp* this, GlobalContext* globalCtx) { return ret; } -void func_80B3D11C(EnDnp* this, GlobalContext* globalCtx) { - static s32 D_80B3DE74[] = { - 0, 16, 14, 10, 18, 12, 5, 7, 2, 19, 21, 22, 24, 8, +void func_80B3D11C(EnDnp* this, PlayState* play) { + static s32 sCsAnimations[] = { + EN_DNP_ANIM_JUMP_KICK, EN_DNP_ANIM_CUTSCENE_IDLE, EN_DNP_ANIM_GREETING, + EN_DNP_ANIM_THINK_START, EN_DNP_ANIM_WALK, EN_DNP_ANIM_ARMS_TOGETHER_START, + EN_DNP_ANIM_LAUGH_START, EN_DNP_ANIM_TURN_AROUND, EN_DNP_ANIM_CUTSCENE_HURRY, + EN_DNP_ANIM_ANGRY_START, EN_DNP_ANIM_JUMP, EN_DNP_ANIM_BOUNCE_START, + EN_DNP_ANIM_GLARE_START, EN_DNP_ANIM_BOW, }; s32 temp_v0; s32 val; - if (!(gSaveContext.save.weekEventReg[29] & 0x40) && (globalCtx->sceneNum == SCENE_MITURIN) && - (globalCtx->csCtx.currentCsIndex == 0)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_29_40) && (play->sceneId == SCENE_MITURIN) && + (play->csCtx.currentCsIndex == 0)) { this->unk_322 |= 0x20; - gSaveContext.save.weekEventReg[29] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_29_40); } - 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) { + EnDnp_ChangeAnim(this, sCsAnimations[val]); + if (this->animIndex == EN_DNP_ANIM_CUTSCENE_IDLE) { this->unk_322 |= 8; } else { this->unk_322 &= ~8; } - if (this->unk_340 == 19) { + if (this->animIndex == EN_DNP_ANIM_ANGRY_START) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_DHVO04); } - if (this->unk_340 == 24) { + if (this->animIndex == EN_DNP_ANIM_GLARE_START) { this->unk_322 &= ~0x80; - this->unk_336 = 3; - this->unk_334 = 0; + this->eyeIndex = EN_DNP_EYE_ANGRY; + this->blinkTimer = 0; } } this->unk_324 = val; - if (((this->unk_340 == 10) || (this->unk_340 == 12) || (this->unk_340 == 5) || (this->unk_340 == 19) || - (this->unk_340 == 22) || (this->unk_340 == 24)) && + if (((this->animIndex == EN_DNP_ANIM_THINK_START) || (this->animIndex == EN_DNP_ANIM_ARMS_TOGETHER_START) || + (this->animIndex == EN_DNP_ANIM_LAUGH_START) || (this->animIndex == EN_DNP_ANIM_ANGRY_START) || + (this->animIndex == EN_DNP_ANIM_BOUNCE_START) || (this->animIndex == EN_DNP_ANIM_GLARE_START)) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80B3CC38(this, this->unk_340 + 1); + EnDnp_ChangeAnim(this, this->animIndex + 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 +340,27 @@ 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)) { - Actor_MarkForDeath(&this->actor); - } else if (this->unk_32E == 0) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { + if ((this->unk_32E != 0) && (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING)) { + Actor_Kill(&this->actor); + return; + } + + if (this->unk_32E == 0) { + 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_IA_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 +369,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,30 +384,30 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_23_20); } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } } -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); - this->unk_340 = -1; - func_80B3CC38(this, 15); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gDekuPrincessSkel, NULL, this->jointTable, this->morphTable, + DEKU_PRINCESS_LIMB_MAX); + this->animIndex = EN_DNP_ANIM_NONE; + EnDnp_ChangeAnim(this, EN_DNP_ANIM_IDLE); + 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; this->unk_322 |= (0x100 | 0x80 | 0x10); this->actor.gravity = -1.0f; - if (ENDNP_GET_7(&this->actor) == ENDNP_GET_7_1) { + if (EN_DNP_GET_TYPE(&this->actor) == EN_DNP_TYPE_RELEASED_FROM_BOTTLE) { this->actor.flags &= ~ACTOR_FLAG_1; Actor_SetScale(&this->actor, 0.00085000007f); SubS_UpdateFlags(&this->unk_322, 0, 7); @@ -365,54 +415,55 @@ 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) && - !(gSaveContext.save.weekEventReg[23] & 0x20)) || - ((ENDNP_GET_7(&this->actor) == ENDNP_GET_7_2) && (gSaveContext.save.weekEventReg[23] & 0x20))) { + } else if (((EN_DNP_GET_TYPE(&this->actor) == EN_DNP_TYPE_WOODFALL_TEMPLE) && + !Inventory_HasItemInBottle(ITEM_DEKU_PRINCESS) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) || + ((EN_DNP_GET_TYPE(&this->actor) == EN_DNP_TYPE_DEKU_KINGS_CHAMBER) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20))) { 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->sceneId == SCENE_MITURIN) && CHECK_WEEKEVENTREG(WEEKEVENTREG_29_40)) { this->unk_322 |= 0x20; - func_80B3CC38(this, 1); + EnDnp_ChangeAnim(this, EN_DNP_ANIM_HURRY); } this->actionFunc = func_80B3D2D4; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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); + if ((this->unk_322 & 0x400) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { + Actor_PickUp(&this->actor, play, GI_MAX, sp2C, sp28); } - func_8013C964(&this->actor, globalCtx, sp2C, sp28, EXCH_ITEM_NONE, this->unk_322 & 7); + func_8013C964(&this->actor, play, sp2C, sp28, PLAYER_IA_NONE, this->unk_322 & 7); Actor_SetFocus(&this->actor, 30.0f); - func_80B3CC80(this, globalCtx); + func_80B3CC80(this, play); } if (this->unk_322 & 0x100) { @@ -446,10 +497,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; @@ -465,7 +516,7 @@ void EnDnp_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } } - if (limbIndex == 12) { + if (limbIndex == DEKU_PRINCESS_LIMB_HEAD) { 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_Pop(); @@ -478,26 +529,26 @@ void EnDnp_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } } -void EnDnp_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_80B3DEAC[] = { - object_dnp_Tex_0103D0, - object_dnp_Tex_0105D0, - object_dnp_Tex_0107D0, - object_dnp_Tex_0109D0, +void EnDnp_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sEyeTextures[] = { + gDekuPrincessEyeOpenTex, + gDekuPrincessEyeHalfTex, + gDekuPrincessEyeClosedTex, + gDekuPrincessEyeAngryTex, }; 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])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); - 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..a41a63615 100644 --- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h +++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.h @@ -2,18 +2,19 @@ #define Z_EN_DNP_H #include "global.h" +#include "objects/object_dnq/object_dnq.h" struct EnDnp; -typedef void (*EnDnpActionFunc)(struct EnDnp*, GlobalContext*); +typedef void (*EnDnpActionFunc)(struct EnDnp*, PlayState*); -#define ENDNP_GET_7(thisx) ((thisx)->params & 7) +#define EN_DNP_GET_TYPE(thisx) ((thisx)->params & 7) -enum { - /* 0x0 */ ENDNP_GET_7_0, - /* 0x1 */ ENDNP_GET_7_1, - /* 0x2 */ ENDNP_GET_7_2, -}; +typedef enum { + /* 0x0 */ EN_DNP_TYPE_WOODFALL_TEMPLE, + /* 0x1 */ EN_DNP_TYPE_RELEASED_FROM_BOTTLE, + /* 0x2 */ EN_DNP_TYPE_DEKU_KINGS_CHAMBER, +} EnDnpType; typedef struct EnDnp { /* 0x000 */ Actor actor; @@ -22,8 +23,8 @@ typedef struct EnDnp { /* 0x18C */ ColliderCylinder collider; /* 0x1D8 */ Vec3f unk_1D8; /* 0x1E4 */ Vec3s unk_1E4; - /* 0x1EA */ Vec3s jointTable[26]; - /* 0x286 */ Vec3s morphTable[26]; + /* 0x1EA */ Vec3s jointTable[DEKU_PRINCESS_LIMB_MAX]; + /* 0x286 */ Vec3s morphTable[DEKU_PRINCESS_LIMB_MAX]; /* 0x322 */ u16 unk_322; /* 0x324 */ u8 unk_324; /* 0x328 */ s32 unk_328; @@ -31,13 +32,11 @@ typedef struct EnDnp { /* 0x32E */ s16 unk_32E; /* 0x330 */ s16 unk_330; /* 0x332 */ s16 unk_332; - /* 0x334 */ s16 unk_334; - /* 0x336 */ s16 unk_336; + /* 0x334 */ s16 blinkTimer; + /* 0x336 */ s16 eyeIndex; /* 0x338 */ s16 unk_338; /* 0x33A */ UNK_TYPE1 unk_33A[0x6]; - /* 0x340 */ s32 unk_340; + /* 0x340 */ s32 animIndex; } EnDnp; // size = 0x344 -extern const ActorInit En_Dnp_InitVars; - #endif // Z_EN_DNP_H diff --git a/src/overlays/actors/ovl_En_Dnq/overlay.cfg b/src/overlays/actors/ovl_En_Dnq/overlay.cfg deleted file mode 100644 index 169a41621..000000000 --- a/src/overlays/actors/ovl_En_Dnq/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dnq -z_en_dnq.c 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 ae7f918f1..021b94476 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c @@ -2,32 +2,34 @@ * File: z_en_dnq.c * Overlay: ovl_En_Dnq * Description: Deku King + * + * This actor's name is probably short for "Dekunuts Queen". This is likely a misnamed actor, + * since it uses assets from object_dno (probably short for "Dekunuts Ou (king)"). */ #include "z_en_dnq.h" -#include "objects/object_dnq/object_dnq.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #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, 0x0C0E089D, 0x0C0F089E, 0x0C111202, 0x100E089F, 0x0C100000, 0x0E08A10C, 0x0F08A20C, 0x10000000, }; -const ActorInit En_Dnq_InitVars = { +ActorInit En_Dnq_InitVars = { ACTOR_EN_DNQ, ACTORCAT_NPC, FLAGS, - OBJECT_DNQ, + OBJECT_DNO, sizeof(EnDnq), (ActorFunc)EnDnq_Init, (ActorFunc)EnDnq_Destroy, @@ -57,31 +59,32 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS D_80A5349C[] = { - { &object_dnq_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dnq_Anim_008328, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnq_Anim_007528, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnq_Anim_0006F0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnq_Anim_000BF8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnq_Anim_002690, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnq_Anim_002690, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnq_Anim_003408, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnq_Anim_006984, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnq_Anim_005E18, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnq_Anim_005A14, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnq_Anim_005284, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnq_Anim_001AEC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnq_Anim_001100, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dnq_Anim_004EA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnq_Anim_00F504, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnq_Anim_0047B8, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dnq_Anim_005A14, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dnq_Anim_003DBC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, +static AnimationInfoS sAnimationInfo[] = { + { &gDekuKingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gDekuKingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuKingSurpriseAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuKingJumpedOnStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuKingJumpedOnLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuKingJumpedOnEndAnim, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuKingJumpedOnEndAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuKingLyingDownTwitchAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuKingWailLoopAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuKingFootStampStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuKingFootStampLoopAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuKingWailStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuKingMarchAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuKingSpinScepterAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gDekuKingIntimidateAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuKingPointScepterAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuKingJumpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuKingLaughAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gDekuKingFootStampLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gDekuKingLaughAnim, 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 +107,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 +131,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 +199,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 +217,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 +233,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 +255,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 & PLAYER_STATE1_40) && (player->talkActor == &this->picto.actor)) { switch (temp) { case 0x89B: func_80A5257C(this, 18); @@ -292,21 +295,21 @@ 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) { - if (gSaveContext.save.weekEventReg[23] & 0x20) { +s32* func_80A52CF8(EnDnq* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { return &D_80A53400[14]; } @@ -317,12 +320,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 +333,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); @@ -340,67 +343,67 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_37C, 0, 7); } - if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { this->unk_390 = 70.0f; - if (Interface_HasItemInBottle(ITEM_DEKU_PRINCESS) && !Play_InCsMode(globalCtx) && - (Message_GetState(&globalCtx->msgCtx) == 0) && (ActorCutscene_GetCurrentIndex() == -1)) { - if ((DECR(this->unk_384) == 0) && (gSaveContext.save.weekEventReg[29] & 0x40)) { - Message_StartTextbox(globalCtx, 0x969, NULL); + 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) && CHECK_WEEKEVENTREG(WEEKEVENTREG_29_40)) { + 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_83_08)) { + 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,65 +411,65 @@ 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, &gDekuKingSkel, NULL, this->jointTable, this->morphTable, + DEKU_KING_LIMB_MAX); 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); - if (gSaveContext.save.weekEventReg[9] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_09_80)) { this->unk_3A4 = 1; } 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, EXCH_ITEM_NONE, - 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_IA_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..5afb8bdf8 100644 --- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h +++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.h @@ -2,22 +2,22 @@ #define Z_EN_DNQ_H #include "global.h" +#include "objects/object_dno/object_dno.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; /* 0x1DC */ u8 unk_1DC; /* 0x1E0 */ s32 unk_1E0; - /* 0x1E4 */ Vec3s jointTable[33]; - /* 0x2AA */ Vec3s morphTable[33]; + /* 0x1E4 */ Vec3s jointTable[DEKU_KING_LIMB_MAX]; + /* 0x2AA */ Vec3s morphTable[DEKU_KING_LIMB_MAX]; /* 0x370 */ Vec3f unk_370; /* 0x37C */ u16 unk_37C; /* 0x37E */ s16 unk_37E; @@ -35,6 +35,4 @@ typedef struct EnDnq { /* 0x3A4 */ s32 unk_3A4; } EnDnq; // size = 0x3A8 -extern const ActorInit En_Dnq_InitVars; - #endif // Z_EN_DNQ_H diff --git a/src/overlays/actors/ovl_En_Dns/overlay.cfg b/src/overlays/actors/ovl_En_Dns/overlay.cfg deleted file mode 100644 index 3fc03b217..000000000 --- a/src/overlays/actors/ovl_En_Dns/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dns -z_en_dns.c 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 1cad6dd8f..714235b17 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, @@ -39,7 +39,7 @@ static s32 D_8092DCB0[] = { 0x0E08330C, 0x09000015, 0x1C014016, 0x10000000, 0x0E082E0C, 0x10000000, }; -const ActorInit En_Dns_InitVars = { +ActorInit En_Dns_InitVars = { ACTOR_EN_DNS, ACTORCAT_NPC, FLAGS, @@ -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; @@ -146,7 +144,7 @@ void func_8092C740(EnDns* this, GlobalContext* globalCtx) { this->unk_2CE = CLAMP(this->unk_2CE, -0x3FFC, 0x3FFC); Math_Vec3f_Copy(&sp28, &player->actor.world.pos); - sp28.y = player->bodyPartsPos[7].y + 3.0f; + sp28.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; Math_Vec3f_Copy(&sp34, &this->actor.world.pos); sp34.y += 10.0f; temp = Math_Vec3f_Pitch(&sp34, &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,10 +177,10 @@ 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { if (player->transformation != PLAYER_FORM_DEKU) { return &D_8092DCB0[16]; } else if (this->unk_2FC != 0) { @@ -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; @@ -361,37 +359,37 @@ s32 func_8092D068(EnDns* this) { s32 ret = false; if (ENDNS_GET_8000(&this->actor)) { - if (gSaveContext.save.weekEventReg[23] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { ret = true; } } else if (ENDNS_GET_4000(&this->actor)) { - if ((gSaveContext.save.weekEventReg[9] & 0x80) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_09_80) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { ret = true; } - } else if (!(gSaveContext.save.weekEventReg[9] & 0x80) && !(gSaveContext.save.weekEventReg[23] & 0x20)) { + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_09_80) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { ret = true; } 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_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)) { - player->stateFlags1 |= 0x20; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20) && !CHECK_EVENTINF(EVENTINF_15) && func_8092CC68(play)) { + player->stateFlags1 |= PLAYER_STATE1_20; this->unk_2C6 |= 0x100; SubS_UpdateFlags(&this->unk_2C6, 4, 7); play_sound(NA_SE_SY_FOUND); - gSaveContext.eventInf[1] |= 0x20; + SET_EVENTINF(EVENTINF_15); 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); + } else if (CHECK_EVENTINF(EVENTINF_16)) { + 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)) { + if (!CHECK_EVENTINF(EVENTINF_15)) { 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,48 +471,47 @@ 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)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } 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; @@ -525,38 +521,38 @@ void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_2C6, 3, 7); this->unk_2C6 |= (0x40 | 0x10); this->unk_2C6 |= 0x200; - if (gSaveContext.save.weekEventReg[9] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_09_80)) { this->unk_2FC = 1; } else { this->unk_2FC = 0; } this->actionFunc = func_8092D1B8; - gSaveContext.eventInf[1] &= (u8)~0x20; - gSaveContext.eventInf[1] &= (u8)~0x40; + CLEAR_EVENTINF(EVENTINF_15); + CLEAR_EVENTINF(EVENTINF_16); } -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, EXCH_ITEM_NONE, 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_IA_NONE, this->unk_2C6 & 7); Actor_SetFocus(&this->actor, 34.0f); - func_8092C6FC(this, globalCtx); + func_8092C6FC(this, play); func_8092C5C0(this); } } @@ -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; @@ -624,15 +620,15 @@ void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve 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..b54e49a6a 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,10 +53,8 @@ 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 -extern const ActorInit En_Dns_InitVars; - #endif // Z_EN_DNS_H diff --git a/src/overlays/actors/ovl_En_Dodongo/overlay.cfg b/src/overlays/actors/ovl_En_Dodongo/overlay.cfg deleted file mode 100644 index 05d2f0a6e..000000000 --- a/src/overlays/actors/ovl_En_Dodongo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dodongo -z_en_dodongo.c 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 914ee2bca..d1ec4ea70 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -13,29 +13,29 @@ #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* play2); +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 = { +ActorInit En_Dodongo_InitVars = { ACTOR_EN_DODONGO, ACTORCAT_ENEMY, FLAGS, @@ -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, }; @@ -273,12 +273,12 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 3, 100, 100, 80 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 13, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_DODONGO, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), 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 }, @@ -295,19 +295,19 @@ void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_330.a = 200; 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,28 +572,28 @@ 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)) { if ((ABS_ALT(temp_v1) < 0x1388) && (this->actor.playerHeightRel < 60.0f) && - !(player->stateFlags1 & 0x800000)) { + !(player->stateFlags1 & PLAYER_STATE1_800000)) { func_808777A8(this); } } } 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; @@ -731,7 +729,7 @@ void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { if (Animation_OnFrame(&this->skelAnime, 28.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_J_EAT); if (this->actor.child != NULL) { - Actor_MarkForDeath(this->actor.child); + Actor_Kill(this->actor.child); this->actor.child = NULL; } this->actor.flags &= ~ACTOR_FLAG_10; @@ -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 & PLAYER_STATE1_800000) && (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); + Actor_Kill(&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[] = { @@ -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..3cc80b0d1 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; @@ -36,6 +36,4 @@ typedef struct EnDodongo { /* 0x754 */ ColliderJntSphElement collider3Elements[3]; } EnDodongo; // size = 0x814 -extern const ActorInit En_Dodongo_InitVars; - #endif // Z_EN_DODONGO_H diff --git a/src/overlays/actors/ovl_En_Door/overlay.cfg b/src/overlays/actors/ovl_En_Door/overlay.cfg deleted file mode 100644 index 9c737bc9d..000000000 --- a/src/overlays/actors/ovl_En_Door/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Door -z_en_door.c 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 fe65bb30d..3d7e79a3d 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -24,18 +24,18 @@ #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* play2); +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[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x12 - 0x04), @@ -57,7 +57,7 @@ u8 D_808675E4[] = { /* 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), + /* 0x23 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_28_08, 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(), @@ -93,14 +93,14 @@ u8 D_8086764C[] = { u8 D_80867658[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x13 - 0x04), - /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x0A - 0x08), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_28_08, 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), + /* 0x1B */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_08, 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), @@ -231,7 +231,7 @@ u8 D_8086773C[] = { u8 D_80867744[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x08 - 0x04), - /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x63, 0x80, 0x0E - 0x08), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_99_80, 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), @@ -240,12 +240,12 @@ u8 D_80867744[] = { }; u8 D_8086775C[] = { - /* 0x00 */ SCHEDULE_CMD_CHECK_FLAG_S(0x34, 0x20, 0x1B - 0x04), - /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x20, 0x1B - 0x08), - /* 0x08 */ SCHEDULE_CMD_CHECK_FLAG_S(0x0E, 0x04, 0x0E - 0x0C), + /* 0x00 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_52_20, 0x1B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_75_20, 0x1B - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_14_04, 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), + /* 0x0E */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_59_01, 0x1A - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_61_02, 0x18 - 0x16), /* 0x16 */ SCHEDULE_CMD_RET_VAL_S(30), /* 0x18 */ SCHEDULE_CMD_RET_VAL_S(31), /* 0x1A */ SCHEDULE_CMD_RET_NONE(), @@ -277,7 +277,7 @@ u8* D_8086778C[] = { D_80867734, D_8086773C, D_80867744, D_8086775C, D_80867778, D_8086777C, D_80867780, D_80867784, }; -const ActorInit En_Door_InitVars = { +ActorInit En_Door_InitVars = { ACTOR_EN_DOOR, ACTORCAT_DOOR, FLAGS, @@ -290,7 +290,7 @@ const ActorInit En_Door_InitVars = { }; typedef struct { - /* 0x00 */ s16 sceneNum; + /* 0x00 */ s16 sceneId; /* 0x02 */ u8 dListIndex; /* 0x04 */ s16 objectId; } EnDoorInfo; @@ -384,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; @@ -398,77 +398,75 @@ 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->sceneId == objectInfo->sceneId) { 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); + Actor_Kill(&this->dyna.actor); return; } } 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) { - static s32 D_80867BC0[4]; - Player* player = GET_PLAYER(globalCtx); +void func_80866B20(EnDoor* this, PlayState* play) { + static s32 D_80867BC0; + Player* player = GET_PLAYER(play); Vec3f playerPosRelToDoor; s16 temp_a2; s16 yawDiff; @@ -476,49 +474,49 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { s32 temp_t0; u8 temp_a1; - if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state) && (this->dyna.actor.textId == 0x1821)) { - D_80867BC0[0] = 1; + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state) && (this->dyna.actor.textId == 0x1821)) { + D_80867BC0 = true; } if (this->unk_1A1 != 0) { this->actionFunc = func_80867144; Animation_PlayOnceSetSpeed(&this->skelAnime, sAnimations[this->animIndex], - (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); + (player->stateFlags1 & PLAYER_STATE1_8000000) ? 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))) { + if (D_80867BC0 || ((fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && + (fabsf(playerPosRelToDoor.z) < 50.0f))) { yawDiff = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; if (playerPosRelToDoor.z > 0.0f) { yawDiff = (0x8000 - yawDiff); } if (ABS_ALT(yawDiff) < 0x3000) { - player->doorType = 1; + player->doorType = PLAYER_DOORTYPE_HANDLE; player->doorDirection = playerPosRelToDoor.z >= 0.0f ? 1.0f : -1.0f; player->doorActor = &this->dyna.actor; if (this->unk_1A6 != 0) { if (gSaveContext.save.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { - player->doorType = -1; + player->doorType = PLAYER_DOORTYPE_TALKING; this->dyna.actor.textId = 0x1802; } else { player->doorTimer = 10; } } else if (this->unk_1A4 == 4) { - player->doorType = -1; + player->doorType = PLAYER_DOORTYPE_TALKING; this->dyna.actor.textId = 0x1800; } 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)) || @@ -530,16 +528,18 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { } else if (this->unk_1A4 == 2) { baseTextId = 0x181D; } - player->doorType = -1; + player->doorType = PLAYER_DOORTYPE_TALKING; this->dyna.actor.textId = baseTextId + textIdOffset; } } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { - ScheduleResult sp30; + ScheduleOutput sp30; - if (Schedule_RunScript(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { + if (Schedule_RunScript(play, D_8086778C[this->switchFlag], &sp30)) { this->dyna.actor.textId = sp30.result + 0x1800; - player->doorType = ((this->dyna.actor.textId == 0x1821) && (D_80867BC0[0] != 0)) ? 5 : -1; + player->doorType = ((this->dyna.actor.textId == 0x1821) && D_80867BC0) + ? PLAYER_DOORTYPE_PROXIMITY + : PLAYER_DOORTYPE_TALKING; } } func_80122F28(player); @@ -551,7 +551,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) { @@ -571,13 +571,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)) { @@ -585,14 +585,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; @@ -605,7 +605,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])) { @@ -614,14 +614,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; @@ -633,15 +632,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 { @@ -655,18 +654,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); @@ -675,8 +674,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..bea44a122 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) @@ -26,6 +26,4 @@ typedef struct EnDoor { /* 0x1C8 */ EnDoorActionFunc actionFunc; } EnDoor; -extern const ActorInit En_Door_InitVars; - #endif // Z_EN_DOOR_H diff --git a/src/overlays/actors/ovl_En_Door_Etc/overlay.cfg b/src/overlays/actors/ovl_En_Door_Etc/overlay.cfg deleted file mode 100644 index fa6a13d8a..000000000 --- a/src/overlays/actors/ovl_En_Door_Etc/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Door_Etc -z_en_door_etc.c 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..8959dde7a 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 @@ -5,17 +5,22 @@ */ #include "z_en_door_etc.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10) #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* play2); +void EnDoorEtc_Destroy(Actor* thisx, PlayState* play); +void EnDoorEtc_Update(Actor* thisx, PlayState* play); -#if 0 -const ActorInit En_Door_Etc_InitVars = { +void EnDoorEtc_WaitForObject(EnDoorEtc* this, PlayState* play); +void func_80AC21A0(EnDoorEtc* this, PlayState* play); +void func_80AC2354(EnDoorEtc* this, PlayState* play); +void EnDoorEtc_Draw(Actor* thisx, PlayState* play); + +ActorInit En_Door_Etc_InitVars = { ACTOR_EN_DOOR_ETC, ACTORCAT_DOOR, FLAGS, @@ -27,42 +32,219 @@ const ActorInit En_Door_Etc_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AC25A0 = { - { 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, + }, { 100, 40, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC2634[] = { +typedef struct { + /* 0x0 */ s16 sceneId; + /* 0x2 */ u8 dListIndex; + /* 0x4 */ s16 objectId; +} EnDoorEtcInfo; // size = 0x6 + +EnDoorEtcInfo sObjInfo[] = { + { SCENE_MITURIN, 1, OBJECT_NUMA_OBJ }, + { -1, 0, GAMEPLAY_KEEP }, + { -1, 13, GAMEPLAY_FIELD_KEEP }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, + { 0, 0, OBJECT_UNSET_0 }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.x, 0, ICHAIN_CONTINUE), ICHAIN_U16(shape.rot.z, 0, ICHAIN_STOP), }; -#endif +void EnDoorEtc_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + s32 objectIndex; + EnDoorEtcInfo* objectInfo = sObjInfo; + s32 i; + EnDoorEtc* this = THIS; -extern ColliderCylinderInit D_80AC25A0; -extern InitChainEntry D_80AC2634[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.x = -0x4000; + this->angle = 0; + for (i = 0; i < 15; i++, objectInfo++) { + if (play->sceneId == objectInfo->sceneId) { + break; + } + } + if ((i >= 15) && (Object_GetIndex(&play->objectCtx, GAMEPLAY_FIELD_KEEP) >= 0)) { + objectInfo++; + } + objectIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); + if (objectIndex < 0) { + Actor_Kill(&this->actor); + } else { + this->objectIndex = objectIndex; + this->dListIndex = objectInfo->dListIndex; + if (this->actor.objBankIndex == this->objectIndex) { + EnDoorEtc_WaitForObject(this, play); + } else { + this->actionFunc = EnDoorEtc_WaitForObject; + } + } + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Init.s") +void EnDoorEtc_Destroy(Actor* thisx, PlayState* play) { + EnDoorEtc* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2044.s") +/** + * Calculates if the distance between `a` and `b` is greater than distance `c` + */ +s32 EnDoorEtc_IsDistanceGreater(Vec3f* a, Vec3f* b, f32 c) { + f32 dx = b->x - a->x; + f32 dy = b->y - a->y; + f32 dz = b->z - a->z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC20A8.s") + return ((SQ(dx) + SQ(dy) + SQ(dz)) < SQ(c)); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2118.s") +void EnDoorEtc_WaitForObject(EnDoorEtc* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { + this->actor.flags &= ~ACTOR_FLAG_10; + this->actor.objBankIndex = this->objectIndex; + this->actionFunc = func_80AC2354; + this->actor.draw = EnDoorEtc_Draw; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2154.s") +void func_80AC2118(EnDoorEtc* this, PlayState* play) { + if (this->angle < 0) { + this->angle += 0x100; + } else { + this->angle = 0; + this->actionFunc = func_80AC21A0; + this->unk_1F4 &= ~1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC21A0.s") +void func_80AC2154(EnDoorEtc* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + } else if (this->angle > -0x4000) { + this->angle -= 0x800; + } else { + this->angle = -0x4000; + this->actionFunc = func_80AC2118; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC2354.s") +void func_80AC21A0(EnDoorEtc* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f playerOffsetFromDoor; + s32 pad; + s16 yawDiff; + s32 yawDiffAbs; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/EnDoorEtc_Update.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &playerOffsetFromDoor, &player->actor.world.pos); + if (this->unk_1A1 == 0) { + if ((!Player_InCsMode(play)) && + ((fabsf(playerOffsetFromDoor.y) < 20.0f) && fabsf(playerOffsetFromDoor.x) < 20.0f) && + (fabsf(playerOffsetFromDoor.z) < 50.0f)) { + yawDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; + if (playerOffsetFromDoor.z > 0.0f) { + yawDiff = 0x8000 - yawDiff; + } + yawDiffAbs = ABS_ALT(yawDiff); + if (yawDiffAbs < 0x3000) { + player->doorDirection = (playerOffsetFromDoor.z >= 0.0f) ? 1.0f : -1.0f; + player->doorActor = &this->actor; + player->doorType = -1; + } + } + } + if ((this->actor.textId == 0x239B) && Flags_GetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->actor))) { + Flags_UnsetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->actor)); + this->actionFunc = func_80AC2154; + this->actor.textId = 0x1800; // "It won't budge!" + this->unk_1F4 |= 1; + this->timer = 0x5A; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Door_Etc/func_80AC24A8.s") +void func_80AC2354(EnDoorEtc* this, PlayState* play) { + Actor* door = play->actorCtx.actorLists[ACTORCAT_DOOR].first; + + while (door != NULL) { + if ((door->id != ACTOR_EN_DOOR) || + !EnDoorEtc_IsDistanceGreater(&door->world.pos, &this->actor.world.pos, 10.0f)) { + door = door->next; + } else { + this->actor.world.pos.x = door->world.pos.x; + this->actor.world.pos.y = door->world.pos.y; + this->actor.world.pos.z = door->world.pos.z; + this->actor.shape.rot.y = door->shape.rot.y; + this->actor.world.rot.y = door->world.rot.y; + Actor_Kill(door); + this->actionFunc = func_80AC21A0; + this->actor.textId = 0x239B; + Actor_SetFocus(&this->actor, 70.0f); + break; + } + } +} + +void EnDoorEtc_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnDoorEtc* this = THIS; + + this->actionFunc(this, play); + if (this->unk_1F4 & 1) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } +} + +void EnDoorEtc_Draw(Actor* thisx, PlayState* play) { + EnDoorEtc* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + Matrix_Translate(-2900.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_RotateZS(this->angle, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gDoorLeftDL); + gSPDisplayList(POLY_OPA_DISP++, gDoorRightDL); + + CLOSE_DISPS(play->state.gfxCtx); +} 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..49ca83f2a 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,14 +5,21 @@ struct EnDoorEtc; -typedef void (*EnDoorEtcActionFunc)(struct EnDoorEtc*, GlobalContext*); +#define ENDOORETC_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) + +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 pad_144[0x5D]; + /* 0x1A1 */ u8 unk_1A1; + /* 0x1A2 */ s8 objectIndex; + /* 0x1A3 */ u8 dListIndex; // Never read, inferred from ovl_En_Door + /* 0x1A4 */ s16 angle; + /* 0x1A6 */ s16 timer; + /* 0x1A8 */ ColliderCylinder collider; + /* 0x1F4 */ u8 unk_1F4; + /* 0x1F8 */ EnDoorEtcActionFunc actionFunc; } EnDoorEtc; // size = 0x1FC -extern const ActorInit En_Door_Etc_InitVars; - #endif // Z_EN_DOOR_ETC_H diff --git a/src/overlays/actors/ovl_En_Dragon/overlay.cfg b/src/overlays/actors/ovl_En_Dragon/overlay.cfg deleted file mode 100644 index 2720fb7f1..000000000 --- a/src/overlays/actors/ovl_En_Dragon/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dragon -z_en_dragon.c 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 a37d8f828..83b93cf52 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.c @@ -10,26 +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; + /* 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, @@ -50,7 +50,7 @@ typedef enum { static s32 sNumPythonsDead = 0; -const ActorInit En_Dragon_InitVars = { +ActorInit En_Dragon_InitVars = { ACTOR_EN_DRAGON, ACTORCAT_ENEMY, FLAGS, @@ -206,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 = @@ -242,17 +242,17 @@ void EnDragon_Init(Actor* thisx, GlobalContext* globalCtx) { this->pythonIndex = EN_DRAGON_GET_PYTHON_INDEX(&this->actor); this->actor.colChkInfo.mass = MASS_IMMOVABLE; this->action = DEEP_PYTHON_ACTION_IDLE; - this->actor.hintId = 0xE; + this->actor.hintId = TATL_HINT_ID_DEEP_PYTHON; this->scale = 0.5f; this->actor.flags &= ~ACTOR_FLAG_8000000; 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[] = { @@ -264,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[] = { @@ -290,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; @@ -316,20 +316,21 @@ 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, - &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, 0); + EffectSsDtBubble_SpawnCustomColor(play, &bubblePos, &sBubbleVelocity, &sBubbleAccel, + &sBubblePrimColors[colorIndex], &sBubbleEnvColors[colorIndex], scale, 30, + false); } } -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; @@ -338,7 +339,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); @@ -366,12 +367,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); @@ -397,8 +398,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; @@ -419,8 +420,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; @@ -430,7 +431,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; } @@ -445,15 +446,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; @@ -471,17 +472,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 }, }; @@ -490,12 +491,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) { @@ -507,37 +508,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, PLAYER_CSMODE_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; @@ -547,8 +549,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; @@ -557,35 +559,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); + func_800B8E58((Player*)this, player->ageProperties->voiceSfxIdOffset + 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; @@ -593,30 +595,30 @@ 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++; } if (((this->state != DEEP_PYTHON_ATTACK_STATE_START) && (this->endFrame <= currentFrame)) || - (!(player->stateFlags2 & 0x80)) || ((this->collider.elements[0].info.bumperFlags & BUMP_HIT)) || + (!(player->stateFlags2 & PLAYER_STATE2_80)) || ((this->collider.elements[0].info.bumperFlags & BUMP_HIT)) || (this->collider.elements[1].info.bumperFlags & BUMP_HIT) || (this->collider.elements[2].info.bumperFlags & BUMP_HIT)) { player->actor.parent = NULL; this->grabWaitTimer = 30; ActorCutscene_Stop(this->grabCutsceneIndex); - if (player->stateFlags2 & 0x80) { + if (player->stateFlags2 & PLAYER_STATE2_80) { player->unk_AE8 = 100; } @@ -631,7 +633,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 { @@ -643,21 +645,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); } } @@ -679,50 +681,50 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_13_01); switch (this->pythonIndex) { case 0: - gSaveContext.save.weekEventReg[83] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_83_10); break; case 1: - gSaveContext.save.weekEventReg[83] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_83_20); break; case 2: - gSaveContext.save.weekEventReg[83] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_83_40); break; case 3: - gSaveContext.save.weekEventReg[83] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_83_80); break; case 4: - gSaveContext.save.weekEventReg[84] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_84_01); break; case 5: - gSaveContext.save.weekEventReg[84] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_84_02); break; case 6: - gSaveContext.save.weekEventReg[84] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_84_04); break; case 7: - gSaveContext.save.weekEventReg[84] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_84_08); break; } } } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&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) { @@ -738,7 +740,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; @@ -751,7 +753,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; @@ -759,7 +761,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; @@ -779,27 +781,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) { @@ -811,7 +812,7 @@ 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 }; @@ -830,11 +831,11 @@ void EnDragon_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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 5fe44083b..cb2ab9490 100644 --- a/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h +++ b/src/overlays/actors/ovl_En_Dragon/z_en_dragon.h @@ -18,7 +18,7 @@ typedef enum { struct EnDragon; -typedef void (*EnDragonActionFunc)(struct EnDragon*, GlobalContext*); +typedef void (*EnDragonActionFunc)(struct EnDragon*, PlayState*); typedef struct EnDragon { /* 0x000 */ Actor actor; @@ -26,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; @@ -50,7 +50,7 @@ typedef struct EnDragon { /* 0x2C0 */ s16 grabCutsceneIndex; /* 0x2C2 */ s16 deathCutsceneIndex; /* 0x2C4 */ UNK_TYPE1 unk_2C4[0x4]; - /* 0x2C8 */ s16 cameraId; + /* 0x2C8 */ s16 subCamId; /* 0x2CA */ s16 grabTimer; // Counts up from the time a grab starts until the time the actor begins attacking /* 0x2CC */ s16 unk_2CC; // Initialized, but never used /* 0x2CE */ UNK_TYPE1 unk_2CE[0x2]; @@ -61,6 +61,4 @@ typedef struct EnDragon { /* 0x2FC */ ColliderJntSphElement colliderElements[8]; } EnDragon; // size = 0x4FC -extern const ActorInit En_Dragon_InitVars; - #endif // Z_EN_DRAGON_H diff --git a/src/overlays/actors/ovl_En_Drs/overlay.cfg b/src/overlays/actors/ovl_En_Drs/overlay.cfg deleted file mode 100644 index 7a0ab3db7..000000000 --- a/src/overlays/actors/ovl_En_Drs/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Drs -z_en_drs.c 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..7e232d5bd 100644 --- a/src/overlays/actors/ovl_En_Drs/z_en_drs.c +++ b/src/overlays/actors/ovl_En_Drs/z_en_drs.c @@ -10,14 +10,14 @@ #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 = { +ActorInit En_Drs_InitVars = { ACTOR_EN_DRS, ACTORCAT_PROP, FLAGS, @@ -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); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_87_02) && (limbIndex == WEDDING_DRESS_MANNEQUIN_LIMB_MASK)) { + 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..d811ae780 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; @@ -19,6 +19,4 @@ typedef struct EnDrs { /* 0x208 */ s8 moonMaskObjBankIndex; } EnDrs; // size = 0x20C */ -extern const ActorInit En_Drs_InitVars; - #endif // Z_EN_DRS_H diff --git a/src/overlays/actors/ovl_En_Ds2n/overlay.cfg b/src/overlays/actors/ovl_En_Ds2n/overlay.cfg deleted file mode 100644 index d0764f1c1..000000000 --- a/src/overlays/actors/ovl_En_Ds2n/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ds2n -z_en_ds2n.c 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..67dff9c41 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,13 +13,14 @@ #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); -#if 0 -const ActorInit En_Ds2n_InitVars = { +void EnDs2n_Idle(EnDs2n* this, PlayState* play); + +ActorInit En_Ds2n_InitVars = { ACTOR_EN_DS2N, ACTORCAT_NPC, FLAGS, @@ -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..f2a6c0725 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h @@ -2,18 +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; - #endif // Z_EN_DS2N_H diff --git a/src/overlays/actors/ovl_En_Dt/overlay.cfg b/src/overlays/actors/ovl_En_Dt/overlay.cfg deleted file mode 100644 index 6eb553237..000000000 --- a/src/overlays/actors/ovl_En_Dt/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dt -z_en_dt.c 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..0ac7dcb4b 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.c +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.c @@ -10,13 +10,13 @@ #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 = { +ActorInit En_Dt_InitVars = { ACTOR_EN_DT, ACTORCAT_NPC, FLAGS, 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..6afbf8cd2 100644 --- a/src/overlays/actors/ovl_En_Dt/z_en_dt.h +++ b/src/overlays/actors/ovl_En_Dt/z_en_dt.h @@ -5,15 +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; - #endif // Z_EN_DT_H diff --git a/src/overlays/actors/ovl_En_Dy_Extra/overlay.cfg b/src/overlays/actors/ovl_En_Dy_Extra/overlay.cfg deleted file mode 100644 index 04c14d5ce..000000000 --- a/src/overlays/actors/ovl_En_Dy_Extra/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Dy_Extra -z_en_dy_extra.c 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..dfd97196a 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,15 +11,15 @@ #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 = { +ActorInit En_Dy_Extra_InitVars = { ACTOR_EN_DY_EXTRA, ACTORCAT_PROP, FLAGS, @@ -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,11 +61,11 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -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..0e5d8614b 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,10 +15,8 @@ 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 -extern const ActorInit En_Dy_Extra_InitVars; - #endif // Z_EN_DY_EXTRA_H diff --git a/src/overlays/actors/ovl_En_Egblock/overlay.cfg b/src/overlays/actors/ovl_En_Egblock/overlay.cfg deleted file mode 100644 index c80635d34..000000000 --- a/src/overlays/actors/ovl_En_Egblock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Egblock -z_en_egblock.c 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..de26515fa 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.c @@ -1,22 +1,35 @@ /* * File: z_en_egblock.c * Overlay: ovl_En_Egblock - * Description: Eyegore Block + * Description: Unused pillar. Eyegore can destroy it. */ #include "z_en_egblock.h" +#include "objects/object_eg/object_eg.h" #define FLAGS (ACTOR_FLAG_8000000) #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); +typedef enum { + /* 0 */ EGBLOCK_EFFECT_DEBRIS_SOLID, + /* 1 */ EGBLOCK_EFFECT_DEBRIS_FLAT, +} EnEgblockEffectType; -#if 0 -const ActorInit En_Egblock_InitVars = { +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* play2); + +void EnEgblock_Active(EnEgblock* this, PlayState* play); +void EnEgblock_DoNothing(EnEgblock* this, PlayState* play); +void EnEgblock_Inactive(EnEgblock* this, PlayState* play); + +void EnEgblock_SpawnEffect(EnEgblock* this, Vec3f* pos, s16 lifetime, s16 arg3); +void EnEgblock_UpdateEffects(EnEgblock* this, PlayState* play); +void EnEgblock_DrawEffects(EnEgblock* this, PlayState* play); + +ActorInit En_Egblock_InitVars = { ACTOR_EN_EGBLOCK, ACTORCAT_PROP, FLAGS, @@ -28,28 +41,191 @@ const ActorInit En_Egblock_InitVars = { (ActorFunc)EnEgblock_Draw, }; -#endif +void EnEgblock_Init(Actor* thisx, PlayState* play) { + EnEgblock* this = THIS; + CollisionHeader* colHeader = NULL; + s32 pad; -extern UNK_TYPE D_06001698; -extern UNK_TYPE D_06001820; -extern UNK_TYPE D_06001BF8; + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&gEyegoreBlockCol, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; + this->inactive = false; + Actor_SetScale(&this->dyna.actor, 0.5f); + this->type = EGBLOCK_GET_TYPE(&this->dyna.actor); + this->paramF80 = EGBLOCK_GET_PARAM_F80(&this->dyna.actor); + this->param7F = EGBLOCK_GET_PARAM_7F(&this->dyna.actor); + if (this->type == EGBLOCK_TYPE_ACTIVE) { + this->dyna.actor.colChkInfo.health = 1; + this->actionFunc = EnEgblock_Active; + } else { + this->actionFunc = EnEgblock_DoNothing; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/EnEgblock_Init.s") +void EnEgblock_Destroy(Actor* thisx, PlayState* play) { + EnEgblock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/EnEgblock_Destroy.s") + if (this->dyna.actor.colChkInfo.health == 1) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/func_80ABA8A4.s") +void EnEgblock_Active(EnEgblock* this, PlayState* play) { + if (this->dyna.actor.colChkInfo.health <= 0) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/func_80ABA988.s") + //! @bug Egblock doesn't have an effect with index 2, so half of these spawns do nothing. + for (i = 0; i < ARRAY_COUNT(this->effects); i++) { + EnEgblock_SpawnEffect(this, &this->dyna.actor.world.pos, 30, (i & 1) + EGBLOCK_EFFECT_DEBRIS_FLAT); + } + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 30.0f, 30, 10.0f, 100, 30, true); + this->inactive = true; + this->timer = 50; + this->actionFunc = EnEgblock_Inactive; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/func_80ABA9B8.s") +void EnEgblock_Inactive(EnEgblock* this, PlayState* play) { + if (this->timer == 0) { + Actor_Kill(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/EnEgblock_Update.s") +void EnEgblock_DoNothing(EnEgblock* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/EnEgblock_Draw.s") +void EnEgblock_Update(Actor* thisx, PlayState* play) { + EnEgblock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/func_80ABAAF4.s") + this->actionFunc(this, play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/func_80ABACB4.s") + DECR(this->timer); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egblock/func_80ABAE64.s") + EnEgblock_UpdateEffects(this, play); +} + +void EnEgblock_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnEgblock* this = THIS; + + func_8012C28C(play->state.gfxCtx); + + if (this->inactive != true) { + 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++, 0x00, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gEyegoreBlockDL); + + CLOSE_DISPS(play->state.gfxCtx); + } + + EnEgblock_DrawEffects(this, play); +} + +void EnEgblock_SpawnEffect(EnEgblock* this, Vec3f* pos, s16 lifetime, s16 arg3) { + EnEgblockEffect* effect = this->effects; + s16 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isActive) { + effect->isActive = true; + effect->pos = *pos; + effect->pos.x += randPlusMinusPoint5Scaled(50.0f); + effect->pos.z += randPlusMinusPoint5Scaled(50.0f); + effect->timer = lifetime; + effect->alpha = 255; + effect->type = arg3; + effect->accel.x = Rand_ZeroOne() - 0.5f; + effect->accel.y = -1.0f; + effect->accel.z = Rand_ZeroOne() - 0.5f; + effect->velocity.x = 2.0f * (Rand_ZeroOne() - 0.5f); + effect->velocity.y = 5.0f + (10.0f * Rand_ZeroOne()); + effect->velocity.z = 2.0f * (Rand_ZeroOne() - 0.5f); + effect->scale = 0.5f + (0.2f * Rand_ZeroFloat(1.0f)); + effect->rot.x = randPlusMinusPoint5Scaled(0x7530); + effect->rot.y = randPlusMinusPoint5Scaled(0x7530); + effect->rot.z = randPlusMinusPoint5Scaled(0x7530); + break; + } + } +} + +void EnEgblock_UpdateEffects(EnEgblock* this, PlayState* play) { + EnEgblockEffect* effect = this->effects; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isActive) { + if (effect->type != EGBLOCK_EFFECT_DEBRIS_SOLID) { + effect->rot.x -= 0x64; + effect->rot.y -= 0x64; + effect->rot.z -= 0x64; + } + + effect->pos.x += effect->velocity.x; + 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->timer) { + effect->timer--; + } else { + effect->alpha -= 10; + if (effect->alpha < 10) { + effect->isActive = false; + } + } + } + } +} + +void EnEgblock_DrawEffects(EnEgblock* this, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + EnEgblockEffect* effect = this->effects; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isActive) { + switch (effect->type) { + case EGBLOCK_EFFECT_DEBRIS_SOLID: + case EGBLOCK_EFFECT_DEBRIS_FLAT: + Matrix_Push(); + + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + Matrix_RotateYS(effect->rot.y, MTXMODE_APPLY); + Matrix_RotateXS(effect->rot.x, MTXMODE_APPLY); + Matrix_RotateZS(effect->rot.z, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, effect->alpha); + + if (effect->type == EGBLOCK_EFFECT_DEBRIS_SOLID) { + gSPDisplayList(POLY_OPA_DISP++, gEyegoreEffectSolidDebrisDL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gEyegoreEffectFlatDebrisDL); + } + + Matrix_Pop(); + break; + + default: + break; + } + } + } + + CLOSE_DISPS(gfxCtx); +} 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..2d875c4d2 100644 --- a/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h +++ b/src/overlays/actors/ovl_En_Egblock/z_en_egblock.h @@ -5,15 +5,42 @@ struct EnEgblock; -typedef void (*EnEgblockActionFunc)(struct EnEgblock*, GlobalContext*); +typedef void (*EnEgblockActionFunc)(struct EnEgblock*, PlayState*); + +#define EGBLOCK_GET_PARAM_7F(thisx) ((thisx)->params & 0x7F) +#define EGBLOCK_GET_PARAM_F80(thisx) (((thisx)->params >> 7) & 0x1F) +#define EGBLOCK_GET_TYPE(thisx) (((thisx)->params >> 12) & 0xF) + +#define EGBLOCK_PARAMS(type, param1, param2) ((((type) & 0xF) << 12) | (((param1) & 0x1F) << 7) | ((param2) & 0x7F)) + +#define EGBLOCK_TYPE_ACTIVE 0 + +#define EGBLOCK_EFFECT_COUNT 50 + +typedef struct { + /* 0x00 */ u8 isActive; + /* 0x04 */ Vec3f pos; + /* 0x10 */ s16 alpha; + /* 0x12 */ s16 timer; + /* 0x14 */ s16 type; + /* 0x18 */ Vec3f velocity; + /* 0x24 */ Vec3f accel; + /* 0x30 */ Vec3s rot; + /* 0x38 */ f32 scale; +} EnEgblockEffect; // size = 0x3C typedef struct EnEgblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x5C]; - /* 0x01A0 */ EnEgblockActionFunc actionFunc; - /* 0x01A4 */ char unk_1A4[0xC10]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ UNK_TYPE1 unk_15C[0x44]; // SkelAnime? + /* 0x1A0 */ EnEgblockActionFunc actionFunc; + /* 0x1A4 */ s16 type; + /* 0x1A6 */ s16 paramF80; + /* 0x1A8 */ s16 param7F; + /* 0x1AA */ s16 timer; + /* 0x1AC */ s16 inactive; + /* 0x1AE */ UNK_TYPE1 unk_1AE[2]; + /* 0x1B0 */ UNK_TYPE1 unk_1B0[0x4C]; // ColliderCylinder? + /* 0x1FC */ EnEgblockEffect effects[EGBLOCK_EFFECT_COUNT]; } EnEgblock; // size = 0xDB4 -extern const ActorInit En_Egblock_InitVars; - #endif // Z_EN_EGBLOCK_H diff --git a/src/overlays/actors/ovl_En_Egol/overlay.cfg b/src/overlays/actors/ovl_En_Egol/overlay.cfg deleted file mode 100644 index 1073044cd..000000000 --- a/src/overlays/actors/ovl_En_Egol/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Egol -z_en_egol.c 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..731497436 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -5,109 +5,295 @@ */ #include "z_en_egol.h" +#include "objects/object_eg/object_eg.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_En_Estone/z_en_estone.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" +#include "overlays/effects/ovl_Effect_Ss_Hitmark/z_eff_ss_hitmark.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_80000000) #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); +typedef enum { + /* 0 */ EYEGORE_ACTION_WAIT, + /* 1 */ EYEGORE_ACTION_STAND, + /* 2 */ EYEGORE_ACTION_WALK, + /* 3 */ EYEGORE_ACTION_RETREAT, + /* 4 */ EYEGORE_ACTION_LASER, + /* 5 */ EYEGORE_ACTION_SLAM, + /* 6 */ EYEGORE_ACTION_PUNCH, + /* 7 */ EYEGORE_ACTION_SLAM_WAIT, + /* 8 */ EYEGORE_ACTION_STUNNED, + /* 9 */ EYEGORE_ACTION_STUN_END, + /* 10 */ EYEGORE_ACTION_SLAM_END, + /* 11 */ EYEGORE_ACTION_DAMAGED, + /* 12 */ EYEGORE_ACTION_STOP, + /* 13 */ EYEGORE_ACTION_DYING, + /* 14 */ EYEGORE_ACTION_DEAD +} EnEgolAction; -#if 0 -// static ColliderJntSphElementInit sJntSphElementsInit[6] = { -static ColliderJntSphElementInit D_80A80C64[6] = { +typedef enum { + /* 0 */ EYEGORE_EFFECT_IMPACT, + /* 1 */ EYEGORE_EFFECT_PIECE_LARGE, + /* 2 */ EYEGORE_EFFECT_PIECE_SMALL, + /* 3 */ EYEGORE_EFFECT_DEBRIS, +} EnEgolEffectType; + +typedef enum { + /* 0 */ EYEGORE_ANIM_STAND, + /* 1 */ EYEGORE_ANIM_WALK, + /* 2 */ EYEGORE_ANIM_SLAM, + /* 3 */ EYEGORE_ANIM_SLAM_WAIT, + /* 4 */ EYEGORE_ANIM_SLAM_END, + /* 5 */ EYEGORE_ANIM_DAMAGED, + /* 6 */ EYEGORE_ANIM_DEATH, + /* 7 */ EYEGORE_ANIM_LASER, + /* 8 */ EYEGORE_ANIM_LASER_END, // unused + /* 9 */ EYEGORE_ANIM_STUNNED, + /* 10 */ EYEGORE_ANIM_STUN_END, + /* 11 */ EYEGORE_ANIM_RETREAT, + /* 12 */ EYEGORE_ANIM_SIT, + /* 13 */ EYEGORE_ANIM_LEFT_PUNCH, + /* 14 */ EYEGORE_ANIM_RIGHT_PUNCH, + /* 15 */ EYEGORE_ANIM_MAX, +} EnEgolAnimation; + +typedef enum { + /* 0 */ EYEGORE_LASER_OFF, + /* 1 */ EYEGORE_LASER_START, + /* 2 */ EYEGORE_LASER_CHARGING, + /* 3 */ EYEGORE_LASER_FIRE, + /* 7 */ EYEGORE_LASER_ON = 7, +} EnEgolLaserState; + +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* play2); + +void EnEgol_SetupWait(EnEgol* this); +void EnEgol_Wait(EnEgol* this, PlayState* play); +void EnEgol_SetupStand(EnEgol* this); +void EnEgol_Stand(EnEgol* this, PlayState* play); +void EnEgol_SetupWalk(EnEgol* this); +void EnEgol_Walk(EnEgol* this, PlayState* play); +void EnEgol_SetupRetreat(EnEgol* this); +void EnEgol_Retreat(EnEgol* this, PlayState* play); +void EnEgol_SetupLaser(EnEgol* this); +void EnEgol_Laser(EnEgol* this, PlayState* play); +void EnEgol_SetupStop(EnEgol* this); +void EnEgol_Stop(EnEgol* this, PlayState* play); +void EnEgol_SetupSlam(EnEgol* this); +void EnEgol_Slam(EnEgol* this, PlayState* play); +void EnEgol_SetupPunch(EnEgol* this); +void EnEgol_Punch(EnEgol* this, PlayState* play); +void EnEgol_SetupSlamWait(EnEgol* this); +void EnEgol_SlamWait(EnEgol* this, PlayState* play); +void EnEgol_SetupStunned(EnEgol* this); +void EnEgol_Stunned(EnEgol* this, PlayState* play); +void EnEgol_SetupStunEnd(EnEgol* this); +void EnEgol_StunEnd(EnEgol* this, PlayState* play); +void EnEgol_SetupSlamEnd(EnEgol* this); +void EnEgol_SlamEnd(EnEgol* this, PlayState* play); +void EnEgol_SetupDamaged(EnEgol* this); +void EnEgol_Damaged(EnEgol* this, PlayState* play); +void EnEgol_StartDeathCutscene(EnEgol* this, PlayState* play); +void EnEgol_Death(EnEgol* this, PlayState* play); + +void EnEgol_SpawnEffect(EnEgol* this, Vec3f* pos, Vec3s* rot, s16 lifetime, f32 scale, s16 type); +void EnEgol_UpdateEffects(EnEgol* this, PlayState* play); +void EnEgol_DrawEffects(EnEgol* this, PlayState* play); + +static ColliderJntSphElementInit sEyeJntSphElementsInit[1] = { { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 6, { { 0, 0, 0 }, 0 }, 1 }, - }, - { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x04, 0x10 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 9, { { 0, 0, 0 }, 0 }, 1 }, - }, - { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 3, { { 0, 0, 0 }, 0 }, 1 }, - }, - { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 4, { { 0, 0, 0 }, 0 }, 1 }, - }, - { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 7, { { 0, 0, 0 }, 0 }, 1 }, - }, - { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, - { 23, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { EYEGORE_LIMB_EYE_COLLIDER, { { 0, 0, 0 }, 0 }, 1 }, }, }; -// 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, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80A80C40[1] = { +static ColliderJntSphElementInit sBodySphElementsInit[6] = { { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 14, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { EYEGORE_LIMB_LEFT_HAND, { { 0, 0, 0 }, 0 }, 1 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x04, 0x10 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { EYEGORE_LIMB_RIGHT_HAND, { { 0, 0, 0 }, 0 }, 1 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { EYEGORE_LIMB_HEAD, { { 0, 0, 0 }, 0 }, 1 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { EYEGORE_LIMB_LEFT_SHOULDER, { { 0, 0, 0 }, 0 }, 1 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { EYEGORE_LIMB_RIGHT_SHOULDER, { { 0, 0, 0 }, 0 }, 1 }, + }, + { + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { EYEGORE_LIMB_FAULDS, { { 0, 0, 0 }, 0 }, 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, +static ColliderJntSphInit sBodyJntSphInit = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sBodySphElementsInit), + sBodySphElementsInit, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80A80D5C = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x07, 0x10 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, BUMP_NONE, OCELEM_NONE, }, +static ColliderJntSphInit sEyeJntSphInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sEyeJntSphElementsInit), + sEyeJntSphElementsInit, +}; + +static ColliderQuadInit sLaserQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x07, 0x10 }, + { 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_80A80DAC = { - /* Deku Nut */ DMG_ENTRY(0, 0xF), - /* Deku Stick */ DMG_ENTRY(0, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(2, 0xE), - /* Zora boomerang */ DMG_ENTRY(1, 0xE), - /* Normal arrow */ DMG_ENTRY(1, 0xE), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0xE), - /* Sword */ DMG_ENTRY(0, 0xF), - /* Goron pound */ DMG_ENTRY(0, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0xE), - /* Ice arrow */ DMG_ENTRY(2, 0xE), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xE), - /* Deku spin */ DMG_ENTRY(1, 0xE), - /* Deku bubble */ DMG_ENTRY(1, 0xE), - /* Deku launch */ DMG_ENTRY(2, 0xE), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0xF), - /* Zora barrier */ DMG_ENTRY(0, 0x0), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0xF), - /* Thrown object */ DMG_ENTRY(1, 0xE), - /* Zora punch */ DMG_ENTRY(1, 0xE), - /* Spin attack */ DMG_ENTRY(0, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ EYEGORE_DMGEFF_IMMUNE_0, + /* 0x4 */ EYEGORE_DMGEFF_LIGHT_ARROW = 4, + /* 0xE */ EYEGORE_DMGEFF_NONE = 0xE, + /* 0xF */ EYEGORE_DMGEFF_IMMUNE_F, +} EnEgolDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_F), + /* Deku Stick */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_F), + /* Horse trample */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* Explosives */ DMG_ENTRY(2, EYEGORE_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* Hookshot */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_F), + /* Goron pound */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_F), + /* Fire arrow */ DMG_ENTRY(2, EYEGORE_DMGEFF_NONE), + /* Ice arrow */ DMG_ENTRY(2, EYEGORE_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, EYEGORE_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EYEGORE_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_F), + /* Zora barrier */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* Normal shield */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* Light ray */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_F), + /* Thrown object */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EYEGORE_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_F), + /* Sword beam */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* Normal Roll */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* Unblockable */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EYEGORE_DMGEFF_IMMUNE_0), + /* Powder Keg */ DMG_ENTRY(1, EYEGORE_DMGEFF_IMMUNE_F), }; -const ActorInit En_Egol_InitVars = { +static Color_RGB8 sEyePrimColors[] = { + { 175, 255, 255 }, // light cyan + { 195, 245, 10 }, // lime green + { 255, 55, 205 }, // magenta +}; + +static Color_RGB8 sEyeEnvColors[] = { + { 255, 115, 155 }, // pink + { 40, 155, 155 }, // dark cyan + { 215, 255, 255 }, // light cyan +}; + +static Color_RGB8 sLightOrbColors[] = { + { 255, 255, 255 }, // white + { 255, 255, 255 }, // white +}; + +ActorInit En_Egol_InitVars = { ACTOR_EN_EGOL, ACTORCAT_ENEMY, FLAGS, @@ -119,99 +305,1344 @@ const ActorInit En_Egol_InitVars = { (ActorFunc)EnEgol_Draw, }; -#endif +void EnEgol_ChangeAnim(EnEgol* this, s32 animation) { + static AnimationHeader* sAnimations[EYEGORE_ANIM_MAX] = { + &gEyegoreStandAnim, &gEyegoreWalkAnim, &gEyegoreSlamAnim, + &gEyegoreSlamWaitAnim, &gEyegoreSlamEndAnim, &gEyegoreDamagedAnim, + &gEyegoreDeathAnim, &gEyegoreLaserAnim, &gEyegoreUnusedLaserEndAnim, + &gEyegoreStunnedAnim, &gEyegoreStunEndAnim, &gEyegoreRetreatAnim, + &gEyegoreSitAnim, &gEyegoreLeftPunchAnim, &gEyegoreRightPunchAnim, + }; + static u8 sAnimModes[EYEGORE_ANIM_MAX] = { + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, + }; + this->animation = animation; + this->animEndFrame = Animation_GetLastFrame(sAnimations[this->animation]); + Animation_Change(&this->skelAnime, sAnimations[this->animation], 1.0f, 0.0f, this->animEndFrame, + sAnimModes[this->animation], 0.0f); +} -extern ColliderJntSphElementInit D_80A80C64[6]; -extern ColliderJntSphInit D_80A80D3C; -extern ColliderJntSphElementInit D_80A80C40[1]; -extern ColliderJntSphInit D_80A80D4C; -extern ColliderQuadInit D_80A80D5C; -extern DamageTable D_80A80DAC; +void EnEgol_FootstepEffects(EnEgol* this, PlayState* play, f32 leftFootFrame, f32 rightFootFrame) { + if (Animation_OnFrame(&this->skelAnime, leftFootFrame) || Animation_OnFrame(&this->skelAnime, rightFootFrame)) { + Vec3f spawnPos; + Player* player = GET_PLAYER(play); + s32 quakeSize; + s32 pad; -extern UNK_TYPE D_06000040; -extern UNK_TYPE D_060094E4; -extern UNK_TYPE D_0600EE4C; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_WALK); + quakeSize = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f); + if (quakeSize > 4) { + quakeSize = 4; + } else if (quakeSize < 1) { + quakeSize = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7C990.s") + if (player->stateFlags3 != PLAYER_STATE3_1000000) { + func_800BC848(&this->actor, play, quakeSize, 2); + } + if (Animation_OnFrame(&this->skelAnime, leftFootFrame)) { + Math_Vec3f_Copy(&spawnPos, &this->leftFootPos); + spawnPos.y = this->actor.floorHeight; + Actor_SpawnFloorDustRing(play, &this->actor, &spawnPos, 0.0f, 10, 6.0f, 50, 30, true); + } else { + Math_Vec3f_Copy(&spawnPos, &this->rightFootPos); + spawnPos.y = this->actor.floorHeight; + Actor_SpawnFloorDustRing(play, &this->actor, &spawnPos, 0.0f, 10, 6.0f, 50, 30, true); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7CA18.s") +void EnEgol_DestroyBlocks(EnEgol* this, PlayState* play, Vec3f pos1, Vec3f pos2) { + Actor* prop = play->actorCtx.actorLists[ACTORCAT_PROP].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7CBC4.s") + while (prop != NULL) { + if (prop->id != ACTOR_EN_EGBLOCK) { + prop = prop->next; + continue; + } + if (prop->colChkInfo.health > 0) { + Vec3f blockTo1; + Vec3f blockTo2; + f32 dist1; + f32 dist2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7CD08.s") + blockTo1.x = pos1.x - prop->world.pos.x; + blockTo1.y = pos1.y - prop->world.pos.y; + blockTo1.z = pos1.z - prop->world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/EnEgol_Init.s") + blockTo2.x = pos2.x - prop->world.pos.x; + blockTo2.y = pos2.y - prop->world.pos.y; + blockTo2.z = pos2.z - prop->world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/EnEgol_Destroy.s") + dist1 = sqrtf(SQXZ(blockTo1)); + dist2 = sqrtf(SQXZ(blockTo2)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7D140.s") + if ((dist1 < 40.0f) || (dist2 < 40.0f)) { + dist1 = sqrtf(SQ(blockTo1.y)); + dist2 = sqrtf(SQ(blockTo2.y)); + if ((dist1 < 40.0f) || (dist2 < 40.0f)) { + prop->colChkInfo.health = 0; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALL_BROKEN); + break; + } + } + } + prop = prop->next; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7D168.s") +void EnEgol_GetWaypoint(EnEgol* this) { + if ((this->pathIndex != -1) && (this->path != NULL) && + !SubS_CopyPointFromPath(this->path, this->waypoint, &this->waypointPos)) { + Actor_Kill(&this->actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7D1E4.s") +#define EYEGORE_SET_SPH_DIM(element, centerX, centerY, centerZ, radiusV, scaleV) \ + element.dim.modelSphere.radius = radiusV; \ + element.dim.scale = scaleV; \ + element.dim.modelSphere.center.x = centerX; \ + element.dim.modelSphere.center.y = centerY; \ + element.dim.modelSphere.center.z = centerZ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7D240.s") +void EnEgol_Init(Actor* thisx, PlayState* play) { + EnEgol* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7D27C.s") + this->actor.gravity = -2.0f; + Actor_SetScale(&this->actor, 0.015f); + this->actor.colChkInfo.damageTable = &sDamageTable; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7D2C4.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.hintId = TATL_HINT_ID_EYEGORE; + this->actor.colChkInfo.health = 8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7D710.s") + SkelAnime_InitFlex(play, &this->skelAnime, &gEyegoreSkel, &gEyegoreStandAnim, this->jointTable, this->morphTable, + EYEGORE_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7D780.s") + Collider_InitAndSetJntSph(play, &this->bodyCollider, &this->actor, &sBodyJntSphInit, this->bodyElements); + Collider_InitAndSetJntSph(play, &this->eyeCollider, &this->actor, &sEyeJntSphInit, this->eyeElements); + Collider_InitAndSetQuad(play, &this->laserCollider, &this->actor, &sLaserQuadInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7DAAC.s") + this->pathIndex = EYEGORE_GET_PATH(&this->actor); + if (this->pathIndex == 0x3F) { + this->pathIndex = -1; + Actor_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7DAF0.s") + this->wakeupRange = this->actor.world.rot.x * 20.0f; + this->actor.world.rot.x = 0; + if (this->wakeupRange < 0.0f) { + this->wakeupRange = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E2E8.s") + this->minLaserRange = this->actor.world.rot.z * 20.0f; + this->actor.world.rot.z = 0; + if (this->minLaserRange < 0.0f) { + this->minLaserRange = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E344.s") + this->path = SubS_GetPathByIndex(play, this->pathIndex, 0x3F); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E478.s") + EYEGORE_SET_SPH_DIM(this->eyeCollider.elements[0], 500, 0, 0, 26, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E4B4.s") + EYEGORE_SET_SPH_DIM(this->bodyCollider.elements[0], 1800, 100, 0, 20, 1.0f); + EYEGORE_SET_SPH_DIM(this->bodyCollider.elements[1], 1800, 100, 0, 20, 1.0f); + EYEGORE_SET_SPH_DIM(this->bodyCollider.elements[2], 1000, -500, 0, 35, 1.0f); + EYEGORE_SET_SPH_DIM(this->bodyCollider.elements[3], 200, 200, 0, 25, 1.0f); + EYEGORE_SET_SPH_DIM(this->bodyCollider.elements[4], 300, 200, 0, 25, 1.0f); + EYEGORE_SET_SPH_DIM(this->bodyCollider.elements[5], 2100, -300, 0, 37, 1.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E7EC.s") + this->switchFlag = EYEGORE_GET_SWITCH(&this->actor); + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } + if ((this->switchFlag > -1) && Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&this->actor); + return; + } + EnEgol_SetupWait(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E820.s") +void EnEgol_Destroy(Actor* thisx, PlayState* play) { + EnEgol* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E924.s") + Collider_DestroyJntSph(play, &this->bodyCollider); + Collider_DestroyJntSph(play, &this->eyeCollider); + Collider_DestroyQuad(play, &this->laserCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E970.s") +void EnEgol_SetupWait(EnEgol* this) { + this->actor.flags |= ACTOR_FLAG_8000000; + this->action = EYEGORE_ACTION_WAIT; + this->actionFunc = EnEgol_Wait; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7E9D0.s") +void EnEgol_Wait(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s16 angleToFacing = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EA28.s") + if ((curFrame >= this->animEndFrame) && (ABS_ALT(angleToFacing) < 0x3000) && + (this->actor.xzDistToPlayer < this->wakeupRange)) { + EnEgol_SetupStand(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EA88.s") +void EnEgol_SetupStand(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_STAND); + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->action = EYEGORE_ACTION_STAND; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_STAND); + this->actionFunc = EnEgol_Stand; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EAD8.s") +void EnEgol_Stand(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EB14.s") + if (curFrame >= this->animEndFrame) { + EnEgol_SetupWalk(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EB54.s") +void EnEgol_SetupWalk(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_WALK); + this->laserCount = 0; + EnEgol_GetWaypoint(this); + this->action = EYEGORE_ACTION_WALK; + this->actionFunc = EnEgol_Walk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EB90.s") +void EnEgol_Walk(EnEgol* this, PlayState* play) { + s16 angleToFacing = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + f32 curFrame = this->skelAnime.curFrame; + Player* player = GET_PLAYER(play); + Vec3f spawnPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EBDC.s") + Math_SmoothStepToS(&this->headRot, 0, 1, 0x3E8, 0); + Math_Vec3f_Copy(&spawnPos, &gZeroVec3f); + if (curFrame >= this->animEndFrame) { + this->laserCount++; + if (this->laserCount > 0) { + this->laserCount = 0; + if (this->actor.xzDistToPlayer > this->minLaserRange) { + EnEgol_SetupLaser(this); + return; + } + } + } + if ((this->actor.world.pos.y - 50.0f) <= player->actor.world.pos.y) { + if (Animation_OnFrame(&this->skelAnime, 24.0f)) { + Math_Vec3f_Copy(&spawnPos, &this->rightFootPos); + spawnPos.y = this->actor.floorHeight + 2.0f; + EnEgol_SpawnEffect(this, &spawnPos, &gZeroVec3s, 100, 0.005f, EYEGORE_EFFECT_IMPACT); + } + if (Animation_OnFrame(&this->skelAnime, 9.0f)) { + Math_Vec3f_Copy(&spawnPos, &this->leftFootPos); + spawnPos.y = this->actor.floorHeight + 2.0f; + EnEgol_SpawnEffect(this, &spawnPos, &gZeroVec3s, 100, 0.005f, EYEGORE_EFFECT_IMPACT); + } + } + if ((ABS_ALT(angleToFacing) < 0x3000) && (this->actor.xzDistToPlayer < 100.0f)) { + EnEgol_SetupSlam(this); + } else { + s16 angleBehind; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EC84.s") + if (!((this->skelAnime.curFrame == 0.0f) || + ((9.0f <= this->skelAnime.curFrame) && (this->skelAnime.curFrame <= 15.0f)) || + ((24.0f <= this->skelAnime.curFrame) && (this->skelAnime.curFrame <= 29.0f)))) { + Math_ApproachF(&this->actor.world.pos.x, this->waypointPos.x, 0.5f, + fabsf(Math_SinS(this->actor.world.rot.y) * 4.0f)); + Math_ApproachF(&this->actor.world.pos.z, this->waypointPos.z, 0.5f, + fabsf(Math_CosS(this->actor.world.rot.y) * 4.0f)); + } + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->waypointPos), 1, + 0x7D0, 0); + EnEgol_FootstepEffects(this, play, 9.0f, 24.0f); + angleBehind = this->actor.world.rot.y - this->actor.yawTowardsPlayer + 0x8000; + if (ABS_ALT(angleBehind) < 0x2000) { + this->waypoint--; + if (this->waypoint < 0) { + this->waypoint = 0; + } + EnEgol_SetupStop(this); + } else { + f32 dx = this->actor.world.pos.x - this->waypointPos.x; + f32 dz = this->actor.world.pos.z - this->waypointPos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7ED14.s") + if (sqrtf(SQ(dx) + SQ(dz)) < 4.0f) { + if (this->path != NULL) { + this->waypoint++; + if (this->waypoint >= this->path->count) { + this->waypoint -= 2; + if (this->waypoint < 0) { + this->waypoint = 0; + } + EnEgol_SetupStop(this); + } + EnEgol_GetWaypoint(this); + } + } + if (this->actor.wallBgId != BGCHECK_SCENE) { + EnEgol_DestroyBlocks(this, play, this->rightFootPos, this->leftFootPos); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7EFB8.s") +void EnEgol_SetupRetreat(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_RETREAT); + this->laserCount = 0; + EnEgol_GetWaypoint(this); + this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->waypointPos); + this->actor.shape.rot.y = this->actor.world.rot.y + 0x8000; + this->action = EYEGORE_ACTION_RETREAT; + this->actionFunc = EnEgol_Retreat; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/EnEgol_Update.s") +void EnEgol_Retreat(EnEgol* this, PlayState* play) { + s16 angleToFacing = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + Vec3f toWaypoint; + Vec3f spawnPos; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7F8E8.s") + if ((ABS_ALT(angleToFacing) < 0x3000) && (fabsf(this->actor.world.pos.y - player->actor.world.pos.y) < 50.0f) && + (this->actor.xzDistToPlayer < 100.0f) && (player->invincibilityTimer == 0)) { + func_800B8D50(play, &this->actor, 2.0f, (s32)randPlusMinusPoint5Scaled(0x2000) + this->actor.world.rot.y, 5.0f, + 0x10); + } + Math_Vec3f_Copy(&spawnPos, &gZeroVec3f); + if ((this->actor.world.pos.y - 50.0f) <= player->actor.world.pos.y) { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + Math_Vec3f_Copy(&spawnPos, &this->rightFootPos); + spawnPos.y = this->actor.floorHeight + 2.0f; + EnEgol_SpawnEffect(this, &spawnPos, &gZeroVec3s, 100, 0.005f, EYEGORE_EFFECT_IMPACT); + } + if (Animation_OnFrame(&this->skelAnime, 0.0f)) { + Math_Vec3f_Copy(&spawnPos, &this->leftFootPos); + spawnPos.y = this->actor.floorHeight + 2.0f; + EnEgol_SpawnEffect(this, &spawnPos, &gZeroVec3s, 100, 0.005f, EYEGORE_EFFECT_IMPACT); + } + } + Math_ApproachF(&this->actor.world.pos.x, this->waypointPos.x, 0.5f, + fabsf(Math_SinS(this->actor.world.rot.y) * 10.0f)); + Math_ApproachF(&this->actor.world.pos.z, this->waypointPos.z, 0.5f, + fabsf(Math_CosS(this->actor.world.rot.y) * 10.0f)); + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->waypointPos), 1, 0x7D0, + 0); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y + 0x8000, 1, 0x7D0, 0); + EnEgol_FootstepEffects(this, play, 5.0f, 0.0f); + toWaypoint.x = this->actor.world.pos.x - this->waypointPos.x; + toWaypoint.z = this->actor.world.pos.z - this->waypointPos.z; + if (sqrtf(SQXZ(toWaypoint)) < 4.0f) { + this->waypoint--; + if (this->waypoint < 0) { + this->waypoint = 0; + EnEgol_SetupStop(this); + } + EnEgol_GetWaypoint(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A7FAFC.s") +void EnEgol_SetupLaser(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_LASER); + this->actionTimer = 0; + this->laserCount = 0; + this->action = EYEGORE_ACTION_LASER; + this->actionFunc = EnEgol_Laser; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/EnEgol_Draw.s") +void EnEgol_Laser(EnEgol* this, PlayState* play) { + static s16 sLaserAngles[3] = { 0x1F40, 0xBB8, 0x7D0 }; + s32 pad1; + Vec3f stonePos; + s32 pad2; + CollisionPoly* colPoly; + Vec3f hitPos; + s32 bgId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A80508.s") + if ((ABS_ALT((s16)(this->actor.world.rot.y - this->actor.yawTowardsPlayer)) < 0x3000) && + (this->actor.xzDistToPlayer < 100.0f)) { + this->chargingLaser = false; + this->chargeLevel = 0; + this->actionTimer = 0; + this->laserState = EYEGORE_LASER_OFF; + Math_Vec3f_Copy(&this->laserScale, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserScaleTarget, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[1], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[3], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[0], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[2], &this->laserBase); + EnEgol_SetupSlam(this); + } else if (this->actor.xzDistToPlayer < this->minLaserRange) { + this->chargingLaser = false; + this->chargeLevel = 0; + this->actionTimer = 0; + this->laserState = EYEGORE_LASER_OFF; + Math_Vec3f_Copy(&this->laserScale, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserScaleTarget, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[1], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[3], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[0], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[2], &this->laserBase); + EnEgol_SetupWalk(this); + } else { + if (this->chargingLaser) { + switch (this->chargeLevel) { + case 0: + this->waitTimer = 10; + this->chargeLevel++; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A80750.s") + case 1: + Math_ApproachF(&this->chargeLightScale, 8.0f, 0.5f, 2.5f); + if (this->waitTimer == 0) { + this->waitTimer = 10; + this->chargeLevel++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Egol/func_80A80904.s") + case 2: + Math_ApproachF(&this->chargeLightScale, 1.0f, 0.5f, 1.0f); + if (this->waitTimer == 0) { + this->chargeLevel = 0; + this->laserState = EYEGORE_LASER_FIRE; + this->chargingLaser = false; + this->chargeLightScale = 0.0f; + } + break; + + default: + break; + } + this->chargeLightRot += 0x7D0; + } + if ((this->laserState != EYEGORE_LASER_OFF) || (this->laserCount != 0)) { + Math_SmoothStepToS(&this->headRot, -0x2710, 5, 0x1F4, 5); + } else { + Math_SmoothStepToS(&this->headRot, 0, 5, 0x1F4, 5); + } + if (this->laserState == EYEGORE_LASER_OFF) { + if (this->laserCount >= 3) { + EnEgol_SetupWalk(this); + } else { + this->laserRot.x = sLaserAngles[this->laserCount]; + this->laserScaleTarget.z = 0.0f; + this->laserScale.z = 0.0f; + if (this->laserCount == 0) { + this->laserState = EYEGORE_LASER_START; + } else { + this->laserState = EYEGORE_LASER_FIRE; + this->laserScaleTarget.x = 0.03f; + this->laserScaleTarget.y = 0.03f; + } + this->laserCount++; + } + } else if (this->laserState >= EYEGORE_LASER_FIRE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_BEAM - SFX_FLAG); + if (this->laserState != EYEGORE_LASER_OFF) { + EnEgol_DestroyBlocks(this, play, this->laserCollider.dim.quad[0], this->laserCollider.dim.quad[1]); + } + //! @bug this should check walls, too + if ((this->actionTimer == 0) && BgCheck_EntityLineTest1(&play->colCtx, &this->laserCollider.dim.quad[3], + &this->laserCollider.dim.quad[1], &hitPos, &colPoly, + false, true, false, true, &bgId)) { + Vec3s rotToNorm; + f32 nx; + f32 ny; + f32 nz; + s32 pad3; + s32 i; + s32 quakeSize; + Player* player = GET_PLAYER(play); + + nx = COLPOLY_GET_NORMAL(colPoly->normal.x); + ny = COLPOLY_GET_NORMAL(colPoly->normal.y); + nz = COLPOLY_GET_NORMAL(colPoly->normal.z); + + /*! @bug The following is supposed to calculate the rotation from vertical to the collision poly normal. + * However, the calculation is performed incorrectly. The correct calculation is + * rotToNorm.x = func_80086B30(nz, ny) * 0x8000 / M_PI; + * rotToNorm.z = func_80086B30(-nx, sqrtf(1.0f - SQ(nx))) * 0x8000 / M_PI; + */ + rotToNorm.x = -func_80086B30(-nz * ny, 1.0f) * 0x8000 / M_PI; + rotToNorm.z = func_80086B30(-nx * ny, 1.0f) * 0x8000 / M_PI; + + if ((this->actor.world.pos.y - 50.0f) <= player->actor.world.pos.y) { + EnEgol_SpawnEffect(this, &hitPos, &rotToNorm, 100, 0.02f, EYEGORE_EFFECT_IMPACT); + } + quakeSize = 4 - (s32)(fabsf(player->actor.world.pos.y - this->actor.world.pos.y) * 0.02f); + if (quakeSize > 4) { + quakeSize = 4; + } else if (quakeSize < 1) { + quakeSize = 1; + } + if (player->stateFlags3 != PLAYER_STATE3_1000000) { + func_800BC848(&this->actor, play, quakeSize, 2); + } + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); + func_800B31BC(play, &hitPos, 40, -2, 255, 20); + func_800BBFB0(play, &hitPos, 6.0f, 2, 120, 20, true); + + if ((this->actor.world.pos.y - 50.0f <= player->actor.world.pos.y) && + (this->actor.floorBgId == BGCHECK_SCENE)) { + Math_Vec3f_Copy(&stonePos, &hitPos); + stonePos.x += Math_SinS(this->actor.world.rot.y) * 60.0f; + stonePos.z += Math_CosS(this->actor.world.rot.y) * 60.0f; + for (i = 0; i < 3; i++) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ESTONE, stonePos.x, stonePos.y, stonePos.z, 0, + this->actor.world.rot.y, 0, ENESTONE_TYPE_SMALL); + } + } + if (this->actor.world.pos.y - 50.0f <= player->actor.world.pos.y) { + for (i = 0; i < 10; i++) { + EnEgol_SpawnEffect(this, &hitPos, &gZeroVec3s, 30, (Rand_ZeroFloat(1.0f) * 0.1f) + 0.2f, + EYEGORE_EFFECT_DEBRIS); + } + } + this->actionTimer = 1; + } + if (this->actionTimer != 0) { + this->actionTimer++; + if (this->actionTimer >= 5) { + this->laserState = EYEGORE_LASER_OFF; + Math_Vec3f_Copy(&this->laserScale, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserScaleTarget, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[1], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[3], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[0], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[2], &this->laserBase); + this->actionTimer = 0; + } + } + Math_ApproachF(&this->laserScale.x, this->laserScaleTarget.x, 0.5f, 0.5f); + Math_ApproachF(&this->laserScale.y, this->laserScaleTarget.y, 0.5f, 0.5f); + Math_ApproachF(&this->laserScale.z, this->laserScaleTarget.z, 0.5f, 0.5f); + } + } +} + +void EnEgol_SetupStop(EnEgol* this) { + if (!this->isRetreating) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_LASER); + } else { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_STUN_END); + } + this->action = EYEGORE_ACTION_STOP; + this->actionFunc = EnEgol_Stop; +} + +void EnEgol_Stop(EnEgol* this, PlayState* play) { + s32 isHome = false; + f32 curFrame = this->skelAnime.curFrame; + s16 angleToHome; + + EnEgol_FootstepEffects(this, play, 28.0f, 13.0f); + if (this->isRetreating) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 5, 0xBB8, 5); + this->actor.world.rot.y = this->actor.shape.rot.y; + angleToHome = this->actor.world.rot.y - this->actor.home.rot.y; + } + if (!this->isRetreating) { + isHome = true; + } else if (ABS_ALT(angleToHome) < 0x64) { + this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.home.rot.y; + isHome = true; + } + if (isHome && (curFrame >= this->animEndFrame)) { + this->isRetreating ^= true; + if (!this->isRetreating) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_SIT); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_SIT); + this->laserCount = 0; + this->actionFunc = EnEgol_Wait; + } else { + EnEgol_SetupRetreat(this); + } + } +} + +void EnEgol_SetupSlam(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_SLAM); + this->action = EYEGORE_ACTION_SLAM; + this->actionFunc = EnEgol_Slam; +} + +void EnEgol_Slam(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + Math_SmoothStepToS(&this->headRot, 0, 1, 0x3E8, 0); + if (Animation_OnFrame(&this->skelAnime, 17.0f)) { + s32 i; + s32 spawnCount; + Player* player = GET_PLAYER(play); + Vec3f spawnPos; + f32 dyToPlayer = fabsf(player->actor.world.pos.y - this->actor.world.pos.y); + s32 quakeSize; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); + quakeSize = 4 - (s32)(dyToPlayer * 0.02f); + if (quakeSize > 4) { + quakeSize = 4; + } else if (quakeSize < 1) { + quakeSize = 1; + } + func_800BC848(&this->actor, play, quakeSize, 2); + if (this->actor.floorBgId == BGCHECK_SCENE) { + Math_Vec3f_Copy(&spawnPos, &this->actor.world.pos); + spawnPos.x += Math_SinS(this->actor.world.rot.y) * 60.0f; + spawnPos.y = this->actor.floorHeight; + spawnPos.z += Math_CosS(this->actor.world.rot.y) * 60.0f; + spawnCount = Rand_S16Offset(1, 3); + for (i = 0; i < spawnCount; i++) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ESTONE, spawnPos.x, spawnPos.y, spawnPos.z, 0, + this->actor.world.rot.y, 0, ENESTONE_TYPE_LARGE); + } + Actor_SpawnFloorDustRing(play, &this->actor, &spawnPos, 30.0f, 30, 10.0f, 100, 30, true); + Math_Vec3f_Copy(&spawnPos, &this->actor.world.pos); + spawnPos.x += Math_SinS(this->actor.world.rot.y) * 55.0f; + spawnPos.y = this->actor.floorHeight + 2.0f; + spawnPos.z += Math_CosS(this->actor.world.rot.y) * 55.0f; + EnEgol_SpawnEffect(this, &spawnPos, &gZeroVec3s, 100, 0.03f, EYEGORE_EFFECT_IMPACT); + } + EnEgol_DestroyBlocks(this, play, this->rightHandPos, this->leftHandPos); + } + if (this->animEndFrame <= curFrame) { + EnEgol_SetupSlamWait(this); + } else if ((this->skelAnime.curFrame <= 17.0f) && (this->skelAnime.curFrame >= 10.0f)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->bodyCollider.base); + } +} + +void EnEgol_SetupPunch(EnEgol* this) { + this->bodyCollider.elements[0].dim.modelSphere.radius = 40; + this->bodyCollider.elements[1].dim.modelSphere.radius = 40; + this->hitPlayer = false; + this->action = EYEGORE_ACTION_PUNCH; + this->actionFunc = EnEgol_Punch; +} + +void EnEgol_Punch(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + Math_SmoothStepToS(&this->headRot, 0, 1, 0x3E8, 0); + if (curFrame >= this->animEndFrame) { + this->bodyCollider.elements[0].dim.modelSphere.radius = 20; + this->bodyCollider.elements[1].dim.modelSphere.radius = 20; + EnEgol_SetupWalk(this); + } else if (!this->hitPlayer) { + if ((this->bodyCollider.elements[0].info.toucherFlags & TOUCH_HIT) || + (this->bodyCollider.elements[1].info.toucherFlags & TOUCH_HIT)) { + this->hitPlayer = true; + func_800B8D50(play, &this->actor, 10.0f, this->actor.home.rot.y, 10.0f, 0); + } + if (!(this->bodyCollider.base.atFlags & AT_BOUNCED)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->bodyCollider.base); + } + } +} + +void EnEgol_SetupSlamWait(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_SLAM_WAIT); + this->actionTimer = 0; + this->eyeCollider.elements[0].info.elemType = ELEMTYPE_UNK1; + this->action = EYEGORE_ACTION_SLAM_WAIT; + this->actionFunc = EnEgol_SlamWait; +} + +void EnEgol_SlamWait(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (curFrame >= this->animEndFrame) { + this->actionTimer++; + if (this->actionTimer > 20) { + this->eyeCollider.elements[0].info.elemType = ELEMTYPE_UNK2; + EnEgol_SetupSlamEnd(this); + } + } +} + +void EnEgol_SetupStunned(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_STUNNED); + this->actionTimer = 0; + this->eyeCollider.elements[0].info.elemType = ELEMTYPE_UNK1; + this->bodyCollider.elements[0].dim.modelSphere.radius = 0; + this->bodyCollider.elements[1].dim.modelSphere.radius = 0; + this->action = EYEGORE_ACTION_STUNNED; + this->actionFunc = EnEgol_Stunned; +} + +void EnEgol_Stunned(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (curFrame >= this->animEndFrame) { + this->actionTimer++; + if (this->actionTimer > 80) { + this->eyeCollider.elements->info.elemType = ELEMTYPE_UNK2; + EnEgol_SetupStunEnd(this); + } + } +} + +void EnEgol_SetupStunEnd(EnEgol* this) { + this->bodyCollider.elements[0].dim.modelSphere.radius = 20; + this->bodyCollider.elements[1].dim.modelSphere.radius = 20; + EnEgol_ChangeAnim(this, EYEGORE_ANIM_STUN_END); + this->action = EYEGORE_ACTION_STUN_END; + this->actionFunc = EnEgol_StunEnd; +} + +void EnEgol_StunEnd(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (curFrame >= this->animEndFrame) { + EnEgol_SetupWalk(this); + } +} + +void EnEgol_SetupSlamEnd(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_SLAM_END); + this->actionTimer = 0; + this->action = EYEGORE_ACTION_SLAM_END; + this->actionFunc = EnEgol_SlamEnd; +} + +void EnEgol_SlamEnd(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (curFrame >= this->animEndFrame) { + EnEgol_SetupWalk(this); + } +} + +void EnEgol_SetupDamaged(EnEgol* this) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_DAMAGED); + this->bodyCollider.elements[0].dim.modelSphere.radius = 20; + this->bodyCollider.elements[1].dim.modelSphere.radius = 20; + this->action = EYEGORE_ACTION_DAMAGED; + this->actionFunc = EnEgol_Damaged; +} + +void EnEgol_Damaged(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (curFrame >= this->animEndFrame) { + if (this->actor.colChkInfo.health > 0) { + EnEgol_SetupWalk(this); + } else { + Enemy_StartFinishingBlow(play, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DEAD); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_100000; + this->actionFunc = EnEgol_StartDeathCutscene; + } + } +} + +void EnEgol_StartDeathCutscene(EnEgol* this, PlayState* play) { + if (!ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + this->subCamFovTarget = 60.0f; + EnEgol_ChangeAnim(this, EYEGORE_ANIM_DEATH); + this->action = EYEGORE_ACTION_DYING; + this->actionFunc = EnEgol_Death; + this->actor.shape.shadowScale = 0.0f; + } +} + +void EnEgol_Death(EnEgol* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + Vec3f atOffset; + + this->subCamAt.x = 0.0f; + this->subCamAt.y = 60.0f; + this->subCamAt.z = 260.0f; + Math_Vec3f_Copy(&atOffset, &this->subCamAt); + OLib_DbCameraVec3fSum(&this->actor.world, &atOffset, &this->subCamAt, 1); + this->subCamEye.x = this->actor.world.pos.x; + this->subCamEye.y = this->actor.world.pos.y + 70.0f; + this->subCamEye.z = this->actor.world.pos.z; + Math_ApproachF(&this->subCamFov, this->subCamFovTarget, 0.3f, 10.0f); + Play_SetCameraAtEye(play, this->subCamId, &this->subCamEye, &this->subCamAt); + Play_SetCameraFov(play, this->subCamId, this->subCamFov); + if ((this->action == EYEGORE_ACTION_DEAD) && (this->waitTimer == 1)) { + if (this->switchFlag > -1) { + Flags_SetSwitch(play, this->switchFlag); + } + ActorCutscene_Stop(this->actor.cutscene); + Actor_Kill(&this->actor); + } else { + if (Animation_OnFrame(&this->skelAnime, 46.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_EXPLOSION); + func_800BC848(&this->actor, play, 10, 5); + } + if ((curFrame >= this->animEndFrame) && (this->action != EYEGORE_ACTION_DEAD)) { + s32 i; + + 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); + this->waitTimer = 30; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + this->action = EYEGORE_ACTION_DEAD; + for (i = 0; i < 20; i++) { + EnEgol_SpawnEffect(this, &this->actor.world.pos, &gZeroVec3s, 10.0f + Rand_ZeroFloat(20.0f), + 0.01f + (0.02f * Rand_ZeroFloat(1.0f)), (i & 1) + EYEGORE_EFFECT_PIECE_LARGE); + } + } + } +} + +typedef enum { + /* 0 */ EYEGORE_HIT_NONE, + /* 1 */ EYEGORE_HIT_DAMAGE, + /* 2 */ EYEGORE_HIT_IMMUNE, // Makes hitmarks, but no reaction +} EyegoreHitReaction; + +void EnEgol_CollisionCheck(EnEgol* this, PlayState* play) { + s16 angleToFacing = this->actor.world.rot.y - this->actor.yawTowardsPlayer; + s32 reaction = EYEGORE_HIT_NONE; + + if ((this->action == EYEGORE_ACTION_LASER) && (this->laserCollider.base.atFlags & AT_BOUNCED)) { + this->laserCollider.base.atFlags &= ~AT_HIT; + this->laserCollider.base.atFlags &= ~AT_BOUNCED; + this->actionTimer = 0; + this->laserState = EYEGORE_LASER_OFF; + Math_Vec3f_Copy(&this->laserScale, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserScaleTarget, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[1], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[3], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[0], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[2], &this->laserBase); + EnEgol_SetupWalk(this); + } + if (this->eyeCollider.elements[0].info.bumperFlags & BUMP_HIT) { + reaction = EYEGORE_HIT_IMMUNE; + switch (this->actor.colChkInfo.damageEffect) { + case EYEGORE_DMGEFF_LIGHT_ARROW: + if (ABS_ALT(angleToFacing) < 0x3000) { + if ((this->action == EYEGORE_ACTION_STUNNED) || (this->action == EYEGORE_ACTION_SLAM_WAIT)) { + 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); + this->dmgEffectTimer = 20; + reaction = EYEGORE_HIT_DAMAGE; + } else if ((this->action >= EYEGORE_ACTION_WALK) && (this->action <= EYEGORE_ACTION_STUN_END) && + !this->isRetreating) { + reaction = EYEGORE_HIT_NONE; + this->chargingLaser = false; + this->chargeLevel = 0; + this->actionTimer = 0; + this->laserState = EYEGORE_LASER_OFF; + Math_Vec3f_Copy(&this->laserScale, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserScaleTarget, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[1], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[3], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[0], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[2], &this->laserBase); + Actor_SetColorFilter(&this->actor, 0, 120, false, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnEgol_SetupStunned(this); + } + } + break; + + case EYEGORE_DMGEFF_NONE: + if ((this->action == EYEGORE_ACTION_SLAM_WAIT) || (this->action == EYEGORE_ACTION_STUNNED)) { + reaction = EYEGORE_HIT_DAMAGE; + } + break; + + default: + break; + } + } + if (reaction == EYEGORE_HIT_DAMAGE) { + Actor_ApplyDamage(&this->actor); + CollisionCheck_BlueBlood(play, NULL, &this->eyePos); + CollisionCheck_BlueBlood(play, NULL, &this->eyePos); + CollisionCheck_BlueBlood(play, NULL, &this->eyePos); + Actor_SetColorFilter(&this->actor, 0x4000, 255, false, 25); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_DAMAGE); + EnEgol_SetupDamaged(this); + } else if (reaction == EYEGORE_HIT_IMMUNE) { + Vec3f hitPos; + + hitPos.x = this->eyeCollider.elements[0].info.bumper.hitPos.x; + hitPos.y = this->eyeCollider.elements[0].info.bumper.hitPos.y; + hitPos.z = this->eyeCollider.elements[0].info.bumper.hitPos.z; + Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_SHIELD_BOUND); + EffectSsHitmark_SpawnFixedScale(play, EFFECT_HITMARK_METAL, &hitPos); + CollisionCheck_SpawnShieldParticlesMetal(play, &hitPos); + } +} + +void EnEgol_Update(Actor* thisx, PlayState* play) { + EnEgol* this = THIS; + Player* player = GET_PLAYER(play); + s32 pad; + + if (!((this->action == EYEGORE_ACTION_PUNCH) || (this->action == EYEGORE_ACTION_RETREAT) || + (this->action >= EYEGORE_ACTION_DYING))) { + s16 angleToFacing = this->actor.shape.rot.y - this->actor.yawTowardsPlayer; + s16 angleBehind = this->actor.world.rot.y - this->actor.yawTowardsPlayer + 0x8000; + + if ((ABS_ALT(angleToFacing) > 0x1888) && (ABS_ALT(angleBehind) > 0x2000) && + (this->actor.xzDistToPlayer < 100.0f)) { + if (angleToFacing < 0) { + if (this->animation != EYEGORE_ANIM_LEFT_PUNCH) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_LEFT_PUNCH); + } + } else if (this->animation != EYEGORE_ANIM_RIGHT_PUNCH) { + EnEgol_ChangeAnim(this, EYEGORE_ANIM_RIGHT_PUNCH); + } + this->chargingLaser = false; + this->chargeLevel = 0; + this->actionTimer = 0; + this->laserState = EYEGORE_LASER_OFF; + Math_Vec3f_Copy(&this->laserScale, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserScaleTarget, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[1], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[3], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[0], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[2], &this->laserBase); + EnEgol_SetupPunch(this); + } + } + if (this->action != EYEGORE_ACTION_WAIT) { + SkelAnime_Update(&this->skelAnime); + } + if (this->laserState == EYEGORE_LASER_OFF) { + Math_ApproachZeroF(&this->laserLightScale, 0.5f, 0.5f); + } else if (this->laserState >= EYEGORE_LASER_FIRE) { + Math_ApproachF(&this->laserLightScale, 1.0f, 0.5f, 0.5f); + } + Actor_SetScale(&this->actor, 0.015f); + + if (!((this->action == EYEGORE_ACTION_STOP) || (this->action == EYEGORE_ACTION_RETREAT))) { + this->actor.shape.rot.y = this->actor.world.rot.y; + } + this->texScroll += 12; + DECR(this->waitTimer); + DECR(this->eyeShutTimer); + DECR(this->dmgEffectTimer); + + EnEgol_UpdateEffects(this, play); + this->actionFunc(this, play); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->eyePos); + 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; + if (!((this->action == EYEGORE_ACTION_SLAM_WAIT) || (this->action == EYEGORE_ACTION_WAIT) || + (this->action == EYEGORE_ACTION_RETREAT) || (this->action == EYEGORE_ACTION_STAND) || + (this->action == EYEGORE_ACTION_LASER) || (this->action == EYEGORE_ACTION_STUNNED) || + (this->action == EYEGORE_ACTION_DAMAGED) || (this->action == EYEGORE_ACTION_DYING))) { + + this->pupilRot.x = Math_Vec3f_Pitch(&this->eyePos, &player->actor.world.pos); + this->pupilRot.y = -Math_Vec3f_Yaw(&this->eyePos, &player->actor.world.pos); + + this->pupilRot.y += this->actor.world.rot.y; + + if (this->pupilRot.x > 0x7D0) { + this->pupilRot.x = 0x7D0; + } else if (this->pupilRot.x < -0x7D0) { + this->pupilRot.x = -0x7D0; + } + if (this->pupilRot.y > 0x1770) { + this->pupilRot.y = 0x1770; + } else if (this->pupilRot.y < -0x1770) { + this->pupilRot.y = -0x1770; + } + } else { + this->pupilRot.x = this->pupilRot.y = 0; + } + if (this->eyeShutTimer == 0) { + if (((this->action == EYEGORE_ACTION_WALK) || (this->action == EYEGORE_ACTION_LASER)) && !this->isRetreating) { + Actor* projectile = func_800BC270(play, &this->actor, 80.0f, 0x138B0); + // last argument is DMG_ZORA_BOOMERANG | DMG_HOOKSHOT | DMG_NORMAL_ARROW | DMG_FIRE_ARROW | DMG_ICE_ARROW | + // DMG_LIGHT_ARROW | DMG_DEKU_BUBBLE + + if ((projectile != NULL) && !((projectile->id == ACTOR_EN_ARROW) && (projectile->params == ENARROW_5))) { + this->eyelidRotTarget = 0xFA0; + this->eyeShutTimer = 20; + if (this->action == EYEGORE_ACTION_LASER) { + this->chargingLaser = false; + this->chargeLevel = 0; + this->actionTimer = 0; + this->laserState = EYEGORE_LASER_OFF; + Math_Vec3f_Copy(&this->laserScale, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserScaleTarget, &gZeroVec3f); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[1], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[3], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[0], &this->laserBase); + Math_Vec3f_Copy(&this->laserCollider.dim.quad[2], &this->laserBase); + EnEgol_SetupWalk(this); + } + } + } else { + this->eyelidRotTarget = 0; + } + } else if (this->eyeShutTimer == 1) { + this->eyelidRotTarget = 0; + } + Math_SmoothStepToS(&this->eyelidRot, this->eyelidRotTarget, 1, 0x7D0, 0); + EnEgol_CollisionCheck(this, play); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 50.0f, 50.0f, 0x1D); + if (this->action != EYEGORE_ACTION_DEAD) { + //! @bug This should be ||, not &&. As is, the check always succeeds. + if (!((this->action == EYEGORE_ACTION_DAMAGED) && (this->action == EYEGORE_ACTION_DYING))) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->eyeCollider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bodyCollider.base); + } + CollisionCheck_SetOC(play, &play->colChkCtx, &this->bodyCollider.base); + } + if (this->laserState >= EYEGORE_LASER_ON) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->laserCollider.base); + } +} + +s32 EnEgol_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnEgol* this = THIS; + + if (limbIndex == EYEGORE_LIMB_HEAD) { + rot->z += this->headRot; + } + if (limbIndex == EYEGORE_LIMB_UPPER_EYELID) { + rot->z += this->eyelidRot; + } + if (limbIndex == EYEGORE_LIMB_LOWER_EYELID) { + rot->z += -1 * this->eyelidRot; + } + if (limbIndex == EYEGORE_LIMB_PUPIL) { + rot->y += this->pupilRot.y; + rot->z += this->pupilRot.x; + } + if (limbIndex == EYEGORE_LIMB_EYEBALL) { + s32 eyeColorIndex = 0; + + OPEN_DISPS(play->state.gfxCtx); + + if ((this->action == EYEGORE_ACTION_DAMAGED) || (this->action == EYEGORE_ACTION_DYING)) { + eyeColorIndex = 2; + } else if ((this->action == EYEGORE_ACTION_STUNNED) || (this->action == EYEGORE_ACTION_SLAM_WAIT)) { + eyeColorIndex = 1; + } + this->eyePrimColor.r = sEyePrimColors[eyeColorIndex].r; + this->eyePrimColor.g = sEyePrimColors[eyeColorIndex].g; + this->eyePrimColor.b = sEyePrimColors[eyeColorIndex].b; + this->eyeEnvColor.r = sEyeEnvColors[eyeColorIndex].r; + this->eyeEnvColor.g = sEyeEnvColors[eyeColorIndex].g; + this->eyeEnvColor.b = sEyeEnvColors[eyeColorIndex].b; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0xFF, (u8)this->eyePrimColor.r, (u8)this->eyePrimColor.g, + (u8)this->eyePrimColor.b, 255); + gDPSetEnvColor(POLY_OPA_DISP++, (u8)this->eyeEnvColor.r, (u8)this->eyeEnvColor.g, (u8)this->eyeEnvColor.b, 255); + gSPSegment(POLY_OPA_DISP++, 0x09, func_8012CB28(play->state.gfxCtx, 0, this->texScroll)); + + CLOSE_DISPS(play->state.gfxCtx); + } + return false; +} + +void EnEgol_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnEgol* this = THIS; + Vec3f footOffset = { 1000.0f, 0.0f, 0.0f }; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == EYEGORE_LIMB_LEFT_HAND) { + Matrix_MultVec3f(&gZeroVec3f, &this->leftHandPos); + } + if (limbIndex == EYEGORE_LIMB_RIGHT_HAND) { + Matrix_MultVec3f(&gZeroVec3f, &this->rightHandPos); + } + if (limbIndex == EYEGORE_LIMB_LASER_ATTACH) { + Matrix_MultVec3f(&gZeroVec3f, &this->eyePos); + } + if ((limbIndex == EYEGORE_LIMB_LASER_ATTACH) && (this->laserState >= EYEGORE_LASER_FIRE)) { + Vec3f laserLengthZ = { 0.0f, 0.0f, 0.0f }; + Vec3f laserVec; + f32 targetScale; + f32 targetHeight; + + Matrix_MultVec3f(&zeroVec, &this->laserBase); + this->laserCollider.dim.quad[3].x = + this->laserBase.x + Math_SinS(this->actor.world.rot.y + 0x4000) * this->laserScale.x * 77.0f; + this->laserCollider.dim.quad[3].y = this->laserBase.y; + this->laserCollider.dim.quad[3].z = + this->laserBase.z + Math_CosS(this->actor.world.rot.y + 0x4000) * this->laserScale.x * 77.0f; + this->laserCollider.dim.quad[2].x = + this->laserBase.x + Math_SinS(this->actor.world.rot.y + 0xC000) * this->laserScale.x * 77.0f; + this->laserCollider.dim.quad[2].y = this->laserBase.y; + this->laserCollider.dim.quad[2].z = + this->laserBase.z + Math_CosS(this->actor.world.rot.y + 0xC000) * this->laserScale.x * 77.0f; + + targetScale = this->laserScale.z; + targetHeight = this->laserCollider.dim.quad[3].y; + + while ((targetHeight + 20.0f > this->actor.floorHeight) && (targetScale < 10.0f)) { + Matrix_Push(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->laserRot.x, MTXMODE_APPLY); + laserLengthZ.z = targetScale * 700.0f; + Matrix_MultVec3f(&laserLengthZ, &laserVec); + Matrix_Pop(); + targetHeight = this->laserCollider.dim.quad[3].y + laserVec.y; + targetScale += 0.01f; + } + this->laserScaleTarget.z = targetScale; + Matrix_Push(); + Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_NEW); + Matrix_RotateXS(this->laserRot.x, MTXMODE_APPLY); + laserLengthZ.z = this->laserScale.z * 700.0f; + Matrix_MultVec3f(&laserLengthZ, &laserVec); + Matrix_Pop(); + this->laserCollider.dim.quad[1].x = this->laserCollider.dim.quad[3].x + laserVec.x; + this->laserCollider.dim.quad[1].y = this->laserCollider.dim.quad[3].y + laserVec.y; + this->laserCollider.dim.quad[1].z = this->laserCollider.dim.quad[3].z + laserVec.z; + this->laserCollider.dim.quad[0].x = this->laserCollider.dim.quad[2].x + laserVec.x; + this->laserCollider.dim.quad[0].y = this->laserCollider.dim.quad[2].y + laserVec.y; + this->laserCollider.dim.quad[0].z = this->laserCollider.dim.quad[2].z + laserVec.z; + Collider_SetQuadVertices(&this->laserCollider, &this->laserCollider.dim.quad[0], + &this->laserCollider.dim.quad[1], &this->laserCollider.dim.quad[2], + &this->laserCollider.dim.quad[3]); + this->laserState = EYEGORE_LASER_ON; + } + if ((limbIndex == EYEGORE_LIMB_LASER_ATTACH) && (this->laserState == EYEGORE_LASER_START)) { + this->chargingLaser = true; + this->laserState = EYEGORE_LASER_CHARGING; + this->laserScaleTarget.x = 0.03f; + this->laserScaleTarget.y = 0.03f; + } + if (limbIndex == EYEGORE_LIMB_LEFT_FOOT) { + Matrix_MultVec3f(&footOffset, &this->leftFootPos); + } + if (limbIndex == EYEGORE_LIMB_RIGHT_FOOT) { + Matrix_MultVec3f(&footOffset, &this->rightFootPos); + } + if ((limbIndex == EYEGORE_LIMB_HEAD) || (limbIndex == EYEGORE_LIMB_LEFT_SHOULDER) || + (limbIndex == EYEGORE_LIMB_LEFT_ARM) || (limbIndex == EYEGORE_LIMB_LEFT_HAND) || + (limbIndex == EYEGORE_LIMB_RIGHT_SHOULDER) || (limbIndex == EYEGORE_LIMB_RIGHT_ARM) || + (limbIndex == EYEGORE_LIMB_RIGHT_HAND) || (limbIndex == EYEGORE_LIMB_UPPER_EYELID) || + (limbIndex == EYEGORE_LIMB_LOWER_EYELID) || (limbIndex == EYEGORE_LIMB_HIPS) || + (limbIndex == EYEGORE_LIMB_LEFT_SHIN) || (limbIndex == EYEGORE_LIMB_RIGHT_SHIN)) { + Matrix_MultZero(&this->limbPos[this->limbPosIndex]); + this->limbPosIndex++; + if (this->limbPosIndex >= ARRAY_COUNT(this->limbPos)) { + this->limbPosIndex = 0; + } + } + Collider_UpdateSpheres(limbIndex, &this->bodyCollider); + Collider_UpdateSpheres(limbIndex, &this->eyeCollider); +} + +void EnEgol_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnEgol* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + if (this->action != EYEGORE_ACTION_DEAD) { + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gEyegoreEyeLaserTexAnim)); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnEgol_OverrideLimbDraw, EnEgol_PostLimbDraw, &this->actor); + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + } + if (this->dmgEffectTimer != 0) { + f32 drawDmgEffAlpha = 0.05f * this->dmgEffectTimer; + + Actor_DrawDamageEffects(play, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), 0.8f, 0.8f, + drawDmgEffAlpha, ACTOR_DRAW_DMGEFF_LIGHT_ORBS); + } + if (this->laserState >= EYEGORE_LASER_FIRE) { + this->laserRot.y = this->actor.world.rot.y; + gSPSegment(POLY_OPA_DISP++, 0x08, func_8012CB28(play->state.gfxCtx, 0, this->texScroll)); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + Matrix_Translate(this->laserBase.x, this->laserBase.y, this->laserBase.z, MTXMODE_NEW); + Matrix_RotateZYX(this->laserRot.x, this->laserRot.y, 0, MTXMODE_APPLY); + Matrix_Scale(this->laserScale.x, this->laserScale.y, this->laserScale.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++, gEyegoreLaserDL); + } + if (((this->action == EYEGORE_ACTION_LASER) && (this->laserState >= EYEGORE_LASER_FIRE)) || this->chargingLaser) { + func_8012C2DC(play->state.gfxCtx); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbMaterial1DL); + if (!this->chargingLaser) { + s32 i; + f32 laserLightScaleMod; + f32 laserLightAlpha; + + gDPSetEnvColor(POLY_XLU_DISP++, 155, 255, 255, 128); + Matrix_Translate(this->eyePos.x, this->eyePos.y, this->eyePos.z, MTXMODE_NEW); + Matrix_Scale(this->laserLightScale, this->laserLightScale, this->laserLightScale, MTXMODE_APPLY); + + laserLightScaleMod = 10.0f; + laserLightAlpha = 80.0f; + for (i = 0; i < ARRAY_COUNT(sLightOrbColors); i++) { + Matrix_Push(); + Matrix_Scale(laserLightScaleMod, laserLightScaleMod, laserLightScaleMod, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, sLightOrbColors[i].r, sLightOrbColors[i].g, sLightOrbColors[i].b, + laserLightAlpha); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbModelDL); + Matrix_Pop(); + laserLightScaleMod = 3.0f; + laserLightAlpha = 200.0f; + } + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 155, 255, 255, 128); + Matrix_Translate(this->eyePos.x, this->eyePos.y, this->eyePos.z, MTXMODE_NEW); + Matrix_Scale(this->chargeLightScale, this->chargeLightScale, this->chargeLightScale, MTXMODE_APPLY); + Matrix_Push(); + Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_RotateZS(this->chargeLightRot, MTXMODE_APPLY); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gLightOrbModelDL); + Matrix_Pop(); + } + } + EnEgol_DrawEffects(this, play); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnEgol_SpawnEffect(EnEgol* this, Vec3f* pos, Vec3s* rot, s16 lifetime, f32 scale, s16 type) { + EnEgolEffect* effect = this->effects; + s16 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isActive) { + effect->isActive = true; + effect->scale = scale; + effect->pos = *pos; + effect->timer = lifetime; + effect->alpha = 255; + effect->type = type; + effect->rot.x = randPlusMinusPoint5Scaled(0x7530); + effect->rot.y = randPlusMinusPoint5Scaled(0x7530); + effect->rot.z = randPlusMinusPoint5Scaled(0x7530); + if ((effect->type == EYEGORE_EFFECT_PIECE_LARGE) || (effect->type == EYEGORE_EFFECT_PIECE_SMALL)) { + effect->accel.y = -1.0f; + effect->velocity.x = 4.0f * (Rand_ZeroOne() - 0.5f); + effect->velocity.y = 10.0f + (10.0f * Rand_ZeroOne()); + effect->velocity.z = 4.0f * (Rand_ZeroOne() - 0.5f); + break; + } else if (effect->type == EYEGORE_EFFECT_DEBRIS) { + effect->accel.y = -1.0f; + effect->velocity.x = 0.5f * (Rand_ZeroOne() - 0.5f); + effect->velocity.y = 5.0f + (5.0f * Rand_ZeroOne()); + effect->velocity.z = 0.5f * (Rand_ZeroOne() - 0.5f); + effect->timer = 20.0f + Rand_ZeroFloat(10.0f); + break; + } else if (effect->type == EYEGORE_EFFECT_IMPACT) { + effect->rot.x = rot->x; + effect->rot.y = 0; + effect->rot.z = rot->z; + break; + } + } + } +} + +void EnEgol_UpdateEffects(EnEgol* this, PlayState* play) { + EnEgolEffect* effect = this->effects; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isActive) { + if (this->action == EYEGORE_ACTION_DYING) { + effect->timer = 0; + } + if (effect->type != EYEGORE_EFFECT_IMPACT) { + effect->rot.x += 0x100; + effect->rot.z += 0x130; + + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + + effect->velocity.y += effect->accel.y; + } + if (effect->timer != 0) { + effect->timer--; + } else if (effect->type == EYEGORE_EFFECT_IMPACT) { + effect->alpha -= 10; + if (effect->alpha < 10) { + effect->isActive = false; + } + } else { + effect->isActive = false; + } + } + } +} + +void EnEgol_DrawEffects(EnEgol* this, PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + EnEgolEffect* effect = this->effects; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(play->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isActive) { + Matrix_Push(); + + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateXS(effect->rot.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->rot.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->rot.z, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + + switch (effect->type) { + case EYEGORE_EFFECT_IMPACT: + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 155, 155, 155, 255); + Matrix_Translate(0.0f, 50.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, effect->alpha); + gSPDisplayList(POLY_OPA_DISP++, gEyegoreEffectImpactDL); + break; + + case EYEGORE_EFFECT_PIECE_LARGE: + case EYEGORE_EFFECT_PIECE_SMALL: + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, effect->alpha); + if (effect->type == EYEGORE_EFFECT_PIECE_LARGE) { + gSPDisplayList(POLY_OPA_DISP++, gEyegoreEffectLargeBodyPieceDL); + } else { + gSPDisplayList(POLY_OPA_DISP++, gEyegoreEffectSmallBodyPieceDL); + } + break; + + case EYEGORE_EFFECT_DEBRIS: + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gEyegoreEffectSolidDebrisDL); + break; + + default: + break; + } + Matrix_Pop(); + } + } + + CLOSE_DISPS(gfxCtx); +} 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..cec69e5a1 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.h +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.h @@ -2,18 +2,94 @@ #define Z_EN_EGOL_H #include "global.h" +#include "objects/object_eg/object_eg.h" struct EnEgol; -typedef void (*EnEgolActionFunc)(struct EnEgol*, GlobalContext*); +typedef void (*EnEgolActionFunc)(struct EnEgol*, PlayState*); + +#define EYEGORE_GET_PATH(thisx) ((thisx)->params & 0x3F) +#define EYEGORE_GET_SWITCH(thisx) (((thisx)->params >> 6) & 0x7F) + +#define EYEGORE_PARAMS(switch, path) ((((switch) & 0x7F) << 6) | ((path) & 0x3F)) + +#define EYEGORE_EFFECT_COUNT 100 + +typedef struct { + /* 0x00 */ u8 isActive; + /* 0x04 */ Vec3f pos; + /* 0x10 */ s16 alpha; + /* 0x12 */ s16 timer; + /* 0x14 */ s16 type; + /* 0x18 */ Vec3f velocity; + /* 0x24 */ Vec3f accel; + /* 0x30 */ Vec3s rot; + /* 0x38 */ f32 scale; +} EnEgolEffect; // size = 0x3C typedef struct EnEgol { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[EYEGORE_LIMB_MAX]; + /* 0x0218 */ Vec3s morphTable[EYEGORE_LIMB_MAX]; /* 0x02A8 */ EnEgolActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x1BC4]; + /* 0x02AC */ Path* path; + /* 0x02B0 */ s16 waypoint; + /* 0x02B2 */ s16 action; + /* 0x02B4 */ s16 waitTimer; + /* 0x02B6 */ s16 eyeShutTimer; + /* 0x02B4 */ s16 headRot; + /* 0x02BA */ s16 switchFlag; + /* 0x02BC */ s16 dmgEffectTimer; + /* 0x02C0 */ Vec3f limbPos[12]; + /* 0x0350 */ s16 limbPosIndex; + /* 0x0352 */ s16 pathIndex; + /* 0x0354 */ s32 animation; + /* 0x0358 */ u8 isRetreating; + /* 0x035C */ f32 animEndFrame; + /* 0x0360 */ f32 wakeupRange; + /* 0x0364 */ f32 minLaserRange; + /* 0x0368 */ UNK_TYPE1 unk_368[4]; // f32? + /* 0x036C */ f32 laserLightScale; + /* 0x0370 */ f32 chargeLightScale; + /* 0x0374 */ s16 eyelidRot; + /* 0x0376 */ s16 eyelidRotTarget; + /* 0x0378 */ s16 actionTimer; + /* 0x037C */ s32 laserCount; + /* 0x0380 */ s32 chargingLaser; + /* 0x0384 */ s16 chargeLightRot; + /* 0x0388 */ s32 chargeLevel; + /* 0x038C */ s32 hitPlayer; + /* 0x0390 */ UNK_TYPE1 unk_390[0xC]; // Vec3f? + /* 0x039C */ Vec3f eyePos; + /* 0x03A8 */ Vec3f laserBase; + /* 0x03B4 */ Vec3f laserScale; + /* 0x03C0 */ Vec3f laserScaleTarget; + /* 0x03CC */ UNK_TYPE1 unk_3CC[0xC]; // Vec3f? + /* 0x03D8 */ Vec3f leftFootPos; + /* 0x03E4 */ Vec3f rightFootPos; + /* 0x03F0 */ Vec3f leftHandPos; + /* 0x03FC */ Vec3f rightHandPos; + /* 0x0408 */ Vec3f waypointPos; + /* 0x0414 */ Vec3s pupilRot; + /* 0x041A */ Vec3s laserRot; + /* 0x0420 */ Color_RGB16 eyePrimColor; + /* 0x0426 */ Color_RGB16 eyeEnvColor; + /* 0x042C */ s16 laserState; + /* 0x0430 */ s32 texScroll; + /* 0x0434 */ EnEgolEffect effects[EYEGORE_EFFECT_COUNT]; + /* 0x1BA4 */ ColliderJntSph bodyCollider; + /* 0x1BC4 */ ColliderJntSphElement bodyElements[6]; + /* 0x1D44 */ ColliderJntSph eyeCollider; + /* 0x1D64 */ ColliderJntSphElement eyeElements[1]; + /* 0x1DA4 */ ColliderQuad laserCollider; + /* 0x1E24 */ UNK_TYPE1 unk_1E24[4]; + /* 0x1E28 */ s16 subCamId; + /* 0x1E2C */ f32 subCamFov; + /* 0x1E30 */ f32 subCamFovTarget; + /* 0x1E34 */ Vec3f subCamAt; + /* 0x1E40 */ Vec3f subCamEye; + /* 0x1E4C */ UNK_TYPE1 unk_1E4C[0x24]; // Vec3f[3]? } EnEgol; // size = 0x1E70 -extern const ActorInit En_Egol_InitVars; - #endif // Z_EN_EGOL_H diff --git a/src/overlays/actors/ovl_En_Elf/overlay.cfg b/src/overlays/actors/ovl_En_Elf/overlay.cfg deleted file mode 100644 index cc1ddac28..000000000 --- a/src/overlays/actors/ovl_En_Elf/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Elf -z_en_elf.c 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 f71c0b30d..54d5c3210 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -11,29 +11,29 @@ #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* play2); +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 sparkleLife); +void func_8089010C(Actor* thisx, PlayState* play); +void func_808908D0(Vec3f* vec, PlayState* play, u32 action); -const ActorInit En_Elf_InitVars = { +ActorInit En_Elf_InitVars = { ACTOR_EN_ELF, ACTORCAT_ITEMACTION, FLAGS, @@ -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,11 +293,11 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if ((this->fairyFlags & 0x400) && Flags_GetCollectible(play, this->unk_260)) { + Actor_Kill(&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 = QuestHint_GetTatlTextId(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,11 +416,11 @@ void EnElf_Init(Actor* thisx, GlobalContext* globalCtx2) { case 10: colorConfig = -2; - func_8088CC48(this, globalCtx); + func_8088CC48(this, play); break; case 8: - Actor_MarkForDeath(thisx); + Actor_Kill(thisx); return; case 3: @@ -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; @@ -565,17 +565,17 @@ void func_8088D9BC(EnElf* this, GlobalContext* globalCtx) { switch (this->unk_244) { case 0: - targetYaw = Math_FAtan2F(-(this->actor.world.pos.z - vec->z), -(this->actor.world.pos.x - vec->x)); + targetYaw = Math_Atan2S_XY(-(this->actor.world.pos.z - vec->z), -(this->actor.world.pos.x - vec->x)); break; case 3: - targetYaw = Math_FAtan2F(-(this->actor.world.pos.z - player->actor.world.pos.z), - -(this->actor.world.pos.x - player->actor.world.pos.x)); + targetYaw = Math_Atan2S_XY(-(this->actor.world.pos.z - player->actor.world.pos.z), + -(this->actor.world.pos.x - player->actor.world.pos.x)); break; case 2: - targetYaw = Math_FAtan2F(this->actor.world.pos.z - player->actor.world.pos.z, - this->actor.world.pos.x - player->actor.world.pos.x); + targetYaw = Math_Atan2S_XY(this->actor.world.pos.z - player->actor.world.pos.z, + this->actor.world.pos.x - player->actor.world.pos.x); break; default: @@ -627,17 +627,17 @@ s32 func_8088DCA4(EnElf* this) { if (this->disappearTimer > -10) { Actor_SetScale(&this->actor, (this->disappearTimer + 10) * 0.008f * 0.1f); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return true; } } 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); + Actor_Kill(&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,9 @@ 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); + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); } gSaveContext.jinxTimer = 0; this->unk_254 = 50.0f; @@ -687,7 +686,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 +700,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)) { @@ -718,16 +717,16 @@ void func_8088E018(EnElf* this, GlobalContext* globalCtx) { parentPos.y += (1500.0f * this->actor.scale.y) + 40.0f; func_8088D660(this, &parentPos, 0.2f); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } - this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); + this->unk_258 = Math_Atan2S_XY(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); @@ -763,21 +762,21 @@ void func_8088E0F0(EnElf* this, GlobalContext* globalCtx) { } if (this->unk_224.y < -10.0f) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); - func_8088F5F4(this, globalCtx, 32); + this->unk_258 = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); + 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -800,14 +799,14 @@ void func_8088E304(EnElf* this, GlobalContext* globalCtx) { this->unk_224.z = Math_SinS(this->unk_248) * -this->unk_254; this->unk_248 += this->unk_24C; - func_8088D7F8(this, &player->bodyPartsPos[0]); - this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); - func_8088F5F4(this, globalCtx, 0x20); + func_8088D7F8(this, &player->bodyPartsPos[PLAYER_BODYPART_WAIST]); + this->unk_258 = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); + 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); @@ -824,45 +823,45 @@ void func_8088E484(EnElf* this, GlobalContext* globalCtx) { this->unk_254 = 1.0f; } - func_8088D7F8(this, &player->bodyPartsPos[0]); + func_8088D7F8(this, &player->bodyPartsPos[PLAYER_BODYPART_WAIST]); 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); + this->unk_258 = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); + 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) { + if (player->stateFlags1 & PLAYER_STATE1_400) { glowLightRadius = 200; } else { glowLightRadius = 100; } - if ((this->unk_244 == 6) || (player->stateFlags1 & 2) || (this->fairyFlags & 0x8000)) { + if ((this->unk_244 == 6) || (player->stateFlags1 & PLAYER_STATE1_2) || (this->fairyFlags & 0x8000)) { 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); @@ -873,29 +872,29 @@ void func_8088E60C(EnElf* this, GlobalContext* globalCtx) { Lights_PointGlowSetInfo(&this->lightInfoGlow, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 255, 255, 255, glowLightRadius); - this->unk_258 = Math_FAtan2F(this->actor.velocity.z, this->actor.velocity.x); + this->unk_258 = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); 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,24 +903,23 @@ 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->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 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->sceneId == SCENE_SECOM) && (gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 4) && + (play->csCtx.frames == 95)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WHITE_FAIRY_DASH); } } else { this->actor.shape.rot.x = 0; - distFromLinksHead = Math_Vec3f_DistXYZ(&player->bodyPartsPos[8], &this->actor.world.pos); + distFromLinksHead = Math_Vec3f_DistXYZ(&player->bodyPartsPos[PLAYER_BODYPART_HAT], &this->actor.world.pos); switch (this->unk_244) { case 5: - func_8088D660(this, &player->bodyPartsPos[8], 1.0f - (this->unk_24A * 0.033333335f)); - xScale = Math_Vec3f_DistXYZ(&player->bodyPartsPos[8], &this->actor.world.pos); + func_8088D660(this, &player->bodyPartsPos[PLAYER_BODYPART_HAT], 1.0f - (this->unk_24A * 0.033333335f)); + xScale = Math_Vec3f_DistXYZ(&player->bodyPartsPos[PLAYER_BODYPART_HAT], &this->actor.world.pos); if (distFromLinksHead < 7.0f) { this->unk_25C = 0; @@ -933,20 +931,20 @@ void func_8088E850(EnElf* this, GlobalContext* globalCtx) { } else { xScale = 0.008f; } - func_8088F5F4(this, globalCtx, 16); + func_8088F5F4(this, play, 16); break; case 6: - func_8088D660(this, &player->bodyPartsPos[8], 0.2f); - this->actor.world.pos = player->bodyPartsPos[8]; + func_8088D660(this, &player->bodyPartsPos[PLAYER_BODYPART_HAT], 0.2f); + this->actor.world.pos = player->bodyPartsPos[PLAYER_BODYPART_HAT]; break; case 9: - nextPos = player->bodyPartsPos[8]; + nextPos = player->bodyPartsPos[PLAYER_BODYPART_HAT]; 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 +960,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; - if ((player->stateFlags1 & 0x40) && (player->targetActor != NULL)) { - Math_Vec3f_Copy(&nextPos, &player->targetActor->focus.pos); + arrowPointedActor = play->actorCtx.targetContext.arrowPointedActor; + if ((player->stateFlags1 & PLAYER_STATE1_40) && (player->talkActor != NULL)) { + Math_Vec3f_Copy(&nextPos, &player->talkActor->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 +989,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 +1013,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 +1034,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 +1060,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,27 +1068,27 @@ 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); } } if (this->fairyFlags & 1) { - if ((arrayPointerActor == NULL) || (player->unk_730 == NULL)) { + if ((arrayPointerActor == NULL) || (player->targetedActor == NULL)) { this->fairyFlags ^= 1; } - } else if ((arrayPointerActor != NULL) && (player->unk_730 != NULL)) { + } else if ((arrayPointerActor != NULL) && (player->targetedActor != NULL)) { u8 temp = this->unk_269; u16 targetSfxId = this->unk_269 == 0 ? NA_SE_PL_WALK_GROUND - SFX_FLAG : NA_SE_PL_WALK_GROUND - SFX_FLAG; @@ -1101,15 +1099,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,14 +1132,14 @@ 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; - if (player->stateFlags1 & 0x400) { + arrowPointedActor = play->actorCtx.targetContext.arrowPointedActor; + if (player->stateFlags1 & PLAYER_STATE1_400) { sp34 = 10; this->unk_25C = 100; } else if ((arrowPointedActor == NULL) || (arrowPointedActor->category == 4)) { if (arrowPointedActor != NULL) { this->unk_25C = 100; - player->stateFlags2 |= 0x100000; + player->stateFlags2 |= PLAYER_STATE2_100000; sp34 = 0; } else { switch (this->unk_244) { @@ -1149,7 +1147,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { if (this->unk_25C != 0) { this->unk_25C--; sp34 = 0; - } else if (!(player->stateFlags1 & 0x40)) { + } else if (!(player->stateFlags1 & PLAYER_STATE1_40)) { if (this->unk_269 == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); } @@ -1165,7 +1163,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { this->unk_24A--; sp34 = 5; } else { - player->stateFlags2 |= 0x100000; + player->stateFlags2 |= PLAYER_STATE2_100000; sp34 = 0; } } else { @@ -1197,7 +1195,7 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { switch (sp34) { case 0: - if (!(player->stateFlags2 & 0x100000)) { + if (!(player->stateFlags2 & PLAYER_STATE2_100000)) { sp34 = 5; if (this->unk_269 == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_NAVY_VANISH); @@ -1206,25 +1204,25 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { break; case 6: - if (player->stateFlags2 & 0x100000) { + if (player->stateFlags2 & PLAYER_STATE2_100000) { sp34 = 9; this->unk_25C = 0x2A; if (this->unk_269 == 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BELL_DASH_NORMAL); } - } else if (player->stateFlags1 & 0x40) { - player->stateFlags2 |= 0x100000; + } else if (player->stateFlags1 & PLAYER_STATE1_40) { + player->stateFlags2 |= PLAYER_STATE2_100000; sp34 = 0; this->unk_25C = 0; } break; case 5: - player->stateFlags2 &= ~0x100000; + player->stateFlags2 &= ~PLAYER_STATE2_100000; break; default: - player->stateFlags2 |= 0x100000; + player->stateFlags2 |= PLAYER_STATE2_100000; break; } } @@ -1232,13 +1230,13 @@ void func_8088F214(EnElf* this, GlobalContext* globalCtx) { if (sp34 != this->unk_244) { func_8088C51C(this, sp34); if (sp34 == 9) { - this->unk_254 = Math_Vec3f_DistXZ(&player->bodyPartsPos[8], &this->actor.world.pos); - this->unk_248 = Math_Vec3f_Yaw(&this->actor.world.pos, &player->bodyPartsPos[8]); + this->unk_254 = Math_Vec3f_DistXZ(&player->bodyPartsPos[PLAYER_BODYPART_HAT], &this->actor.world.pos); + this->unk_248 = Math_Vec3f_Yaw(&this->actor.world.pos, &player->bodyPartsPos[PLAYER_BODYPART_HAT]); } } } -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,35 +1257,37 @@ 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; } else { - if ((player->unk_730 == NULL) || (&player->actor == player->unk_730) || (&this->actor == player->unk_730) || - (this->unk_264 & 4)) { - refPos.x = player->bodyPartsPos[7].x + (Math_SinS(player->actor.shape.rot.y) * 20.0f); - refPos.y = player->bodyPartsPos[7].y + 5.0f; - refPos.z = player->bodyPartsPos[7].z + (Math_CosS(player->actor.shape.rot.y) * 20.0f); + if ((player->targetedActor == NULL) || (&player->actor == player->targetedActor) || + (&this->actor == player->targetedActor) || (this->unk_264 & 4)) { + refPos.x = + player->bodyPartsPos[PLAYER_BODYPART_HEAD].x + (Math_SinS(player->actor.shape.rot.y) * 20.0f); + refPos.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 5.0f; + refPos.z = + player->bodyPartsPos[PLAYER_BODYPART_HEAD].z + (Math_CosS(player->actor.shape.rot.y) * 20.0f); this->unk_264 &= ~4; } } @@ -1295,20 +1295,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 +1319,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 +1353,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 +1374,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,72 +1407,72 @@ 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); + CHECK_WEEKEVENTREG(WEEKEVENTREG_74_20)) { + 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 = QuestHint_GetTatlTextId(play); if (temp_v0 != this->unk_266) { this->unk_266 = temp_v0; gSaveContext.save.playerData.tatlTimer = 0; } - if ((player->tatlTextId == 0) && (player->unk_730 == NULL)) { + if ((player->tatlTextId == 0) && (player->targetedActor == NULL)) { if ((gSaveContext.save.playerData.tatlTimer >= 600) && (gSaveContext.save.playerData.tatlTimer <= 3000)) { - player->tatlTextId = ElfMessage_GetFirstCycleHint(globalCtx); + player->tatlTextId = QuestHint_GetTatlTextId(play); } } if (player->tatlTextId < 0) { - thisx->flags |= 0x10000; + thisx->flags |= ACTOR_FLAG_10000; } - 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 == QuestHint_GetTatlTextId(play)) { this->fairyFlags |= 0x80; gSaveContext.save.playerData.tatlTimer = 3001; } @@ -1482,19 +1482,19 @@ void func_8089010C(Actor* thisx, GlobalContext* globalCtx) { thisx->update = func_8088FE64; func_8088C51C(this, 3); if (this->elfMsg != NULL) { - this->elfMsg->flags |= 0x100; + this->elfMsg->flags |= ACTOR_FLAG_100; thisx->cutscene = this->elfMsg->cutscene; if (thisx->cutscene != -1) { func_8088FD04(this); } if (this->elfMsg->home.rot.x == -0x961) { this->unk_234 = this->elfMsg; - Actor_ChangeFocus(thisx, globalCtx, this->elfMsg); + Actor_ChangeFocus(thisx, play, this->elfMsg); } } else { thisx->cutscene = -1; } - thisx->flags &= ~0x10000; + thisx->flags &= ~ACTOR_FLAG_10000; } else if (this->unk_264 & 4) { thisx->focus.pos = thisx->world.pos; this->fairyFlags |= 0x10; @@ -1502,9 +1502,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 +1516,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 +1525,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,7 +1556,7 @@ 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_MultVec3f(&zeroVec, &sp34); Matrix_Translate(sp34.x, sp34.y, sp34.z, MTXMODE_NEW); @@ -1570,59 +1570,59 @@ 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)) && - (!(player->stateFlags1 & 0x100000) || (kREG(90) < this->actor.projectedPos.z))) { - Gfx* dListHead = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4); + (!Cutscene_CheckActorAction(play, 201) || + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 201)]->action != 6)) && + (!(player->stateFlags1 & PLAYER_STATE1_100000) || (kREG(90) < this->actor.projectedPos.z))) { + Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Gfx)); 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; alphaScale = (this->disappearTimer < 0) ? (this->disappearTimer * 0.0011666666f) + 1.0f : 1.0f; - gSPSegment(POLY_XLU_DISP++, 0x08, dListHead); + gSPSegment(POLY_XLU_DISP++, 0x08, gfx); - gDPPipeSync(dListHead++); - gDPSetPrimColor(dListHead++, 0, 0x01, (u8)(s8)this->innerColor.r, (u8)(s8)this->innerColor.g, + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0x01, (u8)(s8)this->innerColor.r, (u8)(s8)this->innerColor.g, (u8)(s8)this->innerColor.b, (u8)(s8)(this->innerColor.a * alphaScale)); if (this->fairyFlags & 4) { - gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_CLD_SURF2); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_CLD_SURF2); } else { - gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_ZB_CLD_SURF2); } - gSPEndDisplayList(dListHead); + gSPEndDisplayList(gfx); 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 +1633,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..680d59158 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,59 @@ 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 -extern const ActorInit En_Elf_InitVars; +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; #endif // Z_EN_ELF_H diff --git a/src/overlays/actors/ovl_En_Elfbub/overlay.cfg b/src/overlays/actors/ovl_En_Elfbub/overlay.cfg deleted file mode 100644 index 91957fdd0..000000000 --- a/src/overlays/actors/ovl_En_Elfbub/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Elfbub -z_en_elfbub.c 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 ec64038ce..12026b8b9 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.c @@ -12,15 +12,15 @@ #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* play2); -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 = { +ActorInit En_Elfbub_InitVars = { ACTOR_EN_ELFBUB, ACTORCAT_MISC, FLAGS, @@ -52,17 +52,17 @@ 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))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, ENELFBUB_GET_SWITCHFLAG(&this->actor))) { + Actor_Kill(&this->actor); return; } ActorShape_Init(&this->actor.shape, 16.0f, ActorShadow_DrawCircle, 0.2f); - this->actor.hintId = 0x16; + this->actor.hintId = TATL_HINT_ID_IGOS_DU_IKANA; Actor_SetScale(&this->actor, 1.25f); this->actionFunc = EnElfbub_Idle; @@ -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, - Rand_S16Offset(100, 50), 25, 0); + EffectSsDtBubble_SpawnCustomColor(play, &pos, &velocity, &sAccel, &sPrimColor, &sEnvColor, + Rand_S16Offset(100, 50), 25, false); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); - Actor_MarkForDeath(&this->actor); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 60, NA_SE_EN_AWA_BREAK); + Actor_Kill(&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_Translate(0.0f, 0.0f, 1.0f, MTXMODE_APPLY); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(this->xyScale + 1.0f, this->xyScale + 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateZS(this->zRot, MTXMODE_APPLY); Matrix_Scale(this->xScale + 1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateZS(this->zRot * -1, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_bubble_DL_001000); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gBubbleDL); - 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..50c6bd672 100644 --- a/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h +++ b/src/overlays/actors/ovl_En_Elfbub/z_en_elfbub.h @@ -7,20 +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; - #endif // Z_EN_ELFBUB_H diff --git a/src/overlays/actors/ovl_En_Elfgrp/overlay.cfg b/src/overlays/actors/ovl_En_Elfgrp/overlay.cfg deleted file mode 100644 index a371edb2f..000000000 --- a/src/overlays/actors/ovl_En_Elfgrp/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Elfgrp -z_en_elfgrp.c 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 de1959ab4..169d56fdd 100644 --- a/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c +++ b/src/overlays/actors/ovl_En_Elfgrp/z_en_elfgrp.c @@ -11,29 +11,31 @@ #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); +//! TODO: this file require macros for its uses of weekEventReg -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); +void EnElfgrp_Init(Actor* thisx, PlayState* play); +void EnElfgrp_Destroy(Actor* thisx, PlayState* play); +void EnElfgrp_Update(Actor* thisx, PlayState* play); -const ActorInit En_Elfgrp_InitVars = { +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); + +ActorInit En_Elfgrp_InitVars = { ACTOR_EN_ELFGRP, ACTORCAT_PROP, FLAGS, @@ -56,7 +58,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 +75,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,12 +88,12 @@ 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) { case ENELFGRP_1: - if (gSaveContext.save.weekEventReg[23] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_02)) { func_80A396B0(this, 1); } else { this->unk_14A |= 4; @@ -99,7 +101,7 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENELFGRP_2: - if (gSaveContext.save.playerData.doubleMagic == true) { + if (gSaveContext.save.playerData.isDoubleMagicAcquired == true) { func_80A396B0(this, 1); } break; @@ -118,7 +120,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 +134,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); @@ -146,8 +148,8 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_14A |= 2; func_80A396B0(this, 6); } - } else if ((gSaveContext.save.weekEventReg[8] & 0x80)) { - func_80A39DC8(this, globalCtx, 24, 0); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_80)) { + 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) { @@ -156,11 +158,11 @@ void EnElfgrp_Init(Actor* thisx, GlobalContext* globalCtx) { func_80A396B0(this, 3); this->unk_14A |= 2; } - } else if (gSaveContext.save.playerData.magicAcquired == true) { + } else if (gSaveContext.save.playerData.isMagicAcquired == true) { 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,18 +175,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) { +s32 func_80A39BD0(PlayState* play, s32 arg2) { if ((arg2 < 1) || (arg2 >= 5)) { return 0; } - return (((void)0, gSaveContext.save.inventory.strayFairies[arg2 - 1]) - 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; @@ -205,13 +207,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->sceneId].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->sceneId].unk_14 >> (((arg1 - 1) * 5) + 1)) & 0x1F; if (temp_v1 < 10) { temp_v1 = 10; } else if (temp_v1 > 25) { @@ -220,30 +222,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->sceneId].unk_14 |= 1; } else { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~1; + gSaveContext.save.permanentSceneFlags[play->sceneId].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->sceneId].unk_14 &= ~(0x1F << ((arg1 * 5) - 4)); + gSaveContext.save.permanentSceneFlags[play->sceneId].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; @@ -252,17 +254,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; } @@ -272,8 +273,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) { @@ -285,8 +286,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; } @@ -294,8 +295,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; @@ -308,8 +309,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; } @@ -323,8 +324,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) { @@ -337,28 +338,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); } } @@ -372,10 +373,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; } @@ -384,27 +385,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; @@ -412,21 +413,21 @@ 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) { - gSaveContext.save.weekEventReg[23] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_23_02); } 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) { @@ -434,16 +435,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; @@ -451,106 +452,105 @@ 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, - ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 0x30) + 0x30); + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); gSaveContext.healthAccumulator = 320; } if (this->unk_144 > 0) { player->actor.freezeTimer = 100; - player->stateFlags1 |= 0x20000000; + player->stateFlags1 |= PLAYER_STATE1_20000000; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FAIRY_GROUP_HEAL - SFX_FLAG); } else { player->actor.freezeTimer = 0; - player->stateFlags1 &= ~0x20000000; + player->stateFlags1 &= ~PLAYER_STATE1_20000000; this->actionFunc = func_80A3A600; this->unk_14A |= 8; } } -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); + player->stateFlags1 |= PLAYER_STATE1_20000000; + 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); + player->stateFlags1 |= PLAYER_STATE1_20000000; + 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; } @@ -560,23 +560,23 @@ void func_80A3A8F8(EnElfgrp* this, GlobalContext* globalCtx) { if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { this->actor.flags &= ~ACTOR_FLAG_10000; player->actor.freezeTimer = 100; - player->stateFlags1 |= 0x20000000; - Message_StartTextbox(globalCtx, this->actor.textId, &this->actor); + player->stateFlags1 |= PLAYER_STATE1_20000000; + 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..975b08c2c 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,15 +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; - #endif // Z_EN_ELFGRP_H diff --git a/src/overlays/actors/ovl_En_Elforg/overlay.cfg b/src/overlays/actors/ovl_En_Elforg/overlay.cfg deleted file mode 100644 index 124b13ce0..000000000 --- a/src/overlays/actors/ovl_En_Elforg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Elforg -z_en_elforg.c 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 16139fa08..803a66ac4 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -5,25 +5,24 @@ */ #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 = { +ActorInit En_Elforg_InitVars = { ACTOR_EN_ELFORG, ACTORCAT_ITEMACTION, FLAGS, @@ -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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_80)) { + Actor_Kill(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_Kill(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_Kill(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) { @@ -214,8 +220,9 @@ void EnElforg_MoveToTargetFairyFountain(EnElforg* this, Vec3f* homePos) { EnElforg_ApproachTargetYPosition(this, homePos); xDifference = this->actor.world.pos.x - homePos->x; zDifference = this->actor.world.pos.z - homePos->z; - targetAngle = Math_FAtan2F(-zDifference, -xDifference); + targetAngle = Math_Atan2S_XY(-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); @@ -239,7 +247,8 @@ 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)); + targetAngle = Math_Atan2S_XY(-(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.flags |= ACTORCTX_FLAG_3; } -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; @@ -281,17 +293,19 @@ void EnElforg_TurnInFairy(EnElforg* this, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); this->actor.shape.yOffset *= 0.9f; this->actor.speedXZ = 5.0f; - EnElforg_ApproachTargetYPosition(this, &player->bodyPartsPos[0]); + EnElforg_ApproachTargetYPosition(this, &player->bodyPartsPos[PLAYER_BODYPART_WAIST]); + 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,33 +351,38 @@ 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); + Actor_Kill(&this->actor); } } } -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,27 +390,29 @@ 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); + this->actor.world.pos.y = player->bodyPartsPos[PLAYER_BODYPART_WAIST].y; + 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); + Actor_Kill(&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; + this->actor.world.pos.y = player->bodyPartsPos[PLAYER_BODYPART_WAIST].y; this->actor.world.pos.z = playerActor->world.pos.z; this->actionFunc = EnElforg_FairyCollected; this->timer = 0; @@ -397,38 +420,39 @@ 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)) { + player->stateFlags1 |= PLAYER_STATE1_20000000; + if (Actor_TextboxIsClosing(&this->actor, play)) { player->actor.freezeTimer = 0; - player->stateFlags1 &= ~0x20000000; - Actor_MarkForDeath(&this->actor); - gSaveContext.save.weekEventReg[8] |= 0x80; + player->stateFlags1 &= ~PLAYER_STATE1_20000000; + Actor_Kill(&this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_08_80); ActorCutscene_Stop(0x7C); - } else { - func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); - if (ActorCutscene_GetCurrentIndex() != 0x7C) { - if (ActorCutscene_GetCanPlayNext(0x7C)) { - ActorCutscene_Start(0x7C, &this->actor); - } else { - ActorCutscene_SetIntentToPlay(0x7C); - } + return; + } + + func_800B9010(&this->actor, NA_SE_PL_CHIBI_FAIRY_HEAL - SFX_FLAG); + if (ActorCutscene_GetCurrentIndex() != 0x7C) { + if (ActorCutscene_GetCanPlayNext(0x7C)) { + ActorCutscene_Start(0x7C, &this->actor); + } else { + ActorCutscene_SetIntentToPlay(0x7C); } } } -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) { - pos = player->bodyPartsPos[0]; + if (Player_GetMask(play) == PLAYER_MASK_GREAT_FAIRY) { + pos = player->bodyPartsPos[PLAYER_BODYPART_WAIST]; this->targetSpeedXZ = 5.0f; EnElforg_MoveToTarget(this, &pos); } else { @@ -437,49 +461,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); + player->stateFlags1 |= PLAYER_STATE1_20000000; + // 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) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); + 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) { + Audio_PlayFanfare(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 +519,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 +553,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 +566,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 +575,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 +604,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 +619,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_Mult(&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..798982b09 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; @@ -67,6 +55,4 @@ typedef struct EnElforg { /* 0x22C */ EnElforgActionFunc actionFunc; } EnElforg; // size = 0x230 -extern const ActorInit En_Elforg_InitVars; - #endif // Z_EN_ELFORG_H diff --git a/src/overlays/actors/ovl_En_Encount1/overlay.cfg b/src/overlays/actors/ovl_En_Encount1/overlay.cfg deleted file mode 100644 index 132566c38..000000000 --- a/src/overlays/actors/ovl_En_Encount1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Encount1 -z_en_encount1.c 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..2e6a44b64 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -10,13 +10,12 @@ #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 = { +ActorInit En_Encount1_InitVars = { ACTOR_EN_ENCOUNT1, ACTORCAT_PROP, FLAGS, @@ -28,10 +27,129 @@ const ActorInit En_Encount1_InitVars = { (ActorFunc)NULL, }; -#endif +static s16 sActorList[] = { + ACTOR_EN_GRASSHOPPER, + ACTOR_EN_WALLMAS, + ACTOR_EN_PR2, + ACTOR_EN_PR2, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/EnEncount1_Init.s") +static s16 sActorParams[] = { 1, 0, 1, 3 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/func_808E0954.s") +void EnEncount1_Init(Actor* thisx, PlayState* play) { + EnEncount1* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/EnEncount1_Update.s") + if (this->actor.params <= 0) { + Actor_Kill(&this->actor); + return; + } + + this->actorType = ENENCOUNT1_GET_TYPE(&this->actor); + this->unk_14C = ENENCOUNT1_GET_7C0(&this->actor); + this->unk_154 = ENENCOUNT1_GET_PATH(&this->actor); + this->unk_158 = this->actor.world.rot.x; + this->unk_15C = this->actor.world.rot.y; + this->unk_160 = (this->actor.world.rot.z * 40.0f) + 120.0f; + + if (this->unk_154 >= 0x3F) { + this->unk_154 = -1; + } + if (this->actor.world.rot.z < 0) { + this->unk_160 = -1.0f; + } + if (this->actorType == EN_ENCOUNT1_SKULLFISH_2) { + this->unk_15A = ENENCOUNT1_GET_PATH(&this->actor); + this->path = SubS_GetPathByIndex(play, this->unk_15A, 0x3F); + this->unk_154 = -1; + this->unk_160 = -1.0f; + } + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_808E0954; +} + +void func_808E0954(EnEncount1* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f spawnPos; + f32 sp64; + f32 temp_fv0_2; + s16 sp5E; + s16 actorList; + s32 actorParams; + CollisionPoly* sp54; + s32 sp50; + + if (((this->unk_14E >= this->unk_14C) || ((this->unk_160 > 0.0f) && (this->unk_160 < this->actor.xzDistToPlayer)) || + ((this->unk_154 > 0) && (this->unk_154 <= this->unk_152)))) { + return; + } else if (this->unk_156 != 0) { + this->unk_156++; + if (this->unk_156 < this->unk_158) { + return; + } + } + + this->unk_156 = 0; + switch (this->actorType) { + case EN_ENCOUNT1_GRASSHOPPER: + sp64 = randPlusMinusPoint5Scaled(40.0f) + 200.0f; + sp5E = player->actor.shape.rot.y; + if (this->unk_14E & 1) { + sp5E = -sp5E; + sp64 = randPlusMinusPoint5Scaled(20.0f) + 100.0f; + } + spawnPos.x = player->actor.world.pos.x + (Math_SinS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); + spawnPos.y = player->actor.floorHeight + 120.0f; + spawnPos.z = player->actor.world.pos.z + (Math_CosS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); + temp_fv0_2 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp54, &sp50, &this->actor, &spawnPos); + if ((temp_fv0_2 <= BGCHECK_Y_MIN) || + ((player->actor.depthInWater != BGCHECK_Y_MIN) && + (temp_fv0_2 < (player->actor.world.pos.y - player->actor.depthInWater)))) { + return; + } + spawnPos.y = temp_fv0_2; + break; + + case EN_ENCOUNT1_WALLMASTER: + Math_Vec3f_Copy(&spawnPos, &player->actor.world.pos); + break; + + case EN_ENCOUNT1_SKULLFISH: + sp64 = randPlusMinusPoint5Scaled(250.0f) + 500.0f; + sp5E = player->actor.shape.rot.y; + spawnPos.x = player->actor.world.pos.x + Math_SinS(sp5E) * sp64 + randPlusMinusPoint5Scaled(40.0f); + spawnPos.y = player->actor.world.pos.y - Rand_ZeroFloat(20.0f); + spawnPos.z = player->actor.world.pos.z + (Math_CosS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f); + temp_fv0_2 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp54, &sp50, &this->actor, &spawnPos); + if ((!(player->stateFlags1 & 0x8000000) || (temp_fv0_2 <= (BGCHECK_Y_MIN)) || + (player->actor.depthInWater < temp_fv0_2))) { + return; + } + break; + + case EN_ENCOUNT1_SKULLFISH_2: + if ((this->path != NULL) && (!SubS_CopyPointFromPath(this->path, 0, &spawnPos))) { + Actor_Kill(&this->actor); + } + break; + } + + actorList = sActorList[this->actorType]; + actorParams = sActorParams[this->actorType]; + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, actorList, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0, + actorParams) != NULL) { + this->unk_14E++; + if (this->unk_154 > 0) { + this->unk_152++; + } + + if ((this->unk_14E >= this->unk_14C) && (this->unk_158 != 0)) { + this->unk_156 = 1; + } + } +} + +void EnEncount1_Update(Actor* thisx, PlayState* play) { + EnEncount1* this = THIS; + + this->actionFunc(this, play); +} 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..52e0fb30c 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.h @@ -3,20 +3,35 @@ #include "global.h" +#define ENENCOUNT1_GET_TYPE(thisx) (((thisx)->params >> 11) & 0x1F) +#define ENENCOUNT1_GET_7C0(thisx) (((thisx)->params >> 6) & 0x1F) +#define ENENCOUNT1_GET_PATH(thisx) ((thisx)->params & 0x3F) + +typedef enum EnEncount1Enemy { + /* 0x0 */ EN_ENCOUNT1_GRASSHOPPER, + /* 0x1 */ EN_ENCOUNT1_WALLMASTER, + /* 0x2 */ EN_ENCOUNT1_SKULLFISH, + /* 0x3 */ EN_ENCOUNT1_SKULLFISH_2, +} EnEncount1Enemy; + 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 */ Path* path; + /* 0x14C */ s16 unk_14C; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ s16 actorType; + /* 0x152 */ s16 unk_152; + /* 0x154 */ s16 unk_154; + /* 0x156 */ s16 unk_156; + /* 0x158 */ s16 unk_158; + /* 0x15A */ s16 unk_15A; + /* 0x15C */ s32 unk_15C; + /* 0x160 */ f32 unk_160; } EnEncount1; // size = 0x164 -extern const ActorInit En_Encount1_InitVars; - #endif // Z_EN_ENCOUNT1_H diff --git a/src/overlays/actors/ovl_En_Encount2/overlay.cfg b/src/overlays/actors/ovl_En_Encount2/overlay.cfg deleted file mode 100644 index 31c83ff6f..000000000 --- a/src/overlays/actors/ovl_En_Encount2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Encount2 -z_en_encount2.c 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 ea7ee7aa4..656ec7936 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -12,20 +12,20 @@ #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 = { +ActorInit En_Encount2_InitVars = { ACTOR_EN_ENCOUNT2, ACTORCAT_PROP, FLAGS, @@ -60,7 +60,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -99,29 +99,29 @@ 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))) { - Actor_MarkForDeath(&this->dyna.actor); + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { + Actor_Kill(&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); + Actor_Kill(&this->dyna.actor); } } -void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnEncount2_Update(Actor* thisx, PlayState* play) { EnEncount2* this = THIS; s32 pad; @@ -193,44 +194,44 @@ 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, gMajoraBalloonDL); + Gfx_DrawDListOpa(play, gMajoraBalloonKnotDL); } - 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; + sPtr->alpha = 255; sPtr->accel.x = (Rand_ZeroOne() - 0.5f) * 10.0f; 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,55 +239,54 @@ 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) { + 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)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZF(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + 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++, gSunSparkleModelDL); } } CLOSE_DISPS(gfxCtx); 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..0a9cb1394 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,11 +30,9 @@ 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)) - -extern const ActorInit En_Encount2_InitVars; +#define ENCOUNT2_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) #endif // Z_EN_ENCOUNT2_H diff --git a/src/overlays/actors/ovl_En_Encount3/overlay.cfg b/src/overlays/actors/ovl_En_Encount3/overlay.cfg deleted file mode 100644 index 552775655..000000000 --- a/src/overlays/actors/ovl_En_Encount3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Encount3 -z_en_encount3.c 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..869d8681e 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.c @@ -10,17 +10,17 @@ #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 = { +ActorInit En_Encount3_InitVars = { ACTOR_EN_ENCOUNT3, ACTORCAT_ENEMY, FLAGS, 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..9ebc87303 100644 --- a/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h +++ b/src/overlays/actors/ovl_En_Encount3/z_en_encount3.h @@ -5,14 +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; - #endif // Z_EN_ENCOUNT3_H diff --git a/src/overlays/actors/ovl_En_Encount4/overlay.cfg b/src/overlays/actors/ovl_En_Encount4/overlay.cfg deleted file mode 100644 index 124d2e4b4..000000000 --- a/src/overlays/actors/ovl_En_Encount4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Encount4 -z_en_encount4.c 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..311668bfe 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c @@ -10,18 +10,17 @@ #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 = { +ActorInit En_Encount4_InitVars = { ACTOR_EN_ENCOUNT4, ACTORCAT_PROP, FLAGS, @@ -33,20 +32,180 @@ const ActorInit En_Encount4_InitVars = { (ActorFunc)NULL, }; -#endif +s16 D_809C46D0[] = { + 0x4000, 0xC000, 0x4000, 0, 0xC000, +}; +f32 D_809C46DC[] = { + 200.0f, 200.0f, 100.0f, 0.0f, 100.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Init.s") +void EnEncount4_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnEncount4* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Destroy.s") + this->unk_148 = ENENCOUNT4_GET_F000(thisx); + this->switchFlag = ENENCOUNT4_GET_FLAG(thisx); + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C3FD8.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_809C3FD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C4078.s") +void EnEncount4_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C42A8.s") +void func_809C3FD8(EnEncount4* this, PlayState* play) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C4598.s") + this->unk_14E = 0; + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + this->timer = 100; + this->actionFunc = func_809C464C; + } else { + actor = play->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (actor != NULL) { + if (actor->id != ACTOR_EN_BSB) { + actor = actor->next; + } else { + this->captainKeeta = (EnBsb*)actor; + this->actionFunc = func_809C4078; + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C464C.s") +void func_809C4078(EnEncount4* this, PlayState* play) { + s16 rotY; + Vec3f pos; + s32 fireWallParams; + s32 i; + EnBsb* captainKeeta = this->captainKeeta; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Update.s") + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + this->timer = 100; + this->actionFunc = func_809C464C; + } else if (BREG(1) == 0) { + if ((this->captainKeeta->actor.id != ACTOR_EN_BSB) || (captainKeeta->actor.update == NULL)) { + Actor_Kill(&this->actor); + return; + } + + if ((this->unk_148 != 0) || (this->actor.xzDistToPlayer < 240.0f)) { + if ((this->unk_148 == 0) && (captainKeeta->unk2DC != 0)) { + Actor_Kill(&this->actor); + return; + } + + fireWallParams = BGFIREWALL_PARAMS_0; + if ((this->unk_148 == 0) || (captainKeeta->unk2DC != 0)) { + i = 0; + if (this->unk_148 != 0) { + fireWallParams = BGFIREWALL_PARAMS_1; + i = 2; + } + while (i < ARRAY_COUNT(D_809C46DC)) { + rotY = D_809C46D0[i] + this->actor.world.rot.y; + pos.x = Math_SinS(rotY) * D_809C46DC[i] + this->actor.world.pos.x; + pos.y = this->actor.world.pos.y; + pos.z = Math_CosS(rotY) * D_809C46DC[i] + this->actor.world.pos.z; + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_BG_FIRE_WALL, pos.x, pos.y, pos.z, 0, + this->actor.world.rot.y, 0, fireWallParams); + i++; + } + this->actionFunc = func_809C42A8; + } + } + } +} + +void func_809C42A8(EnEncount4* this, PlayState* play) { + Player* actor = GET_PLAYER(play); + EnBsb* captainKeeta = this->captainKeeta; + Vec3f pos; + f32 yIntersect; + s16 yRot; + CollisionPoly* colPoly; + s32 bgId; + + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { + this->timer = 100; + this->actionFunc = func_809C464C; + + return; + } + + if (this->unk_148 == 1) { + if ((this->captainKeeta->actor.id != ACTOR_EN_BSB) || (captainKeeta->actor.update == NULL)) { + Actor_Kill(&this->actor); + } + + return; + } else if (this->unk_14E >= 2) { + this->timer = 100; + this->actionFunc = func_809C464C; + + return; + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_85_40) || (this->unk_14C >= 2) || + (this->actor.xzDistToPlayer > 240.0f)) { + return; + } + + pos.x = (Math_SinS(this->actor.world.rot.y) * 30.0f) + this->actor.world.pos.x; + pos.y = actor->actor.floorHeight + 120.0f; + pos.z = (Math_CosS(this->actor.world.rot.y) * 30.0f) + this->actor.world.pos.z; + yIntersect = BgCheck_EntityRaycastFloor5(&play->colCtx, &colPoly, &bgId, &this->actor, &pos); + if ((yIntersect <= BGCHECK_Y_MIN) || ((actor->actor.depthInWater != BGCHECK_Y_MIN) && + (yIntersect < (actor->actor.world.pos.y - actor->actor.depthInWater)))) { + return; + } + + pos.y = yIntersect; + yRot = (s32)Rand_ZeroFloat(512.0f) + this->actor.world.rot.y + 0x3800; + if (this->unk_14C != 0) { + yRot += 0x8000; + } + pos.x += Math_SinS(yRot) * (40.0f + randPlusMinusPoint5Scaled(40.0f)); + pos.z += Math_CosS(yRot) * (40.0f + randPlusMinusPoint5Scaled(40.0f)); + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_SKB, pos.x, pos.y, pos.z, 0, 0, 0, + ENSKB_PARAMS_0) != NULL) { + this->unk_14C++; + if (this->unk_14C >= 2) { + this->actionFunc = func_809C4598; + } + } +} + +void func_809C4598(EnEncount4* this, PlayState* play) { + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + this->timer = 100; + this->actionFunc = func_809C464C; + } else if (this->unk_14E >= 2) { + this->timer = 100; + if (this->switchFlag >= 0) { + Flags_SetSwitch(play, this->switchFlag); + } + this->actionFunc = func_809C464C; + } else if (this->unk_14C == 0) { + this->actionFunc = func_809C42A8; + } +} + +void func_809C464C(EnEncount4* this, PlayState* play) { + if (this->timer == 0) { + Actor_Kill(&this->actor); + } +} + +void EnEncount4_Update(Actor* thisx, PlayState* play) { + EnEncount4* this = THIS; + + DECR(this->timer); + this->actionFunc(this, play); +} 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..a692f796a 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h @@ -2,20 +2,26 @@ #define Z_EN_ENCOUNT4_H #include "global.h" +#include "overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h" +#include "overlays/actors/ovl_En_Bsb/z_en_bsb.h" +#include "overlays/actors/ovl_En_Skb/z_en_skb.h" struct EnEncount4; -typedef void (*EnEncount4ActionFunc)(struct EnEncount4*, GlobalContext*); +typedef void (*EnEncount4ActionFunc)(struct EnEncount4*, PlayState*); + +#define ENENCOUNT4_GET_FLAG(thisx) ((thisx)->params & 0x7F) +#define ENENCOUNT4_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) typedef struct EnEncount4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnEncount4ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; - /* 0x014C */ s16 unk_14C; - /* 0x014E */ s16 unk_14E; - /* 0x0150 */ char unk_150[0x8]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnEncount4ActionFunc actionFunc; + /* 0x148 */ s16 unk_148; + /* 0x14A */ s16 switchFlag; + /* 0x14C */ s16 unk_14C; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ s16 timer; + /* 0x154 */ EnBsb* captainKeeta; } EnEncount4; // size = 0x158 -extern const ActorInit En_Encount4_InitVars; - #endif // Z_EN_ENCOUNT4_H diff --git a/src/overlays/actors/ovl_En_Ending_Hero/overlay.cfg b/src/overlays/actors/ovl_En_Ending_Hero/overlay.cfg deleted file mode 100644 index a512a6a47..000000000 --- a/src/overlays/actors/ovl_En_Ending_Hero/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ending_Hero -z_en_ending_hero.c 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..6cdf54d70 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,15 +11,15 @@ #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 = { +ActorInit En_Ending_Hero_InitVars = { ACTOR_EN_ENDING_HERO, ACTORCAT_NPC, FLAGS, @@ -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..6049e3449 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; @@ -18,6 +18,4 @@ typedef struct EnEndingHero { /* 0x244 */ u16 unk244; } EnEndingHero; // size = 0x248 -extern const ActorInit En_Ending_Hero_InitVars; - #endif // Z_EN_ENDING_HERO_H diff --git a/src/overlays/actors/ovl_En_Ending_Hero2/overlay.cfg b/src/overlays/actors/ovl_En_Ending_Hero2/overlay.cfg deleted file mode 100644 index eeddcc9c7..000000000 --- a/src/overlays/actors/ovl_En_Ending_Hero2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ending_Hero2 -z_en_ending_hero2.c 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..2650ad156 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,15 +11,15 @@ #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 = { +ActorInit En_Ending_Hero2_InitVars = { ACTOR_EN_ENDING_HERO2, ACTORCAT_NPC, FLAGS, @@ -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..2ad3b4914 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; @@ -16,6 +16,4 @@ typedef struct EnEndingHero2 { /* 0x27C */ u16 unk27C; } EnEndingHero2; // size = 0x280 -extern const ActorInit En_Ending_Hero2_InitVars; - #endif // Z_EN_ENDING_HERO2_H diff --git a/src/overlays/actors/ovl_En_Ending_Hero3/overlay.cfg b/src/overlays/actors/ovl_En_Ending_Hero3/overlay.cfg deleted file mode 100644 index 13ddc6d82..000000000 --- a/src/overlays/actors/ovl_En_Ending_Hero3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ending_Hero3 -z_en_ending_hero3.c 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..8dcc12199 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,15 +11,15 @@ #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 = { +ActorInit En_Ending_Hero3_InitVars = { ACTOR_EN_ENDING_HERO3, ACTORCAT_NPC, FLAGS, @@ -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..0887df1ab 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; @@ -16,6 +16,4 @@ typedef struct EnEndingHero3 { /* 0x258 */ u16 unk258; } EnEndingHero3; // size = 0x25C -extern const ActorInit En_Ending_Hero3_InitVars; - #endif // Z_EN_ENDING_HERO3_H diff --git a/src/overlays/actors/ovl_En_Ending_Hero4/overlay.cfg b/src/overlays/actors/ovl_En_Ending_Hero4/overlay.cfg deleted file mode 100644 index 314fdd562..000000000 --- a/src/overlays/actors/ovl_En_Ending_Hero4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ending_Hero4 -z_en_ending_hero4.c 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..333bbc918 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,15 +11,15 @@ #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 = { +ActorInit En_Ending_Hero4_InitVars = { ACTOR_EN_ENDING_HERO4, ACTORCAT_NPC, FLAGS, @@ -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..4cada4183 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; @@ -16,6 +16,4 @@ typedef struct EnEndingHero4 { /* 0x258 */ u16 unk258; } EnEndingHero4; // size = 0x25C -extern const ActorInit En_Ending_Hero4_InitVars; - #endif // Z_EN_ENDING_HERO4_H diff --git a/src/overlays/actors/ovl_En_Ending_Hero5/overlay.cfg b/src/overlays/actors/ovl_En_Ending_Hero5/overlay.cfg deleted file mode 100644 index 1b49c5572..000000000 --- a/src/overlays/actors/ovl_En_Ending_Hero5/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ending_Hero5 -z_en_ending_hero5.c 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..ee62798f1 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,15 +11,15 @@ #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 = { +ActorInit En_Ending_Hero5_InitVars = { ACTOR_EN_ENDING_HERO5, ACTORCAT_NPC, FLAGS, @@ -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..9e3dab09e 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; @@ -17,6 +17,4 @@ typedef struct EnEndingHero5 { /* 0x25C */ s32 unk25C; } EnEndingHero5; // size = 0x260 -extern const ActorInit En_Ending_Hero5_InitVars; - #endif // Z_EN_ENDING_HERO5_H diff --git a/src/overlays/actors/ovl_En_Ending_Hero6/overlay.cfg b/src/overlays/actors/ovl_En_Ending_Hero6/overlay.cfg deleted file mode 100644 index d6911ffa0..000000000 --- a/src/overlays/actors/ovl_En_Ending_Hero6/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ending_Hero6 -z_en_ending_hero6.c 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..8f19fe9f8 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,16 +15,16 @@ #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 = { +ActorInit En_Ending_Hero6_InitVars = { ACTOR_EN_ENDING_HERO6, ACTORCAT_NPC, FLAGS, @@ -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..76af1d67f 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,24 +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; - #endif // Z_EN_ENDING_HERO6_H diff --git a/src/overlays/actors/ovl_En_Estone/overlay.cfg b/src/overlays/actors/ovl_En_Estone/overlay.cfg deleted file mode 100644 index b847b42fa..000000000 --- a/src/overlays/actors/ovl_En_Estone/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Estone -z_en_estone.c 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..c55ab5272 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.c +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.c @@ -1,25 +1,29 @@ /* * File: z_en_estone.c * Overlay: ovl_En_Estone - * Description: Eyegore Rubble + * Description: Rubble from Eyegore's attacks */ #include "z_en_estone.h" +#include "objects/object_eg/object_eg.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) #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* play2); +void EnEstone_Draw(Actor* thisx, PlayState* play2); -void func_80A9A1DC(EnEstone* this, GlobalContext* globalCtx); -void func_80A9A4B0(EnEstone* this, GlobalContext* globalCtx); +void EnEstone_Active(EnEstone* this, PlayState* play); +void EnEstone_Inactive(EnEstone* this, PlayState* play); +void EnEstone_SpawnEffect(EnEstone* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 lifetime); +void EnEstone_UpdateEffects(EnEstone* this, PlayState* play); +void EnEstone_DrawEffects(EnEstone* this, PlayState* play); -#if 0 -const ActorInit En_Estone_InitVars = { +ActorInit En_Estone_InitVars = { ACTOR_EN_ESTONE, ACTORCAT_PROP, FLAGS, @@ -31,33 +35,250 @@ const ActorInit En_Estone_InitVars = { (ActorFunc)EnEstone_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A9AB70 = { - { COLTYPE_HARD, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HARD, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 30, 30, -10, { 0, 0, 0 } }, }; -#endif +void EnEstone_Init(Actor* thisx, PlayState* play) { + EnEstone* this = THIS; + Vec3f accel; + Vec3f velocity; + f32 scale; + s32 i; + s32 pad; -extern ColliderCylinderInit D_80A9AB70; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 15.0f); + this->rotVel.x = this->rotVel.y = this->rotVel.z = randPlusMinusPoint5Scaled(1.0f) * 20.0f; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.world.rot.y += (s16)randPlusMinusPoint5Scaled(0x2710); + this->actor.shape.rot.y = this->actor.world.rot.y; -extern UNK_TYPE D_06010240; + if (this->actor.params == ENESTONE_TYPE_LARGE) { + this->actor.speedXZ = Rand_ZeroFloat(5.0f) + 2.0f; + this->scale = (Rand_ZeroFloat(1.0f) * 0.005f) + 0.005f; + this->actor.velocity.y = Rand_ZeroFloat(10.0f) + 15.0f; + this->actor.gravity = -2.0f; + } else { + this->actor.speedXZ = Rand_ZeroFloat(3.0f) + 1.0f; + this->scale = (Rand_ZeroFloat(1.0f) * 0.003f) + 0.003f; + this->actor.velocity.y = Rand_ZeroFloat(5.0f) + 7.0f; + this->actor.gravity = -1.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/EnEstone_Init.s") + this->collider.dim.radius = this->scale * 3000.0f; + this->collider.dim.height = this->scale * 3000.0f; + this->collider.dim.yShift = this->scale * -1300.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/EnEstone_Destroy.s") + for (i = 0; i < 7; i++) { + accel.x = 0.5f * (Rand_ZeroOne() - 0.5f); + accel.y = -1.0f; + accel.z = 0.5f * (Rand_ZeroOne() - 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/func_80A9A1DC.s") + velocity.x = 2.0f * (Rand_ZeroOne() - 0.5f); + velocity.y = 8.0f + (Rand_ZeroOne() * 10.0f); + velocity.z = 2.0f * (Rand_ZeroOne() - 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/func_80A9A4B0.s") + scale = (Rand_ZeroFloat(1.0f) * 0.001f) + 0.001f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/EnEstone_Update.s") + EnEstone_SpawnEffect(this, &this->actor.world.pos, &velocity, &accel, scale, 70); + } + this->timer = 5; + this->inactive = false; + Actor_SetScale(&this->actor, 1.0f); + this->actionFunc = EnEstone_Active; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/EnEstone_Draw.s") +void EnEstone_Destroy(Actor* thisx, PlayState* play) { + EnEstone* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/func_80A9A774.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/func_80A9A870.s") +void EnEstone_Active(EnEstone* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f accel; + Vec3f velocity; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Estone/func_80A9A9C0.s") + if ((this->actor.floorHeight == -10000.0f) || ((player->actor.world.pos.y - 200.0f) > this->actor.world.pos.y)) { + Actor_Kill(&this->actor); + return; + } + if (((this->actor.bgCheckFlags & 1) && (this->actor.velocity.y < 0.0f)) || (this->collider.base.atFlags & 4)) { + this->collider.base.atFlags &= ~4; + if (this->actor.params == ENESTONE_TYPE_LARGE) { + for (i = 0; i < 2; i++) { + accel.x = 2.0f * (Rand_ZeroOne() - 0.5f); + accel.y = -1.0f; + accel.z = 2.0f * (Rand_ZeroOne() - 0.5f); + velocity.x = 3.0f * (Rand_ZeroOne() - 0.5f); + velocity.y = 5.0f + (Rand_ZeroOne() * 10.0f); + velocity.z = 3.0f * (Rand_ZeroOne() - 0.5f); + EnEstone_SpawnEffect(this, &this->actor.world.pos, &velocity, &accel, + 0.003f + (0.002f * Rand_ZeroFloat(1.0f)), 20); + } + } + Math_Vec3f_Copy(&velocity, &this->actor.world.pos); + velocity.y = this->actor.floorHeight; + Actor_SpawnFloorDustRing(play, &this->actor, &velocity, 0.0f, 10, 6.0f, 50, 30, true); + this->actor.velocity.y = this->actor.gravity = 0.0f; + this->actor.speedXZ *= 0.3f; + this->actor.shape.shadowScale = 0.0f; + this->inactive = true; + this->timer = 50; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WALL_BROKEN); + this->actionFunc = EnEstone_Inactive; + } else { + //! FAKE: https://decomp.me/scratch/YiPVN + label: + this->actor.shape.shadowScale = 4500.0f * this->scale; + Actor_SetScale(&this->actor, this->scale); + } +} + +void EnEstone_Inactive(EnEstone* this, PlayState* play) { + if (this->timer == 0) { + Actor_Kill(&this->actor); + } +} + +void EnEstone_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnEstone* this = THIS; + + DECR(this->timer); + + this->actionFunc(this, play); + + this->rot.x -= this->rotVel.x; + this->rot.y -= this->rotVel.y; + this->rot.z -= this->rotVel.z; + + Actor_MoveWithGravity(&this->actor); + if ((this->timer == 0) && !this->inactive) { + Actor_UpdateBgCheckInfo(play, &this->actor, 50.0f, 50.0f, 100.0f, 0x1C); + } + if (!this->inactive) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } + EnEstone_UpdateEffects(this, play); +} + +void EnEstone_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnEstone* this = THIS; + + if (this->inactive != true) { + Matrix_Push(); + + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); + Matrix_RotateXFApply(this->rot.x * (M_PI / 180.0f)); + Matrix_RotateYF(this->rot.y * (M_PI / 180.0f), MTXMODE_APPLY); + Matrix_RotateZF(this->rot.z * (M_PI / 180.0f), MTXMODE_APPLY); + Matrix_Scale(this->scale, this->scale, this->scale, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gEyegoreStoneDL); + + CLOSE_DISPS(play->state.gfxCtx); + + Matrix_Pop(); + } + EnEstone_DrawEffects(this, play); +} + +void EnEstone_SpawnEffect(EnEstone* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 lifetime) { + EnEstoneEffect* effect = this->effects; + s16 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isActive) { + effect->isActive = true; + effect->pos = *pos; + effect->velocity = *velocity; + effect->accel = *accel; + effect->scale = scale; + effect->timer = lifetime; + effect->rot.x = randPlusMinusPoint5Scaled(0x7530); + effect->rot.y = randPlusMinusPoint5Scaled(0x7530); + effect->rot.z = randPlusMinusPoint5Scaled(0x7530); + break; + } + } +} + +void EnEstone_UpdateEffects(EnEstone* this, PlayState* play) { + EnEstoneEffect* effect = this->effects; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isActive) { + effect->rot.x += 0x100; + effect->rot.z += 0x130; + + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; + + effect->velocity.y += effect->accel.y; + if ((effect->pos.y < this->actor.floorHeight) && (effect->velocity.y < 0.0f)) { + effect->timer = 0; + Actor_SpawnFloorDustRing(play, &this->actor, &effect->pos, 0.0f, 5, 3.0f, 30, 15, true); + } + if (effect->timer != 0) { + effect->timer--; + } else { + effect->isActive = false; + } + } + } +} + +void EnEstone_DrawEffects(EnEstone* this, PlayState* play) { + EnEstoneEffect* effect = this->effects; + GraphicsContext* gfxCtx = play->state.gfxCtx; + s16 i; + + OPEN_DISPS(gfxCtx); + + func_8012C28C(play->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isActive) { + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateXS(effect->rot.x, MTXMODE_APPLY); + Matrix_RotateYS(effect->rot.y, MTXMODE_APPLY); + Matrix_RotateZS(effect->rot.z, MTXMODE_APPLY); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x80, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_06AB30); + } + } + + CLOSE_DISPS(gfxCtx); +} 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..ceb26c9c6 100644 --- a/src/overlays/actors/ovl_En_Estone/z_en_estone.h +++ b/src/overlays/actors/ovl_En_Estone/z_en_estone.h @@ -5,14 +5,35 @@ struct EnEstone; -typedef void (*EnEstoneActionFunc)(struct EnEstone*, GlobalContext*); +typedef void (*EnEstoneActionFunc)(struct EnEstone*, PlayState*); + +#define ENESTONE_EFFECT_COUNT 200 + +typedef enum { + /* 0 */ ENESTONE_TYPE_LARGE, + /* 1 */ ENESTONE_TYPE_SMALL, +} EnEstoneType; + +typedef struct { + /* 0x00 */ u8 isActive; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ Vec3f accel; + /* 0x28 */ Vec3s rot; + /* 0x30 */ f32 scale; + /* 0x34 */ s16 timer; +} EnEstoneEffect; // size = 0x38 typedef struct EnEstone { /* 0x0000 */ Actor actor; /* 0x0144 */ EnEstoneActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x2C2C]; + /* 0x0148 */ f32 scale; + /* 0x014C */ Vec3f rot; + /* 0x0158 */ Vec3f rotVel; + /* 0x0164 */ s16 timer; + /* 0x0166 */ s16 inactive; + /* 0x0168 */ ColliderCylinder collider; + /* 0x01B4 */ EnEstoneEffect effects[ENESTONE_EFFECT_COUNT]; } EnEstone; // size = 0x2D74 -extern const ActorInit En_Estone_InitVars; - #endif // Z_EN_ESTONE_H diff --git a/src/overlays/actors/ovl_En_Fall/overlay.cfg b/src/overlays/actors/ovl_En_Fall/overlay.cfg deleted file mode 100644 index 48cfdea22..000000000 --- a/src/overlays/actors/ovl_En_Fall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fall -z_en_fall.c 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 b84eb3d74..32a4b7c82 100644 --- a/src/overlays/actors/ovl_En_Fall/z_en_fall.c +++ b/src/overlays/actors/ovl_En_Fall/z_en_fall.c @@ -28,39 +28,41 @@ #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 -const ActorInit En_Fall_InitVars = { +EnFallDebrisEffect debrisEffects[EN_FALL_DEBRIS_EFFECT_COUNT]; + +ActorInit En_Fall_InitVars = { ACTOR_EN_FALL, ACTORCAT_ITEMACTION, FLAGS, @@ -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,38 +161,38 @@ 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; } if (objectIndex < 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } this->objIndex = objectIndex; 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)) { @@ -218,8 +220,8 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.draw = EnFall_Moon_Draw; this->actionFunc = EnFall_StoppedClosedMouthMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); - if (!(gSaveContext.save.weekEventReg[25] & 2)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_25_02)) { + Actor_Kill(&this->actor); } break; @@ -227,8 +229,8 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actionFunc = EnFall_ClockTowerOrTitleScreenMoon_PerformCutsceneActions; Actor_SetScale(&this->actor, this->scale * 3.0f); this->actor.draw = EnFall_Moon_Draw; - if (gSaveContext.save.weekEventReg[25] & 2) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_02)) { + Actor_Kill(&this->actor); } break; @@ -252,7 +254,7 @@ void EnFall_Setup(EnFall* this, GlobalContext* globalCtx) { this->actor.update = EnFall_RisingDebris_Update; this->actor.draw = EnFall_RisingDebris_Draw; this->scale = 1.0f; - EnFall_RisingDebris_ResetParticles(this); + EnFall_RisingDebris_ResetEffects(this); Actor_SetScale(&this->actor, 1.0f); this->actor.shape.rot.x = 0; break; @@ -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,13 +279,13 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + Actor_Kill(&this->actor); } - moon = EnFall_MoonsTear_GetTerminaFieldMoon(globalCtx); + moon = EnFall_MoonsTear_GetTerminaFieldMoon(play); this->actor.child = moon; if (moon == NULL) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } break; @@ -304,28 +306,27 @@ 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->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 1) && (play->csCtx.currentCsIndex == 0)) { switch (sGiantsCutsceneState) { case 0: - if (globalCtx->csCtx.state != 0) { + if (play->csCtx.state != 0) { sGiantsCutsceneState += 2; } break; case 2: - if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { - if (gSaveContext.save.weekEventReg[93] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_93_04)) { if (ActorCutscene_GetCanPlayNext(0xC)) { ActorCutscene_Start(0xC, &this->actor); sGiantsCutsceneState++; @@ -334,39 +335,39 @@ void EnFall_CrashingMoon_HandleGiantsCutscene(EnFall* this, GlobalContext* globa } } else if (ActorCutscene_GetCanPlayNext(0xB)) { ActorCutscene_Start(0xB, &this->actor); - gSaveContext.save.weekEventReg[93] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_93_04); sGiantsCutsceneState++; } 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->sceneId == SCENE_OKUJOU) && (gSaveContext.sceneLayer == 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->sceneId == 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,27 +504,26 @@ 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); } if (this->actor.draw != NULL) { if (Math_Vec3f_StepTo(&this->actor.world.pos, &this->actor.home.pos, this->actor.speedXZ) <= 0.0f) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_GORON_BOUND_1); - gSaveContext.save.weekEventReg[74] |= 0x80; - gSaveContext.save.weekEventReg[74] |= 0x20; - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_TEST, this->actor.world.pos.x, + SET_WEEKEVENTREG(WEEKEVENTREG_74_80); + SET_WEEKEVENTREG(WEEKEVENTREG_74_20); + 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->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 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,17 +726,17 @@ 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); + 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; @@ -744,35 +744,35 @@ void EnFall_Moon_Draw(Actor* thisx, GlobalContext* globalCtx) { 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,29 +784,29 @@ 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; + 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_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); @@ -814,18 +814,18 @@ void EnFall_LodMoon_DrawWithLerp(Actor* thisx, GlobalContext* globalCtx) { 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,50 +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_Translate(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_RotateZYX(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; @@ -891,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); @@ -904,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..c9eaaf44f 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; @@ -50,6 +50,4 @@ typedef struct EnFall { /* 0x160 */ EnFallActionFunc actionFunc; } EnFall; // size = 0x164 -extern const ActorInit En_Fall_InitVars; - #endif // Z_EN_FALL_H diff --git a/src/overlays/actors/ovl_En_Fall2/overlay.cfg b/src/overlays/actors/ovl_En_Fall2/overlay.cfg deleted file mode 100644 index 4219364f5..000000000 --- a/src/overlays/actors/ovl_En_Fall2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fall2 -z_en_fall2.c 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..33cf9a64d 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -10,13 +10,18 @@ #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); -#if 0 -const ActorInit En_Fall2_InitVars = { +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); + +ActorInit En_Fall2_InitVars = { ACTOR_EN_FALL2, ACTORCAT_ITEMACTION, FLAGS, @@ -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, 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..41f064498 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.h @@ -2,17 +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; - #endif // Z_EN_FALL2_H diff --git a/src/overlays/actors/ovl_En_Famos/overlay.cfg b/src/overlays/actors/ovl_En_Famos/overlay.cfg deleted file mode 100644 index 375bd1638..000000000 --- a/src/overlays/actors/ovl_En_Famos/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Famos -z_en_famos.c 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 42ff95aba..27dcabc23 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -5,6 +5,7 @@ */ #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" @@ -12,45 +13,45 @@ #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, GlobalContext* globalCtx); +s32 EnFamos_IsPlayerSeen(EnFamos* this, PlayState* play); void EnFamos_SetupStillIdle(EnFamos* this); -void EnFamos_StillIdle(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_StillIdle(EnFamos* this, PlayState* play); void EnFamos_SetupPathingIdle(EnFamos* this); -void EnFamos_PathingIdle(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_PathingIdle(EnFamos* this, PlayState* play); void EnFamos_SetupTurnHome(EnFamos* this); -void EnFamos_TurnHome(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_TurnHome(EnFamos* this, PlayState* play); void EnFamos_SetupReturnHome(EnFamos* this); -void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_ReturnHome(EnFamos* this, PlayState* play); void EnFamos_SetupAlert(EnFamos* this); -void EnFamos_Alert(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_Alert(EnFamos* this, PlayState* play); void EnFamos_SetupChase(EnFamos* this); -void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_Chase(EnFamos* this, PlayState* play); void EnFamos_SetupAttackAim(EnFamos* this); -void EnFamos_AttackAim(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_AttackAim(EnFamos* this, PlayState* play); void EnFamos_SetupAttack(EnFamos* this); -void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_Attack(EnFamos* this, PlayState* play); void EnFamos_SetupFinishAttack(EnFamos* this); -void EnFamos_FinishAttack(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_FinishAttack(EnFamos* this, PlayState* play); void EnFamos_SetupAttackRebound(EnFamos* this); -void EnFamos_AttackRebound(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_AttackRebound(EnFamos* this, PlayState* play); void EnFamos_SetupScanForPlayer(EnFamos* this); -void EnFamos_ScanForPlayer(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_ScanForPlayer(EnFamos* this, PlayState* play); void EnFamos_SetupDeathSlam(EnFamos* this); -void EnFamos_DeathSlam(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_DeathSlam(EnFamos* this, PlayState* play); void EnFamos_SetupDeathExplosion(EnFamos* this); -void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_DeathExplosion(EnFamos* this, PlayState* play); void EnFamos_SetupDeathFade(EnFamos* this); -void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx); -void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx); +void EnFamos_DeathFade(EnFamos* this, PlayState* play); +void EnFamos_DrawDebris(EnFamos* this, PlayState* play); -const ActorInit En_Famos_InitVars = { +ActorInit En_Famos_InitVars = { ACTOR_EN_FAMOS, ACTORCAT_ENEMY, FLAGS, @@ -138,7 +139,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -153,20 +154,20 @@ static AnimatedMaterial* sEmblemAnimatedMats[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 15, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_DEATH_ARMOS, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; static s32 sAnimatedMaterialsDesgmented = false; -void EnFamos_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnFamos_Init(Actor* thisx, PlayState* play) { EnFamos* this = THIS; Path* path; s32 i; Actor_ProcessInitChain(&this->actor, sInitChain); - if (GET_FAMOS_PATH(thisx) != 0xFF) { - path = &globalCtx->setupPathList[this->actor.params]; + 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) { @@ -176,12 +177,11 @@ void EnFamos_Init(Actor* thisx, GlobalContext* globalCtx) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawSquare, 30.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gFamosSkeleton, &gFamosIdleAnim, this->jointTable, this->morphTable, + SkelAnime_Init(play, &this->skelAnime, &gFamosSkeleton, &gFamosIdleAnim, this->jointTable, this->morphTable, FAMOS_LIMB_MAX); - Collider_InitAndSetCylinder(globalCtx, &this->collider1, &this->actor, &sCylinderInit1); - Collider_InitAndSetCylinder(globalCtx, &this->collider2, &this->actor, &sCylinderInit2); - Collider_InitAndSetJntSph(globalCtx, &this->emblemCollider, &this->actor, &sJntSphInit, - this->emblemColliderElements); + 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); if (!sAnimatedMaterialsDesgmented) { // init animated materials for (i = 0; i < ARRAY_COUNT(sEmblemAnimatedMats); i++) { @@ -193,7 +193,7 @@ void EnFamos_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = 250; this->baseHeight = this->actor.world.pos.y; // params: [this->actor.shape.rot.x] is used to set aggro distance - this->aggroDistance = (GET_FAMOS_AGGRO_DISTANCE(thisx) <= 0) ? (200.0f) : (this->actor.shape.rot.x * 40.0f * 0.1f); + this->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; @@ -205,12 +205,12 @@ void EnFamos_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnFamos_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnFamos_Destroy(Actor* thisx, PlayState* play) { EnFamos* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider1); - Collider_DestroyCylinder(globalCtx, &this->collider2); - Collider_DestroyJntSph(globalCtx, &this->emblemCollider); + Collider_DestroyCylinder(play, &this->collider1); + Collider_DestroyCylinder(play, &this->collider2); + Collider_DestroyJntSph(play, &this->emblemCollider); } /** @@ -226,15 +226,15 @@ void EnFamos_SetupAttackDebris(EnFamos* this) { this->debrisTimer = 40; rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - randVelDirection = Rand_Next() >> 0x10; + 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 = Rand_Next() >> 0x10; - rock->rotation.y = Rand_Next() >> 0x10; - rock->rotation.z = Rand_Next() >> 0x10; + 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; @@ -255,15 +255,15 @@ void EnFamos_SetupDeathDebris(EnFamos* this) { this->debrisTimer = 40; rock = &this->rocks[0]; for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { - randVelDirection = Rand_Next() >> 0x10; - randSmaller = (u32)Rand_Next() >> 0x12; + 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 = Rand_Next() >> 0x10; - rock->rotation.y = Rand_Next() >> 0x10; - rock->rotation.z = Rand_Next() >> 0x10; + 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; @@ -271,9 +271,9 @@ void EnFamos_SetupDeathDebris(EnFamos* this) { } } -s32 EnFamos_IsPlayerSeen(EnFamos* this, GlobalContext* globalCtx) { - if ((Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && - (Actor_XZDistanceToPoint(&GET_PLAYER(globalCtx)->actor, &this->calmPos) < this->aggroDistance) && +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 { @@ -350,12 +350,12 @@ void EnFamos_SetupStillIdle(EnFamos* this) { this->actor.speedXZ = 0.0f; } -void EnFamos_StillIdle(EnFamos* this, GlobalContext* globalCtx) { +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, globalCtx)) { + if (EnFamos_IsPlayerSeen(this, play)) { EnFamos_SetupAlert(this); } } @@ -379,13 +379,13 @@ void EnFamos_SetupPathingIdle(EnFamos* this) { this->actor.speedXZ = 0.0f; } -void EnFamos_PathingIdle(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_PathingIdle(EnFamos* this, PlayState* play) { EnFamos_UpdateBobbingHeight(this); if (this->isCalm) { Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); } - if (EnFamos_IsPlayerSeen(this, globalCtx)) { + if (EnFamos_IsPlayerSeen(this, play)) { EnFamos_SetupAlert(this); } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200)) { EnFamos_SetupReturnHome(this); @@ -402,9 +402,9 @@ void EnFamos_SetupTurnHome(EnFamos* this) { this->actor.speedXZ = 0.0f; } -void EnFamos_TurnHome(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_TurnHome(EnFamos* this, PlayState* play) { EnFamos_UpdateBobbingHeight(this); - if (EnFamos_IsPlayerSeen(this, globalCtx)) { + if (EnFamos_IsPlayerSeen(this, play)) { EnFamos_SetupAlert(this); } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0x200)) { EnFamos_SetupReturnHome(this); @@ -420,7 +420,7 @@ void EnFamos_SetupReturnHome(EnFamos* this) { this->actionFunc = EnFamos_ReturnHome; } -void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_ReturnHome(EnFamos* this, PlayState* play) { f32 distanceToHome = Actor_XZDistanceToPoint(&this->actor, &this->targetDest); this->actor.shape.rot.y = Actor_YawToPoint(&this->actor, &this->targetDest); @@ -430,7 +430,7 @@ void EnFamos_ReturnHome(EnFamos* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&this->calmPos, &this->actor.world.pos); } - if (EnFamos_IsPlayerSeen(this, globalCtx)) { + if (EnFamos_IsPlayerSeen(this, play)) { EnFamos_SetupAlert(this); } else if (distanceToHome < 20.0f) { if (this->pathPoints != NULL) { @@ -461,7 +461,7 @@ void EnFamos_SetupAlert(EnFamos* this) { this->actionFunc = EnFamos_Alert; } -void EnFamos_Alert(EnFamos* this, GlobalContext* globalCtx) { +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 { @@ -486,8 +486,8 @@ void EnFamos_SetupChase(EnFamos* this) { this->actionFunc = EnFamos_Chase; } -void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnFamos_Chase(EnFamos* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f abovePlayerPos; u32 surfaceType; @@ -500,13 +500,13 @@ void EnFamos_Chase(EnFamos* this, GlobalContext* globalCtx) { this->actor.world.rot.x = -Actor_PitchToPoint(&this->actor, &abovePlayerPos); Math_StepToF(&this->actor.speedXZ, 6.0f, 0.5f); - surfaceType = func_800C9B18(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + 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); - } else if ((Player_GetMask(globalCtx) == PLAYER_MASK_STONE) || - (this->aggroDistance < Actor_XZDistanceToPoint(&GET_PLAYER(globalCtx)->actor, &this->calmPos)) || + } 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); } @@ -519,7 +519,7 @@ void EnFamos_SetupAttackAim(EnFamos* this) { this->actionFunc = EnFamos_AttackAim; } -void EnFamos_AttackAim(EnFamos* this, GlobalContext* globalCtx) { +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); @@ -533,7 +533,7 @@ void EnFamos_SetupAttack(EnFamos* this) { this->actionFunc = EnFamos_Attack; } -void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_Attack(EnFamos* this, PlayState* play) { s32 hitFloor; u32 surfaceType; @@ -543,18 +543,18 @@ void EnFamos_Attack(EnFamos* this, GlobalContext* globalCtx) { this->emblemCollider.base.acFlags &= ~AC_ON; } - surfaceType = func_800C9B18(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId); + 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) { - func_800DFD04(globalCtx->cameraPtrs[globalCtx->activeCamera], 2, 15, 10); // camera shake? - func_8013ECE0(this->actor.xyzDistToPlayerSq, 180, 20, 100); + 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(&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.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x0); if (this->actor.child != NULL) { @@ -590,7 +590,7 @@ void EnFamos_SetupFinishAttack(EnFamos* this) { this->actionFunc = EnFamos_FinishAttack; } -void EnFamos_FinishAttack(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_FinishAttack(EnFamos* this, PlayState* play) { if (this->stateTimer == 0) { this->collider2.base.atFlags &= ~AT_ON; } @@ -607,7 +607,7 @@ void EnFamos_SetupAttackRebound(EnFamos* this) { this->actor.speedXZ = 0.0f; } -void EnFamos_AttackRebound(EnFamos* this, GlobalContext* globalCtx) { +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) { @@ -632,11 +632,11 @@ void EnFamos_SetupScanForPlayer(EnFamos* this) { this->actor.speedXZ = 0.0f; } -void EnFamos_ScanForPlayer(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_ScanForPlayer(EnFamos* this, PlayState* play) { EnFamos_UpdateBobbingHeight(this); this->stateTimer--; - if (EnFamos_IsPlayerSeen(this, globalCtx)) { + if (EnFamos_IsPlayerSeen(this, play)) { EnFamos_SetupAlert(this); } else if (this->stateTimer == 0) { EnFamos_SetupTurnHome(this); @@ -659,7 +659,7 @@ void EnFamos_SetupDeathSlam(EnFamos* this) { this->actionFunc = EnFamos_DeathSlam; } -void EnFamos_DeathSlam(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_DeathSlam(EnFamos* this, PlayState* play) { if (this->stateTimer == 17) { this->collider2.base.atFlags &= ~AT_ON; } @@ -680,7 +680,7 @@ void EnFamos_SetupDeathExplosion(EnFamos* this) { this->actionFunc = EnFamos_DeathExplosion; } -void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx) { +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); @@ -690,7 +690,7 @@ void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx) { this->actor.world.pos.z = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.z; if (this->stateTimer == 1) { EnBom* explosion = - (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + (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 @@ -698,7 +698,7 @@ void EnFamos_DeathExplosion(EnFamos* this, GlobalContext* globalCtx) { this->stateTimer--; } else if (this->stateTimer == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, (0xD << 4)); // random item from droptable 0xD EnFamos_SetupDeathFade(this); @@ -715,7 +715,7 @@ void EnFamos_SetupDeathFade(EnFamos* this) { this->actor.speedXZ = 0.0f; } -void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_DeathFade(EnFamos* this, PlayState* play) { Actor* enBom; if (this->debrisTimer == 0) { @@ -723,7 +723,7 @@ void EnFamos_DeathFade(EnFamos* this, GlobalContext* globalCtx) { if (enBom != NULL) { enBom->parent = NULL; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -735,14 +735,13 @@ void EnFamos_UpdateDebrisPosRot(EnFamos* this) { for (i = 0; i < ARRAY_COUNT(this->rocks); i++, rock++) { rock->velocity.y -= 1.0f; Math_Vec3f_Sum(&rock->pos, &rock->velocity, &rock->pos); - // all casts seem required - rock->rotation.x += (s16)(((u32)Rand_Next() >> 0x17) + 0x700); - rock->rotation.y += (s16)(((u32)Rand_Next() >> 0x17) + 0x900); - rock->rotation.z += (s16)(((u32)Rand_Next() >> 0x17) + 0xB00); + rock->rotation.x += (s16)((Rand_Next() >> 0x17) + 0x700); + rock->rotation.y += (s16)((Rand_Next() >> 0x17) + 0x900); + rock->rotation.z += (s16)((Rand_Next() >> 0x17) + 0xB00); } } -void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnFamos_Update(Actor* thisx, PlayState* play) { s32 pad; EnFamos* this = THIS; f32 oldHeight; @@ -759,7 +758,7 @@ void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx) { } } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); oldHeight = this->actor.world.pos.y; Actor_MoveWithoutGravity(&this->actor); if (oldHoverTimer != this->hoverTimer) { // test if updated in actionFunc @@ -767,7 +766,7 @@ void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->flippedTimer >= 0) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 35.0f, 30.0f, 80.0f, 0x1F); + 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; @@ -777,25 +776,24 @@ void EnFamos_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.rot.y = this->actor.shape.rot.y; Collider_UpdateCylinder(&this->actor, &this->collider1); if (this->collider1.base.atFlags & AT_ON) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider1.base); } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->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(globalCtx, &globalCtx->colChkCtx, &this->emblemCollider.base); + 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(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider2.base); } } } -s32 EnFamos_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - Actor* thisx) { +s32 EnFamos_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnFamos* this = THIS; if (limbIndex == FAMOS_LIMB_BODY) { @@ -812,7 +810,7 @@ s32 EnFamos_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis return false; } -void EnFamos_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnFamos_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnFamos* this = THIS; if (limbIndex == FAMOS_LIMB_EMBLEM) { @@ -821,14 +819,14 @@ void EnFamos_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } -void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx) { +void EnFamos_DrawDebris(EnFamos* this, PlayState* play) { s32 i; if (this->debrisTimer > 0) { Gfx* dispOpa; EnFamosRock* rock; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); dispOpa = POLY_OPA_DISP; gSPDisplayList(&dispOpa[0], &sSetupDL[6 * 0x19]); @@ -843,7 +841,7 @@ void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx) { Matrix_SetTranslateRotateYXZ(rock->pos.x, rock->pos.y, rock->pos.z, &rock->rotation); Matrix_Scale(rock->scale, rock->scale, rock->scale, MTXMODE_APPLY); - gSPMatrix(&dispOpa[3 + i * 2], Matrix_NewMtx(globalCtx->state.gfxCtx), + 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 @@ -851,21 +849,21 @@ void EnFamos_DrawDebris(EnFamos* this, GlobalContext* globalCtx) { POLY_OPA_DISP = &dispOpa[3 + (ARRAY_COUNT(this->rocks) * 2)]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void EnFamos_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFamos_Draw(Actor* thisx, PlayState* play) { EnFamos* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->actionFunc != EnFamos_DeathFade) { - AnimatedMat_Draw(globalCtx, sEmblemAnimatedMats[this->animatedMaterialIndex]); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnFamos_OverrideLimbDraw, + 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(globalCtx); + func_800AE5A0(play); } } - EnFamos_DrawDebris(this, globalCtx); + 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 a3db181e6..874da9034 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.h +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.h @@ -6,17 +6,17 @@ struct EnFamos; -typedef void (*EnFamosActionFunc)(struct EnFamos*, GlobalContext*); +typedef void (*EnFamosActionFunc)(struct EnFamos*, PlayState*); typedef struct EnFamosRock { - /* 00 */ Vec3f pos; - /* 0C */ Vec3f velocity; - /* 18 */ Vec3s rotation; - /* 20 */ f32 scale; + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3f velocity; + /* 0x18 */ Vec3s rotation; + /* 0x20 */ f32 scale; } EnFamosRock; // size = 0x24 -#define GET_FAMOS_PATH(thisx) (thisx->params) -#define GET_FAMOS_AGGRO_DISTANCE(thisx) (thisx->shape.rot.x) +#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) diff --git a/src/overlays/actors/ovl_En_Fg/overlay.cfg b/src/overlays/actors/ovl_En_Fg/overlay.cfg deleted file mode 100644 index 712186262..000000000 --- a/src/overlays/actors/ovl_En_Fg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fg -z_en_fg.c 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 bd3bd9e29..6a4c357d9 100644 --- a/src/overlays/actors/ovl_En_Fg/z_en_fg.c +++ b/src/overlays/actors/ovl_En_Fg/z_en_fg.c @@ -12,19 +12,19 @@ #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 = { +ActorInit En_Fg_InitVars = { ACTOR_EN_FG, ACTORCAT_NPC, FLAGS, @@ -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,19 +369,19 @@ 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); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == 4) { @@ -390,7 +389,7 @@ void EnFg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFg_Draw(Actor* thisx, PlayState* play) { EnFg* this = THIS; s32 pad; Color_RGBA8 envColor[] = { @@ -399,19 +398,19 @@ void EnFg_Draw(Actor* thisx, GlobalContext* globalCtx) { }; Matrix_Push(); - EnFg_DrawDust(globalCtx, &this->dustEffect[0]); + 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) { @@ -445,18 +444,18 @@ void EnFg_UpdateDust(EnFgEffectDust* dustEffect) { } } -TexturePtr sDustTex[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, +static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; -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) { @@ -472,14 +471,13 @@ void EnFg_DrawDust(GlobalContext* globalCtx, EnFgEffectDust* dustEffect) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, alpha); gDPPipeSync(POLY_XLU_DISP++); Matrix_Translate(dustEffect->pos.x, dustEffect->pos.y, dustEffect->pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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])); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[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/overlay.cfg b/src/overlays/actors/ovl_En_Fire_Rock/overlay.cfg deleted file mode 100644 index e1d38e60a..000000000 --- a/src/overlays/actors/ovl_En_Fire_Rock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fire_Rock -z_en_fire_rock.c 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..90801ef44 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,12 +10,12 @@ #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 = { +ActorInit En_Fire_Rock_InitVars = { ACTOR_EN_FIRE_ROCK, ACTORCAT_ENEMY, FLAGS, @@ -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_Fire_Rock/z_en_fire_rock.h b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.h index 84c437ac1..e2b32aaf9 100644 --- a/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.h +++ b/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.h @@ -10,6 +10,4 @@ typedef struct EnFireRock { /* 0x144 */ char unk_144[0x94]; } EnFireRock; // size = 0x1D8 -extern const ActorInit En_Fire_Rock_InitVars; - #endif // Z_EN_FIRE_ROCK_H diff --git a/src/overlays/actors/ovl_En_Firefly/overlay.cfg b/src/overlays/actors/ovl_En_Firefly/overlay.cfg deleted file mode 100644 index 8b88be0b8..000000000 --- a/src/overlays/actors/ovl_En_Firefly/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Firefly -z_en_firefly.c 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 677edb81a..5cdcd99fe 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* play2); +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, @@ -44,7 +44,7 @@ typedef enum { /* 2 */ KEESE_AURA_ICE } KeeseAuraType; -const ActorInit En_Firefly_InitVars = { +ActorInit En_Firefly_InitVars = { ACTOR_EN_FIREFLY, ACTORCAT_ENEMY, FLAGS, @@ -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) { @@ -140,19 +149,19 @@ void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) { this->auraType = KEESE_AURA_FIRE; this->timer = Rand_S16Offset(20, 60); this->actor.shape.rot.x = 0x1554; - this->actor.hintId = 0x11; // Fire Keese + this->actor.hintId = TATL_HINT_ID_FIRE_KEESE; this->maxAltitude = this->actor.home.pos.y; this->actionFunc = EnFirefly_FlyIdle; } else if (this->actor.params == KEESE_ICE_FLY) { this->auraType = KEESE_AURA_ICE; this->collider.info.toucher.effect = 2; // Freeze - this->actor.hintId = 0x56; // Ice Keese + this->actor.hintId = TATL_HINT_ID_ICE_KEESE; this->maxAltitude = this->actor.home.pos.y + 100.0f; this->actionFunc = EnFirefly_FlyIdle; } else { this->auraType = KEESE_AURA_NONE; this->collider.info.toucher.effect = 0; // Nothing - this->actor.hintId = 0x12; // Keese + this->actor.hintId = TATL_HINT_ID_KEESE; this->maxAltitude = this->actor.home.pos.y + 100.0f; this->actionFunc = EnFirefly_Perch; } @@ -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); } } @@ -179,7 +188,7 @@ void EnFirefly_Extinguish(EnFirefly* this) { this->currentType = KEESE_NORMAL; this->collider.info.toucher.effect = 0; // Nothing this->auraType = KEESE_AURA_NONE; - this->actor.hintId = 0x12; // Keese + this->actor.hintId = TATL_HINT_ID_KEESE; } void EnFirefly_Ignite(EnFirefly* this) { @@ -187,12 +196,12 @@ void EnFirefly_Ignite(EnFirefly* this) { this->currentType = KEESE_FIRE; this->collider.info.toucher.effect = 1; // Fire this->auraType = KEESE_AURA_FIRE; - this->actor.hintId = 0x11; // Fire Keese + this->actor.hintId = TATL_HINT_ID_FIRE_KEESE; } } -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,20 +410,20 @@ 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); - Actor_MarkForDeath(&this->actor); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xA0); + Actor_Kill(&this->actor); } } 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.lensMaskSize != LENS_MASK_ACTIVE_SIZE)) { *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,7 +764,7 @@ 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) { @@ -788,7 +796,7 @@ 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); } @@ -801,12 +809,12 @@ void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } -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..6ac9fb008 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,18 +26,16 @@ 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 -extern const ActorInit En_Firefly_InitVars; - #endif // Z_EN_FIREFLY_H diff --git a/src/overlays/actors/ovl_En_Firefly2/overlay.cfg b/src/overlays/actors/ovl_En_Firefly2/overlay.cfg deleted file mode 100644 index 0872be9ea..000000000 --- a/src/overlays/actors/ovl_En_Firefly2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Firefly2 -z_en_firefly2.c 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..6c105caa2 100644 --- a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c +++ b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.c @@ -10,12 +10,12 @@ #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 = { +ActorInit En_Firefly2_InitVars = { ACTOR_EN_FIREFLY2, ACTORCAT_ENEMY, FLAGS, @@ -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_Firefly2/z_en_firefly2.h b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.h index c60f26ae2..b1e8179e1 100644 --- a/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.h +++ b/src/overlays/actors/ovl_En_Firefly2/z_en_firefly2.h @@ -10,6 +10,4 @@ typedef struct EnFirefly2 { /* 0x144 */ char unk_144[0x228]; } EnFirefly2; // size = 0x36C -extern const ActorInit En_Firefly2_InitVars; - #endif // Z_EN_FIREFLY2_H diff --git a/src/overlays/actors/ovl_En_Fish/overlay.cfg b/src/overlays/actors/ovl_En_Fish/overlay.cfg deleted file mode 100644 index a78daf631..000000000 --- a/src/overlays/actors/ovl_En_Fish/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fish -z_en_fish.c 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..5f9bbb2da 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* play2); +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, }; @@ -68,7 +68,7 @@ static Color_RGB8 D_8091FA94[] = { { 215, 97, 7 }, }; -const ActorInit En_Fish_InitVars = { +ActorInit En_Fish_InitVars = { ACTOR_EN_FISH, ACTORCAT_ITEMACTION, FLAGS, @@ -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->sceneId == 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,15 +512,15 @@ 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); } } else if ((this->unk_240 <= 0) && (this->actor.params == ENFISH_0) && (this->actor.floorHeight < BGCHECK_Y_MIN + 10)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -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); @@ -582,15 +582,18 @@ void func_8091EAF0(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_240 <= 0) { - Actor_MarkForDeath(&this->actor); - } else if (this->unk_240 <= 60) { + Actor_Kill(&this->actor); + return; + } + + if (this->unk_240 <= 60) { if (sp40 & 4) { this->actor.draw = EnFish_Draw; } else { this->actor.draw = NULL; } } else if (this->actor.bgCheckFlags & 0x20) { - if (func_8091DA14(this, globalCtx)) { + if (func_8091DA14(this, play)) { func_8091EF30(this); } else { func_8091ECF4(this); @@ -613,13 +616,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); @@ -655,7 +658,7 @@ void func_8091ED70(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_240 <= 0) { - Actor_MarkForDeath(thisx); + Actor_Kill(thisx); } } @@ -678,17 +681,17 @@ 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; s16 sp2E; if (sp3C == 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -707,12 +710,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 +781,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 +828,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 +848,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 +856,14 @@ 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->sceneId != SCENE_LABO); + 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,29 +873,30 @@ 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); + Actor_Kill(&this->actor); + return; } - } else if (func_8091DDF4(this, globalCtx)) { - Actor_PickUp(&this->actor, globalCtx, GI_MAX, 80.0f, 25.0f); + + func_8091D904(this); + } 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -899,7 +904,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 +923,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 +938,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..528eeb40c 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, @@ -48,6 +48,4 @@ typedef struct EnFish { /* 0x279 */ s8 unk_279; } EnFish; // size = 0x27C -extern const ActorInit En_Fish_InitVars; - #endif // Z_EN_FISH_H diff --git a/src/overlays/actors/ovl_En_Fish2/overlay.cfg b/src/overlays/actors/ovl_En_Fish2/overlay.cfg deleted file mode 100644 index cba83b735..000000000 --- a/src/overlays/actors/ovl_En_Fish2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fish2 -z_en_fish2.c 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 bceaa7225..c7dd18369 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* play2); +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; @@ -49,7 +49,7 @@ static s32 D_80B2B2EC = 0; static s32 D_80B2B2F0 = 0; static Actor* D_80B2B2F4 = NULL; -const ActorInit En_Fish2_InitVars = { +ActorInit En_Fish2_InitVars = { ACTOR_EN_FISH2, ACTORCAT_PROP, FLAGS, @@ -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,31 +159,31 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_81_10)) { this->unk_2C0 = 1; } - if (gSaveContext.save.weekEventReg[81] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_81_20)) { this->unk_2C0 = 2; } - if (gSaveContext.save.weekEventReg[81] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_81_40)) { this->unk_2C0 = 3; } } else { - if (gSaveContext.save.weekEventReg[81] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_81_80)) { this->unk_2C0 = 1; } - if (gSaveContext.save.weekEventReg[82] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_82_01)) { this->unk_2C0 = 2; } - if (gSaveContext.save.weekEventReg[82] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_82_02)) { this->unk_2C0 = 3; } } @@ -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); } @@ -526,22 +527,21 @@ void func_80B2951C(EnFish2* this) { this->unk_2B4 = 10; this->actor.speedXZ = 3.0f; - Actor_MarkForDeath(this->unk_350); + Actor_Kill(this->unk_350); this->unk_350 = NULL; D_80B2B2F4 = &this->actor; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DODO_M_EAT); 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); @@ -619,18 +619,18 @@ void func_80B297FC(EnFish2* this, GlobalContext* globalCtx) { this->unk_2C0++; if (this->unk_344 == 0) { if (this->unk_2C0 == 1) { - gSaveContext.save.weekEventReg[81] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_81_10); } else if (this->unk_2C0 == 2) { - gSaveContext.save.weekEventReg[81] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_81_20); } else if (this->unk_2C0 == 3) { - gSaveContext.save.weekEventReg[81] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_81_40); } } else if (this->unk_2C0 == 1) { - gSaveContext.save.weekEventReg[81] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_81_80); } else if (this->unk_2C0 == 2) { - gSaveContext.save.weekEventReg[82] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_82_01); } else if (this->unk_2C0 == 3) { - gSaveContext.save.weekEventReg[82] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_82_02); } if (this->unk_2B0 != 0) { @@ -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,36 +794,36 @@ 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++; if (D_80B2B2EC > 200) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); ActorCutscene_Stop(this->unk_2BA[0]); return; } } 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,36 +834,36 @@ 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; D_80B2B2F4 = NULL; ActorCutscene_Stop(this->unk_2BA[0]); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -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,18 +884,18 @@ 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; temp_v0->velocity.y = 15.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_PIECE_OF_HEART); - gSaveContext.save.weekEventReg[81] &= (u8)~0x10; - gSaveContext.save.weekEventReg[81] &= (u8)~0x20; - gSaveContext.save.weekEventReg[81] &= (u8)~0x40; - gSaveContext.save.weekEventReg[81] &= (u8)~0x80; - gSaveContext.save.weekEventReg[82] &= (u8)~1; - gSaveContext.save.weekEventReg[82] &= (u8)~2; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_81_10); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_81_20); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_81_40); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_81_80); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_02); } } @@ -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,22 +1045,22 @@ 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_Push(); - Matrix_ReplaceRotation(&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++, *dList); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (limbIndex == 14) { @@ -1075,14 +1074,14 @@ void EnFish2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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); @@ -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..49941d67e 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; @@ -61,6 +60,4 @@ typedef struct EnFish2 { /* 0x03F8 */ EnFish2UnkStruct unk_3F8[200]; } EnFish2; // size = 0x2018 -extern const ActorInit En_Fish2_InitVars; - #endif // Z_EN_FISH2_H diff --git a/src/overlays/actors/ovl_En_Fishing/overlay.cfg b/src/overlays/actors/ovl_En_Fishing/overlay.cfg deleted file mode 100644 index 193cfdb5f..000000000 --- a/src/overlays/actors/ovl_En_Fishing/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fishing -z_en_fishing.c 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 668033cd6..6d75abddb 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -6,6 +6,8 @@ #include "prevent_bss_reordering.h" #include "z_en_fishing.h" +#include "z64rumble.h" +#include "z64shrink_window.h" #include "objects/object_fish/object_fish.h" #include "overlays/actors/ovl_En_Kanban/z_en_kanban.h" @@ -13,15 +15,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* play2); +void EnFishing_Destroy(Actor* thisx, PlayState* play2); +void EnFishing_UpdateFish(Actor* thisx, PlayState* play2); +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* play2); +void EnFishing_DrawOwner(Actor* thisx, PlayState* play); typedef struct { /* 0x00 */ u8 unk_00; @@ -138,11 +140,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; @@ -200,7 +202,7 @@ s16 D_80917272; u8 D_80917274; Vec3f D_80917278; -const ActorInit En_Fishing_InitVars = { +ActorInit En_Fishing_InitVars = { ACTOR_EN_FISHING, ACTORCAT_NPC, FLAGS, @@ -724,7 +726,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 +796,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 +812,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; @@ -830,7 +832,7 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { thisx->focus.pos = thisx->world.pos; thisx->focus.pos.y += 75.0f; - thisx->flags |= 9; + thisx->flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); if (sLinkAge != 1) { // HIGH_SCORE(HS_FISHING) from OoT @@ -844,8 +846,8 @@ void EnFishing_Init(Actor* thisx, GlobalContext* globalCtx2) { } D_8090CD04 = 20; - globalCtx->specialEffects = sFishingEffects; - REG(15) = 1; // gTimeIncrement in OoT + play->specialEffects = sFishingEffects; + R_TIME_SPEED = 1; D_809171FC = 0; D_809171F6 = 10; @@ -865,10 +867,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; } @@ -921,10 +923,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 +939,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 +949,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 +960,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); + thisx->flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); } else { this->unk_150 = 10; this->unk_152 = 10; @@ -982,20 +984,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 +1030,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 +1041,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 +1052,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 +1061,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)) { + 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; @@ -1107,7 +1109,7 @@ void EnFishing_UpdateEffects(FishingEffect* effect, GlobalContext* globalCtx) { Math_ApproachS(&sEffOwnerHatRot.z, -0x4000, 20, 100); sqDistXZ = SQXZ(effect->pos); - bottomY = WATER_SURFACE_Y(globalCtx) + ((sqrtf(sqDistXZ) - 920.0f) * 0.147f); + 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 +1117,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 +1126,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,14 +1143,14 @@ 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_Push(); @@ -1157,7 +1159,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { for (i = 0; i < 100; i++) { if (effect->type == FS_EFF_RIPPLE) { if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gFishingRippleSetupDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); flag++; } @@ -1167,10 +1169,9 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleModelDL); } effect++; } @@ -1180,7 +1181,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { for (i = 0; i < 100; i++) { if (effect->type == FS_EFF_DUST_SPLASH) { if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashSetupDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 0); flag++; } @@ -1188,13 +1189,12 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, effect->alpha); Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingDustSplashModelDL); } effect++; } @@ -1204,7 +1204,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { for (i = 0; i < 100; i++) { if (effect->type == FS_EFF_WATER_DUST) { if (flag == 0) { - gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustSetupDL); + gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustMaterialDL); gDPSetEnvColor(POLY_OPA_DISP++, 40, 90, 80, 128); flag++; } @@ -1212,17 +1212,16 @@ 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_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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); + gSPDisplayList(POLY_OPA_DISP++, gFishingWaterDustModelDL); } effect++; } @@ -1232,20 +1231,19 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { for (i = 0; i < 100; i++) { if (effect->type == FS_EFF_BUBBLE) { if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleSetupDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 150, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); flag++; } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingBubbleModelDL); } effect++; } @@ -1267,22 +1265,21 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingRainDropModelDL); } effect++; } - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); effect = firstEffect + 30; flag = 0; for (i = 30; i < EFFECT_COUNT; i++) { if (effect->type == FS_EFF_RAIN_RIPPLE) { if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gFishingRippleSetupDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleMaterialDL); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 130); flag++; @@ -1291,10 +1288,9 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingRippleModelDL); } effect++; } @@ -1304,7 +1300,7 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { for (i = 30; i < EFFECT_COUNT; i++) { if (effect->type == FS_EFF_RAIN_SPLASH) { if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashSetupDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashMaterialDL); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, KREG(19) + 80); flag++; } @@ -1316,14 +1312,13 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { } Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingRainSplashModelDL); } effect++; } @@ -1337,34 +1332,34 @@ void EnFishing_DrawEffects(FishingEffect* effect, GlobalContext* globalCtx) { Matrix_Scale(effect->unk_30, effect->unk_30, effect->unk_30, MTXMODE_APPLY); 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_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_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 +1373,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 +1436,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; @@ -1487,9 +1482,9 @@ void EnFishing_UpdateLine(GlobalContext* globalCtx, Vec3f* basePos, Vec3f* pos, dy = spD8 - (pos + i - 1)->y; dz = (pos + i)->z - (pos + i - 1)->z; - ry = Math_Acot2F(dz, dx); + ry = Math_Atan2F_XY(dz, dx); dist = sqrtf(SQ(dx) + SQ(dz)); - rx = -Math_Acot2F(dist, dy); + rx = -Math_Atan2F_XY(dist, dy); (rot + i - 1)->y = ry; (rot + i - 1)->x = rx; @@ -1523,9 +1518,9 @@ void EnFishing_UpdateLinePos(Vec3f* pos) { dy = (pos + i)->y - (pos + i + 1)->y; dz = (pos + i)->z - (pos + i + 1)->z; - ry = Math_Acot2F(dz, dx); + ry = Math_Atan2F_XY(dz, dx); dist = sqrtf(SQ(dx) + SQ(dz)); - rx = -Math_Acot2F(dist, dy); + rx = -Math_Atan2F_XY(dist, dy); Matrix_RotateYF(ry, MTXMODE_NEW); Matrix_RotateXFApply(rx); @@ -1537,7 +1532,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 +1542,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_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; @@ -1565,9 +1560,9 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, dy = refPos->y - pos->y + offsetY; dz = refPos->z - pos->z; - ry = Math_Acot2F(dz, dx); + ry = Math_Atan2F_XY(dz, dx); dist = sqrtf(SQ(dx) + SQ(dz)); - rx = -Math_Acot2F(dist, dy); + rx = -Math_Atan2F_XY(dist, dy); Matrix_RotateYF(ry, MTXMODE_NEW); Matrix_RotateXFApply(rx); @@ -1590,12 +1585,12 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, Matrix_Scale(0.0039999997f, 0.0039999997f, 0.005f, 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_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)) { @@ -1604,7 +1599,7 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, Matrix_Push(); if (D_8090CD10 != 0) { - FishingEffect* effect = globalCtx->specialEffects; + FishingEffect* effect = play->specialEffects; MtxF mf; Matrix_MultVec3f(&sZeroVec, &effect->pos); @@ -1624,16 +1619,16 @@ void EnFishing_DrawLureHook(GlobalContext* globalCtx, Vec3f* pos, Vec3f* refPos, 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_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 +1643,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,7 +1653,7 @@ 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; @@ -1686,9 +1681,9 @@ void EnFishing_UpdateSinkingLure(GlobalContext* globalCtx) { dy = (pos + i)->y - (pos + i - 1)->y + offsetY; dz = (pos + i)->z - (pos + i - 1)->z + offsetZ; - ry = Math_Acot2F(dz, dx); + ry = Math_Atan2F_XY(dz, dx); dist = sqrtf(SQ(dx) + SQ(dz)); - rx = -Math_Acot2F(dist, dy); + rx = -Math_Atan2F_XY(dist, dy); Matrix_RotateYF(ry, MTXMODE_NEW); Matrix_RotateXFApply(rx); @@ -1705,72 +1700,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); + gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentMaterialDL); for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { 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_ReplaceRotation(&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); + gSPDisplayList(POLY_OPA_DISP++, gFishingSinkingLureSegmentModelDL); } } } else { - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentSetupDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentMaterialDL); for (i = SINKING_LURE_SEG_COUNT - 1; i >= 0; i--) { if ((i + D_80911F20) < SINKING_LURE_SEG_COUNT) { 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_ReplaceRotation(&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); + gSPDisplayList(POLY_XLU_DISP++, gFishingSinkingLureSegmentModelDL); } } } - 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); + func_8012C28C(play->state.gfxCtx); Matrix_Push(); if (D_8090CD54 != 0) { Vec3f posTemp = sLurePos; sLurePos = sSinkingLureBasePos; - EnFishing_DrawSinkingLure(globalCtx); + EnFishing_DrawSinkingLure(play); sLurePos = posTemp; } @@ -1806,9 +1801,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* 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; @@ -1819,12 +1814,12 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* posSrc.x = 500.0f; posSrc.z = -300.0f; Matrix_MultVec3f(&posSrc, &hookPos[0]); - EnFishing_DrawLureHook(globalCtx, &hookPos[0], &sLureHookRefPos[0], 0); + EnFishing_DrawLureHook(play, &hookPos[0], &sLureHookRefPos[0], 0); posSrc.x = 2100.0f; posSrc.z = -50.0f; Matrix_MultVec3f(&posSrc, &hookPos[1]); - EnFishing_DrawLureHook(globalCtx, &hookPos[1], &sLureHookRefPos[1], 1); + EnFishing_DrawLureHook(play, &hookPos[1], &sLureHookRefPos[1], 1); } POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14); @@ -1855,8 +1850,8 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* 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); - gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineModelDL); } else { for (i = spB4; i < LINE_SEG_COUNT - 1; i++) { if ((i == LINE_SEG_COUNT - 3) && (D_80917206 == 0) && (D_8090CD14 == 3)) { @@ -1882,9 +1877,9 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineModelDL); break; } @@ -1893,16 +1888,15 @@ void EnFishing_DrawLureAndLine(GlobalContext* globalCtx, Vec3f* linePos, Vec3f* 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); - gSPDisplayList(POLY_XLU_DISP++, gFishingLineVtxDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gFishingLineModelDL); } } Matrix_Pop(); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } f32 sRodScales[22] = { @@ -1918,16 +1912,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,7 +1989,7 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { } } - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gFishingRodSetupDL); @@ -2031,7 +2025,7 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { 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, @@ -2054,12 +2048,12 @@ void EnFishing_DrawRod(GlobalContext* globalCtx) { } } - 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 +2064,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 +2138,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); @@ -2158,7 +2152,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { Math_ApproachF(&D_809101C0, 195.0f, 1.0f, 1.0f); - if (player->stateFlags1 & 0x8000000) { + if (player->stateFlags1 & PLAYER_STATE1_8000000) { D_80917204 = 0; player->unk_B28 = 0; } @@ -2166,7 +2160,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; @@ -2221,7 +2215,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sLureRot.y = sReelLineRot[LINE_SEG_COUNT - 2].y; } else { sLureRot.x = 0.0f; - sLureRot.y = Math_Acot2F(spD0, spD8) + M_PI; + sLureRot.y = Math_Atan2F_XY(spD0, spD8) + M_PI; } phi_f16 = sqrtf(SQ(spD8) + SQ(spD4) + SQ(spD0)); @@ -2237,7 +2231,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 +2250,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 +2262,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 +2276,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; @@ -2298,15 +2292,15 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { 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 +2318,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 +2361,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)) { @@ -2406,7 +2400,7 @@ void EnFishing_UpdateLure(EnFishing* this, GlobalContext* globalCtx) { sp90.x = player->actor.world.pos.x - sLurePos.x; sp90.z = player->actor.world.pos.z - sLurePos.z; - sp90.y = Math_Acot2F(sp90.z, sp90.x); + sp90.y = Math_Atan2F_XY(sp90.z, sp90.x); D_809101B0 = (sp70 * D_809101BC) + sp90.y; D_809101BC *= -1.0f; @@ -2443,7 +2437,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; @@ -2495,13 +2489,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 +2510,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 +2538,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 +2564,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 +2573,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 +2613,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 +2622,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; } @@ -2654,24 +2647,24 @@ s32 func_809033F0(EnFishing* this, GlobalContext* globalCtx, u8 ignorePosCheck) 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; @@ -2704,7 +2697,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); } } @@ -2799,7 +2792,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 +2817,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 +2855,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 +2876,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 +2924,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; } @@ -2971,10 +2964,10 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp12C = this->unk_1AC.y - this->actor.world.pos.y; sp128 = this->unk_1AC.z - this->actor.world.pos.z; - spFC = Math_FAtan2F(sp128, sp130); + spFC = Math_Atan2S_XY(sp128, sp130); sp124 = sqrtf(SQ(sp130) + SQ(sp128)); - spFE = Math_FAtan2F(sp124, sp12C); + spFE = Math_Atan2S_XY(sp124, sp12C); sp124 = sqrtf(SQ(sp130) + SQ(sp128) + SQ(sp12C)); if ((this->unk_198 != 0) && (this->unk_150 != 2) && (this->unk_150 != 3) && (this->unk_150 != 4)) { @@ -2992,7 +2985,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 +2994,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 +3005,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 +3057,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 +3080,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 +3142,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 +3165,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 +3183,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 +3196,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; @@ -3387,7 +3379,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 +3404,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 +3414,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 +3442,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 +3455,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 +3469,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 +3477,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 +3497,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 +3552,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 +3586,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) { @@ -3630,7 +3622,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 +3750,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 +3773,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 +3783,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; } @@ -3813,17 +3805,17 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.z = 50.0f; } Matrix_RotateYF((player->actor.shape.rot.y / 32768.0f) * M_PI, MTXMODE_NEW); - Matrix_MultVec3f(&sp10C, &sCameraEye); + Matrix_MultVec3f(&sp10C, &sSubCamEye); - sCameraEye.x += player->actor.world.pos.x; - sCameraEye.y += player->actor.world.pos.y; - sCameraEye.z += player->actor.world.pos.z; + sSubCamEye.x += player->actor.world.pos.x; + sSubCamEye.y += player->actor.world.pos.y; + sSubCamEye.z += player->actor.world.pos.z; - sCameraAt = player->actor.world.pos; + sSubCamAt = player->actor.world.pos; if (sLinkAge != 1) { - sCameraAt.y += 40.0f; + sSubCamAt.y += 40.0f; } else { - sCameraAt.y += 25.0f; + sSubCamAt.y += 25.0f; } if (this->unk_172[0] == 90) { @@ -3856,29 +3848,33 @@ void EnFishing_UpdateFish(Actor* thisx, GlobalContext* globalCtx2) { sp10C.y = -10.0f; sp10C.z = 5.0f; 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); + Math_ApproachF(&this->actor.world.pos.x, player->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].x + sp100.x, 1.0f, + 6.0f); + Math_ApproachF(&this->actor.world.pos.y, player->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].y + sp100.y, 1.0f, + 6.0f); + Math_ApproachF(&this->actor.world.pos.z, player->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].z + sp100.z, 1.0f, + 6.0f); D_809101C0 = 188.0f; if (this->unk_172[0] <= 50) { switch (this->unk_1CD) { case 0: - if ((Message_GetState(&globalCtx->msgCtx) == 4) || Message_GetState(&globalCtx->msgCtx) == 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; D_809171D2 = D_80917206; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else if ((this->unk_148 == 0) && (D_809171D0 == 0) && ((s16)this->unk_1A4 < (s16)D_8090CCF0)) { this->unk_1CD = 1; this->unk_172[0] = 0x3C; - Message_StartTextbox(globalCtx, 0x4098, NULL); + Message_StartTextbox(play, 0x4098, NULL); } else { f32 temp1 = D_8090CCF0; s16 temp2 = D_809171D0; @@ -3896,10 +3892,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 +3920,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 +3960,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 +3984,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 +4061,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 +4097,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 +4109,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 +4142,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 +4161,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,7 +4189,7 @@ 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) { @@ -4203,8 +4197,7 @@ void EnFishing_FishPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d } } -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,7 +4211,7 @@ 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; @@ -4227,10 +4220,10 @@ void EnFishing_LoachPostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** } } -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_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); @@ -4242,18 +4235,16 @@ void EnFishing_DrawFish(Actor* thisx, GlobalContext* globalCtx) { 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_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); } } @@ -4263,7 +4254,7 @@ void EnFishing_HandleReedContact(FishingProp* prop, Vec3f* entityPos) { f32 distXZ = sqrtf(SQ(dx) + SQ(dz)); if (distXZ <= 20.0f) { - prop->rotY = Math_Acot2F(dz, dx); + prop->rotY = Math_Atan2F_XY(dz, dx); Math_ApproachF(&prop->rotX, (20.0f - distXZ) * 0.03f, 0.2f, 0.2f); } @@ -4275,7 +4266,7 @@ void EnFishing_HandleLilyPadContact(FishingProp* prop, Vec3f* entityPos, u8 fish f32 distXZ = sqrtf(SQ(dx) + SQ(dz)); if (distXZ <= 40.0f) { - Math_ApproachS(&prop->lilyPadAngle, Math_FAtan2F(dz, dx), 10, 0x300); + Math_ApproachS(&prop->lilyPadAngle, Math_Atan2S_XY(dz, dx), 10, 0x300); } if (fishTimer && (distXZ <= 60.0f)) { @@ -4289,9 +4280,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 +4291,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 +4302,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 +4316,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 +4328,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,25 +4337,25 @@ 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_Push(); for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_REED) { if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gFishingReedSetupDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingReedMaterialDL); flag++; } @@ -4375,9 +4366,9 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingReedModelDL); } } @@ -4389,7 +4380,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_WOOD_POST) { if (flag == 0) { - gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostSetupDL); + gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostMaterialDL); flag++; } @@ -4397,9 +4388,9 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_OPA_DISP++, gFishingWoodPostModelDL); } } @@ -4411,7 +4402,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_LILY_PAD) { if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadSetupDL); + gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadMaterialDL); flag++; } @@ -4422,9 +4413,9 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_XLU_DISP++, gFishingLilyPadModelDL); } } @@ -4436,7 +4427,7 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { for (i = 0; i < POND_PROP_COUNT; i++) { if (prop->type == FS_PROP_ROCK) { if (flag == 0) { - gSPDisplayList(POLY_OPA_DISP++, gFishingRockSetupDL); + gSPDisplayList(POLY_OPA_DISP++, gFishingRockMaterialDL); flag++; } @@ -4445,9 +4436,9 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { Matrix_Scale(prop->scale, prop->scale, prop->scale, 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); + gSPDisplayList(POLY_OPA_DISP++, gFishingRockModelDL); } } @@ -4456,12 +4447,12 @@ void EnFishing_DrawPondProps(GlobalContext* globalCtx) { 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; @@ -4499,7 +4490,7 @@ 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); } @@ -4516,7 +4507,7 @@ 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); } @@ -4533,7 +4524,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 +4539,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; @@ -4570,9 +4561,9 @@ void EnFishing_UpdateGroupFishes(GlobalContext* globalCtx) { dx = fish->unk_10.x - fish->pos.x; dy = fish->unk_10.y - fish->pos.y; dz = fish->unk_10.z - fish->pos.z; - spD4 = Math_FAtan2F(dz, dx); + spD4 = Math_Atan2S_XY(dz, dx); dist = sqrtf(SQ(dx) + SQ(dz)); - spD6 = Math_FAtan2F(dist, dy); + spD6 = Math_Atan2S_XY(dist, dy); if ((dist < 10.0f) || (((fish->timer % 32) == 0) && (Rand_ZeroOne() > 0.5f))) { fish->unk_10.y = basePos[groupIndex].y + randPlusMinusPoint5Scaled(10.0f); @@ -4586,8 +4577,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) { @@ -4645,7 +4636,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,12 +4649,12 @@ 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) { if (flag == 0) { - gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishSetupDL); + gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishMaterialDL); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 155, 155, 155, 255); flag++; } @@ -4674,20 +4665,20 @@ void EnFishing_DrawGroupFishes(GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_OPA_DISP++, gFishingGroupFishModelDL); } } 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 +4697,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 +4709,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 +4742,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 +4794,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 +4810,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 +4835,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 +4849,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 +4870,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 +4882,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 +4943,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 +4953,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 +4986,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 +5031,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 +5042,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 +5058,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 +5078,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 +5100,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 +5113,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 +5146,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,28 +5160,27 @@ 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; + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); + sSubCamVelFactor = 0.0f; // fallthrough - case 2: - ShrinkWindow_SetLetterboxTarget(27); + ShrinkWindow_Letterbox_SetSizeTarget(27); spFC.x = sLurePos.x - player->actor.world.pos.x; spFC.z = sLurePos.z - player->actor.world.pos.z; lureDistXZ = sqrtf(SQXZ(spFC)); - Matrix_RotateYF(Math_Acot2F(spFC.z, spFC.x), MTXMODE_NEW); + Matrix_RotateYF(Math_Atan2F_XY(spFC.z, spFC.x), MTXMODE_NEW); sp114.x = 0.0f; sp114.y = 0.0f; @@ -5202,9 +5193,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) { @@ -5272,88 +5263,90 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.z = 100.0f; Matrix_MultVec3f(&sp114, &spFC); - Math_ApproachF(&sCameraEye.x, sp108.x, 0.3f, fabsf(spFC.x) * D_80911F4C); - Math_ApproachF(&sCameraEye.y, sp108.y, 0.3f, 20.0f * D_80911F4C); - Math_ApproachF(&sCameraEye.z, sp108.z, 0.3f, fabsf(spFC.z) * D_80911F4C); + Math_ApproachF(&sSubCamEye.x, sp108.x, 0.3f, fabsf(spFC.x) * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.y, sp108.y, 0.3f, 20.0f * sSubCamVelFactor); + Math_ApproachF(&sSubCamEye.z, sp108.z, 0.3f, fabsf(spFC.z) * sSubCamVelFactor); break; case 3: { - Camera* camera = Play_GetCamera(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, PLAYER_CSMODE_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, PLAYER_CSMODE_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, PLAYER_CSMODE_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 @@ -5371,7 +5364,7 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { Math_ApproachF(&D_80911F64, 71.0f, 0.5f, 3.0f); 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) { @@ -5396,43 +5389,45 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { sp114.z = -35.0f; } - Matrix_MultVec3f(&sp114, &sCameraEye); - sCameraEye.x += player->actor.world.pos.x; - sCameraEye.y += player->actor.world.pos.y; - sCameraEye.z += player->actor.world.pos.z; + Matrix_MultVec3f(&sp114, &sSubCamEye); + sSubCamEye.x += player->actor.world.pos.x; + sSubCamEye.y += player->actor.world.pos.y; + sSubCamEye.z += player->actor.world.pos.z; - sCameraAt = player->actor.world.pos; + sSubCamAt = player->actor.world.pos; if (sLinkAge != 1) { - sCameraAt.y += 62.0f; + sSubCamAt.y += 62.0f; } else { - sCameraAt.y += 40.0f; + sSubCamAt.y += 40.0f; } if (D_8090CD50 == 0) { - if ((Message_GetState(&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, + PLAYER_CSMODE_6); // arg2 changed from PLAYER_CSMODE_7 to PLAYER_CSMODE_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 +5437,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++) { @@ -5490,10 +5485,9 @@ void EnFishing_UpdateOwner(Actor* thisx, GlobalContext* globalCtx2) { 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 +5495,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 +5534,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 +5548,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 +5578,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,9 +5588,9 @@ 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_MultVec3f(&sZeroVec, &sOwnerHeadPos); @@ -5608,7 +5600,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 +5610,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 +5652,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; @@ -5675,15 +5666,15 @@ void EnFishing_DrawOwner(Actor* thisx, GlobalContext* globalCtx) { 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..a3dcb3a95 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.h @@ -5,62 +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; - #endif // Z_EN_FISHING_H diff --git a/src/overlays/actors/ovl_En_Floormas/overlay.cfg b/src/overlays/actors/ovl_En_Floormas/overlay.cfg deleted file mode 100644 index 16ece1e42..000000000 --- a/src/overlays/actors/ovl_En_Floormas/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Floormas -z_en_floormas.c 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 e7fb183c1..3ad6809dc 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -10,56 +10,56 @@ #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* play2); +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 = { +ActorInit En_Floormas_InitVars = { ACTOR_EN_FLOORMAS, ACTORCAT_ENEMY, FLAGS, @@ -129,7 +129,7 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 49, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_FLOORMASTER, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; @@ -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,19 +175,19 @@ 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); + Actor_Kill(&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); + Actor_Kill(this->actor.parent); + Actor_Kill(&this->actor); return; } @@ -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,7 +706,7 @@ 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); } } @@ -719,7 +719,7 @@ void func_808D217C(EnFloormas* this, Player* player) { this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; func_808D08D0(this); - ptr = &D_808D3900[(void)0, gSaveContext.save.playerForm]; + ptr = &D_808D3900[GET_PLAYER_FORM]; 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); @@ -728,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) { @@ -745,7 +745,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&player->actor.world.pos, &this->actor.home.pos, &this->actor.world.pos); - if (!(player->stateFlags2 & 0x80) || (player->invincibilityTimer < 0)) { + if (!(player->stateFlags2 & PLAYER_STATE2_80) || (player->invincibilityTimer < 0)) { EnFloormas* parent = (EnFloormas*)this->actor.parent; EnFloormas* child = (EnFloormas*)this->actor.child; @@ -762,8 +762,8 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { this->actor.speedXZ = -3.0f; func_808D1740(this); } else if ((this->unk_190 % 20) == 0) { - func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->unk_92); - globalCtx->damagePlayer(globalCtx, -4); + func_800B8E58(player, NA_SE_VO_LI_DAMAGE_S + player->ageProperties->voiceSfxIdOffset); + play->damagePlayer(play, -4); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FLOORMASTER_SM_STICK - SFX_FLAG); } @@ -774,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); @@ -822,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; @@ -836,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)) { @@ -898,7 +898,7 @@ void func_808D2A20(EnFloormas* this) { if ((parent->actionFunc == func_808D2AA8) && (child->actionFunc == func_808D2AA8)) { func_808D2AB8(parent); func_808D2AB8(child); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->actor.draw = NULL; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10); @@ -906,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) { @@ -916,8 +916,8 @@ void func_808D2AB8(EnFloormas* this) { this->actionFunc = func_808D2AF4; } -void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { - Actor_MarkForDeath(&this->actor); +void func_808D2AF4(EnFloormas* this, PlayState* play) { + Actor_Kill(&this->actor); } void func_808D2B18(EnFloormas* this) { @@ -943,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); } @@ -971,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); } @@ -986,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); @@ -1026,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) { @@ -1064,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); } @@ -1078,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; @@ -1091,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; @@ -1102,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); } } @@ -1144,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) { @@ -1155,8 +1155,7 @@ 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) { @@ -1173,58 +1172,58 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis 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_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..002f9e67c 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,23 +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; - #endif // Z_EN_FLOORMAS_H diff --git a/src/overlays/actors/ovl_En_Fr/overlay.cfg b/src/overlays/actors/ovl_En_Fr/overlay.cfg deleted file mode 100644 index b21ec2145..000000000 --- a/src/overlays/actors/ovl_En_Fr/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fr -z_en_fr.c 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..0b645b302 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -10,11 +10,11 @@ #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 = { +ActorInit En_Fr_InitVars = { ACTOR_EN_FR, ACTORCAT_ITEMACTION, FLAGS, @@ -26,25 +26,29 @@ 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))) { - Actor_MarkForDeath(&this->actor); - } else { - this->actor.targetMode = ENFR_GET_TARGETMODE(&this->actor); + if (Flags_GetSwitch(play, ENFR_GET_SWITCHFLAG(&this->actor))) { + Actor_Kill(&this->actor); + return; } + + 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))) { - Actor_MarkForDeath(&this->actor); - } else if (this->actor.xyzDistToPlayerSq < SQ(IREG(29))) { + if (Flags_GetSwitch(play, ENFR_GET_SWITCHFLAG(&this->actor))) { + Actor_Kill(&this->actor); + return; + } + + if (this->actor.xyzDistToPlayerSq < SQ(IREG(29))) { this->actor.flags &= ~ACTOR_FLAG_40000000; } else { this->actor.flags |= ACTOR_FLAG_40000000; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.h b/src/overlays/actors/ovl_En_Fr/z_en_fr.h index f0de1936d..27682ce40 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.h +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.h @@ -12,6 +12,4 @@ typedef struct EnFr { /* 0x000 */ Actor actor; } EnFr; // size = 0x144 -extern const ActorInit En_Fr_InitVars; - #endif // Z_EN_FR_H diff --git a/src/overlays/actors/ovl_En_Fsn/overlay.cfg b/src/overlays/actors/ovl_En_Fsn/overlay.cfg deleted file mode 100644 index c173063cf..000000000 --- a/src/overlays/actors/ovl_En_Fsn/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fsn -z_en_fsn.c 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 670bafff2..0fa23e71a 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,23 +53,23 @@ 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 = { +ActorInit En_Fsn_InitVars = { ACTOR_EN_FSN, ACTORCAT_NPC, FLAGS, @@ -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,10 +150,10 @@ 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)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_80_10)) { this->textId = 0x29E0; break; } else { @@ -166,7 +166,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.save.weekEventReg[80] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_80_10); this->textId = 0x29F1; break; } else { @@ -186,7 +186,7 @@ void EnFsn_HandleConversationBackroom(EnFsn* this, GlobalContext* globalCtx) { this->flags |= ENFSN_GIVE_ITEM; this->flags |= ENFSN_GAVE_LETTER_TO_MAMA; this->getItemId = GI_LETTER_TO_MAMA; - gSaveContext.save.weekEventReg[80] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_80_10); this->textId = 0x29F1; break; case 0x29F1: @@ -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_IA_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) { @@ -261,26 +261,26 @@ u8 EnFsn_SetCursorIndexFromNeutral(EnFsn* this) { } void EnFsn_CursorLeftRight(EnFsn* this) { - u8 cursorScan = this->cursorIdx; + u8 cursorScan = this->cursorIndex; if (this->stickAccumX > 0) { if (cursorScan != this->totalSellingItems - 1) { while (cursorScan != this->totalSellingItems - 1) { cursorScan++; if (this->itemIds[cursorScan] != -1) { - this->cursorIdx = cursorScan; + this->cursorIndex = cursorScan; break; } } } else if (this->itemIds[cursorScan] != -1) { - this->cursorIdx = cursorScan; + this->cursorIndex = cursorScan; } } else if (this->stickAccumX < 0) { if (cursorScan != 0) { while (cursorScan != 0) { cursorScan--; if (this->itemIds[cursorScan] != -1) { - this->cursorIdx = cursorScan; + this->cursorIndex = cursorScan; break; } else if (cursorScan == 0) { play_sound(NA_SE_SY_CURSOR); @@ -294,15 +294,15 @@ void EnFsn_CursorLeftRight(EnFsn* this) { this->drawCursor = 0; this->actionFunc = EnFsn_LookToShopkeeperFromShelf; if (this->itemIds[cursorScan] != -1) { - this->cursorIdx = cursorScan; + this->cursorIndex = cursorScan; } } } } s16 EnFsn_GetThirdDayItemId(void) { - if (!(gSaveContext.save.weekEventReg[33] & 4) && CURRENT_DAY == 3) { - if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_33_04) && CURRENT_DAY == 3) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40)) { return SI_BOMB_BAG_30_1; } return SI_MASK_ALL_NIGHT; @@ -335,7 +335,7 @@ s32 EnFsn_HasItemsToSell(void) { } if ((STOLEN_ITEM_1 != STOLEN_ITEM_NONE) || (STOLEN_ITEM_2 != STOLEN_ITEM_NONE) || - !(gSaveContext.save.weekEventReg[33] & 4)) { + !CHECK_WEEKEVENTREG(WEEKEVENTREG_33_04)) { return true; } @@ -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,96 +379,96 @@ 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; - Interface_ChangeAlpha(50); + Actor_ProcessTalkRequest(&this->actor, &play->state); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); 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->cursorIndex]->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->cursorIndex]->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) { this->actor.textId = 0x29FB; - } else if (gSaveContext.save.weekEventReg[33] & 4) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_04)) { this->actor.textId = 0x29FF; - } else if (!(gSaveContext.save.weekEventReg[33] & 8) && !(gSaveContext.save.weekEventReg[79] & 0x40)) { + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40)) { this->actor.textId = 0x29D7; } 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 (!this->items[this->cursorIdx]->isOutOfStock) { - this->tmpActionFunc = this->actionFunc; - func_80151938(globalCtx, this->items[this->cursorIdx]->choiceTextId); + if (EnFsn_TestItemSelected(play)) { + if (!this->items[this->cursorIndex]->isOutOfStock) { + 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; @@ -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) { @@ -522,7 +522,7 @@ void EnFsn_UpdateJoystickInputState(EnFsn* this, GlobalContext* globalCtx) { void EnFsn_PositionSelectedItem(EnFsn* this) { Vec3f selectedItemPosition = { 13.0f, 38.0f, -71.0f }; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; EnGirlA* item = this->items[i]; Vec3f worldPos; @@ -572,7 +572,7 @@ void EnFsn_UpdateItemSelectedProperty(EnFsn* this) { this->drawCursor == 0) { (*items)->isSelected = false; } else { - (*items)->isSelected = (i == this->cursorIdx) ? true : false; + (*items)->isSelected = (i == this->cursorIndex) ? true : false; } } } @@ -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->eyeTextureIdx = 0; - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimations, this->animationIndex); + this->animIndex = FSN_ANIM_HANDS_ON_COUNTER_START; + this->eyeTexIndex = 0; + 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, DO_ACTION_NEXT); 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_IA_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,39 +858,38 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_04)) { this->actor.textId = 0x2A01; - } else if (!(gSaveContext.save.weekEventReg[33] & 8) && - !(gSaveContext.save.weekEventReg[79] & 0x40)) { + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40)) { this->actor.textId = 0x29D3; } 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, DO_ACTION_DECIDE); + 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 +897,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,27 +905,24 @@ 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); - s32 itemActionParam; +void EnFsn_DeterminePrice(EnFsn* this, PlayState* play) { + Player* player = GET_PLAYER(play); + PlayerItemAction itemAction; u8 buttonItem; - if (Message_GetState(&globalCtx->msgCtx) == 16) { - itemActionParam = func_80123810(globalCtx); - if (itemActionParam > PLAYER_AP_NONE) { - if (player->heldItemButton == 0) { - buttonItem = CUR_FORM_EQUIP(player->heldItemButton); - } else { - buttonItem = gSaveContext.save.equips.buttonItems[0][player->heldItemButton]; - } + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemAction = func_80123810(play); + + if (itemAction > PLAYER_IA_NONE) { + buttonItem = GET_CUR_FORM_BTN_ITEM(player->heldItemButton); this->price = (buttonItem < ITEM_MOON_TEAR) ? gItemPrices[buttonItem] : 0; if (this->price > 0) { player->actor.textId = 0x29EF; @@ -937,30 +933,30 @@ void EnFsn_DeterminePrice(EnFsn* this, GlobalContext* globalCtx) { this->actionFunc = EnFsn_StartBuying; } this->actor.textId = player->actor.textId; - func_801477B4(globalCtx); - } else if (itemActionParam < PLAYER_AP_NONE) { + func_801477B4(play); + } else if (itemAction <= PLAYER_IA_MINUS1) { 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 +982,43 @@ void EnFsn_MakeOffer(EnFsn* this, GlobalContext* globalCtx) { break; case 1: func_8019F230(); - player->exchangeItemId = EXCH_ITEM_NONE; + player->exchangeItemId = PLAYER_IA_NONE; this->actionFunc = EnFsn_SetupDeterminePrice; break; } } } -void EnFsn_GiveItem(EnFsn* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - if ((this->isSelling == true) && (this->items[this->cursorIdx]->getItemId == GI_MASK_ALL_NIGHT)) { - func_80151BB4(globalCtx, 45); - func_80151BB4(globalCtx, 3); +void EnFsn_GiveItem(EnFsn* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + if ((this->isSelling == true) && (this->items[this->cursorIndex]->getItemId == GI_MASK_ALL_NIGHT)) { + 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); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_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->cursorIndex]->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 +1027,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_IA_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 +1052,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, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actionFunc = EnFsn_FaceShopkeeperSelling; @@ -1071,7 +1067,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,19 +1080,19 @@ 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->cursorIndex]->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; + u8 prevCursorIdx = this->cursorIndex; if (!EnFsn_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -1105,21 +1101,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, DO_ACTION_DECIDE); + if (!EnFsn_HasPlayerSelectedItem(this, play, CONTROLLER1(&play->state))) { EnFsn_CursorLeftRight(this); - if (this->cursorIdx != prevCursorIdx) { + if (this->cursorIndex != prevCursorIdx) { play_sound(NA_SE_SY_CURSOR); - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + func_80151938(play, this->items[this->cursorIndex]->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 +1131,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,96 +1139,96 @@ void EnFsn_LookToShopkeeperFromShelf(EnFsn* this, GlobalContext* globalCtx) { } } -void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, GlobalContext* globalCtx) { - EnGirlA* item = this->items[this->cursorIdx]; +void EnFsn_HandleCanPlayerBuyItem(EnFsn* this, PlayState* play) { + EnGirlA* item = this->items[this->cursorIndex]; - switch (item->canBuyFunc(globalCtx, item)) { + switch (item->canBuyFunc(play, item)) { case CANBUY_RESULT_SUCCESS_2: func_8019F208(); - gSaveContext.save.weekEventReg[33] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_33_04); case CANBUY_RESULT_SUCCESS_1: if (this->cutsceneState == ENFSN_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENFSN_CUTSCENESTATE_STOPPED; } 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; - Interface_ChangeAlpha(50); + item = this->items[this->cursorIndex]; + item->buyFanfareFunc(play, item); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->shopItemSelectedTween = 0.0f; - item = this->items[this->cursorIdx]; - item->boughtFunc(globalCtx, item); - if (this->stolenItem1 == this->cursorIdx) { + item = this->items[this->cursorIndex]; + item->boughtFunc(play, item); + if (this->stolenItem1 == this->cursorIndex) { SET_STOLEN_ITEM_1(STOLEN_ITEM_NONE); - } else if (this->stolenItem2 == this->cursorIdx) { + } else if (this->stolenItem2 == this->cursorIndex) { SET_STOLEN_ITEM_2(STOLEN_ITEM_NONE); } this->numSellingItems--; - this->itemIds[this->cursorIdx] = -1; + this->itemIds[this->cursorIndex] = -1; this->actionFunc = EnFsn_GiveItem; 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, DO_ACTION_DECIDE); + 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->cursorIndex]->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->cursorIndex]->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 +1242,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 +1288,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); - u8 cursorIdx; +void EnFsn_FaceShopkeeperSelling(EnFsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + u8 cursorIndex; - 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, DO_ACTION_DECIDE); + 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; + cursorIndex = EnFsn_SetCursorIndexFromNeutral(this); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; this->actionFunc = EnFsn_LookToShelf; - func_8011552C(globalCtx, 6); + func_8011552C(play, DO_ACTION_DECIDE); 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); } } } @@ -1394,73 +1390,75 @@ void EnFsn_Blink(EnFsn* this) { s16 decr = this->blinkTimer - 1; if (decr >= 3) { - this->eyeTextureIdx = 0; + this->eyeTexIndex = 0; this->blinkTimer = decr; } else if (decr == 0) { - this->eyeTextureIdx = 2; + this->eyeTexIndex = 2; this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; } else { - this->eyeTextureIdx = 1; + this->eyeTexIndex = 1; this->blinkTimer = decr; } } -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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08) || CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40)) { + Actor_Kill(&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->eyeTexIndex = 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 +1467,10 @@ 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 +1483,11 @@ 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 +1498,8 @@ 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 +1516,30 @@ 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,22 +1548,23 @@ 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; @@ -1594,7 +1597,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 +1605,27 @@ 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); - 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, + OPEN_DISPS(play->state.gfxCtx); + + func_8012C5B0(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + 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 +1634,8 @@ 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..35b654c3d 100644 --- a/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h +++ b/src/overlays/actors/ovl_En_Fsn/z_en_fsn.h @@ -15,22 +15,22 @@ 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; + /* 0x364 */ s16 eyeTexIndex; /* 0x366 */ s16 blinkTimer; /* 0x368 */ s16 cutsceneState; /* 0x36A */ s16 cutscene; @@ -41,7 +41,7 @@ typedef struct EnFsn { /* 0x374 */ s16 price; /* 0x376 */ u16 textId; /* 0x378 */ u8 isSelling; - /* 0x379 */ u8 cursorIdx; + /* 0x379 */ u8 cursorIndex; /* 0x37C */ s32 getItemId; /* 0x380 */ s16 stolenItem1; /* 0x382 */ s16 stolenItem2; @@ -64,10 +64,8 @@ typedef struct EnFsn { /* 0x444 */ u8 arrowAnimState; /* 0x445 */ u8 stickAnimState; /* 0x448 */ f32 shopItemSelectedTween; - /* 0x44C */ s16 animationIndex; + /* 0x44C */ s16 animIndex; /* 0x44E */ u16 flags; } EnFsn; // size = 0x450 -extern const ActorInit En_Fsn_InitVars; - #endif // Z_EN_FSN_H diff --git a/src/overlays/actors/ovl_En_Fu/overlay.cfg b/src/overlays/actors/ovl_En_Fu/overlay.cfg deleted file mode 100644 index 0cc55f8eb..000000000 --- a/src/overlays/actors/ovl_En_Fu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fu -z_en_fu.c 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 77450f9ab..041cadaa7 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -16,46 +16,46 @@ #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 = { +ActorInit En_Fu_InitVars = { ACTOR_EN_FU, ACTORCAT_NPC, FLAGS, @@ -73,14 +73,14 @@ static Vec3f D_80964B0C = { 0.0f, 60.0f, -8.0f }; static Vec3f D_80964B18 = { 0.0f, 55.0f, 12.0f }; static Vec3f D_80964B24 = { 0.0f, 60.0f, 0.0f }; -static AnimationInfo sAnimations[] = { - { &object_mu_Anim_0053E0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_mu_Anim_001F74, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_mu_Anim_002F64, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_mu_Anim_004904, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_mu_Anim_005304, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_mu_Anim_00BAC4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, +static AnimationInfo sAnimationInfo[] = { + { &gHoneyAndDarlingIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gHoneyAndDarlingCupCheeksLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gHoneyAndDarlingHugLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gHoneyAndDarlingGameDanceLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHoneyAndDarlingHoldHandsLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, + { &gHoneyAndDarlingHoldHandsLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHoneyAndDarlingSurpiseAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -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; @@ -119,10 +119,10 @@ void func_809616E0(EnFu* this, GlobalContext* globalCtx) { for (i = 0; i < this->unk_520; i++) { temp_f20 = this->actor.world.pos.x - this->unk_538[i].x; temp_f22 = this->actor.world.pos.z - this->unk_538[i].z; - atan = Math_FAtan2F(temp_f22, temp_f20); + atan = Math_Atan2S_XY(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, &gHoneyAndDarlingSkel, &gHoneyAndDarlingCupCheeksLoopAnim, + this->jointTable, this->morphTable, HONEY_AND_DARLING_LIMB_MAX); + 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); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_08_01); + 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,17 +270,17 @@ 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); + Actor_Kill(explosive); explosive = explosive->next; } } -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); @@ -371,91 +371,92 @@ void func_8096209C(EnFu* this, GlobalContext* globalCtx) { } 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); + } else if ((CURRENT_DAY == 3) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_10) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_22_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_40)) { + 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); + } else if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) && + (this->unk_552 != 0x2888)) { + 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; + player->stateFlags1 &= ~PLAYER_STATE1_20; 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 +464,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 +498,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 +519,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 +527,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); - player->stateFlags1 |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + func_801477B4(play); + player->stateFlags1 |= PLAYER_STATE1_20; this->unk_53C = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); - func_801A2BB8(NA_BGM_MINI_GAME_2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); 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 +560,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 +577,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: @@ -604,8 +605,8 @@ void func_809628D0(EnFu* this, GlobalContext* globalCtx) { case 0x2884: case 0x2887: case 0x288A: - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); func_809622FC(this); break; @@ -617,12 +618,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 +631,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; @@ -643,17 +644,16 @@ void func_80962A10(EnFu* this, GlobalContext* globalCtx) { } play_sound(NA_SE_SY_FOUND); - player->stateFlags1 &= ~0x20; - func_8010E9F0(4, 60); + player->stateFlags1 &= ~PLAYER_STATE1_20; + Interface_StartTimer(TIMER_ID_MINIGAME_2, 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) { - Parameter_AddMagic(globalCtx, - ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + if ((gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && gSaveContext.save.playerData.isMagicAcquired) { + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); } func_80962F10(this); @@ -667,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)) { @@ -680,17 +680,17 @@ void func_80962BCC(EnFu* this, GlobalContext* globalCtx) { } play_sound(NA_SE_SY_FOUND); - player->stateFlags1 &= ~0x20; - player->stateFlags3 |= 0x400000; - func_8010E9F0(4, 60); + player->stateFlags1 &= ~PLAYER_STATE1_20; + player->stateFlags3 |= PLAYER_STATE3_400000; + Interface_StartTimer(TIMER_ID_MINIGAME_2, 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); } @@ -699,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)) { @@ -711,24 +711,24 @@ void func_80962D60(EnFu* this, GlobalContext* globalCtx) { } play_sound(NA_SE_SY_FOUND); - player->stateFlags1 &= ~0x20; - player->stateFlags3 |= 0x400000; - func_8010E9F0(4, 60); + player->stateFlags1 &= ~PLAYER_STATE1_20; + player->stateFlags3 |= PLAYER_STATE3_400000; + Interface_StartTimer(TIMER_ID_MINIGAME_2, 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); } } @@ -737,94 +737,94 @@ void func_80962EBC(EnFu* this, GlobalContext* globalCtx) { void func_80962F10(EnFu* this) { this->unk_548 = 0; this->actor.flags &= ~ACTOR_FLAG_1; - gSaveContext.save.weekEventReg[8] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_08_01); 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) { case 0: if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - player->stateFlags3 |= 0x400; + player->stateFlags3 |= PLAYER_STATE3_400; } break; case 1: - globalCtx->unk_1887E = 30; + play->unk_1887E = 30; break; case 2: - globalCtx->unk_1887D = 30; + play->unk_1887D = 30; break; } - if (gSaveContext.unk_3DE0[4] < 2000) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(20)) { s16 val = D_80964B00[this->unk_542] + 200; Math_SmoothStepToS(&fuKaiten->rotationSpeed, val, 10, 5, 5); - } else if (gSaveContext.unk_3DE0[4] < 4000) { + } else if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(40)) { s16 val = D_80964B00[this->unk_542] + 100; Math_SmoothStepToS(&fuKaiten->rotationSpeed, val, 10, 5, 5); } 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); - player->stateFlags1 |= 0x20; + (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] <= SECONDS_TO_TIMER(0)) || (this->unk_548 == this->unk_54C)) { + player->stateFlags3 &= ~PLAYER_STATE3_400000; + func_80961E88(play); + player->stateFlags1 |= PLAYER_STATE1_20; if (this->unk_548 < this->unk_54C) { - if (gSaveContext.unk_3DE0[4] == 0) { - Message_StartTextbox(globalCtx, 0x2885, &this->actor); + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { + 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(); - gSaveContext.unk_3DE0[4] = 0; - gSaveContext.unk_3DD0[4] = 5; + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; this->unk_548 = 0; func_809632D0(this); } else { this->unk_548 = 0; func_801A2C20(); - gSaveContext.unk_3DE0[4] = 0; - gSaveContext.unk_3DD0[4] = 5; - func_801A3098(NA_BGM_GET_ITEM | 0x900); - func_8011B4E0(globalCtx, 1); + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); + Interface_SetPerfectLetters(play, PERFECT_LETTERS_TYPE_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); } } void func_809632D0(EnFu* this) { if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - Interface_ChangeAlpha(50); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); } - gSaveContext.save.weekEventReg[8] &= (u8)~1; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_08_01); if (this->unk_2D4 != NULL) { BgFuMizu* mizu = this->unk_2D4; @@ -836,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.perfectLettersOn) { 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); } } @@ -873,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); + } else if ((this->unk_552 == 0x2880) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_22_80)) { + 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; } @@ -890,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 ((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); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_10) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_20) && (CURRENT_DAY == 3) && + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_40)) { + 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); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_22_80); + 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; } @@ -919,27 +920,27 @@ void func_80963630(EnFu* this, GlobalContext* globalCtx) { if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { switch (CURRENT_DAY) { case 1: - gSaveContext.save.weekEventReg[22] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_22_10); break; case 2: - gSaveContext.save.weekEventReg[22] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_22_20); break; case 3: - gSaveContext.save.weekEventReg[22] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_22_40); break; } } - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_20; } else { this->actor.child->freezeTimer = 10; - func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 500.0f, PLAYER_IA_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; @@ -955,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; @@ -964,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); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_10)) { + 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)) { + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_10)) { 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); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_20)) { + 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; @@ -1067,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); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_40)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_10) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_20)) { + 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)) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_10) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_20)) { 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)) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_20)) { 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) { - if (gSaveContext.save.playerData.magicAcquired) { +void func_80963EAC(EnFu* this, PlayState* play) { + if (gSaveContext.save.playerData.isMagicAcquired) { 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; + if (player->stateFlags1 & PLAYER_STATE1_100000) { + 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) { @@ -1190,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)) { @@ -1202,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: @@ -1239,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: @@ -1320,30 +1321,30 @@ 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) { @@ -1362,7 +1363,7 @@ s32 EnFu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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; @@ -1374,25 +1375,25 @@ void EnFu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnFu_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnFu_Draw(Actor* thisx, PlayState* play) { s32 pad; EnFu* this = THIS; Matrix_Push(); - func_80964950(globalCtx, this->unk_2D8, ARRAY_COUNT(this->unk_2D8)); + 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) { @@ -1418,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++) { @@ -1441,31 +1442,30 @@ void func_809647EC(GlobalContext* globalCtx, EnFuUnkStruct* ptr, s32 len) { } } -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++) { if (ptr->unk_36 == 1) { if (!flag) { - gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0A0); + gSPDisplayList(POLY_OPA_DISP++, gHoneyAndDarlingHeartMaterialDL); flag = true; } Matrix_Translate(ptr->unk_08.x, ptr->unk_08.y, ptr->unk_08.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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); - gSPDisplayList(POLY_OPA_DISP++, object_mu_DL_00B0E0); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHoneyAndDarlingHeartModelDL); } } - 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..44f769a8c 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.h +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.h @@ -6,52 +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; - #endif // Z_EN_FU_H diff --git a/src/overlays/actors/ovl_En_Fu_Kago/overlay.cfg b/src/overlays/actors/ovl_En_Fu_Kago/overlay.cfg deleted file mode 100644 index 9a946e309..000000000 --- a/src/overlays/actors/ovl_En_Fu_Kago/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fu_Kago -z_en_fu_kago.c 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 ef4c8b6bb..b232210f5 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,27 +7,28 @@ #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 = { +ActorInit En_Fu_Kago_InitVars = { ACTOR_EN_FU_KAGO, ACTORCAT_BG, FLAGS, @@ -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) { @@ -99,12 +100,12 @@ void EnFuKago_Init(Actor* thisx, GlobalContext* globalCtx) { } if (npc == NULL) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); 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; @@ -341,29 +342,29 @@ void func_80AD0288(EnFuKago* this, GlobalContext* globalCtx) { scale->z = scale->x; scale->y = scale->x; if (scale->x == 0.0f) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } } -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_Push(); @@ -373,25 +374,25 @@ void func_80AD0340(EnFuKago* this, GlobalContext* globalCtx) { 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_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..48bd69a27 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,15 +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; - #endif // Z_EN_FU_KAGO_H diff --git a/src/overlays/actors/ovl_En_Fu_Mato/overlay.cfg b/src/overlays/actors/ovl_En_Fu_Mato/overlay.cfg deleted file mode 100644 index 78253baff..000000000 --- a/src/overlays/actors/ovl_En_Fu_Mato/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fu_Mato -z_en_fu_mato.c 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 4591eab65..6f9706a2b 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,27 +6,28 @@ #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 = { +ActorInit En_Fu_Mato_InitVars = { ACTOR_EN_FU_MATO, ACTORCAT_BG, FLAGS, @@ -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) { @@ -91,7 +92,7 @@ void EnFuMato_Init(Actor* thisx, GlobalContext* globalCtx) { } if (actor == NULL) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } @@ -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); - Actor_MarkForDeath(&this->dyna.actor); + func_800B3030(play, &this->dyna.actor.world.pos, &sp3C, &sp30, 20, 40, 2); + Actor_Kill(&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,17 +346,17 @@ 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); scale->y = scale->z = scale->x; if (scale->x == 0.0f) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } } -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_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) { @@ -436,49 +437,49 @@ void func_80ACF1F4(EnFuMato* this, GlobalContext* globalCtx) { 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_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_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..2065784d7 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,21 +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; - #endif // Z_EN_FU_MATO_H diff --git a/src/overlays/actors/ovl_En_Fz/overlay.cfg b/src/overlays/actors/ovl_En_Fz/overlay.cfg deleted file mode 100644 index 0eba400a5..000000000 --- a/src/overlays/actors/ovl_En_Fz/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Fz -z_en_fz.c 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 bd6f66e34..f7d1d7cd1 100644 --- a/src/overlays/actors/ovl_En_Fz/z_en_fz.c +++ b/src/overlays/actors/ovl_En_Fz/z_en_fz.c @@ -13,43 +13,43 @@ #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 = { +ActorInit En_Fz_InitVars = { ACTOR_EN_FZ, ACTORCAT_ENEMY, FLAGS, @@ -156,25 +156,25 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 59, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_FREEZARD, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1400, ICHAIN_CONTINUE), 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,25 +230,25 @@ 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)) { + (this->actor.parent->update != NULL) && (((EnWiz*)this->actor.parent)->freezard != NULL)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - wiz->unk_448 = 0; + wiz->freezard = NULL; } } -void func_80932784(EnFz* this, GlobalContext* globalCtx) { +void func_80932784(EnFz* this, PlayState* play) { Vec3f sp5C; Vec3f sp50; Vec3f sp44; @@ -266,8 +266,7 @@ void func_80932784(EnFz* this, GlobalContext* globalCtx) { sp44.z = 440.0f; Matrix_MultVec3f(&sp44, &this->unk_22C); - if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &sp5C, &this->unk_22C, &sp50, &sp3C, true, false, false, true, - &sp40)) { + 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; @@ -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,14 +656,14 @@ 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); + Actor_Kill(&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; } @@ -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); @@ -1004,23 +1003,23 @@ void func_80934464(EnFz* this, GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); if (flag == 0) { - gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamDL); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamMaterialDL); flag++; } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_2C); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (ptr->unk_01 + (i * 3)) * 3, + 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_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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); - gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL); + gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamModelDL); } } - 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..539560c88 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) @@ -70,6 +70,4 @@ typedef struct EnFz { /* 0xBD9 */ u8 unk_BD9; } EnFz; /* size = 0xBDC */ -extern const ActorInit En_Fz_InitVars; - #endif // Z_EN_FZ_H diff --git a/src/overlays/actors/ovl_En_Gakufu/overlay.cfg b/src/overlays/actors/ovl_En_Gakufu/overlay.cfg deleted file mode 100644 index 9f421707a..000000000 --- a/src/overlays/actors/ovl_En_Gakufu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Gakufu -z_en_gakufu.c 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 de6a752d8..55dc23737 100644 --- a/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c +++ b/src/overlays/actors/ovl_En_Gakufu/z_en_gakufu.c @@ -11,21 +11,21 @@ #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 = { +ActorInit En_Gakufu_InitVars = { ACTOR_EN_GAKUFU, ACTORCAT_ITEMACTION, FLAGS, @@ -106,18 +106,21 @@ 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]; + + //! FAKE: + if (1) {} songNumButtons = gOcarinaSongButtons[this->songIndex].numButtons; - for (i = 0; i < songNumButtons; i++) { + for (i = 0; i < (u8)songNumButtons; i++) { this->buttonIndex[i] = ocarinaSongButtons->buttonIndex[i]; } @@ -126,7 +129,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,21 +144,21 @@ void EnGakufu_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_2000000; - if (EnGakufu_IsPlayerInRange(this, globalCtx)) { - gSaveContext.eventInf[3] |= 2; + if (EnGakufu_IsPlayerInRange(this, play)) { + SET_EVENTINF(EVENTINF_31); } else { - gSaveContext.eventInf[3] &= (u8)~2; + CLEAR_EVENTINF(EVENTINF_31); } this->actionFunc = EnGakufu_WaitForSong; - gSaveContext.eventInf[3] &= (u8)~4; + CLEAR_EVENTINF(EVENTINF_32); } -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) { - gSaveContext.eventInf[3] &= (u8)~2; + CLEAR_EVENTINF(EVENTINF_31); } } @@ -164,7 +167,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 +183,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 +204,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); } @@ -228,48 +231,48 @@ void EnGakufu_PlayRewardCutscene(EnGakufu* this, GlobalContext* globalCtx) { /** * Waits for the notes on the wall to be played and updates the corresponding flags - * (gSaveContext.eventInf[3] & 2) is checking if Player is within range of the wall - * (gSaveContext.eventInf[3] & 4) is checking if Player has played the notes of the wall + * EVENTINF_31 is used to track if Player is within range of the wall + * EVENTINF_32 is used to track if Player has played the notes of the wall */ -void EnGakufu_WaitForSong(EnGakufu* this, GlobalContext* globalCtx) { - if (gSaveContext.eventInf[3] & 2) { - if (gSaveContext.eventInf[3] & 4) { - gSaveContext.eventInf[3] &= (u8)~2; - gSaveContext.eventInf[3] &= (u8)~4; +void EnGakufu_WaitForSong(EnGakufu* this, PlayState* play) { + if (CHECK_EVENTINF(EVENTINF_31)) { + if (CHECK_EVENTINF(EVENTINF_32)) { + CLEAR_EVENTINF(EVENTINF_31); + CLEAR_EVENTINF(EVENTINF_32); this->actionFunc = EnGakufu_PlayRewardCutscene; - EnGakufu_PlayRewardCutscene(this, globalCtx); + EnGakufu_PlayRewardCutscene(this, play); this->actor.draw = NULL; - } else if (!EnGakufu_IsPlayerInRange(this, globalCtx)) { - gSaveContext.eventInf[3] &= (u8)~2; + } else if (!EnGakufu_IsPlayerInRange(this, play)) { + CLEAR_EVENTINF(EVENTINF_31); } - } else if (EnGakufu_IsPlayerInRange(this, globalCtx)) { - gSaveContext.eventInf[3] |= 2; + } else if (EnGakufu_IsPlayerInRange(this, play)) { + SET_EVENTINF(EVENTINF_31); } } -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_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, @@ -286,7 +289,7 @@ void EnGakufu_Draw(Actor* thisx, GlobalContext* globalCtx) { 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..04d9c7159 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 { @@ -21,6 +21,4 @@ typedef struct EnGakufu { /* 0x150 */ EnGakufuActionFunc actionFunc; } EnGakufu; // size = 0x154 -extern const ActorInit En_Gakufu_InitVars; - #endif // Z_EN_GAKUFU_H diff --git a/src/overlays/actors/ovl_En_Gamelupy/overlay.cfg b/src/overlays/actors/ovl_En_Gamelupy/overlay.cfg deleted file mode 100644 index a9b07ebae..000000000 --- a/src/overlays/actors/ovl_En_Gamelupy/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Gamelupy -z_en_gamelupy.c 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..40c3d5c05 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.c @@ -5,22 +5,25 @@ */ #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 = { +ActorInit En_Gamelupy_InitVars = { ACTOR_EN_GAMELUPY, ACTORCAT_PROP, FLAGS, @@ -32,37 +35,157 @@ 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 sRupeeTextures[] = { + gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeeOrangeTex, gRupeePurpleTex, +}; -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_Kill(&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(sRupeeTextures[this->rupeeIndex])); + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); + + 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..5d45f3168 100644 --- a/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h +++ b/src/overlays/actors/ovl_En_Gamelupy/z_en_gamelupy.h @@ -5,15 +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; - #endif // Z_EN_GAMELUPY_H diff --git a/src/overlays/actors/ovl_En_Gb2/overlay.cfg b/src/overlays/actors/ovl_En_Gb2/overlay.cfg deleted file mode 100644 index d604decdc..000000000 --- a/src/overlays/actors/ovl_En_Gb2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Gb2 -z_en_gb2.c 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 41783a1b7..d6643dbeb 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -11,32 +11,32 @@ #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 = { +ActorInit En_Gb2_InitVars = { ACTOR_EN_GB2, ACTORCAT_NPC, FLAGS, @@ -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; } @@ -120,8 +120,8 @@ s32 func_80B0F660(EnGb2* this, GlobalContext* globalCtx) { } void func_80B0F6DC(EnGb2* this) { - if (!(gSaveContext.save.weekEventReg[54] & 0x20)) { - gSaveContext.save.weekEventReg[54] |= 0x20; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_54_20)) { + SET_WEEKEVENTREG(WEEKEVENTREG_54_20); this->unk_26E = 0x14D0; } else { this->unk_26E = 0x14D1; @@ -130,26 +130,26 @@ void func_80B0F6DC(EnGb2* this) { this->actionFunc = func_80B0FEBC; } -void func_80B0F728(EnGb2* this, GlobalContext* globalCtx) { - if (gSaveContext.eventInf[4] & 0x10) { - func_80B0FBF0(this, globalCtx); +void func_80B0F728(EnGb2* this, PlayState* play) { + if (CHECK_EVENTINF(EVENTINF_44)) { + func_80B0FBF0(this, play); this->unk_26E = 0x14E1; - if (gSaveContext.eventInf[4] & 0x80) { + if (CHECK_EVENTINF(EVENTINF_47)) { this->unk_288 = 10; } else { this->unk_288 = 30; } - } else if (gSaveContext.eventInf[4] & 0x20) { - func_80B0FBF0(this, globalCtx); + } else if (CHECK_EVENTINF(EVENTINF_45)) { + func_80B0FBF0(this, play); this->unk_26E = 0x14E0; this->unk_26C |= 2; } else { this->unk_26E = 0x14DC; } - gSaveContext.eventInf[4] &= (u8)~0x10; - gSaveContext.eventInf[4] &= (u8)~0x20; - gSaveContext.eventInf[4] &= (u8)~0x40; + CLEAR_EVENTINF(EVENTINF_44); + CLEAR_EVENTINF(EVENTINF_45); + CLEAR_EVENTINF(EVENTINF_46); this->actionFunc = func_80B10584; } @@ -159,7 +159,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14D1; case 0x14D1: - if (gSaveContext.eventInf[4] & 0x80) { + if (CHECK_EVENTINF(EVENTINF_47)) { return 0x14E4; } @@ -179,7 +179,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14D3; case 0x14D2: - if (gSaveContext.eventInf[4] & 0x80) { + if (CHECK_EVENTINF(EVENTINF_47)) { return 0x14E5; } return 0x14D4; @@ -208,7 +208,7 @@ u16 func_80B0F8F8(EnGb2* this) { case 0x14DE: this->unk_26C |= 2; - gSaveContext.save.weekEventReg[54] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_54_80); return 0x14DF; case 0x14E1: @@ -226,7 +226,7 @@ u16 func_80B0F97C(EnGb2* this) { return 0x14F7; case 0x14F7: - gSaveContext.save.weekEventReg[76] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_76_80); this->unk_26C |= 2; return 0x14F8; @@ -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; @@ -259,7 +259,7 @@ s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { return false; case PLAYER_MASK_CAPTAIN: - if (!(gSaveContext.save.weekEventReg[80] & 0x40)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_80_40)) { this->unk_26E = 0x14EB; return false; } @@ -267,7 +267,7 @@ s32 func_80B0FA48(EnGb2* this, GlobalContext* globalCtx) { return true; } - if (!(gSaveContext.save.weekEventReg[80] & 0x20)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_80_20)) { this->unk_26E = 0x14EF; return false; } else { @@ -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,81 +341,81 @@ 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; - gSaveContext.eventInf[4] |= 0x80; +void func_80B0FEBC(EnGb2* this, PlayState* play) { + if ((play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING)) { + play->msgCtx.ocarinaMode = 4; + SET_EVENTINF(EVENTINF_47); 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; + CLEAR_EVENTINF(EVENTINF_47); this->unk_26C &= ~2; 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, PLAYER_CSMODE_7); this->actionFunc = func_80B11344; break; @@ -441,25 +441,25 @@ 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); + Interface_StartTimer(TIMER_ID_MINIGAME_1, 180); } this->actionFunc = func_80B10344; } else { @@ -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) { @@ -487,10 +487,10 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { if (this->unk_26C & 0x200) { if (this->unk_280 == 3) { this->unk_26C &= ~0x200; - gSaveContext.unk_3DD0[1] = 5; - func_800FE498(); - gSaveContext.eventInf[4] |= 0x40; - func_80B0FE7C(globalCtx); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; + Environment_StartTime(); + SET_EVENTINF(EVENTINF_46); + func_80B0FE7C(play); } else if (this->unk_280 == 2) { if (this->unk_26C & 0x400) { this->unk_280++; @@ -506,9 +506,9 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { } if (gSaveContext.save.playerData.health < 49) { - gSaveContext.unk_3DD0[1] = 5; - gSaveContext.eventInf[4] |= 0x40; - gSaveContext.eventInf[4] |= 0x20; + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; + SET_EVENTINF(EVENTINF_46); + SET_EVENTINF(EVENTINF_45); if ((this->unk_268 != NULL) && (this->unk_268->update == NULL)) { this->unk_268 = NULL; @@ -518,11 +518,11 @@ void func_80B10344(EnGb2* this, GlobalContext* globalCtx) { this->actor.child = NULL; } - func_80B0FE7C(globalCtx); - } else if (gSaveContext.unk_3DE0[1] == 0) { - gSaveContext.unk_3DD0[1] = 5; - gSaveContext.eventInf[4] |= 0x40; - gSaveContext.eventInf[4] |= 0x10; + func_80B0FE7C(play); + } else if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; + SET_EVENTINF(EVENTINF_46); + SET_EVENTINF(EVENTINF_44); if ((this->unk_268 != NULL) && (this->unk_268->update == NULL)) { this->unk_268 = NULL; @@ -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; @@ -564,28 +564,28 @@ void func_80B10634(EnGb2* this, GlobalContext* globalCtx) { } else { this->unk_26E = 0x14D1; this->unk_288 = 30; - gSaveContext.eventInf[4] &= (u8)~0x80; + CLEAR_EVENTINF(EVENTINF_47); this->actionFunc = func_80B0FEBC; } } 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, PLAYER_CSMODE_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,101 +614,102 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_40)) { sp24 = 5; } else { 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; + SET_WEEKEVENTREG(WEEKEVENTREG_54_40); } 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; switch (ENGB2_GET_7(&this->actor)) { case ENGB2_7_0: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; case ENGB2_7_1: ActorCutscene_Stop(this->unk_282[this->unk_290]); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; case ENGB2_7_2: ActorCutscene_Stop(this->unk_282[this->unk_290]); if (this->unk_26E == 0x14FB) { - Flags_SetSwitch(globalCtx, ENGB2_GET_7F8(&this->actor)); - Actor_MarkForDeath(&this->actor); - } else { - this->actor.draw = NULL; - this->unk_26C |= 0x100; - this->actor.flags &= ~ACTOR_FLAG_1; - this->actionFunc = func_80B111AC; + Flags_SetSwitch(play, ENGB2_GET_7F8(&this->actor)); + Actor_Kill(&this->actor); + return; } + + this->actor.draw = NULL; + this->unk_26C |= 0x100; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_80B111AC; break; } } } -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; + SET_WEEKEVENTREG(WEEKEVENTREG_80_40); } else if (this->unk_26E == 0x14EF) { - gSaveContext.save.weekEventReg[80] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_80_20); } this->unk_26C &= ~0x20; this->unk_290 = 0; @@ -718,19 +719,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 +746,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 +767,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 +779,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.curRoom.num == 1) { return; } - switch (globalCtx->roomCtx.currRoom.num) { + switch (play->roomCtx.curRoom.num) { case 2: index = 1; break; @@ -836,12 +837,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.curRoom.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 +854,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,34 +865,34 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (func_80B0F660(this, play)) { + Actor_Kill(&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)) { case ENGB2_7_0: - if (gSaveContext.save.weekEventReg[54] & 0x80) { - Actor_MarkForDeath(&this->actor); - } else if (gSaveContext.save.weekEventReg[52] & 0x20) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_80)) { + Actor_Kill(&this->actor); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + Actor_Kill(&this->actor); } - if (gSaveContext.save.entranceIndex == 0x9C10) { - func_800FE484(); + if (gSaveContext.save.entrance == ENTRANCE(GHOST_HUT, 1)) { + Environment_StopTime(); this->actionFunc = func_80B10240; break; } @@ -901,46 +901,46 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_2000000; - if (gSaveContext.eventInf[4] & 0x40) { - func_80B0F728(this, globalCtx); + if (CHECK_EVENTINF(EVENTINF_46)) { + 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)) { - Actor_MarkForDeath(&this->actor); + if ((play->curSpawn == 1) || CHECK_WEEKEVENTREG(WEEKEVENTREG_80_80)) { + Actor_Kill(&this->actor); return; } - if (Flags_GetSwitch(globalCtx, ENGB2_GET_7F8(thisx))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, ENGB2_GET_7F8(thisx))) { + Actor_Kill(&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))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, ENGB2_GET_7F8(thisx))) { + Actor_Kill(&this->actor); return; } - if (Flags_GetClear(globalCtx, 2) && Flags_GetClear(globalCtx, 3) && Flags_GetClear(globalCtx, 4) && - Flags_GetClear(globalCtx, 5)) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetClear(play, 2) && Flags_GetClear(play, 3) && Flags_GetClear(play, 4) && + Flags_GetClear(play, 5)) { + Actor_Kill(&this->actor); return; } - if (gSaveContext.save.weekEventReg[76] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_76_80)) { this->actor.draw = NULL; this->unk_26C |= 0x100; this->actor.flags &= ~ACTOR_FLAG_1; @@ -953,31 +953,31 @@ void EnGb2_Init(Actor* thisx, GlobalContext* globalCtx) { break; default: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } -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; @@ -992,7 +992,7 @@ 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 }; @@ -1001,30 +1001,30 @@ void EnGb2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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..ec3b379a1 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) @@ -38,6 +38,4 @@ typedef struct EnGb2 { /* 0x290 */ s16 unk_290; } EnGb2; // size = 0x294 -extern const ActorInit En_Gb2_InitVars; - #endif // Z_EN_GB2_H diff --git a/src/overlays/actors/ovl_En_Ge1/overlay.cfg b/src/overlays/actors/ovl_En_Ge1/overlay.cfg deleted file mode 100644 index ebd643e2a..000000000 --- a/src/overlays/actors/ovl_En_Ge1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ge1 -z_en_ge1.c 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..cbc8511b7 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -10,13 +10,12 @@ #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 = { +ActorInit En_Ge1_InitVars = { ACTOR_EN_GE1, ACTORCAT_NPC, FLAGS, @@ -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* thisx, Lights* lights, PlayState* play); +void EnGe1_Wait(EnGe1* this, PlayState* play); +void EnGe1_PerformCutsceneActions(EnGe1* this, PlayState* play); +s32 EnGe1_ValidatePictograph(PlayState* play, Actor* thisx); -#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_Kill(&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..5388a1186 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.h @@ -2,17 +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; - #endif // Z_EN_GE1_H diff --git a/src/overlays/actors/ovl_En_Ge2/overlay.cfg b/src/overlays/actors/ovl_En_Ge2/overlay.cfg deleted file mode 100644 index 965bfcf19..000000000 --- a/src/overlays/actors/ovl_En_Ge2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ge2 -z_en_ge2.c 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..4659c4aa9 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -10,24 +10,24 @@ #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 = { +ActorInit En_Ge2_InitVars = { ACTOR_EN_GE2, ACTORCAT_NPC, FLAGS, 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..0558166db 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.h @@ -5,14 +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; - #endif // Z_EN_GE2_H diff --git a/src/overlays/actors/ovl_En_Ge3/overlay.cfg b/src/overlays/actors/ovl_En_Ge3/overlay.cfg deleted file mode 100644 index 5eec23b4b..000000000 --- a/src/overlays/actors/ovl_En_Ge3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ge3 -z_en_ge3.c 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..1f680e9e8 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -10,13 +10,13 @@ #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 = { +ActorInit En_Ge3_InitVars = { ACTOR_EN_GE3, ACTORCAT_NPC, FLAGS, 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..909ed7599 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.h @@ -5,14 +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; - #endif // Z_EN_GE3_H diff --git a/src/overlays/actors/ovl_En_Geg/overlay.cfg b/src/overlays/actors/ovl_En_Geg/overlay.cfg deleted file mode 100644 index 412bb71c1..000000000 --- a/src/overlays/actors/ovl_En_Geg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Geg -z_en_geg.c 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 79e5a3480..1da6c1a61 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,28 +16,28 @@ #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 = { +ActorInit En_Geg_InitVars = { ACTOR_EN_GEG, ACTORCAT_NPC, FLAGS, @@ -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; @@ -354,7 +355,7 @@ s32 func_80BB1D64(EnGeg* this, GlobalContext* globalCtx) { sp40 = player->actor.world.pos; } else { sp40 = player->actor.world.pos; - sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp40.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; } sp34 = this->actor.world.pos; @@ -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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_35_40)) { + 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)) { - gSaveContext.save.weekEventReg[35] |= 0x40; + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state) && (this->unk_230 & 8)) { + SET_WEEKEVENTREG(WEEKEVENTREG_35_40); 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; @@ -655,18 +656,18 @@ void func_80BB2B1C(EnGeg* this, GlobalContext* globalCtx) { if (ActorCutscene_GetCurrentIndex() != this->unk_49C[4]) { if (ActorCutscene_GetCanPlayNext(this->unk_498)) { - gSaveContext.save.weekEventReg[37] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_37_08); if (this->actor.child != NULL) { - Actor_MarkForDeath(this->actor.child); + Actor_Kill(this->actor.child); } this->unk_230 |= 0x10; ActorCutscene_StartAndSetFlag(this->unk_498, &this->actor); this->unk_496 = 0xD68; - func_80151938(globalCtx, this->unk_496); - this->unk_248 = Object_GetIndex(&globalCtx->objectCtx, OBJECT_TAISOU); + 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,28 +796,28 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_61_01); if (getItemId == GI_MASK_DON_GERO) { this->unk_230 |= 0x40; } this->actionFunc = func_80BB32AC; } else { - Actor_PickUp(&this->actor, globalCtx, getItemId, 300.0f, 300.0f); + 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,13 +833,13 @@ 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); } if (ActorCutscene_GetCurrentIndex() != this->unk_49C[7]) { func_800AEF44(Effect_GetByIndex(this->unk_4DC)); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { Math_ApproachF(&this->actor.speedXZ, 10.0f, 0.2f, 1.0f); Actor_MoveWithGravity(&this->actor); @@ -847,66 +848,66 @@ 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; s32 sp34[] = { 0x3E, 0xF64 }; - if (gSaveContext.save.weekEventReg[61] & 1) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_61_01)) { + Actor_Kill(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 0.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_oF1d_map_Skel_011AC8, &object_oF1d_map_Anim_012DE0, - this->jointTable, this->morphTable, 18); + SkelAnime_InitFlex(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); + Actor_Kill(&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) { @@ -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(); @@ -976,7 +977,7 @@ void EnGeg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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; @@ -1033,35 +1034,35 @@ void EnGeg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } } -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); + 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); @@ -1071,18 +1072,18 @@ void func_80BB3CB4(EnGeg* this, GlobalContext* globalCtx) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 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..ea29fd6cf 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; @@ -46,6 +46,4 @@ typedef struct EnGeg { /* 0x4E4 */ Vec3f unk_4E4; } EnGeg; // size = 0x4F0 -extern const ActorInit En_Geg_InitVars; - #endif // Z_EN_GEG_H diff --git a/src/overlays/actors/ovl_En_Gg/overlay.cfg b/src/overlays/actors/ovl_En_Gg/overlay.cfg deleted file mode 100644 index 5c782de1b..000000000 --- a/src/overlays/actors/ovl_En_Gg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Gg -z_en_gg.c 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 2683e1296..a6c2a31ec 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -12,21 +12,21 @@ #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 = { +ActorInit En_Gg_InitVars = { ACTOR_EN_GG, ACTORCAT_NPC, FLAGS, @@ -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,20 +116,20 @@ 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; sp40 = player->actor.world.pos; - sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp40.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; sp34 = this->actor.world.pos; sp34.y += 70.0f; pitch = Math_Vec3f_Pitch(&sp34, &sp40); if ((this->actor.xzDistToPlayer < 250.0f) && (this->actor.xzDistToPlayer > 50.0f) && - (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (gSaveContext.save.weekEventReg[19] & 0x80))) { + (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80))) { Math_SmoothStepToS(&this->unk_2E8, pitch, 4, 0x2AA8, 1); } else { Math_SmoothStepToS(&this->unk_2E8, 0, 4, 0x2AA8, 1); @@ -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,109 +170,109 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_19_80); this->actionFunc = func_80B3556C; } else if ((this->unk_2E6 == 0) && ((this->actor.textId == 0xCED) || (this->actor.textId == 0xCEE))) { if (sp26 < (lastFrame - 1)) { this->skelAnime.playSpeed = 2.0f; } else { this->unk_2E6 = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_91_10) && (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); + Actor_DeactivateLens(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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80)) { + 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,25 +315,25 @@ 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: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; default: 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,44 +364,44 @@ 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) { - if (player->stateFlags2 & 0x8000000) { + if (player->stateFlags2 & PLAYER_STATE2_8000000) { this->unk_306 = 1; play_sound(NA_SE_SY_TRE_BOX_APPEAR); } - } else if (!(player->stateFlags2 & 0x8000000)) { + } else if (!(player->stateFlags2 & PLAYER_STATE2_8000000)) { this->unk_306 = 0; } - if ((player->transformation == PLAYER_FORM_HUMAN) && (globalCtx->msgCtx.ocarinaMode == 3) && - (globalCtx->msgCtx.unk1202E == 7)) { - if (!(gSaveContext.save.weekEventReg[19] & 0x80)) { - gSaveContext.save.weekEventReg[19] |= 0x80; + if ((player->transformation == PLAYER_FORM_HUMAN) && (play->msgCtx.ocarinaMode == 3) && + (play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_19_80); } this->unk_307 = true; } @@ -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,7 +507,7 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -526,11 +526,11 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + 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); - gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } Matrix_Pop(); @@ -550,21 +550,21 @@ void func_80B35C84(EnGgStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + 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); - gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } 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,7 +581,7 @@ void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { } if (phi_s4 > 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -603,23 +603,22 @@ void func_80B3610C(EnGgStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 150, 0, 255); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + 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); - gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } 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,33 +636,33 @@ 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; if (INV_CONTENT(ITEM_MASK_GORON) == ITEM_MASK_GORON) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= 0x400; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, + 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; - gSaveContext.save.weekEventReg[20] &= (u8)~8; - gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); this->actor.flags &= ~ACTOR_FLAG_80; this->unk_310 = this->actor.home.pos.y; this->unk_2DC = this->actor.cutscene; @@ -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.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { this->actor.flags |= ACTOR_FLAG_80; this->actor.flags |= ACTOR_FLAG_1; } else { @@ -691,50 +690,50 @@ void EnGg_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } - if (gSaveContext.save.weekEventReg[19] & 0x80) { - if (globalCtx->csCtx.state == 0) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80)) { + 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) && - ((gSaveContext.save.weekEventReg[19] & 0x80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_91_10) && + (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80) || CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_80) || (this->unk_308 == 1))) { - gSaveContext.save.weekEventReg[91] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_91_10); } - 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; @@ -744,7 +743,7 @@ s32 EnGg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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 }; @@ -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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_80)) { + 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..cb9f9e7cb 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,39 +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; - #endif // Z_EN_GG_H diff --git a/src/overlays/actors/ovl_En_Gg2/overlay.cfg b/src/overlays/actors/ovl_En_Gg2/overlay.cfg deleted file mode 100644 index 24b42b858..000000000 --- a/src/overlays/actors/ovl_En_Gg2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Gg2 -z_en_gg2.c 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 46f0b657c..6da3b1378 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -11,23 +11,23 @@ #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* play2); +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); -const ActorInit En_Gg2_InitVars = { +ActorInit En_Gg2_InitVars = { ACTOR_EN_GG2, ACTORCAT_NPC, FLAGS, @@ -74,14 +74,14 @@ 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; sp40 = player->actor.world.pos; - sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp40.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; sp34 = this->actor.world.pos; sp34.y += 70.0f; @@ -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,22 +209,22 @@ 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) { - gSaveContext.save.weekEventReg[20] |= 4; - gSaveContext.save.weekEventReg[20] &= (u8)~8; - gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - gSaveContext.save.weekEventReg[20] &= (u8)~4; - gSaveContext.save.weekEventReg[20] |= 8; - gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - gSaveContext.save.weekEventReg[20] &= (u8)~4; - gSaveContext.save.weekEventReg[20] &= (u8)~8; - gSaveContext.save.weekEventReg[20] |= 0x10; + if (play->sceneId == SCENE_11GORONNOSATO) { + SET_WEEKEVENTREG(WEEKEVENTREG_20_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); + } else if (play->sceneId == SCENE_17SETUGEN) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); + SET_WEEKEVENTREG(WEEKEVENTREG_20_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); + } else if (play->sceneId == SCENE_10YUKIYAMANOMURA) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); + SET_WEEKEVENTREG(WEEKEVENTREG_20_10); } if (this->unk_1D8 != NULL) { @@ -239,18 +239,18 @@ void func_80B3B294(EnGg2* this, GlobalContext* globalCtx) { this->unk_1DC++; } else { this->unk_2F1 = 1; - if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { - gSaveContext.save.weekEventReg[20] |= 4; - gSaveContext.save.weekEventReg[20] &= (u8)~8; - gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - gSaveContext.save.weekEventReg[20] &= (u8)~4; - gSaveContext.save.weekEventReg[20] |= 8; - gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - gSaveContext.save.weekEventReg[20] &= (u8)~4; - gSaveContext.save.weekEventReg[20] &= (u8)~8; - gSaveContext.save.weekEventReg[20] |= 0x10; + if (play->sceneId == SCENE_11GORONNOSATO) { + SET_WEEKEVENTREG(WEEKEVENTREG_20_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); + } else if (play->sceneId == SCENE_17SETUGEN) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); + SET_WEEKEVENTREG(WEEKEVENTREG_20_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); + } else if (play->sceneId == SCENE_10YUKIYAMANOMURA) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); + SET_WEEKEVENTREG(WEEKEVENTREG_20_10); } } } @@ -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,25 +351,25 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - if (gSaveContext.save.weekEventReg[91] & 0x10) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_91_10)) { + Actor_Kill(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= 0x400; - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, + 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,48 +380,48 @@ void EnGg2_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk_2EC = 20; this->unk_2EA = 0; - if (globalCtx->sceneNum == SCENE_11GORONNOSATO) { - gSaveContext.save.weekEventReg[20] &= (u8)~4; - gSaveContext.save.weekEventReg[20] &= (u8)~8; - gSaveContext.save.weekEventReg[20] &= (u8)~0x10; + if (play->sceneId == SCENE_11GORONNOSATO) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); this->unk_2EE = 0; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3AFB0; - } else if (globalCtx->sceneNum == SCENE_17SETUGEN) { - if ((gSaveContext.save.weekEventReg[20] & 4) && !(gSaveContext.save.weekEventReg[20] & 8) && - !(gSaveContext.save.weekEventReg[20] & 0x10)) { - gSaveContext.save.weekEventReg[20] &= (u8)~4; + } else if (play->sceneId == SCENE_17SETUGEN) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_04) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_20_08) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_20_10)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); this->unk_2EE = 8; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3B05C; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } - } else if (globalCtx->sceneNum == SCENE_10YUKIYAMANOMURA) { - if (!(gSaveContext.save.weekEventReg[20] & 4) && (gSaveContext.save.weekEventReg[20] & 8) && - !(gSaveContext.save.weekEventReg[20] & 0x10)) { - gSaveContext.save.weekEventReg[20] &= (u8)~8; + } else if (play->sceneId == SCENE_10YUKIYAMANOMURA) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_04) && CHECK_WEEKEVENTREG(WEEKEVENTREG_20_08) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_20_10)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); this->unk_2EE = 8; Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); this->actionFunc = func_80B3B05C; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else { - gSaveContext.save.weekEventReg[20] &= (u8)~4; - gSaveContext.save.weekEventReg[20] &= (u8)~8; - gSaveContext.save.weekEventReg[20] &= (u8)~0x10; - Actor_MarkForDeath(&this->actor); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); + Actor_Kill(&this->actor); } } -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.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { this->actor.flags |= ACTOR_FLAG_80; this->actor.flags |= ACTOR_FLAG_1; if ((this->unk_2EE == 5) && (this->unk_2EE == 7)) { @@ -432,27 +432,26 @@ 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.lensMaskSize == LENS_MASK_ACTIVE_SIZE) && ((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)) { @@ -467,7 +466,7 @@ s32 func_80B3BD44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p 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) { @@ -475,20 +474,20 @@ void func_80B3BDC0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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..f91310775 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h @@ -5,36 +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; - #endif // Z_EN_GG2_H diff --git a/src/overlays/actors/ovl_En_Giant/overlay.cfg b/src/overlays/actors/ovl_En_Giant/overlay.cfg deleted file mode 100644 index a56d149b7..000000000 --- a/src/overlays/actors/ovl_En_Giant/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Giant -z_en_giant.c 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 26dfcb756..dbd180359 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. @@ -72,7 +72,7 @@ typedef enum { /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER } GiantCsActionIndex; -const ActorInit En_Giant_InitVars = { +ActorInit En_Giant_InitVars = { ACTOR_EN_GIANT, ACTORCAT_NPC, FLAGS, @@ -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; } } @@ -110,7 +110,7 @@ s32 EnGiant_IsImprisoned(EnGiant* this) { case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: case GIANT_TYPE_SWAMP_CLOCK_TOWER_FAILURE: - if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA)) { + if (!CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA)) { return true; } break; @@ -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; @@ -183,8 +183,8 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { } if (GIANT_TYPE_IS_CLOCK_TOWER_SUCCESS(type)) { - if (!(gSaveContext.save.weekEventReg[25] & 2)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_25_02)) { + Actor_Kill(&this->actor); return; } @@ -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,13 +204,13 @@ 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; this->actor.gravity = 0.0f; if (EnGiant_IsImprisoned(this)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -220,7 +220,7 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { this->sfxId = 0xFFFF; if (GIANT_TYPE_IS_CHAMBER_OR_ENDING(type)) { - switch (gSaveContext.sceneSetupIndex) { + switch (gSaveContext.sceneLayer) { case 0: case 10: this->sfxId = NA_SE_EV_KYOJIN_GRATITUDE2 - SFX_FLAG; @@ -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,18 +467,17 @@ 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) { @@ -489,40 +485,39 @@ void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis } } -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_Mult(&this->headDrawMtxF, MTXMODE_NEW); - 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++, 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..9ce182a98 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; @@ -58,6 +58,4 @@ typedef struct EnGiant { /* 0x298 */ EnGiantActionFunc actionFunc; } EnGiant; // size = 0x29C -extern const ActorInit En_Giant_InitVars; - #endif // Z_EN_GIANT_H diff --git a/src/overlays/actors/ovl_En_Ginko_Man/overlay.cfg b/src/overlays/actors/ovl_En_Ginko_Man/overlay.cfg deleted file mode 100644 index 5d02f02dc..000000000 --- a/src/overlays/actors/ovl_En_Ginko_Man/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ginko_Man -z_en_ginko_man.c 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 300987214..88d55dc14 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,15 +22,15 @@ 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 = { +ActorInit En_Ginko_Man_InitVars = { ACTOR_EN_GINKO_MAN, ACTORCAT_NPC, FLAGS, @@ -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); - if (gSaveContext.save.weekEventReg[10] & 8) { - Message_StartTextbox(globalCtx, 0x44E, &this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, GINKO_ANIM_SITTING); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_10_08)) { + 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); + !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_40)) { + SET_WEEKEVENTREG(WEEKEVENTREG_59_40); + 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); + !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_59_80); + 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); + if ((this->previousBankValue < 5000) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_60_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_60_01); + 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); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_10_08)) { + 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); - } 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_RUPEE_BLUE, 500.0f, 100.0f); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_59_08)) { + 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)) { - if (!(gSaveContext.save.weekEventReg[10] & 8) && (this->curTextId == 0x45B)) { +void EnGinkoMan_BankAward2(EnGinkoMan* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_10_08) && (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); + SET_WEEKEVENTREG(WEEKEVENTREG_10_08); + 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 (!(gSaveContext.save.weekEventReg[59] & 8)) { - gSaveContext.save.weekEventReg[59] |= 8; + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_59_08)) { + SET_WEEKEVENTREG(WEEKEVENTREG_59_08); } EnGinkoMan_SetupIdle(this); } } else { - func_800B85E0(&this->actor, globalCtx, 500.0f, EXCH_ITEM_MINUS1); + func_800B85E0(&this->actor, play, 500.0f, PLAYER_IA_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) { @@ -648,22 +660,22 @@ s32 EnGinkoMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d 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..b8a19d0f3 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; @@ -24,8 +24,6 @@ typedef struct EnGinkoMan { /* 0x264 */ s16 animTimer; } EnGinkoMan; // size = 0x268 -extern const ActorInit En_Ginko_Man_InitVars; - #define GINKOMAN_CHOICE_DEPOSIT 0 #define GINKOMAN_CHOICE_WITHDRAWL 1 #define GINKOMAN_CHOICE_CANCEL 2 @@ -34,12 +32,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/overlay.cfg b/src/overlays/actors/ovl_En_GirlA/overlay.cfg deleted file mode 100644 index 2083a3377..000000000 --- a/src/overlays/actors/ovl_En_GirlA/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_GirlA -z_en_girla.c 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 45fe0c132..65df46284 100644 --- a/src/overlays/actors/ovl_En_GirlA/z_en_girla.c +++ b/src/overlays/actors/ovl_En_GirlA/z_en_girla.c @@ -10,48 +10,48 @@ #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 = { +ActorInit En_GirlA_InitVars = { ACTOR_EN_GIRLA, ACTORCAT_PROP, FLAGS, @@ -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,18 +156,18 @@ 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 || - if (params >= SI_MAX && params < SI_POTION_RED_1) { - Actor_MarkForDeath(&this->actor); + if ((params >= SI_MAX) && (params < SI_POTION_RED_1)) { + Actor_Kill(&this->actor); 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); + Actor_Kill(&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) { - if (!(gSaveContext.save.weekEventReg[53] & 8)) { +s32 EnGirlA_CanBuyPotionBlue(PlayState* play, EnGirlA* this) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_53_08)) { return CANBUY_RESULT_CANNOT_GET_NOW; } - if (!Interface_HasEmptyBottle()) { + if (!Inventory_HasEmptyBottle()) { return CANBUY_RESULT_NEED_EMPTY_BOTTLE; } - if (!(gSaveContext.save.weekEventReg[53] & 0x10)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_53_10)) { 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_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..f61b50b5a 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,67 +48,65 @@ 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; - /* * Shopkeeper Common Defines */ @@ -127,8 +125,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/overlay.cfg b/src/overlays/actors/ovl_En_Gk/overlay.cfg deleted file mode 100644 index 15b8f08e6..000000000 --- a/src/overlays/actors/ovl_En_Gk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Gk -z_en_gk.c 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 ae9dd8553..6f2f3c09c 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -11,29 +11,29 @@ #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 = { +ActorInit En_Gk_InitVars = { ACTOR_EN_GK, ACTORCAT_NPC, FLAGS, @@ -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,12 +115,12 @@ 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->sceneId == SCENE_17SETUGEN2) { if (player->transformation == PLAYER_FORM_GORON) { - if (!(gSaveContext.save.weekEventReg[40] & 0x80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_40_80)) { switch (this->unk_31C) { case 0xE7A: return 0xE7B; @@ -133,7 +133,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { case 0xE7E: return 0xE7F; case 0xE7F: - gSaveContext.save.weekEventReg[40] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_40_80); this->unk_1E4 |= 1; return 0xE80; default: @@ -143,7 +143,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 1; return 0xE81; } - } else if (!(gSaveContext.save.weekEventReg[41] & 1)) { + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_01)) { switch (this->unk_31C) { case 0xE82: return 0xE83; @@ -154,7 +154,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { case 0xE7E: return 0xE7F; case 0xE7F: - gSaveContext.save.weekEventReg[41] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_41_01); this->unk_1E4 |= 1; return 0xE80; default: @@ -164,14 +164,14 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { this->unk_1E4 |= 1; return 0xE81; } - } else if (globalCtx->sceneNum == SCENE_GORONRACE) { + } else if (play->sceneId == SCENE_GORONRACE) { if (player->transformation == PLAYER_FORM_GORON) { - if (!(gSaveContext.save.weekEventReg[41] & 4)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_04)) { if (this->unk_31C == 0xE88) { - if (!(gSaveContext.save.weekEventReg[41] & 8) || Interface_HasEmptyBottle()) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_08) || Inventory_HasEmptyBottle()) { return 0xE89; } - gSaveContext.save.weekEventReg[41] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_41_04); this->unk_1E4 |= 1; return 0xE94; } @@ -179,10 +179,10 @@ 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_08) || Inventory_HasEmptyBottle()) { return 0xE89; } - gSaveContext.save.weekEventReg[41] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_41_04); this->unk_1E4 |= 1; return 0xE94; } @@ -193,12 +193,12 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { return 0xE98; } - if (!(gSaveContext.save.weekEventReg[41] & 2)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_02)) { switch (this->unk_31C) { case 0xE85: return 0xE86; case 0xE86: - gSaveContext.save.weekEventReg[41] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_41_02); this->unk_1E4 |= 1; return 0xE87; default: @@ -216,7 +216,7 @@ u16 func_80B50410(EnGk* this, GlobalContext* globalCtx) { u16 func_80B50710(EnGk* this) { switch (this->unk_31C) { case 0xE8E: - gSaveContext.save.weekEventReg[41] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_41_04); this->unk_1E4 &= ~0x10; this->unk_1E4 |= 1; return 0xE8F; @@ -225,7 +225,7 @@ u16 func_80B50710(EnGk* this) { return 0xE8B; case 0xE8B: - gSaveContext.save.weekEventReg[41] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_41_04); this->unk_1E4 |= 0x10; this->unk_1E4 |= 1; return 0xE8C; @@ -233,33 +233,33 @@ 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) { + if (player->stateFlags2 & PLAYER_STATE2_8000000) { this->unk_1E4 |= 0x40; play_sound(NA_SE_SY_TRE_BOX_APPEAR); } - } else if (!(player->stateFlags2 & 0x8000000)) { + } else if (!(player->stateFlags2 & PLAYER_STATE2_8000000)) { 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, - Rand_S16Offset(15, 15), phi_s1, 0); - EffectSsDtBubble_SpawnCustomColor(globalCtx, &this->unk_2F4, &this->unk_30C, &sp4C, &D_80B533A0, &D_80B533A4, - Rand_S16Offset(15, 15), phi_s1, 0); + EffectSsDtBubble_SpawnCustomColor(play, &this->unk_2E8, &this->unk_300, &sp4C, &D_80B533A0, &D_80B533A4, + Rand_S16Offset(15, 15), phi_s1, false); + EffectSsDtBubble_SpawnCustomColor(play, &this->unk_2F4, &this->unk_30C, &sp4C, &D_80B533A0, &D_80B533A4, + Rand_S16Offset(15, 15), phi_s1, false); } -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: @@ -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; @@ -442,7 +442,7 @@ s32 func_80B5100C(EnGk* this, GlobalContext* globalCtx) { this->unk_324 = CLAMP(this->unk_324, -0x1C70, 0x1C70); sp40 = player->actor.world.pos; - sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp40.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; sp34 = this->actor.world.pos; sp34.y += 70.0f; @@ -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))) { - gSaveContext.save.weekEventReg[40] |= 0x40; + if (Flags_GetSwitch(play, ENGK_GET_3F00(&this->actor))) { + SET_WEEKEVENTREG(WEEKEVENTREG_40_40); 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 != ENTRANCE(GORON_RACETRACK, 1))) { + 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,11 @@ 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; + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); } else { this->actionFunc = func_80B51760; } @@ -736,23 +732,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)) { - 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 +758,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 +769,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 +786,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 +798,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; @@ -814,7 +810,7 @@ void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { if (func_80B50C78(this, this->path, this->unk_1EC)) { if (this->unk_1EC >= (this->path->count - 1)) { ActorCutscene_Stop(this->unk_318); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->unk_1EC++; } @@ -832,8 +828,8 @@ void func_80B51EA4(EnGk* this, GlobalContext* globalCtx) { func_80B50954(this); } -void func_80B51FD0(EnGk* this, GlobalContext* globalCtx) { - if (!(gSaveContext.save.weekEventReg[22] & 4)) { +void func_80B51FD0(EnGk* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { if (this->unk_1E4 & 2) { func_801A4748(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); } else { @@ -842,19 +838,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)) { - gSaveContext.save.weekEventReg[24] |= 0x80; + if (!func_80B50854(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + SET_WEEKEVENTREG(WEEKEVENTREG_24_80); 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 +859,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,34 +868,34 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_22_04); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GOLON_SIT_IMT); this->unk_350 = 0x4000; @@ -908,38 +903,38 @@ 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) { + if (CHECK_EVENTINF(EVENTINF_11)) { this->unk_31C = 0xE90; this->actionFunc = func_80B52430; } else { this->unk_31C = 0xE93; this->actionFunc = func_80B52430; } - Message_StartTextbox(globalCtx, this->unk_31C, &this->actor); + 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,40 +952,40 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_41_08)) { sp24 = 0x93; } else { 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; + SET_WEEKEVENTREG(WEEKEVENTREG_41_08); } 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)) { - gSaveContext.save.weekEventReg[22] |= 4; + if ((this->unk_1E4 & 0x80) && (play->csCtx.frames == 250)) { + SET_WEEKEVENTREG(WEEKEVENTREG_22_04); } this->unk_354 = Math_SinS(this->unk_350) * 0.006f * 0.06f; @@ -1002,15 +997,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,83 +1017,83 @@ 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_MarkForDeath(&this->actor); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); + if (play->sceneId == SCENE_17SETUGEN2) { + if (Flags_GetSwitch(play, ENGK_GET_3F00(&this->actor))) { + Actor_Kill(&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) { - if (gSaveContext.save.weekEventReg[33] & 0x80) { - if (gSaveContext.save.entranceIndex == 0xD010) { + } else if (play->sceneId == SCENE_GORONRACE) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + 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; } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else if (ENGK_GET_F(&this->actor) == ENGK_F_2) { - if (!(gSaveContext.save.weekEventReg[22] & 4)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { this->actionFunc = func_80B51FD0; this->actor.draw = NULL; this->actor.flags |= ACTOR_FLAG_10; this->actor.flags &= ~ACTOR_FLAG_1; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } - } else if (!(gSaveContext.save.weekEventReg[22] & 4)) { + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { this->unk_2E4 = 0; this->unk_318 = this->actor.cutscene; this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_2000000; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + 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); + ((ENGK_GET_F(&this->actor) == ENGK_F_0) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04))) { + 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 }; @@ -1160,7 +1155,7 @@ void EnGk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -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; @@ -1228,40 +1223,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)) { + if ((ENGK_GET_F(&this->actor) == ENGK_F_0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { 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 +1272,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..bebe6c6c9 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,41 +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; - #endif // Z_EN_GK_H diff --git a/src/overlays/actors/ovl_En_Gm/overlay.cfg b/src/overlays/actors/ovl_En_Gm/overlay.cfg deleted file mode 100644 index d39cd1d30..000000000 --- a/src/overlays/actors/ovl_En_Gm/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Gm -z_en_gm.c 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 07699e7de..01146c0cf 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -12,13 +12,13 @@ #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 u8 D_80951820[] = { /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x13B - 0x005), @@ -80,7 +80,7 @@ static u8 D_80951820[] = { /* 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), + /* 0x140 */ SCHEDULE_CMD_CHECK_FLAG_L(WEEKEVENTREG_50_01, 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), @@ -155,7 +155,7 @@ static s32 D_80951C2C[] = { 0x0E295A2D, 0x000A0C10 }; static s32 D_80951C34[] = { 0x0E29622D, 0x000A0C10 }; -const ActorInit En_Gm_InitVars = { +ActorInit En_Gm_InitVars = { ACTOR_EN_GM, ACTORCAT_NPC, FLAGS, @@ -209,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 }, @@ -225,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; @@ -251,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) { @@ -283,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) { @@ -301,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; @@ -317,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; } } @@ -325,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.curRoom.num) && (play->roomCtx.unk31 == 0)) { + this->unk_260 = play->roomCtx.curRoom.num; + this->unk_262 = SubS_GetObjectIndex(OBJECT_IN2, play); this->actor.draw = NULL; this->unk_3FC = 1; } @@ -339,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; @@ -353,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) { @@ -451,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; @@ -463,10 +463,10 @@ s32 func_8094E52C(EnGm* this, GlobalContext* globalCtx) { } case 2: - if (!(gSaveContext.save.weekEventReg[86] & 0x40) && (this->unk_3E0 == 2)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_86_40) && (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; @@ -474,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; @@ -491,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; @@ -502,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; @@ -534,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; } @@ -545,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; @@ -565,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; @@ -576,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; @@ -626,20 +625,20 @@ 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; switch (this->unk_3E0) { case 0: - if ((gSaveContext.save.weekEventReg[50] & 1) || (gSaveContext.save.weekEventReg[51] & 0x80) || - (gSaveContext.save.weekEventReg[75] & 2)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_50_01) || CHECK_WEEKEVENTREG(WEEKEVENTREG_51_80) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_75_02)) { ret = true; 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++; @@ -669,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++; @@ -680,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; @@ -729,25 +728,25 @@ 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)) { + if ((this->unk_258 == 5) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_50_01) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_51_80) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_75_02)) { this->unk_3A4 |= 0x20; } else if ((this->unk_258 != 1) && (this->unk_258 != 5) && (this->unk_258 != 7)) { this->unk_3A4 |= 0x20; } - if ((this->unk_258 == 3) && (gSaveContext.save.weekEventReg[75] & 1)) { + if ((this->unk_258 == 3) && CHECK_WEEKEVENTREG(WEEKEVENTREG_75_01)) { this->unk_3A4 &= ~0x20; } @@ -758,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->sceneId == SCENE_MILK_BAR) && (gSaveContext.sceneLayer == 2)) { + func_8094E054(this, play, 0); this->unk_258 = 255; } this->unk_259 = 255; @@ -772,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->sceneId == SCENE_MILK_BAR) { this->unk_400 = 0; } this->unk_3F8 = 0; @@ -780,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: @@ -793,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; } @@ -856,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->talkActor) && ((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 { @@ -873,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_Translate(this->unk_3B0, 0.0f, 0.0f, MTXMODE_APPLY); - this->unk_3F0 = sp28; + 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) { + if (player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_400)) { 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; } @@ -956,21 +956,22 @@ 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.flags & ACTORCTX_FLAG_5) && + Animation_OnFrame(&this->skelAnime, 20.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_HANKO); } return false; } -s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 arg3, s16 arg4) { +s32 func_8094F7D0(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput, u8 arg3, s16 arg4) { u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -979,18 +980,18 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 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->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80951A0C[scheduleOutput->result]); } if ((actor != NULL) && (actor->update != NULL)) { - 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); @@ -1000,7 +1001,7 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 return ret; } -s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_8094F904(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENGM_GET_FF(&this->actor); EnDoor* door; @@ -1010,16 +1011,16 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; - door = func_8094DF90(globalCtx, arg2->result); + this->timePath = NULL; + door = func_8094DF90(play, scheduleOutput->result); - if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); + if (D_80951A0C[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp55, D_80951A0C[scheduleOutput->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - 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); @@ -1033,12 +1034,12 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { this->unk_261 = 75; } - this->unk_3B8 = arg2->time1 - arg2->time0; - this->unk_3BA = sp56 - arg2->time0; + this->unk_3B8 = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_3BA = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; - func_8094E054(this, globalCtx, 7); + func_8094E054(this, play, 7); this->actor.gravity = 0.0f; ret = true; } @@ -1046,63 +1047,65 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_8094FAC4(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENGM_GET_FF(&this->actor); - s32 pad; + u16 tmp; + s16 pad; s32 ret = false; - this->unk_234 = NULL; - if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); + 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->time0; + phi_v1 = scheduleOutput->time0; } - if (arg2->time1 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->unk_248 = arg2->time1 - 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, ScheduleResult* arg2) { +s32 func_8094FCC4(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951D90 = { 64.0f, 0.0f, -122.0f }; s32 ret = false; - if (func_8094F7D0(this, 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); - this->skelAnime.moveFlags = 0x10; + func_8094E054(this, play, 9); + this->skelAnime.moveFlags = ANIM_FLAG_NOMOVE; } this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; @@ -1111,11 +1114,11 @@ s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, ScheduleResult* 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; @@ -1124,16 +1127,17 @@ s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, ScheduleResult* 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)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_86_20)) { this->unk_3C8 = 2; this->unk_3CA = 2; this->unk_3CC = 8; @@ -1145,7 +1149,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_8094FF04(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951D9C = { 64.0f, 0.0f, -122.0f }; u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; @@ -1154,16 +1158,16 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; - if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); + 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) { @@ -1172,12 +1176,12 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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); - this->skelAnime.moveFlags = 0x10; + func_8094E054(this, play, 9); + this->skelAnime.moveFlags = ANIM_FLAG_NOMOVE; } this->unk_400 = 0; this->unk_3A4 |= 0x100; @@ -1187,7 +1191,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80950088(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80950088(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DA8 = { 278.0f, 0.0f, 223.0f }; static Vec3s D_80951DB4 = { 0x0000, 0xC000, 0x0000 }; s32 pad; @@ -1198,11 +1202,11 @@ s32 func_80950088(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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, ScheduleResult* arg2) { +s32 func_80950120(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DBC = { -525.0f, 214.0f, 515.0f }; static Vec3s D_80951DC8 = { 0x0000, 0x38E0, 0x0000 }; s32 pad; @@ -1213,11 +1217,11 @@ s32 func_80950120(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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, ScheduleResult* arg2) { +s32 func_809501B8(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80951DD0 = { -334.0f, 225.0f, 903.0f }; static Vec3s D_80951DDC = { 0x0000, 0x7FFF, 0x0000 }; s32 pad; @@ -1234,11 +1238,11 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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, ScheduleResult* arg2) { +s32 func_80950280(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 phi_v1; this->actor.flags |= ACTOR_FLAG_1; @@ -1249,33 +1253,33 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { this->unk_3CC = 8; this->unk_3B4 = 40.0f; - switch (arg2->result) { + 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: @@ -1290,7 +1294,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { case 18: case 19: case 20: - phi_v1 = func_8094F904(this, globalCtx, arg2); + phi_v1 = func_8094F904(this, play, scheduleOutput); break; case 21: @@ -1303,7 +1307,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { case 28: case 29: case 30: - phi_v1 = func_8094FAC4(this, globalCtx, arg2); + phi_v1 = func_8094FAC4(this, play, scheduleOutput); break; default: @@ -1314,7 +1318,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return phi_v1; } -s32 func_80950388(EnGm* this, GlobalContext* globalCtx) { +s32 func_80950388(EnGm* this, PlayState* play) { Vec3f sp2C; Vec3f sp20; @@ -1327,34 +1331,34 @@ 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, }; s32 pad; - if ((gSaveContext.save.weekEventReg[50] & 1) || (gSaveContext.save.weekEventReg[51] & 0x80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_50_01) || CHECK_WEEKEVENTREG(WEEKEVENTREG_51_80)) { if (this->unk_400 == 0) { this->unk_3C8 = 1; this->unk_3CA = 1; this->unk_3CC = 8; this->unk_400 = 1; - func_8094E054(this, globalCtx, 3); + func_8094E054(this, play, 3); } return false; } @@ -1369,17 +1373,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); @@ -1388,7 +1392,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); @@ -1398,17 +1402,17 @@ 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)) { + !(player->stateFlags1 & PLAYER_STATE1_40)) { if (DECR(this->unk_3B8) == 0) { if (al == this->unk_268) { this->unk_268 = toto; @@ -1432,19 +1436,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 (!SubS_InCsMode(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; @@ -1459,7 +1463,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); } @@ -1468,77 +1472,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 (SubS_InCsMode(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 (SubS_InCsMode(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: @@ -1553,7 +1559,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: @@ -1566,20 +1572,20 @@ 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) { - ScheduleResult sp20; +void func_80950CDC(EnGm* this, PlayState* play) { + ScheduleOutput sp20; - this->unk_3C4 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); - if (!Schedule_RunScript(globalCtx, D_80951820, &sp20) || - ((this->unk_258 != sp20.result) && !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.result = 0; @@ -1588,19 +1594,19 @@ void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; } this->unk_258 = sp20.result; - this->unk_268 = func_8094F074(this, globalCtx); - func_80950C24(this, globalCtx); + 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); @@ -1619,26 +1625,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)) { @@ -1655,21 +1661,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)) { - Actor_MarkForDeath(&this->actor); + if (func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_GM)) { + Actor_Kill(&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; @@ -1677,52 +1682,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, EXCH_ITEM_NONE, this->unk_3A4 & 7); + func_8013C964(&this->actor, play, this->unk_3B4, 30.0f, PLAYER_IA_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) { @@ -1751,7 +1756,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]; @@ -1763,13 +1768,13 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec 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_MultVec3f(&gZeroVec3f, &sp30); @@ -1777,7 +1782,7 @@ void EnGm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnGm_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnGm* this = THIS; s32 overrideRot = true; s32 stepRot = false; @@ -1818,22 +1823,22 @@ void EnGm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this } } -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..3bed5335a 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -5,77 +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; - #endif // Z_EN_GM_H diff --git a/src/overlays/actors/ovl_En_Go/overlay.cfg b/src/overlays/actors/ovl_En_Go/overlay.cfg deleted file mode 100644 index 3ab4530a4..000000000 --- a/src/overlays/actors/ovl_En_Go/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Go -z_en_go.c 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 27c307777..e1250dbc6 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -5,6 +5,7 @@ */ #include "z_en_go.h" +#include "z64quake.h" #include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/object_hakugin_demo/object_hakugin_demo.h" #include "objects/object_taisou/object_taisou.h" @@ -14,20 +15,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, @@ -77,7 +78,7 @@ static s32 D_80A163EC[4] = { 0x100060E, 0xE040C12, 0x100E0E05, 0xC121000 }; static s32 D_80A163FC[4] = { 0x100060E, 0xE060C12, 0x100E0E07, 0xC121000 }; static s32 D_80A1640C[2] = { 0xE023A0C, 0x12100000 }; -const ActorInit En_Go_InitVars = { +ActorInit En_Go_InitVars = { ACTOR_EN_GO, ACTORCAT_NPC, FLAGS, @@ -186,17 +187,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 }, @@ -233,15 +234,15 @@ EnGoStruct* func_80A10FD0(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f 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,7 +250,7 @@ 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; } @@ -260,23 +261,22 @@ void func_80A11144(EnGoStruct* ptr, GlobalContext* globalCtx) { 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_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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_Pop(); - if (globalCtx->state.gfxCtx) {} + 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) { @@ -299,9 +299,9 @@ void func_80A1143C(EnGoStruct* ptr, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32 arg4 } } -void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { - static TexturePtr D_80A16644[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, +void func_80A115B4(EnGoStruct* ptr, PlayState* play) { + static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; static Color_RGBA8 D_80A16664[] = { { 255, 255, 255, 0 }, @@ -317,15 +317,15 @@ 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_Push(); @@ -339,19 +339,18 @@ void func_80A115B4(EnGoStruct* ptr, GlobalContext* globalCtx) { 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_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80A16644[(s32)(temp * 7.0f)])); - gSPDisplayList(POLY_XLU_DISP++, object_oF1d_map_DL_014D00); + 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(sDustTextures[(s32)(temp * 7.0f)])); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); Matrix_Pop(); } - if (globalCtx->state.gfxCtx) {} + if (play->state.gfxCtx) {} } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #ifdef NON_MATCHING @@ -450,13 +449,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) { @@ -473,7 +472,7 @@ void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* ar 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); } @@ -482,10 +481,10 @@ void func_80A11EC0(EnGoStruct* ptr, GlobalContext* globalCtx, Gfx* arg2, Gfx* ar } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #else -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); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Go/func_80A11EC0.s") #endif @@ -515,31 +514,32 @@ 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)) { + if ((player->transformation == PLAYER_FORM_GORON) && (player->stateFlags3 & PLAYER_STATE3_2000000)) { return false; } 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)) || + (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04) && (play->sceneId == SCENE_16GORON_HOUSE) && + (gSaveContext.sceneLayer == 0) && (this->unk_3EC == 0) && (play->csCtx.currentCsIndex == 1))) { ret = true; } return ret; @@ -567,7 +567,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); @@ -581,21 +581,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); @@ -609,10 +609,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); @@ -621,43 +621,43 @@ 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 (!(player->stateFlags2 & PLAYER_STATE2_4000)) { if (this->unk_3C6 != 0) { this->unk_3C6--; } } 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; } @@ -682,7 +682,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; @@ -709,10 +709,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->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneLayer == 1) && + (play->csCtx.currentCsIndex == 0)) { if (this->unk_3F0 == 0) { this->actor.flags &= ~ACTOR_FLAG_1; this->unk_394 = 255; @@ -732,7 +732,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; @@ -746,17 +746,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); @@ -778,7 +778,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; @@ -792,11 +792,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; @@ -812,25 +812,25 @@ 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; } - if (player->stateFlags1 & 0x40) { + if (player->stateFlags1 & PLAYER_STATE1_40) { if (this->unk_392 != temp) { switch (temp) { case 0xE1A: @@ -841,7 +841,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; @@ -857,7 +857,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; } @@ -868,18 +868,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; @@ -912,17 +912,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; @@ -938,34 +938,34 @@ 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)) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else if ((player->transformation != PLAYER_FORM_GORON) || (ABS_ALT(temp_v1) >= 0x1C70) || - (gSaveContext.save.weekEventReg[21] & 4) || (gSaveContext.save.weekEventReg[21] & 8)) { + CHECK_WEEKEVENTREG(WEEKEVENTREG_21_04) || CHECK_WEEKEVENTREG(WEEKEVENTREG_21_08)) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else { SubS_UpdateFlags(&this->unk_390, 4, 7); } } -void func_80A133A8(EnGo* this, GlobalContext* globalCtx) { - if (gSaveContext.save.weekEventReg[21] & 8) { +void func_80A133A8(EnGo* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_21_08)) { SubS_UpdateFlags(&this->unk_390, 3, 7); } else { SubS_UpdateFlags(&this->unk_390, 4, 7); } } -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) && @@ -987,8 +987,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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_18_80) || (play->actorCtx.flags & ACTORCTX_FLAG_0) || arg2) { this->colliderSphere.dim.modelSphere.radius = 300; } else { this->colliderSphere.dim.modelSphere.radius = 380; @@ -1046,46 +1046,46 @@ 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 speed, s16 verticalMag, s16 countdown) { + s16 quakeIndex = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); - Quake_SetCountdown(sp26, arg3); - Quake_SetSpeed(sp26, arg1); - Quake_SetQuakeValues(sp26, arg2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetQuakeValues(quakeIndex, verticalMag, 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, 27767, 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_Push(); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + 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_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_Pop(); } @@ -1105,8 +1105,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; @@ -1146,7 +1146,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; @@ -1175,17 +1175,17 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_88_40); } break; 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; @@ -1197,20 +1197,20 @@ s32 func_80A13B1C(EnGo* this, GlobalContext* globalCtx) { this->unk_3C0++; if (this->unk_3C0 >= 65) { switch (player->transformation) { - case 4: - gSaveContext.save.weekEventReg[88] |= 0x80; + case PLAYER_FORM_HUMAN: + SET_WEEKEVENTREG(WEEKEVENTREG_88_80); break; - case 1: - gSaveContext.save.weekEventReg[89] |= 4; + case PLAYER_FORM_GORON: + SET_WEEKEVENTREG(WEEKEVENTREG_89_04); break; - case 2: - gSaveContext.save.weekEventReg[89] |= 2; + case PLAYER_FORM_ZORA: + SET_WEEKEVENTREG(WEEKEVENTREG_89_02); break; - case 3: - gSaveContext.save.weekEventReg[89] |= 1; + case PLAYER_FORM_DEKU: + SET_WEEKEVENTREG(WEEKEVENTREG_89_01); break; } ret = true; @@ -1222,7 +1222,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; @@ -1237,7 +1237,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: @@ -1246,11 +1246,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++; } @@ -1271,7 +1271,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; @@ -1281,7 +1281,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); @@ -1295,11 +1295,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; @@ -1311,11 +1311,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; @@ -1325,7 +1325,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; @@ -1344,8 +1344,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; @@ -1358,8 +1358,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; @@ -1373,69 +1373,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)) && - (gSaveContext.save.weekEventReg[33] & 0x80)) { - func_80A14018(this, globalCtx); +void func_80A14430(EnGo* this, PlayState* play) { + if (((gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 0)) || + (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 2))) && + (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80))) { + func_80A14018(this, play); this->actionFunc = func_80A149B0; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&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); + Actor_Kill(&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)) || - !(gSaveContext.save.weekEventReg[21] & 8))) { - this->actor.child = func_80A13400(this, globalCtx); + (((play->sceneId == SCENE_10YUKIYAMANOMURA2) && (gSaveContext.sceneLayer == 1) && + (play->csCtx.currentCsIndex == 0)) || + !CHECK_WEEKEVENTREG(WEEKEVENTREG_21_08))) { + 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) { - if (!(gSaveContext.save.weekEventReg[22] & 4)) { - func_80A14324(this, globalCtx); +void func_80A14668(EnGo* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { + 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; @@ -1449,27 +1451,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; @@ -1477,56 +1479,56 @@ 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: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; } } } -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) { @@ -1540,11 +1542,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; } @@ -1564,12 +1566,12 @@ 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; this->actor.shape.yOffset = 0.0f; - } else if ((this->unk_3EC != 0) && (gSaveContext.save.weekEventReg[22] & 4)) { + } else if ((this->unk_3EC != 0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { this->actor.scale.x = this->unk_3A4 - (Math_SinS(this->unk_3AE) * 0.001f); this->actor.scale.y = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; this->actor.scale.z = (Math_SinS(this->unk_3AE) * 0.001f) + this->unk_3A4; @@ -1588,18 +1590,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)) || @@ -1608,13 +1610,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) { @@ -1624,17 +1626,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, }; @@ -1653,13 +1655,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; @@ -1674,7 +1676,7 @@ void func_80A14FC8(EnGo* this, GlobalContext* globalCtx) { case 5: case 6: - func_80A141D4(this, globalCtx); + func_80A141D4(this, play); break; } } @@ -1682,13 +1684,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; @@ -1699,13 +1701,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: @@ -1729,7 +1731,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); @@ -1749,13 +1751,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; @@ -1773,16 +1775,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); @@ -1801,7 +1803,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)); @@ -1813,8 +1815,8 @@ void func_80A153FC(EnGo* this, GlobalContext* globalCtx) { } } -s32* func_80A15684(EnGo* this, GlobalContext* globalCtx) { - static s32 D_80A16704[] = { +s32* func_80A15684(EnGo* this, PlayState* play) { + static s32* D_80A16704[] = { D_80A16100, D_80A16164, }; @@ -1858,18 +1860,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; } @@ -1887,38 +1889,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)) { @@ -1927,28 +1929,28 @@ void EnGo_Update(Actor* thisx, GlobalContext* globalCtx) { } else { phi_f0 = this->colliderCylinder.dim.radius + 40; } - func_8013C964(&this->actor, globalCtx, phi_f0, 20.0f, EXCH_ITEM_NONE, this->unk_390 & 7); + func_8013C964(&this->actor, play, phi_f0, 20.0f, PLAYER_IA_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, EXCH_ITEM_NONE, this->unk_390 & 7); + func_8013C964(&this->actor, play, phi_f0, 20.0f, PLAYER_IA_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_Translate(this->actor.world.pos.x, this->actor.world.pos.y + this->actor.shape.yOffset, this->actor.world.pos.z, MTXMODE_NEW); @@ -1965,13 +1967,13 @@ void func_80A15B80(EnGo* this, GlobalContext* globalCtx) { 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; @@ -2007,7 +2009,7 @@ 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 stepRot; @@ -2057,31 +2059,30 @@ void EnGo_TransfromLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this } } -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_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..fd4876430 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,61 +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; - #endif // Z_EN_GO_H diff --git a/src/overlays/actors/ovl_En_Goroiwa/overlay.cfg b/src/overlays/actors/ovl_En_Goroiwa/overlay.cfg deleted file mode 100644 index 0f4bb5a32..000000000 --- a/src/overlays/actors/ovl_En_Goroiwa/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Goroiwa -z_en_goroiwa.c 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 f17a75f6a..98d27f735 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -5,6 +5,7 @@ */ #include "z_en_goroiwa.h" +#include "z64quake.h" #include "objects/object_goroiwa/object_goroiwa.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -12,27 +13,27 @@ #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 = { +ActorInit En_Goroiwa_InitVars = { ACTOR_EN_GOROIWA, ACTORCAT_PROP, FLAGS, @@ -67,7 +68,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -144,12 +145,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 +183,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 +254,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 +295,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 +323,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 +344,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 +434,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,10 +451,11 @@ 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); - Quake_SetSpeed(sp72, 0x4350); - Quake_SetQuakeValues(sp72, 3, 0, 0, 0); - Quake_SetCountdown(sp72, 7); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); } this->unk_1C4 = 0.0f; @@ -469,8 +471,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 +480,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 +502,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 +513,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 +529,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; @@ -578,7 +579,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 +600,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 +623,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 +644,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 +701,7 @@ void func_80940090(EnGoroiwa* this, GlobalContext* globalCtx) { phi_s1 = D_80942E0C[sp120][0]; phi_s3 = 1; phi_f22 = 0.8f; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -720,7 +720,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,18 +728,18 @@ 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); } } } -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; @@ -779,7 +779,7 @@ void func_80940588(GlobalContext* globalCtx, Vec3f* arg1, Gfx* arg2[], Color_RGB phi_s7 = arg2[0]; phi_fp = -0x190; spC8 = 1; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -801,20 +801,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); } } } -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; @@ -856,7 +856,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA if ((i & 3) == 1) { phi_s1 = arg2[1]; phi_s2 = -0x154; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -864,7 +864,7 @@ void func_80940A1C(GlobalContext* globalCtx, Vec3f* arg1, Gfx** arg2, Color_RGBA } else { phi_s1 = arg2[0]; phi_s2 = -0x190; - if (Rand_Next() > 0) { + if ((s32)Rand_Next() > 0) { phi_s0 = 0x21; } else { phi_s0 = 0x41; @@ -872,19 +872,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; @@ -909,7 +909,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); } @@ -917,7 +917,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; @@ -937,21 +937,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; @@ -962,15 +962,15 @@ 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); + Actor_Kill(&this->actor); return; } if (sp2C->count < 2) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -981,22 +981,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; @@ -1006,18 +1006,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; @@ -1075,9 +1075,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))) || @@ -1087,12 +1087,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; } } @@ -1103,7 +1103,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; @@ -1115,7 +1115,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, @@ -1127,24 +1127,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 ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { + if (!func_8094156C(this, play)) { + if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & PLAYER_STATE3_80000)) { 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 { @@ -1158,7 +1158,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); @@ -1178,8 +1178,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) && @@ -1223,7 +1223,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)) { @@ -1243,8 +1243,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 { @@ -1260,12 +1260,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 ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + if (func_8094156C(this, play) == 0) { + if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & PLAYER_STATE3_80000)) { + 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; @@ -1288,17 +1288,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 ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & 0x80000)) { - func_800B8D50(globalCtx, &this->actor, 2.0f, this->actor.yawTowardsPlayer, 0.0f, 0); + if (func_8094156C(this, play) == 0) { + if ((this->collider.base.atFlags & AT_HIT) && !(player->stateFlags3 & PLAYER_STATE3_80000)) { + 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; @@ -1312,7 +1312,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; @@ -1346,7 +1346,7 @@ 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_RotateZYX(ptr->unk_1C, ptr->unk_1E, ptr->unk_20, MTXMODE_NEW); @@ -1374,7 +1374,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); } } @@ -1409,7 +1409,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; @@ -1418,14 +1418,14 @@ void func_80942604(EnGoroiwa* this, GlobalContext* globalCtx) { if (this->unk_1C8 > 0) { this->unk_1C8--; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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; @@ -1434,7 +1434,8 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { u32 temp_v0_2; CollisionPoly* tmp; - if (!(player->stateFlags1 & (0x30000000 | 0x80 | 0x40))) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000))) { if (this->unk_1CC > 0) { this->unk_1CC--; } @@ -1452,7 +1453,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)) { @@ -1460,7 +1461,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; @@ -1473,26 +1474,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)) { @@ -1507,7 +1508,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); @@ -1515,21 +1516,21 @@ void EnGoroiwa_Update(Actor* thisx, GlobalContext* globalCtx) { func_8093E938(this); if ((this->unk_1E5 & 1) && (this->unk_1CC <= 0) && - (!(player->stateFlags3 & 0x2000000) || (player->transformation != PLAYER_FORM_GORON) || + (!(player->stateFlags3 & PLAYER_STATE3_2000000) || (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; } @@ -1542,7 +1543,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; @@ -1568,12 +1569,12 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { 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); @@ -1583,17 +1584,17 @@ void func_80942B1C(EnGoroiwa* this, GlobalContext* globalCtx) { 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, @@ -1603,8 +1604,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..e672355e5 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,33 +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; - #endif // Z_EN_GOROIWA_H diff --git a/src/overlays/actors/ovl_En_Grasshopper/overlay.cfg b/src/overlays/actors/ovl_En_Grasshopper/overlay.cfg deleted file mode 100644 index a5fa8bb0a..000000000 --- a/src/overlays/actors/ovl_En_Grasshopper/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Grasshopper -z_en_grasshopper.c 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..eb7948ffb 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -5,54 +5,139 @@ */ #include "z_en_grasshopper.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_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 = { -static DamageTable D_809A8CDC = { - /* Deku Nut */ DMG_ENTRY(1, 0xF), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xE), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(0, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xF), - /* Deku spin */ DMG_ENTRY(1, 0xF), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(2, 0xF), - /* UNK_DMG_0x12 */ DMG_ENTRY(1, 0xF), - /* Zora barrier */ DMG_ENTRY(1, 0xF), - /* 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, 0xE), +void EnGrasshopper_ChangeAnim(EnGrasshopper* this, s32 animIndex); +void EnGrasshopper_RaiseTail(EnGrasshopper* this); +void EnGrasshopper_LowerTail(EnGrasshopper* this); +void EnGrasshopper_DecideAction(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupFly(EnGrasshopper* this); +void EnGrasshopper_Fly(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_RoamInCircles(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupBank(EnGrasshopper* this); +void EnGrasshopper_Bank(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupBounced(EnGrasshopper* this); +void EnGrasshopper_Bounced(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupApproachPlayer(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_ApproachPlayer(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupAttack(EnGrasshopper* this); +void EnGrasshopper_Attack(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupWaitAfterAttack(EnGrasshopper* this); +void EnGrasshopper_WaitAfterAttack(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_Damaged(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_Dead(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_SetupFall(EnGrasshopper* this); +void EnGrasshopper_Fall(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_InitializeEffect(EnGrasshopper* this, Vec3f* pos); +void EnGrasshopper_UpdateEffects(EnGrasshopper* this, PlayState* play); +void EnGrasshopper_DrawEffects(EnGrasshopper* this, PlayState* play); + +typedef enum { + /* 0 */ EN_GRASSHOPPER_ACTION_FLY, + /* 1 */ EN_GRASSHOPPER_ACTION_ROAM_IN_CIRCLES, + /* 2 */ EN_GRASSHOPPER_ACTION_BANK, + /* 3 */ EN_GRASSHOPPER_ACTION_BOUNCED, + /* 4 */ EN_GRASSHOPPER_ACTION_DECIDE_ACTION, + /* 5 */ EN_GRASSHOPPER_ACTION_APPROACH_PLAYER, + /* 6 */ EN_GRASSHOPPER_ACTION_ATTACK, + /* 7 */ EN_GRASSHOPPER_ACTION_WAIT_AFTER_ATTACK, + /* 8 */ EN_GRASSHOPPER_ACTION_DAMAGED, + /* 9 */ EN_GRASSHOPPER_ACTION_DEAD, + /* 10 */ EN_GRASSHOPPER_ACTION_FALL, +} EnGrasshopperAction; + +typedef enum { + /* 0 */ EN_GRASSHOPPER_DECISION_ATTACK, + /* 1 */ EN_GRASSHOPPER_DECISION_FLY, + /* 2 */ EN_GRASSHOPPER_DECISION_ROAM_IN_CIRCLES, // Never used in the final game +} EnGrasshopperNextAction; + +typedef enum { + /* 0 */ EN_GRASSHOPPER_BANK_STATE_BANKING, + /* 1 */ EN_GRASSHOPPER_BANK_STATE_DONE, +} EnGrasshopperBankState; + +typedef enum { + /* 0 */ EN_GRASSHOPPER_ANIM_RAISE_TAIL, + /* 1 */ EN_GRASSHOPPER_ANIM_LOWER_TAIL, + /* 2 */ EN_GRASSHOPPER_ANIM_FLY, + /* 3 */ EN_GRASSHOPPER_ANIM_ATTACK, + /* 4 */ EN_GRASSHOPPER_ANIM_HOVER, + /* 5 */ EN_GRASSHOPPER_ANIM_DAMAGE, + /* 6 */ EN_GRASSHOPPER_ANIM_DEAD, + /* 7 */ EN_GRASSHOPPER_ANIM_FALL, +} EnGrasshopperAnim; + +static s32 sOccupiedIndices[] = { + false, false, false, false, false, }; -const ActorInit En_Grasshopper_InitVars = { +static s8 sLimbIndexToShadowBodyPartsIndex[DRAGONFLY_LIMB_MAX] = { + -1, -1, 0, 1, 2, 3, 4, 5, -1, -1, 6, 7, -1, 8, 9, -1, 10, 11, -1, 12, 13, -1, -1, -1, +}; + +static s8 sParentBodyParts[DRAGONFLY_LIMB_MAX] = { + -1, -1, -1, 0, 1, 2, 3, -1, -1, -1, -1, 6, -1, -1, 8, -1, -1, 10, -1, -1, 12, -1, -1, -1, +}; + +static u8 sShadowSizes[DRAGONFLY_LIMB_MAX] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +typedef enum { + /* 0x0 */ EN_GRASSHOPPER_DMGEFF_IMMUNE, // Deals no damage + /* 0x2 */ EN_GRASSHOPPER_DMGEFF_FIRE = 0x2, // Damages and sets the Dragonfly on fire + /* 0x3 */ EN_GRASSHOPPER_DMGEFF_FREEZE, // Damages and freezes the Dragonfly in ice + /* 0x4 */ EN_GRASSHOPPER_DMGEFF_LIGHT_ORB, // Damages and surrounds the Dragonfly with light orbs + /* 0xE */ EN_GRASSHOPPER_DMGEFF_HOOK = 0xE, // If hit by the Hookshot, it pulls the Dragonfly towards the player + /* 0xF */ EN_GRASSHOPPER_DMGEFF_NONE, // Deals regular damage with no extra effect +} EnDragonflyDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Deku Stick */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Explosives */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Hookshot */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_HOOK), + /* Goron punch */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_GRASSHOPPER_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_GRASSHOPPER_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_GRASSHOPPER_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_GRASSHOPPER_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Zora barrier */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Normal shield */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_GRASSHOPPER_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_GRASSHOPPER_DMGEFF_HOOK), +}; + +ActorInit En_Grasshopper_InitVars = { ACTOR_EN_GRASSHOPPER, ACTORCAT_ENEMY, FLAGS, @@ -64,92 +149,996 @@ const ActorInit En_Grasshopper_InitVars = { (ActorFunc)EnGrasshopper_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[2] = { -static ColliderJntSphElementInit D_809A8D1C[2] = { +static ColliderJntSphElementInit sJntSphElementsInit[2] = { { - { ELEMTYPE_UNK3, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, - { 7, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK3, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, + { DRAGONFLY_LIMB_THORAX, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x07, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 6, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x07, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { DRAGONFLY_LIMB_TAIL_TIP, { { 0, 0, 0 }, 0 }, 0 }, }, }; -// 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, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT2, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_1, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -#endif +void EnGrasshopper_Init(Actor* thisx, PlayState* play) { + EnGrasshopper* this = THIS; + s32 i; -extern DamageTable D_809A8CDC; -extern ColliderJntSphElementInit D_809A8D1C[2]; -extern ColliderJntSphInit D_809A8D64; + this->actor.hintId = TATL_HINT_ID_DRAGONFLY; + this->actor.targetMode = 4; + this->actor.colChkInfo.mass = 60; + this->actor.colChkInfo.health = 2; -extern UNK_TYPE D_06000F9C; + Collider_InitAndSetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements[0].dim.modelSphere.radius = 1; + this->collider.elements[0].dim.scale = 22.0f; + this->collider.elements[1].dim.modelSphere.radius = 1; + this->collider.elements[1].dim.scale = 16.0f; + this->collider.elements[1].dim.modelSphere.center.x = 1000; + this->collider.elements[0].dim.modelSphere.center.x = this->collider.elements[0].dim.modelSphere.center.y = + this->collider.elements[0].dim.modelSphere.center.z = this->collider.elements[1].dim.modelSphere.center.y = + this->collider.elements[1].dim.modelSphere.center.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/EnGrasshopper_Init.s") + this->actor.flags |= ACTOR_FLAG_200; + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 1.0f); + this->actor.colChkInfo.damageTable = &sDamageTable; + Math_Vec3f_Copy(&this->flyingHomePos, &this->actor.home.pos); + this->action = EN_GRASSHOPPER_ACTION_FLY; + this->index = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/EnGrasshopper_Destroy.s") + for (i = 0; i < ARRAY_COUNT(sOccupiedIndices); i++) { + if (!sOccupiedIndices[i]) { + this->index = i; + sOccupiedIndices[i] = true; + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6524.s") + // Deciding a random index like this if all indices are occupied causes a bug in EnGrasshopper_Destroy. + if (this->index < 0) { + this->index = Rand_ZeroFloat(4.99f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A65D8.s") + SkelAnime_Init(play, &this->skelAnime, &gDragonflySkel, &gDragonflyFlyAnim, this->jointTable, this->morphTable, + DRAGONFLY_LIMB_MAX); + this->type = EN_GRASSHOPPER_GET_TYPE(&this->actor); + if (this->type < EN_GRASSHOPPER_TYPE_UNUSED_NORMAL) { + this->type = EN_GRASSHOPPER_TYPE_NORMAL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6628.s") + if (this->type != EN_GRASSHOPPER_TYPE_GROWS_WHEN_SPAWNED) { + this->dragonflyScale = 0.01f; + } else { + this->dragonflyScale = 0.0f; + Actor_SetScale(&this->actor, 0.0f); + this->actor.world.rot.y = this->actor.yawTowardsPlayer; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + Math_Vec3f_Copy(&this->flyingHomePos, &this->actor.world.pos); + this->flyingHomePos.y += 90.0f; + this->collider.elements[0].dim.modelSphere.radius = this->collider.elements[1].dim.modelSphere.radius = + this->type; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6668.s") + this->baseFlyHeight = randPlusMinusPoint5Scaled(50.0f) + this->flyingHomePos.y; + EnGrasshopper_SetupFly(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6754.s") +void EnGrasshopper_Destroy(Actor* thisx, PlayState* play) { + EnGrasshopper* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A67A4.s") + Collider_DestroyJntSph(play, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6B6C.s") + //! @bug If the dragonfly selected a random index in EnGrasshopper_Init (because all indices were occupied), + //! then two dragonflies will have the same index. When one of those dragonflies sharing an index is destroyed, + //! it will mark the index as unoccupied, when it still occupied by at least one dragonfly. + sOccupiedIndices[this->index] = false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6E18.s") +static AnimationHeader* sAnimations[] = { + &gDragonflyRaiseTailAnim, // EN_GRASSHOPPER_ANIM_RAISE_TAIL + &gDragonflyLowerTailAnim, // EN_GRASSHOPPER_ANIM_LOWER_TAIL + &gDragonflyFlyAnim, // EN_GRASSHOPPER_ANIM_FLY + &gDragonflyAttackAnim, // EN_GRASSHOPPER_ANIM_ATTACK + &gDragonflyHoverAnim, // EN_GRASSHOPPER_ANIM_HOVER + &gDragonflyDamageAnim, // EN_GRASSHOPPER_ANIM_DAMAGE + &gDragonflyDeadAnim, // EN_GRASSHOPPER_ANIM_DEAD + &gDragonflyFallAnim, // EN_GRASSHOPPER_ANIM_FALL +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6E74.s") +static u8 sAnimationModes[] = { + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_RAISE_TAIL + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_LOWER_TAIL + ANIMMODE_LOOP, // EN_GRASSHOPPER_ANIM_FLY + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_ATTACK + ANIMMODE_LOOP, // EN_GRASSHOPPER_ANIM_HOVER + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_DAMAGE + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_DEAD + ANIMMODE_ONCE, // EN_GRASSHOPPER_ANIM_FALL +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A6F8C.s") +void EnGrasshopper_ChangeAnim(EnGrasshopper* this, s32 animIndex) { + f32 morphFrames; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A700C.s") + this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); + morphFrames = 0.0f; + if ((animIndex == EN_GRASSHOPPER_ANIM_ATTACK) || (animIndex == EN_GRASSHOPPER_ANIM_HOVER) || + (animIndex == EN_GRASSHOPPER_ANIM_DAMAGE)) { + morphFrames = -3.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7134.s") + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, sAnimationModes[animIndex], + morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A71CC.s") +void EnGrasshopper_RaiseTail(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_RAISE_TAIL); + if (this->decision != EN_GRASSHOPPER_DECISION_ROAM_IN_CIRCLES) { + this->decision = EN_GRASSHOPPER_DECISION_FLY; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7494.s") + this->action = EN_GRASSHOPPER_ACTION_DECIDE_ACTION; + this->actionFunc = EnGrasshopper_DecideAction; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A753C.s") +void EnGrasshopper_LowerTail(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_LOWER_TAIL); + this->action = EN_GRASSHOPPER_ACTION_DECIDE_ACTION; + this->decision = EN_GRASSHOPPER_DECISION_ATTACK; + this->actionFunc = EnGrasshopper_DecideAction; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7844.s") +void EnGrasshopper_DecideAction(EnGrasshopper* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A78EC.s") + if (curFrame >= this->endFrame) { + if (this->decision == EN_GRASSHOPPER_DECISION_ATTACK) { + EnGrasshopper_SetupAttack(this); + } else { + Math_Vec3f_Copy(&this->flyingHomePos, &this->actor.world.pos); + this->flyingHomePos.y = this->actor.floorHeight + 90.0f; + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_FLY); + if (this->decision != EN_GRASSHOPPER_DECISION_ROAM_IN_CIRCLES) { + if (Player_GetMask(play) == PLAYER_MASK_STONE) { + EnGrasshopper_SetupFly(this); + } else { + EnGrasshopper_SetupApproachPlayer(this, play); + } + } else { + this->timer = 0; + this->action = EN_GRASSHOPPER_ACTION_ROAM_IN_CIRCLES; + this->decision = EN_GRASSHOPPER_DECISION_ATTACK; + this->waitTimer = this->timer; + this->actionFunc = EnGrasshopper_RoamInCircles; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A797C.s") +void EnGrasshopper_SetupFly(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_FLY); + this->baseFlyHeight = randPlusMinusPoint5Scaled(50.0f) + this->flyingHomePos.y; + this->action = EN_GRASSHOPPER_ACTION_FLY; + this->actionFunc = EnGrasshopper_Fly; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7A8C.s") +void EnGrasshopper_Fly(EnGrasshopper* this, PlayState* play) { + f32 diffX; + f32 diffZ; + f32 targetSpeed; + Vec3f collisionCheckPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7AE4.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + diffX = this->flyingHomePos.x - this->actor.world.pos.x; + diffZ = this->flyingHomePos.z - this->actor.world.pos.z; + if ((this->type != EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM) && + (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { + this->bobPhase += 0xAF0; + this->targetPosY = (Math_SinS(this->bobPhase) * 10.0f) + this->baseFlyHeight; + Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); + collisionCheckPos.x = (Math_SinS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.x; + collisionCheckPos.y = this->actor.world.pos.y; + collisionCheckPos.z = (Math_CosS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7BBC.s") + if (this->collider.elements[0].info.ocElemFlags & OCELEM_HIT) { + this->shouldTurn = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7C98.s") + if (BgCheck_SphVsFirstPoly(&play->colCtx, &collisionCheckPos, 10.0f)) { + this->shouldTurn = true; + } else { + this->shouldTurn = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A7CE0.s") + //! @bug Unreachable code. To get here, the type must NOT be EN_GRASSHOPPER_TYPE_WOODFALL + if (this->type == EN_GRASSHOPPER_TYPE_WOODFALL) { + if (sqrtf(SQ(this->actor.world.pos.x) + SQ(this->actor.world.pos.z)) < 600.0f) { + this->shouldTurn = true; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A8044.s") + if (this->shouldTurn) { + this->baseFlyHeight = randPlusMinusPoint5Scaled(50.0f) + this->flyingHomePos.y; + this->targetRot.y = Math_Atan2S(diffX, diffZ); + this->timer = Rand_S16Offset(30, 30); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/EnGrasshopper_Update.s") + if ((Player_GetMask(play) != PLAYER_MASK_STONE) && !CHECK_EVENTINF(EVENTINF_41) && !this->shouldTurn && + (this->actor.xzDistToPlayer < 200.0f)) { + EnGrasshopper_SetupApproachPlayer(this, play); + } else { + Math_SmoothStepToS(&this->actor.world.rot.z, this->targetRot.z, 5, 0x3E8, 5); + this->targetRot.z *= 0.8f; + if (this->waitTimer != 0) { + Math_ApproachZeroF(&this->actor.speedXZ, 0.2f, 0.5f); + } else { + this->targetRot.z = (this->actor.world.rot.y - this->targetRot.y) * 0.2f; + targetSpeed = (this->index * 0.1f) + 4.0f; + Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.7f); + Math_ApproachF(&this->rotationalVelocity, 2000.0f, 1.0f, 50.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, 5, this->rotationalVelocity, 5); + if (this->timer == 0) { + if (Rand_ZeroFloat(1.0f) < 0.3f) { + this->waitTimer = Rand_S16Offset(10, 10); + this->rotationalVelocity = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A847C.s") + this->targetRot.y = Math_Atan2S(diffX, diffZ); + this->timer = Rand_S16Offset(30, 70); + this->baseFlyHeight = randPlusMinusPoint5Scaled(50.0f) + this->flyingHomePos.y; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/EnGrasshopper_Draw.s") +/** + * Unused in the final game. Makes the dragonfly roam the area in a very wide circular arc. + */ +void EnGrasshopper_RoamInCircles(EnGrasshopper* this, PlayState* play) { + f32 diffX; + f32 diffZ; + f32 targetSpeed; + s16 rotationSpeed; + s32 pad; + Vec3f collisionCheckPos; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A8870.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + if (Player_GetMask(play) == PLAYER_MASK_STONE) { + EnGrasshopper_SetupFly(this); + } else { + diffX = player->actor.world.pos.x - this->actor.world.pos.x; + diffZ = player->actor.world.pos.z - this->actor.world.pos.z; + this->bobPhase += 0xAF0; + this->targetPosY = player->actor.world.pos.y + 60.0f; + this->baseFlyHeight = Math_SinS(this->bobPhase) * 10.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A8924.s") + if (this->timer == 0) { + this->baseFlyHeight = randPlusMinusPoint5Scaled(10.0f); + this->timer = Rand_S16Offset(30, 30); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Grasshopper/func_809A8A64.s") + Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); + collisionCheckPos.x = (Math_SinS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.x; + collisionCheckPos.y = this->actor.world.pos.y; + collisionCheckPos.z = (Math_CosS(this->actor.shape.rot.y) * 100.0f) + this->actor.world.pos.z; + + if ((this->actor.bgCheckFlags & 8) || BgCheck_SphVsFirstPoly(&play->colCtx, &collisionCheckPos, 10.0f)) { + EnGrasshopper_SetupBank(this); + } else if (player->stateFlags1 & PLAYER_STATE1_8000000) { + this->collider.elements[0].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); + EnGrasshopper_RaiseTail(this); + } else if (this->collider.base.atFlags & AT_BOUNCED) { + this->collider.elements[0].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + EnGrasshopper_SetupBounced(this); + } else { + this->targetRot.z = (this->actor.world.rot.y - this->targetRot.y) * 0.2f; + Math_SmoothStepToS(&this->actor.world.rot.z, this->targetRot.z, 5, 0x3E8, 5); + rotationSpeed = this->index + 70; + targetSpeed = (this->index * 0.05f) + 4.0f; + this->targetRot.y = Math_Atan2S(diffX, diffZ); + Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.8f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, rotationSpeed, 0xFA0, 0xA); + } + } +} + +/** + * Unused in the final game. + */ +void EnGrasshopper_SetupBank(EnGrasshopper* this) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + this->targetBankRot.y = this->actor.world.rot.y + 0x8000; + this->action = EN_GRASSHOPPER_ACTION_BANK; + this->bankState = EN_GRASSHOPPER_BANK_STATE_BANKING; + this->actor.speedXZ = 2.0f; + this->actionFunc = EnGrasshopper_Bank; +} + +/** + * Unused in the final game. Makes the dragonfly perform a wide banking turn on its side, then + * it flies forward for 100 frames. + */ +void EnGrasshopper_Bank(EnGrasshopper* this, PlayState* play) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + switch (this->bankState) { + case EN_GRASSHOPPER_BANK_STATE_BANKING: + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetBankRot.y, 0x64, 0x3E8, 0x3E8); + Math_SmoothStepToS(&this->actor.world.rot.z, 0x4000, 0x64, 0x1F40, 0xBB8); + if (fabsf(this->actor.world.rot.y - (f32)this->targetBankRot.y) < 10.0f) { + this->postBankTimer = 100; + this->bankState = EN_GRASSHOPPER_BANK_STATE_DONE; + } + break; + + case EN_GRASSHOPPER_BANK_STATE_DONE: + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 0x64, 0x1F40, 0xBB8); + if (this->postBankTimer == 0) { + this->timer = 0; + this->action = EN_GRASSHOPPER_ACTION_ROAM_IN_CIRCLES; + this->decision = EN_GRASSHOPPER_DECISION_ATTACK; + this->waitTimer = this->timer; + this->actionFunc = EnGrasshopper_RoamInCircles; + } + break; + } +} + +/** + * Unused in the final game. + */ +void EnGrasshopper_SetupBounced(EnGrasshopper* this) { + this->targetRot.y = -this->actor.yawTowardsPlayer; + this->timer = Rand_S16Offset(30, 30); + this->targetRot.z = (this->actor.world.rot.y - this->targetRot.y) * 0.2f; + this->action = EN_GRASSHOPPER_ACTION_BOUNCED; + this->actionFunc = EnGrasshopper_Bounced; +} + +/** + * Unused in the final game. Makes the dragonfly rotate away from the player, then go + * back to roaming in circles. + */ +void EnGrasshopper_Bounced(EnGrasshopper* this, PlayState* play) { + f32 targetSpeed; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + targetSpeed = (this->index * 0.05f) + 7.0f; + Math_ApproachF(&this->actor.speedXZ, targetSpeed, 0.4f, 0.8f); + Math_SmoothStepToS(&this->actor.world.rot.z, this->targetRot.z, 5, 0x3E8, 5); + this->targetRot.z *= 0.8f; + Math_SmoothStepToS(&this->actor.world.rot.y, this->targetRot.y, 5, this->rotationalVelocity, 5); + if (this->timer == 0) { + this->collider.elements[0].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); + this->timer = 0; + this->action = EN_GRASSHOPPER_ACTION_ROAM_IN_CIRCLES; + this->waitTimer = this->timer; + this->actionFunc = EnGrasshopper_RoamInCircles; + } +} + +void EnGrasshopper_SetupApproachPlayer(EnGrasshopper* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + + this->timer = 50; + this->action = EN_GRASSHOPPER_ACTION_APPROACH_PLAYER; + this->approachSpeed = 0.0f; + this->targetApproachPos.x = (Math_SinS(player->actor.shape.rot.y) * 130.0f) + player->actor.world.pos.x; + this->targetApproachPos.z = (Math_CosS(player->actor.shape.rot.y) * 130.0f) + player->actor.world.pos.z; + this->actionFunc = EnGrasshopper_ApproachPlayer; +} + +/** + * Approaches the player in preparation for an attack. It will also attack if the timer reaches 0. + */ +void EnGrasshopper_ApproachPlayer(EnGrasshopper* this, PlayState* play) { + Player* player = GET_PLAYER(play); + WaterBox* waterBox; + Vec3f splashPos; + + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_FLY - SFX_FLAG); + this->bobPhase += 0xAF0; + this->targetApproachPos.y = (Math_SinS(this->bobPhase) * 10.0f) + (player->actor.world.pos.y + 120.0f); + + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 5, 0x3E8, 5); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.shape.rot.y, 0xA, 0xFA0, 0xA); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xFA0, 0xA); + Math_ApproachF(&this->actor.world.pos.x, this->targetApproachPos.x, 0.3f, this->approachSpeed); + Math_ApproachF(&this->actor.world.pos.y, this->targetApproachPos.y, 0.1f, this->approachSpeed); + Math_ApproachF(&this->actor.world.pos.z, this->targetApproachPos.z, 0.3f, this->approachSpeed); + Math_ApproachF(&this->approachSpeed, 7.0f, 0.3f, 1.0f); + + if (WaterBox_GetSurface1(play, &play->colCtx, this->tailTipPos.x, this->tailTipPos.z, &this->waterSurface, + &waterBox)) { + if (this->tailTipPos.y < this->waterSurface) { + if ((this->splashCount < 3) || !(play->gameplayFrames % 8)) { + this->splashCount++; + Math_Vec3f_Copy(&splashPos, &this->tailTipPos); + splashPos.x += randPlusMinusPoint5Scaled(20.0f); + splashPos.z += randPlusMinusPoint5Scaled(20.0f); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, (((s32)Rand_ZeroOne() * 100) + 400)); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + } + } else { + this->splashCount = 0; + } + } + + if ((this->timer == 0) || ((fabsf(this->targetApproachPos.x - this->actor.world.pos.x) <= 10.0f) && + (fabsf(this->targetApproachPos.y - this->actor.world.pos.y) <= 20.0f) && + (fabsf(this->targetApproachPos.z - this->actor.world.pos.z) <= 10.0f))) { + EnGrasshopper_LowerTail(this); + } +} + +void EnGrasshopper_SetupAttack(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_ATTACK); + this->approachSpeed = 0.0f; + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xFA0, 0xA); + this->actor.speedXZ = 3.0f; + this->baseFlyHeight = this->actor.world.pos.y; + this->collider.elements[0].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + this->collider.elements[1].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_ATTACK); + this->action = EN_GRASSHOPPER_ACTION_ATTACK; + this->actionFunc = EnGrasshopper_Attack; +} + +void EnGrasshopper_Attack(EnGrasshopper* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 curFrame = this->skelAnime.curFrame; + Vec3f hitPos; + Vec3f diff; + f32 playerToHitPosDist; + s32 i; + WaterBox* waterBox; + Vec3f splashPos; + + for (i = 0; i < 6; i++) { + EnGrasshopper_InitializeEffect(this, &this->tailTipPos); + } + + if (WaterBox_GetSurface1(play, &play->colCtx, this->tailTipPos.x, this->tailTipPos.z, &this->waterSurface, + &waterBox)) { + if (this->tailTipPos.y < this->waterSurface) { + if ((this->splashCount < 3) || !(play->gameplayFrames % 8)) { + this->splashCount++; + Math_Vec3f_Copy(&splashPos, &this->tailTipPos); + splashPos.x += randPlusMinusPoint5Scaled(20.0f); + splashPos.z += randPlusMinusPoint5Scaled(20.0f); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, ((s32)Rand_ZeroOne() * 100) + 400); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + } + } else { + this->splashCount = 0; + } + } + + this->bobPhase += 0xAF0; + this->targetApproachPos.y = (Math_SinS(this->bobPhase) * 10.0f) + (player->actor.world.pos.y + 60.0f); + + hitPos.x = this->collider.elements[1].info.bumper.hitPos.x; + hitPos.y = this->collider.elements[1].info.bumper.hitPos.y; + hitPos.z = this->collider.elements[1].info.bumper.hitPos.z; + diff.x = hitPos.x - player->actor.world.pos.x; + diff.y = hitPos.y - player->actor.world.pos.y; + diff.z = hitPos.z - player->actor.world.pos.z; + playerToHitPosDist = sqrtf(SQXYZ(diff)); + + if ((this->collider.base.atFlags & AT_BOUNCED) || + ((player->stateFlags1 & PLAYER_STATE1_400000) && (playerToHitPosDist <= 60.0f) && + ((s16)((player->actor.shape.rot.y - this->actor.shape.rot.y) + 0x8000) < 0x2000) && + ((s16)((player->actor.shape.rot.y - this->actor.shape.rot.y) + 0x8000) > -0x2000))) { + this->collider.elements[1].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + } + + Math_ApproachF(&this->actor.world.pos.y, this->targetApproachPos.y, 0.1f, this->approachSpeed); + Math_ApproachF(&this->approachSpeed, 10.0f, 0.1f, 1.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xFA0, 0xA); + if (curFrame >= this->endFrame) { + EnGrasshopper_SetupWaitAfterAttack(this); + } +} + +void EnGrasshopper_SetupWaitAfterAttack(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_HOVER); + this->bobPhase += 0xAF0; + this->targetPosY = (Math_SinS(this->bobPhase) * 10.0f) + this->baseFlyHeight; + Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); + this->action = EN_GRASSHOPPER_ACTION_WAIT_AFTER_ATTACK; + this->waitTimer = 20; + this->actor.speedXZ = 0.0f; + this->collider.elements[1].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + this->actionFunc = EnGrasshopper_WaitAfterAttack; +} + +/** + * Hover in place for a bit after an attack before raising the tail back up. + */ +void EnGrasshopper_WaitAfterAttack(EnGrasshopper* this, PlayState* play) { + this->bobPhase += 0xAF0; + this->targetPosY = (Math_SinS(this->bobPhase) * 10.0f) + this->baseFlyHeight; + Math_ApproachF(&this->actor.world.pos.y, this->targetPosY, 0.1f, 10.0f); + if (this->waitTimer == 0) { + this->collider.elements[0].info.toucherFlags |= (TOUCH_ON | TOUCH_SFX_WOOD); + EnGrasshopper_RaiseTail(this); + } +} + +void EnGrasshopper_SetupDamaged(EnGrasshopper* this, PlayState* play) { + Vec3f damagedVelocity; + + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_DAMAGE); + this->actor.speedXZ = 0.0f; + this->actor.flags |= ACTOR_FLAG_1; + this->approachSpeed = 0.0f; + this->collider.elements[1].info.toucherFlags &= ~(TOUCH_ON | TOUCH_SFX_WOOD); + Matrix_RotateYS(this->actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_MultVecZ(-20.0f, &damagedVelocity); + Math_Vec3f_Copy(&this->damagedVelocity, &damagedVelocity); + 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.3f, 0.2f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + this->action = EN_GRASSHOPPER_ACTION_DAMAGED; + this->actionFunc = EnGrasshopper_Damaged; +} + +void EnGrasshopper_Damaged(EnGrasshopper* this, PlayState* play) { + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 5, 0x3E8, 5); + if (this->actor.colorFilterTimer == 0) { + EnGrasshopper_RaiseTail(this); + } +} + +void EnGrasshopper_SetupDead(EnGrasshopper* this, PlayState* play) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_DEAD); + this->actor.flags |= ACTOR_FLAG_8000000; + this->actor.speedXZ = 0.0f; + this->approachSpeed = 0.0f; + this->actor.velocity.y = 5.0f; + this->actor.gravity = -0.5f; + 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); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_DEAD); + this->action = EN_GRASSHOPPER_ACTION_DEAD; + this->actionFunc = EnGrasshopper_Dead; +} + +/** + * Plays the death animation before transitioning to falling from the sky. + */ +void EnGrasshopper_Dead(EnGrasshopper* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + Math_SmoothStepToS(&this->actor.world.rot.z, 0, 5, 0x3E8, 5); + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->drawDmgEffTimer < 2)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.3f, 0.2f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + if (curFrame >= this->endFrame) { + this->actor.flags &= ~ACTOR_FLAG_10; + EnGrasshopper_SetupFall(this); + } +} + +void EnGrasshopper_SetupFall(EnGrasshopper* this) { + EnGrasshopper_ChangeAnim(this, EN_GRASSHOPPER_ANIM_FALL); + this->action = EN_GRASSHOPPER_ACTION_FALL; + this->actor.speedXZ = 0.0f; + this->approachSpeed = 0.0f; + this->actionFunc = EnGrasshopper_Fall; +} + +/** + * Falls from the sky and bursts into flames once it touches land or water. + */ +void EnGrasshopper_Fall(EnGrasshopper* this, PlayState* play) { + WaterBox* waterBox; + f32 waterSurface; + s32 isUnderWater = false; + + this->actor.shape.rot.y += 0x1388; + if ((this->actor.floorHeight <= BGCHECK_Y_MIN) || (this->actor.floorHeight >= BGCHECK_Y_MAX)) { + Actor_Kill(&this->actor); + return; + } + + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &waterSurface, + &waterBox)) { + if (this->actor.world.pos.y < waterSurface) { + Vec3f splashPos; + s32 i; + + for (i = 0; i < 3; i++) { + Math_Vec3f_Copy(&splashPos, &this->actor.world.pos); + splashPos.x += randPlusMinusPoint5Scaled((i * 5.0f) + 20.0f); + splashPos.z += randPlusMinusPoint5Scaled((i * 5.0f) + 20.0f); + EffectSsGSplash_Spawn(play, &splashPos, NULL, NULL, 0, (((s32)Rand_ZeroOne() * 100) + 400)); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_BOMB_DROP_WATER); + isUnderWater = true; + } + } + + if ((BgCheck_SphVsFirstPoly(&play->colCtx, &this->tailTipPos, 40.0f)) && + (((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.3f, 0.2f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + if (isUnderWater || (BgCheck_SphVsFirstPoly(&play->colCtx, &this->tailTipPos, 10.0f))) { + Vec3f firePos; + Vec3f sFireVelocityAndAccel[] = { + { 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(sFireVelocityAndAccel); i++) { + Math_Vec3f_Copy(&firePos, &this->actor.world.pos); + firePos.x += randPlusMinusPoint5Scaled(30.0f); + if (!isUnderWater) { + firePos.y = this->actor.floorHeight; + } else if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, + &waterSurface, &waterBox)) { + firePos.y = waterSurface; + } + + firePos.z += randPlusMinusPoint5Scaled(30.0f); + func_800B3030(play, &firePos, &sFireVelocityAndAccel[i], &sFireVelocityAndAccel[i], 100, 0, 2); + } + + SoundSource_PlaySfxEachFrameAtFixedWorldPos(play, &this->actor.world.pos, 10, + NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0x60); + Actor_Kill(&this->actor); + } +} + +void EnGrasshopper_UpdateDamage(EnGrasshopper* this, PlayState* play) { + s32 pad; + s16 attackDealsDamage = false; + + if ((this->collider.elements[0].info.bumperFlags & BUMP_HIT) || + (this->collider.elements[1].info.bumperFlags & BUMP_HIT)) { + this->collider.base.acFlags &= ~AC_HIT; + if ((this->action != EN_GRASSHOPPER_ACTION_DAMAGED) && (this->action != EN_GRASSHOPPER_ACTION_DEAD) && + (this->action != EN_GRASSHOPPER_ACTION_FALL)) { + if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_NONE) { + attackDealsDamage = true; + } else if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_FIRE) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + attackDealsDamage = true; + } else if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_FREEZE) { + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_BLUE_FIRE) || (this->drawDmgEffTimer == 0)) { + Actor_ApplyDamage(&this->actor); + attackDealsDamage = false; + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffFrozenSteamScale = 1.5f; + } + + if (this->actor.colChkInfo.health <= 0) { + EnGrasshopper_SetupDead(this, play); + return; + } + } else if (this->actor.colChkInfo.damageEffect == EN_GRASSHOPPER_DMGEFF_LIGHT_ORB) { + Actor_SetColorFilter(&this->actor, 0x8000, 255, 0, 25); + this->drawDmgEffTimer = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + 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); + attackDealsDamage = true; + } + } + } + + if (attackDealsDamage) { + Actor_ApplyDamage(&this->actor); + if (this->actor.colChkInfo.health > 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BATTA_DAMAGE); + EnGrasshopper_SetupDamaged(this, play); + } else { + EnGrasshopper_SetupDead(this, play); + } + } +} + +void EnGrasshopper_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnGrasshopper* this = THIS; + + SkelAnime_Update(&this->skelAnime); + EnGrasshopper_UpdateDamage(this, play); + this->actionFunc(this, play); + + Actor_SetFocus(&this->actor, 0.0f); + Actor_SetScale(&this->actor, this->dragonflyScale); + + DECR(this->timer); + DECR(this->waitTimer); + DECR(this->postBankTimer); + DECR(this->drawDmgEffTimer); + + Actor_MoveWithGravity(&this->actor); + this->actor.world.pos.x += this->damagedVelocity.x; + this->actor.world.pos.y += this->damagedVelocity.y; + this->actor.world.pos.z += this->damagedVelocity.z; + Math_ApproachZeroF(&this->damagedVelocity.x, 1.0f, 2.0f); + Math_ApproachZeroF(&this->damagedVelocity.y, 1.0f, 2.0f); + Math_ApproachZeroF(&this->damagedVelocity.z, 1.0f, 2.0f); + if ((this->action != EN_GRASSHOPPER_ACTION_FALL) && (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 60.0f, 60.0f, 0x1D); + } + + this->actor.shape.rot.z = this->actor.world.rot.z; + if (this->type == EN_GRASSHOPPER_TYPE_GROWS_WHEN_SPAWNED) { + f32 targetScale = this->type * 0.01f; + + if (targetScale >= 0.018f) { + targetScale = 0.018f; + } + + Math_ApproachF(&this->dragonflyScale, targetScale, 0.1f, 0.01f); + } + + if ((this->action != EN_GRASSHOPPER_ACTION_FALL) && (this->action != EN_GRASSHOPPER_ACTION_APPROACH_PLAYER)) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 5, 0x3E8, 5); + } + + EnGrasshopper_UpdateEffects(this, play); + if ((this->action != EN_GRASSHOPPER_ACTION_DEAD) && (this->action != EN_GRASSHOPPER_ACTION_FALL)) { + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + if ((this->action == EN_GRASSHOPPER_ACTION_APPROACH_PLAYER) || (this->action == EN_GRASSHOPPER_ACTION_ATTACK)) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + } +} + +void EnGrasshopper_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnGrasshopper* this = THIS; + Vec3f sEffectOffsetFromTailTop = { 500.0f, 0.0f, 0.0f }; + Vec3f sZeroVec3f = { 0.0f, 0.0f, 0.0f }; + + Matrix_Push(); + + if ((this->type != EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM) && + (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { + if ((s8)(sLimbIndexToShadowBodyPartsIndex[limbIndex] >= 0)) { + Matrix_MultVec3f(&sZeroVec3f, &this->shadowBodyPartsPos[sLimbIndexToShadowBodyPartsIndex[limbIndex]]); + } + } + + if (limbIndex == DRAGONFLY_LIMB_TAIL_TIP) { + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&gZeroVec3f, &this->tailTipPos); + Matrix_MultVec3f(&sEffectOffsetFromTailTop, &this->effectBasePos); + } + + Collider_UpdateSpheres(limbIndex, &this->collider); + if ((limbIndex == DRAGONFLY_LIMB_ROOT) || (limbIndex == DRAGONFLY_LIMB_TAIL_SEGMENT_2) || + (limbIndex == DRAGONFLY_LIMB_TAIL_TIP) || (limbIndex == DRAGONFLY_LIMB_BACK_LEFT_UPPER_LEG) || + (limbIndex == DRAGONFLY_LIMB_BACK_RIGHT_UPPER_LEG) || (limbIndex == DRAGONFLY_LIMB_FRONT_LEFT_UPPER_LEG) || + (limbIndex == DRAGONFLY_LIMB_FRONT_LEFT_FOOT) || (limbIndex == DRAGONFLY_LIMB_FRONT_RIGHT_UPPER_LEG) || + (limbIndex == DRAGONFLY_LIMB_HEAD) || + //! @bug: These do not check for valid limbs. Limb index 24 is DRAGONFLY_LIMB_MAX, so it (and any index + //! larger than it) is not tied to an actual limb. + (limbIndex == 24) || (limbIndex == 25) || + // While checking for DRAGONFLY_LIMB_ROOT twice is not a bug by itself, it causes another bug below. + (limbIndex == DRAGONFLY_LIMB_ROOT)) { + //! @bug: This code only works properly if all 12 elements of bodyPartsPos are updated every frame, since + //! otherwise bodyPartsPosIndex will be non-zero at the end of a frame. Despite the fact that there are 12 + //! checks in the above if-statement, only 9 of them are valid and non-duplicate, so only 9 elements of + //! bodyPartsPos are updated on each frame. As a result, three elements in bodyPartsPos will either be (0, 0, 0) + //! or be a value carried over from the previous frame. + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } + + Matrix_Pop(); +} + +// We need to pass in 14 into SubS_GenShadowTex for the bodyPartsNum, NOT the actual size of the +// parent body parts array. This is both necessary to match and to prevent extra dots from being +// drawn with the shadow. +#define SHADOW_BODY_PARTS_NUM 14 + +void EnGrasshopper_Draw(Actor* thisx, PlayState* play) { + EnGrasshopper* this = THIS; + s32 i; + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); + u8* shadowTexIter; + + func_8012C2DC(play->state.gfxCtx); + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, NULL, EnGrasshopper_PostLimbDraw, + &this->actor); + if ((this->type != EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM) && + (this->type != EN_GRASSHOPPER_TYPE_WOODFALL)) { + Matrix_RotateXS(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { + *shadowTexIter++ = 0; + } + + for (i = 0; i < 5; i++) { + SubS_GenShadowTex(this->shadowBodyPartsPos, &this->actor.world.pos, shadowTex, i / 5.0f, + SHADOW_BODY_PARTS_NUM, sShadowSizes, sParentBodyParts); + //! FAKE: Needed to fix some regs and stack + //! https://decomp.me/scratch/4wJBW + if ((shadowTex && shadowTex) && shadowTex) {} + } + + SubS_DrawShadowTex(&this->actor, &play->state, shadowTex); + } + + if (this->drawDmgEffTimer != 0) { + f32 drawDmgEffAlpha = 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, drawDmgEffAlpha, + this->drawDmgEffType); + } + + EnGrasshopper_DrawEffects(this, play); +} + +void EnGrasshopper_InitializeEffect(EnGrasshopper* this, Vec3f* pos) { + EnGrasshopperEffect* effect = this->effects; + s16 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + effect->pos = *pos; + effect->timer = 10; + effect->velocity.x = randPlusMinusPoint5Scaled(20.0f); + effect->velocity.y = randPlusMinusPoint5Scaled(20.0f); + effect->velocity.z = randPlusMinusPoint5Scaled(20.0f); + effect->yaw = randPlusMinusPoint5Scaled(30000.0f); + return; + } + } +} + +void EnGrasshopper_UpdateEffects(EnGrasshopper* this, PlayState* play) { + EnGrasshopperEffect* effect = this->effects; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->pos.x = this->effectBasePos.x + effect->velocity.x; + effect->pos.y = this->effectBasePos.y + effect->velocity.y; + effect->pos.z = this->effectBasePos.z + effect->velocity.z; + if (effect->timer != 0) { + effect->timer--; + effect->lightningIndex++; + Math_ApproachF(&effect->scale.x, 0.1f, 0.1f, 0.05f); + if (effect->lightningIndex >= 8) { + effect->lightningIndex = 0; + } + } else { + Math_ApproachZeroF(&effect->scale.x, 0.1f, 0.1f); + if (effect->scale.x < 0.2f) { + effect->isEnabled = 0; + } + } + + effect->scale.y = effect->scale.z = effect->scale.x; + } + } +} + +static TexturePtr sLightningTextures[] = { + gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, + gEffLightning5Tex, gEffLightning6Tex, gEffLightning7Tex, gEffLightning8Tex, +}; + +void EnGrasshopper_DrawEffects(EnGrasshopper* this, PlayState* play) { + s32 pad[2]; + EnGrasshopperEffect* effect; + s16 i; + MtxF mfResult; + MtxF mfTrans; + MtxF mfScale; + MtxF mfRot; + MtxF mfTransBillboard; + MtxF mfTransBillboardRot; + Mtx* mtx; + + OPEN_DISPS(play->state.gfxCtx); + + effect = this->effects; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + SkinMatrix_SetTranslate(&mfTrans, effect->pos.x, effect->pos.y, effect->pos.z); + SkinMatrix_SetScale(&mfScale, effect->scale.x, effect->scale.y, effect->scale.z); + SkinMatrix_SetRotateRPY(&mfRot, 0, 0, effect->yaw); + 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(play->state.gfxCtx, &mfResult); + + if (mtx != NULL) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C9BC(play->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sLightningTextures[effect->lightningIndex])); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 255, 255); + gSPDisplayList(POLY_XLU_DISP++, Lib_SegmentedToVirtual(gEffLightningDL)); + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} 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..8056253f6 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h @@ -2,18 +2,77 @@ #define Z_EN_GRASSHOPPER_H #include "global.h" +#include "objects/object_grasshopper/object_grasshopper.h" + +#define EN_GRASSHOPPER_GET_TYPE(thisx) ((thisx)->params) struct EnGrasshopper; -typedef void (*EnGrasshopperActionFunc)(struct EnGrasshopper*, GlobalContext*); +typedef void (*EnGrasshopperActionFunc)(struct EnGrasshopper*, PlayState*); + +typedef enum EnGrasshopperType { + /* -1 */ EN_GRASSHOPPER_TYPE_UNUSED_NORMAL = -1, // Acts exactly like EN_GRASSHOPPER_TYPE_NORMAL + /* 0 */ EN_GRASSHOPPER_TYPE_NORMAL, + /* 1 */ EN_GRASSHOPPER_TYPE_GROWS_WHEN_SPAWNED, // Spawned by EnEncount1 + /* 2 */ EN_GRASSHOPPER_TYPE_WOODFALL_TEMPLE_FINAL_ROOM, + /* 3 */ EN_GRASSHOPPER_TYPE_WOODFALL, +} EnGrasshopperType; + +typedef struct EnGrasshopperEffect { + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; + /* 0x10 */ Vec3f velocity; + /* 0x1C */ f32 yaw; + /* 0x20 */ Vec3f scale; + /* 0x2C */ s16 timer; + /* 0x2E */ s16 lightningIndex; +} EnGrasshopperEffect; // size = 0x30 + +#define EN_GRASSHOPPER_EFFECT_COUNT 100 typedef struct EnGrasshopper { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x164]; + /* 0x0144 */ SkelAnime skelAnime; + /* 0x0188 */ Vec3s jointTable[DRAGONFLY_LIMB_MAX]; + /* 0x0218 */ Vec3s morphTable[DRAGONFLY_LIMB_MAX]; /* 0x02A8 */ EnGrasshopperActionFunc actionFunc; - /* 0x02AC */ char unk_2AC[0x15C4]; + /* 0x02AC */ u8 decision; + /* 0x02AD */ u8 shouldTurn; + /* 0x02AE */ UNK_TYPE1 unk_2AE[2]; + /* 0x02B0 */ s16 timer; + /* 0x02B2 */ s16 waitTimer; + /* 0x02B4 */ s16 postBankTimer; + /* 0x02B6 */ s16 drawDmgEffTimer; + /* 0x02B8 */ s16 drawDmgEffType; + /* 0x02BC */ f32 drawDmgEffScale; + /* 0x02C0 */ f32 drawDmgEffFrozenSteamScale; + /* 0x02C4 */ Vec3f bodyPartsPos[12]; + /* 0x0354 */ s16 bodyPartsPosIndex; + /* 0x0356 */ s16 splashCount; + /* 0x0358 */ s16 action; + /* 0x035A */ s16 index; // Has a minor effect on speed for some reason. + /* 0x035C */ s16 bankState; + /* 0x035E */ s16 type; + /* 0x0360 */ f32 dragonflyScale; + /* 0x0364 */ f32 rotationalVelocity; + /* 0x0368 */ f32 endFrame; + /* 0x036C */ f32 approachSpeed; + /* 0x0370 */ f32 baseFlyHeight; + /* 0x0374 */ f32 targetPosY; + /* 0x0376 */ Vec3s targetRot; + /* 0x0380 */ Vec3f flyingHomePos; + /* 0x038C */ s16 bobPhase; + /* 0x038E */ UNK_TYPE1 unk_38E[0x26]; + /* 0x03B4 */ Vec3f targetApproachPos; + /* 0x03C0 */ Vec3f tailTipPos; + /* 0x03CC */ Vec3f effectBasePos; + /* 0x03D8 */ Vec3f shadowBodyPartsPos[DRAGONFLY_LIMB_MAX]; + /* 0x04F8 */ f32 waterSurface; + /* 0x04FC */ Vec3f damagedVelocity; + /* 0x0508 */ Vec3s targetBankRot; + /* 0x0510 */ ColliderJntSph collider; + /* 0x0530 */ ColliderJntSphElement colliderElements[2]; + /* 0x0570 */ EnGrasshopperEffect effects[EN_GRASSHOPPER_EFFECT_COUNT]; } EnGrasshopper; // size = 0x1870 -extern const ActorInit En_Grasshopper_InitVars; - #endif // Z_EN_GRASSHOPPER_H diff --git a/src/overlays/actors/ovl_En_Gs/overlay.cfg b/src/overlays/actors/ovl_En_Gs/overlay.cfg deleted file mode 100644 index 0fc22a856..000000000 --- a/src/overlays/actors/ovl_En_Gs/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Gs -z_en_gs.c 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 a97de7b80..93d7e3f88 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -12,32 +12,32 @@ #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 = { +ActorInit En_Gs_InitVars = { ACTOR_EN_GS, ACTORCAT_PROP, FLAGS, @@ -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; @@ -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], - EXCH_ITEM_NONE, 0x2000, 0x2000); + func_8013E8F8(&this->actor, play, D_8099A408[this->actor.params], D_8099A408[this->actor.params], + PLAYER_IA_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,22 +329,22 @@ 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) { @@ -356,32 +356,32 @@ f32 func_80998334(EnGs* this, GlobalContext* globalCtx, f32* arg2, f32* arg3, s1 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, PLAYER_CSMODE_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_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); Matrix_MultVecZ(160.0f, &sp38); @@ -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; } @@ -459,61 +459,61 @@ void func_8099874C(EnGs* this, GlobalContext* globalCtx) { this->unk_20C = -1; switch (this->unk_194) { case 1: - if (!(gSaveContext.save.weekEventReg[77] & 8)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_77_08)) { this->unk_20C = 6; - gSaveContext.save.weekEventReg[77] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_77_08); } break; case 3: - if (!(gSaveContext.save.weekEventReg[77] & 0x10)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_77_10)) { this->unk_20C = 6; - gSaveContext.save.weekEventReg[77] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_77_10); } break; case 2: - if (!(gSaveContext.save.weekEventReg[77] & 0x20)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_77_20)) { this->unk_20C = 6; - gSaveContext.save.weekEventReg[77] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_77_20); } break; } - if (!(gSaveContext.save.weekEventReg[90] & 0x10)) { - gSaveContext.save.weekEventReg[90] |= 0x10; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_90_10)) { + SET_WEEKEVENTREG(WEEKEVENTREG_90_10); this->unk_20C = 12; } 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; @@ -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,9 +869,9 @@ 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); + Actor_Kill(&this->actor); sp7C = 0; } } @@ -880,9 +879,9 @@ 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); + Actor_Kill(&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,11 +1064,11 @@ 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); + func_8012C28C(play->state.gfxCtx); Matrix_Push(); if (this->unk_19A & 1) { @@ -1082,26 +1081,26 @@ void EnGs_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); - gSPDisplayList(POLY_OPA_DISP++, object_gs_DL_000950); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneMaterialDL); 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); + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneDL); + gSPDisplayList(POLY_OPA_DISP++, gGossipStoneBottomModelDL); Matrix_Pop(); if (this->unk_19A & 2) { - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_ReplaceRotation(&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..51e899fcc 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) @@ -57,6 +57,4 @@ typedef struct EnGs { /* 0x21E */ s16 unk_21E; } EnGs; // size = 0x220 -extern const ActorInit En_Gs_InitVars; - #endif // Z_EN_GS_H diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/overlay.cfg b/src/overlays/actors/ovl_En_Guard_Nuts/overlay.cfg deleted file mode 100644 index 135b80f6c..000000000 --- a/src/overlays/actors/ovl_En_Guard_Nuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Guard_Nuts -z_en_guard_nuts.c 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 1394efff7..b13bca1dd 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,26 +5,27 @@ */ #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 = { +ActorInit En_Guard_Nuts_InitVars = { ACTOR_EN_GUARD_NUTS, ACTORCAT_NPC, FLAGS, @@ -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,45 +94,45 @@ 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, + 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; sGuardCount++; // If you have returned deku princess guards will init burrowed. - if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { 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; } @@ -157,10 +158,10 @@ void EnGuardNuts_Wait(EnGuardNuts* this, GlobalContext* globalCtx) { if (player->transformation == PLAYER_FORM_DEKU) { // this is the palace of... this->guardTextIndex = 0; - if ((gSaveContext.save.weekEventReg[17] & 4) && (!this->hasCompletedConversation)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_17_04) && (!this->hasCompletedConversation)) { // I told you not to enter!! this->guardTextIndex = 7; - } else if (gSaveContext.save.weekEventReg[12] & 0x40) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_40)) { // come to see the monkey again? this->guardTextIndex = 4; } @@ -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)) { + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_12_40); + 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,17 +295,17 @@ 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; // If you have returned Deku Princess, guards will not unburrow - if (!(gSaveContext.save.weekEventReg[23] & 0x20)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_20)) { yawDiff = ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.home.rot.y)); if ((yawDiff < 0x4000) && ((D_80ABBE20 == 0) || (this->actor.xzDistToPlayer > 150.0f))) { Math_Vec3f_Copy(&digPos, &this->actor.world.pos); digPos.y = this->actor.floorHeight; - EffectSsHahen_SpawnBurst(globalCtx, &digPos, 4.0f, 0, 10, 3, 15, -1, 10, NULL); + 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,15 +345,14 @@ 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 == DEKU_PALACE_GUARD_LIMB_HEAD) { @@ -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); + 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 4a42e4e5a..8cbe26f03 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,7 +6,7 @@ struct EnGuardNuts; -typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, GlobalContext*); +typedef void (*EnGuardNutsActionFunc)(struct EnGuardNuts*, PlayState*); typedef struct EnGuardNuts { /* 0x000 */ Actor actor; @@ -29,6 +29,4 @@ typedef struct EnGuardNuts { /* 0x244 */ ColliderCylinder collider; } EnGuardNuts; // size = 0x290 -extern const ActorInit En_Guard_Nuts_InitVars; - #endif // Z_EN_GUARD_NUTS_H diff --git a/src/overlays/actors/ovl_En_Guruguru/overlay.cfg b/src/overlays/actors/ovl_En_Guruguru/overlay.cfg deleted file mode 100644 index 727ca7b59..000000000 --- a/src/overlays/actors/ovl_En_Guruguru/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Guruguru -z_en_guruguru.c 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 3830864d1..f7eddbe6f 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -11,23 +11,23 @@ #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; -const ActorInit En_Guruguru_InitVars = { +ActorInit En_Guruguru_InitVars = { ACTOR_EN_GURUGURU, ACTORCAT_NPC, FLAGS, @@ -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) { @@ -88,41 +88,41 @@ void EnGuruguru_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; this->actionFunc = EnGuruguru_DoNothing; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else if (this->actor.params == 1) { func_80BC6E10(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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) { - if (gSaveContext.save.weekEventReg[38] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_38_10)) { this->textIdIndex = 1; } - } else if (gSaveContext.save.weekEventReg[38] & 0x40) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_38_40)) { this->textIdIndex = 2; } else { this->textIdIndex = 3; @@ -131,8 +131,8 @@ void func_80BC6E10(EnGuruguru* this) { this->headZRotTarget = 0; this->unk268 = 1; this->actor.textId = textIDs[this->textIdIndex]; - if ((this->textIdIndex == 0 || this->textIdIndex == 1) && (gSaveContext.save.weekEventReg[77] & 4)) { - if (!(gSaveContext.save.weekEventReg[88] & 4)) { + if ((this->textIdIndex == 0 || this->textIdIndex == 1) && CHECK_WEEKEVENTREG(WEEKEVENTREG_77_04)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_88_04)) { this->actor.textId = 0x295F; } else { this->actor.textId = 0x2960; @@ -142,18 +142,18 @@ 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) { this->textIdIndex = 13; - if (gSaveContext.save.weekEventReg[79] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_04)) { this->textIdIndex = 14; } } @@ -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,23 +207,23 @@ 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); - gSaveContext.save.weekEventReg[79] |= 4; + func_80151BB4(play, 0x13); + SET_WEEKEVENTREG(WEEKEVENTREG_79_04); func_80BC6E10(this); return; } if (this->actor.params == 0) { if (this->actor.textId == 0x295F) { - gSaveContext.save.weekEventReg[88] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_88_04); } if (this->actor.textId == 0x292A) { - gSaveContext.save.weekEventReg[38] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_38_10); } - func_80151BB4(globalCtx, 0x13); + func_80151BB4(play, 0x13); func_80BC6E10(this); return; } @@ -232,10 +232,10 @@ void func_80BC7068(EnGuruguru* this, GlobalContext* globalCtx) { return; } if (this->textIdIndex == 12) { - gSaveContext.save.weekEventReg[38] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_38_40); 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,48 +288,48 @@ 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_IA_MINUS1); this->unk268 = 0; - gSaveContext.save.weekEventReg[38] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_38_40); 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_IA_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) { if (this->actor.params == 1) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } else if (this->actor.params == 0 || this->actor.params == 2) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); 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..0158e3ddc 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; @@ -30,6 +30,4 @@ typedef struct EnGuruguru { /* 0x278 */ ColliderCylinder collider; } EnGuruguru; // size = 0x2C4 -extern const ActorInit En_Guruguru_InitVars; - #endif // Z_EN_GURUGURU_H diff --git a/src/overlays/actors/ovl_En_Hakurock/overlay.cfg b/src/overlays/actors/ovl_En_Hakurock/overlay.cfg deleted file mode 100644 index 93c363b8d..000000000 --- a/src/overlays/actors/ovl_En_Hakurock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hakurock -z_en_hakurock.c 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 d8551103d..0e1d2f050 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -13,26 +13,26 @@ #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 = { +ActorInit En_Hakurock_InitVars = { ACTOR_EN_HAKUROCK, ACTORCAT_ITEMACTION, FLAGS, @@ -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--; @@ -276,7 +276,8 @@ void func_80B22500(EnHakurock* this, GlobalContext* globalCtx) { (this->collider.base.oc->params == EN_HAKUROCK_TYPE_UNK_2))) { func_80B21EA4(this, 3); func_80B21FFC(this); - } else if ((&player->actor == this->collider.base.oc) && ((player->stateFlags3 & 0x81000) != 0) && + } else if ((&player->actor == this->collider.base.oc) && + (player->stateFlags3 & (PLAYER_STATE3_1000 | PLAYER_STATE3_80000)) && (player->linearVelocity > 8.0f)) { player->unk_B08[0] = player->linearVelocity = -5.0f; player->unk_B08[1] += (player->linearVelocity * 0.05f); @@ -307,52 +308,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); +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(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011100); - gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011178); - CLOSE_DISPS(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++, gGohtStalactiteMaterialDL); + gSPDisplayList(POLY_OPA_DISP++, gGohtStalactiteModelDL); + 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..4934c7fc8 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, @@ -22,6 +22,4 @@ typedef struct EnHakurock { /* 0x14C */ ColliderCylinder collider; } EnHakurock; // size = 0x198 -extern const ActorInit En_Hakurock_InitVars; - #endif // Z_EN_HAKUROCK_H diff --git a/src/overlays/actors/ovl_En_Hanabi/overlay.cfg b/src/overlays/actors/ovl_En_Hanabi/overlay.cfg deleted file mode 100644 index 67feefe27..000000000 --- a/src/overlays/actors/ovl_En_Hanabi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hanabi -z_en_hanabi.c 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 f90ed476b..507bf9deb 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -11,17 +11,17 @@ #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* play2); +void EnHanabi_Destroy(Actor* thisx, PlayState* play2); +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 = { +ActorInit En_Hanabi_InitVars = { ACTOR_EN_HANABI, ACTORCAT_ITEMACTION, FLAGS, @@ -133,20 +133,20 @@ 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); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB10); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); sp53 = 0xFF; if (sp53) {} @@ -154,17 +154,16 @@ void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { for (i = 0; i < 400; i++, arg0++) { if (arg0->unk_00 == 1) { Matrix_Translate(arg0->unk_08.x, arg0->unk_08.y, arg0->unk_08.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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_RotateZS(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++); @@ -182,15 +181,15 @@ void func_80B22FA8(EnHanabiStruct* arg0, GlobalContext* globalCtx2) { D_80B23C2C[arg0->unk_02 + 2], 255); } - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_07AB58); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); } } 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); + Actor_Kill(&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.sceneLayer == 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->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 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_Push(); - func_80B22FA8(this->unk_148, globalCtx); + 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..4c0c2e216 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) @@ -32,6 +32,4 @@ typedef struct EnHanabi { /* 0x4654 */ EnHanabiActionFunc actionFunc; } EnHanabi; // size = 0x4658 -extern const ActorInit En_Hanabi_InitVars; - #endif // Z_EN_HANABI_H diff --git a/src/overlays/actors/ovl_En_Hata/overlay.cfg b/src/overlays/actors/ovl_En_Hata/overlay.cfg deleted file mode 100644 index e670da262..000000000 --- a/src/overlays/actors/ovl_En_Hata/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hata -z_en_hata.c 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..4a01b663e 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.c +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.c @@ -5,18 +5,18 @@ */ #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 = { +ActorInit En_Hata_InitVars = { ACTOR_EN_HATA, ACTORCAT_PROP, FLAGS, @@ -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..155460f60 100644 --- a/src/overlays/actors/ovl_En_Hata/z_en_hata.h +++ b/src/overlays/actors/ovl_En_Hata/z_en_hata.h @@ -2,14 +2,19 @@ #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 - -extern const ActorInit En_Hata_InitVars; + /* 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 */ #endif // Z_EN_HATA_H diff --git a/src/overlays/actors/ovl_En_Heishi/overlay.cfg b/src/overlays/actors/ovl_En_Heishi/overlay.cfg deleted file mode 100644 index 3b8a0e40e..000000000 --- a/src/overlays/actors/ovl_En_Heishi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Heishi -z_en_heishi.c 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..756f37eb8 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -5,31 +5,30 @@ */ #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 = { +ActorInit En_Heishi_InitVars = { ACTOR_EN_HEISHI, ACTORCAT_NPC, FLAGS, @@ -61,50 +60,48 @@ 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; if (this->paramsCopy == 0) { this->shouldSetHeadRotation = 1; - if (!(gSaveContext.save.weekEventReg[63] & 0x80) && - !((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_80) && !((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_Kill(&this->actor); } } else { this->colliderCylinder.dim.radius = 30; this->colliderCylinder.dim.height = 60; this->colliderCylinder.dim.yShift = 0; - if ((gSaveContext.save.weekEventReg[63] & 0x80) || - ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_80) || ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_Kill(&this->actor); } } 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 +110,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 +129,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; @@ -153,29 +150,29 @@ void EnHeishi_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; if ((this->paramsCopy != 0) && (gSaveContext.save.day == 3) && gSaveContext.save.isNight) { - Actor_MarkForDeath(&this->actor); - } else { - this->actionFunc(this, globalCtx); - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 29); - Actor_SetScale(&this->actor, 0.01f); - if (this->shouldSetHeadRotation) { - EnHeishi_SetHeadRotation(this); - } - - Actor_SetFocus(&this->actor, 60.0f); - Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 3000, 0); - Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 1000, 0); - Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base); + Actor_Kill(&this->actor); + return; } + + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 29); + Actor_SetScale(&this->actor, 0.01f); + if (this->shouldSetHeadRotation) { + EnHeishi_SetHeadRotation(this); + } + + Actor_SetFocus(&this->actor, 60.0f); + Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 3000, 0); + Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 1000, 0); + Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); + CollisionCheck_SetOC(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 +181,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/overlay.cfg b/src/overlays/actors/ovl_En_Hg/overlay.cfg deleted file mode 100644 index d3037b31d..000000000 --- a/src/overlays/actors/ovl_En_Hg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hg -z_en_hg.c 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 2b77feacf..e100a2de3 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -1,37 +1,53 @@ /* * 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_80BCF468(EnHg* this); -void func_80BCF468(EnHg* this); -void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx); -void func_80BCF5F0(EnHg* this); -void func_80BCF634(EnHg* this, GlobalContext* globalCtx); -void func_80BCF68C(EnHg* this); -void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx); -void func_80BCF8A0(EnHg* this, GlobalContext* globalCtx); -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 EnHg_SetupWait(EnHg* this); +void EnHg_Wait(EnHg* this, PlayState* play); +void EnHg_SetupChasePlayer(EnHg* this); +void EnHg_ChasePlayer(EnHg* this, PlayState* play); +void EnHg_SetupChasePlayerWait(EnHg* this); +void EnHg_ChasePlayerWait(EnHg* this, PlayState* play); +void EnHg_SetupReactToHit(EnHg* this); +void EnHg_ReactToHit(EnHg* this, PlayState* play); +void EnHg_PlayCutscene(EnHg* this, PlayState* play); +void EnHg_SetupCsAction(EnHg* this); +void EnHg_HandleCsAction(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 = { +typedef enum { + /* 0 */ HG_ANIM_IDLE, + /* 1 */ HG_ANIM_LURCH_FORWARD, + /* 2 */ HG_ANIM_RECOIL, + /* 3 */ HG_ANIM_LEAN_FORWARD, + /* 4 */ HG_ANIM_REACH_FORWARD, + /* 5 */ HG_ANIM_CURL_UP, + /* 6 */ HG_ANIM_CROUCHED_PANIC, + /* 7 */ HG_ANIM_PANIC, +} HgAnimation; + +typedef enum { + /* 0 */ HG_CS_FIRST_ENCOUNTER, + /* 1 */ HG_CS_GET_MASK, + /* 2 */ HG_CS_SUBSEQUENT_ENCOUNTER, + /* 3 */ HG_CS_SONG_OF_HEALING, +} HgCsIndex; + +ActorInit En_Hg_InitVars = { ACTOR_EN_HG, ACTORCAT_PROP, FLAGS, @@ -102,32 +118,32 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, 0x80, }; -static AnimationInfo sAnimations[] = { - { &object_harfgibud_Anim_00260C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_harfgibud_Anim_009D44, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_harfgibud_Anim_00A164, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_harfgibud_Anim_000370, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_harfgibud_Anim_001138, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_0015D4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_harfgibud_Anim_001960, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_00AE1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +static AnimationInfo sAnimationInfo[] = { + { &gPamelasFatherIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gPamelasFatherLurchForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gPamelasFatherRecoilFromHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gPamelasFatherLeanForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gPamelasFatherReachForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherCurlUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gPamelasFatherCrouchedPanicAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherPanicAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; -static u32 D_80BD00C8 = false; +static u32 sHasSoundPlayed = 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, &gPamelasFatherGibdoSkel, &gPamelasFatherIdleAnim, this->jointTable, + this->morphTable, PAMELAS_FATHER_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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + Actor_Kill(&this->actor); } this->actor.targetMode = 1; this->actor.colChkInfo.health = 0; @@ -139,44 +155,44 @@ void EnHg_Init(Actor* thisx, GlobalContext* globalCtx) { this->cutscenes[i] = currentCutscene; currentCutscene = ActorCutscene_GetAdditionalCutscene(currentCutscene); } - func_80BCF354(this); + EnHg_SetupWait(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); - this->actionFunc = func_80BCF398; +void EnHg_SetupWait(EnHg* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_IDLE); + this->actionFunc = EnHg_Wait; } -void func_80BCF398(EnHg* this, GlobalContext* globalCtx) { +void EnHg_Wait(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)) { - func_80BCF468(this); + !Cutscene_CheckActorAction(play, 0x1E3)) { + EnHg_SetupChasePlayer(this); } - if ((gSaveContext.sceneSetupIndex == 0 && globalCtx->csCtx.currentCsIndex == 0) && - (globalCtx->csCtx.frames == 20 || globalCtx->csCtx.frames == 60)) { + if ((gSaveContext.sceneLayer == 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); - this->actionFunc = func_80BCF4AC; +void EnHg_SetupChasePlayer(EnHg* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_LURCH_FORWARD); + this->actionFunc = EnHg_ChasePlayer; } -void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnHg_ChasePlayer(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 & PLAYER_STATE2_8000000) && 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); @@ -185,238 +201,259 @@ void func_80BCF4AC(EnHg* this, GlobalContext* globalCtx) { } if ((Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) > 200.0f) && (Math_Vec3f_DistXZ(&player->actor.world.pos, &this->actor.home.pos) > 200.0f)) { - func_80BCF5F0(this); + EnHg_SetupChasePlayerWait(this); } } } -void func_80BCF5F0(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); - this->actionFunc = func_80BCF634; +void EnHg_SetupChasePlayerWait(EnHg* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_IDLE); + this->actionFunc = EnHg_ChasePlayerWait; } -void func_80BCF634(EnHg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnHg_ChasePlayerWait(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); + EnHg_SetupChasePlayer(this); } } -void func_80BCF68C(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); - this->actionFunc = func_80BCF6D0; +void EnHg_SetupReactToHit(EnHg* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_RECOIL); + this->actionFunc = EnHg_ReactToHit; } -void func_80BCF6D0(EnHg* this, GlobalContext* globalCtx) { +void EnHg_ReactToHit(EnHg* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80BCF5F0(this); + EnHg_SetupChasePlayerWait(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 EnHg_HandleTatlDialog(EnHg* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + // "...Sort of looks different..." + 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 EnHg_PlayRedeadSfx(EnHg* this, PlayState* play) { if (this->actor.colChkInfo.health == 1) { - if (this->actionFunc == func_80BCF4AC || this->actionFunc == func_80BCF6D0 || - this->actionFunc == func_80BCF634) { + if ((this->actionFunc == EnHg_ChasePlayer) || (this->actionFunc == EnHg_ReactToHit) || + (this->actionFunc == EnHg_ChasePlayerWait)) { func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_LOOP - SFX_FLAG); } } } -void func_80BCF7D8(EnHg* this, GlobalContext* globalCtx) { - if (this->actor.colChkInfo.health) { +void EnHg_UpdateCollision(EnHg* this, PlayState* play) { + if (this->actor.colChkInfo.health != 0) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_80BCF68C(this); + EnHg_SetupReactToHit(this); } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->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_SetOC(play, &play->colChkCtx, &this->collider.base); + if ((this->actionFunc != EnHg_ReactToHit) && (this->actionFunc != EnHg_PlayCutscene) && + (this->actionFunc != EnHg_HandleCsAction)) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } -void func_80BCF88C(EnHg* this) { - this->actionFunc = func_80BCF8A0; +void EnHg_SetupCutscene(EnHg* this) { + this->actionFunc = EnHg_PlayCutscene; } -void func_80BCF8A0(EnHg* this, GlobalContext* globalCtx) { - if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->unk218])) { - ActorCutscene_Start(this->cutscenes[this->unk218], &this->actor); - func_80BCF93C(this); +void EnHg_PlayCutscene(EnHg* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIndex])) { + ActorCutscene_Start(this->cutscenes[this->cutsceneIndex], &this->actor); + EnHg_SetupCsAction(this); } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } - ActorCutscene_SetIntentToPlay(this->cutscenes[this->unk218]); + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); } } -void func_80BCF93C(EnHg* this) { +void EnHg_SetupCsAction(EnHg* this) { this->cutscenes[3] = 0x63; this->cutscenes[2] = 0; - this->actionFunc = func_80BCF95C; + this->actionFunc = EnHg_HandleCsAction; } -void func_80BCF95C(EnHg* this, GlobalContext* globalCtx) { - if (Cutscene_CheckActorAction(globalCtx, 484)) { - s32 actionIndex = Cutscene_GetActorActionIndex(globalCtx, 484); +void EnHg_HandleCsAction(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, HG_ANIM_IDLE); break; + case 2: this->cutscenes[2] = 0; - this->currentAnimation = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->animIndex = HG_ANIM_LEAN_FORWARD; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_LEAN_FORWARD); break; + case 3: this->cutscenes[2] = 0; - this->currentAnimation = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->animIndex = HG_ANIM_CURL_UP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_CURL_UP); break; + case 4: this->cutscenes[2] = 0; - this->currentAnimation = 7; - if ((this->unk218 == 1) || (this->unk218 == 3)) { + this->animIndex = HG_ANIM_PANIC; + if ((this->cutsceneIndex == HG_CS_GET_MASK) || (this->cutsceneIndex == HG_CS_SONG_OF_HEALING)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_PANIC); break; + case 5: - this->currentAnimation = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->animIndex = HG_ANIM_LURCH_FORWARD; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_LURCH_FORWARD); break; + case 6: - gSaveContext.save.weekEventReg[75] |= 0x20; - Actor_MarkForDeath(&this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_75_20); + Actor_Kill(&this->actor); break; } - } else { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - switch (this->currentAnimation) { - case 3: - this->currentAnimation = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); - break; - case 5: - this->currentAnimation = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); - break; - } + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + switch (this->animIndex) { + case HG_ANIM_LEAN_FORWARD: + this->animIndex = HG_ANIM_REACH_FORWARD; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_REACH_FORWARD); + break; + + case HG_ANIM_CURL_UP: + this->animIndex = HG_ANIM_CROUCHED_PANIC; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_CROUCHED_PANIC); + break; } } - switch (this->currentAnimation) { - case 3: - case 4: + + switch (this->animIndex) { + case HG_ANIM_LEAN_FORWARD: + case HG_ANIM_REACH_FORWARD: func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_LOOP - SFX_FLAG); break; - case 5: - case 6: + + case HG_ANIM_CURL_UP: + case HG_ANIM_CROUCHED_PANIC: func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_SCREAME - SFX_FLAG); break; - case 7: - if ((this->unk218 == 0) || (this->unk218 == 2)) { + + case HG_ANIM_PANIC: + if ((this->cutsceneIndex == HG_CS_FIRST_ENCOUNTER) || + (this->cutsceneIndex == HG_CS_SUBSEQUENT_ENCOUNTER)) { func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_SCREAME - SFX_FLAG); } break; } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); return; - } else if (globalCtx->csCtx.state == 0) { - func_80BCF354(this); + + } else if (play->csCtx.state == 0) { + EnHg_SetupWait(this); } + this->cutscenes[3] = 0x63; } -void func_80BCFC0C(EnHg* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnHg_WaitForPlayerAction(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) { - if (!D_80BD00C8) { - play_sound(NA_SE_SY_TRE_BOX_APPEAR); - } - D_80BD00C8 = true; - } else { - D_80BD00C8 = false; + // If the player has gone upstairs this interaction will not trigger + if ((this->actor.colChkInfo.health != 1) || (fabsf(this->actor.playerHeightRel) >= 80.0f)) { + return; + } + + if (player->stateFlags2 & PLAYER_STATE2_8000000) { + if (!sHasSoundPlayed) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); } - if (globalCtx->msgCtx.ocarinaMode == 3) { - if (globalCtx->msgCtx.unk1202E == 7 && gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { - this->unk218 = 3; + sHasSoundPlayed = true; + } else { + sHasSoundPlayed = false; + } + + 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->cutsceneIndex = HG_CS_SONG_OF_HEALING; + } else { + this->cutsceneIndex = HG_CS_GET_MASK; + } + + EnHg_SetupCutscene(this); + } + + } else { + if ((this->actor.xzDistToPlayer < 60.0f) && (fabsf(this->actor.playerHeightRel) < 40.0f)) { + if ((this->actionFunc != EnHg_PlayCutscene) && (this->actionFunc != EnHg_HandleCsAction)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_61_02)) { + SET_WEEKEVENTREG(WEEKEVENTREG_61_02); + this->cutsceneIndex = HG_CS_FIRST_ENCOUNTER; } else { - this->unk218 = 1; + this->cutsceneIndex = HG_CS_SUBSEQUENT_ENCOUNTER; } - func_80BCF88C(this); + + EnHg_SetupCutscene(this); + return; } - } else { - if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.playerHeightRel) < 40.0f) { - if ((this->actionFunc != func_80BCF8A0) && (this->actionFunc != func_80BCF95C)) { - if (!(gSaveContext.save.weekEventReg[61] & 2)) { - gSaveContext.save.weekEventReg[61] |= 2; - this->unk218 = 0; - } else { - this->unk218 = 2; - } - func_80BCF88C(this); - return; - } - } - func_80BCF710(this, globalCtx); } + + EnHg_HandleTatlDialog(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); + EnHg_UpdateCollision(this, play); + EnHg_WaitForPlayerAction(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 0.0f, 5); + EnHg_PlayRedeadSfx(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_Get(&this->unk1D8); - } else if (limbIndex == HG_LIMB_PELVIS) { + if (limbIndex == PAMELAS_FATHER_GIBDO_LIMB_EYEBROWS) { + Matrix_Get(&this->mf); + } else if (limbIndex == PAMELAS_FATHER_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_Put(&this->unk1D8); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_harfgibud_DL_005E28); - CLOSE_DISPS(globalCtx->state.gfxCtx); + Matrix_Put(&this->mf); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gPamelasFatherGibdoEyebrowsDL); + 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..1211a4cf3 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.h +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.h @@ -2,48 +2,25 @@ #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; /* 0x144 */ ColliderCylinder collider; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnHgActionFunc actionFunc; - /* 0x1D8 */ MtxF unk1D8; - /* 0x218 */ s32 unk218; - /* 0x21C */ s32 currentAnimation; - /* 0x220 */ Vec3s jointTable[HG_LIMB_MAX]; - /* 0x292 */ Vec3s morphTable[HG_LIMB_MAX]; + /* 0x1D8 */ MtxF mf; + /* 0x218 */ s32 cutsceneIndex; + /* 0x21C */ s32 animIndex; + /* 0x220 */ Vec3s jointTable[PAMELAS_FATHER_GIBDO_LIMB_MAX]; + /* 0x292 */ Vec3s morphTable[PAMELAS_FATHER_GIBDO_LIMB_MAX]; /* 0x304 */ UNK_TYPE1 pad304[0xC]; /* 0x310 */ u16 cutscenes[4]; } EnHg; // size = 0x318 -extern const ActorInit En_Hg_InitVars; - #endif // Z_EN_HG_H diff --git a/src/overlays/actors/ovl_En_Hgo/overlay.cfg b/src/overlays/actors/ovl_En_Hgo/overlay.cfg deleted file mode 100644 index 242079637..000000000 --- a/src/overlays/actors/ovl_En_Hgo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hgo -z_en_hgo.c 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 a16e0d94a..f7a9df82a 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -1,34 +1,54 @@ /* * 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_80BD049C(EnHgo* this); -void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx); +void EnHgo_SetupDoNothing(EnHgo* this); +void EnHgo_DoNothing(EnHgo* this, PlayState* play); +void EnHgo_UpdateCollision(EnHgo* this, PlayState* play); +void EnHgo_SetupTalk(EnHgo* this); +void EnHgo_Talk(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 EnHgo_HandlePlayerChoice(EnHgo* this, PlayState* play); +s32 EnHgo_HandleCsAction(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 = { +#define TALK_FLAG_NONE 0 +#define TALK_FLAG_HAS_SPOKEN_WITH_HUMAN (1 << 0) +#define TALK_FLAG_HAS_SPOKEN_WITH_OTHER_MASK_FORM (1 << 1) +#define TALK_FLAG_HAS_SPOKEN_WITH_GIBDO_MASK (1 << 2) + +typedef enum { + /* 0 */ HGO_EYE_OPEN, + /* 1 */ HGO_EYE_HALF, + /* 2 */ HGO_EYE_CLOSED +} EyeState; + +typedef enum { + /* 0 */ HGO_ANIM_ARMS_FOLDED, + /* 1 */ HGO_ANIM_ASTONISHED, + /* 2 */ HGO_ANIM_KNEEL_DOWN_AND_HUG, + /* 3 */ HGO_ANIM_CONSOLE, + /* 4 */ HGO_ANIM_CONSOLE_HEAD_UP, + /* 5 */ HGO_ANIM_REACH_DOWN_TO_LIFT, + /* 6 */ HGO_ANIM_TOSS, +} HgoAnimation; + +ActorInit En_Hgo_InitVars = { ACTOR_EN_HGO, ACTORCAT_NPC, FLAGS, @@ -40,14 +60,14 @@ const ActorInit En_Hgo_InitVars = { (ActorFunc)EnHgo_Draw, }; -static AnimationInfo sAnimations[] = { - { &object_harfgibud_Anim_00B644, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_harfgibud_Anim_013684, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_0152EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_harfgibud_Anim_015C70, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_0165F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_014220, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_harfgibud_Anim_014A9C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +static AnimationInfo sAnimationInfo[] = { + { &gPamelasFatherArmsFoldedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gPamelasFatherAstonishedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherKneelDownAndHugAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gPamelasFatherConsoleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherConsoleHeadUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherReachDownToLiftAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gPamelasFatherTossAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -72,100 +92,95 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static TexturePtr sEyeTextures[] = { - object_harfgibud_Tex_011138, - object_harfgibud_Tex_011938, - object_harfgibud_Tex_012138, -}; - -void EnHgo_Init(Actor* thisx, GlobalContext* globalCtx) { - EnHgo* this = THIS; +void EnHgo_Init(Actor* thisx, PlayState* play) { s32 pad; + EnHgo* this = THIS; 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, &gPamelasFatherHumanSkel, &gPamelasFatherArmsFoldedAnim, + this->jointTable, this->morphTable, PAMELAS_FATHER_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; - this->unk_30E = 0; - this->unk_314 = 0; - this->unk_310 = 0; - this->unk_312 = 0; - if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { - func_80BD049C(this); + + this->eyeIndex = 0; + this->blinkTimer = 0; + this->textId = 0; + this->talkFlags = TALK_FLAG_NONE; + this->isInCutscene = false; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + EnHgo_SetupTalk(this); } else { thisx->draw = NULL; - func_80BD03EC(this); + EnHgo_SetupDoNothing(this); } } -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) { +void EnHgo_SetupDoNothing(EnHgo* this) { this->actor.flags &= ~ACTOR_FLAG_1; - this->actionFunc = func_80BD0410; + this->actionFunc = EnHgo_DoNothing; } -void func_80BD0410(EnHgo* this, GlobalContext* globalCtx) { +void EnHgo_DoNothing(EnHgo* this, PlayState* play) { } -void func_80BD0420(EnHgo* this) { - this->actionFunc = func_80BD0434; +void EnHgo_SetupInitCollision(EnHgo* this) { + this->actionFunc = EnHgo_UpdateCollision; } -void func_80BD0434(EnHgo* this, GlobalContext* globalCtx) { +void EnHgo_UpdateCollision(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); - this->actionFunc = func_80BD04E0; +void EnHgo_SetupTalk(EnHgo* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + this->actionFunc = EnHgo_Talk; } -void func_80BD04E0(EnHgo* this, GlobalContext* globalCtx) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - if (Player_GetMask(globalCtx) == PLAYER_MASK_GIBDO) { - if (!(this->unk_310 & 4)) { - this->unk_310 |= 4; - Message_StartTextbox(globalCtx, 0x15A5, &this->actor); - this->unk_314 = 0x15A5; // That mask is a gibdo +void EnHgo_Talk(EnHgo* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { + if (!(this->talkFlags & TALK_FLAG_HAS_SPOKEN_WITH_GIBDO_MASK)) { + this->talkFlags |= TALK_FLAG_HAS_SPOKEN_WITH_GIBDO_MASK; + Message_StartTextbox(play, 0x15A5, &this->actor); + this->textId = 0x15A5; // That mask is a gibdo } else { - Message_StartTextbox(globalCtx, 0x15A7, &this->actor); - this->unk_314 = 0x15A7; // can I research that mask + Message_StartTextbox(play, 0x15A7, &this->actor); + this->textId = 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); - this->unk_314 = 0x158F; // Isn't this a fairy + if (!(this->talkFlags & TALK_FLAG_HAS_SPOKEN_WITH_HUMAN)) { + this->talkFlags |= TALK_FLAG_HAS_SPOKEN_WITH_HUMAN; + Message_StartTextbox(play, 0x158F, &this->actor); + this->textId = 0x158F; // Isn't this a fairy } else { - Message_StartTextbox(globalCtx, 0x1593, &this->actor); - this->unk_314 = 0x1593; // Never seen a fairy this lively + Message_StartTextbox(play, 0x1593, &this->actor); + this->textId = 0x1593; // Never seen a fairy this lively } } else { - if (!(this->unk_310 & 2)) { - this->unk_310 |= 2; - Message_StartTextbox(globalCtx, 0x1595, &this->actor); - this->unk_314 = 0x1595; // ghost radar is reacting + if (!(this->talkFlags & TALK_FLAG_HAS_SPOKEN_WITH_OTHER_MASK_FORM)) { + this->talkFlags |= TALK_FLAG_HAS_SPOKEN_WITH_OTHER_MASK_FORM; + Message_StartTextbox(play, 0x1595, &this->actor); + this->textId = 0x1595; // ghost radar is reacting } else { - Message_StartTextbox(globalCtx, 0x1598, &this->actor); - this->unk_314 = 0x1598; // you seem to be similar to a ghost + Message_StartTextbox(play, 0x1598, &this->actor); + this->textId = 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,209 +188,240 @@ 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: + EnHgo_HandlePlayerChoice(this, play); break; - case 6: - if (Message_ShouldAdvance(globalCtx)) { - func_80BD049C(this); + + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + EnHgo_SetupTalk(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)) { - switch (this->unk_314) { +// Handles the next dialogue based on player's selection +void EnHgo_HandlePlayerChoice(EnHgo* this, PlayState* play) { + if (Message_ShouldAdvance(play)) { + switch (this->textId) { case 0x158F: - Message_StartTextbox(globalCtx, 0x1590, &this->actor); - this->unk_314 = 0x1590; + Message_StartTextbox(play, 0x1590, &this->actor); + this->textId = 0x1590; break; + case 0x1590: - if (gSaveContext.save.weekEventReg[14] & 4) { - Message_StartTextbox(globalCtx, 0x1591, &this->actor); - this->unk_314 = 0x1591; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { + Message_StartTextbox(play, 0x1591, &this->actor); + this->textId = 0x1591; break; } - Message_StartTextbox(globalCtx, 0x1592, &this->actor); - this->unk_314 = 0x1592; + + Message_StartTextbox(play, 0x1592, &this->actor); + this->textId = 0x1592; break; + case 0x1591: - Message_StartTextbox(globalCtx, 0x1592, &this->actor); - this->unk_314 = 0x1592; + Message_StartTextbox(play, 0x1592, &this->actor); + this->textId = 0x1592; break; + case 0x1593: - Message_StartTextbox(globalCtx, 0x1594, &this->actor); - this->unk_314 = 0x1594; + Message_StartTextbox(play, 0x1594, &this->actor); + this->textId = 0x1594; break; + case 0x1595: - Message_StartTextbox(globalCtx, 0x1596, &this->actor); - this->unk_314 = 0x1596; + Message_StartTextbox(play, 0x1596, &this->actor); + this->textId = 0x1596; break; + case 0x1596: - Message_StartTextbox(globalCtx, 0x1597, &this->actor); - this->unk_314 = 0x1597; + Message_StartTextbox(play, 0x1597, &this->actor); + this->textId = 0x1597; break; + case 0x1598: - Message_StartTextbox(globalCtx, 0x1599, &this->actor); - this->unk_314 = 0x1599; + Message_StartTextbox(play, 0x1599, &this->actor); + this->textId = 0x1599; break; + case 0x15A5: - Message_StartTextbox(globalCtx, 0x15A6, &this->actor); - this->unk_314 = 0x15A6; + Message_StartTextbox(play, 0x15A6, &this->actor); + this->textId = 0x15A6; break; + case 0x15A6: - Message_StartTextbox(globalCtx, 0x15A7, &this->actor); - this->unk_314 = 0x15A7; + Message_StartTextbox(play, 0x15A7, &this->actor); + this->textId = 0x15A7; break; + case 0x15A7: - func_801477B4(globalCtx); - func_80BD049C(this); + func_801477B4(play); + EnHgo_SetupTalk(this); break; } } } -s32 func_80BD0898(EnHgo* this, GlobalContext* globalCtx) { +s32 EnHgo_HandleCsAction(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->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: - this->unk_218 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->animIndex = HGO_ANIM_ARMS_FOLDED; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); break; + case 2: this->actor.draw = EnHgo_Draw; - this->unk_218 = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + this->animIndex = HGO_ANIM_ASTONISHED; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; + case 3: - this->unk_218 = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + this->animIndex = HGO_ANIM_KNEEL_DOWN_AND_HUG; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); break; + case 4: - this->unk_218 = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + this->animIndex = HGO_ANIM_CONSOLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); break; + case 5: - this->unk_218 = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 4); + this->animIndex = HGO_ANIM_CONSOLE_HEAD_UP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); break; + case 6: - this->unk_218 = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 5); + this->animIndex = HGO_ANIM_REACH_DOWN_TO_LIFT; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - switch (this->unk_218) { - case 1: - 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))) { + switch (this->animIndex) { + case HGO_ANIM_ASTONISHED: + if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && + (this->isInCutscene == false)) { + this->isInCutscene = true; + if ((gSaveContext.sceneLayer == 0) && + ((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); + + case HGO_ANIM_KNEEL_DOWN_AND_HUG: + this->animIndex = HGO_ANIM_CONSOLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); break; - case 5: - this->unk_218 = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 6); + + case HGO_ANIM_REACH_DOWN_TO_LIFT: + this->animIndex = HGO_ANIM_TOSS; + 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)) && - (this->actionFunc == func_80BD0410)) { + + if ((play->csCtx.state == CS_STATE_0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && + (this->actionFunc == EnHgo_DoNothing)) { 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); + EnHgo_SetupInitCollision(this); } - this->unk_316 = 0x63; + + this->csAction = 0x63; return false; } -void func_80BD0B8C(EnHgo* this, GlobalContext* globalCtx) { - func_800E9250(globalCtx, &this->actor, &this->unk_300, &this->unk_306, this->actor.focus.pos); - if (this->unk_30E > 2) { - this->unk_30E--; - } else if (this->unk_30E == 2) { - this->unk_30C = 1; - this->unk_30E = 1; - } else if (this->unk_30E == 1) { - this->unk_30C = 2; - this->unk_30E = 0; +void EnHgo_UpdateModel(EnHgo* this, PlayState* play) { + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); + if (this->blinkTimer > 2) { + this->blinkTimer--; + } else if (this->blinkTimer == 2) { + this->eyeIndex = HGO_EYE_HALF; + this->blinkTimer = 1; + } else if (this->blinkTimer == 1) { + this->eyeIndex = HGO_EYE_CLOSED; + this->blinkTimer = 0; } else { - this->unk_30C = 0; - this->unk_30E = 60; + this->eyeIndex = HGO_EYE_OPEN; + this->blinkTimer = 60; } } -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); - } else if (this->actionFunc != func_80BD0410) { - if (this->actionFunc != func_80BD0434) { + if (EnHgo_HandleCsAction(this, play)) { + Actor_TrackNone(&this->headRot, &this->torsoRot); + } else if (this->actionFunc != EnHgo_DoNothing) { + if (this->actionFunc != EnHgo_UpdateCollision) { 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); + EnHgo_UpdateModel(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 == PAMELAS_FATHER_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_Get(&this->unk_1D8); + if (limbIndex == PAMELAS_FATHER_HUMAN_LIMB_HEAD) { + Matrix_Get(&this->mf); Matrix_MultZero(&this->actor.focus.pos); } } -void EnHgo_Draw(Actor* thisx, GlobalContext* globalCtx) { +static TexturePtr sEyeTextures[] = { + gPamelasFatherHumanEyeOpenTex, + gPamelasFatherHumanEyeHalfTex, + gPamelasFatherHumanEyeClosedTex, +}; + +void EnHgo_Draw(Actor* thisx, PlayState* play) { EnHgo* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->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, + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(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, EnHgo_OverrideLimbDraw, &EnHgo_PostLimbDraw, &this->actor); - Matrix_Put(&this->unk_1D8); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_harfgibud_DL_00F248); - CLOSE_DISPS(globalCtx->state.gfxCtx); + Matrix_Put(&this->mf); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gPamelasFatherHumanEyebrowsDL); + 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..6882c1127 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h @@ -2,54 +2,29 @@ #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; /* 0x144 */ ColliderCylinder collider; /* 0x190 */ SkelAnime skelAnime; /* 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; - /* 0x30C */ s16 unk_30C; - /* 0x30E */ s16 unk_30E; - /* 0x310 */ s16 unk_310; - /* 0x312 */ s16 unk_312; - /* 0x314 */ u16 unk_314; - /* 0x316 */ u16 unk_316; + /* 0x1D8 */ MtxF mf; + /* 0x218 */ s32 animIndex; + /* 0x21C */ Vec3s jointTable[PAMELAS_FATHER_HUMAN_LIMB_MAX]; + /* 0x28E */ Vec3s morphTable[PAMELAS_FATHER_HUMAN_LIMB_MAX]; + /* 0x300 */ Vec3s headRot; + /* 0x306 */ Vec3s torsoRot; // Set, but not used + /* 0x30C */ s16 eyeIndex; + /* 0x30E */ s16 blinkTimer; + /* 0x310 */ s16 talkFlags; + /* 0x312 */ s16 isInCutscene; + /* 0x314 */ u16 textId; + /* 0x316 */ u16 csAction; } EnHgo; // size = 0x318 -extern const ActorInit En_Hgo_InitVars; - #endif // Z_EN_HGO_H diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/overlay.cfg b/src/overlays/actors/ovl_En_Hidden_Nuts/overlay.cfg deleted file mode 100644 index 491a14d60..000000000 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hidden_Nuts -z_en_hidden_nuts.c 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..d8df99887 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,32 +5,33 @@ */ #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 = { +ActorInit En_Hidden_Nuts_InitVars = { ACTOR_EN_HIDDEN_NUTS, ACTORCAT_PROP, FLAGS, @@ -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,26 +94,26 @@ void EnHiddenNuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->switchFlag = -1; } - if ((this->switchFlag >= 0) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - Actor_MarkForDeath(&this->actor); + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&this->actor); return; } if (this->unk_21E == 0x1F) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); 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,13 +141,13 @@ 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); - if (player->stateFlags2 & 0x8000000) { + if (player->stateFlags2 & PLAYER_STATE2_8000000) { if (this->unk_20A == 0) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); this->unk_20A = 1; @@ -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,20 @@ 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, + true); } 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 +199,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 +219,14 @@ 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, + true); } 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 +240,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 +260,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 +282,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 +293,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,13 +307,13 @@ 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; if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_208, &this->unk_20C)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } this->actor.speedXZ = 2.0f; @@ -323,7 +324,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 +332,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,24 +375,24 @@ 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); + Actor_Kill(&this->actor); } } } } -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 +401,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); - Actor_MarkForDeath(&this->actor); + EffectSsHahen_SpawnBurst(play, &sp38, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + Actor_Kill(&this->actor); } } -void EnHiddenNuts_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnHiddenNuts_Update(Actor* thisx, PlayState* play) { s32 pad; EnHiddenNuts* this = THIS; @@ -417,22 +417,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..e40a89193 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,34 +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; - #endif // Z_EN_HIDDEN_NUTS_H diff --git a/src/overlays/actors/ovl_En_Hint_Skb/overlay.cfg b/src/overlays/actors/ovl_En_Hint_Skb/overlay.cfg deleted file mode 100644 index 95449a9a4..000000000 --- a/src/overlays/actors/ovl_En_Hint_Skb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hint_Skb -z_en_hint_skb.c 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 c9b9485ce..c07bbc5da 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,40 +5,41 @@ */ #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 = { +ActorInit En_Hint_Skb_InitVars = { ACTOR_EN_HINT_SKB, ACTORCAT_NPC, FLAGS, @@ -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,18 +147,18 @@ 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; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->unk_3E4 = 0; this->unk_3DE = 0; this->unk_3E0 = 0; @@ -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,13 +324,13 @@ 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); - Actor_MarkForDeath(&this->actor); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x10); + Actor_Kill(&this->actor); } void func_80C20540(EnHintSkb* this) { @@ -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,24 +580,24 @@ 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.hintId = TATL_HINT_ID_NONE; 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; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->actor.textId = 0; if (this->skelAnime.animation == &object_skb_Anim_00697C) { func_80C1FE0C(this); @@ -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,26 +836,25 @@ 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_MultZero(&this->actor.focus.pos); } else if ((limbIndex == 12) && (this->unk_3DE == 1)) { @@ -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,11 +876,11 @@ 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) { @@ -893,15 +897,15 @@ void EnHintSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } -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..22f72084d 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,33 +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; - #endif // Z_EN_HINT_SKB_H diff --git a/src/overlays/actors/ovl_En_Hit_Tag/overlay.cfg b/src/overlays/actors/ovl_En_Hit_Tag/overlay.cfg deleted file mode 100644 index e7ee964c9..000000000 --- a/src/overlays/actors/ovl_En_Hit_Tag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hit_Tag -z_en_hit_tag.c 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..c76d92106 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,13 +10,13 @@ #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 = { +ActorInit En_Hit_Tag_InitVars = { ACTOR_EN_HIT_TAG, ACTORCAT_ITEMACTION, FLAGS, @@ -48,45 +48,45 @@ 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))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, ENHITTAG_GET_SWITCHFLAG(thisx))) { + Actor_Kill(&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; if (this->collider.base.acFlags & AC_HIT) { play_sound(NA_SE_SY_GET_RUPY); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); dropLocation.x = this->actor.world.pos.x; dropLocation.y = this->actor.world.pos.y; 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..e2effa078 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,16 +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; - #endif // Z_EN_HIT_TAG_H diff --git a/src/overlays/actors/ovl_En_Holl/overlay.cfg b/src/overlays/actors/ovl_En_Holl/overlay.cfg deleted file mode 100644 index 35c8d8f8e..000000000 --- a/src/overlays/actors/ovl_En_Holl/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Holl -z_en_holl.c 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 c3d577e7a..e7615d25f 100644 --- a/src/overlays/actors/ovl_En_Holl/z_en_holl.c +++ b/src/overlays/actors/ovl_En_Holl/z_en_holl.c @@ -43,21 +43,21 @@ #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 = { +ActorInit En_Holl_InitVars = { ACTOR_EN_HOLL, ACTORCAT_DOOR, FLAGS, @@ -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,82 +121,82 @@ 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.curRoom; - globalCtx->roomCtx.currRoom = globalCtx->roomCtx.prevRoom; - globalCtx->roomCtx.prevRoom = tempRoom; - globalCtx->roomCtx.activeMemPage ^= 1; + play->roomCtx.curRoom = 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); + Actor_Kill(&this->actor); return; } if (this == sInstancePlayingSound) { 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->sceneId == 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.curRoom.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->sceneId == 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->sceneId == 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.curRoom.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.curRoom.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.curRoom.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 & PLAYER_STATE1_200)) { + 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; @@ -332,7 +333,7 @@ void EnHoll_Draw(Actor* thisx, GlobalContext* globalCtx) { if (this->playerSide == EN_HOLL_BEHIND) { 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..e4d8791ba 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) @@ -72,6 +71,4 @@ typedef struct EnHoll { #define EN_HOLL_SCALE_ALPHA(playerDistFromCentralPlane) ((playerDistFromCentralPlane - sTransparencyPlaneDistance) * (255 / (sTranslucencyPlaneDistance - sTransparencyPlaneDistance))) #define EN_HOLL_SCALE_BG_COVER_ALPHA(playerDistFromCentralPlane) ((EN_HOLL_ACTIVATION_PLANE_DISTANCE_VERTICAL - playerDistFromCentralPlane) * (255 / (EN_HOLL_ACTIVATION_PLANE_DISTANCE_VERTICAL - EN_HOLL_LOADING_PLANE_DISTANCE_VERTICAL))) -extern const ActorInit En_Holl_InitVars; - #endif // Z_EN_HOLL_H diff --git a/src/overlays/actors/ovl_En_Honotrap/overlay.cfg b/src/overlays/actors/ovl_En_Honotrap/overlay.cfg deleted file mode 100644 index 4a20640de..000000000 --- a/src/overlays/actors/ovl_En_Honotrap/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Honotrap -z_en_honotrap.c 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 0b2d38c7a..97804d2f4 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.c @@ -11,33 +11,33 @@ #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); -void func_8092E638(EnHonotrap* this, GlobalContext* globalCtx); // d -void func_8092E840(EnHonotrap* this, GlobalContext* globalCtx); // d -void func_8092E988(EnHonotrap* this, GlobalContext* globalCtx); // d -void func_8092FE44(Actor* thisx, GlobalContext* globalCtx); -void func_8092FEFC(Actor* thisx, GlobalContext* globalCtx); -void func_80930030(Actor* thisx, GlobalContext* globalCtx); -void func_80930190(Actor* thisx, GlobalContext* globalCtx); +void func_8092E638(EnHonotrap* this, PlayState* play); // d +void func_8092E840(EnHonotrap* this, PlayState* play); // d +void func_8092E988(EnHonotrap* this, PlayState* play); // d +void func_8092FE44(Actor* thisx, PlayState* play); +void func_8092FEFC(Actor* thisx, PlayState* play); +void func_80930030(Actor* thisx, PlayState* play); +void func_80930190(Actor* thisx, PlayState* play); void func_8092EBC0(EnHonotrap* this); void func_8092EE68(EnHonotrap* this); @@ -45,7 +45,7 @@ void func_8092F0F8(EnHonotrap* this); void func_8092F854(EnHonotrap* this); #if 0 -const ActorInit En_Honotrap_InitVars = { +ActorInit En_Honotrap_InitVars = { ACTOR_EN_HONOTRAP, ACTORCAT_PROP, FLAGS, @@ -72,7 +72,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 = { @@ -106,7 +106,7 @@ extern InitChainEntry D_809304E0[]; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_8092E5A4.s") // EnHonotrap_InitEye -void func_8092E638(EnHonotrap* this, GlobalContext* globalCtx) { +void func_8092E638(EnHonotrap* this, PlayState* play) { s32 i; s32 j; s32 k; @@ -126,8 +126,8 @@ void func_8092E638(EnHonotrap* this, GlobalContext* globalCtx) { } } - Collider_InitTris(globalCtx, &this->collider.tris); - Collider_SetTris(globalCtx, &this->collider.tris, &this->actor, &D_8093049C, this->collider.elements); + Collider_InitTris(play, &this->collider.tris); + Collider_SetTris(play, &this->collider.tris, &this->actor, &D_8093049C, this->collider.elements); for (i = 0; i < 2; i++) { for (j = 0, vtx = sp70; j < 3; j++, vtx++) { @@ -150,20 +150,20 @@ void func_8092E638(EnHonotrap* this, GlobalContext* globalCtx) { } // EnHonotrap_InitFlame -void func_8092E840(EnHonotrap* this, GlobalContext* globalCtx) { +void func_8092E840(EnHonotrap* this, PlayState* play) { s32 pad[2]; s32 params; params = this->actor.params; Actor_SetScale(&this->actor, 0.0001f); - Collider_InitCylinder(globalCtx, &this->collider.cyl); - Collider_SetCylinder(globalCtx, &this->collider.cyl, &this->actor, &D_809304AC); + Collider_InitCylinder(play, &this->collider.cyl); + Collider_SetCylinder(play, &this->collider.cyl, &this->actor, &D_809304AC); Collider_UpdateCylinder(&this->actor, &this->collider.cyl); this->actor.terminalVelocity = -1.0f; CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &D_809304D8); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.shape.shadowAlpha = 0x80; - this->unk228 = GET_PLAYER(globalCtx)->actor.world.pos; + this->unk228 = GET_PLAYER(play)->actor.world.pos; this->unk228.y += 10.0f; this->unk23A = Rand_ZeroOne() * 511.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_FLAME_IGNITION); @@ -176,14 +176,14 @@ void func_8092E840(EnHonotrap* this, GlobalContext* globalCtx) { func_8092F0F8(this); } -void func_8092E988(EnHonotrap* this, GlobalContext* globalCtx) { +void func_8092E988(EnHonotrap* this, PlayState* play) { EnHonotrap23C* var_s2; s32 var_s0; s32 i; Actor_SetScale(&this->actor, 0.0001f); - Collider_InitCylinder(globalCtx, &this->collider.cyl); - Collider_SetCylinder(globalCtx, &this->collider.cyl, &this->actor, &D_809304AC); + Collider_InitCylinder(play, &this->collider.cyl); + Collider_SetCylinder(play, &this->collider.cyl, &this->actor, &D_809304AC); CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &D_809304D8); var_s0 = Rand_ZeroOne() * 511.0f; @@ -198,36 +198,36 @@ void func_8092E988(EnHonotrap* this, GlobalContext* globalCtx) { func_8092F854(this); } -void EnHonotrap_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnHonotrap_Init(Actor* thisx, PlayState* play) { s32 params; EnHonotrap* this = (EnHonotrap*)thisx; params = this->actor.params; Actor_ProcessInitChain(&this->actor, D_809304E0); if ((params == 0) || (params == 3)) { - func_8092E638(this, globalCtx); + func_8092E638(this, play); } else if (params == 4) { - func_8092E988(this, globalCtx); + func_8092E988(this, play); this->actor.update = func_8092FEFC; this->actor.draw = func_80930190; this->actor.uncullZoneScale = 500.0f; this->actor.uncullZoneDownward = 500.0f; } else { - func_8092E840(this, globalCtx); + func_8092E840(this, play); this->actor.update = func_8092FE44; this->actor.draw = func_80930030; } } -void EnHonotrap_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnHonotrap_Destroy(Actor* thisx, PlayState* play) { s16 params; EnHonotrap* this = (EnHonotrap*)thisx; params = this->actor.params; if ((params == 0) || (params == 3)) { - Collider_DestroyTris(globalCtx, &this->collider.tris); + Collider_DestroyTris(play, &this->collider.tris); } else { - Collider_DestroyCylinder(globalCtx, &this->collider.cyl); + Collider_DestroyCylinder(play, &this->collider.cyl); } } @@ -301,7 +301,7 @@ void func_8092F854(EnHonotrap* this) { #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/EnHonotrap_Update.s") -void func_8092FE44(Actor* thisx, GlobalContext* globalCtx) { +void func_8092FE44(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; if (this->unk220 > 0) { @@ -314,12 +314,12 @@ void func_8092FE44(Actor* thisx, GlobalContext* globalCtx) { } Actor_SetFocus(&this->actor, 5.0f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->unk23A -= 0x14; this->unk23A &= 0x1FF; } -void func_8092FEFC(Actor* thisx, GlobalContext* globalCtx) { +void func_8092FEFC(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; Actor* temp_v0; @@ -332,40 +332,40 @@ void func_8092FEFC(Actor* thisx, GlobalContext* globalCtx) { } this->unk238 += 0x640; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/EnHonotrap_Draw.s") -void func_80930030(Actor* thisx, GlobalContext* globalCtx) { +void func_80930030(Actor* thisx, PlayState* play) { s32 pad; EnHonotrap* this = (EnHonotrap*)thisx; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, this->unk23A, 32, 128)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, this->unk23A, 32, 128)); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - Matrix_RotateYS(Camera_GetCamDirYaw(globalCtx->cameraPtrs[globalCtx->activeCamera]) + 0x8000, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + Matrix_RotateYS(Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamId]) + 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++, gEffFire1DL); + CLOSE_DISPS(play->state.gfxCtx); } #ifdef NON_MATCHING -void func_80930190(Actor* thisx, GlobalContext* globalCtx) { +void func_80930190(Actor* thisx, PlayState* play) { EnHonotrap* this = (EnHonotrap*)thisx; Vec3s spB8; EnHonotrapArr* temp_s0; EnHonotrap23C* var_s3; s32 i; // s4 - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 200, 0, 255); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); - func_800DFC90(&spB8, globalCtx->cameraPtrs[globalCtx->activeCamera]); + func_800DFC90(&spB8, play->cameraPtrs[play->activeCamId]); spB8.y += 0x8000; var_s3 = &this->unk23C; for (i = 0; i < 6; i++) { @@ -373,19 +373,19 @@ void func_80930190(Actor* thisx, GlobalContext* globalCtx) { if (temp_s0->unk12 != 0) { gSPSegment( POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, temp_s0->unk_10, 0x20, 0x80)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, temp_s0->unk_10, 0x20, 0x80)); Matrix_SetTranslateRotateYXZ(temp_s0->unk0.x, temp_s0->unk0.y - (4000.0f * temp_s0->unkC), temp_s0->unk0.z, &spB8); // temp_fa1 = temp_s0->unkC; Matrix_Scale(((fabsf(Math_SinS((s16)(spB8.y - this->actor.shape.rot.y) >> 1)) * 0.2f) + 1.7f) * temp_s0->unkC, temp_s0->unkC, 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); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #else #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Honotrap/func_80930190.s") 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 2e3174648..f53bdac73 100644 --- a/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h +++ b/src/overlays/actors/ovl_En_Honotrap/z_en_honotrap.h @@ -5,7 +5,7 @@ struct EnHonotrap; -typedef void (*EnHonotrapActionFunc)(struct EnHonotrap*, GlobalContext*); +typedef void (*EnHonotrapActionFunc)(struct EnHonotrap*, PlayState*); typedef union { struct { @@ -43,6 +43,4 @@ typedef struct EnHonotrap { /* 0x2C0 */ s8 unk2C0; } EnHonotrap; // size = 0x2C4 -extern const ActorInit En_Honotrap_InitVars; - #endif // Z_EN_HONOTRAP_H diff --git a/src/overlays/actors/ovl_En_Horse/overlay.cfg b/src/overlays/actors/ovl_En_Horse/overlay.cfg deleted file mode 100644 index 90043637c..000000000 --- a/src/overlays/actors/ovl_En_Horse/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Horse -z_en_horse.c 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 a0756abdf..5ffc364c3 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* play2); +void EnHorse_Destroy(Actor* thisx, PlayState* play); +void EnHorse_Update(Actor* thisx, PlayState* play2); +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,29 +108,43 @@ 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, }; -const ActorInit En_Horse_InitVars = { +ActorInit En_Horse_InitVars = { ACTOR_EN_HORSE, ACTORCAT_BG, FLAGS, @@ -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 != 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,11 +693,11 @@ void EnHorse_ClearDustFlags(u16* dustFlags) { void func_8087C9F8(EnHorse* this) { } -void func_8087CA04(EnHorse* this, GlobalContext* globalCtx) { +void func_8087CA04(EnHorse* this, PlayState* play) { } -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; @@ -693,54 +716,54 @@ 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) { - Actor_MarkForDeath(&this->actor); + if ((this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HA)) < 0) { + Actor_Kill(&this->actor); return; } this->unk_1EC |= 1; thisx->update = func_8087D540; - } else if (ENHORSE_GET_4000(&this->actor)) { - this->type = HORSE_2; + } 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) { - thisx->objBankIndex = Object_Spawn(&globalCtx->objectCtx, OBJECT_HORSE_LINK_CHILD); - Actor_SetObjectDependency(globalCtx, &this->actor); - Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); - Animation_PlayOnce(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animationIdx]); + 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 { 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) { - Actor_MarkForDeath(&this->actor); + if ((this->bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_HA)) < 0) { + Actor_Kill(&this->actor); return; } this->unk_1EC |= 1; thisx->update = func_8087D540; } else { - this->type = HORSE_EPONA; + this->type = HORSE_TYPE_EPONA; this->boostSpeed = 15; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } - thisx->params &= ~0xE000; - if (thisx->params == 0x1FFF) { - thisx->params = ENHORSE_1; + this->actor.params &= ~(ENHORSE_PARAM_DONKEY | ENHORSE_PARAM_4000 | ENHORSE_PARAM_BANDIT); + if (this->actor.params == 0x1FFF) { + this->actor.params = ENHORSE_1; } if (thisx->params == ENHORSE_3) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP | ENHORSE_UNRIDEABLE; } else if (thisx->params == ENHORSE_8) { this->stateFlags = ENHORSE_FLAG_19 | ENHORSE_CANT_JUMP; - if (CHECK_QUEST_ITEM(14)) { + if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { this->stateFlags &= ~ENHORSE_CANT_JUMP; this->stateFlags |= ENHORSE_FLAG_26; } @@ -769,42 +792,42 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { 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->sceneId == SCENE_KOEPONARACE) && (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_START)) || + ((gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && (Cutscene_GetSceneLayer(play) != 0))) { this->stateFlags |= ENHORSE_FLAG_25; } thisx->gravity = -3.5f; ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawHorse, 20.0f); - this->action = ENHORSE_ACT_IDLE; + 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(&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); @@ -815,51 +838,48 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { thisx->focus.pos.y += 70.0f; if (!(this->unk_1EC & 1) && !(this->unk_1EC & 0x200) && (thisx->update == EnHorse_Update)) { - Skin_Init(&globalCtx->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); + 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 (thisx->params == ENHORSE_2) { this->unk_53C = 0; EnHorse_InitInactive(this); } else if (thisx->params == ENHORSE_3) { EnHorse_InitIngoHorse(this); - this->rider = - (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, - thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); + this->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 (thisx->params == ENHORSE_4) { func_80881634(this); this->unk_398 = 14.34f; - this->rider = - (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, - thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 1); + this->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 (thisx->params == ENHORSE_5) { func_80881634(this); this->unk_398 = 14.525f; - this->rider = - (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, - thisx->world.pos.z, thisx->shape.rot.x, thisx->shape.rot.y, 1, 2); + this->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 (thisx->params == ENHORSE_9) { - EnHorse_InitCutscene(this, globalCtx); + EnHorse_InitCutscene(this, play); } else if (thisx->params == ENHORSE_10) { EnHorse_InitHorsebackArchery(this); - func_80112AFC(globalCtx); + Interface_InitMinigame(play); } else if (thisx->params == ENHORSE_14) { - func_808846F0(this, globalCtx); - if ((globalCtx->sceneNum == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(globalCtx)) { - Actor_MarkForDeath(&this->actor); + func_808846F0(this, play); + if ((play->sceneId == SCENE_LOST_WOODS) && !Cutscene_IsPlaying(play)) { + Actor_Kill(&this->actor); } } else if (thisx->params == ENHORSE_16) { func_8087C9F8(this); @@ -870,16 +890,16 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { } else if (thisx->params == ENHORSE_19) { EnIn* in; - func_80884D04(this, globalCtx); - in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + 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 (thisx->params == ENHORSE_20) { EnIn* in; - func_80884D04(this, globalCtx); - in = (EnIn*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_IN, thisx->world.pos.x, thisx->world.pos.y, + 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); @@ -891,7 +911,7 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { thisx->world.rot.z = thisx->shape.rot.z; thisx->home.rot.z = thisx->shape.rot.z; this->unk_3EC = thisx->world.rot.y; - this->unk_538 = 0; + this->unk_538 = OBJ_UM_ANIM_TROT; if (this->unk_1EC & 0x100) { this->colliderCylinder1.base.colType = COLTYPE_HIT3; @@ -905,53 +925,54 @@ void EnHorse_Init(Actor* thisx, GlobalContext* globalCtx2) { } } -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; @@ -959,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) { @@ -980,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); @@ -995,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); @@ -1005,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) { @@ -1022,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) { @@ -1044,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; } @@ -1096,33 +1117,34 @@ 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); } } } + 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) { @@ -1142,19 +1164,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); @@ -1162,14 +1184,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) { @@ -1188,24 +1210,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); @@ -1220,7 +1242,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 { @@ -1251,23 +1273,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; @@ -1276,7 +1298,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; } @@ -1323,23 +1345,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); @@ -1349,7 +1371,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) { @@ -1367,43 +1389,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; @@ -1417,10 +1439,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 { @@ -1433,19 +1455,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); @@ -1453,19 +1475,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; @@ -1473,19 +1495,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; @@ -1507,37 +1529,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) { @@ -1548,15 +1570,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_GetSceneLayer(play) == 0))) { 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); @@ -1588,22 +1610,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)) { @@ -1621,8 +1643,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; @@ -1646,7 +1668,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); @@ -1659,21 +1681,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; @@ -1683,18 +1705,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; @@ -1712,8 +1734,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; @@ -1743,34 +1764,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; @@ -1782,18 +1803,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; @@ -1811,8 +1832,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; @@ -1841,17 +1861,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); } } @@ -1859,17 +1879,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; @@ -1878,7 +1898,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; @@ -1887,10 +1907,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; } @@ -1898,22 +1918,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); @@ -1922,8 +1942,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); } } @@ -1933,8 +1953,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) { @@ -1942,24 +1962,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); @@ -1970,43 +1990,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; @@ -2014,13 +2034,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) { @@ -2028,7 +2048,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 { @@ -2039,19 +2059,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) { @@ -2061,9 +2081,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) { @@ -2071,24 +2091,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; @@ -2103,7 +2123,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); @@ -2113,9 +2133,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); } @@ -2124,7 +2144,7 @@ void EnHorse_FollowPlayer(EnHorse* this, GlobalContext* globalCtx) { if (distToPlayer < 100.0f) { EnHorse_StartIdleRidable(this); } else { - EnHorse_SetFollowAnimation(this, globalCtx); + EnHorse_SetFollowAnimation(this, play); } } } @@ -2139,13 +2159,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; } } } @@ -2154,43 +2174,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); @@ -2200,40 +2220,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; @@ -2241,37 +2259,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; @@ -2303,28 +2321,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; @@ -2346,43 +2364,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); @@ -2391,60 +2409,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; @@ -2452,26 +2468,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_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_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; @@ -2480,7 +2496,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 { @@ -2490,26 +2506,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; @@ -2520,28 +2536,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; } @@ -2570,19 +2586,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; @@ -2593,28 +2609,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); @@ -2623,21 +2639,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; @@ -2646,13 +2662,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; @@ -2661,7 +2677,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 { @@ -2671,13 +2687,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; @@ -2686,28 +2702,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); @@ -2716,23 +2732,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; } @@ -2753,15 +2769,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; } @@ -2779,14 +2795,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; @@ -2809,7 +2825,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; @@ -2837,104 +2853,103 @@ 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.minigameAmmo == 0) { this->hbaTimer++; } - sp28 = Audio_IsSequencePlaying(0x41); - EnHorse_UpdateHbaRaceInfo(this, globalCtx, &sHbaInfo); + sp28 = Audio_IsSequencePlaying(NA_BGM_HORSE_GOAL); + EnHorse_UpdateHbaRaceInfo(this, play, &sHbaInfo); - if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && (gSaveContext.minigameState != 3)) { + if (((this->hbaFlags & 1) || (this->hbaTimer > 45)) && (sp28 != 1) && + (gSaveContext.minigameStatus != MINIGAME_STATUS_END)) { 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.minigameAmmo) {} - if (((globalCtx->interfaceCtx.hbaAmmo == 0) || (this->hbaFlags & 2)) && (this->hbaFlags & 4)) { + if (((play->interfaceCtx.minigameAmmo == 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; @@ -2942,23 +2957,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); } } -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 = this->animationIdx; + 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); @@ -2995,25 +3010,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; @@ -3033,63 +3049,63 @@ 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); } } @@ -3104,38 +3120,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, @@ -3143,65 +3158,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; @@ -3210,17 +3223,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; @@ -3229,8 +3242,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); @@ -3238,7 +3251,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; @@ -3247,8 +3260,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); @@ -3259,26 +3272,26 @@ void func_80884604(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* ac } } -void func_808846B4(EnHorse* this, GlobalContext* globalCtx, CsCmdActorAction* action) { - Actor_MarkForDeath(&this->actor); +void func_808846B4(EnHorse* this, PlayState* play, CsCmdActorAction* action) { + Actor_Kill(&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) { @@ -3295,24 +3308,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); @@ -3328,75 +3341,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; @@ -3404,36 +3417,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; } } @@ -3443,25 +3455,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 } @@ -3476,25 +3488,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->sceneId != 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; @@ -3515,7 +3527,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; @@ -3533,48 +3545,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; } @@ -3591,7 +3603,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; } @@ -3602,17 +3614,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; @@ -3627,24 +3639,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); } } @@ -3654,15 +3666,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; @@ -3683,7 +3695,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; @@ -3698,13 +3710,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; @@ -3729,15 +3740,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); @@ -3745,7 +3756,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) && @@ -3754,7 +3765,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); @@ -3767,7 +3778,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; } @@ -3780,7 +3791,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, GlobalContext* globalCtx) { movingFast = true; } } else { - EnHorse_BgCheckSlowMoving(this, globalCtx); + EnHorse_BgCheckSlowMoving(this, play); return; } @@ -3795,7 +3806,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; @@ -3803,29 +3814,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->sceneId != 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) { @@ -3833,7 +3843,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; @@ -3848,7 +3858,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; @@ -3867,28 +3877,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->sceneId != 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->sceneId != 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; @@ -3898,12 +3908,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; @@ -3927,7 +3937,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; @@ -3940,18 +3950,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->sceneId != 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->sceneId != SCENE_KOEPONARACE)) { this->stateFlags |= ENHORSE_FORCE_REVERSING; - EnHorse_StartBraking(this, globalCtx); + EnHorse_StartBraking(this, play); } } else { temp_f0 = (this->actor.scale.y * 100.0f); @@ -3979,16 +3989,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; @@ -3996,7 +4006,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; @@ -4007,7 +4017,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); @@ -4016,23 +4026,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); } @@ -4046,15 +4047,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); } } @@ -4062,7 +4056,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); @@ -4070,11 +4064,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); @@ -4096,7 +4090,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; @@ -4120,16 +4114,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; @@ -4147,54 +4141,54 @@ s32 EnHorse_RandInt(f32 arg0) { } static EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - func_808819D8, - func_80881398, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, - func_80884718, - func_8087CA04, - func_808848C8, - func_80884A40, - func_80884E0C, + 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, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +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 = thisx->shape.rot.y; - EnHorse_UpdateStick(this, globalCtx); - EnHorse_UpdatePlayerDir(this, globalCtx); + 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) { @@ -4202,17 +4196,17 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { 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 = thisx->world.rot.y; - if ((this->animationIdx == ENHORSE_ANIM_STOPPING) || (this->animationIdx == ENHORSE_ANIM_REARING)) { + if ((this->animIndex == ENHORSE_ANIM_STOPPING) || (this->animIndex == ENHORSE_ANIM_REARING)) { this->skin.skelAnime.jointTable[0].y += 0x154; } @@ -4220,32 +4214,32 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { 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) { 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)) { + 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_ACT_MOUNTED_IDLE_WHINNEYING) { + } else if (this->action == ENHORSE_ACTION_6) { EnIn* in = this->rider; s16 jnt = in->jointTable[0].y; @@ -4264,16 +4258,16 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { } 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)) { @@ -4296,7 +4290,7 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { 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(thisx->shape.rot.y) * 11.0f) + this->colliderCylinder1.dim.pos.x; this->colliderCylinder1.dim.pos.z = @@ -4316,25 +4310,25 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { (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); + 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) { @@ -4371,26 +4365,26 @@ void EnHorse_Update(Actor* thisx, GlobalContext* globalCtx2) { 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; } } -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; } @@ -4402,7 +4396,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) { @@ -4418,7 +4412,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; } @@ -4430,16 +4424,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) { @@ -4448,7 +4442,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 }; @@ -4462,7 +4456,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 { @@ -4477,15 +4471,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) { @@ -4494,11 +4488,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); @@ -4508,7 +4502,7 @@ 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 { Skin_GetLimbPos(skin, 28, &hoofOffset, &sp64); @@ -4520,7 +4514,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); @@ -4532,17 +4526,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); @@ -4550,7 +4544,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); @@ -4558,7 +4552,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); @@ -4566,18 +4560,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); @@ -4586,18 +4580,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); @@ -4607,7 +4601,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); @@ -4639,11 +4633,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, @@ -4653,24 +4647,24 @@ 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; @@ -4680,17 +4674,17 @@ s32 func_80888D18(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p 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) { @@ -4698,12 +4692,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/overlay.cfg b/src/overlays/actors/ovl_En_Horse_Game_Check/overlay.cfg deleted file mode 100644 index b950cc9c2..000000000 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Horse_Game_Check -z_en_horse_game_check.c 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 ae5f25c87..e97deee04 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,31 +11,31 @@ #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 = { +ActorInit En_Horse_Game_Check_InitVars = { ACTOR_EN_HORSE_GAME_CHECK, ACTORCAT_BG, FLAGS, @@ -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; @@ -59,20 +59,20 @@ s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 0); - if (GET_RACE_FLAGS != RACE_FLAG_START) { - Actor_MarkForDeath(&this->dyna.actor); + if (GET_WEEKEVENTREG_RACE_FLAGS != WEEKEVENTREG_RACE_FLAG_START) { + Actor_Kill(&this->dyna.actor); return false; } CollisionHeader_GetVirtual(&object_horse_game_check_Colheader_003918, &sp78); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp78); + this->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); @@ -87,93 +87,93 @@ s32 func_808F8AA0(EnHorseGameCheck* this, GlobalContext* globalCtx) { 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; this->unk_174 = 0; - if (GET_RACE_FLAGS != RACE_FLAG_START) { - Actor_MarkForDeath(&this->dyna.actor); + if (GET_WEEKEVENTREG_RACE_FLAGS != WEEKEVENTREG_RACE_FLAG_START) { + Actor_Kill(&this->dyna.actor); return false; } - func_8010E9F0(4, 0); - globalCtx->interfaceCtx.unk_280 = 1; + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; - 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); - func_800FE484(); + 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); + Environment_StopTime(); return false; } -s32 func_808F8E94(EnHorseGameCheck* this, GlobalContext* globalCtx) { - gSaveContext.unk_3DD0[4] = 0; +s32 func_808F8E94(EnHorseGameCheck* this, PlayState* play) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; 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; - } else if (GET_RACE_FLAGS == RACE_FLAG_2) { - globalCtx->unk_1887F = 0x50; - gSaveContext.nextTransition = 3; - } else if (GET_RACE_FLAGS == RACE_FLAG_4) { - SET_RACE_FLAGS(RACE_FLAG_3); - globalCtx->unk_1887F = 2; - gSaveContext.nextTransition = 2; + if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_3) { + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; + } else if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_2) { + play->transitionType = TRANS_TYPE_80; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + } else if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_4) { + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_3); + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_02; } D_801BDA9C = 0; - if (player->stateFlags1 & 0x800000) { + if (player->stateFlags1 & PLAYER_STATE1_800000) { 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.minigameState >= MINIGAME_STATE_COUNTDOWN_GO) && !(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.minigameState >= MINIGAME_STATE_COUNTDOWN_GO) && !(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,17 +242,17 @@ 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; } - if (gSaveContext.unk_3DE0[4] >= 0x4650) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(180)) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; - gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_4); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_4); this->unk_174 = 60; } @@ -277,15 +277,15 @@ 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)) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x40000; - gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_3); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_3); this->unk_174 = 60; } @@ -310,15 +310,15 @@ 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)) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x02000000; - gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_3); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_3); this->unk_174 = 60; } @@ -339,21 +339,21 @@ 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)) { Audio_QueueSeqCmd(0x8041); play_sound(NA_SE_SY_START_SHOT); this->unk_164 |= 0x800; - gSaveContext.unk_3DD0[4] = 6; - SET_RACE_FLAGS(RACE_FLAG_2); + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_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,13 +362,13 @@ 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); @@ -383,12 +383,12 @@ s32 func_808F96E4(EnHorseGameCheck* this, GlobalContext* globalCtx) { 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 886187b49..d43f1f90c 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) @@ -25,22 +25,6 @@ enum { /* 10 */ ENHORSEGAMECHECK_FF_MAX, }; -#define RACE_FLAG_END 0 -#define RACE_FLAG_START 1 -#define RACE_FLAG_2 2 -#define RACE_FLAG_3 3 -#define RACE_FLAG_4 4 -#define RACE_FLAGS 7 - -#define GET_RACE_FLAGS (gSaveContext.save.weekEventReg[92] & RACE_FLAGS) - -#define SET_RACE_FLAGS(flag) \ - { \ - gSaveContext.save.weekEventReg[92] &= (u8)~RACE_FLAGS; \ - gSaveContext.save.weekEventReg[92] = \ - gSaveContext.save.weekEventReg[92] | (u8)((gSaveContext.save.weekEventReg[92] & ~RACE_FLAGS) | (flag)); \ - } (void)0 - typedef struct EnHorseGameCheck { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ s32 unk_15C; @@ -55,6 +39,4 @@ typedef struct EnHorseGameCheck { /* 0x180 */ UNK_TYPE1 pad180[0x38]; } EnHorseGameCheck; // size = 0x1B8 -extern const ActorInit En_Horse_Game_Check_InitVars; - #endif // Z_EN_HORSE_GAME_CHECK_H diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/overlay.cfg b/src/overlays/actors/ovl_En_Horse_Link_Child/overlay.cfg deleted file mode 100644 index 09ec53e20..000000000 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Horse_Link_Child -z_en_horse_link_child.c 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..a10504720 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,18 +5,28 @@ */ #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); -#if 0 -const ActorInit En_Horse_Link_Child_InitVars = { +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); + +ActorInit En_Horse_Link_Child_InitVars = { ACTOR_EN_HORSE_LINK_CHILD, ACTORCAT_BG, FLAGS, @@ -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.sceneLayer >= 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_01_20)) { + 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..62fac6a63 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,11 +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; - #endif // Z_EN_HORSE_LINK_CHILD_H diff --git a/src/overlays/actors/ovl_En_Hs/overlay.cfg b/src/overlays/actors/ovl_En_Hs/overlay.cfg deleted file mode 100644 index dab1cacf7..000000000 --- a/src/overlays/actors/ovl_En_Hs/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hs -z_en_hs.c 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 1e9fdfbf9..2eb1c71a6 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -10,20 +10,20 @@ #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 EnHs_DoNothing(EnHs* this, GlobalContext* globalCtx); -void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, GlobalContext* globalCtx); -void func_80953354(EnHs* this, GlobalContext* globalCtx); -void func_8095345C(EnHs* this, GlobalContext* globalCtx); +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 = { +ActorInit En_Hs_InitVars = { ACTOR_EN_HS, ACTORCAT_NPC, FLAGS, @@ -57,8 +57,8 @@ 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->nwcPos); i++) { @@ -69,39 +69,39 @@ void func_80952C50(EnHs* this, GlobalContext* globalCtx) { 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, &gHsSkeleton, &gHsIdleAnim, this->jointTable, this->morphTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gHsSkeleton, &gHsIdleAnim, this->jointTable, this->morphTable, OBJECT_HS_LIMB_MAX); Animation_PlayLoop(&this->skelAnime, &gHsIdleAnim); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + 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->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 EnHs_UpdateChickPos(Vec3f* dst, Vec3f src, f32 offset) { @@ -124,8 +124,8 @@ void EnHs_UpdateChickPos(Vec3f* dst, Vec3f src, f32 offset) { 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 offset; @@ -142,7 +142,7 @@ void func_80952F00(EnHs* this, GlobalContext* globalCtx) { } } -void func_80952FE0(EnHs* this, GlobalContext* globalCtx) { +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) { @@ -150,53 +150,53 @@ void func_80952FE0(EnHs* this, GlobalContext* globalCtx) { } else { this->actionFunc = func_80953180; this->stateFlags &= ~4; - func_80151938(globalCtx, 0x33F6); - func_80952DFC(globalCtx); + func_80151938(play, 0x33F6); + func_80952DFC(play); } 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->stateFlags |= 0x10; - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); } else { this->stateFlags |= 8; if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_RED, 10000.0f, 50.0f); + 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) { +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(globalCtx); + func_801477B4(play); this->actionFunc = func_8095345C; break; case 0x33F7: // text: notice his chicks are grown up, happy, wants to give you bunny hood this->actor.flags &= ~ACTOR_FLAG_10000; - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_80953098; - func_80953098(this, globalCtx); + func_80953098(this, play); break; 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: // He heard from his gramps (?) the moon is going to fall - globalCtx->msgCtx.unk11F10 = 0; + play->msgCtx.msgLength = 0; this->actionFunc = func_80952FE0; this->stateTimer = 0; this->headRot.z = 0; @@ -204,100 +204,100 @@ void func_80953180(EnHs* this, GlobalContext* globalCtx) { break; default: - func_801477B4(globalCtx); + func_801477B4(play); this->actionFunc = func_8095345C; break; } } } -void EnHs_DoNothing(EnHs* this, GlobalContext* globalCtx) { +void EnHs_DoNothing(EnHs* this, PlayState* play) { } -void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, GlobalContext* globalCtx) { +void EnHs_SceneTransitToBunnyHoodDialogue(EnHs* this, PlayState* play) { if (DECR(this->stateTimer) == 0) { - globalCtx->nextEntranceIndex = globalCtx->setupExitList[HS_GET_EXIT_INDEX(&this->actor)]; - globalCtx->sceneLoadFlag = 0x14; - gSaveContext.save.weekEventReg[25] |= 8; + play->nextEntrance = play->setupExitList[HS_GET_EXIT_INDEX(&this->actor)]; + play->transitionTrigger = TRANS_TRIGGER_START; + SET_WEEKEVENTREG(WEEKEVENTREG_25_08); this->actionFunc = EnHs_DoNothing; } } -void func_80953354(EnHs* this, GlobalContext* globalCtx) { - if (!Play_InCsMode(globalCtx)) { - func_800B7298(globalCtx, &this->actor, 7); +void func_80953354(EnHs* this, PlayState* play) { + if (!Play_InCsMode(play)) { + func_800B7298(play, &this->actor, PLAYER_CSMODE_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->stateFlags & 0x20)) { + if ((play->curSpawn == 1) && !(this->stateFlags & 0x20)) { sp1E = 0x33F7; this->stateFlags |= 0x20; } else if (this->stateFlags & 0x10) { sp1E = 0x33F9; this->stateFlags &= ~0x10; - } else if (gSaveContext.save.weekEventReg[25] & 8) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_08)) { 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); + func_809533A0(this, play); if (this->stateFlags & 8) { - func_80952DFC(globalCtx); + func_80952DFC(play); this->stateFlags &= ~8; } } else if (this->actor.home.rot.x >= 20) { // chicks turned adult >= 10 this->actionFunc = func_80953354; this->stateTimer = 40; } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { - func_800B8500(&this->actor, globalCtx, 1000.0f, 1000.0f, -1); + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); this->stateFlags |= 1; - } else if ((this->actor.xzDistToPlayer < 120.0f) && Player_IsFacingActor(&this->actor, 0x2000, globalCtx)) { - func_800B8614(&this->actor, globalCtx, 130.0f); + } 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->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->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) { - func_800E9250(globalCtx, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->unusedRot, this->actor.focus.pos); } else { Math_SmoothStepToS(&this->headRot.x, 0x3200, 6, 0x1838, 0x64); Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); @@ -306,7 +306,7 @@ void EnHs_Update(Actor* thisx, GlobalContext* globalCtx) { } } -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) { @@ -345,7 +345,7 @@ 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 == HS_LIMB_HEAD) { @@ -353,10 +353,10 @@ void EnHs_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -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 62fc1d2a1..79f94fd4b 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.h +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.h @@ -6,7 +6,7 @@ struct EnHs; -typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); +typedef void (*EnHsActionFunc)(struct EnHs*, PlayState*); #define HS_GET_EXIT_INDEX(thisx) ((thisx)->params & 0xF) @@ -21,19 +21,17 @@ typedef void (*EnHsActionFunc)(struct EnHs*, GlobalContext*); // The count of [chicks transformed into adult] is stored in [this->actor.home.rot.x] (incremented by 2) typedef struct EnHs { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderCylinder collider; - /* 0x0190 */ SkelAnime skelAnime; - /* 0x01D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; - /* 0x0234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; - /* 0x0294 */ Vec3s headRot; - /* 0x029A */ Vec3s unusedRot; // probably not chest, as chest is same limb as lower body - /* 0x02A0 */ u16 stateFlags; - /* 0x02A2 */ s16 stateTimer; // reused for different actionFunc - /* 0x02A4 */ Vec3f nwcPos[20]; // actual chick position are even values, odd values seem to be extra values for smoother chain - /* 0x0394 */ EnHsActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ Vec3s jointTable[OBJECT_HS_LIMB_MAX]; + /* 0x234 */ Vec3s morphTable[OBJECT_HS_LIMB_MAX]; + /* 0x294 */ Vec3s headRot; + /* 0x29A */ Vec3s unusedRot; // probably not chest, as chest is same limb as lower body + /* 0x2A0 */ u16 stateFlags; + /* 0x2A2 */ s16 stateTimer; // reused for different actionFunc + /* 0x2A4 */ Vec3f nwcPos[20]; // actual chick position are even values, odd values seem to be extra values for smoother chain + /* 0x394 */ EnHsActionFunc actionFunc; } EnHs; // size = 0x398 -extern const ActorInit En_Hs_InitVars; - #endif // Z_EN_HS_H diff --git a/src/overlays/actors/ovl_En_Hs2/overlay.cfg b/src/overlays/actors/ovl_En_Hs2/overlay.cfg deleted file mode 100644 index a34ed88c5..000000000 --- a/src/overlays/actors/ovl_En_Hs2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Hs2 -z_en_hs2.c 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..8273d8789 100644 --- a/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c +++ b/src/overlays/actors/ovl_En_Hs2/z_en_hs2.c @@ -1,7 +1,7 @@ /* * File: z_en_hs2.c * Overlay: ovl_En_Hs2 - * Description: Blue Target Spot (?) + * Description: Near-empty actor. Does nothing, but can be targeted. */ #include "z_en_hs2.h" @@ -10,14 +10,14 @@ #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 = { +ActorInit En_Hs2_InitVars = { ACTOR_EN_HS2, ACTORCAT_NPC, FLAGS, @@ -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..69836605d 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; @@ -13,6 +13,4 @@ typedef struct EnHs2 { /* 0x394 */ EnHs2ActionFunc actionFunc; } EnHs2; // size = 0x398 -extern const ActorInit En_Hs2_InitVars; - #endif // Z_EN_HS2_H diff --git a/src/overlays/actors/ovl_En_Ig/overlay.cfg b/src/overlays/actors/ovl_En_Ig/overlay.cfg deleted file mode 100644 index fa0125cbf..000000000 --- a/src/overlays/actors/ovl_En_Ig/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ig -z_en_ig.c 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 e687b770d..2468e5961 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -12,20 +12,20 @@ #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 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), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_75_10, 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), @@ -42,7 +42,7 @@ static u8 D_80BF3260[] = { /* 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), + /* 0x6D */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_75_10, 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(), @@ -89,7 +89,7 @@ static s32 D_80BF33F0[] = { 0x10000000, }; -const ActorInit En_Ig_InitVars = { +ActorInit En_Ig_InitVars = { ACTOR_EN_IG, ACTORCAT_NPC, FLAGS, @@ -143,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 }, @@ -156,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; @@ -182,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) { @@ -201,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) { @@ -237,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) { @@ -261,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->scheduleResult == 3) { - retActor = func_80BF1150(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN); + retActor = func_80BF1150(this, play, ACTORCAT_NPC, ACTOR_EN_AN); } else { - retActor = &GET_PLAYER(globalCtx)->actor; + retActor = &GET_PLAYER(play)->actor; } return retActor; } @@ -348,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; @@ -362,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++; @@ -372,11 +372,11 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { case 1: case 3: - if (!(gSaveContext.save.weekEventReg[75] & 0x10) && (this->unk_3F6 == 3)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_10) && (this->unk_3F6 == 3)) { 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; @@ -391,7 +391,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { return ret; } -s32* func_80BF1920(EnIg* this, GlobalContext* globalCtx) { +s32* func_80BF1920(EnIg* this, PlayState* play) { switch (this->scheduleResult) { case 3: this->unk_3F8 = func_80BF17BC; @@ -417,16 +417,16 @@ 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_29C = func_80BF1920(this, globalCtx); + this->unk_29C = func_80BF1920(this, play); if ((this->scheduleResult != 2) && (this->scheduleResult != 3) && (this->scheduleResult != 4)) { this->unk_3D0 |= 0x20; } @@ -437,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++; @@ -447,7 +447,7 @@ void func_80BF1A60(EnIg* this, GlobalContext* globalCtx) { } } -s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { +s32 func_80BF1AE0(EnIg* this, PlayState* play) { switch (this->scheduleResult) { case 3: func_80BF1284(this, 0); @@ -464,12 +464,12 @@ 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) { + if (player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_400 | PLAYER_STATE1_800)) { this->unk_3D0 |= 0x400; if (this->unk_3D2 != temp) { if ((this->unk_3FC == 2) || (this->unk_3FC == 3)) { @@ -486,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, ScheduleResult* arg2, s32 arg3, s32 arg4) { +s32 func_80BF1C44(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput, s32 arg3, s32 arg4) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -505,18 +505,18 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s3 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->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp4F, D_80BF3318[scheduleOutput->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - 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); @@ -526,10 +526,10 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s3 return sp24; } -s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, ScheduleResult* 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; @@ -539,7 +539,7 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return sp2C; } -s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENIG_GET_FF(&this->actor); EnDoor* door; @@ -549,16 +549,16 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_274 = NULL; - door = func_80BF1200(globalCtx, arg2->result); + this->timePath = NULL; + door = func_80BF1200(play, scheduleOutput->result); - if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); + if (D_80BF3318[scheduleOutput->result] >= 0) { + this->timePath = SubS_GetAdditionalPath(play, sp55, D_80BF3318[scheduleOutput->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - 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); @@ -572,8 +572,8 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { this->unk_2A4 = 75; } - this->unk_3E0 = arg2->time1 - arg2->time0; - this->unk_3E2 = sp56 - arg2->time0; + this->unk_3E0 = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_3E2 = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); @@ -584,43 +584,44 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BF1FA8(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); - s32 temp_t8; + u16 tmp; + s16 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; - if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); + 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->scheduleResult; - 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->time0; + phi_v1 = scheduleOutput->time0; } - if (arg2->time1 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->time1) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->unk_288 = arg2->time1 - 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; @@ -633,7 +634,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BF219C(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3f sp40; Vec3f sp34; @@ -641,22 +642,22 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; - if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); + 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->result) { + switch (scheduleOutput->result) { case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; @@ -678,20 +679,20 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BF2368(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; this->actor.targetMode = 0; this->unk_3D0 = 0; this->actor.flags |= ACTOR_FLAG_1; - switch (arg2->result) { + switch (scheduleOutput->result) { case 5: case 6: case 7: case 8: case 9: - ret = func_80BF1DF4(this, globalCtx, arg2); + ret = func_80BF1DF4(this, play, scheduleOutput); break; case 10: @@ -699,22 +700,22 @@ s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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; @@ -727,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->scheduleResult); +s32 func_80BF2470(EnIg* this, PlayState* play) { + EnDoor* door = func_80BF1200(play, this->scheduleResult); Vec3f sp38; f32 temp; s32 pad; - if (!SubS_InCsMode(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; @@ -747,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); } @@ -755,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 (SubS_InCsMode(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 (SubS_InCsMode(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; } @@ -822,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); @@ -837,14 +840,14 @@ s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { return true; } -void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { +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: @@ -852,31 +855,31 @@ 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) { - ScheduleResult sp20; +void func_80BF2AF8(EnIg* this, PlayState* play) { + ScheduleOutput sp20; - this->unk_3EC = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); - if (!Schedule_RunScript(globalCtx, D_80BF3260, &sp20) || - ((this->scheduleResult != sp20.result) && !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.result = 0; @@ -884,17 +887,17 @@ void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_2A8 = func_80BF146C(this, globalCtx); + this->unk_2A8 = func_80BF146C(this, play); this->scheduleResult = sp20.result; - func_80BF2A50(this, globalCtx); + 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_29C, this->unk_3F8, &this->unk_2A0)) { + 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; @@ -910,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->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->scheduleResult != 0) { func_80BF1258(this); func_80BF13E4(this); func_80BF15EC(this); - func_8013C964(&this->actor, globalCtx, 60.0f, 30.0f, EXCH_ITEM_NONE, this->unk_3D0 & 7); + func_8013C964(&this->actor, play, 60.0f, 30.0f, PLAYER_IA_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; @@ -965,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; @@ -995,7 +997,7 @@ void EnIg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -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 stepRot; s32 overrideRot; @@ -1025,7 +1027,7 @@ void EnIg_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this } } -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, @@ -1034,22 +1036,22 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { EnIg* this = THIS; if (this->scheduleResult != 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_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_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 21abb08ac..c3fd0c3fb 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -5,63 +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 */ u8 scheduleResult; - /* 0x029C */ s32* unk_29C; - /* 0x02A0 */ s32 unk_2A0; - /* 0x02A4 */ s8 unk_2A4; - /* 0x02A8 */ Actor* unk_2A8; - /* 0x02AC */ UNK_TYPE1 unk2AC[0x4]; - /* 0x02B0 */ Vec3f unk_2B0; - /* 0x02BC */ Vec3f unk_2BC; - /* 0x02C8 */ UNK_TYPE1 unk2C8[0xC]; - /* 0x02D4 */ Vec3f unk_2D4; - /* 0x02E0 */ UNK_TYPE1 unk2E0[0x6]; - /* 0x02E6 */ Vec3s unk_2E6; - /* 0x02EC */ Vec3s jointTable[19]; - /* 0x035E */ Vec3s morphTable[19]; - /* 0x03D0 */ u16 unk_3D0; - /* 0x03D2 */ u16 unk_3D2; - /* 0x03D4 */ f32 unk_3D4; - /* 0x03D8 */ UNK_TYPE1 unk3D8[0x8]; - /* 0x03E0 */ s16 unk_3E0; - /* 0x03E2 */ s16 unk_3E2; - /* 0x03E4 */ s16 unk_3E4; - /* 0x03E6 */ s16 unk_3E6; - /* 0x03E8 */ s16 unk_3E8; - /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 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; - #endif // Z_EN_IG_H diff --git a/src/overlays/actors/ovl_En_Ik/overlay.cfg b/src/overlays/actors/ovl_En_Ik/overlay.cfg deleted file mode 100644 index c4cc60ed3..000000000 --- a/src/overlays/actors/ovl_En_Ik/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ik -z_en_ik.c 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..4188f44c4 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -5,18 +5,76 @@ */ #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* play2); +void EnIk_Draw(Actor* thisx, PlayState* play); -#if 0 -const ActorInit En_Ik_InitVars = { +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 }, +}; + +ActorInit En_Ik_InitVars = { ACTOR_EN_IK, ACTORCAT_ENEMY, FLAGS, @@ -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); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + this->actor.hintId = TATL_HINT_ID_IRON_KNUCKLE; + 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_Kill(&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); + Audio_RestorePrevBgm(); + } + } + 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..3489329b1 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.h +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.h @@ -2,18 +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; - #endif // Z_EN_IK_H diff --git a/src/overlays/actors/ovl_En_In/overlay.cfg b/src/overlays/actors/ovl_En_In/overlay.cfg deleted file mode 100644 index 2a1b953aa..000000000 --- a/src/overlays/actors/ovl_En_In/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_In -z_en_in.c 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 ef4db6f9e..a51cae556 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -12,17 +12,17 @@ #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 = { +ActorInit En_In_InitVars = { ACTOR_EN_IN, ACTORCAT_NPC, FLAGS, @@ -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,40 +139,40 @@ static AnimationInfoS sAnimations[] = { { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, }; -static TurnOptionsSet sTurnOptions = { +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); } @@ -190,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; @@ -215,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; } @@ -224,13 +224,13 @@ s32 func_808F33B8(void) { s32 ret = (((gSaveContext.save.day == 1) && ((gSaveContext.save.time >= CLOCK_TIME(5, 30)) && (gSaveContext.save.time <= CLOCK_TIME(6, 0)))) || (gSaveContext.save.day >= 2)) && - !(gSaveContext.save.weekEventReg[22] & 1); + !CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01); return ret; } -void func_808F3414(EnIn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_808F3414(EnIn* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f point; if (this->unk23D == 0) { @@ -238,43 +238,43 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { } if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { point.x = player->actor.world.pos.x; - point.y = player->bodyPartsPos[7].y + 3.0f; + point.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->trackTarget.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->headRot.y, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.x, 0, 4, 0x3E8, 1); Math_SmoothStepToS(&this->torsoRot.y, 0, 4, 0x3E8, 1); } func_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; @@ -283,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; @@ -297,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, @@ -319,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; } @@ -335,229 +335,227 @@ void func_808F38F8(EnIn* this, GlobalContext* globalCtx) { } } -void func_808F395C(EnIn* this, GlobalContext* globalCtx) { - if (this->unk4B0 == RACE_FLAG_END) { +void func_808F395C(EnIn* this, PlayState* play) { + if (this->unk4B0 == WEEKEVENTREG_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) { - switch (GET_RACE_FLAGS) { - case RACE_FLAG_2: + switch (GET_WEEKEVENTREG_RACE_FLAGS) { + case WEEKEVENTREG_RACE_FLAG_2: textId = 0x347A; break; - case RACE_FLAG_3: + case WEEKEVENTREG_RACE_FLAG_3: textId = 0x3476; break; } - SET_RACE_FLAGS(RACE_FLAG_END); + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_END); } else { - switch (GET_RACE_FLAGS) { - case RACE_FLAG_2: + switch (GET_WEEKEVENTREG_RACE_FLAGS) { + case WEEKEVENTREG_RACE_FLAG_2: textId = 0x349D; break; - case RACE_FLAG_3: + case WEEKEVENTREG_RACE_FLAG_3: textId = 0x3499; break; } - SET_RACE_FLAGS(RACE_FLAG_END); + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_END); } this->actor.flags |= ACTOR_FLAG_10000; this->actor.textId = textId; this->actionFunc = func_808F395C; - if (this->unk4B0 == RACE_FLAG_2) { + if (this->unk4B0 == WEEKEVENTREG_RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); } } -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_IA_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_IA_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_IA_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 (!(gSaveContext.save.weekEventReg[63] & 0x40)) { - return 0x34A9; + if (Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40)) { + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_15_08)) { + textId = 0x3458; + } else { + textId = 0x345B; + } + break; + case 1: + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_15_10)) { + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_56_04)) { + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_16_01)) { + textId = 0x3486; + } else { + textId = 0x3489; + } + break; + case 5: + if (func_808F33B8()) { + textId = 0x34B3; + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_16_02)) { + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_16_04)) { + 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: @@ -565,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.weekEventReg[57] & 1)) { - func_808F4108(this, globalCtx, 0x3474); + if (gSaveContext.save.playerData.rupees >= play->msgCtx.unk1206C) { + Rupees_ChangeBy(-play->msgCtx.unk1206C); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_57_01)) { + 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); - if (!(gSaveContext.save.weekEventReg[57] & 1)) { + Rupees_ChangeBy(-fee); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_57_01)) { 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; } @@ -637,44 +635,44 @@ s32 func_808F4270(GlobalContext* globalCtx, EnIn* this, s32 arg2, MessageContext s32 func_808F43E0(EnIn* this) { this->unk48C = 0; this->actor.textId = 0; - SET_RACE_FLAGS(RACE_FLAG_END); + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_END); 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); - gSaveContext.save.weekEventReg[63] |= 0x40; + func_808F4108(this, play, 0x34AA); + SET_WEEKEVENTREG(WEEKEVENTREG_63_40); 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: @@ -685,48 +683,48 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 0: switch (textId) { case 0x3458: - gSaveContext.save.weekEventReg[15] |= 8; - func_800E8EA0(globalCtx, &this->actor, 0x3459); + SET_WEEKEVENTREG(WEEKEVENTREG_15_08); + 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; } @@ -734,112 +732,112 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 1: switch (textId) { case 0x3463: - gSaveContext.save.weekEventReg[15] |= 0x10; - func_800E8EA0(globalCtx, &this->actor, 0x3464); + SET_WEEKEVENTREG(WEEKEVENTREG_15_10); + 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); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); + func_80151BB4(play, 0x11); ret = true; break; case 0x3473: - gSaveContext.save.weekEventReg[56] &= (u8)~8; - func_80151BB4(globalCtx, 0x11); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); + func_80151BB4(play, 0x11); break; case 0x3475: - SET_RACE_FLAGS(RACE_FLAG_START); + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); - globalCtx->nextEntranceIndex = 0xCE50; - globalCtx->unk_1887F = 5; - globalCtx->sceneLoadFlag = 0x14; - gSaveContext.save.weekEventReg[57] |= 1; + play->nextEntrance = ENTRANCE(GORMAN_TRACK, 5); + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; + SET_WEEKEVENTREG(WEEKEVENTREG_57_01); 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); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); + func_808F4108(this, play, 0x3479); ret = false; } break; case 0x347B: - func_808F4108(this, globalCtx, 0x347C); - gSaveContext.save.weekEventReg[56] &= (u8)~8; + func_808F4108(this, play, 0x347C); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); ret = false; break; } @@ -847,96 +845,96 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 3: switch (textId) { case 0x346D: - func_808F4108(this, globalCtx, 0x346E); - gSaveContext.save.weekEventReg[56] |= 4; - gSaveContext.save.weekEventReg[56] |= 8; + func_808F4108(this, play, 0x346E); + SET_WEEKEVENTREG(WEEKEVENTREG_56_04); + SET_WEEKEVENTREG(WEEKEVENTREG_56_08); 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); - gSaveContext.save.weekEventReg[56] |= 8; + func_808F4108(this, play, 0x3483); + SET_WEEKEVENTREG(WEEKEVENTREG_56_08); 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); + SET_WEEKEVENTREG(WEEKEVENTREG_56_08); + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_56_08); + 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; } @@ -944,34 +942,34 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { case 4: switch (textId) { case 0x3486: - func_800E8EA0(globalCtx, &this->actor, 0x3487); - gSaveContext.save.weekEventReg[16] |= 1; + Actor_ContinueText(play, &this->actor, 0x3487); + SET_WEEKEVENTREG(WEEKEVENTREG_16_01); 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; } @@ -981,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); - gSaveContext.save.weekEventReg[16] |= 2; + Actor_ContinueText(play, &this->actor, 0x348F); + SET_WEEKEVENTREG(WEEKEVENTREG_16_02); 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); - gSaveContext.save.weekEventReg[16] |= 4; - gSaveContext.save.weekEventReg[56] |= 8; + func_808F4108(this, play, 0x3496); + SET_WEEKEVENTREG(WEEKEVENTREG_16_04); + SET_WEEKEVENTREG(WEEKEVENTREG_56_08); 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); - gSaveContext.save.weekEventReg[56] |= 8; + func_808F4108(this, play, 0x34A6); + SET_WEEKEVENTREG(WEEKEVENTREG_56_08); ret = false; break; case 0x3473: - gSaveContext.save.weekEventReg[56] &= (u8)~8; - func_80151BB4(globalCtx, 0x11); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); + 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); + SET_WEEKEVENTREG_RACE_FLAGS(WEEKEVENTREG_RACE_FLAG_START); func_800FD750(NA_BGM_HORSE); - globalCtx->nextEntranceIndex = 0xCE50; - globalCtx->unk_1887F = 5; - globalCtx->sceneLoadFlag = 0x14; - gSaveContext.save.weekEventReg[57] |= 1; + play->nextEntrance = ENTRANCE(GORMAN_TRACK, 5); + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; + SET_WEEKEVENTREG(WEEKEVENTREG_57_01); 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); + SET_WEEKEVENTREG(WEEKEVENTREG_56_08); + 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; } @@ -1149,27 +1147,27 @@ 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); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); + func_80151BB4(play, 0x11); ret = true; break; case 0x349E: - func_808F4108(this, globalCtx, 0x349F); - gSaveContext.save.weekEventReg[56] &= (u8)~8; + func_808F4108(this, play, 0x349F); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); ret = false; break; } @@ -1178,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; @@ -1198,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; @@ -1207,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) { @@ -1237,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)); @@ -1253,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; @@ -1279,64 +1277,64 @@ 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) || - gSaveContext.save.weekEventReg[56] & 8) { +void func_808F5B58(EnIn* this, PlayState* play) { + if (func_800F41E4(play, &play->actorCtx)) { + if ((Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40)) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_56_08)) { 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 && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40))) { 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) { - if (this->unk4B0 == RACE_FLAG_END) { +void func_808F5C98(EnIn* this, PlayState* play) { + if (this->unk4B0 == WEEKEVENTREG_RACE_FLAG_END) { this->actionFunc = func_808F5B58; } - if ((Player_GetMask(globalCtx) == PLAYER_MASK_CIRCUS_LEADER && gSaveContext.save.weekEventReg[63] & 0x40) || - gSaveContext.save.weekEventReg[56] & 8) { + if ((Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40)) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_56_08)) { 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) { - if (this->unk4B0 == RACE_FLAG_2) { + if (this->unk4B0 == WEEKEVENTREG_RACE_FLAG_2) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_LOST); } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_IN_JOY0); @@ -1352,24 +1350,23 @@ 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; this->unk4AC = 0; type = ENIN_GET_TYPE(thisx); - this->unk4B0 = GET_RACE_FLAGS; + this->unk4B0 = GET_WEEKEVENTREG_RACE_FLAGS; if (type == ENIN_HORSE_RIDER_BLUE_SHIRT || type == ENIN_BLUE_SHIRT) { this->unk4AC |= 8; } @@ -1377,32 +1374,34 @@ 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; + if ((GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_2) || + (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_3)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); 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); + + if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_2) { + 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) { + if (GET_WEEKEVENTREG_RACE_FLAGS == WEEKEVENTREG_RACE_FLAG_2) { this->skelAnime.curFrame = ((Rand_ZeroOne() * 0.6f) + 0.2f) * this->skelAnime.endFrame; } if (this->unk4AC & 8) { @@ -1411,35 +1410,35 @@ void EnIn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = func_808F5C98; } } else { - if (GET_RACE_FLAGS != RACE_FLAG_START) { - gSaveContext.save.weekEventReg[56] &= (u8)~8; + if (GET_WEEKEVENTREG_RACE_FLAGS != WEEKEVENTREG_RACE_FLAG_START) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_56_08); this->unk23C = 0; 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, + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01)) { + 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); + Actor_Kill(&this->actor); } else { - func_808F30B0(&this->skelAnime, 0); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_0); this->actionFunc = func_808F5A94; } } } else { - if (gSaveContext.save.weekEventReg[52] & 1) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01)) { + Actor_Kill(&this->actor); } else { - func_808F30B0(&this->skelAnime, 7); + EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_7); this->actionFunc = func_808F5B58; } } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } else { @@ -1448,54 +1447,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_Translate(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)) { + if ((&this->actor == player->talkActor) && + !((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[] = { @@ -1530,24 +1528,23 @@ 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_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - func_808F6334(this, globalCtx); + func_808F6334(this, play); } if (limbIndex == 9) { Matrix_RotateYS(this->torsoRot.y, MTXMODE_APPLY); @@ -1575,7 +1572,7 @@ 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 }; @@ -1594,33 +1591,33 @@ void EnIn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } 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 ae339ecaa..dd32ac9c6 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 turnTarget; + /* 0x352 */ Vec3s trackTarget; /* 0x358 */ Vec3s headRot; /* 0x35E */ Vec3s torsoRot; - /* 0x364 */ char unk364[0x12]; + /* 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,9 +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; - #endif // Z_EN_IN_H diff --git a/src/overlays/actors/ovl_En_Insect/overlay.cfg b/src/overlays/actors/ovl_En_Insect/overlay.cfg deleted file mode 100644 index f439a7c1b..000000000 --- a/src/overlays/actors/ovl_En_Insect/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Insect -z_en_insect.c 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..9eae19437 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -11,28 +11,28 @@ #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; -const ActorInit En_Insect_InitVars = { +ActorInit En_Insect_InitVars = { ACTOR_EN_INSECT, ACTORCAT_ITEMACTION, FLAGS, @@ -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,12 +305,12 @@ 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) { if (this->unk_30C & 4) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -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,12 +350,12 @@ 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); } if (this->unk_312 <= 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -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,21 +426,21 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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..ea4025414 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.h +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.h @@ -5,26 +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; - #endif // Z_EN_INSECT_H diff --git a/src/overlays/actors/ovl_En_Invadepoh/overlay.cfg b/src/overlays/actors/ovl_En_Invadepoh/overlay.cfg deleted file mode 100644 index a05f98b61..000000000 --- a/src/overlays/actors/ovl_En_Invadepoh/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Invadepoh -z_en_invadepoh.c 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 2eace7815..2c6a15737 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -4,7 +4,6 @@ * 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" @@ -18,160 +17,160 @@ #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_80B450C0(f32* x1, f32* z1, f32 x2, f32 z2, f32 speed); s32 func_80B4516C(EnInvadepoh* this); void func_80B45A4C(EnInvadePohStruct* s, unkstructInvadepoh4** u); void func_80B45A94(EnInvadePohStruct* s, unkstructInvadepoh4** u); @@ -179,7 +178,7 @@ void func_80B45B1C(EnInvadePohStruct* s, unkstructInvadepoh4** u); extern s32 D_801BDA9C; -const ActorInit En_Invadepoh_InitVars = { +ActorInit En_Invadepoh_InitVars = { ACTOR_EN_INVADEPOH, ACTORCAT_PROP, FLAGS, @@ -255,29 +254,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; @@ -327,7 +325,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, @@ -618,8 +616,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; @@ -800,8 +798,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); @@ -832,7 +830,7 @@ s32 func_80B440B8(EnInvadepoh* this, f32 arg1, f32 arg2) { sp40 = temp_a3->x - sp48->x; sp3C = temp_a3->z - sp48->z; - sp1E = Math_FAtan2F(sp3C, sp40); + sp1E = Math_Atan2S_XY(sp3C, sp40); sp38 = Math_CosS(sp1E); sp34 = Math_SinS(sp1E); sp30 = this->actor.world.pos.x - sp48->x; @@ -923,14 +921,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 +938,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 +958,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 +968,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 +982,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); } @@ -1005,7 +1003,7 @@ void func_80B44700(EnInvadepoh* this) { } } -void func_80B447C0(EnInvadepoh* this, GlobalContext* globalCtx) { +void func_80B447C0(EnInvadepoh* this, PlayState* play) { s32 pad1; Vec3s* sp60; s32 pad2; @@ -1046,7 +1044,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) { @@ -1077,7 +1075,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; @@ -1089,33 +1087,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; @@ -1162,8 +1160,8 @@ s32 func_80B44C80(EnInvadepoh* this, GlobalContext* globalCtx) { } Math_SmoothStepToS(&this->actor.world.rot.y, - Math_FAtan2F(((sp60.z + temp_f0_2) * 0.9f) + sp6C.z, ((sp60.x + temp_f0_3) * 0.9f) + sp6C.x), 4, - 0xFA0, 0x64); + Math_Atan2S_XY(((sp60.z + temp_f0_2) * 0.9f) + sp6C.z, ((sp60.x + temp_f0_3) * 0.9f) + sp6C.x), + 4, 0xFA0, 0x64); Actor_MoveWithGravity(&this->actor); if (func_80B440B8(this, 50.0f, 15.0f)) { phi_v0 = 4; @@ -1171,24 +1169,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); } @@ -1198,11 +1196,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); } } @@ -1214,19 +1212,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) { @@ -1254,7 +1252,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; @@ -1285,7 +1283,7 @@ void func_80B451A0(EnInvadepoh* this, GlobalContext* globalCtx) { } if (D_80B4E940 == 0) { - if (gSaveContext.save.weekEventReg[22] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { D_80B4E940 = 3; } else { D_80B4E940 = 4; @@ -1294,33 +1292,33 @@ 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); } @@ -1332,9 +1330,9 @@ void EnInvadepoh_SetSysMatrix(Vec3f* vec) { 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) { @@ -1350,9 +1348,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) { @@ -1365,16 +1363,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; } @@ -1424,11 +1422,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; } } @@ -1550,7 +1548,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; @@ -1577,7 +1575,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); } } @@ -1627,7 +1625,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; @@ -1635,7 +1633,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; @@ -1643,9 +1641,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); @@ -1653,16 +1651,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); @@ -1672,61 +1670,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); + Actor_Kill(&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); + Actor_Kill(&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); + Actor_Kill(&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) { @@ -1744,40 +1741,41 @@ 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); + Actor_Kill(&this->actor); } + if (temp == 5) { - if (gSaveContext.save.weekEventReg[22] & 1) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + Actor_Kill(&this->actor); return; } } else if (temp == 7) { if (gSaveContext.save.time < CLOCK_TIME(6, 0) && gSaveContext.save.time >= CLOCK_TIME(2, 15)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } else if (temp != 8) { if (temp == 9) { - if (gSaveContext.save.entranceIndex != 0x6460) { - Actor_MarkForDeath(&this->actor); + if (gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 6)) { + Actor_Kill(&this->actor); return; } } else if (temp == 0xC) { - if (!(gSaveContext.save.weekEventReg[22] & 1)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + Actor_Kill(&this->actor); } D_80B503F4 = this; } } } -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; @@ -1787,63 +1785,63 @@ void func_80B468B4(EnInvadepoh* this, GlobalContext* globalCtx) { this->actor.world.pos.y += 1500.0f; func_80B49628(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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); + Actor_Kill(&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); + Actor_Kill(&this->actor); } - if (!(gSaveContext.save.weekEventReg[22] & 1)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + Actor_Kill(&this->actor); } 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; } @@ -1853,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) { @@ -1900,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); } } @@ -1914,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])) { @@ -1931,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++) { @@ -1953,11 +1951,11 @@ 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))) { - gSaveContext.save.weekEventReg[22] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_22_01); func_80B47064(this); } else { func_80B457A0(this); @@ -1975,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); @@ -1990,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); + Audio_PlayFanfare(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); @@ -2012,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); } } @@ -2028,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) { @@ -2036,13 +2034,13 @@ 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; - gSaveContext.save.weekEventReg[89] |= 0x10; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_72; + gSaveContext.nextTransitionType = TRANS_TYPE_72; + SET_WEEKEVENTREG(WEEKEVENTREG_89_10); func_80B47304(this); } @@ -2051,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 { @@ -2078,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); @@ -2103,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); @@ -2116,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; @@ -2129,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) { @@ -2158,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; @@ -2173,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) { @@ -2187,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; @@ -2200,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); @@ -2212,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; @@ -2224,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; @@ -2258,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)) { @@ -2300,12 +2298,12 @@ void func_80B47BAC(Actor* thisx, GlobalContext* globalCtx) { func_80B47568(this); } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } -void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { +void func_80B47D30(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; s32 pad; @@ -2316,7 +2314,7 @@ void func_80B47D30(Actor* thisx, GlobalContext* globalCtx) { thisx->gravity = 0.0f; func_80B47830(this); } else if ((this->actionFunc == func_80B474DC) || (this->actionFunc == func_80B473E4)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } else if (this->collider.base.acFlags & AC_HIT) { @@ -2328,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; @@ -2380,7 +2377,7 @@ void func_80B48060(Actor* thisx, GlobalContext* globalCtx) { MtxF unkMtx; if (D_80B503F0 == NULL || this->actor.parent == NULL) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -2401,26 +2398,26 @@ void func_80B48060(Actor* thisx, GlobalContext* globalCtx) { } } -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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -2429,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); } @@ -2445,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; @@ -2477,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) { @@ -2507,41 +2504,41 @@ 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; if (this->actor.parent == NULL) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); func_80B45CE0(substruct); if (substruct->unk40 != 0) { @@ -2560,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; @@ -2620,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; @@ -2632,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); @@ -2656,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) { @@ -2691,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; @@ -2713,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); } } @@ -2770,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; @@ -2780,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); } } @@ -2794,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) { @@ -2822,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; @@ -2834,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); @@ -2871,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; @@ -2879,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; @@ -2905,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; @@ -2937,14 +2934,14 @@ 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); if (this->actionTimer > 0) { this->actionTimer--; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -2957,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; @@ -2973,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 { @@ -2981,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; @@ -2998,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; @@ -3007,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); + temp_v0_2 = (R_TIME_SPEED * -16.0f / temp_v0_2) - 0.5f; + this->unk378 = func_80B45550(this, play, SQ(80.0f), temp_v0_2); } } this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); @@ -3034,7 +3031,7 @@ void func_80B49C38(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (this->clockTime >= 0.9999f) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -3042,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; @@ -3061,35 +3058,35 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_54_10); this->actor.textId = 0x332E; } func_80B49BD0(this); } } -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]) { - if (gSaveContext.save.weekEventReg[54] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_21_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_10)) { this->actor.textId = 0x332E; } else { this->actor.textId = 0x332D; @@ -3107,12 +3104,12 @@ void func_80B49F88(Actor* thisx, GlobalContext* globalCtx) { this->actor.draw = func_80B4E324; func_80B49BD0(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } -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))) { @@ -3122,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; @@ -3159,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; @@ -3167,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); @@ -3178,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; @@ -3188,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 { @@ -3206,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; @@ -3216,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); } @@ -3225,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; @@ -3234,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; @@ -3248,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 { @@ -3268,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; @@ -3288,9 +3285,9 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_54_10); this->actor.textId = 0x332E; } if (this->pathIndex == this->endPoint) { @@ -3301,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; @@ -3327,10 +3324,10 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_21_20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_10)) { this->actor.textId = 0x332E; } else { this->actor.textId = 0x332D; @@ -3341,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))) { @@ -3351,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); } } @@ -3377,8 +3374,8 @@ void func_80B4ACDC(EnInvadepoh* this) { this->actionFunc = func_80B4ACF0; } -void func_80B4ACF0(EnInvadepoh* this, GlobalContext* globalCtx) { - if (gSaveContext.save.weekEventReg[22] & 1) { +void func_80B4ACF0(EnInvadepoh* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { this->actor.draw = func_80B4E324; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); func_80B4AD3C(this); @@ -3390,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); } } @@ -3403,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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_02)) { + 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); } } @@ -3429,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; + SET_WEEKEVENTREG(WEEKEVENTREG_22_02); 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); } } @@ -3449,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_IA_MINUS1); } } @@ -3466,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; @@ -3507,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); @@ -3522,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); } } @@ -3540,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); @@ -3563,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; @@ -3585,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); } @@ -3606,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); } @@ -3626,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) { @@ -3657,13 +3655,13 @@ void func_80B4B8BC(Actor* thisx, GlobalContext* globalCtx) { } else if (D_80B4E940 == 1) { this->actor.update = func_80B4BA30; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); if (!this) {} } } } -void func_80B4BA30(Actor* thisx, GlobalContext* globalCtx) { +void func_80B4BA30(Actor* thisx, PlayState* play) { EnInvadepoh* this = THIS; if (D_80B4E940 == 2) { @@ -3674,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); @@ -3685,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); @@ -3694,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; @@ -3733,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; @@ -3763,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) { @@ -3794,7 +3789,7 @@ void func_80B4BC4C(EnInvadepoh* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_ROMANI_WALK); } if (gSaveContext.save.time > CLOCK_TIME(20, 15)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else if ((temp_t6 != NULL) && (temp_t6->actionFunc == func_80B4CB0C)) { func_80B4C1BC(this); } @@ -3803,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; @@ -3827,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); } } @@ -3835,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; @@ -3865,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) { @@ -3898,12 +3893,12 @@ void func_80B4C3A0(Actor* thisx, GlobalContext* globalCtx) { this->actor.draw = func_80B4E7BC; func_80B4BBE0(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } -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))) { @@ -3913,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; @@ -3947,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; @@ -3962,7 +3957,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { s16 pad2; func_80B44700(this); - func_80B44EFC(this, globalCtx); + func_80B44EFC(this, play); func_80B43E6C(this, 6, 2000, 100); phi_a2 = ((this->pathIndex < this->endPoint) ? this->pathIndex : this->endPoint - 1); @@ -3971,10 +3966,10 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { 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); + temp_v0_2 = (R_TIME_SPEED * -23.0f / temp_v0_2) - 0.5f; + this->unk378 = func_80B45550(this, play, SQ(80.0f), temp_v0_2); } } @@ -3984,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) { @@ -4009,7 +4004,7 @@ void func_80B4C730(EnInvadepoh* this, GlobalContext* globalCtx) { } if (this->clockTime >= 0.9999f) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -4021,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; @@ -4042,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); } } @@ -4050,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; @@ -4078,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; @@ -4107,12 +4102,12 @@ void func_80B4CE54(Actor* thisx, GlobalContext* globalCtx) { this->actor.draw = func_80B4E324; func_80B4C6C8(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } -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)) { @@ -4122,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); } } @@ -4149,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; @@ -4169,12 +4164,12 @@ 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; if (D_80B503F0 == NULL) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -4196,12 +4191,12 @@ void func_80B4D290(EnInvadepoh* this, GlobalContext* globalCtx) { } if (sp28 < 5.0f) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } 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; @@ -4215,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; @@ -4263,83 +4258,78 @@ void func_80B4D480(EnInvadepoh* this, GlobalContext* globalCtx) { } if ((this->actionTimer <= 0) || sp2C) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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); + 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)) { @@ -4362,10 +4352,10 @@ void func_80B4D9F4(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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); @@ -4376,35 +4366,35 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { 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_Mult(&D_80B502A0, MTXMODE_NEW); - gSPMatrix(spBC++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spBC++, object_uch_DL_000080); + 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(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(spBC++, object_uch_DL_000080); + gSPMatrix(spBC++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(spBC++, gAlienEyeBeamDL); spB8->polyXlu.p = spBC; } } @@ -4414,16 +4404,15 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { &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; @@ -4431,7 +4420,7 @@ 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_Mult(&globalCtx->billboardMtxF, MTXMODE_NEW); + 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; @@ -4441,12 +4430,11 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { 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); } } @@ -4454,99 +4442,99 @@ void func_80B4DB14(Actor* thisx, GlobalContext* globalCtx) { 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) { + 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_Push(); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_NEW); + 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_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_RotateZS(((EnInvadepoh*)thisx)->unk304, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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); + gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); + 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; @@ -4556,10 +4544,10 @@ 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) { @@ -4567,18 +4555,18 @@ void func_80B4E61C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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 @@ -4590,10 +4578,10 @@ 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) { @@ -4601,14 +4589,14 @@ void func_80B4E784(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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..061d9c326 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,10 +148,8 @@ 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 -extern const ActorInit En_Invadepoh_InitVars; - #endif // Z_EN_INVADEPOH_H diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/overlay.cfg b/src/overlays/actors/ovl_En_Invadepoh_Demo/overlay.cfg deleted file mode 100644 index 192412f5f..000000000 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Invadepoh_Demo -z_en_invadepoh_demo.c 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..6a73eceec 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,20 +10,20 @@ #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 = { +ActorInit En_Invadepoh_Demo_InitVars = { ACTOR_EN_INVADEPOH_DEMO, ACTORCAT_PROP, FLAGS, 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..ff13ca668 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,14 +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; - #endif // Z_EN_INVADEPOH_DEMO_H diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/overlay.cfg b/src/overlays/actors/ovl_En_Invisible_Ruppe/overlay.cfg deleted file mode 100644 index 18c1eed56..000000000 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Invisible_Ruppe -z_en_invisible_ruppe.c 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..70f77b18a 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,15 +10,15 @@ #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 = { +ActorInit En_Invisible_Ruppe_InitVars = { ACTOR_EN_INVISIBLE_RUPPE, ACTORCAT_NPC, FLAGS, @@ -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) { - Actor_MarkForDeath(&this->actor); +void func_80C259E8(EnInvisibleRuppe* this, PlayState* play) { + Actor_Kill(&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)) { - Actor_MarkForDeath(&this->actor); + if ((this->unk_190 >= 0) && Flags_GetSwitch(play, this->unk_190)) { + Actor_Kill(&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..5b6f6ca64 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,19 +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; - #endif // Z_EN_INVISIBLE_RUPPE_H diff --git a/src/overlays/actors/ovl_En_Ishi/overlay.cfg b/src/overlays/actors/ovl_En_Ishi/overlay.cfg deleted file mode 100644 index 689d8deb5..000000000 --- a/src/overlays/actors/ovl_En_Ishi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ishi -z_en_ishi.c 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 9b60a41dd..f911bc4f4 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,8 @@ */ #include "z_en_ishi.h" +#include "z64quake.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,36 +15,36 @@ #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* play2); +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; static s16 D_8095F694 = 0; -const ActorInit En_Ishi_InitVars = { +ActorInit En_Ishi_InitVars = { ACTOR_EN_ISHI, ACTORCAT_PROP, FLAGS, @@ -142,15 +144,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 +160,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 +169,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 +205,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 +256,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 +274,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 +290,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,7 +309,7 @@ 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_Push(); Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); @@ -316,7 +318,7 @@ void func_8095DFF0(EnIshi* this, GlobalContext* globalCtx) { 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; + temp_v1_2 = Math_Atan2S_XY(sp30.z, sp30.x) - sp3C->world.rot.y; if (ABS_ALT(temp_v1_2) > 0x4000) { sp3C->world.rot.y = BINANG_ROT180(sp3C->world.rot.y); } @@ -346,11 +348,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 +360,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,19 +386,19 @@ 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))) { - Actor_MarkForDeath(&this->actor); + if ((sp34 == 1) && Flags_GetSwitch(play, ENISHI_GET_FE00(&this->actor))) { + Actor_Kill(&this->actor); return; } @@ -412,37 +414,37 @@ void EnIshi_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = D_8095F6C0[sp34]; - if ((sp30 == 0) && !func_8095D758(this, globalCtx, 0)) { - Actor_MarkForDeath(&this->actor); + if ((sp30 == 0) && !func_8095D758(this, play, 0)) { + Actor_Kill(&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); + Actor_Kill(&this->actor); return; } 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 +460,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 +470,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,15 +482,15 @@ 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); - Actor_MarkForDeath(&this->actor); + 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_Kill(&this->actor); return; } @@ -506,14 +508,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 +527,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.curRoom.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 +570,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,24 +586,25 @@ 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 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quake, 0x4350); - Quake_SetQuakeValues(quake, 3, 0, 0, 0); - Quake_SetCountdown(quake, 7); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, 3, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); + + Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -610,20 +613,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 +638,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 +648,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 +660,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,56 +680,56 @@ 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); + Actor_Kill(&this->actor); } else if (ActorCutscene_GetCurrentIndex() != this->actor.cutscene) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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 +737,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..65381f638 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,15 +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; - #endif // Z_EN_ISHI_H diff --git a/src/overlays/actors/ovl_En_Ja/overlay.cfg b/src/overlays/actors/ovl_En_Ja/overlay.cfg deleted file mode 100644 index aab759e94..000000000 --- a/src/overlays/actors/ovl_En_Ja/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ja -z_en_ja.c 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 5659e5ba9..39a28c4bd 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -11,16 +11,16 @@ #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); static u8 D_80BC35F0[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x05 - 0x04), @@ -50,7 +50,7 @@ s32 D_80BC366C[] = { 0x0E29440C, 0x170E2945, 0x0C180E29, 0x460C170E, 0x29470C09, 0x0000180E, 0x293B0C09, 0x00001000, }; -const ActorInit En_Ja_InitVars = { +ActorInit En_Ja_InitVars = { ACTOR_EN_JA, ACTORCAT_NPC, FLAGS, @@ -89,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 }, @@ -105,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; @@ -141,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; @@ -157,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; @@ -177,7 +177,7 @@ s32 func_80BC1B60(EnJa* this, GlobalContext* globalCtx) { this->unk_35A = CLAMP(this->unk_35A, -0x1C70, 0x1C70); if (this->unk_1D8.player->actor.id == ACTOR_PLAYER) { - sp40.y = this->unk_1D8.player->bodyPartsPos[7].y + 3.0f; + sp40.y = this->unk_1D8.player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; } else { Math_Vec3f_Copy(&sp40, &this->unk_1D8.player->actor.focus.pos); } @@ -192,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; @@ -214,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->talkActor)) { + if ((play->state.frames % 2) == 0) { if (this->unk_348 != 0.0f) { this->unk_348 = 0.0f; } else { @@ -236,13 +236,13 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { this->unk_34C = CLAMP(this->unk_34C, 0.0f, 120.0f); Matrix_Translate(this->unk_34C, 0.0f, 0.0f, MTXMODE_APPLY); - this->unk_374 = sp20; + this->prevTalkState = talkState; } -s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, ScheduleResult* 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); @@ -252,10 +252,10 @@ s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, ScheduleResult* 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 { @@ -269,41 +269,41 @@ s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BC20D0(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; this->unk_340 = 0; - switch (arg2->result) { + switch (scheduleOutput->result) { case 1: - ret = func_80BC1FC8(this, 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) { - ScheduleResult sp18; +void func_80BC21A8(EnJa* this, PlayState* play) { + ScheduleOutput sp18; - this->unk_35C = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BC35F0, &sp18) || - ((this->unk_1D8.unk_00 != sp18.result) && !func_80BC20D0(this, globalCtx, &sp18))) { + this->unk_35C = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); + 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.result = 0; @@ -312,10 +312,10 @@ void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; } this->unk_1D8.unk_00 = sp18.result; - func_80BC2150(this, globalCtx); + 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) { @@ -332,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; @@ -343,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; @@ -364,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, EXCH_ITEM_NONE, this->unk_340 & 7); + func_8013C964(&this->actor, play, radius, height, PLAYER_IA_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 }; @@ -423,27 +422,27 @@ void EnJa_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec 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_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_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_Push(); Matrix_Translate(D_80BC378C.x, D_80BC378C.y, D_80BC378C.z, MTXMODE_APPLY); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); gDPPipeSync(POLY_OPA_DISP++); @@ -469,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_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_Push(); Matrix_Translate(D_80BC3798.x, D_80BC3798.y, D_80BC3798.z, MTXMODE_APPLY); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); gDPPipeSync(POLY_OPA_DISP++); @@ -509,19 +507,19 @@ 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_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 stepRot; s32 overrideRot; @@ -568,7 +566,7 @@ void EnJa_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this } } -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 }, @@ -594,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); } } @@ -691,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; @@ -719,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_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); switch (ptr->unk_0C) { @@ -751,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..00746ec63 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,44 +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; - #endif // Z_EN_JA_H diff --git a/src/overlays/actors/ovl_En_Jc_Mato/overlay.cfg b/src/overlays/actors/ovl_En_Jc_Mato/overlay.cfg deleted file mode 100644 index 361e01617..000000000 --- a/src/overlays/actors/ovl_En_Jc_Mato/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Jc_Mato -z_en_jc_mato.c 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 6afe9c1a0..03cc41f20 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,16 +11,16 @@ #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 = { +ActorInit En_Jc_Mato_InitVars = { ACTOR_EN_JC_MATO, ACTORCAT_PROP, FLAGS, @@ -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.minigamePoints = 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) { - Actor_MarkForDeath(&this->actor); + if (DECR(this->despawnTimer) == 0) { + Actor_Kill(&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,29 @@ 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); - if (!(gSaveContext.eventInf[4] & 1)) { - EnJcMato_CheckForHit(this, globalCtx); + this->actionFunc(this, play); + if (!CHECK_EVENTINF(EVENTINF_40)) { + 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) { + static Vec3f sOffset = { 0.0f, -2500.0f, 0.0f }; 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); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_000390); - Matrix_MultVec3f(&movement, &this->pos); - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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++, gKoumeTargetDL); + Matrix_MultVec3f(&sOffset, &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..f2c64c37c 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; @@ -16,6 +16,4 @@ typedef struct EnJcMato { /* 0x1A4 */ Vec3f pos; } EnJcMato; // size = 0x1B0 -extern const ActorInit En_Jc_Mato_InitVars; - #endif // Z_EN_JC_MATO_H diff --git a/src/overlays/actors/ovl_En_Jg/overlay.cfg b/src/overlays/actors/ovl_En_Jg/overlay.cfg deleted file mode 100644 index a60b43afc..000000000 --- a/src/overlays/actors/ovl_En_Jg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Jg -z_en_jg.c 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 8f2408495..e7c2ad78d 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, @@ -64,7 +64,7 @@ typedef enum { /* 0x3 */ EN_JG_ACTION_LULLABY_INTRO_CS, } EnJgAction; -const ActorInit En_Jg_InitVars = { +ActorInit En_Jg_InitVars = { ACTOR_EN_JG, ACTORCAT_NPC, FLAGS, @@ -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) { @@ -214,7 +214,7 @@ s16 EnJg_GetWalkingYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ *distSQ = SQ(diffX) + SQ(diffZ); - return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); + return RADF_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); } s32 EnJg_ReachedPoint(EnJg* this, Path* path, s32 pointIndex) { @@ -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; @@ -493,25 +493,25 @@ void EnJg_Talk(EnJg* this, GlobalContext* globalCtx) { temp = this->textId; if ((temp == 0xDBB) || (temp == 0xDBC)) { - if (!(gSaveContext.save.weekEventReg[24] & 0x80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_24_80)) { // 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)) || + } else if ((CHECK_WEEKEVENTREG(WEEKEVENTREG_24_40)) || (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)) { - 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,78 +619,78 @@ 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); + Actor_Kill(this->drum); this->drum = NULL; } 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)) { @@ -700,7 +700,7 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, GlobalContext* globalCtx) { } else { this->csAction = 99; this->freezeTimer = 1000; - gSaveContext.save.weekEventReg[24] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_24_40); this->actionFunc = EnJg_Idle; } } @@ -830,7 +830,7 @@ s32 EnJg_GetNextTextId(EnJg* this) { return 0xDDC; // Everyone would accept you case 0xDDC: // Everyone would accept you - gSaveContext.save.weekEventReg[77] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_77_80); return 0xDDD; // Think it over slowly default: @@ -843,12 +843,12 @@ 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) { - if ((gSaveContext.save.weekEventReg[24] & 0x10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_10) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY) || CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { // The player has already talked as a Goron at least once. return 0xDBC; // Following me won't do you any good @@ -858,7 +858,7 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { return 0xDB6; // "Hunh???" } - if (gSaveContext.save.weekEventReg[24] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_20)) { // The player has already talked as a non-Goron at least once. return 0xDB5; // This is our problem (repeat) } @@ -868,7 +868,7 @@ s32 EnJg_GetStartingConversationTextId(EnJg* this, GlobalContext* globalCtx) { } if (player->transformation == PLAYER_FORM_GORON) { - if (gSaveContext.save.weekEventReg[77] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_80)) { // The player has heard the Goron Shrine cheer as a Goron at least once. return 0xDDE; // Come back after entering the race } @@ -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,107 +897,106 @@ 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; if (this->textId == 0xDAC) { this->action = EN_JG_ACTION_FIRST_THAW; } else if (this->textId == 0xDAE) { - gSaveContext.save.weekEventReg[24] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_24_20); } else if (this->textId == 0xDB6) { - gSaveContext.save.weekEventReg[24] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_24_10); } - 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->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 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) { @@ -1014,7 +1013,7 @@ s32 EnJg_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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) { @@ -1029,9 +1028,9 @@ void EnJg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -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..757a8bd86 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,20 +26,18 @@ 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; /* 0x3D0 */ u8 focusedShrineGoronParam; } EnJg; // size = 0x3D4 -extern const ActorInit En_Jg_InitVars; - #endif // Z_EN_JG_H diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/overlay.cfg b/src/overlays/actors/ovl_En_Jgame_Tsn/overlay.cfg deleted file mode 100644 index 9d3fbbf9d..000000000 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Jgame_Tsn -z_en_jgame_tsn.c 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 c16fa4147..92e918c5d 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,32 +11,32 @@ #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 = { +ActorInit En_Jgame_Tsn_InitVars = { ACTOR_EN_JGAME_TSN, ACTORCAT_NPC, FLAGS, @@ -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,94 +103,94 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } for (i = 0; i < ARRAY_COUNT(this->unk_1D8); i++) { this->unk_1D8[i].points = Lib_SegmentedToVirtual(path->points); this->unk_1D8[i].count = path->count; - path = &globalCtx->setupPathList[path->unk1]; + path = &play->setupPathList[path->unk1]; if (path == NULL) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } 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); + Actor_Kill(&this->actor); } this->unk_200.points = Lib_SegmentedToVirtual(path->points); 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); - gSaveContext.save.weekEventReg[90] &= (u8)~0x20; + Collider_DestroyCylinder(play, &this->collider); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_20); } 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); + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] > SECONDS_TO_TIMER(0)) { + 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)) { + if ((player->actor.bgCheckFlags & 1) && !(player->stateFlags1 & PLAYER_STATE1_2000) && (this->unk_2FE == 0) && + (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,41 +279,41 @@ 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; + player->stateFlags1 |= PLAYER_STATE1_20; func_801A2BB8(0x25); - globalCtx->interfaceCtx.unk_280 = 1; - func_80112AFC(globalCtx); - gSaveContext.save.weekEventReg[90] |= 0x20; - func_8010E9F0(4, 0x78); + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; + Interface_InitMinigame(play); + SET_WEEKEVENTREG(WEEKEVENTREG_90_20); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 120); 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.minigameState == MINIGAME_STATE_COUNTDOWN_GO) { func_80C141DC(this); - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_20; } } 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; + player->stateFlags1 |= PLAYER_STATE1_20; + *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; + player->stateFlags1 |= PLAYER_STATE1_20; + *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); + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] == SECONDS_TO_TIMER(0)) { + Message_StartTextbox(play, 0x10A1, &this->actor); this->unk_300 = 0x10A1; - player->stateFlags1 |= 0x20; - *this->unk_208[this->unk_218] &= ~1; + player->stateFlags1 |= PLAYER_STATE1_20; + *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)) { - if (!(gSaveContext.save.weekEventReg[82] & 0x10)) { - gSaveContext.save.weekEventReg[82] |= 0x10; +void func_80C14554(EnJgameTsn* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_82_10)) { + SET_WEEKEVENTREG(WEEKEVENTREG_82_10); } func_80C145FC(this); - } else if (gSaveContext.save.weekEventReg[82] & 0x10) { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_82_10)) { + 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,25 +469,25 @@ 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); - gSaveContext.minigameState = 3; - gSaveContext.unk_3DD0[4] = 5; - gSaveContext.save.weekEventReg[90] &= (u8)~0x20; + func_801477B4(play); + gSaveContext.minigameStatus = MINIGAME_STATUS_END; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_20); func_80C144E4(this); 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.minigamePoints = 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.minigamePoints = 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_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..c32a51565 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,27 +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; - #endif // Z_EN_JGAME_TSN_H diff --git a/src/overlays/actors/ovl_En_Js/overlay.cfg b/src/overlays/actors/ovl_En_Js/overlay.cfg deleted file mode 100644 index 6923c80b4..000000000 --- a/src/overlays/actors/ovl_En_Js/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Js -z_en_js.c 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..d36bbb6c3 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -10,13 +10,24 @@ #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 = { +s32 func_80968B8C(EnJs* this, PlayState* play); +s32 func_809692A8(s32 arg0); +void func_80968A5C(EnJs* this); +void func_80969400(s32 arg0); +void func_8096971C(EnJs* this, PlayState* play); +void func_80969898(EnJs* this, PlayState* play); +void func_80969B5C(EnJs* this, PlayState* play); +void func_80969DA4(EnJs* this, PlayState* play); +void func_8096A104(EnJs* this, PlayState* play); +void func_8096A38C(EnJs* this, PlayState* play); +void func_8096A6F4(EnJs* this, PlayState* play); + +ActorInit En_Js_InitVars = { ACTOR_EN_JS, ACTORCAT_NPC, FLAGS, @@ -28,89 +39,1026 @@ const ActorInit En_Js_InitVars = { (ActorFunc)EnJs_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_8096ABA0 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +static Gfx* D_8096ABCC[] = { + gMoonChildMajorasMaskDL, gMoonChildOdolwasMaskDL, gMoonChildGohtsMaskDL, + gMoonChildGyorgsMaskDL, gMoonChildTwinmoldsMaskDL, +}; -extern ColliderCylinderInit D_8096ABA0; +f32 D_8096ABE0[] = { 1.0f, 0.5f, 0.5f, 0.48f, 0.45f }; -extern UNK_TYPE D_06010880; -extern UNK_TYPE D_06016F58; -extern UNK_TYPE D_06017E98; +f32 D_8096ABF4[] = { 60.0f, 0.0f, 0.0f, 0.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/EnJs_Init.s") +f32 D_8096AC08[] = { -450.0f, 1400.0f, 1470.0f, 1670.0f, 1470.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/EnJs_Destroy.s") +f32 D_8096AC1C[] = { 0.0f, 700.0f, 900.0f, 900.0f, 900.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968A5C.s") +Vec3f D_8096AC30 = { 500.0f, -500.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968B18.s") +void EnJs_Init(Actor* thisx, PlayState* play) { + s32 pad; + s16 cs; + s32 i; + EnJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968B8C.s") + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gMoonChildSkel, &gMoonChildStandingAnim, this->jointTable, + this->morphTable, MOONCHILD_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gMoonChildStandingAnim); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968CB8.s") + this->actionFunc = func_8096971C; + this->maskType = 0; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968DD0.s") + cs = this->actor.cutscene; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968E38.s") + for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { + this->cutscenes[i] = cs; + if (cs != -1) { + this->actor.cutscene = cs; + cs = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80968F48.s") + this->cutsceneIndex = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809691B8.s") + switch (ENJS_GET_TYPE(&this->actor)) { + case 0: + this->maskType = 0; + this->actionFunc = func_8096A6F4; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809692A8.s") + Animation_PlayLoop(&this->skelAnime, &gMoonChildSittingAnim); + func_8016566C(0x3C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096933C.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_20)) { + Inventory_DeleteItem(ITEM_MASK_FIERCE_DEITY, SLOT(ITEM_MASK_FIERCE_DEITY)); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_84_20); + } + break; + case 1: + case 2: + case 3: + case 4: + this->maskType = ENJS_GET_TYPE(&this->actor); + func_80968B8C(this, play); + this->actionFunc = func_80969B5C; + func_80968A5C(this); + if (func_809692A8(ENJS_GET_TYPE(&this->actor) + 4)) { + Actor_Kill(&this->actor); + return; + } + break; + case 5: + case 6: + case 7: + case 8: + this->maskType = ENJS_GET_TYPE(&this->actor) - 4; + this->actionFunc = func_8096A104; + break; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969400.s") +void EnJs_Destroy(Actor* thisx, PlayState* play) { + u32 paramsF; + EnJs* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969494.s") + Collider_DestroyCylinder(play, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809694E8.s") + paramsF = ENJS_GET_TYPE(&this->actor); + switch (paramsF) { + case 0: + func_80165690(); + break; + case 5: + case 6: + case 7: + case 8: + if (!func_809692A8(paramsF)) { + func_80969400(ENJS_GET_TYPE(&this->actor)); + } + break; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969530.s") +void func_80968A5C(EnJs* this) { + if (Rand_ZeroOne() < 0.5f) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildRunningAnim, -10.0f); + this->unk_2B4 = 5.0f; + } else { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildWalkingAnim, -10.0f); + this->unk_2B4 = 2.5f; + } + this->unk_2B8 &= ~4; + this->unk_2BC = Rand_ZeroFloat(40.0f) + 80.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809695FC.s") +void func_80968B18(EnJs* this) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, -10.0f); + this->unk_2B4 = 0.0f; + this->unk_2BC = Rand_ZeroFloat(20.0f) + 40.0f; + this->unk_2B8 |= 4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969688.s") +s32 func_80968B8C(EnJs* this, PlayState* play) { + Path* path; + f32 temp_f0; + f32 temp_f2; + s32 pathIndex = ENJS_GET_PATH_INDEX(&this->actor); + s32 i; + f32 sp18 = 0.0f; + Vec3s* points; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_809696EC.s") + if (pathIndex != 0x3F) { + this->path = &play->setupPathList[pathIndex]; + if (this->path != NULL) { + path = this->path; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096971C.s") + points = Lib_SegmentedToVirtual(path->points); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969748.s") + for (i = 0; i < path->count; i++, points++) { + temp_f0 = points->x - this->actor.world.pos.x; + temp_f2 = points->z - this->actor.world.pos.z; + temp_f0 = SQ(temp_f0) + SQ(temp_f2); + if (i == 0) { + sp18 = temp_f0; + this->unk_2B0 = 0; + } else if (temp_f0 < sp18) { + sp18 = temp_f0; + this->unk_2B0 = i; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969898.s") + this->unk_2B0++; + if (this->unk_2B0 >= path->count) { + this->unk_2B0 = 0; + } + } + } else { + this->path = NULL; + this->unk_2B0 = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969AA0.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969B5C.s") +s32 func_80968CB8(EnJs* this) { + Path* path; + s32 pad; + f32 temp_fa0; + f32 temp_fa1; + Vec3s* temp_v1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969C54.s") + if (this->path == NULL) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_80969DA4.s") + path = this->path; + temp_v1 = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->unk_2B0]; + temp_fa0 = temp_v1->x - this->actor.world.pos.x; + temp_fa1 = temp_v1->z - this->actor.world.pos.z; + this->actor.world.rot.y = Math_Atan2S(temp_fa0, temp_fa1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A080.s") + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x7D0, 0xC8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A104.s") + if ((SQ(temp_fa0) + SQ(temp_fa1)) < SQ(10.0f)) { + this->unk_2B0++; + if (this->unk_2B0 >= path->count) { + this->unk_2B0 = 0; + } + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A184.s") + Math_StepToF(&this->actor.speedXZ, this->unk_2B4, 0.5f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A1E8.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A2C0.s") +s32 func_80968DD0(EnJs* this, PlayState* play) { + if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play) && + Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A38C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A6F4.s") +s32 func_80968E38(s32 arg0) { + s32 i; + s32 count; + u8 mask; + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/EnJs_Update.s") + if (((arg0 < 0) || (arg0 >= 9))) { + return 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/func_8096A9F4.s") + count = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Js/EnJs_Draw.s") + arg0 *= 3; + for (mask = 1, i = 0; i < 8; i++, mask <<= 1) { + if (masksGivenOnMoon[arg0] & mask) { + count++; + } + } + + arg0++; + for (mask = 1, i = 0; i < 8; i++, mask <<= 1) { + if (masksGivenOnMoon[arg0] & mask) { + count++; + } + } + + arg0++; + for (mask = 1, i = 0; i < 5; i++, mask <<= 1) { + if (masksGivenOnMoon[arg0] & mask) { + count++; + } + } + + return count; +} + +s32 EnJs_GetRemainingMasks(void) { + s32 count = 0; + + if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KAFEIS_MASK) == ITEM_MASK_KAFEIS_MASK) { + count++; + } + if (INV_CONTENT(ITEM_MASK_ALL_NIGHT) == ITEM_MASK_ALL_NIGHT) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KEATON) == ITEM_MASK_KEATON) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GARO) == ITEM_MASK_GARO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) { + count++; + } + if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) { + count++; + } + if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_DON_GERO) == ITEM_MASK_DON_GERO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) { + count++; + } + if (INV_CONTENT(ITEM_MASK_CAPTAIN) == ITEM_MASK_CAPTAIN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_STONE) == ITEM_MASK_STONE) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) { + count++; + } + if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) { + count++; + } + if (INV_CONTENT(ITEM_MASK_SCENTS) == ITEM_MASK_SCENTS) { + count++; + } + if (INV_CONTENT(ITEM_MASK_GIANT) == ITEM_MASK_GIANT) { + count++; + } + + count -= func_80968E38(0); + return count; +} + +void EnJs_TakeMask(s32 itemActions, s32 childType) { + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; + s32 temp = 0; + + if ((childType >= 0) && (childType < 9)) { + itemActions -= PLAYER_IA_MASK_TRUTH; + childType *= 3; + if (itemActions < 8) { + masksGivenOnMoon[childType] |= 1 << itemActions; + masksGivenOnMoon[temp] |= 1 << itemActions; + return; + } + + itemActions -= 8; + childType++; + temp++; + if (itemActions < 8) { + masksGivenOnMoon[childType] |= 1 << itemActions; + masksGivenOnMoon[temp] |= 1 << itemActions; + return; + } + + itemActions -= 8; + childType++; + temp++; + if (itemActions < 6) { + masksGivenOnMoon[childType] |= 1 << itemActions; + masksGivenOnMoon[temp] |= 1 << itemActions; + } + } +} + +s32 func_809692A8(s32 arg0) { + switch (arg0) { + case 1: + case 2: + case 3: + case 4: + if (func_80968E38(arg0) < arg0) { + return false; + } + return true; + case 5: + case 6: + case 7: + case 8: + if (func_80968E38(arg0) < (arg0 - 4)) { + return false; + } + return true; + default: + return false; + } +} + +s32 func_8096933C(s32 arg0) { + s32 sp1C; + + switch (arg0) { + case 1: + case 2: + case 3: + case 4: + sp1C = EnJs_GetRemainingMasks(); + if ((func_80968E38(arg0) + sp1C) < arg0) { + return false; + } else { + return true; + } + case 5: + case 6: + case 7: + case 8: + sp1C = EnJs_GetRemainingMasks(); + if ((func_80968E38(arg0) + sp1C) < (arg0 - 4)) { + return false; + } else { + return true; + } + default: + return false; + } +} + +void func_80969400(s32 arg0) { + u8* masksGivenOnMoon = gSaveContext.masksGivenOnMoon; + u8* temp_v0 = &gSaveContext.masksGivenOnMoon[arg0 * 3]; + + if ((arg0 >= 0) && (arg0 < 9)) { + masksGivenOnMoon[0] &= ~temp_v0[0]; + masksGivenOnMoon[1] &= ~temp_v0[1]; + + temp_v0[2] &= 0xF; + masksGivenOnMoon[2] &= ~temp_v0[2]; + + temp_v0[0] = 0; + temp_v0[1] = 0; + temp_v0[2] = 0; + } +} + +void func_80969494(EnJs* this, PlayState* play) { + func_80968A5C(this); + func_801477B4(play); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_80969B5C; +} + +void func_809694E8(EnJs* this, PlayState* play) { + func_801477B4(play); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_8096A104; +} + +void func_80969530(EnJs* this, PlayState* play) { + func_801477B4(play); + this->actor.flags &= ~ACTOR_FLAG_100; + this->actionFunc = func_8096A6F4; + if ((this->actor.home.rot.y == this->actor.shape.rot.y) && (this->unk_2B8 & 0x10)) { + Animation_Change(&this->skelAnime, &gMoonChildGettingUpAnim, -1.0f, + Animation_GetLastFrame(&gMoonChildGettingUpAnim) - 1.0f, 0.0f, ANIMMODE_ONCE, -10.0f); + this->unk_2B8 &= ~0x10; + this->unk_2B8 |= 8; + } +} + +s32 func_809695FC(EnJs* this, PlayState* play) { + if (ENJS_GET_EXIT_INDEX(&this->actor) == 0x3F) { + return false; + } + play->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntrance = play->setupExitList[ENJS_GET_EXIT_INDEX(&this->actor)]; + this->actionFunc = func_8096971C; + play->msgCtx.msgLength = 0; + gSaveContext.respawnFlag = -2; + return true; +} + +void func_80969688(EnJs* this) { + if (this->cutsceneIndex != -1) { + if (ActorCutscene_GetCurrentIndex() == this->cutscenes[this->cutsceneIndex]) { + ActorCutscene_Stop(this->cutscenes[this->cutsceneIndex]); + } + this->cutsceneIndex = -1; + } +} + +void func_809696EC(EnJs* this, s16 arg1) { + func_80969688(this); + this->cutsceneIndex = arg1; +} + +void func_8096971C(EnJs* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); +} + +void func_80969748(EnJs* this, PlayState* play) { + PlayerItemAction itemAction; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemAction = func_80123810(play); + + if (itemAction != PLAYER_IA_NONE) { + this->actionFunc = func_80969898; + } + if (itemAction > PLAYER_IA_NONE) { + func_801477B4(play); + if ((itemAction >= PLAYER_IA_MASK_TRUTH) && (itemAction <= PLAYER_IA_MASK_GIANT)) { + EnJs_TakeMask(itemAction, ENJS_GET_TYPE(&this->actor)); + Inventory_UnequipItem(itemAction - 4); + if (!func_809692A8(ENJS_GET_TYPE(&this->actor))) { + player->actor.textId = 0x2212; + } else { + player->actor.textId = 0x2213; + } + } else if ((itemAction >= PLAYER_IA_MASK_FIERCE_DEITY) && (itemAction <= PLAYER_IA_MASK_DEKU)) { + player->actor.textId = 0x2211; + } else { + player->actor.textId = 0x2210; + } + } + + if (itemAction <= PLAYER_IA_MINUS1) { + func_80151938(play, 0x2216); + } + } +} + +void func_80969898(EnJs* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x2215)) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(play, 0x2217); + break; + case 1: + func_8019F230(); + func_80151938(play, 0x2216); + break; + } + } + break; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x220C: + this->unk_2B8 |= 1; + if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { + func_80151938(play, 0x220F); + break; + } + func_80151938(play, 0x220D); + break; + case 0x220D: + case 0x2213: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + case 0x220E: + func_80151938(play, 0xFF); + this->actionFunc = func_80969748; + break; + case 0x2210: + case 0x2211: + case 0x2212: + player->exchangeItemId = PLAYER_IA_NONE; + func_80151938(play, 0xFF); + this->actionFunc = func_80969748; + break; + case 0x2214: + case 0x2217: + if (!func_809695FC(this, play)) { + func_80969494(this, play); + break; + } + break; + default: + func_80969494(this, play); + break; + } + } + break; + } +} + +void func_80969AA0(EnJs* this, PlayState* play) { + u16 textId; + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + textId = 0x220B; + } else { + textId = 0x2215; + if (!func_809692A8(ENJS_GET_TYPE(&this->actor))) { + if (this->unk_2B8 & 1) { + if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { + textId = 0x220F; + } else { + textId = 0x220E; + } + } else { + textId = 0x220C; + } + } else { + textId = 0x2215; + } + } + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, -10.0f); + Message_StartTextbox(play, textId, &this->actor); +} + +void func_80969B5C(EnJs* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (this->unk_2BC > 0) { + this->unk_2BC--; + if (this->unk_2BC == 0) { + if (this->unk_2B8 & 4) { + func_80968A5C(this); + } else { + func_80968B18(this); + } + } + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80969898; + this->actor.speedXZ = 0.0f; + this->unk_2B4 = 0.0f; + func_80969AA0(this, play); + } else if ((this->actor.xzDistToPlayer < 100.0f) && Player_IsFacingActor(&this->actor, 0x3000, play)) { + func_800B8614(&this->actor, play, 120.0f); + } + func_80968CB8(this); +} + +void func_80969C54(EnJs* this, PlayState* play) { + PlayerItemAction itemAction; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemAction = func_80123810(play); + + if (itemAction != PLAYER_IA_NONE) { + this->actionFunc = func_80969DA4; + } + + if (itemAction > PLAYER_IA_NONE) { + func_801477B4(play); + if ((itemAction >= PLAYER_IA_MASK_TRUTH) && (itemAction <= PLAYER_IA_MASK_GIANT)) { + EnJs_TakeMask(itemAction, ENJS_GET_TYPE(&this->actor)); + Inventory_UnequipItem(itemAction - 4); + if (!func_809692A8(ENJS_GET_TYPE(&this->actor))) { + player->actor.textId = 0x2221; + } else { + player->actor.textId = 0x2222; + } + } else if ((itemAction >= PLAYER_IA_MASK_FIERCE_DEITY) && (itemAction <= PLAYER_IA_MASK_DEKU)) { + player->actor.textId = 0x2220; + } else { + player->actor.textId = 0x221D; + } + } + + if (itemAction <= PLAYER_IA_MINUS1) { + func_80151938(play, 0x221E); + } + } +} + +void func_80969DA4(EnJs* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 6, 0x1838, 0x64); + this->actor.shape.rot.y = this->actor.world.rot.y; + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && + ((play->msgCtx.currentTextId == 0x2219) || (play->msgCtx.currentTextId == 0x221E))) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + if (!func_809695FC(this, play)) { + func_809694E8(this, play); + break; + } + break; + case 1: + func_8019F230(); + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + } + } + break; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x221B: + if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { + func_80151938(play, 0x2219); + break; + } + func_80151938(play, 0x221C); + break; + case 0x2224: + case 0x2226: + case 0x2228: + case 0x222A: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + case 0x2225: + case 0x2227: + case 0x2229: + case 0x222B: + if (!func_809695FC(this, play)) { + func_809694E8(this, play); + break; + } + break; + case 0x2222: + player->exchangeItemId = PLAYER_IA_NONE; + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + case 0x2223: + switch (ENJS_GET_TYPE(&this->actor)) { + case 5: + func_80151938(play, 0x2224); + break; + case 6: + func_80151938(play, 0x2226); + break; + case 7: + func_80151938(play, 0x2228); + break; + case 8: + func_80151938(play, 0x222A); + break; + } + break; + case 0x221C: + func_80151938(play, 0xFF); + this->actionFunc = func_80969C54; + break; + case 0x221D: + case 0x2220: + case 0x2221: + player->exchangeItemId = PLAYER_IA_NONE; + func_80151938(play, 0xFF); + this->actionFunc = func_80969C54; + break; + default: + func_809694E8(this, play); + break; + } + } + break; + } +} + +void func_8096A080(EnJs* this, PlayState* play) { + u16 textId; + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + textId = 0x2218; + } else { + textId = 0x221B; + if (this->unk_2B8 & 1) { + if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { + textId = 0x2219; + } else { + textId = 0x221C; + } + } else { + this->unk_2B8 |= 1; + } + } + Message_StartTextbox(play, textId, &this->actor); +} + +void func_8096A104(EnJs* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80969DA4; + func_8096A080(this, play); + } else if (func_80968DD0(this, play)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void func_8096A184(EnJs* this, PlayState* play) { + u16 textId; + + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + textId = 0x220B; + } else if (func_80968E38(0) >= 20) { + textId = 0x2202; + } else { + textId = 0x21FC; + } + Message_StartTextbox(play, textId, &this->actor); +} + +void func_8096A1E8(EnJs* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, 0.0f); + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actor.flags &= ~ACTOR_FLAG_10000; + this->actionFunc = func_8096A38C; + Message_StartTextbox(play, 0x2208, &this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_84_20); + func_809696EC(this, 0); + } else { + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); + } +} + +void func_8096A2C0(EnJs* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, 0.0f); + } + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + this->actor.flags |= ACTOR_FLAG_10000; + this->actionFunc = func_8096A1E8; + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); + } else { + Actor_PickUp(&this->actor, play, GI_MASK_FIERCE_DEITY, 10000.0f, 1000.0f); + } +} + +void func_8096A38C(EnJs* this, PlayState* play) { + if (SkelAnime_Update(&this->skelAnime)) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildStandingAnim, 0.0f); + this->unk_2B8 |= 2; + } + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + break; + + case 1: + func_8019F230(); + break; + } + + switch (play->msgCtx.currentTextId) { + case 0x21FC: + switch (play->msgCtx.choiceIndex) { + case 0: + func_80151938(play, 0x21FE); + Animation_MorphToPlayOnce(&this->skelAnime, &gMoonChildGettingUpAnim, -5.0f); + this->unk_2B8 |= 0x10; + break; + case 1: + func_80151938(play, 0x21FD); + break; + } + break; + + case 0x21FE: + switch (play->msgCtx.choiceIndex) { + case 0: + func_80151938(play, 0x2200); + func_809696EC(this, 0); + break; + case 1: + func_80151938(play, 0x21FF); + break; + } + break; + + case 0x2203: + switch (play->msgCtx.choiceIndex) { + case 0: + func_80151938(play, 0x2205); + Animation_MorphToPlayOnce(&this->skelAnime, &gMoonChildGettingUpAnim, -5.0f); + this->unk_2B8 |= 0x10; + break; + case 1: + func_80151938(play, 0x2204); + break; + } + } + } + break; + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x2202: + case 0x2205: + case 0x2206: + case 0x2209: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + + case 0x2200: + case 0x2208: + func_809696EC(this, 1); + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + + case 0x2207: + if (INV_CONTENT(ITEM_MASK_FIERCE_DEITY) == ITEM_MASK_FIERCE_DEITY) { + func_80151938(play, 0x2208); + func_809696EC(this, 0); + } else { + func_801477B4(play); + this->actionFunc = func_8096A2C0; + func_8096A2C0(this, play); + } + break; + + case 0x2201: + + case 0x220A: + if (!func_809695FC(this, play)) { + func_80969530(this, play); + } + break; + + default: + func_80969530(this, play); + break; + } + } + break; + } +} + +void func_8096A6F4(EnJs* this, PlayState* play) { + s32 pad; + + if (this->actor.home.rot.y != this->actor.shape.rot.y) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 2, 0x400, 0x100); + if ((this->actor.home.rot.y == this->actor.shape.rot.y) && (this->unk_2B8 & 0x10)) { + Animation_Change(&this->skelAnime, &gMoonChildGettingUpAnim, -1.0f, + Animation_GetLastFrame(&gMoonChildGettingUpAnim) - 1.0f, 0.0f, ANIMMODE_ONCE, -10.0f); + this->unk_2B8 &= ~0x10; + this->unk_2B8 |= 8; + } + this->actor.world.rot.y = this->actor.shape.rot.y; + } + if (SkelAnime_Update(&this->skelAnime)) { + Animation_MorphToLoop(&this->skelAnime, &gMoonChildSittingAnim, -10.0f); + this->unk_2B8 &= ~8; + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_8096A38C; + this->unk_2B8 &= ~2; + func_8096A184(this, play); + return; + } + if (!(this->unk_2B8 & 8) && (this->actor.xzDistToPlayer < 100.0f) && + Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x1000)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void EnJs_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnJs* 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, 40.0f, 25.0f, 40.0f, 5); + + this->actionFunc(this, play); + + if ((this->cutsceneIndex != -1) && (ActorCutscene_GetCurrentIndex() != this->cutscenes[this->cutsceneIndex])) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + } else if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIndex])) { + ActorCutscene_Start(this->cutscenes[this->cutsceneIndex], &this->actor); + } else { + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); + } + } +} + +void func_8096A9F4(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnJs* this = THIS; + + if (limbIndex == MOONCHILD_LIMB_HEAD) { + Matrix_MultVec3f(&D_8096AC30, &thisx->focus.pos); + if ((this->maskType >= 0) && (this->maskType < 5)) { + OPEN_DISPS(play->state.gfxCtx); + + if (this->maskType != 0) { + Matrix_Scale(D_8096ABE0[this->maskType], D_8096ABE0[this->maskType], D_8096ABE0[this->maskType], + MTXMODE_APPLY); + Matrix_RotateZYX(0, -0x4000, -0x36B0, MTXMODE_APPLY); + } + Matrix_Translate(D_8096ABF4[this->maskType], D_8096AC08[this->maskType], D_8096AC1C[this->maskType], + 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_8096ABCC[this->maskType]); + + CLOSE_DISPS(play->state.gfxCtx); + } + } +} + +void EnJs_Draw(Actor* thisx, PlayState* play) { + EnJs* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + func_8096A9F4, &this->actor); +} 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..4508e4944 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.h +++ b/src/overlays/actors/ovl_En_Js/z_en_js.h @@ -2,17 +2,31 @@ #define Z_EN_JS_H #include "global.h" +#include "objects/object_ob/object_ob.h" + +#define ENJS_GET_TYPE(thisx) ((thisx)->params & 0xF) +#define ENJS_GET_PATH_INDEX(thisx) (((thisx)->params & 0xFC00) >> 10) +#define ENJS_GET_EXIT_INDEX(thisx) (((thisx)->params & 0x3F0) >> 4) 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 */ SkelAnime skelAnime; + /* 0x188 */ ColliderCylinder collider; + /* 0x1D4 */ Vec3s jointTable[MOONCHILD_LIMB_MAX]; + /* 0x240 */ Vec3s morphTable[MOONCHILD_LIMB_MAX]; + /* 0x2AC */ Path* path; + /* 0x2B0 */ s32 unk_2B0; + /* 0x2B4 */ f32 unk_2B4; + /* 0x2B8 */ u16 unk_2B8; + /* 0x2BA */ s16 maskType; + /* 0x2BC */ s16 unk_2BC; + /* 0x2BE */ s16 cutscenes[2]; + /* 0x2C2 */ s16 cutsceneIndex; + /* 0x2C4 */ EnJsActionFunc actionFunc; } EnJs; // size = 0x2C8 -extern const ActorInit En_Js_InitVars; - #endif // Z_EN_JS_H diff --git a/src/overlays/actors/ovl_En_Jso/overlay.cfg b/src/overlays/actors/ovl_En_Jso/overlay.cfg deleted file mode 100644 index 050d8bc67..000000000 --- a/src/overlays/actors/ovl_En_Jso/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Jso -z_en_jso.c 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..f36629d27 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 = { @@ -69,7 +69,7 @@ static DamageTable D_809B0F48 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -const ActorInit En_Jso_InitVars = { +ActorInit En_Jso_InitVars = { ACTOR_EN_JSO, ACTORCAT_ENEMY, FLAGS, 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..7f5db0757 100644 --- a/src/overlays/actors/ovl_En_Jso/z_en_jso.h +++ b/src/overlays/actors/ovl_En_Jso/z_en_jso.h @@ -5,15 +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; - #endif // Z_EN_JSO_H diff --git a/src/overlays/actors/ovl_En_Jso2/overlay.cfg b/src/overlays/actors/ovl_En_Jso2/overlay.cfg deleted file mode 100644 index 907202195..000000000 --- a/src/overlays/actors/ovl_En_Jso2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Jso2 -z_en_jso2.c 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..b7ad94d93 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 = { @@ -71,7 +71,7 @@ static DamageTable D_80A7B4F0 = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -const ActorInit En_Jso2_InitVars = { +ActorInit En_Jso2_InitVars = { ACTOR_EN_JSO2, ACTORCAT_ENEMY, FLAGS, 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..274aaa284 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; @@ -14,6 +14,4 @@ typedef struct EnJso2 { /* 0x027C */ char unk_27C[0xE14]; } EnJso2; // size = 0x1090 -extern const ActorInit En_Jso2_InitVars; - #endif // Z_EN_JSO2_H diff --git a/src/overlays/actors/ovl_En_Kaizoku/overlay.cfg b/src/overlays/actors/ovl_En_Kaizoku/overlay.cfg deleted file mode 100644 index 4f77e7de7..000000000 --- a/src/overlays/actors/ovl_En_Kaizoku/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kaizoku -z_en_kaizoku.c 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..da327642b 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -10,48 +10,146 @@ #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* play2); +void EnKaizoku_Draw(Actor* thisx, PlayState* play); -#if 0 -// static DamageTable sDamageTable = { -static DamageTable D_80B8AB3C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(0, 0x1), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0x1), - /* Goron punch */ DMG_ENTRY(1, 0xE), - /* Sword */ DMG_ENTRY(1, 0xE), - /* Goron pound */ DMG_ENTRY(0, 0xD), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0xE), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0xE), - /* Deku launch */ DMG_ENTRY(2, 0xE), - /* 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, 0xE), - /* Zora punch */ DMG_ENTRY(1, 0xE), - /* Spin attack */ DMG_ENTRY(1, 0xD), - /* 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, 0xE), +s32 EnKaizoku_ValidatePictograph(PlayState* play, Actor* actor); +void func_80B85F48(EnKaizoku* this); +void func_80B85FA8(EnKaizoku* this, PlayState* play); +void func_80B868B8(EnKaizoku* this, PlayState* play); +void func_80B86B58(EnKaizoku* this); +void func_80B86B74(EnKaizoku* this, PlayState* play); +void func_80B872A4(EnKaizoku* this); +void func_80B872F4(EnKaizoku* this, PlayState* play); +void func_80B874D8(EnKaizoku* this, PlayState* play); +void func_80B8760C(EnKaizoku* this, PlayState* play); +void func_80B87900(EnKaizoku* this); +void func_80B8798C(EnKaizoku* this, PlayState* play); +void func_80B87C7C(EnKaizoku* this); +void func_80B87CF8(PlayState* play, Vec3f* pos); +void func_80B87D3C(EnKaizoku* this, PlayState* play); +void func_80B87E28(EnKaizoku* this); +void func_80B87E9C(EnKaizoku* this, PlayState* play); +void func_80B87F70(EnKaizoku* this); +void func_80B87FDC(EnKaizoku* this, PlayState* play2); +void func_80B88214(EnKaizoku* this); +void func_80B88278(EnKaizoku* this, PlayState* play); +void func_80B8833C(EnKaizoku* this); +void func_80B88378(EnKaizoku* this, PlayState* play); +void func_80B88770(EnKaizoku* this); +void func_80B887AC(EnKaizoku* this, PlayState* play); +void func_80B88910(EnKaizoku* this); +void func_80B88964(EnKaizoku* this, PlayState* play); +void func_80B88CD8(EnKaizoku* this); +void func_80B88D6C(EnKaizoku* this, PlayState* play); +void func_80B89280(EnKaizoku* this, PlayState* play); +void func_80B894C0(EnKaizoku* this, PlayState* play); +void func_80B8971C(EnKaizoku* this, PlayState* play); + +typedef enum EnKaizokuAction { + /* 0 */ KAIZOKU_ACTION_0, + /* 1 */ KAIZOKU_ACTION_1, + /* 2 */ KAIZOKU_ACTION_2, + /* 3 */ KAIZOKU_ACTION_3, + /* 4 */ KAIZOKU_ACTION_4, + /* 5 */ KAIZOKU_ACTION_5, + /* 6 */ KAIZOKU_ACTION_6, + /* 7 */ KAIZOKU_ACTION_7, + /* 8 */ KAIZOKU_ACTION_8, + /* 9 */ KAIZOKU_ACTION_9, + /* 10 */ KAIZOKU_ACTION_10, + /* 11 */ KAIZOKU_ACTION_11, + /* 12 */ KAIZOKU_ACTION_12, + /* 13 */ KAIZOKU_ACTION_13, + /* 14 */ KAIZOKU_ACTION_14, + /* 15 */ KAIZOKU_ACTION_15, + /* 16 */ KAIZOKU_ACTION_16 +} EnKaizokuAction; + +u16 D_80B8A8D0[] = { + 0x11A4, 0x11A5, 0x11A6, 0x11A7, 0x11A8, 0x11A9, 0x11AA, 0x11AB, 0x11AC, 0x11AD, }; -const ActorInit En_Kaizoku_InitVars = { +Vec3f D_80B8A8E4[] = { + { -70.0f, 9.0f, 30.0f }, { -70.0f, 9.0f, 30.0f }, { -70.0f, 9.0f, 30.0f }, { 41.0f, 55.0f, 11.0f }, + { 41.0f, 55.0f, 11.0f }, { 70.0f, 45.0f, 35.0f }, { 80.0f, 45.0f, 25.0f }, { 0.0f, 0.0f, 0.0f }, + { -70.0f, 9.0f, 30.0f }, { -70.0f, 9.0f, 30.0f }, { -70.0f, 9.0f, 30.0f }, { 41.0f, 55.0f, 11.0f }, + { 41.0f, 55.0f, 11.0f }, { 70.0f, 45.0f, 25.0f }, { 80.0f, 45.0f, 25.0f }, { 0.0f, 0.0f, 0.0f }, + { 90.0f, 9.0f, -30.0f }, { 90.0f, 9.0f, -30.0f }, { 90.0f, 9.0f, -30.0f }, { -41.0f, 55.0f, -11.0f }, + { -41.0f, 55.0f, -11.0f }, { -70.0f, 45.0f, -25.0f }, { -80.0f, 45.0f, -25.0f }, { 0.0f, 0.0f, 0.0f }, +}; + +Vec3f D_80B8AA04[] = { + { 120.0f, 60.0f, -20.0f }, { 120.0f, 60.0f, -20.0f }, { 120.0f, 60.0f, -20.0f }, { -470.0f, 30.0f, -140.0f }, + { -470.0f, 30.0f, -140.0f }, { -410.0f, 80.0f, -130.0f }, { -410.0f, 80.0f, -130.0f }, { 0.0f, 0.0f, 0.0f }, + { 120.0f, 60.0f, -20.0f }, { 120.0f, 60.0f, -20.0f }, { 120.0f, 60.0f, -20.0f }, { -470.0f, 30.0f, -140.0f }, + { -470.0f, 30.0f, -140.0f }, { -410.0f, 80.0f, -130.0f }, { -410.0f, 80.0f, -130.0f }, { 0.0f, 0.0f, 0.0f }, + { -120.0f, 60.0f, 20.0f }, { -120.0f, 60.0f, 20.0f }, { -120.0f, 60.0f, 20.0f }, { 470.0f, 30.0f, 140.0f }, + { 470.0f, 30.0f, 140.0f }, { 410.0f, 80.0f, 130.0f }, { 410.0f, 80.0f, 130.0f }, { 0.0f, 0.0f, 0.0f }, +}; + +Color_RGBA8 D_80B8AB24[] = { + { 255, 255, 90, 255 }, + { 55, 25, 80, 255 }, + { 5, 195, 110, 255 }, +}; + +Color_RGBA8 D_80B8AB30[] = { + { 255, 130, 10, 255 }, + { 185, 130, 210, 255 }, + { 135, 195, 80, 255 }, +}; + +typedef enum EnKaizokuDamageEffect { + /* 0x0 */ KAIZOKU_DMGEFF_NONE, + /* 0x1 */ KAIZOKU_DMGEFF_1, + /* 0x2 */ KAIZOKU_DMGEFF_2, + /* 0x3 */ KAIZOKU_DMGEFF_FREEZE, + /* 0x4 */ KAIZOKU_DMGEFF_4, + /* 0x5 */ KAIZOKU_DMGEFF_5, + /* 0xD */ KAIZOKU_DMGEFF_D = 0xD, + /* 0xE */ KAIZOKU_DMGEFF_E, + /* 0xF */ KAIZOKU_DMGEFF_F +} EnKaizokuDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, KAIZOKU_DMGEFF_1), + /* Deku Stick */ DMG_ENTRY(1, KAIZOKU_DMGEFF_F), + /* Horse trample */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, KAIZOKU_DMGEFF_F), + /* Zora boomerang */ DMG_ENTRY(0, KAIZOKU_DMGEFF_1), + /* Normal arrow */ DMG_ENTRY(1, KAIZOKU_DMGEFF_F), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, KAIZOKU_DMGEFF_1), + /* Goron punch */ DMG_ENTRY(1, KAIZOKU_DMGEFF_E), + /* Sword */ DMG_ENTRY(1, KAIZOKU_DMGEFF_E), + /* Goron pound */ DMG_ENTRY(0, KAIZOKU_DMGEFF_D), + /* Fire arrow */ DMG_ENTRY(2, KAIZOKU_DMGEFF_2), + /* Ice arrow */ DMG_ENTRY(2, KAIZOKU_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, KAIZOKU_DMGEFF_4), + /* Goron spikes */ DMG_ENTRY(1, KAIZOKU_DMGEFF_E), + /* Deku spin */ DMG_ENTRY(0, KAIZOKU_DMGEFF_1), + /* Deku bubble */ DMG_ENTRY(1, KAIZOKU_DMGEFF_E), + /* Deku launch */ DMG_ENTRY(2, KAIZOKU_DMGEFF_E), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, KAIZOKU_DMGEFF_1), + /* Zora barrier */ DMG_ENTRY(0, KAIZOKU_DMGEFF_5), + /* Normal shield */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, KAIZOKU_DMGEFF_E), + /* Zora punch */ DMG_ENTRY(1, KAIZOKU_DMGEFF_E), + /* Spin attack */ DMG_ENTRY(1, KAIZOKU_DMGEFF_D), + /* Sword beam */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, KAIZOKU_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, KAIZOKU_DMGEFF_E), +}; + +ActorInit En_Kaizoku_InitVars = { ACTOR_EN_KAIZOKU, ACTORCAT_ENEMY, FLAGS, @@ -63,120 +161,2001 @@ const ActorInit En_Kaizoku_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B8AB7C = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK4, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, 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_UNK4, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 50, 0, { 0, 0, 0 } }, }; -// static ColliderQuadInit sQuadInit = { -static ColliderQuadInit D_80B8ABA8 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_QUAD, }, - { ELEMTYPE_UNK4, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL | TOUCH_UNK7, BUMP_NONE, OCELEM_NONE, }, +static ColliderQuadInit sQuadInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK4, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 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 AnimationHeader* sAnimations[EN_KAIZOKU_ANIM_MAX] = { + &object_kz_Anim_00F8E4, // EN_KAIZOKU_ANIM_0 + &object_kz_Anim_00EF9C, // EN_KAIZOKU_ANIM_1 + &object_kz_Anim_00E1C8, // EN_KAIZOKU_ANIM_2 + &object_kz_Anim_00DBE4, // EN_KAIZOKU_ANIM_3 + &object_kz_Anim_0058B8, // EN_KAIZOKU_ANIM_4 + &object_kz_Anim_004860, // EN_KAIZOKU_ANIM_5 + &object_kz_Anim_002730, // EN_KAIZOKU_ANIM_6 + &object_kz_Anim_001578, // EN_KAIZOKU_ANIM_7 + &object_kz_Anim_001390, // EN_KAIZOKU_ANIM_8 + &object_kz_Anim_0003CC, // EN_KAIZOKU_ANIM_9 + &object_kz_Anim_000F5C, // EN_KAIZOKU_ANIM_10 + &object_kz_Anim_00E8BC, // EN_KAIZOKU_ANIM_11 + &object_kz_Anim_00ED1C, // EN_KAIZOKU_ANIM_12 + &object_kz_Anim_005644, // EN_KAIZOKU_ANIM_13 + &object_kz_Anim_00F288, // EN_KAIZOKU_ANIM_14 + &object_kz_Anim_0043E4, // EN_KAIZOKU_ANIM_15 + &object_kz_Anim_003A3C, // EN_KAIZOKU_ANIM_16 + &object_kz_Anim_002BA0, // EN_KAIZOKU_ANIM_17 + &object_kz_Anim_001E9C, // EN_KAIZOKU_ANIM_18 +}; -extern DamageTable D_80B8AB3C; -extern ColliderCylinderInit D_80B8AB7C; -extern ColliderQuadInit D_80B8ABA8; +static u8 sAnimationModes[EN_KAIZOKU_ANIM_MAX] = { + ANIMMODE_LOOP, // EN_KAIZOKU_ANIM_0 + ANIMMODE_LOOP, // EN_KAIZOKU_ANIM_1 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_2 + ANIMMODE_LOOP, // EN_KAIZOKU_ANIM_3 + ANIMMODE_LOOP, // EN_KAIZOKU_ANIM_4 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_5 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_6 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_7 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_8 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_9 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_10 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_11 + ANIMMODE_LOOP, // EN_KAIZOKU_ANIM_12 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_13 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_14 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_15 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_16 + ANIMMODE_LOOP, // EN_KAIZOKU_ANIM_17 + ANIMMODE_ONCE, // EN_KAIZOKU_ANIM_18 +}; -extern UNK_TYPE D_060058B8; +void EnKaizoku_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnKaizoku* this = THIS; + Player* player = GET_PLAYER(play); + EffectBlureInit1 blureInit; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/EnKaizoku_Init.s") + this->picto.actor.hintId = TATL_HINT_ID_PIRATE; + this->picto.actor.targetMode = 3; + this->picto.actor.colChkInfo.mass = 80; + ActorShape_Init(&this->picto.actor.shape, 0.0f, ActorShadow_DrawFeet, 0.0f); + this->unk_2CA = this->picto.actor.world.rot.z; + this->picto.actor.colChkInfo.health = 8; + this->exitIndex = KAIZOKU_GET_EXIT_INDEX(&this->picto.actor); + this->switchFlag = KAIZOKU_GET_SWITCHFLAG(&this->picto.actor); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/EnKaizoku_Destroy.s") + if (this->unk_2CA >= 2) { + this->unk_2CA = 0; + } else if (this->unk_2CA == 2) { + this->unk_2CA = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B85858.s") + this->unk_2EC = this->picto.actor.world.rot.z; + this->picto.actor.world.rot.z = 0; + this->picto.actor.colChkInfo.damageTable = &sDamageTable; + SkelAnime_InitFlex(play, &this->skelAnime, &gKaizokuSkel, &object_kz_Anim_0058B8, this->jointTable, + this->morphTable, KAIZOKU_LIMB_MAX); + Collider_InitAndSetCylinder(play, &this->bodyCollider, &this->picto.actor, &sCylinderInit); + Collider_InitAndSetQuad(play, &this->swordCollider, &this->picto.actor, &sQuadInit); + 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 = 0; + blureInit.calcMode = 2; + Effect_Add(play, &this->blureIndex, EFFECT_BLURE1, 0, 0, &blureInit); + Actor_SetScale(&this->picto.actor, 0.0125f); + this->picto.actor.flags |= ACTOR_FLAG_8000000; + this->picto.actor.flags &= ~ACTOR_FLAG_1; + if (this->switchFlag == 127) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B85900.s") + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&this->picto.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B85A00.s") + this->bodyCollider.dim.radius = 20; + this->bodyCollider.dim.height = 65; + this->bodyCollider.dim.yShift = 0; + this->unk_2D6 = this->picto.actor.cutscene; + this->picto.actor.world.pos.y = player->actor.world.pos.y + 160.0f; + this->picto.validationFunc = EnKaizoku_ValidatePictograph; + this->picto.actor.flags |= ACTOR_FLAG_400; + func_80B85F48(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B85E18.s") +void EnKaizoku_Destroy(Actor* thisx, PlayState* play) { + EnKaizoku* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B85EA0.s") + Effect_Destroy(play, this->blureIndex); + Collider_DestroyCylinder(play, &this->bodyCollider); + Collider_DestroyQuad(play, &this->swordCollider); + Audio_RestorePrevBgm(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B85F48.s") +s32 func_80B85858(EnKaizoku* this, PlayState* play) { + Actor* itemAction; + Player* player = GET_PLAYER(play); + s16 prevAction = this->action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B85FA8.s") + for (itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first; itemAction != NULL; + itemAction = itemAction->next) { + //! FAKE: + if (1) {} + if (((itemAction->id == ACTOR_ARMS_HOOK) || (itemAction->id == ACTOR_EN_ARROW)) && (player->unk_D57)) { + if (((itemAction->id != ACTOR_ARMS_HOOK) || (this->action != KAIZOKU_ACTION_13)) && + (this->action != KAIZOKU_ACTION_6)) { + func_80B87C7C(this); + } + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B86804.s") + if (prevAction != this->action) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B868B8.s") +void func_80B85900(EnKaizoku* this) { + if (this->action == KAIZOKU_ACTION_1) { + this->headRot.y = Math_SinS(this->lookTimer * 0x1068) * 0x22D8; + } else if (this->action != KAIZOKU_ACTION_13) { + if ((this->action == KAIZOKU_ACTION_9) || (this->action == KAIZOKU_ACTION_11)) { + Math_SmoothStepToS(&this->headRot.y, this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y, 1, + 500, 0); + this->headRot.y = CLAMP(this->headRot.y, -0x256F, 0x256F); + } else { + this->headRot.y = 0; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B86B58.s") +s32 func_80B85A00(EnKaizoku* this, PlayState* play, s16 arg2) { + Player* player = GET_PLAYER(play); + s16 sp32 = ABS_ALT(this->picto.actor.wallYaw - this->picto.actor.shape.rot.y); + s16 sp30 = ABS_ALT(this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y); + Actor* explosiveActor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B86B74.s") + if (func_800BE184(play, &this->picto.actor, 100.0f, 0x2710, 0x4000, this->picto.actor.shape.rot.y)) { + if (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) { + if (this->action != KAIZOKU_ACTION_2) { + func_80B874D8(this, play); + } + return true; + } else { + func_80B87900(this); + return true; + } + } else if (func_800BE184(play, &this->picto.actor, 100.0f, 0x5DC0, 0x2AA8, this->picto.actor.shape.rot.y)) { + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; + if ((this->picto.actor.bgCheckFlags & 8) && (ABS_ALT(sp32) < 0x2EE0) && + (this->picto.actor.xzDistToPlayer < 90.0f)) { + if (this->action != KAIZOKU_ACTION_6) { + func_80B87C7C(this); + } + return true; + } else if (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) { + if (this->action != KAIZOKU_ACTION_2) { + func_80B874D8(this, play); + } + } else if (this->picto.actor.xzDistToPlayer < BREG(11) + 180.0f) { + func_80B87900(this); + } else if (this->action != KAIZOKU_ACTION_7) { + func_80B87E28(this); + } + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B872A4.s") + explosiveActor = Actor_FindNearby(play, &this->picto.actor, -1, ACTORCAT_EXPLOSIVES, 80.0f); + if (explosiveActor != NULL) { + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B872F4.s") + if (((this->picto.actor.bgCheckFlags & 8) && (sp32 < 0x2EE0)) || (explosiveActor->id == ACTOR_EN_BOM_CHU)) { + if ((explosiveActor->id == ACTOR_EN_BOM_CHU) && + (Actor_DistanceBetweenActors(&this->picto.actor, explosiveActor) < 80.0f) && + (BINANG_ADD(this->picto.actor.shape.rot.y - explosiveActor->world.rot.y, 0x8000) < 0x4000)) { + if (this->action != KAIZOKU_ACTION_6) { + func_80B87C7C(this); + } + } else { + func_80B87900(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B874D8.s") + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8760C.s") + if (this->action != KAIZOKU_ACTION_7) { + func_80B87E28(this); + } + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B87900.s") + if (arg2) { + s16 sp2A; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8798C.s") + //! FAKE: + label:; + if (sp30 >= 10000) { + func_80B87900(this); + } else { + sp2A = player->actor.shape.rot.y - this->picto.actor.shape.rot.y; + if (this->picto.actor.xzDistToPlayer <= 65.0f && !Actor_OtherIsTargeted(play, &this->picto.actor) && + ABS_ALT(sp2A) < 0x5000) { + if (this->action != KAIZOKU_ACTION_9) { + func_80B87F70(this); + return 1; + } + } else if (this->action != KAIZOKU_ACTION_3) { + func_80B88CD8(this); + } + } + return true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B87C7C.s") + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B87CF8.s") +void EnKaizoku_ChangeAnim(EnKaizoku* this, EnKaizokuAnimation animIndex) { + this->animIndex = animIndex; + this->frameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + sAnimationModes[this->animIndex], 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B87D3C.s") +s32 EnKaizoku_ValidatePictograph(PlayState* play, Actor* actor) { + s32 ret = Snap_ValidatePictograph(play, actor, PICTOGRAPH_PIRATE_GOOD, &actor->focus.pos, &actor->shape.rot, 10.0f, + 400.0f, -1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B87E28.s") + ret |= Snap_ValidatePictograph(play, actor, PICTOGRAPH_PIRATE_TOO_FAR, &actor->focus.pos, &actor->shape.rot, 10.0f, + 1200.0f, -1); + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B87E9C.s") +void func_80B85F48(EnKaizoku* this) { + Math_Vec3f_Copy(&this->unk_2F8, &gZeroVec3f); + Math_Vec3f_Copy(&this->unk_304, &gZeroVec3f); + this->unk_2D8 = 1; + this->action = KAIZOKU_ACTION_0; + this->actionFunc = func_80B85FA8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B87F70.s") +void func_80B85FA8(EnKaizoku* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 curFrame = this->skelAnime.curFrame; + s32 sp54; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B87FDC.s") + switch (this->unk_59C) { + case 0: + if (!(this->picto.actor.xzDistToPlayer < 200.0f)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B88214.s") + if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B88278.s") + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); + func_800B7298(play, &this->picto.actor, 0x15); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8833C.s") + sp54 = (this->unk_2CA * 4) + this->unk_2C8; + if (this->unk_2EC != 2) { + player->actor.world.pos.x = this->picto.actor.home.pos.x + 90.0f; + player->actor.world.pos.z = this->picto.actor.home.pos.z + 30.0f; + } else { + player->actor.world.pos.x = this->picto.actor.home.pos.x - 90.0f; + player->actor.world.pos.z = this->picto.actor.home.pos.z - 30.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B88378.s") + player->actor.speedXZ = 0.0f; + this->picto.actor.world.pos.x = this->picto.actor.home.pos.x; + this->picto.actor.world.pos.z = this->picto.actor.home.pos.z; + Message_StartTextbox(play, D_80B8A8D0[sp54], &this->picto.actor); + this->unk_2C8++; + this->picto.actor.flags &= ~ACTOR_FLAG_1; + player->actor.shape.rot.y = player->actor.world.rot.y = + Math_Vec3f_Yaw(&player->actor.world.pos, &this->picto.actor.world.pos); + Math_Vec3f_Copy(&this->subCamEye, &this->unk_5C8); + Math_Vec3f_Copy(&this->subCamAt, &this->unk_5D4); + this->subCamUp.x = -0.11f; + this->picto.actor.draw = EnKaizoku_Draw; + this->unk_598 = 0; + func_801A0238(0, 0xA); + this->unk_59C++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B88770.s") + case 1: + player->actor.shape.rot.y = player->actor.world.rot.y = + Math_Vec3f_Yaw(&player->actor.world.pos, &this->picto.actor.world.pos); + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B887AC.s") + if (this->unk_2EC != 2) { + player->actor.world.pos.x = this->picto.actor.home.pos.x + 90.0f; + player->actor.world.pos.z = this->picto.actor.home.pos.z + 30.0f; + } else { + player->actor.world.pos.x = this->picto.actor.home.pos.x - 90.0f; + player->actor.world.pos.z = this->picto.actor.home.pos.z - 30.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B88910.s") + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_11); + this->unk_598 = 0; + this->unk_59C++; + this->picto.actor.gravity = -2.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B88964.s") + case 2: + if (this->picto.actor.bgCheckFlags & 1) { + if (this->unk_2D8 != 0) { + this->unk_2D8 = 0; + this->picto.actor.world.pos.y = this->picto.actor.floorHeight; + this->picto.actor.velocity.y = 0.0f; + func_800B7298(play, &this->picto.actor, 4); + Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_ONGND); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B88CD8.s") + if (curFrame >= 11.0f) { + this->unk_59C++; + this->unk_598 = 0; + this->subCamUp.x = 0.0f; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B88D6C.s") + case 3: + if (this->frameCount <= curFrame) { + sp54 = this->unk_2CA * 4 + this->unk_2C8; + if (Player_GetMask(play) == PLAYER_MASK_STONE) { + if (D_80B8A8D0[sp54] == 0x11A5) { + sp54 = 8; + } else if (D_80B8A8D0[sp54] == 0x11A9) { + sp54 = 9; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B891B8.s") + Message_StartTextbox(play, D_80B8A8D0[sp54], &this->picto.actor); + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_12); + this->unk_2C8++; + this->unk_598 = 0; + this->unk_59C++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B89280.s") + case 4: + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + this->unk_598 = 0; + this->unk_59C++; + func_801A0238(0x7F, 0); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_13); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B893CC.s") + case 5: + Math_ApproachF(&this->unk_5E0, 2.0f, 0.2f, 1.0f); + if (Animation_OnFrame(&this->skelAnime, 20.0f)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_BOSU_SWORD); + } + if (curFrame >= 30.0f) { + this->unk_598 = 0; + this->unk_59C++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B894C0.s") + case 6: + Math_ApproachF(&this->unk_5E0, 5.0f, 0.3f, 1.0f); + if (this->frameCount <= curFrame) { + this->unk_598 = 7; + this->unk_2F8.x = 1.0f; + this->unk_59C++; + this->unk_2F8.y = 1.0f; + this->unk_2F8.z = 1.0f; + this->unk_304.x = 1.0f; + this->unk_304.y = 1.0f; + this->unk_304.z = 1.0f; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8960C.s") + case 7: + if (this->unk_598 == 0) { + func_800B7298(play, &this->picto.actor, 6); + ActorCutscene_Stop(this->unk_2D6); + this->unk_59C = 0; + this->subCamId = 0; + this->picto.actor.flags &= ~ACTOR_FLAG_100000; + this->picto.actor.flags &= ~ACTOR_FLAG_8000000; + this->picto.actor.flags |= ACTOR_FLAG_1; + func_80B872A4(this); + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8971C.s") + if (this->unk_59C < 7) { + s32 temp_v0_3 = this->unk_2EC * 8; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B89A08.s") + temp_v0_3 += this->unk_59C; + this->unk_5C8.x = D_80B8A8E4[temp_v0_3].x + this->picto.actor.home.pos.x; + this->unk_5C8.y = D_80B8A8E4[temp_v0_3].y + player->actor.world.pos.y; + this->unk_5C8.z = D_80B8A8E4[temp_v0_3].z + this->picto.actor.home.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/EnKaizoku_Update.s") + this->unk_5D4.x = D_80B8AA04[temp_v0_3].x + this->picto.actor.home.pos.x; + this->unk_5D4.y = D_80B8AA04[temp_v0_3].y + player->actor.world.pos.y; + this->unk_5D4.z = D_80B8AA04[temp_v0_3].z + this->picto.actor.home.pos.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8A318.s") + if (this->unk_59C >= 5) { + if (curFrame >= 6.0f) { + Math_ApproachF(&this->unk_2F8.x, 1.0f, 0.3f, 0.3f); + this->unk_2F8.z = this->unk_2F8.y = this->unk_2F8.x; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8A468.s") + if (curFrame >= 22.0f) { + Math_ApproachF(&this->unk_304.x, 1.0f, 0.3f, 0.3f); + this->unk_304.z = this->unk_304.y = this->unk_304.x; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8A6B0.s") + if (this->unk_59C >= 5) { + Math_ApproachF(&this->subCamEye.x, this->unk_5C8.x, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamEye.y, this->unk_5C8.y, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamEye.z, this->unk_5C8.z, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamAt.x, this->unk_5D4.x, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamAt.y, this->unk_5D4.y, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamAt.z, this->unk_5D4.z, 0.5f, this->unk_5E0); + } else { + Math_Vec3f_Copy(&this->subCamEye, &this->unk_5C8); + Math_Vec3f_Copy(&this->subCamAt, &this->unk_5D4); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kaizoku/func_80B8A718.s") + if (this->subCamId != 0) { + this->subCamUp.y = 1.0f; + this->subCamUp.z = 0.0f; + Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); + } +} + +void func_80B86804(EnKaizoku* this, PlayState* play) { + if (this->subCamId == 0) { + if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + return; + } + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); + } + + func_800B7298(play, &this->picto.actor, 0x60); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + this->unk_2B2 = 30; + this->picto.actor.flags &= ~ACTOR_FLAG_1; + this->unk_598 = 0; + this->unk_59C = 0; + this->unk_2D8 = 0; + this->action = KAIZOKU_ACTION_0; + this->actionFunc = func_80B868B8; + this->picto.actor.speedXZ = 0.0f; +} + +void func_80B868B8(EnKaizoku* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 4000, 1); + this->subCamEye.x = Math_SinS(this->picto.actor.yawTowardsPlayer) * 155.0f + this->picto.actor.world.pos.x; + this->subCamEye.y = this->picto.actor.world.pos.y + 10.0f; + this->subCamEye.z = Math_CosS(this->picto.actor.yawTowardsPlayer) * 115.0f + this->picto.actor.world.pos.z; + + this->subCamAt.x = Math_SinS(this->picto.actor.yawTowardsPlayer) + this->picto.actor.world.pos.x; + this->subCamAt.y = this->picto.actor.world.pos.y + 30.0f; + this->subCamAt.z = Math_CosS(this->picto.actor.yawTowardsPlayer) * 11.0f + this->picto.actor.world.pos.z; + + switch (this->unk_59C) { + case 0: + if (this->frameCount <= curFrame) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_14); + this->unk_2C8 = 3; + this->unk_598 = 0; + this->unk_59C++; + } + break; + + case 1: + if (this->frameCount <= curFrame) { + s32 textId; + + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_15); + textId = this->unk_2CA * 4 + this->unk_2C8; + Message_StartTextbox(play, D_80B8A8D0[textId], &this->picto.actor); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_LAST2_SHOUT); + this->unk_598 = 0; + this->unk_59C++; + } + break; + + case 2: + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + func_800B7298(play, &this->picto.actor, 6); + ActorCutscene_Stop(this->unk_2D6); + this->subCamId = 0; + play->nextEntrance = play->setupExitList[this->exitIndex]; + gSaveContext.nextCutsceneIndex = 0; + Scene_SetExitFade(play); + play->transitionTrigger = TRANS_TRIGGER_START; + this->unk_59C++; + this->action = KAIZOKU_ACTION_16; + } + + break; + } + + if (this->subCamId != 0) { + this->subCamUp.x = 0.0f; + this->subCamUp.y = 1.0f; + this->subCamUp.z = 0.0f; + Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); + } +} + +void func_80B86B58(EnKaizoku* this) { + this->unk_2D8 = 0; + this->action = KAIZOKU_ACTION_0; + this->actionFunc = func_80B86B74; +} + +void func_80B86B74(EnKaizoku* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 textId; + f32 curFrame = this->skelAnime.curFrame; + + if (this->unk_59C < 2) { + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 0xFA0, 1); + player->actor.world.pos.x = this->picto.actor.home.pos.x + 90.0f; + player->actor.world.pos.z = this->picto.actor.home.pos.z + 30.0f; + this->picto.actor.world.pos.x = this->picto.actor.home.pos.x; + this->picto.actor.world.pos.z = this->picto.actor.home.pos.z; + this->unk_5C8.x = player->actor.world.pos.x + 39.0f; + this->unk_5C8.y = player->actor.world.pos.y + 4.0f; + this->unk_5C8.z = player->actor.world.pos.z - 41.0f; + this->unk_5D4.x = player->actor.world.pos.x - 150.0f; + this->unk_5D4.y = player->actor.world.pos.y + 60.0f; + this->unk_5D4.z = player->actor.world.pos.z + 50.0f; + } + + player->actor.shape.rot.y = player->actor.world.rot.y = + Math_Vec3f_Yaw(&player->actor.world.pos, &this->picto.actor.world.pos); + switch (this->unk_59C) { + case 0: + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_17); + this->unk_2C8 = 2; + textId = this->unk_2CA * 4 + this->unk_2C8; + Message_StartTextbox(play, D_80B8A8D0[textId], &this->picto.actor); + this->unk_2D9 = 0; + this->unk_598 = 0; + this->unk_59C++; + break; + + case 1: + if (this->frameCount <= curFrame) { + if (this->unk_2D9 == 0) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_DAMM_BREATH); + this->unk_2D9 = 1; + } else { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + } + } + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_18); + func_800B7298(play, &this->picto.actor, 0x85); + this->unk_5A0 = 0; + this->unk_598 = 0; + this->unk_59C++; + } + break; + + case 2: + this->unk_5C8.x = player->actor.world.pos.x + 77.0f; + this->unk_5C8.y = player->actor.world.pos.y + 84.0f; + this->unk_5C8.z = player->actor.world.pos.z - 71.0f; + + this->unk_5D4.x = player->actor.world.pos.x - 110.0f; + this->unk_5D4.y = player->actor.world.pos.y; + this->unk_5D4.z = player->actor.world.pos.z + 30.0f; + this->unk_5A0++; + if (curFrame >= 1.0f) { + Math_ApproachZeroF(&this->unk_2F8.x, 0.3f, 0.3f); + Math_ApproachZeroF(&this->unk_304.x, 0.3f, 0.3f); + this->unk_2F8.z = this->unk_2F8.y = this->unk_2F8.x; + this->unk_304.z = this->unk_304.y = this->unk_304.x; + } + if (this->unk_5A0 == 0x12) { + Actor* temp_v0_2; + + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_SHOUT); + temp_v0_2 = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ARROW, this->picto.actor.world.pos.x, + this->picto.actor.world.pos.y + 10.0f, this->picto.actor.world.pos.z, + this->picto.actor.shape.rot.x, this->picto.actor.shape.rot.y, + this->picto.actor.shape.rot.z, -8); + if (temp_v0_2 != NULL) { + temp_v0_2->gravity = -10.0f; + play->envCtx.fillScreen = true; + } + } + + if (this->unk_5A0 >= 0x12) { + Math_ApproachF(&this->unk_5EC, 60.0f, 1.0f, 20.0f); + this->unk_5E8 = this->unk_5EC / 60.0f; + play->envCtx.screenFillColor[3] = this->unk_5E8 * 255.0f; + play->envCtx.screenFillColor[0] = play->envCtx.screenFillColor[1] = play->envCtx.screenFillColor[2] = + 255; + } + + if ((this->frameCount <= curFrame) && (this->unk_5A0 >= 0x28)) { + this->picto.actor.draw = NULL; + this->unk_598 = 10; + Math_Vec3f_Copy(&this->unk_2F8, &gZeroVec3f); + Math_Vec3f_Copy(&this->unk_304, &gZeroVec3f); + this->unk_59C++; + } + break; + + case 3: + if (this->unk_598 == 0) { + Math_ApproachZeroF(&this->unk_5EC, 0.5f, 10.0f); + this->unk_5E8 = this->unk_5EC / 60.0f; + play->envCtx.screenFillColor[3] = this->unk_5E8 * 255.0f; + if (play->envCtx.screenFillColor[3] < 10) { + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[3] = 0; + play->envCtx.fillScreen = false; + this->unk_59C = 0; + this->subCamId = 0; + func_800B7298(play, &this->picto.actor, 6); + ActorCutscene_Stop(this->unk_2D6); + if (this->switchFlag >= 0) { + Flags_SetSwitch(play, this->switchFlag); + } + Actor_Kill(&this->picto.actor); + } + } + break; + } + Math_ApproachF(&this->subCamEye.x, this->unk_5C8.x, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamEye.y, this->unk_5C8.y, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamEye.z, this->unk_5C8.z, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamAt.x, this->unk_5D4.x, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamAt.y, this->unk_5D4.y, 0.5f, this->unk_5E0); + Math_ApproachF(&this->subCamAt.z, this->unk_5D4.z, 0.5f, this->unk_5E0); + Math_ApproachF(&this->unk_5E0, 10.0f, 0.5f, 100.0f); + + if (this->subCamId != 0) { + this->subCamUp.x = 0.0f; + this->subCamUp.z = 0.0f; + this->subCamUp.y = 1.0f; + Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); + } +} + +void func_80B872A4(EnKaizoku* this) { + this->picto.actor.speedXZ = 0.0f; + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_0); + this->action = KAIZOKU_ACTION_1; + this->actionFunc = func_80B872F4; + this->picto.actor.shape.shadowScale = 90.0f; +} + +void func_80B872F4(EnKaizoku* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if ((this->lookTimer == 0) && !func_80B85858(this, play) && !func_80B85A00(this, play, false)) { + s16 yawDiff = this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y; + + if ((this->picto.actor.xzDistToPlayer < 100.0f) && (player->meleeWeaponState != 0) && (yawDiff >= 0x1F40)) { + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; + func_80B88CD8(this); + } else if (Actor_IsFacingPlayer(&this->picto.actor, 0xBB8)) { + if ((this->picto.actor.xzDistToPlayer < 400.0f && this->picto.actor.xzDistToPlayer > 150.0f) && + (Rand_ZeroOne() < 0.7f)) { + if ((Rand_ZeroOne() > 0.5f) || (ABS_ALT(yawDiff) < 0x3000)) { + func_80B88214(this); + } else { + func_80B88910(this); + } + } else if (Rand_ZeroOne() > 0.1f) { + func_80B8833C(this); + } else { + func_80B88CD8(this); + } + } else { + func_80B88770(this); + } + } +} + +void func_80B874D8(EnKaizoku* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_3); + if (Math_SinS(player->actor.shape.rot.y - this->picto.actor.shape.rot.y) > 0.0f) { + this->picto.actor.speedXZ = -10.0f; + } else if (Math_SinS(player->actor.shape.rot.y - this->picto.actor.shape.rot.y) < 0.0f) { + this->picto.actor.speedXZ = 10.0f; + } else if (Rand_ZeroOne() > 0.5f) { + this->picto.actor.speedXZ = 10.0f; + } else { + this->picto.actor.speedXZ = -10.0f; + } + + this->skelAnime.playSpeed = 1.0f; + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; + this->unk_2B2 = 6; + this->action = KAIZOKU_ACTION_2; + this->unk_2E0 = 0.0f; + this->actionFunc = func_80B8760C; +} + +void func_80B8760C(EnKaizoku* this, PlayState* play) { + s16 var_v0; + s32 temp_ft0; + s32 temp_ft1; + + this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer + 0x3A98; + if ((this->picto.actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&this->picto.actor, play, this->picto.actor.speedXZ, + this->picto.actor.shape.rot.y + 0x4000)) { + if (this->picto.actor.bgCheckFlags & 8) { + if (this->picto.actor.speedXZ >= 0.0f) { + var_v0 = this->picto.actor.shape.rot.y + 0x4000; + } else { + var_v0 = this->picto.actor.shape.rot.y - 0x4000; + } + var_v0 = this->picto.actor.wallYaw - var_v0; + } else { + this->picto.actor.speedXZ *= -0.8f; + var_v0 = 0; + } + + if (ABS_ALT(var_v0) > 0x4000) { + func_80B87C7C(this); + return; + } + } + + if (this->picto.actor.xzDistToPlayer <= 65.0f) { + Math_ApproachF(&this->unk_2E0, -4.0f, 1.0f, 1.5f); + } else if (this->picto.actor.xzDistToPlayer > 40.0f) { + Math_ApproachF(&this->unk_2E0, 4.0f, 1.0f, 1.5f); + } else { + Math_ApproachZeroF(&this->unk_2E0, 1.0f, 6.65f); + } + + if (this->unk_2E0 != 0.0f) { + this->picto.actor.world.pos.x += Math_SinS(this->picto.actor.yawTowardsPlayer) * this->unk_2E0; + this->picto.actor.world.pos.z += Math_CosS(this->picto.actor.yawTowardsPlayer) * this->unk_2E0; + } + + this->skelAnime.playSpeed = 1.0f; + temp_ft0 = this->skelAnime.curFrame - this->skelAnime.playSpeed; + temp_ft1 = this->skelAnime.curFrame + this->skelAnime.playSpeed; + if (this->skelAnime.curFrame != 0.0f && ((temp_ft0 < 0 && temp_ft1 > 0) || (temp_ft0 < 5 && temp_ft1 >= 6))) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); + } + + if (!(play->gameplayFrames & 0x5F)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + } + + if (this->unk_2B2 == 0) { + this->picto.actor.shape.rot.y = this->picto.actor.yawTowardsPlayer; + if (!func_80B85858(this, play)) { + if (this->picto.actor.xzDistToPlayer <= 70.0f) { + func_80B87F70(this); + } else { + func_80B87E28(this); + } + } + } else { + if (this->picto.actor.speedXZ >= 0.0f) { + this->picto.actor.shape.rot.y += 0x4000; + } else { + this->picto.actor.shape.rot.y -= 0x4000; + } + } +} + +void func_80B87900(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_7); + + if (this->swordState != 0) { + this->swordState = -1; + } + this->unk_2D8 = 0; + this->picto.actor.speedXZ = 0.0f; + this->unk_2B2 = Rand_S16Offset(10, 10); + this->bodyCollider.base.acFlags |= AC_HARD; + this->lookTimer = 12; + this->action = KAIZOKU_ACTION_12; + this->actionFunc = func_80B8798C; +} + +void func_80B8798C(EnKaizoku* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s16 temp_v0; + + this->unk_2D8 = 1; + if (this->unk_2B2 == 0) { + this->skelAnime.playSpeed = 1.0f; + } + if (this->lookTimer == 0) { + this->unk_2D8 = 0; + temp_v0 = this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y; + if (ABS_ALT(temp_v0) <= 0x4000 && this->picto.actor.xzDistToPlayer < 40.0f && + fabsf(this->picto.actor.playerHeightRel) < 50.0f) { + if (func_800BE184(play, &this->picto.actor, 100.0f, 10000, 0x4000, this->picto.actor.shape.rot.y)) { + if (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) { + this->bodyCollider.base.acFlags &= ~AC_HARD; + func_80B874D8(this, play); + } else if (!(play->gameplayFrames & 1)) { + func_80B87900(this); + } else { + this->bodyCollider.base.acFlags &= ~AC_HARD; + func_80B87E28(this); + } + } else { + temp_v0 = player->actor.shape.rot.y - this->picto.actor.shape.rot.y; + if (ABS_ALT(temp_v0) < 0x4000) { + this->bodyCollider.base.acFlags &= ~AC_HARD; + func_80B87F70(this); + } else { + this->bodyCollider.base.acFlags &= ~AC_HARD; + func_80B88CD8(this); + } + } + } else { + this->bodyCollider.base.acFlags &= ~AC_HARD; + func_80B88CD8(this); + } + } else if (this->unk_2B2 == 0 && + func_800BE184(play, &this->picto.actor, 100.0f, 10000, 0x4000, this->picto.actor.shape.rot.y)) { + if (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) { + this->bodyCollider.base.acFlags &= ~AC_HARD; + func_80B874D8(this, play); + } else if (!func_80B85858(this, play)) { + if (!(play->gameplayFrames & 1)) { + if (this->picto.actor.xzDistToPlayer < 100.0f && Rand_ZeroOne() > 0.7f) { + this->bodyCollider.base.acFlags &= ~AC_HARD; + func_80B87C7C(this); + } else { + this->bodyCollider.base.acFlags &= ~AC_HARD; + func_80B87E28(this); + } + } else { + func_80B87900(this); + } + } + } +} + +void func_80B87C7C(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_8); + this->picto.actor.speedXZ = 6.5f; + this->picto.actor.velocity.y = 15.0f; + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_TEKU_JUMP); + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; + this->bodyCollider.info.elemType = ELEMTYPE_UNK4; + this->bodyCollider.base.colType = COLTYPE_NONE; + this->swordCollider.info.elemType = ELEMTYPE_UNK4; + this->action = KAIZOKU_ACTION_6; + this->actionFunc = func_80B87D3C; +} + +Color_RGBA8 D_80B8AC58 = { 200, 160, 120, 255 }; +Color_RGBA8 D_80B8AC5C = { 130, 90, 50, 255 }; + +Vec3f D_80B8AC60 = { 0.0f, -1.5f, 0.0f }; +Vec3f D_80B8AC6C = { 0.0f, -0.2f, 0.0f }; + +void func_80B87CF8(PlayState* play, Vec3f* pos) { + EffectSsKirakira_SpawnSmall(play, pos, &D_80B8AC60, &D_80B8AC6C, &D_80B8AC58, &D_80B8AC5C); +} + +void func_80B87D3C(EnKaizoku* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 0xFA0, 1); + if (this->picto.actor.velocity.y >= 5.0f) { + func_80B87CF8(play, &this->leftFootPos); + func_80B87CF8(play, &this->rightFootPos); + } + + this->unk_2D8 = 0; + if ((this->frameCount <= curFrame) && (this->picto.actor.bgCheckFlags & 3)) { + this->bodyCollider.info.elemType = ELEMTYPE_UNK1; + this->bodyCollider.base.colType = COLTYPE_HIT3; + this->swordCollider.info.elemType = ELEMTYPE_UNK2; + this->picto.actor.shape.rot.x = 0; + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y = this->picto.actor.yawTowardsPlayer; + this->picto.actor.speedXZ = 0.0f; + this->picto.actor.velocity.y = 0.0f; + this->picto.actor.world.pos.y = this->picto.actor.floorHeight; + func_80B87F70(this); + } +} + +void func_80B87E28(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_8); + this->picto.actor.speedXZ = -8.0f; + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_TEKU_JUMP); + this->bodyCollider.info.elemType = ELEMTYPE_UNK4; + this->bodyCollider.base.colType = COLTYPE_NONE; + this->swordCollider.info.elemType = ELEMTYPE_UNK4; + this->action = KAIZOKU_ACTION_7; + this->actionFunc = func_80B87E9C; + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; +} + +void func_80B87E9C(EnKaizoku* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + this->unk_2D8 = 0; + if (this->frameCount <= curFrame) { + if ((this->picto.actor.xzDistToPlayer < 170.0f) && (this->picto.actor.xzDistToPlayer > 140.0f) && + (Rand_ZeroOne() < 0.2f)) { + func_80B88910(this); + } else { + func_80B87900(this); + } + } + if (!(play->state.frames & 0x5F)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + } +} + +void func_80B87F70(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_9); + this->unk_2D0 = 0; + this->swordCollider.base.atFlags &= ~AT_BOUNCED; + this->picto.actor.speedXZ = 0.0f; + AudioSfx_StopByPosAndId(&this->picto.actor.projectedPos, NA_SE_EN_PIRATE_BREATH); + this->action = KAIZOKU_ACTION_9; + this->actionFunc = func_80B87FDC; +} + +void func_80B87FDC(EnKaizoku* this, PlayState* play2) { + PlayState* play = play2; + f32 curFrame; + s16 sp2E; + s16 sp2C; + Player* player = GET_PLAYER(play2); + + curFrame = this->skelAnime.curFrame; + sp2E = ABS_ALT(player->actor.shape.rot.y - this->picto.actor.shape.rot.y); + sp2C = ABS_ALT(this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y); + this->picto.actor.speedXZ = 0.0f; + + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_ATTACK); + this->swordState = 1; + } else if (Animation_OnFrame(&this->skelAnime, 6.0f)) { + this->swordState = -1; + } + + if (this->swordCollider.base.atFlags & AT_BOUNCED) { + this->swordState = -1; + this->swordCollider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + func_80B87E28(this); + return; + } + + this->unk_2D8 = 0; + if (this->frameCount <= curFrame) { + if (!Actor_IsFacingPlayer(&this->picto.actor, 0x1554)) { + func_80B872A4(this); + + if (sp2C > 0x4000) { + this->lookTimer = 20; + } + } else { + if (Rand_ZeroOne() > 0.7f || this->picto.actor.xzDistToPlayer >= 120.0f) { + func_80B872A4(this); + return; + } + + this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; + + if (BREG(12) * 0.1f + 0.01f * 40.0f < Rand_ZeroOne()) { + func_80B87900(this); + } else if (sp2E <= 0x2710) { + if (sp2C > 0x4000) { + this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; + func_80B88CD8(this); + } else { + func_80B85A00(this, play, true); + } + } else { + func_80B88CD8(this); + } + } + } +} + +void func_80B88214(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_8); + this->unk_2B2 = 0; + this->picto.actor.speedXZ = 10.0f; + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y = this->picto.actor.yawTowardsPlayer; + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_TEKU_JUMP); + this->action = KAIZOKU_ACTION_5; + this->actionFunc = func_80B88278; +} + +void func_80B88278(EnKaizoku* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + this->unk_2D8 = 0; + if (this->frameCount <= curFrame) { + this->picto.actor.speedXZ = 0.0f; + if (!Actor_IsFacingPlayer(&this->picto.actor, 0x1554)) { + func_80B872A4(this); + this->unk_2B2 = Rand_ZeroOne() * 5.0f + 5.0f; + } else { + func_80B87F70(this); + } + } + if (!(play->gameplayFrames & 0x5F)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + } +} + +void func_80B8833C(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_4); + this->action = KAIZOKU_ACTION_4; + this->actionFunc = func_80B88378; +} + +void func_80B88378(EnKaizoku* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 sp30; + s32 sp2C; + s16 sp2A; + + if (!func_80B85858(this, play)) { + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 0x2EE, 0); + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; + if (this->picto.actor.xzDistToPlayer <= 40.0f) { + Math_ApproachF(&this->picto.actor.speedXZ, -8.0f, 1.0f, 1.5f); + } else if (this->picto.actor.xzDistToPlayer > 55.0f) { + Math_ApproachF(&this->picto.actor.speedXZ, 8.0f, 1.0f, 1.5f); + } else { + Math_ApproachZeroF(&this->picto.actor.speedXZ, 2.0f, 6.65f); + } + + this->skelAnime.playSpeed = 1.0f; + sp2A = ABS_ALT(player->actor.shape.rot.y - this->picto.actor.shape.rot.y); + if (this->picto.actor.xzDistToPlayer < 150.0f && player->meleeWeaponState != 0 && sp2A >= 0x2000) { + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; + if (Rand_ZeroOne() > 0.7f) { + func_80B88CD8(this); + return; + } + } + + sp30 = this->skelAnime.curFrame - this->skelAnime.playSpeed; + sp2C = this->skelAnime.curFrame + this->skelAnime.playSpeed; + if (!Actor_IsFacingPlayer(&this->picto.actor, 0x11C7)) { + if (Rand_ZeroOne() > 0.5f) { + func_80B88CD8(this); + } else { + func_80B872A4(this); + } + } else if (this->picto.actor.xzDistToPlayer < 90.0f) { + if ((Rand_ZeroOne() > 0.03f) || ((this->picto.actor.xzDistToPlayer <= 65.0f) && (sp2A < 0x4000))) { + func_80B87F70(this); + } else if (Actor_OtherIsTargeted(play, &this->picto.actor) && (Rand_ZeroOne() > 0.5f)) { + func_80B87E28(this); + } else { + func_80B88CD8(this); + } + } + + if (!func_80B85A00(this, play, false)) { + if (this->picto.actor.xzDistToPlayer < 210.0f && this->picto.actor.xzDistToPlayer > 150.0f && + Actor_IsFacingPlayer(&this->picto.actor, 0x1388)) { + if (Actor_IsTargeted(play, &this->picto.actor)) { + if (Rand_ZeroOne() > 0.5f) { + func_80B88214(this); + } else { + func_80B88910(this); + } + } else { + func_80B88CD8(this); + return; + } + } + + if (!(play->gameplayFrames & 0x5F)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + } + + if ((this->skelAnime.curFrame != 0.0f) && ((sp30 < 0 && sp2C > 0) || (sp30 < 4 && sp2C >= 5))) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); + } + } + } +} + +void func_80B88770(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_3); + this->action = KAIZOKU_ACTION_10; + this->actionFunc = func_80B887AC; +} + +void func_80B887AC(EnKaizoku* this, PlayState* play) { + s16 temp_v0; + s16 var_a2; + + if (!func_80B85858(this, play) && !func_80B85A00(this, play, false)) { + temp_v0 = this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y; + if (temp_v0 > 0) { + var_a2 = (s16)(temp_v0 * 0.25f) + 0x7D0; + } else { + var_a2 = (s16)(temp_v0 * 0.25f) - 0x7D0; + } + this->picto.actor.shape.rot.y += var_a2; + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; + this->skelAnime.playSpeed = 1.0f; + + if (Actor_IsFacingPlayer(&this->picto.actor, 0x1388)) { + if (Rand_ZeroOne() > 0.8f) { + func_80B88CD8(this); + } else { + func_80B8833C(this); + } + } + if (!(play->gameplayFrames & 0x5F)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + } + } +} + +void func_80B88910(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_10); + this->swordCollider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + this->unk_2D0 = 0; + this->action = KAIZOKU_ACTION_11; + this->actionFunc = func_80B88964; + this->picto.actor.speedXZ = 0.0f; +} + +void func_80B88964(EnKaizoku* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 curFrame = this->skelAnime.curFrame; + s16 v1; + s16 a0; + s32 pad; + + if (this->unk_2D0 < 2) { + if (this->swordCollider.base.atFlags & AT_BOUNCED) { + this->swordCollider.base.atFlags &= ~(AT_BOUNCED | AT_HIT); + this->unk_2D0 = 1; + this->skelAnime.playSpeed = 1.0f; + } + } + + if (this->skelAnime.curFrame <= 8.0f) { + this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; + } else { + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + this->swordState = 1; + this->picto.actor.speedXZ = 10.0f; + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_ATTACK); + } else if (Animation_OnFrame(&this->skelAnime, 21.0f)) { + this->picto.actor.speedXZ = 0.0f; + } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { + this->swordState = -1; + } + } + + this->unk_2D8 = 0; + if (this->frameCount <= curFrame && this->unk_2D0 < 2) { + if (!Actor_IsFacingPlayer(&this->picto.actor, 0x1554)) { + func_80B872A4(this); + this->unk_2B2 = Rand_ZeroOne() * 5.0f + 5.0f; + this->lookTimer = 46; + return; + } + + if (this->unk_2D0 != 0) { + func_80B87E28(this); + return; + } + + if ((Rand_ZeroOne() > 0.7f) || (this->picto.actor.xzDistToPlayer >= 120.0f)) { + func_80B872A4(this); + this->unk_2B2 = Rand_ZeroOne() * 5.0f + 5.0f; + return; + } + + this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; + if (BREG(12) * 0.1f + 0.01f * 40.0f < Rand_ZeroOne()) { + func_80B87900(this); + return; + } + + v1 = ABS_ALT(player->actor.shape.rot.y - this->picto.actor.shape.rot.y); + if (v1 <= 0x2710) { + + a0 = ABS_ALT(this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y); + if (a0 > 0x4000) { + this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; + func_80B88CD8(this); + } else { + func_80B85A00(this, play, true); + } + } else { + func_80B88CD8(this); + } + } +} + +void func_80B88CD8(EnKaizoku* this) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_3); + this->picto.actor.speedXZ = randPlusMinusPoint5Scaled(12.0f); + this->skelAnime.playSpeed = 1.0f; + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y; + this->unk_2B2 = Rand_ZeroOne() * 30.0f + 30.0f; + this->action = KAIZOKU_ACTION_3; + this->actionFunc = func_80B88D6C; + this->unk_2E0 = 0.0f; +} + +void func_80B88D6C(EnKaizoku* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s16 sp2A; + s32 temp_ft4; + s32 temp_ft5; + s16 yaw; + + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 0xFA0, 1); + if (!func_80B85858(this, play) && !func_80B85A00(this, play, false)) { + this->picto.actor.world.rot.y = this->picto.actor.shape.rot.y + 0x4000; + sp2A = player->actor.shape.rot.y + 0x8000; + if (Math_SinS(sp2A - this->picto.actor.shape.rot.y) >= 0.0f) { + this->picto.actor.speedXZ -= 0.25f; + if (this->picto.actor.speedXZ < -8.0f) { + this->picto.actor.speedXZ = -8.0f; + } + } else if (Math_SinS((sp2A - this->picto.actor.shape.rot.y)) < 0.0f) { + this->picto.actor.speedXZ += 0.25f; + if (this->picto.actor.speedXZ > 8.0f) { + this->picto.actor.speedXZ = 8.0f; + } + } + + if ((this->picto.actor.bgCheckFlags & 8) || + !Actor_TestFloorInDirection(&this->picto.actor, play, this->picto.actor.speedXZ, + this->picto.actor.shape.rot.y + 0x4000)) { + + if (this->picto.actor.bgCheckFlags & 8) { + if (this->picto.actor.speedXZ >= 0.0f) { + yaw = this->picto.actor.shape.rot.y + 0x4000; + } else { + yaw = this->picto.actor.shape.rot.y - 0x4000; + } + yaw = this->picto.actor.wallYaw - yaw; + } else { + this->picto.actor.speedXZ *= -0.8f; + yaw = 0; + } + + if (ABS_ALT(yaw) > 0x4000) { + this->picto.actor.speedXZ *= -0.8f; + if (this->picto.actor.speedXZ < 0.0f) { + this->picto.actor.speedXZ -= 0.5f; + } else { + this->picto.actor.speedXZ += 0.5f; + } + } + } + + if (this->picto.actor.xzDistToPlayer <= 65.0f) { + Math_ApproachF(&this->unk_2E0, -4.0f, 1.0f, 1.5f); + } else if (this->picto.actor.xzDistToPlayer > 40.0f) { + Math_ApproachF(&this->unk_2E0, 4.0f, 1.0f, 1.5f); + } else { + Math_ApproachZeroF(&this->unk_2E0, 1.0f, 6.65f); + } + + if (this->unk_2E0 != 0.0f) { + this->picto.actor.world.pos.x += Math_SinS(this->picto.actor.shape.rot.y) * this->unk_2E0; + this->picto.actor.world.pos.z += Math_CosS(this->picto.actor.shape.rot.y) * this->unk_2E0; + } + + temp_ft4 = this->skelAnime.curFrame - this->skelAnime.playSpeed; + temp_ft5 = this->skelAnime.curFrame + this->skelAnime.playSpeed; + if (this->skelAnime.curFrame != 0.0f) { + if (((temp_ft4 < 0 && temp_ft5 > 0) || (temp_ft4 < 5 && temp_ft5 > 5))) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_GERUDOFT_WALK); + } + } + + if (!(play->gameplayFrames & 0x5F)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_BREATH); + } + + if (this->picto.actor.xzDistToPlayer <= 65.0f) { + func_80B87F70(this); + } else if (this->unk_2B2 == 0) { + if (Actor_OtherIsTargeted(play, &this->picto.actor) && (Rand_ZeroOne() > 0.5f)) { + func_80B87E28(this); + } else { + func_80B872A4(this); + } + } + } +} + +// EnKaizoku_SetupStunned +void func_80B891B8(EnKaizoku* this) { + if (this->picto.actor.bgCheckFlags & 1) { + this->picto.actor.speedXZ = 0.0f; + } + + if (this->action == KAIZOKU_ACTION_11) { + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_5); + } + + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->unk_2B8 == 0)) { + this->unk_2B8 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_COMMON_FREEZE); + this->unk_2D8 = 1; + + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { + this->unk_2B6 = 40; + } + + this->action = KAIZOKU_ACTION_13; + this->actionFunc = func_80B89280; +} + +// EnKaizoku_Stunned +void func_80B89280(EnKaizoku* this, PlayState* play) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) { + if (this->unk_2B8 != 0 && this->unk_2B8 < 60) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + } + } + + if (this->picto.actor.bgCheckFlags & 2) { + this->picto.actor.speedXZ = 0.0f; + } + + if (this->picto.actor.bgCheckFlags & 1) { + if (this->picto.actor.speedXZ < 0.0f) { + this->picto.actor.speedXZ += 0.05f; + } + } + + if ((this->unk_2B6 == 0) && (this->unk_2B8 == 0) && !CHECK_FLAG_ALL(this->picto.actor.flags, ACTOR_FLAG_2000) && + (this->picto.actor.bgCheckFlags & 1)) { + this->unk_2D8 = 0; + func_80B85A00(this, play, true); + + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX || + this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Actor_SpawnIceEffects(play, &this->picto.actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, + 0.7f, 0.4f); + this->unk_2B8 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->picto.actor.flags |= ACTOR_FLAG_400; + } + } +} + +void func_80B893CC(EnKaizoku* this, PlayState* play) { + Vec3f sp34; + + Matrix_RotateYS(this->picto.actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_MultVecZ(-10.0f, &sp34); + Math_Vec3f_Copy(&this->unk_3C4, &sp34); + this->lookTimer = 0; + this->unk_2D8 = 0; + this->picto.actor.speedXZ = 0.0f; + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_5); + + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->unk_2B8 != 0)) { + Actor_SpawnIceEffects(play, &this->picto.actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.7f, + 0.4f); + this->unk_2B8 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->picto.actor.flags |= ACTOR_FLAG_400; + } + + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_DAMAGE); + this->action = KAIZOKU_ACTION_14; + this->actionFunc = func_80B894C0; +} + +void func_80B894C0(EnKaizoku* this, PlayState* play) { + s16 temp_v0; + + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 4500, 0); + if (!func_80B85858(this, play) && !func_80B85A00(this, play, false) && (this->unk_3C4.x < 1.0f) && + (this->unk_3C4.z < 1.0f)) { + temp_v0 = this->picto.actor.wallYaw - this->picto.actor.shape.rot.y; + if (this->picto.actor.bgCheckFlags & 8) { + if (ABS_ALT(temp_v0) < 0x3000 && (this->picto.actor.xzDistToPlayer < 90.0f)) { + func_80B87C7C(this); + return; + } + } + + if (this->picto.actor.xzDistToPlayer <= 65.0f && ((play->gameplayFrames % 8) != 0)) { + this->swordCollider.info.elemType = ELEMTYPE_UNK2; + func_80B87F70(this); + } else { + func_80B87E28(this); + } + } +} + +void func_80B8960C(EnKaizoku* this, PlayState* play) { + Vec3f sp24; + + this->picto.actor.flags |= ACTOR_FLAG_100000; + Matrix_RotateYS(this->picto.actor.yawTowardsPlayer, MTXMODE_NEW); + Matrix_MultVecZ(-10.0f, &sp24); + Math_Vec3f_Copy(&this->unk_3C4, &sp24); + EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_16); + + if (((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) && + (this->unk_2B8 == 0)) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + this->picto.actor.speedXZ = 0.0f; + this->unk_2D8 = 1; + func_800B7298(play, &this->picto.actor, 0x7B); + Enemy_StartFinishingBlow(play, &this->picto.actor); + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_PIRATE_DEAD); + this->picto.actor.flags |= ACTOR_FLAG_8000000; + this->picto.actor.flags &= ~ACTOR_FLAG_1; + this->picto.actor.flags &= ~ACTOR_FLAG_400; + this->unk_598 = 0; + this->unk_59C = 0; + this->action = KAIZOKU_ACTION_15; + this->actionFunc = func_80B8971C; +} + +void func_80B8971C(EnKaizoku* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + Player* player; + + if (this->picto.actor.bgCheckFlags & 2) { + this->picto.actor.speedXZ = 0.0f; + } + + if (this->picto.actor.bgCheckFlags & 1) { + Math_SmoothStepToF(&this->picto.actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); + } + + if ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX) || + (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) { + if (this->unk_2B8 == 0) { + return; + } + Actor_SpawnIceEffects(play, &this->picto.actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 0.7f, + 0.4f); + this->unk_2B8 = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + if (curFrame >= 25.0f) { + player = GET_PLAYER(play); + if (this->subCamId == 0) { + if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + return; + } + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + } + + Math_Vec3f_Copy(&this->unk_3C4, &gZeroVec3f); + player->actor.world.pos.x = this->picto.actor.home.pos.x + 90.0f; + player->actor.world.pos.z = this->picto.actor.home.pos.z + 30.0f; + this->picto.actor.world.pos.x = this->picto.actor.home.pos.x; + this->picto.actor.world.pos.z = this->picto.actor.home.pos.z; + + this->subCamEye.x = this->unk_5C8.x = player->actor.world.pos.x + 39.0f; + this->subCamEye.y = this->unk_5C8.y = player->actor.world.pos.y + 4.0f; + this->subCamEye.z = this->unk_5C8.z = player->actor.world.pos.z - 41.0f; + + this->subCamAt.x = this->unk_5D4.x = player->actor.world.pos.x - 150.0f; + this->subCamAt.y = this->unk_5D4.y = player->actor.world.pos.y + 60.0f; + this->subCamAt.z = this->unk_5D4.z = player->actor.world.pos.z + 50.0f; + + player->actor.shape.rot.y = player->actor.world.rot.y = + Math_Vec3f_Yaw(&player->actor.world.pos, &this->picto.actor.world.pos); + + if (this->subCamId != 0) { + this->subCamUp.x = 0.0f; + this->subCamUp.y = 1.0f; + this->subCamUp.z = 0.0f; + Play_SetCameraAtEyeUp(play, this->subCamId, &this->subCamAt, &this->subCamEye, &this->subCamUp); + } + } + + Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 0xFA0, 1); + SkelAnime_Update(&this->skelAnime); + if (this->frameCount <= curFrame) { + this->unk_2D8 = 0; + func_80B86B58(this); + } else if (Animation_OnFrame(&this->skelAnime, 10.0f)) { + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_EN_GERUDOFT_DOWN); + } +} + +void func_80B89A08(EnKaizoku* this, PlayState* play) { + s32 sp64 = 0; + Vec3f sp58; + s32 i; + + if (gSaveContext.save.playerData.health <= 0x10) { + this->swordCollider.info.toucher.damage = 0; + } else { + this->swordCollider.info.toucher.damage = 4; + } + + if (!(this->swordCollider.base.atFlags & AT_BOUNCED) && (this->swordCollider.base.atFlags & AT_HIT)) { + if ((gSaveContext.save.playerData.health <= 0x10) && (this->action != KAIZOKU_ACTION_16)) { + this->unk_2D0 = 2; + this->subCamId = 0; + this->picto.actor.flags |= ACTOR_FLAG_100000; + + if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + this->actionFunc = func_80B86804; + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + this->actionFunc = func_80B86804; + } + return; + } else if ((this->action == KAIZOKU_ACTION_11) && (this->swordCollider.base.at == &GET_PLAYER(play)->actor)) { + func_800B8D98(play, &this->picto.actor, 3.0f, this->picto.actor.yawTowardsPlayer, 1.0f); + Health_ChangeBy(play, -0xC); + if ((gSaveContext.save.playerData.health <= 0x10) && (this->action != KAIZOKU_ACTION_16)) { + Health_ChangeBy(play, 0x10); + this->unk_2D0 = 2; + this->subCamId = 0; + this->picto.actor.flags |= ACTOR_FLAG_100000; + + if (!ActorCutscene_GetCanPlayNext(this->unk_2D6)) { + ActorCutscene_SetIntentToPlay(this->unk_2D6); + this->actionFunc = func_80B86804; + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_2D6, &this->picto.actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->picto.actor.cutscene); + this->actionFunc = func_80B86804; + } + return; + } + } + + if (this->swordCollider.base.at->id == ACTOR_OBJ_TARU) { + this->swordCollider.base.at->home.rot.z = 1; + } + } + + if ((this->picto.actor.bgCheckFlags & 8) && (this->picto.actor.wallBgId != BG_ACTOR_MAX) && + ((this->action == KAIZOKU_ACTION_2) || (this->action == KAIZOKU_ACTION_3) || + (this->action == KAIZOKU_ACTION_4) || (this->action == KAIZOKU_ACTION_1))) { + func_80B87F70(this); + } + + if ((this->bodyCollider.base.acFlags & AC_HIT) && (this->action > KAIZOKU_ACTION_0) && (this->unk_2D0 < 2) && + (this->action != KAIZOKU_ACTION_6) && (this->action != KAIZOKU_ACTION_12) && + (this->action != KAIZOKU_ACTION_14) && (this->action != KAIZOKU_ACTION_15)) { + Actor_SetDropFlag(&this->picto.actor, &this->bodyCollider.info); + AudioSfx_StopByPosAndId(&this->picto.actor.projectedPos, NA_SE_EN_PIRATE_BREATH); + + switch (this->picto.actor.colChkInfo.damageEffect) { + case KAIZOKU_DMGEFF_5: + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->unk_2B8 == 0)) { + this->unk_2B8 = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + } + /* fallthrough */ + case KAIZOKU_DMGEFF_1: + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + this->unk_2B8 == 0) { + Actor_SetColorFilter(&this->picto.actor, 0, 120, 0, 40); + this->bodyCollider.info.elemType = ELEMTYPE_UNK1; + this->bodyCollider.base.colType = COLTYPE_HIT3; + this->swordCollider.info.elemType = ELEMTYPE_UNK2; + func_80B891B8(this); + } + break; + + case KAIZOKU_DMGEFF_F: + if ((this->action != KAIZOKU_ACTION_5) && (this->action != KAIZOKU_ACTION_7) && + (this->action < KAIZOKU_ACTION_14)) { + sp64 = 1; + } + break; + + case KAIZOKU_DMGEFF_E: + sp64 = 1; + break; + + case KAIZOKU_DMGEFF_D: + if (this->action == KAIZOKU_ACTION_13) { + sp64 = 1; + } else if (this->action != KAIZOKU_ACTION_6) { + func_80B87C7C(this); + } + break; + + case KAIZOKU_DMGEFF_2: + if ((this->action != KAIZOKU_ACTION_5) && (this->action != KAIZOKU_ACTION_7) && + (this->action < KAIZOKU_ACTION_14)) { + this->unk_2B8 = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + sp64 = 1; + } + break; + + case KAIZOKU_DMGEFF_FREEZE: + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->unk_2B8 == 0)) { + Actor_ApplyDamage(&this->picto.actor); + this->bodyCollider.info.elemType = ELEMTYPE_UNK1; + this->bodyCollider.base.colType = COLTYPE_HIT3; + this->swordCollider.info.elemType = ELEMTYPE_UNK4; + this->unk_2B8 = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffFrozenSteamScale = 1.5f; + this->picto.actor.flags &= ~ACTOR_FLAG_400; + if (this->picto.actor.colChkInfo.health <= 0) { + func_80B8960C(this, play); + } else { + func_80B891B8(this); + } + } + break; + + case KAIZOKU_DMGEFF_4: + if (((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_SFX) && + (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX)) || + (this->unk_2B8 == 0)) { + this->unk_2B8 = 20; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, this->picto.actor.focus.pos.x, + this->picto.actor.focus.pos.y, this->picto.actor.focus.pos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + sp64 = 1; + } + break; + } + + if (sp64) { + Actor_SetColorFilter(&this->picto.actor, 0x4000, 255, 0, 8); + Actor_ApplyDamage(&this->picto.actor); + if (this->picto.actor.colChkInfo.health <= 0) { + func_80B8960C(this, play); + return; + } + + this->bodyCollider.info.elemType = ELEMTYPE_UNK1; + this->bodyCollider.base.colType = COLTYPE_HIT3; + this->swordCollider.info.elemType = ELEMTYPE_UNK4; + Math_Vec3f_Copy(&sp58, &this->picto.actor.focus.pos); + for (i = 0; i < 3; i++) { + sp58.y += Rand_ZeroFloat(20.0f); + CollisionCheck_BlueBlood(play, NULL, &sp58); + } + + func_80B893CC(this, play); + } + } else if (this->bodyCollider.base.acFlags & AC_HIT) { + if ((this->action != KAIZOKU_ACTION_6) && (this->action != KAIZOKU_ACTION_14) && + (this->action != KAIZOKU_ACTION_15)) { + Vec3f pos; + Player* player = GET_PLAYER(play); + + pos.x = this->bodyCollider.info.bumper.hitPos.x; + pos.y = this->bodyCollider.info.bumper.hitPos.y; + pos.z = this->bodyCollider.info.bumper.hitPos.z; + + if (player->transformation != PLAYER_FORM_HUMAN) { + player->unk_B84 = this->picto.actor.yawTowardsPlayer; + player->unk_B80 = 15.0f; + } + + this->bodyCollider.base.acFlags &= ~AC_HIT; + Actor_PlaySfxAtPos(&this->picto.actor, NA_SE_IT_SHIELD_BOUND); + EffectSsHitmark_SpawnFixedScale(play, 3, &pos); + CollisionCheck_SpawnShieldParticlesMetal(play, &pos); + } + } +} + +static Vec3f sFootOffset = { 300.0f, 0.0f, 0.0f }; + +static Vec3f sSwordTipOffset = { 0.0f, -3000.0f, 0.0f }; +static Vec3f sSwordHiltOffset = { 400.0f, 0.0f, 0.0f }; + +static Vec3f sSwordQuadOffset1 = { 1600.0f, -4000.0f, 0.0f }; +static Vec3f sSwordQuadOffset0 = { -3000.0f, -2000.0f, 1300.0f }; +static Vec3f sSwordQuadOffset3 = { -3000.0f, -2000.0f, -1300.0f }; +static Vec3f sSwordQuadOffset2 = { 1000.0f, 1000.0f, 0.0f }; + +static TexturePtr sEyeTextures[] = { + gKaizokuEyeOpenTex, + gKaizokuEyeHalfTex, + gKaizokuEyeClosedTex, + gKaizokuEyeHalfTex, +}; + +void EnKaizoku_Update(Actor* thisx, PlayState* play2) { + EnKaizoku* this = THIS; + PlayState* play = play2; + Vec3f sp34; + s32 pad; + + if (this->unk_2D8 == 0) { + SkelAnime_Update(&this->skelAnime); + } + + if (this->action != KAIZOKU_ACTION_0) { + func_80B85900(this); + } + + if (this->blinkTimer != 0) { + this->blinkTimer--; + } + if (this->unk_2B2 != 0) { + this->unk_2B2--; + } + if (this->lookTimer != 0) { + this->lookTimer--; + } + if (this->unk_2B6 != 0) { + this->unk_2B6--; + } + if (this->unk_598 != 0) { + this->unk_598--; + } + if (this->unk_2B8 != 0) { + this->unk_2B8--; + } + + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->picto.actor); + if (this->action != KAIZOKU_ACTION_0) { + func_80B89A08(this, play); + } + if (this->action != KAIZOKU_ACTION_0) { + Actor_SetFocus(&this->picto.actor, 60.0f); + } + + Actor_SetScale(&this->picto.actor, 0.0125f); + if (this->blinkTimer == 0) { + this->eyeIndex++; + if (this->eyeIndex >= ARRAY_COUNT(sEyeTextures)) { + this->eyeIndex = 0; + this->blinkTimer = Rand_S16Offset(20, 60); + } + } + + if (this->picto.actor.bgCheckFlags & 1) { + Matrix_RotateYS(this->picto.actor.shape.rot.y + this->unk_2F4, 0); + Matrix_MultVecZ(this->unk_2F0, &sp34); + this->picto.actor.world.pos.x += this->unk_3C4.x + sp34.x; + this->picto.actor.world.pos.z += this->unk_3C4.z + sp34.z; + Math_ApproachZeroF(&this->unk_3C4.x, 1.0f, 2.0f); + Math_ApproachZeroF(&this->unk_3C4.z, 1.0f, 2.0f); + Math_ApproachZeroF(&this->unk_2F0, 1.0f, 5.0f); + } + + Actor_UpdateBgCheckInfo(play, &this->picto.actor, 35.0f, 40.0f, 35.0f, 0x1F); + Collider_UpdateCylinder(&this->picto.actor, &this->bodyCollider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->bodyCollider.base); + if ((this->unk_2D0 < 2) && (this->action != KAIZOKU_ACTION_0)) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->bodyCollider.base); + } + if (this->swordState > 0) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->swordCollider.base); + } +} + +s32 EnKaizoku_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnKaizoku* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + if (limbIndex == KAIZOKU_LIMB_05) { + *dList = NULL; + } + + if (limbIndex == KAIZOKU_LIMB_03) { + rot->z += this->headRot.x; + rot->x += this->headRot.y; + rot->y += this->headRot.z; + } else if (limbIndex == KAIZOKU_LIMB_06) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, D_80B8AB24[this->unk_2EC].r, D_80B8AB24[this->unk_2EC].g, + D_80B8AB24[this->unk_2EC].b, 255); + } else { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, D_80B8AB30[this->unk_2EC].r, D_80B8AB30[this->unk_2EC].g, + D_80B8AB30[this->unk_2EC].b, 255); + } + + CLOSE_DISPS(play->state.gfxCtx); + + return false; +} + +void EnKaizoku_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f swordTip; + Vec3f swordHilt; + EnKaizoku* this = THIS; + + if (limbIndex == KAIZOKU_LIMB_R_SWORD) { + Matrix_MultVec3f(&sSwordQuadOffset1, &this->swordCollider.dim.quad[1]); + Matrix_MultVec3f(&sSwordQuadOffset0, &this->swordCollider.dim.quad[0]); + Matrix_MultVec3f(&sSwordQuadOffset3, &this->swordCollider.dim.quad[3]); + Matrix_MultVec3f(&sSwordQuadOffset2, &this->swordCollider.dim.quad[2]); + Collider_SetQuadVertices(&this->swordCollider, &this->swordCollider.dim.quad[0], + &this->swordCollider.dim.quad[1], &this->swordCollider.dim.quad[2], + &this->swordCollider.dim.quad[3]); + Matrix_MultVec3f(&sSwordTipOffset, &swordTip); + Matrix_MultVec3f(&sSwordHiltOffset, &swordHilt); + + if ((this->swordState == 1) && ((this->action == KAIZOKU_ACTION_9) || (this->action == KAIZOKU_ACTION_11))) { + EffectBlure_AddVertex(Effect_GetByIndex(this->blureIndex), &swordTip, &swordHilt); + } else if (this->swordState != 0) { + EffectBlure_AddSpace(Effect_GetByIndex(this->blureIndex)); + this->swordState = 0; + } + } else { + Actor_SetFeetPos(&this->picto.actor, limbIndex, KAIZOKU_LIMB_L_FOOT, &sFootOffset, KAIZOKU_LIMB_R_FOOT, + &sFootOffset); + } + + if (limbIndex == KAIZOKU_LIMB_L_FOOT) { + Matrix_MultVec3f(&sFootOffset, &this->leftFootPos); + } else if (limbIndex == KAIZOKU_LIMB_R_FOOT) { + Matrix_MultVec3f(&sFootOffset, &this->rightFootPos); + } + + if (limbIndex == KAIZOKU_LIMB_02 || limbIndex == KAIZOKU_LIMB_06 || limbIndex == KAIZOKU_LIMB_07 || + limbIndex == KAIZOKU_LIMB_08 || limbIndex == KAIZOKU_LIMB_0A || limbIndex == KAIZOKU_LIMB_0C || + limbIndex == KAIZOKU_LIMB_0D || limbIndex == KAIZOKU_LIMB_0F || limbIndex == KAIZOKU_LIMB_11 || + limbIndex == KAIZOKU_LIMB_12 || limbIndex == KAIZOKU_LIMB_L_FOOT || limbIndex == KAIZOKU_LIMB_14 || + limbIndex == KAIZOKU_LIMB_15 || limbIndex == KAIZOKU_LIMB_R_FOOT || limbIndex == KAIZOKU_LIMB_17) { + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } +} + +void EnKaizoku_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { + EnKaizoku* this = THIS; + + if (limbIndex == KAIZOKU_LIMB_R_SWORD) { + Matrix_Scale(this->unk_2F8.x, this->unk_2F8.y, this->unk_2F8.z, MTXMODE_APPLY); + } + if (limbIndex == KAIZOKU_LIMB_10) { + Matrix_Scale(this->unk_304.x, this->unk_304.y, this->unk_304.z, MTXMODE_APPLY); + } +} + +void EnKaizoku_Draw(Actor* thisx, PlayState* play) { + f32 pad[4]; + f32 drawDmgEffAlpha; + EnKaizoku* this = THIS; + + func_8012C2DC(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + OPEN_DISPS(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex])); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnKaizoku_OverrideLimbDraw, EnKaizoku_PostLimbDraw, + EnKaizoku_TransformLimbDraw, &this->picto.actor); + + if (this->unk_2B8 != 0) { + drawDmgEffAlpha = this->unk_2B8 * 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->picto.actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, drawDmgEffAlpha, + this->drawDmgEffType); + } + + CLOSE_DISPS(play->state.gfxCtx); +} 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..ad161088e 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h @@ -2,21 +2,98 @@ #define Z_EN_KAIZOKU_H #include "global.h" +#include "z64snap.h" +#include "objects/object_kz/object_kz.h" + +#define KAIZOKU_GET_EXIT_INDEX(thisx) ((thisx)->params & 0x3F) +#define KAIZOKU_GET_SWITCHFLAG(thisx) (((thisx)->params >> 6) & 0x7F) struct EnKaizoku; -typedef void (*EnKaizokuActionFunc)(struct EnKaizoku*, GlobalContext*); +typedef void (*EnKaizokuActionFunc)(struct EnKaizoku*, PlayState*); + +typedef enum EnKaizokuAnimation { + /* 0 */ EN_KAIZOKU_ANIM_0, + /* 1 */ EN_KAIZOKU_ANIM_1, + /* 2 */ EN_KAIZOKU_ANIM_2, + /* 3 */ EN_KAIZOKU_ANIM_3, + /* 4 */ EN_KAIZOKU_ANIM_4, + /* 5 */ EN_KAIZOKU_ANIM_5, + /* 6 */ EN_KAIZOKU_ANIM_6, + /* 7 */ EN_KAIZOKU_ANIM_7, + /* 8 */ EN_KAIZOKU_ANIM_8, + /* 9 */ EN_KAIZOKU_ANIM_9, + /* 10 */ EN_KAIZOKU_ANIM_10, + /* 11 */ EN_KAIZOKU_ANIM_11, + /* 12 */ EN_KAIZOKU_ANIM_12, + /* 13 */ EN_KAIZOKU_ANIM_13, + /* 14 */ EN_KAIZOKU_ANIM_14, + /* 15 */ EN_KAIZOKU_ANIM_15, + /* 16 */ EN_KAIZOKU_ANIM_16, + /* 17 */ EN_KAIZOKU_ANIM_17, + /* 18 */ EN_KAIZOKU_ANIM_18, + /* 19 */ EN_KAIZOKU_ANIM_MAX +} EnKaizokuAnimation; 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 */ PictoActor picto; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ Vec3s jointTable[KAIZOKU_LIMB_MAX]; + /* 0x21C */ Vec3s morphTable[KAIZOKU_LIMB_MAX]; + /* 0x2AC */ EnKaizokuActionFunc actionFunc; + /* 0x2B0 */ s16 action; + /* 0x2B2 */ s16 unk_2B2; + /* 0x2B4 */ s16 lookTimer; + /* 0x2B6 */ s16 unk_2B6; + /* 0x2B8 */ s16 unk_2B8; + /* 0x2BA */ s16 drawDmgEffType; + /* 0x2BC */ s16 switchFlag; + /* 0x2BE */ s16 unk_2BE; + /* 0x2C0 */ f32 drawDmgEffScale; + /* 0x2C4 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2C8 */ s16 unk_2C8; + /* 0x2CA */ s16 unk_2CA; + /* 0x2CC */ s16 eyeIndex; + /* 0x2CE */ s16 blinkTimer; + /* 0x2D0 */ s16 unk_2D0; + /* 0x2D2 */ s16 swordState; + /* 0x2D4 */ s16 exitIndex; + /* 0x2D6 */ s16 unk_2D6; + /* 0x2D8 */ u8 unk_2D8; + /* 0x2D9 */ u8 unk_2D9; + /* 0x2DC */ f32 frameCount; + /* 0x2E0 */ f32 unk_2E0; + /* 0x2E4 */ EnKaizokuAnimation animIndex; + /* 0x2E8 */ s32 bodyPartsPosIndex; + /* 0x2EC */ s32 unk_2EC; + /* 0x2F0 */ f32 unk_2F0; + /* 0x2F4 */ s16 unk_2F4; + /* 0x2F8 */ Vec3f unk_2F8; + /* 0x304 */ Vec3f unk_304; + /* 0x310 */ Vec3f bodyPartsPos[15]; + /* 0x3C4 */ Vec3f unk_3C4; + /* 0x3D0 */ s32 blureIndex; + /* 0x3D4 */ ColliderCylinder bodyCollider; + /* 0x420 */ ColliderQuad swordCollider; + /* 0x4A0 */ ColliderTris blockCollider; // Unused. Inferred from OoT + /* 0x4C0 */ ColliderTrisElement blockElements[2]; // Unused. Inferred from OoT + /* 0x578 */ Vec3s headRot; + /* 0x580 */ Vec3f rightFootPos; + /* 0x58C */ Vec3f leftFootPos; + /* 0x598 */ s32 unk_598; + /* 0x59C */ s16 unk_59C; + /* 0x59E */ s16 subCamId; + /* 0x5A0 */ s16 unk_5A0; + /* 0x5A2 */ s16 unk_5A2; + /* 0x5A4 */ Vec3f subCamEye; + /* 0x5B0 */ Vec3f subCamAt; + /* 0x5BC */ Vec3f subCamUp; + /* 0x5C8 */ Vec3f unk_5C8; + /* 0x5D4 */ Vec3f unk_5D4; + /* 0x5E0 */ f32 unk_5E0; + /* 0x5E4 */ f32 unk_5E4; + /* 0x5E8 */ f32 unk_5E8; + /* 0x5EC */ f32 unk_5EC; } EnKaizoku; // size = 0x5F0 -extern const ActorInit En_Kaizoku_InitVars; - #endif // Z_EN_KAIZOKU_H diff --git a/src/overlays/actors/ovl_En_Kakasi/overlay.cfg b/src/overlays/actors/ovl_En_Kakasi/overlay.cfg deleted file mode 100644 index f933ca862..000000000 --- a/src/overlays/actors/ovl_En_Kakasi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kakasi -z_en_kakasi.c 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 78441bc41..0346749a9 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); @@ -66,7 +67,7 @@ static ColliderCylinderInit D_80971D80 = { { 20, 70, 0, { 0, 0, 0 } }, }; -const ActorInit En_Kakasi_InitVars = { +ActorInit En_Kakasi_InitVars = { ACTOR_EN_KAKASI, ACTORCAT_NPC, FLAGS, @@ -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,69 +122,69 @@ 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) { //! FAKE: tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actorCutscenes[i] = tempCutscene); i++; } - if (this->aboveGroundStatus) { - if (gSaveContext.save.weekEventReg[79] & 8) { + if (this->aboveGroundStatus != 0) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_08)) { this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; EnKakasi_SetupIdleUnderground(this); } else { - Actor_SetFocus(&this->actor, 60.0f); - this->unkFunc = EnKakasi_8096F88C; - if (gSaveContext.save.weekEventReg[83] & 1) { + Actor_SetFocus(&this->picto.actor, 60.0f); + this->picto.validationFunc = EnKakasi_ValidatePictograph; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_83_01)) { EnKakasi_InitTimeSkipDialogue(this); } else { EnKakasi_SetupIdleStanding(this); @@ -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->sceneId == 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->sceneId == 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)) { + !CHECK_EVENTINF(EVENTINF_17)) { - 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; - gSaveContext.save.weekEventReg[83] &= (u8)~1; - this->unkMsgState1AC = 5; - player->stateFlags1 |= 0x20; - this->actor.flags |= ACTOR_FLAG_10000; + this->picto.actor.textId = 0x1653; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_83_01); + this->talkState = TEXT_STATE_5; + player->stateFlags1 |= PLAYER_STATE1_20; + this->picto.actor.flags |= ACTOR_FLAG_10000; } - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - player->stateFlags1 &= ~0x20; + if (Actor_ProcessTalkRequest(&this->picto.actor, &play->state)) { + player->stateFlags1 &= ~PLAYER_STATE1_20; 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_IA_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.flags & ACTORCTX_FLAG_PICTO_BOX_ON) { + 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, PLAYER_CSMODE_73); this->unkState1A8 = 0; } - if ((this->unkMsgState1AC == Message_GetState(&globalCtx->msgCtx)) && Message_ShouldAdvance(globalCtx)) { - 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, PLAYER_CSMODE_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, PLAYER_CSMODE_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)) { - 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, PLAYER_CSMODE_86); + 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, PLAYER_CSMODE_86); 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)) { + 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, PLAYER_CSMODE_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, PLAYER_CSMODE_73); func_80165690(); this->unk204 = 0x14; } @@ -926,65 +924,67 @@ 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, + PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &player->unk_3C0, player->unk_3CC); + func_80169EFC(&play->state); + //! FAKE if (0) {} + if (gSaveContext.save.time > CLOCK_TIME(18, 0) || gSaveContext.save.time < CLOCK_TIME(6, 0)) { gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.respawnFlag = -4; - gSaveContext.eventInf[2] |= 0x80; + SET_EVENTINF(EVENTINF_27); } else { gSaveContext.save.time = CLOCK_TIME(18, 0); gSaveContext.respawnFlag = -8; } - gSaveContext.save.weekEventReg[83] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_83_01); this->unk190 = 0; this->actionFunc = EnKakasi_DoNothing; } } } -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 +992,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->sceneId == 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) { - gSaveContext.save.weekEventReg[79] |= 8; - func_800B7298(globalCtx, &this->actor, 6); + Math_ApproachF(&this->picto.actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); + if (fabsf(this->picto.actor.shape.yOffset + 6000.0f) < 10.0f) { + SET_WEEKEVENTREG(WEEKEVENTREG_79_08); + func_800B7298(play, &this->picto.actor, PLAYER_CSMODE_6); ActorCutscene_Stop(this->actorCutscenes[0]); this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; this->songSummonDist = 80.0f; @@ -1023,23 +1023,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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_08) && 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 +1055,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,68 +1083,68 @@ 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)) { - 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) { @@ -1152,9 +1152,9 @@ void EnKakasi_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } -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..c278ef050 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,23 +28,22 @@ 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 -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/overlay.cfg b/src/overlays/actors/ovl_En_Kame/overlay.cfg deleted file mode 100644 index 8f2bff1c1..000000000 --- a/src/overlays/actors/ovl_En_Kame/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kame -z_en_kame.c 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 d2a1f9902..6e021186f 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -11,37 +11,37 @@ #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 = { +ActorInit En_Kame_InitVars = { ACTOR_EN_KAME, ACTORCAT_ENEMY, FLAGS, @@ -114,23 +114,23 @@ static TexturePtr D_80AD8E34[] = { object_tl_Tex_0055A0, object_tl_Tex_0057A0, o object_tl_Tex_0057A0 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 1, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_SNAPPER, ICHAIN_CONTINUE), ICHAIN_F32(gravity, -1, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3500, ICHAIN_STOP), }; 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 & PLAYER_STATE1_800000) && (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 & PLAYER_STATE1_800000) && (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 & PLAYER_STATE1_800000) && ((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,14 +593,14 @@ 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); - Actor_MarkForDeath(&this->actor); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x60); + Actor_Kill(&this->actor); } else { this->actor.scale.y = this->actor.scale.x; this->actor.scale.z = 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 }, @@ -792,7 +792,7 @@ void func_80AD8AF8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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..b6ebc3a23 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.h +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.h @@ -5,34 +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; - #endif // Z_EN_KAME_H diff --git a/src/overlays/actors/ovl_En_Kanban/overlay.cfg b/src/overlays/actors/ovl_En_Kanban/overlay.cfg deleted file mode 100644 index 1ae4caed5..000000000 --- a/src/overlays/actors/ovl_En_Kanban/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kanban -z_en_kanban.c 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 921cb9633..54df1bcd7 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.c @@ -12,12 +12,12 @@ #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 = { +ActorInit En_Kanban_InitVars = { ACTOR_EN_KANBAN, ACTORCAT_PROP, FLAGS, @@ -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; @@ -277,7 +277,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { piece->partFlags = sCutFlags[this->cutType] & this->partFlags; if (piece->partFlags == 0) { - Actor_MarkForDeath(&piece->actor); + Actor_Kill(&piece->actor); return; } @@ -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; @@ -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); } } @@ -673,7 +673,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { signpost = (EnKanban*)this->actor.parent; if (signpost->partFlags == 0xFFFF) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } phi_f0 = 0.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); @@ -852,7 +852,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { signpost->invincibilityTimer = 5; if (signpost->partFlags == 0xFFFF) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } Matrix_RotateYS(signpost->actor.shape.rot.y, MTXMODE_NEW); @@ -876,7 +876,7 @@ void EnKanban_Update(Actor* thisx, GlobalContext* globalCtx) { (this->floorRot.z == 0.0f)) { signpost->partFlags |= this->partFlags; signpost->actor.flags |= ACTOR_FLAG_1; - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } break; @@ -911,18 +911,18 @@ 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); @@ -945,7 +945,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { 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,10 +960,10 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { } this->actor.world.pos.y = this->actor.home.pos.y + phi_f0; Matrix_Translate(0.0f, 0.0f, -100.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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); + gSPDisplayList(POLY_OPA_DISP++, gSignRectangularDL); } else { for (i = 0; i < ARRAY_COUNT(sPartFlags); i++) { if (sPartFlags[i] & this->partFlags) { @@ -982,8 +982,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); } } @@ -1025,7 +1024,7 @@ void EnKanban_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateXS(this->spinRot.x, MTXMODE_APPLY); Matrix_RotateYS(this->spinRot.z, MTXMODE_APPLY); Matrix_Translate(this->offset.x, this->offset.y, this->offset.z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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) { @@ -1039,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_Kanban/z_en_kanban.h b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h index 201364bc0..e54bb3fad 100644 --- a/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h +++ b/src/overlays/actors/ovl_En_Kanban/z_en_kanban.h @@ -105,6 +105,4 @@ typedef struct EnKanban { #define ENKANBAN_PIECE ((s16)0xFFDD) #define ENKANBAN_FISHING 0x300 -extern const ActorInit En_Kanban_InitVars; - #endif // Z_EN_KANBAN_H diff --git a/src/overlays/actors/ovl_En_Karebaba/overlay.cfg b/src/overlays/actors/ovl_En_Karebaba/overlay.cfg deleted file mode 100644 index 004503847..000000000 --- a/src/overlays/actors/ovl_En_Karebaba/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Karebaba -z_en_karebaba.c 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 94452e054..46ad2c30b 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,34 +13,34 @@ #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* play2); +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 = { +ActorInit En_Karebaba_InitVars = { ACTOR_EN_KAREBABA, ACTORCAT_ENEMY, FLAGS, @@ -137,25 +138,25 @@ 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); this->unk_22C = NULL; if (this->actor.params == ENKAREBABA_2) { - this->actor.hintId = 2; + this->actor.hintId = TATL_HINT_ID_MINI_BABA; } else { - this->actor.hintId = 9; + this->actor.hintId = TATL_HINT_ID_WILTED_DEKU_BABA; } if (this->actor.params == ENKAREBABA_0) { @@ -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,12 +625,12 @@ 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); @@ -636,35 +638,34 @@ void func_808F280C(EnKarebaba* this, GlobalContext* globalCtx) { 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_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); + 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) || @@ -686,8 +687,7 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { for (i = 0; i < sp94; i++) { Matrix_Translate(0.0f, 0.0f, -2000.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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_MultZero(&this->limbPos[1 + i]); @@ -696,10 +696,10 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { } } - func_800AE5A0(globalCtx); + func_800AE5A0(play); } - func_800AE2A0(globalCtx, &D_808F2E28, 1, 2); + 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) { @@ -709,19 +709,19 @@ void EnKarebaba_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(sp8C, sp8C, sp8C, MTXMODE_APPLY); Matrix_RotateYS(this->actor.home.rot.y, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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_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_MultZero(&this->limbPos[3]); } - func_800AE5A0(globalCtx); + func_800AE5A0(play); if (this->actor.params == ENKAREBABA_2) { limbCount = 1; @@ -729,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..5063a8dbe 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,22 +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; - #endif // Z_EN_KAREBABA_H diff --git a/src/overlays/actors/ovl_En_Kbt/overlay.cfg b/src/overlays/actors/ovl_En_Kbt/overlay.cfg deleted file mode 100644 index d9195b4b0..000000000 --- a/src/overlays/actors/ovl_En_Kbt/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kbt -z_en_kbt.c 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 095378137..d2847a39d 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -10,19 +10,19 @@ #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 = { +ActorInit En_Kbt_InitVars = { ACTOR_EN_KBT, ACTORCAT_NPC, FLAGS, @@ -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->sceneId].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->sceneId].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,7 +533,7 @@ 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) { @@ -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..eb491bf28 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h @@ -6,23 +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; - #endif // Z_EN_KBT_H diff --git a/src/overlays/actors/ovl_En_Kendo_Js/overlay.cfg b/src/overlays/actors/ovl_En_Kendo_Js/overlay.cfg deleted file mode 100644 index dd63f4c4a..000000000 --- a/src/overlays/actors/ovl_En_Kendo_Js/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kendo_Js -z_en_kendo_js.c 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..c02b00b5a 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,32 +12,32 @@ #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 = { +ActorInit En_Kendo_Js_InitVars = { ACTOR_EN_KENDO_JS, ACTORCAT_NPC, FLAGS, @@ -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_MarkForDeath(&this->actor); + 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_Kill(&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_Kill(&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,22 +144,22 @@ 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); - gSaveContext.save.weekEventReg[82] &= (u8)~8; + Collider_DestroyCylinder(play, &this->collider); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_08); } 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); - player->stateFlags1 |= 0x20; + func_801477B4(play); + player->stateFlags1 |= PLAYER_STATE1_20; 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); - player->stateFlags1 |= 0x20; + func_801477B4(play); + Interface_InitMinigame(play); + player->stateFlags1 |= PLAYER_STATE1_20; func_80B273D0(this); break; case 0x272D: - func_801477B4(globalCtx); - gSaveContext.minigameState = 3; + func_801477B4(play); + gSaveContext.minigameStatus = MINIGAME_STATUS_END; func_80B276C4(this); - func_80B276D8(this, globalCtx); + func_80B276D8(this, play); break; } } @@ -313,118 +315,127 @@ 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)) { - gSaveContext.minigameState = 3; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_20; 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 & PLAYER_STATE3_8000000) || + (player->stateFlags2 & PLAYER_STATE2_80000)) { return 1; } break; case 1: - if ((player->stateFlags3 & 0x8000000)) { + if ((player->stateFlags3 & PLAYER_STATE3_8000000)) { return 0; } - if ((player->swordState != 0) || (player->stateFlags2 & 0x80000)) { + if ((player->meleeWeaponState != 0) || (player->stateFlags2 & PLAYER_STATE2_80000)) { 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 & PLAYER_STATE3_8000000) || + (player->stateFlags2 & PLAYER_STATE2_80000)) { 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; } - if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + if ((this->unk_28E == 1) || (player->stateFlags3 & PLAYER_STATE3_8000000) || + (player->stateFlags2 & PLAYER_STATE2_80000)) { this->unk_28E = 0; return 1; } 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; } - if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + if ((this->unk_28E == 1) || (player->stateFlags3 & PLAYER_STATE3_8000000) || + (player->stateFlags2 & PLAYER_STATE2_80000)) { this->unk_28E = 0; return 1; } 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; } - if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + if ((this->unk_28E == 1) || (player->stateFlags3 & PLAYER_STATE3_8000000) || + (player->stateFlags2 & PLAYER_STATE2_80000)) { this->unk_28E = 0; return 1; } 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; } - if ((this->unk_28E == 1) || (player->stateFlags3 & 0x8000000) || (player->stateFlags2 & 0x80000)) { + if ((this->unk_28E == 1) || (player->stateFlags3 & PLAYER_STATE3_8000000) || + (player->stateFlags2 & PLAYER_STATE2_80000)) { this->unk_28E = 0; return 1; } @@ -433,24 +444,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 +469,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,29 +482,29 @@ 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); + player->stateFlags1 &= ~PLAYER_STATE1_20; + 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); } } } void func_80B2714C(EnKendoJs* this) { - gSaveContext.save.weekEventReg[82] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_82_08); this->unk_28C = 1; this->unk_290 = 0; this->unk_284 = 0; @@ -501,40 +512,40 @@ 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); - player->stateFlags1 &= ~0x20; + func_801477B4(play); + player->stateFlags1 &= ~PLAYER_STATE1_20; } } else if (this->unk_286 == 2) { this->unk_286 = 1; } 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); + player->stateFlags1 |= PLAYER_STATE1_20; + 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); + player->stateFlags1 |= PLAYER_STATE1_20; + 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 +553,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,96 +561,97 @@ 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) { - gSaveContext.save.weekEventReg[82] &= (u8)~8; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_08); func_80B26AE8(this); } } } void func_80B273D0(EnKendoJs* this) { - gSaveContext.save.weekEventReg[82] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_82_08); this->unk_290 = 120; this->unk_284 = 0; this->unk_286 = 1; this->actionFunc = func_80B2740C; } -void func_80B2740C(EnKendoJs* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +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; + player->stateFlags1 &= ~PLAYER_STATE1_20; 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; - gSaveContext.save.weekEventReg[82] &= (u8)~8; + player->stateFlags1 |= PLAYER_STATE1_20; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_08); func_80B26AE8(this); return; } play_sound(NA_SE_SY_FOUND); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 1); - func_80B279F0(this, globalCtx, ((Rand_Next() & 0xFF) % 3) + 4); + 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.minigamePoints = 3; if (gSaveContext.minigameScore >= 27) { - player->stateFlags1 |= 0x20; + player->stateFlags1 |= PLAYER_STATE1_20; } - } else if (player->swordAnimation == 12) { - globalCtx->interfaceCtx.unk_25C = 2; + } else if (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H) { + play->interfaceCtx.minigamePoints = 2; } else { - globalCtx->interfaceCtx.unk_25C = 1; + play->interfaceCtx.minigamePoints = 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); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_20)) { + 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 +659,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 (!(gSaveContext.save.weekEventReg[63] & 0x20)) { - gSaveContext.save.weekEventReg[63] |= 0x20; - Message_StartTextbox(globalCtx, 0x272F, &this->actor); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_20)) { + SET_WEEKEVENTREG(WEEKEVENTREG_63_20); + 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; + player->stateFlags1 &= ~PLAYER_STATE1_20; } 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 +694,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 +710,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 +720,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 +747,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 +767,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..1992f7234 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,25 +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; - #endif // Z_EN_KENDO_JS_H diff --git a/src/overlays/actors/ovl_En_Kgy/overlay.cfg b/src/overlays/actors/ovl_En_Kgy/overlay.cfg deleted file mode 100644 index 9a9ddfd5c..000000000 --- a/src/overlays/actors/ovl_En_Kgy/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kgy -z_en_kgy.c 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 cc184cfed..f188e1df0 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,26 +12,26 @@ #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 = { +ActorInit En_Kgy_InitVars = { ACTOR_EN_KGY, ACTORCAT_NPC, FLAGS, @@ -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; - gSaveContext.save.weekEventReg[21] |= 1; - if (!func_80B40D64(globalCtx)) { - EnKgy_ChangeAnim(this, 4, 0, 0); + 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)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + Flags_SetSwitch(play, ENKGY_GET_FE00(&this->actor) + 1); + play->envCtx.lightSettingOverride = 1; + SET_WEEKEVENTREG(WEEKEVENTREG_21_01); + 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_80)) { + 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->sceneId].unk_14 |= 1; if (CURRENT_DAY == 1) { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 |= 2; + gSaveContext.save.permanentSceneFlags[play->sceneId].unk_14 |= 2; } else { - gSaveContext.save.permanentSceneFlags[globalCtx->sceneNum].unk_14 &= ~2; + gSaveContext.save.permanentSceneFlags[play->sceneId].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->sceneId].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->sceneId].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->sceneId].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->sceneId].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->sceneId].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->talkActor)) { + func_80B411DC(this, play, 4); func_80B40E18(this, this->actor.textId); if (this->actor.textId == 0xC37) { this->actionFunc = func_80B417B8; @@ -509,37 +507,37 @@ 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) { - s32 itemActionParam; - Player* player = GET_PLAYER(globalCtx); +void func_80B41ACC(EnKgy* this, PlayState* play) { + PlayerItemAction itemAction; + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) == 0x10) { - itemActionParam = func_80123810(globalCtx); - if (itemActionParam != PLAYER_AP_NONE) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemAction = func_80123810(play); + if (itemAction != PLAYER_IA_NONE) { this->actionFunc = func_80B41E18; } - if (itemActionParam > PLAYER_AP_NONE) { - func_801477B4(globalCtx); - if (itemActionParam == PLAYER_AP_BOTTLE_GOLD_DUST) { + if (itemAction > PLAYER_IA_NONE) { + func_801477B4(play); + if (itemAction == PLAYER_IA_BOTTLE_GOLD_DUST) { if (this->unk_29C & 0x10) { this->actor.textId = 0xC55; player->actor.textId = 0xC55; } 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; @@ -549,107 +547,107 @@ void func_80B41ACC(EnKgy* this, GlobalContext* globalCtx) { player->actor.textId = 0xC47; } this->unk_29C |= 8; - } else if (itemActionParam < PLAYER_AP_NONE) { + } else if (itemAction <= PLAYER_IA_MINUS1) { if (this->unk_29C & 0x10) { this->actor.textId = 0xC57; } else { 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) { + if (&this->actor != player->talkActor) { 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_IA_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_IA_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; + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE); + player->exchangeItemId = PLAYER_IA_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_IA_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->talkActor)) { 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->talkActor)) { + 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_IA_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,113 +989,113 @@ 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); - gSaveContext.save.weekEventReg[20] |= 0x80; + EnKgy_ChangeAnim(this, 5, ANIMMODE_ONCE, -5.0f); + SET_WEEKEVENTREG(WEEKEVENTREG_20_80); } - 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; + SET_WEEKEVENTREG(WEEKEVENTREG_21_01); } else if (this->actor.xzDistToPlayer < 200.0f) { if (this->unk_2D2 == 4) { this->actor.textId = 0xC2D; } 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,7 +1113,7 @@ 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; @@ -1129,48 +1127,48 @@ void EnKgy_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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); + 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)) { - gSPDisplayList(&gfx[1], gameplay_keep_DL_001D00); + if (func_80B40D8C(play)) { + gSPDisplayList(&gfx[1], gRazorSwordHandleDL); gSPDisplayList(&gfx[2], object_kgy_DL_00F180); } else { - gSPDisplayList(&gfx[1], gameplay_keep_DL_0021A8); + gSPDisplayList(&gfx[1], gKokiriSwordHandleDL); gSPDisplayList(&gfx[2], object_kgy_DL_00E8F0); } POLY_OPA_DISP = &gfx[3]; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); 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..d9423783d 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) @@ -36,6 +38,4 @@ typedef struct EnKgy { /* 0x304 */ EnKgyActionFunc actionFunc; } EnKgy; // size = 0x308 -extern const ActorInit En_Kgy_InitVars; - #endif // Z_EN_KGY_H diff --git a/src/overlays/actors/ovl_En_Kitan/overlay.cfg b/src/overlays/actors/ovl_En_Kitan/overlay.cfg deleted file mode 100644 index cd24348d5..000000000 --- a/src/overlays/actors/ovl_En_Kitan/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kitan -z_en_kitan.c 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..c9d40c1e7 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.c @@ -10,12 +10,12 @@ #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 = { +ActorInit En_Kitan_InitVars = { ACTOR_EN_KITAN, ACTORCAT_NPC, FLAGS, 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..9d2ae096b 100644 --- a/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h +++ b/src/overlays/actors/ovl_En_Kitan/z_en_kitan.h @@ -5,14 +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; - #endif // Z_EN_KITAN_H diff --git a/src/overlays/actors/ovl_En_Knight/overlay.cfg b/src/overlays/actors/ovl_En_Knight/overlay.cfg deleted file mode 100644 index 150eab3c7..000000000 --- a/src/overlays/actors/ovl_En_Knight/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Knight -z_en_knight.c 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..0d80d6020 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.c +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.c @@ -5,45 +5,46 @@ */ #include "z_en_knight.h" +#include "z64shrink_window.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #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 +130,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 +144,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 +158,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 +176,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 = { @@ -192,7 +193,7 @@ static ColliderCylinderInit D_809BDC64 = { { 20, 40, 0, { 0, 0, 0 } }, }; -const ActorInit En_Knight_InitVars = { +ActorInit En_Knight_InitVars = { ACTOR_EN_KNIGHT, ACTORCAT_BOSS, FLAGS, 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..2d413fea3 100644 --- a/src/overlays/actors/ovl_En_Knight/z_en_knight.h +++ b/src/overlays/actors/ovl_En_Knight/z_en_knight.h @@ -5,27 +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; - #endif // Z_EN_KNIGHT_H diff --git a/src/overlays/actors/ovl_En_Kujiya/overlay.cfg b/src/overlays/actors/ovl_En_Kujiya/overlay.cfg deleted file mode 100644 index a47b9648b..000000000 --- a/src/overlays/actors/ovl_En_Kujiya/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kujiya -z_en_kujiya.c 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..511a5dc46 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -13,28 +13,28 @@ #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 = { +ActorInit En_Kujiya_InitVars = { ACTOR_EN_KUJIYA, ACTORCAT_NPC, FLAGS, @@ -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); } } @@ -235,19 +235,19 @@ void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx) { s32 EnKujiya_CheckBoughtTicket(void) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.save.weekEventReg[33] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_10)) { return true; } break; case 2: - if (gSaveContext.save.weekEventReg[33] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_20)) { return true; } break; case 3: - if (gSaveContext.save.weekEventReg[33] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_40)) { return true; } break; @@ -258,15 +258,15 @@ s32 EnKujiya_CheckBoughtTicket(void) { void EnKujiya_SetBoughtTicket(void) { switch (CURRENT_DAY) { case 1: - gSaveContext.save.weekEventReg[33] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_33_10); break; case 2: - gSaveContext.save.weekEventReg[33] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_33_20); break; case 3: - gSaveContext.save.weekEventReg[33] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_33_40); break; } } @@ -277,15 +277,15 @@ void EnKujiya_SetBoughtTicket(void) { void EnKujiya_UnsetBoughtTicket(void) { switch (CURRENT_DAY) { case 1: - gSaveContext.save.weekEventReg[33] &= (u8)~0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_33_10); break; case 2: - gSaveContext.save.weekEventReg[33] &= (u8)~0x20; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_33_20); break; case 3: - gSaveContext.save.weekEventReg[33] &= (u8)~0x40; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_33_40); break; } } @@ -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..5d449963b 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; @@ -14,6 +14,4 @@ typedef struct EnKujiya { /* 0x14A */ s16 textId; } EnKujiya; // size = 0x14C -extern const ActorInit En_Kujiya_InitVars; - #endif // Z_EN_KUJIYA_H diff --git a/src/overlays/actors/ovl_En_Kusa/overlay.cfg b/src/overlays/actors/ovl_En_Kusa/overlay.cfg deleted file mode 100644 index 9cded0ca3..000000000 --- a/src/overlays/actors/ovl_En_Kusa/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kusa -z_en_kusa.c 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 1767f3c86..eaf5ea96a 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,7 +4,6 @@ * 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" @@ -14,34 +13,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* play2); -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; @@ -58,7 +57,7 @@ s16 D_80936CDC; s16 D_80936CDE; s16 D_80936CE0; -const ActorInit En_Kusa_InitVars = { +ActorInit En_Kusa_InitVars = { ACTOR_EN_KUSA, ACTORCAT_PROP, FLAGS, @@ -215,11 +214,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; @@ -230,7 +229,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); @@ -240,22 +239,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); } } } @@ -286,7 +285,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; @@ -306,8 +305,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; @@ -318,18 +317,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; @@ -337,39 +336,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) { @@ -381,55 +380,55 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (!EnKusa_SnapToFloor(this, play, 0.0f)) { + Actor_Kill(&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); + Actor_Kill(&this->actor); return; } EnKusa_SetupWaitObject(this); if (D_809366B4) { - D_80936CD8 = ((u32)Rand_Next() >> 0x10); - D_80936CDA = ((u32)Rand_Next() >> 0x10); - D_80936CDC = ((u32)Rand_Next() >> 0x10); - D_80936CDE = ((u32)Rand_Next() >> 0x10); - D_80936CE0 = ((u32)Rand_Next() >> 0x10); + D_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); @@ -451,32 +450,32 @@ 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) { - Actor_MarkForDeath(&this->actor); - } else { - EnKusa_SetupCut(this); - this->isCut = true; + if (KUSA_GET_TYPE(&this->actor) == ENKUSA_TYPE_BUSH) { + Actor_Kill(&this->actor); + return; } + EnKusa_SetupCut(this); + this->isCut = true; } else { if (!(this->collider.base.ocFlags1 & OC1_TYPE_PLAYER) && (this->actor.xzDistToPlayer > 12.0f)) { this->collider.base.ocFlags1 |= OC1_TYPE_PLAYER; @@ -484,13 +483,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); } } } @@ -504,13 +503,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.curRoom.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); @@ -519,14 +518,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); } } @@ -539,7 +538,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; @@ -554,14 +553,14 @@ 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); + Actor_Kill(&this->actor); break; case ENKUSA_TYPE_REGROWING_GRASS: @@ -578,12 +577,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; @@ -594,7 +593,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); @@ -603,15 +602,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; @@ -623,14 +622,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) { @@ -643,7 +642,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)) { @@ -659,7 +658,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); @@ -672,63 +671,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.curRoom.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.curRoom.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, gKusaBushType1DL); } 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); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2DL); - 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.curRoom.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..56f55af3e 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, @@ -25,15 +25,13 @@ typedef struct EnKusa { /* 0x198 */ u8 isInWater; } EnKusa; // size = 0x19C -extern const ActorInit En_Kusa_InitVars; - -#define KUSA_GET_COLLECTIBLE_ID(thisx) ((((thisx)->params >> 8) & 0x7F)) +#define KUSA_GET_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/overlay.cfg b/src/overlays/actors/ovl_En_Kusa2/overlay.cfg deleted file mode 100644 index 0e08a700b..000000000 --- a/src/overlays/actors/ovl_En_Kusa2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Kusa2 -z_en_kusa2.c 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 6ba532cef..626ab3f3b 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,7 +4,6 @@ * 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" @@ -13,48 +12,48 @@ #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; -static MtxF D_80A60908[8]; -static s16 D_80A60B08; -static s16 D_80A60B0A; -static s16 D_80A60B0C; -static s16 D_80A60B0E; -static s16 D_80A60B10; +EnKusa2UnkBssStruct D_80A5F1C0; +u32 D_80A60900; +MtxF D_80A60908[8]; +s16 D_80A60B08; +s16 D_80A60B0A; +s16 D_80A60B0C; +s16 D_80A60B0E; +s16 D_80A60B10; -const ActorInit En_Kusa2_InitVars = { +ActorInit En_Kusa2_InitVars = { ACTOR_EN_KUSA2, ACTORCAT_PROP, FLAGS, @@ -86,13 +85,13 @@ static ColliderCylinderInit sCylinderInit = { { 6, 44, 0, { 0, 0, 0 } }, }; -static u8 D_80A5EAEC = 1; -static s16 D_80A5EAF0 = 0; -static Vec3s D_80A5EAF4 = { 0, 0, 0 }; -static Vec3s D_80A5EAFC = { 0, 0, 0 }; -static Vec3s D_80A5EB04 = { 0, 0, 0 }; +u8 D_80A5EAEC = 1; +s16 D_80A5EAF0 = 0; +Vec3s D_80A5EAF4 = { 0, 0, 0 }; +Vec3s D_80A5EAFC = { 0, 0, 0 }; +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; @@ -101,8 +100,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) { @@ -116,9 +115,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; @@ -128,7 +127,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; @@ -136,8 +135,8 @@ void func_80A5B334(EnKusa2* this, GlobalContext* globalCtx) { ptr = &this->unk_194[i]; if (*ptr != NULL) { - if (!Actor_HasParent(&(*ptr)->actor, globalCtx)) { - Actor_MarkForDeath(&(*ptr)->actor); + if (!Actor_HasParent(&(*ptr)->actor, play)) { + Actor_Kill(&(*ptr)->actor); } *ptr = NULL; } @@ -156,8 +155,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); } @@ -209,7 +208,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]; @@ -242,15 +241,15 @@ void func_80A5B508(void) { void func_80A5B954(MtxF* matrix, f32 arg1) { s32 i; MtxF* temp = Matrix_GetCurrent(); - f32* tmp = (f32*)&temp->mf[0]; - f32* tmp2 = (f32*)&matrix->mf[0]; + 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; @@ -258,7 +257,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; @@ -268,11 +267,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; @@ -300,12 +299,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, @@ -316,7 +315,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; } } @@ -327,7 +326,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; @@ -338,14 +337,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) { @@ -366,21 +365,21 @@ 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); + Actor_Kill(&this->actor); return true; } return false; @@ -391,7 +390,7 @@ EnKusa2UnkBssSubStruct* func_80A5C074(EnKusa2UnkBssStruct* arg0) { EnKusa2UnkBssSubStruct* phi_v1 = &arg0->unk_0000[0]; for (i = 1; i < ARRAY_COUNT(D_80A5F1C0.unk_0000); i++) { - if (!(phi_v1->unk_26 <= arg0->unk_0000[i].unk_26)) { + if (phi_v1->unk_26 > arg0->unk_0000[i].unk_26) { phi_v1 = &arg0->unk_0000[i]; if (phi_v1->unk_26 <= 0) { break; @@ -407,7 +406,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) { @@ -741,7 +740,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; @@ -756,13 +755,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); } @@ -779,7 +778,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; @@ -798,9 +797,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); } @@ -819,7 +818,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; @@ -836,12 +835,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); } @@ -853,7 +852,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; @@ -862,43 +861,44 @@ 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)) { - Actor_MarkForDeath(&this->actor); - } else { - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); - Collider_UpdateCylinder(&this->actor, &this->collider); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; - this->unk_1CE = D_80A5EAF0 & 7; - D_80A5EAF0++; - this->actor.shape.shadowAlpha = 0; - this->unk_1CF = 255; - this->actor.shape.shadowScale = 1.0f; - func_80A5D7A4(this); + Collider_InitCylinder(play, &this->collider); + if (!func_80A5BA58(this, play)) { + Actor_Kill(&this->actor); + return; } + + 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; + D_80A5EAF0++; + this->actor.shape.shadowAlpha = 0; + this->unk_1CF = 255; + this->actor.shape.shadowScale = 1.0f; + func_80A5D7A4(this); } } -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); } } @@ -906,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); } @@ -914,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); } } @@ -928,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); } } @@ -949,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) { @@ -957,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; @@ -971,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) { @@ -985,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); } } } @@ -1011,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; @@ -1032,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.curRoom.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); @@ -1048,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); } } @@ -1069,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); @@ -1082,22 +1082,22 @@ 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--; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } @@ -1111,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) { @@ -1148,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); @@ -1171,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) { @@ -1196,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); @@ -1242,7 +1242,7 @@ void func_80A5E210(EnKusa2* this, GlobalContext* globalCtx) { if (this->unk_1B8 != NULL) { this->unk_1B8->unk_28 = func_80A5C718; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -1258,58 +1258,58 @@ 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; if (this->unk_1CF <= 15) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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.curRoom.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, @@ -1317,9 +1317,9 @@ 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]; @@ -1328,42 +1328,41 @@ void func_80A5E6F0(Actor* thisx, GlobalContext* globalCtx) { 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); + gSPDisplayList(POLY_XLU_DISP++, gKusaBushType2DL); - 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.curRoom.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, gKusaBushType1DL); } 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; @@ -1371,15 +1370,15 @@ void func_80A5E9B4(Actor* thisx, GlobalContext* globalCtx) { sp18.z = thisx->shape.rot.z + D_80A5EAFC.z; 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, gKusaBushType1DL); } -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, gKusaBushType1DL); } 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..f1245dd50 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,25 +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; - #endif // Z_EN_KUSA2_H diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/overlay.cfg b/src/overlays/actors/ovl_En_Lift_Nuts/overlay.cfg deleted file mode 100644 index df2faa5f0..000000000 --- a/src/overlays/actors/ovl_En_Lift_Nuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Lift_Nuts -z_en_lift_nuts.c 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..f6647cc0b 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,13 +10,46 @@ #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 = { +void func_80AEA910(EnLiftNuts* this, PlayState* play); + +s32 func_80AE9B8C(void); +void func_80AE9F28(EnLiftNuts* this); +void func_80AE9F70(EnLiftNuts* this, PlayState* play); +void func_80AEA044(EnLiftNuts* this, PlayState* play); +void func_80AEA0B4(EnLiftNuts* this); +void func_80AEA128(EnLiftNuts* this, PlayState* play); +void func_80AEA1A0(EnLiftNuts* this, PlayState* play); +void func_80AEABF0(EnLiftNuts* this); +void func_80AEAC64(EnLiftNuts* this, PlayState* play); +void func_80AEACF8(EnLiftNuts* this, PlayState* play); +void func_80AEAEAC(EnLiftNuts* this); +void func_80AEAF14(EnLiftNuts* this, PlayState* play); +void func_80AEAF8C(EnLiftNuts* this); +void func_80AEAFA0(EnLiftNuts* this, PlayState* play); +void func_80AEB114(EnLiftNuts* this); +void func_80AEB148(EnLiftNuts* this, PlayState* play); +void func_80AEB1C8(EnLiftNuts* this); +void func_80AEB230(EnLiftNuts* this, PlayState* play); +void func_80AEB280(EnLiftNuts* this); +void func_80AEB294(EnLiftNuts* this, PlayState* play); +void func_80AEB3E0(EnLiftNuts* this, PlayState* play); +void func_80AEB428(EnLiftNuts* this, PlayState* play); +void func_80AEB584(EnLiftNuts* this); +void func_80AEB598(EnLiftNuts* this, PlayState* play); +void func_80AEB684(EnLiftNuts* this); +void func_80AEB698(EnLiftNuts* this, PlayState* play); +void func_80AEB828(EnLiftNuts* this); +void func_80AEB8A4(EnLiftNuts* this, PlayState* play); +void func_80AEB934(EnLiftNuts* this, PlayState* play); +void func_80AEB974(EnLiftNuts* this); +void func_80AEB9E0(EnLiftNuts* this, PlayState* play); + +ActorInit En_Lift_Nuts_InitVars = { ACTOR_EN_LIFT_NUTS, ACTORCAT_NPC, FLAGS, @@ -28,111 +61,955 @@ const ActorInit En_Lift_Nuts_InitVars = { (ActorFunc)EnLiftNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AEBF28 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_dnt_Anim_005488, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_00B0B4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_004AA0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_0029E8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_005CA8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dnt_Anim_0038CC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_003CC0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dnt_Anim_0012F4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_004700, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_001BC8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_003438, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -2.0f }, + { &object_dnt_Anim_001E2C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_000994, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_002268, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dnt_Anim_002F08, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_00577C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_004E38, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_0029E8, 1.0f, 4.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_0029E8, 1.0f, 8.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, +}; + +Gfx* D_80AEBF18[] = { + object_dnt_DL_008290, + object_dnt_DL_001350, + object_dnt_DL_001420, + NULL, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 25, 75, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80AEBF54 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +void func_80AE9A20(EnLiftNuts* this, PlayState* play) { + static s16 D_80AEBF60 = 0; + static s32 D_80AEBF64 = false; -extern ColliderCylinderInit D_80AEBF28; -extern CollisionCheckInfoInit2 D_80AEBF54; + if (!D_80AEBF64) { + func_800B6584(play, ACTOR_EN_GAMELUPY, &D_80AEBF60, sizeof(s16)); + D_80AEBF64 = true; + } + this->ptr_1EC = &D_80AEBF60; +} -extern UNK_TYPE D_060029E8; +void func_80AE9A80(EnLiftNuts* this, PlayState* play) { + static s16 D_80AEBF68 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9A20.s") + if (!D_80AEBF68) { + func_800B6608(play, ACTOR_EN_GAMELUPY); + D_80AEBF68 = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9A80.s") +s32 func_80AE9AC4(EnLiftNuts* this, s32 arg1) { + static s32 D_80AEBF6C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9AC4.s") + switch (arg1) { + case 0: + if (D_80AEBF6C == 0) { + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9B4C.s") + case 1: + if (D_80AEBF6C == 0) { + this->unk_34E = 1; + D_80AEBF6C = 1; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9B8C.s") + case 2: + if (D_80AEBF6C == 1) { + this->unk_34E = 0; + D_80AEBF6C = 0; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9BCC.s") + default: + break; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/EnLiftNuts_Init.s") +s32 func_80AE9B4C(s32 arg0, s32 arg1) { + static s32 D_80AEBF70 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/EnLiftNuts_Destroy.s") + if (arg0 == 0) { + if (D_80AEBF70 == arg1) { + return true; + } + } else if (arg0 == 1) { + D_80AEBF70 = arg1; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9F28.s") +s32 func_80AE9B8C() { + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9F70.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_10)) { + ret = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9FC8.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_20)) { + ret++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA044.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_40)) { + ret++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA0B4.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA128.s") +void func_80AE9BCC(EnLiftNuts* this, PlayState* play) { + if ((this->actionFunc != func_80AEB934) && (this->actionFunc != func_80AEB8A4) && + (this->actionFunc != func_80AEACF8) && (this->actionFunc != func_80AEAC64) && + (this->actionFunc != func_80AEA044) && (this->actionFunc != func_80AEB598) && + (this->actionFunc != func_80AEB698) && !func_80AE9B4C(0, 3) && (func_80AE9B8C() == 3) && + (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && (this->actor.xzDistToPlayer < 150.0f)) { + func_80AEB828(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA1A0.s") +void EnLiftNuts_Init(Actor* thisx, PlayState* play) { + EnLiftNuts* this = THIS; + Path* path; + Vec3s* pathPos; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA7A4.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_0029E8, this->jointTable, + this->morphTable, OBJECT_DNT_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + if (this->actor.floorBgId != BGCHECK_SCENE) { + DynaPolyActor* bgActor = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA910.s") + if (bgActor != NULL) { + this->actor.world.pos = bgActor->actor.world.pos; + this->actor.home.pos = bgActor->actor.world.pos; + } + } + this->actor.targetMode = 0; + this->unk_354 = 0; + this->unk_34E = 0; + this->unk_356 = 0; + this->unk_1E4 = 0; + this->unk_1E8 = 0; + this->actor.gravity = -2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEABF0.s") + path = &play->setupPathList[ENLIFTNUTS_GET_FF00(&this->actor)]; + pathPos = Lib_SegmentedToVirtual(path->points); + this->vec_1D8.x = pathPos->x; + this->vec_1D8.y = pathPos->y; + this->vec_1D8.z = pathPos->z; + func_80AE9A20(this, play); + if (!Flags_GetSwitch(play, 0x41)) { + func_80AE9B4C(1, 0); + func_80AE9F28(this); + } else if (func_80AE9AC4(this, 0)) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAC64.s") + player->stateFlags1 |= PLAYER_STATE1_20; + func_80AE9AC4(this, 1); + func_80AE9B4C(1, 3); + func_80AEA0B4(this); + } else { + func_80AE9F28(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEACF8.s") +void EnLiftNuts_Destroy(Actor* thisx, PlayState* play) { + EnLiftNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAEAC.s") + Collider_DestroyCylinder(play, &this->collider); + func_80AE9A80(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAF14.s") +void func_80AE9F28(EnLiftNuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 18); + this->actionFunc = func_80AE9F70; + this->unk_354 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAF8C.s") +void func_80AE9F70(EnLiftNuts* this, PlayState* play) { + if (this->unk_354 < 40) { + this->unk_354++; + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_80AEA0B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAFA0.s") +void func_80AE9FC8(EnLiftNuts* this) { + if (this->actionFunc == func_80AEA1A0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 17); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB114.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = func_80AEA044; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB148.s") +void func_80AEA044(EnLiftNuts* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80AE9F28(this); + } else if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + func_80AEB9E0(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB1C8.s") +void func_80AEA0B4(EnLiftNuts* this) { + if (func_80AE9B4C(0, 1)) { + this->actionFunc = func_80AEA1A0; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = func_80AEA128; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB230.s") +void func_80AEA128(EnLiftNuts* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + this->actionFunc = func_80AEA1A0; + } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { + func_80AEB9E0(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB280.s") +void func_80AEA1A0(EnLiftNuts* this, PlayState* play) { + if ((func_80AE9B4C(0, 3) || func_80AE9B4C(0, 1)) && this->unk_34E == 1) { + this->actor.flags |= ACTOR_FLAG_10000; + } else if (this->actor.xzDistToPlayer > 120.0f) { + func_80AE9FC8(this); + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + if (func_80AE9B4C(0, 0)) { + switch (CURRENT_DAY) { + case 1: + if (gSaveContext.save.time > CLOCK_TIME(23, 30) || gSaveContext.save.time <= CLOCK_TIME(6, 0)) { + Message_StartTextbox(play, 0x27F7, &this->actor); + this->textId = 0x27F7; + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_10)) { + Message_StartTextbox(play, 0x27D9, &this->actor); + this->textId = 0x27D9; + } else { + Message_StartTextbox(play, 0x27DA, &this->actor); + this->textId = 0x27DA; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB294.s") + case 2: + if (gSaveContext.save.time > CLOCK_TIME(23, 30) || gSaveContext.save.time <= CLOCK_TIME(6, 0)) { + Message_StartTextbox(play, 0x27F7, &this->actor); + this->textId = 0x27F7; + } else { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_20)) { + Message_StartTextbox(play, 0x27DB, &this->actor); + this->textId = 0x27DB; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB3E0.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_10)) { + Message_StartTextbox(play, 0x27DC, &this->actor); + this->textId = 0x27DC; + } else { + Message_StartTextbox(play, 0x27DD, &this->actor); + this->textId = 0x27DD; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB428.s") + case 3: + if (gSaveContext.save.time > CLOCK_TIME(23, 30) || gSaveContext.save.time <= CLOCK_TIME(6, 0)) { + Message_StartTextbox(play, 0x27F7, &this->actor); + this->textId = 0x27F7; + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_40)) { + Message_StartTextbox(play, 0x27DE, &this->actor); + this->textId = 0x27DE; + } else if (func_80AE9B8C() == 2) { + Message_StartTextbox(play, 0x27DF, &this->actor); + this->textId = 0x27DF; + } else if (func_80AE9B8C() == 1) { + Message_StartTextbox(play, 0x27E0, &this->actor); + this->textId = 0x27E0; + } else { + Message_StartTextbox(play, 0x27E1, &this->actor); + this->textId = 0x27E1; + } + break; + } + } else if (func_80AE9B4C(0, 3)) { + if (Flags_GetSwitch(play, 0x40)) { + Flags_UnsetSwitch(play, 0x40); + Inventory_SaveDekuPlaygroundHighScore(4); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_10) && CHECK_WEEKEVENTREG(WEEKEVENTREG_14_20) && + CURRENT_DAY == 3) { + this->unk_354 = 0; + Message_StartTextbox(play, 0x27F4, &this->actor); + this->textId = 0x27F4; + } else { + Message_StartTextbox(play, 0x27EE, &this->actor); + this->textId = 0x27EE; + } + } else { + if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) >= + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < 0x2EE0) { + Message_StartTextbox(play, 0x27F9, &this->actor); + this->textId = 0x27F9; + } else { + Message_StartTextbox(play, 0x27EB, &this->actor); + this->textId = 0x27EB; + } + } else { + Message_StartTextbox(play, 0x27ED, &this->actor); + this->textId = 0x27ED; + } + } + Flags_UnsetSwitch(play, 0x41); + this->actor.flags &= ~ACTOR_FLAG_10000; + } else if (!Flags_GetSwitch(play, 0x42)) { + Flags_SetSwitch(play, 0x42); + Message_StartTextbox(play, 0x27E6, &this->actor); + this->textId = 0x27E6; + } else { + switch (CURRENT_DAY) { + case 1: + Message_StartTextbox(play, 0x27E7, &this->actor); + this->textId = 0x27E7; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB584.s") + case 2: + Message_StartTextbox(play, 0x27E8, &this->actor); + this->textId = 0x27E8; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB598.s") + case 3: + Message_StartTextbox(play, 0x27E9, &this->actor); + this->textId = 0x27E9; + break; + } + } + } else { + Message_StartTextbox(play, 0x27D8, &this->actor); + this->textId = 0x27D8; + } + func_80AEABF0(this); + } else if (func_80AE9AC4(this, 0) || this->unk_34E == 1) { + if (this->unk_34E == 1) { + func_800B8614(&this->actor, play, 200.0f); + } else if (this->actor.playerHeightRel >= -13.0f) { + func_800B8614(&this->actor, play, 100.0f); + } + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000, 0x500); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB684.s") +void func_80AEA7A4(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB698.s") + if (Message_ShouldAdvance(play)) { + switch (this->textId) { + case 0x27E2: + if (play->msgCtx.choiceIndex == 0) { // Yes + if (gSaveContext.save.playerData.rupees >= 10) { + func_8019F208(); + Message_StartTextbox(play, 0x27E5, &this->actor); + this->textId = 0x27E5; + Rupees_ChangeBy(-10); + } else { + play_sound(NA_SE_SY_ERROR); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(play, 0x27E4, &this->actor); + this->textId = 0x27E4; + } + } else { + func_8019F230(); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(play, 0x27E3, &this->actor); + this->textId = 0x27E3; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB828.s") + case 0x238D: + if (play->msgCtx.choiceIndex == 0) { // Yes + player->stateFlags1 |= PLAYER_STATE1_20; + func_80AEB1C8(this); + } else { + func_80AE9FC8(this); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB8A4.s") + default: + func_80AE9FC8(this); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB934.s") +void func_80AEA910(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB974.s") + if (Message_ShouldAdvance(play)) { + switch (this->textId) { + case 0x27D9: + case 0x27DA: + case 0x27DB: + case 0x27DC: + case 0x27DD: + case 0x27DE: + case 0x27DF: + case 0x27E0: + case 0x27E1: + Message_StartTextbox(play, 0x27E2, &this->actor); + this->textId = 0x27E2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB9E0.s") + case 0x27E3: + case 0x27E4: + func_80AE9FC8(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEBB30.s") + case 0x27E5: + func_801477B4(play); + player->stateFlags1 |= PLAYER_STATE1_20; + func_80AEAEAC(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/EnLiftNuts_Update.s") + case 0x27E6: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + switch (CURRENT_DAY) { + case 1: + Message_StartTextbox(play, 0x27E7, &this->actor); + this->textId = 0x27E7; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEBC18.s") + case 2: + Message_StartTextbox(play, 0x27E8, &this->actor); + this->textId = 0x27E8; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEBC90.s") + case 3: + Message_StartTextbox(play, 0x27E9, &this->actor); + this->textId = 0x27E9; + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/EnLiftNuts_Draw.s") + case 0x27E7: + case 0x27E8: + case 0x27E9: + Message_StartTextbox(play, 0x27FA, &this->actor); + this->textId = 0x27FA; + break; + + case 0x27FA: + func_801477B4(play); + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80AEB114(this); + break; + + case 0x27EE: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x10); + Message_StartTextbox(play, 0x27EF, &this->actor); + this->textId = 0x27EF; + break; + + case 0x27EF: + func_801477B4(play); + func_80AEB584(this); + func_80AEB598(this, play); + break; + + case 0x27F1: + Message_StartTextbox(play, 0x27F2, &this->actor); + this->textId = 0x27F2; + break; + + case 0x27F2: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(play, 0x27F3, &this->actor); + this->textId = 0x27F3; + break; + + case 0x27F4: + func_801477B4(play); + func_80AEB584(this); + func_80AEB598(this, play); + break; + + case 0x27F5: + func_801477B4(play); + func_80AE9B4C(1, 0); + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80AE9FC8(this); + break; + + case 0x27F9: + Message_StartTextbox(play, 0x27ED, &this->actor); + this->textId = 0x27ED; + break; + } + } +} + +void func_80AEABF0(EnLiftNuts* this) { + this->unk_354 = 0; + + if (this->actionFunc != func_80AEB698) { + if (func_80AE9B4C(0, 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 16); + } + this->actionFunc = func_80AEAC64; +} + +void func_80AEAC64(EnLiftNuts* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->textId == 0x27EE) || (this->textId == 0x27F4) || (this->textId == 0x27F5)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + } + this->actionFunc = func_80AEACF8; + } +} + +void func_80AEACF8(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + switch (Message_GetState(&play->msgCtx)) { + case 0: + case 1: + case 2: + case 3: + break; + + case 4: + func_80AEA7A4(this, play); + break; + + case 5: + func_80AEA910(this, play); + break; + + case 6: + if (Message_ShouldAdvance(play)) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80AE9FC8(this); + func_80AE9AC4(this, 2); + if (func_80AE9B4C(0, 3)) { + func_80AE9B4C(1, 0); + } + } + break; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x2000, 0x500); + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + switch (this->textId) { + case 0x27EE: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + break; + + case 0x27EF: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + break; + + case 0x27F4: + if (this->unk_354 == 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + this->unk_354++; + } else if (this->unk_354 == 4) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); + this->unk_354 = 0; + } else { + this->unk_354++; + } + break; + } + } + func_80AEB974(this); +} + +void func_80AEAEAC(EnLiftNuts* this) { + this->actor.speedXZ = 2.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + func_80AE9AC4(this, 1); + func_80AE9B4C(1, 1); + this->actionFunc = func_80AEAF14; +} + +void func_80AEAF14(EnLiftNuts* this, PlayState* play) { + f32 dist; + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 10, 0x1000, 0x500); + dist = Math_Vec3f_StepTo(&this->actor.world.pos, &this->vec_1D8, this->actor.speedXZ); + this->actor.world.pos.y += this->actor.gravity; + + if (dist == 0.0f) { + func_80AEAF8C(this); + } +} + +void func_80AEAF8C(EnLiftNuts* this) { + this->actionFunc = func_80AEAFA0; +} + +void func_80AEAFA0(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 dist; + f32 temp_fv0; + s16 yaw; + s16 sp28; + s16 yawDiff; + + sp28 = this->actor.yawTowardsPlayer - 0x8000; + yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &this->actor.home.pos); + yawDiff = yaw - sp28; + dist = Math_Vec3f_DistXZ(&player->actor.world.pos, &this->actor.home.pos); + + if (this->actor.xzDistToPlayer < dist) { + if (ABS_ALT(yawDiff) < 0x2000) { + yaw = (yawDiff > 0) ? (yaw + 0x2000) : (yaw - 0x2000); + } + } + if (dist < 5.0f) { + temp_fv0 = 10.0f; + } else if (dist < 30.0f) { + temp_fv0 = 40.0f; + } else { + temp_fv0 = 80.0f; + } + + play->actorCtx.unk268 = 1; + func_800B6F20(play, &play->actorCtx.unk_26C, temp_fv0, yaw); + if (dist < 5.0f) { + func_80AEA0B4(this); + } +} + +void func_80AEB114(EnLiftNuts* this) { + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); + this->actionFunc = func_80AEB148; +} + +void func_80AEB148(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (player->stateFlags3 & PLAYER_STATE3_200) { + this->actor.speedXZ = 2.0f; + gSaveContext.eventInf[3] |= 0x10; + Interface_StartTimer(4, 0); + func_80AE9B4C(1, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); + func_80AEB280(this); + } +} + +void func_80AEB1C8(EnLiftNuts* this) { + this->actor.speedXZ = 2.0f; + gSaveContext.eventInf[3] |= 0x10; + Interface_StartTimer(4, 0); + func_80AE9B4C(1, 2); + this->actionFunc = func_80AEB230; +} + +void func_80AEB230(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] > 0) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80AEB280(this); + } +} + +void func_80AEB280(EnLiftNuts* this) { + this->actionFunc = func_80AEB294; +} + +void func_80AEB294(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (((player->actor.bgCheckFlags & 1) && (player->actor.floorBgId == BG_ACTOR_MAX) && + player->actor.world.pos.y < 20.0f) || + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= 0x2EE0) { + player->stateFlags1 |= PLAYER_STATE1_20; + Flags_SetSwitch(play, 0x41); + func_80AEB3E0(this, play); + } + + if (*this->ptr_1EC == 300) { + player->stateFlags1 |= PLAYER_STATE1_20; + + if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) < + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + Flags_SetSwitch(play, 0x40); + } + Flags_SetSwitch(play, 0x41); + func_80AEB3E0(this, play); + } +} + +void func_80AEB3E0(EnLiftNuts* this, PlayState* play) { + play_sound(NA_SE_SY_FOUND); + this->unk_354 = 0; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; + this->actionFunc = func_80AEB428; +} + +void func_80AEB428(EnLiftNuts* this, PlayState* play) { + s32 pad; + + if (this->unk_354 == 10) { + if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) > + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + Message_StartTextbox(play, 0x27EA, &this->actor); + this->textId = 0x27EA; + } else if (*this->ptr_1EC == 300) { + Message_StartTextbox(play, 0x27F8, &this->actor); + this->textId = 0x27F8; + } else { + Message_StartTextbox(play, 0x27EC, &this->actor); + this->textId = 0x27EC; + } + } else if (this->unk_354 == 30) { + gSaveContext.eventInf[3] &= (u8)~0x10; + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = ENTRANCE(DEKU_SCRUB_PLAYGROUND, 1); + gSaveContext.nextCutsceneIndex = 0; + func_80169EFC(&play->state); + gSaveContext.respawnFlag = -2; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; + } + this->unk_354++; +} + +void func_80AEB584(EnLiftNuts* this) { + this->actionFunc = func_80AEB598; +} + +void func_80AEB598(EnLiftNuts* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_10) && CHECK_WEEKEVENTREG(WEEKEVENTREG_14_20) && (CURRENT_DAY == 3) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_14_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_14_80); + } + func_80AEB684(this); + } else if ((this->textId == 0x27F4) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_14_80)) { + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } +} + +void func_80AEB684(EnLiftNuts* this) { + this->actionFunc = func_80AEB698; +} + +void func_80AEB698(EnLiftNuts* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_10) && CHECK_WEEKEVENTREG(WEEKEVENTREG_14_20) && (CURRENT_DAY == 3)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 13); + Message_StartTextbox(play, 0x27F5, &this->actor); + this->textId = 0x27F5; + } else if (func_80AE9B8C() > 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(play, 0x27F0, &this->actor); + this->textId = 0x27F0; + } else { + Message_StartTextbox(play, 0x27F1, &this->actor); + this->textId = 0x27F1; + } + this->actor.flags &= ~ACTOR_FLAG_10000; + func_80AEABF0(this); + switch (CURRENT_DAY) { + case 1: + SET_WEEKEVENTREG(WEEKEVENTREG_14_10); + break; + + case 2: + SET_WEEKEVENTREG(WEEKEVENTREG_14_20); + break; + + case 3: + SET_WEEKEVENTREG(WEEKEVENTREG_14_40); + break; + + default: + break; + } + } else { + func_800B85E0(&this->actor, play, 200.0f, -1); + } +} + +void func_80AEB828(EnLiftNuts* this) { + if (!func_80AE9B4C(0, 4)) { + func_80AE9B4C(1, 4); + this->unk_356 = 1; + } + if (this->actionFunc == func_80AE9F70) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + } + this->unk_354 = 0; + this->actionFunc = func_80AEB8A4; +} + +void func_80AEB8A4(EnLiftNuts* this, PlayState* play) { + if (this->unk_354 == 22) { + if (this->unk_356 == 1) { + Message_StartTextbox(play, 0x27F6, &this->actor); + this->textId = 0x27F6; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 17); + this->actionFunc = func_80AEB934; + } + this->unk_354++; +} + +void func_80AEB934(EnLiftNuts* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + func_80AEB9E0(this, play); + } +} + +void func_80AEB974(EnLiftNuts* this) { + s16 textId = this->textId; + + switch (textId) { + default: + this->unk_1E4 = 0; + break; + + case 0x27EE: + case 0x27EF: + this->unk_1E4 = 1; + break; + + case 0x27F5: + this->unk_1E4 = 2; + break; + + case 0x27F4: + if (this->unk_354 == 0) { + this->unk_1E4 = 2; + break; + } + this->unk_1E4 = 1; + } +} + +void func_80AEB9E0(EnLiftNuts* this, PlayState* play) { + Vec3f worldPos = this->actor.world.pos; + Vec3f velocity; + Vec3f accel; + Color_RGBA8 primColor = { 170, 130, 90, 255 }; + Color_RGBA8 envColor = { 100, 60, 20, 255 }; + s32 i; + + accel.y = 0.0f; + + for (i = 0; i < 30; i++) { + velocity.x = Rand_Centered() * 15.0f; + velocity.y = Rand_ZeroOne() * 2.0f; + velocity.z = Rand_Centered() * 15.0f; + + accel.x = -0.2f * velocity.x; + accel.z = -0.2f * velocity.z; + + func_800B0EB0(play, &worldPos, &velocity, &accel, &primColor, &envColor, 80, 25, 10); + } +} + +void func_80AEBB30(EnLiftNuts* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} + +void EnLiftNuts_Update(Actor* thisx, PlayState* play) { + EnLiftNuts* this = THIS; + + SkelAnime_Update(&this->skelAnime); + this->actionFunc(this, play); + func_80AEBB30(this, play); + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); + func_80AE9BCC(this, play); + + if (func_80AE9B4C(0, 2)) { + thisx->flags &= ~ACTOR_FLAG_1; + } +} + +s32 EnLiftNuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnLiftNuts* this = THIS; + + if (limbIndex == OBJECT_DNT_LIMB_0F || limbIndex == OBJECT_DNT_LIMB_10 || limbIndex == OBJECT_DNT_LIMB_15 || + limbIndex == OBJECT_DNT_LIMB_17 || limbIndex == OBJECT_DNT_LIMB_18 || limbIndex == OBJECT_DNT_LIMB_15 || + limbIndex == OBJECT_DNT_LIMB_1B) { + *dList = NULL; + } + + if (limbIndex == OBJECT_DNT_LIMB_1A) { + *dList = D_80AEBF18[this->unk_1E4]; + } + return false; +} + +void EnLiftNuts_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sFocusOffset = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == OBJECT_DNT_LIMB_19) { + Matrix_MultVec3f(&sFocusOffset, &thisx->focus.pos); + } +} + +void EnLiftNuts_Draw(Actor* thisx, PlayState* play) { + EnLiftNuts* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnLiftNuts_OverrideLimbDraw, EnLiftNuts_PostLimbDraw, thisx); +} 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..9a54132a4 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 @@ -2,18 +2,31 @@ #define Z_EN_LIFT_NUTS_H #include "global.h" +#include "objects/object_dnt/object_dnt.h" struct EnLiftNuts; -typedef void (*EnLiftNutsActionFunc)(struct EnLiftNuts*, GlobalContext*); +typedef void (*EnLiftNutsActionFunc)(struct EnLiftNuts*, PlayState*); + +#define ENLIFTNUTS_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) typedef struct EnLiftNuts { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; - /* 0x01D4 */ EnLiftNutsActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x180]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnLiftNutsActionFunc actionFunc; + /* 0x1D8 */ Vec3f vec_1D8; + /* 0x1E4 */ s32 unk_1E4; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ s16* ptr_1EC; + /* 0x1F0 */ Vec3s jointTable[OBJECT_DNT_LIMB_MAX]; + /* 0x298 */ Vec3s morphTable[OBJECT_DNT_LIMB_MAX]; + /* 0x340 */ UNK_TYPE1 unk_340[0xC]; + /* 0x34C */ s16 textId; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ UNK_TYPE1 unk_350[0x4]; + /* 0x354 */ s16 unk_354; + /* 0x356 */ s16 unk_356; } EnLiftNuts; // size = 0x358 -extern const ActorInit En_Lift_Nuts_InitVars; - #endif // Z_EN_LIFT_NUTS_H diff --git a/src/overlays/actors/ovl_En_Light/overlay.cfg b/src/overlays/actors/ovl_En_Light/overlay.cfg deleted file mode 100644 index 763d0ad6d..000000000 --- a/src/overlays/actors/ovl_En_Light/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Light -z_en_light.c 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 9dc919e0e..b988fcce3 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.c +++ b/src/overlays/actors/ovl_En_Light/z_en_light.c @@ -11,14 +11,14 @@ #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 = { +ActorInit En_Light_InitVars = { ACTOR_EN_LIGHT, ACTORCAT_ITEMACTION, FLAGS, @@ -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,41 +153,40 @@ 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_RotateYS(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_RotateYF(M_PI, MTXMODE_APPLY); @@ -195,8 +194,8 @@ void EnLight_Draw(Actor* thisx, GlobalContext* globalCtx) { 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_Light/z_en_light.h b/src/overlays/actors/ovl_En_Light/z_en_light.h index b17f55fd7..17762d7fa 100644 --- a/src/overlays/actors/ovl_En_Light/z_en_light.h +++ b/src/overlays/actors/ovl_En_Light/z_en_light.h @@ -20,6 +20,4 @@ typedef struct EnLight { /* 0x14C */ LightInfo lightInfo; } EnLight; // size = 0x15C -extern const ActorInit En_Light_InitVars; - #endif // Z_EN_LIGHT_H diff --git a/src/overlays/actors/ovl_En_Look_Nuts/overlay.cfg b/src/overlays/actors/ovl_En_Look_Nuts/overlay.cfg deleted file mode 100644 index 8d594952f..000000000 --- a/src/overlays/actors/ovl_En_Look_Nuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Look_Nuts -z_en_look_nuts.c 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 774acf118..ac376bb16 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 @@ -5,25 +5,26 @@ */ #include "z_en_look_nuts.h" +#include "overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h" #define FLAGS (ACTOR_FLAG_80000000) #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 = { +ActorInit En_Look_Nuts_InitVars = { ACTOR_EN_LOOK_NUTS, ACTORCAT_NPC, FLAGS, @@ -99,17 +100,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, + 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,12 +119,12 @@ void EnLookNuts_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->switchFlag == 0x7F) { this->switchFlag = -1; } - if ((this->switchFlag >= 0) && (Flags_GetSwitch(globalCtx, this->switchFlag))) { - Actor_MarkForDeath(&this->actor); + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { + Actor_Kill(&this->actor); return; } if (this->pathLocation == 0x1F) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -131,25 +132,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,7 +165,7 @@ 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); } @@ -189,7 +190,7 @@ void EnLookNuts_Patrol(EnLookNuts* this, GlobalContext* globalCtx) { 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; @@ -202,12 +203,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: @@ -260,16 +261,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); @@ -285,27 +286,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; - gSaveContext.save.weekEventReg[17] |= 4; + Scene_SetExitFade(play); + play->transitionTrigger = TRANS_TRIGGER_START; + SET_WEEKEVENTREG(WEEKEVENTREG_17_04); } } 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; @@ -319,7 +320,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--; } @@ -340,28 +341,29 @@ void EnLookNuts_Update(Actor* thisx, GlobalContext* globalCtx) { Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); if (!this->isPlayerDetected) { - s16 drawFlag = 1; + s16 effectFlags = SOLDERSRCHBALL_INVISIBLE; + if (gSaveContext.save.isNight) { - drawFlag = 0; + effectFlags = 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, + effectFlags); } } 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 & PLAYER_STATE3_100) && !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, PLAYER_CSMODE_26); 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; } @@ -372,7 +374,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); } } @@ -382,14 +384,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 e6eb6597a..b72215ce6 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,35 +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[DEKU_PALACE_GUARD_LIMB_MAX]; - /* 0x01CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; - /* 0x020C */ EnLookNutsActionFunc actionFunc; - /* 0x0210 */ Path *path; - /* 0x0214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path - /* 0x0216 */ s16 eyeState; - /* 0x0218 */ s16 blinkTimer; - /* 0x021A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen - /* 0x021C */ s16 state; - /* 0x021E */ s16 switchFlag; - /* 0x0220 */ s16 pathLocation; // Determines path that a guard will patrol - /* 0x0222 */ s16 isPlayerDetected; - /* 0x0224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for - /* 0x0226 */ s16 spawnIndex; - /* 0x0228 */ UNK_TYPE4 pad228; // Unused necessary padding - /* 0x022C */ Vec3f headRotation; - /* 0x0238 */ Vec3f headRotTarget; // Target value for head rotation - /* 0x0244 */ ColliderCylinder collider; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x1CA */ Vec3s morphTable[DEKU_PALACE_GUARD_LIMB_MAX]; + /* 0x20C */ EnLookNutsActionFunc actionFunc; + /* 0x210 */ Path *path; + /* 0x214 */ s16 currentPathIndex; // Index for the point where the deku guard is in its path + /* 0x216 */ s16 eyeState; + /* 0x218 */ s16 blinkTimer; + /* 0x21A */ s16 eventTimer; // Timer to trigger when another event within the actor will happen + /* 0x21C */ s16 state; + /* 0x21E */ s16 switchFlag; + /* 0x220 */ s16 pathLocation; // Determines path that a guard will patrol + /* 0x222 */ s16 isPlayerDetected; + /* 0x224 */ s16 waitTimer; // Timer for how long the deku guard will take a break for + /* 0x226 */ s16 spawnIndex; + /* 0x228 */ UNK_TYPE4 pad228; // Unused necessary padding + /* 0x22C */ Vec3f headRotation; + /* 0x238 */ Vec3f headRotTarget; // Target value for head rotation + /* 0x244 */ ColliderCylinder collider; } EnLookNuts; // size = 0x290 -extern const ActorInit En_Look_Nuts_InitVars; - #endif // Z_EN_LOOK_NUTS_H diff --git a/src/overlays/actors/ovl_En_M_Fire1/overlay.cfg b/src/overlays/actors/ovl_En_M_Fire1/overlay.cfg deleted file mode 100644 index 1d43db731..000000000 --- a/src/overlays/actors/ovl_En_M_Fire1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_M_Fire1 -z_en_m_fire1.c 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..14a9c4add 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,11 +10,11 @@ #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 = { +ActorInit En_M_Fire1_InitVars = { ACTOR_EN_M_FIRE1, ACTORCAT_MISC, FLAGS, @@ -46,31 +46,32 @@ 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; if (Math_StepToF(&this->timer, 1.0f, 0.2f)) { - Actor_MarkForDeath(&this->actor); - } else { - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + Actor_Kill(&this->actor); + return; } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } diff --git a/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.h b/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.h index fd5504e15..144e48d4d 100644 --- a/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.h +++ b/src/overlays/actors/ovl_En_M_Fire1/z_en_m_fire1.h @@ -11,6 +11,4 @@ typedef struct EnMFire1 { /* 0x190 */ f32 timer; } EnMFire1; // size = 0x194 -extern const ActorInit En_M_Fire1_InitVars; - #endif // Z_EN_M_FIRE1_H diff --git a/src/overlays/actors/ovl_En_M_Thunder/overlay.cfg b/src/overlays/actors/ovl_En_M_Thunder/overlay.cfg deleted file mode 100644 index 5de5ce33a..000000000 --- a/src/overlays/actors/ovl_En_M_Thunder/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_M_Thunder -z_en_m_thunder.c 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..3d97839a0 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,18 +5,31 @@ */ #include "z_en_m_thunder.h" +#include "z64rumble.h" +#include "overlays/actors/ovl_Eff_Dust/z_eff_dust.h" +#include "objects/gameplay_keep/gameplay_keep.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* play2); -#if 0 -const ActorInit En_M_Thunder_InitVars = { +void EnMThunder_UnkType_Update(Actor* thisx, PlayState* play); + +void EnMThunder_AdjustLights(PlayState* play, f32 arg1); + +void EnMThunder_Charge(EnMThunder* this, PlayState* play); +void EnMThunder_Spin_Attack(EnMThunder* this, PlayState* play); +void EnMThunder_SwordBeam_Attack(EnMThunder* this, PlayState* play); +void EnMThunder_UnkType_Attack(EnMThunder* this, PlayState* play); + +#define ENMTHUNDER_TYPE_MAX 4 + +ActorInit En_M_Thunder_InitVars = { ACTOR_EN_M_THUNDER, ACTORCAT_ITEMACTION, FLAGS, @@ -28,39 +41,536 @@ const ActorInit En_M_Thunder_InitVars = { (ActorFunc)EnMThunder_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_808B7120 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_PLAYER, AC_NONE, OC1_NONE, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x01000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x01000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 200, 200, 0, { 0, 0, 0 } }, }; -#endif +static u8 sDamages[] = { + 1, 2, 3, 4, // Regular + 1, 2, 3, 4, // Great Spin +}; -extern ColliderCylinderInit D_808B7120; +static u16 sChargingSfxIds[] = { + NA_SE_IT_ROLLING_CUT_LV2, // ENMTHUNDER_SUBTYPE_SPIN_GREAT + NA_SE_IT_ROLLING_CUT_LV1, // ENMTHUNDER_SUBTYPE_SPIN_REGULAR + NA_SE_IT_ROLLING_CUT_LV2, // ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT + NA_SE_IT_ROLLING_CUT_LV1, // ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B53C0.s") +static f32 sScales[] = { 0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.25f, 0.2f, 0.15f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Init.s") +typedef enum { + /* 0 */ ENMTHUNDER_SUBTYPE_SPIN_GREAT, + /* 1 */ ENMTHUNDER_SUBTYPE_SPIN_REGULAR, + /* 2 */ ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT, + /* 3 */ ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR +} EnMThunderSubType; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Destroy.s") +void EnMThunder_UnkType_Setup(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5890.s") + this->actor.update = EnMThunder_UnkType_Update; + this->isCharging = false; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + this->scaleTarget = 2; + this->actionFunc = EnMThunder_UnkType_Attack; + this->timer = 8; + this->lightColorFrac = 1.0f; + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT_LV1, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + this->actor.child = NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B58CC.s") +void EnMThunder_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnMThunder* this = THIS; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5984.s") + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->type = ENMTHUNDER_GET_TYPE(&this->actor); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 255, 255, 255, 0); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5EEC.s") + if (this->type == ENMTHUNDER_TYPE_UNK) { + EnMThunder_UnkType_Setup(this, play); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B5F68.s") + this->collider.dim.radius = 0; + this->collider.dim.height = 40; + this->collider.dim.yShift = -20; + this->timer = 8; + this->scroll = 0.0f; + this->actor.world.pos = player->bodyPartsPos[0]; + this->lightColorFrac = 0.0f; + this->adjustLightsArg1 = 0.0f; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.room = -1; + Actor_SetScale(&this->actor, 0.1f); + this->isCharging = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B60D4.s") + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if (!gSaveContext.save.playerData.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || + ((ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) && + !Magic_Consume(play, ENMTHUNDER_GET_MAGIC_COST(&this->actor), MAGIC_CONSUME_NOW))) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + Actor_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B6310.s") + player->stateFlags2 &= ~PLAYER_STATE2_20000; + this->isCharging = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Update.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_02)) { + player->unk_B08[0] = 1.0f; + this->collider.info.toucher.damage = sDamages[this->type + ENMTHUNDER_TYPE_MAX]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_GREAT; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 6; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 4; + } else { + this->scaleTarget = 3; + } + } else { + player->unk_B08[0] = 0.5f; + this->collider.info.toucher.damage = sDamages[this->type]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 4; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 3; + } else { + this->scaleTarget = 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/func_808B65BC.s") + if (player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) { + this->subtype += ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT; + this->actionFunc = EnMThunder_SwordBeam_Attack; + this->timer = 1; + this->scaleTarget = 12; + this->collider.info.toucher.dmgFlags = DMG_SWORD_BEAM; + this->collider.info.toucher.damage = 3; + } else { + this->actionFunc = EnMThunder_Spin_Attack; + this->timer = 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_M_Thunder/EnMThunder_Draw.s") + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT_LV1, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + + this->lightColorFrac = 1.0f; + } else { + this->actionFunc = EnMThunder_Charge; + } + + this->actor.child = NULL; +} + +void EnMThunder_Destroy(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + if (this->isCharging) { + Magic_Reset(play); + } + + Collider_DestroyCylinder(play, &this->collider); + EnMThunder_AdjustLights(play, 0.0f); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); +} + +void EnMThunder_AdjustLights(PlayState* play, f32 arg1) { + func_800FD2B4(play, arg1, 850.0f, 0.2f, 0.0f); +} + +void EnMThunder_Spin_AttackNoMagic(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + Actor_Kill(&this->actor); + return; + } + + if (!(player->stateFlags1 & PLAYER_STATE1_1000)) { + Actor_Kill(&this->actor); + } +} + +void EnMThunder_Charge(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Actor* child = this->actor.child; + + this->unk1B0 = player->unk_B08[0]; + this->actor.world.pos = player->bodyPartsPos[0]; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + + if (!this->isCharging && (player->unk_B08[0] >= 0.1f)) { + if ((gSaveContext.magicState != MAGIC_STATE_IDLE) || + ((ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) && + !Magic_Consume(play, ENMTHUNDER_GET_MAGIC_COST(&this->actor), MAGIC_CONSUME_WAIT_PREVIEW))) { + EnMThunder_Spin_AttackNoMagic(this, play); + this->actionFunc = EnMThunder_Spin_AttackNoMagic; + this->chargingAlpha = 0; + this->adjustLightsArg1 = 0.0f; + this->lightColorFrac = 0.0f; + return; + } + this->isCharging = true; + } + + if (player->unk_B08[0] >= 0.1f) { + Rumble_Request(0.0f, (s32)(player->unk_B08[0] * 150.0f), 2, (s32)(player->unk_B08[0] * 150.0f)); + } + + if (player->stateFlags2 & PLAYER_STATE2_20000) { + if ((child != NULL) && (child->update != NULL)) { + child->parent = NULL; + } + + if (player->unk_B08[0] <= 0.15f) { + if ((player->unk_B08[0] >= 0.1f) && (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H)) { + AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + } + Actor_Kill(&this->actor); + return; + } + + player->stateFlags2 &= ~PLAYER_STATE2_20000; + + if (ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) { + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; + } + + if (player->unk_B08[0] < 0.85f) { + this->collider.info.toucher.damage = sDamages[this->type]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 4; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 3; + } else { + this->scaleTarget = 2; + } + } else { + this->collider.info.toucher.damage = sDamages[this->type + ENMTHUNDER_TYPE_MAX]; + this->subtype = ENMTHUNDER_SUBTYPE_SPIN_GREAT; + if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { + this->scaleTarget = 6; + } else if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + this->scaleTarget = 4; + } else { + this->scaleTarget = 3; + } + } + + if (player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) { + this->subtype += ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT; + this->actionFunc = EnMThunder_SwordBeam_Attack; + this->timer = 1; + } else { + this->actionFunc = EnMThunder_Spin_Attack; + this->timer = 8; + } + + AudioSfx_PlaySfx(sChargingSfxIds[this->subtype], &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, + &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); + + this->lightColorFrac = 1.0f; + + return; + } + + if (!(player->stateFlags1 & PLAYER_STATE1_1000)) { + if (this->actor.child != NULL) { + this->actor.child->parent = NULL; + } + Actor_Kill(&this->actor); + return; + } + + if (player->unk_B08[0] > 0.15f) { + this->chargingAlpha = 255; + if (this->actor.child == NULL) { + 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, + EFF_DUST_TYPE_SPIN_ATTACK_CHARGE); + } + this->adjustLightsArg1 += (((player->unk_B08[0] - 0.15f) * 1.5f) - this->adjustLightsArg1) * 0.5f; + } else if (player->unk_B08[0] > .1f) { + this->chargingAlpha = (s32)((player->unk_B08[0] - .1f) * 255.0f * 20.0f); + this->lightColorFrac = (player->unk_B08[0] - .1f) * 10.0f; + } else { + this->chargingAlpha = 0; + } + + if (player->unk_B08[0] > 0.85f) { + func_8019F900(&player->actor.projectedPos, 2); + } else if (player->unk_B08[0] > 0.15f) { + func_8019F900(&player->actor.projectedPos, 1); + } else if (player->unk_B08[0] > 0.1f) { + func_8019F900(&player->actor.projectedPos, 0); + } + + if (Play_InCsMode(play)) { + Actor_Kill(&this->actor); + } +} + +void func_808B5EEC(EnMThunder* this, PlayState* play) { + if (this->timer < 2) { + if (this->chargingAlpha < 40) { + this->chargingAlpha = 0; + } else { + this->chargingAlpha -= 40; + } + } + + this->scroll += 2.0f * this->alphaFrac; + + if (this->adjustLightsArg1 < this->lightColorFrac) { + this->adjustLightsArg1 = F32_LERPIMP(this->adjustLightsArg1, this->lightColorFrac, 0.1f); + } else { + this->adjustLightsArg1 = this->lightColorFrac; + } +} + +void EnMThunder_Spin_Attack(EnMThunder* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.0625f)) { + Actor_Kill(&this->actor); + } else { + Math_SmoothStepToF(&this->actor.scale.x, (s32)this->scaleTarget, 0.6f, 0.8f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + this->collider.dim.radius = this->actor.scale.x * 30.0f; + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + if (this->timer > 0) { + this->actor.world.pos.x = player->bodyPartsPos[0].x; + this->actor.world.pos.z = player->bodyPartsPos[0].z; + this->timer--; + } + + if (this->lightColorFrac > (6.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 6.0f); + } + + func_808B5EEC(this, play); + + if (Play_InCsMode(play)) { + Actor_Kill(&this->actor); + } +} + +void EnMThunder_SwordBeam_Attack(EnMThunder* this, PlayState* play) { + s32 pad[2]; + f32 sp2C; + + if (this->lightColorFrac > (9.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 9.0f); + } + + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.05f)) { + Actor_Kill(&this->actor); + } else { + sp2C = -80.0f * Math_CosS(this->actor.world.rot.x); + + this->actor.world.pos.x += sp2C * Math_SinS(this->actor.shape.rot.y); + this->actor.world.pos.z += sp2C * Math_CosS(this->actor.shape.rot.y); + this->actor.world.pos.y += -80.0f * Math_SinS(this->actor.world.rot.x); + + Math_SmoothStepToF(&this->actor.scale.x, this->scaleTarget, 0.6f, 2.0f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + + this->collider.dim.radius = this->actor.scale.x * 5.0f; + + 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; + + this->collider.dim.pos.x = + (Math_SinS(this->actor.shape.rot.y) * -5.0f * this->actor.scale.x) + this->actor.world.pos.x; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->collider.dim.pos.z = + (Math_CosS(this->actor.shape.rot.y) * -5.0f * this->actor.scale.z) + this->actor.world.pos.z; + + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + } + + if (this->timer > 0) { + this->timer--; + } + + func_808B5EEC(this, play); +} + +void EnMThunder_UnkType_Attack(EnMThunder* this, PlayState* play) { + if (Math_StepToF(&this->lightColorFrac, 0.0f, 0.0625f)) { + Actor_Kill(&this->actor); + } else { + Math_SmoothStepToF(&this->actor.scale.x, (s32)this->scaleTarget, 0.6f, 0.8f, 0.0f); + Actor_SetScale(&this->actor, this->actor.scale.x); + } + + if (this->lightColorFrac > (6.0f / 10.0f)) { + this->alphaFrac = 1.0f; + } else { + this->alphaFrac = this->lightColorFrac * (10.0f / 6.0f); + } + + func_808B5EEC(this, play); +} + +void EnMThunder_Update(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + this->actionFunc(this, play); + EnMThunder_AdjustLights(play, this->adjustLightsArg1); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->lightColorFrac * 255.0f, this->lightColorFrac * 255.0f, + this->lightColorFrac * 100.0f, this->lightColorFrac * 800.0f); +} + +void EnMThunder_UnkType_Update(Actor* thisx, PlayState* play) { + EnMThunder* this = THIS; + + this->actionFunc(this, play); + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, this->lightColorFrac * 255.0f, this->lightColorFrac * 255.0f, + this->lightColorFrac * 100.0f, this->lightColorFrac * 800.0f); +} + +void EnMThunder_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnMThunder* this = THIS; + Player* player = GET_PLAYER(play); + f32 scale; + s32 y2Scroll; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + switch (this->subtype) { + case ENMTHUNDER_SUBTYPE_SPIN_GREAT: + case ENMTHUNDER_SUBTYPE_SPIN_REGULAR: + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0xFF - ((u16)(s32)(this->scroll * 30.0f) & 0xFF), 0, 64, + 32, 1, 0xFF - ((u16)(s32)(this->scroll * 20.0f) & 0xFF), 0, 8, 8)); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT: + case ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR: + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 16, 64, 1, 0, + 0x1FF - ((u16)(s32)(this->scroll * 10.0f) & 0x1FF), 32, 128)); + break; + + default: + break; + } + + switch (this->subtype) { + case ENMTHUNDER_SUBTYPE_SPIN_GREAT: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, (u16)(this->alphaFrac * 255.0f)); + gSPDisplayList(POLY_XLU_DISP++, gGreatSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gGreatSpinAttackCylinderDL); + break; + + case ENMTHUNDER_SUBTYPE_SPIN_REGULAR: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackCylinderDL); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_REGULAR: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); + gSPDisplayList(POLY_XLU_DISP++, gSwordBeamDL); + break; + + case ENMTHUNDER_SUBTYPE_SWORDBEAM_GREAT: + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 0, 255, 255, (u16)(this->alphaFrac * 255.0f)); + gDPSetEnvColor(POLY_XLU_DISP++, 200, 200, 200, 128); + gSPDisplayList(POLY_XLU_DISP++, gSwordBeamDL); + break; + + default: + break; + } + + Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + + if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { + Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(-1.2f, -0.8f, -0.6f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); + } else { + Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(-0.7f, -0.6f, -0.4f, MTXMODE_APPLY); + Matrix_RotateXS(0x4000, MTXMODE_APPLY); + } + + if (this->unk1B0 >= 0.85f) { + scale = (sScales[play->gameplayFrames & 7] * 6.0f) + 1.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, this->chargingAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128); + y2Scroll = 40; + } else { + scale = (sScales[play->gameplayFrames & 7] * 2.0f) + 1.0f; + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, this->chargingAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128); + y2Scroll = 20; + } + + Matrix_Scale(1.0f, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (play->gameplayFrames * 5) & 0xFF, 0, 32, 32, 1, + (play->gameplayFrames * 20) & 0xFF, (play->gameplayFrames * y2Scroll) & 0xFF, 8, 8)); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackChargingDL); + + CLOSE_DISPS(play->state.gfxCtx); +} 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..9842eeb78 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,15 +5,36 @@ struct EnMThunder; -typedef void (*EnMThunderActionFunc)(struct EnMThunder*, GlobalContext*); +#define ENMTHUNDER_GET_TYPE(thisx) ((thisx)->params & 0xFF) +#define ENMTHUNDER_GET_MAGIC_COST(thisx) (((thisx)->params & 0xFF00) >> 8) + +typedef enum { + /* 0x00 */ ENMTHUNDER_TYPE_KOKIRI_SWORD, + /* 0x01 */ ENMTHUNDER_TYPE_RAZOR_SWORD, + /* 0x02 */ ENMTHUNDER_TYPE_GILDED_SWORD, + /* 0x03 */ ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD, + /* 0x80 */ ENMTHUNDER_TYPE_UNK = 0x80 +} EnMThunderType; + +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 */ ColliderCylinder collider; + /* 0x190 */ LightNode* lightNode; + /* 0x194 */ LightInfo lightInfo; + /* 0x1A4 */ f32 lightColorFrac; + /* 0x1A8 */ f32 alphaFrac; + /* 0x1AC */ f32 scroll; + /* 0x1B0 */ f32 unk1B0; + /* 0x1B4 */ f32 adjustLightsArg1; + /* 0x1B8 */ EnMThunderActionFunc actionFunc; + /* 0x1BC */ u16 timer; + /* 0x1BE */ u8 subtype; + /* 0x1BF */ u8 type; + /* 0x1C0 */ u8 chargingAlpha; + /* 0x1C1 */ u8 scaleTarget; + /* 0x1C2 */ u8 isCharging; } EnMThunder; // size = 0x1C4 -extern const ActorInit En_M_Thunder_InitVars; - #endif // Z_EN_M_THUNDER_H diff --git a/src/overlays/actors/ovl_En_Ma4/overlay.cfg b/src/overlays/actors/ovl_En_Ma4/overlay.cfg deleted file mode 100644 index 3a0c5af88..000000000 --- a/src/overlays/actors/ovl_En_Ma4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ma4 -z_en_ma4.c 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 226059ae2..93f33cfed 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); @@ -55,7 +54,7 @@ typedef enum { /* 3 */ MA4_STATE_AFTERDESCRIBETHEMCS, } EnMa4State; -const ActorInit En_Ma4_InitVars = { +ActorInit En_Ma4_InitVars = { ACTOR_EN_MA4, ACTORCAT_NPC, FLAGS, @@ -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; @@ -202,24 +200,24 @@ void EnMa4_Init(Actor* thisx, GlobalContext* globalCtx) { if (CURRENT_DAY == 1) { this->type = MA4_TYPE_DAY1; - } else if (gSaveContext.save.weekEventReg[22] & 1) { // Aliens defeated + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { this->type = MA4_TYPE_ALIENS_DEFEATED; } else { this->type = MA4_TYPE_ALIENS_WON; this->hasBow = false; } - if (Cutscene_GetSceneSetupIndex(globalCtx) != 0) { // if (sceneSetupIndex != 0) + if (Cutscene_GetSceneLayer(play) != 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); - gSaveContext.save.weekEventReg[8] &= (u8)~1; + Collider_DestroyCylinder(play, &this->collider); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_08_01); } // 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); + if (!(player->stateFlags1 & PLAYER_STATE1_800000)) { + 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)) { +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); + SET_WEEKEVENTREG(WEEKEVENTREG_21_20); + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_21_20); + 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)) { + 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); - player->stateFlags1 |= 0x20; + func_801477B4(play); + player->stateFlags1 |= PLAYER_STATE1_20; 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); + if ((gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) || !CHECK_QUEST_ITEM(QUEST_SONG_EPONA)) { + 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)) { - 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); + } else if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < SECONDS_TO_TIMER(115)) { + 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; - func_8010E9F0(4, 0); - gSaveContext.save.weekEventReg[8] |= 1; - func_80112AFC(globalCtx); - player->stateFlags1 |= 0x20; + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); + SET_WEEKEVENTREG(WEEKEVENTREG_08_01); + Interface_InitMinigame(play); + player->stateFlags1 |= PLAYER_STATE1_20; 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.minigameState == MINIGAME_STATE_COUNTDOWN_GO) { this->actionFunc = EnMa4_HorsebackGameWait; - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_20; } } -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); + player->stateFlags3 |= PLAYER_STATE3_400; + EnMa4_HorsebackGameCheckPlayerInteractions(this, play); if (this->poppedBalloonCounter != D_80AC0258) { D_80AC0258 = this->poppedBalloonCounter; - globalCtx->interfaceCtx.unk_25C = 1; + play->interfaceCtx.minigamePoints = 1; } - if ((gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) // timer >= 2 minutes - || (this->poppedBalloonCounter == 10)) { - gSaveContext.unk_3DD0[4] = 6; - EnMa4_SetupHorsebackGameEnd(this, globalCtx); + if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) || + (this->poppedBalloonCounter == 10)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; + EnMa4_SetupHorsebackGameEnd(this, play); D_80AC0258 = 0; } } -void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { - gSaveContext.save.weekEventReg[8] &= (u8)~1; +void EnMa4_SetupHorsebackGameEnd(EnMa4* this, PlayState* play) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_08_01); 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; + if (player->stateFlags1 & PLAYER_STATE1_100000) { + 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); + player->stateFlags1 |= PLAYER_STATE1_20; + func_800B85E0(&this->actor, play, 200.0f, PLAYER_IA_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) { - player->stateFlags1 &= ~0x20; - Message_StartTextbox(globalCtx, 0x334C, &this->actor); + if (Actor_ProcessTalkRequest(&this->actor, &play->state) != 0) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + 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_IA_MINUS1); } } @@ -862,62 +858,62 @@ 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; switch (this->type) { case MA4_TYPE_DAY1: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.save.weekEventReg[21] & 0x80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_21_80)) { 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; + SET_WEEKEVENTREG(WEEKEVENTREG_21_80); } } 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_21_40)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_21_20)) { + 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; + SET_WEEKEVENTREG(WEEKEVENTREG_21_40); } } else if (this->state == MA4_STATE_AFTERHORSEBACKGAME) { - if (gSaveContext.unk_3DE0[4] >= 2 * 60 * 100) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "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]; + time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; if ((s32)time < (s32)gSaveContext.save.horseBackBalloonHighScore) { // [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; } @@ -933,33 +929,33 @@ void EnMa4_StartDialogue(EnMa4* this, GlobalContext* globalCtx) { case MA4_TYPE_ALIENS_DEFEATED: if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { - if ((gSaveContext.save.weekEventReg[21] & 0x80)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_21_80)) { 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; + SET_WEEKEVENTREG(WEEKEVENTREG_21_80); } } 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) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "Try again?" - Message_StartTextbox(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } else { - time = gSaveContext.unk_3DE0[4]; + time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; 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) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= SECONDS_TO_TIMER(120)) { // "Try again?" - Message_StartTextbox(globalCtx, 0x3356, &this->actor); + Message_StartTextbox(play, 0x3356, &this->actor); this->textId = 0x3356; } else { - time = gSaveContext.unk_3DE0[4]; + time = gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]; 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) { + if (limbIndex == ROMANI_LIMB_HEAD) { Matrix_MultVec3f(&sp28, &this->actor.focus.pos); - } else if (limbIndex == MA1_LIMB_HAND_LEFT) { + } 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..3ac405b00 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; @@ -35,6 +35,4 @@ typedef struct EnMa4 { /* 0x33E */ u16 textId; } EnMa4; // size = 0x340 -extern const ActorInit En_Ma4_InitVars; - #endif // Z_EN_MA4_H diff --git a/src/overlays/actors/ovl_En_Ma_Yto/overlay.cfg b/src/overlays/actors/ovl_En_Ma_Yto/overlay.cfg deleted file mode 100644 index a1085bf0e..000000000 --- a/src/overlays/actors/ovl_En_Ma_Yto/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ma_Yto -z_en_ma_yto.c 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 52c6a2998..c9ba0f34d 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,61 +5,61 @@ */ #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); @@ -69,7 +69,7 @@ s32 EnMaYto_HasSpokenToPlayerToday(void); s32 EnMaYto_HasSpokenToPlayer(void); void EnMaYto_SetTalkedFlag(void); -const ActorInit En_Ma_Yto_InitVars = { +ActorInit En_Ma_Yto_InitVars = { ACTOR_EN_MA_YTO, ACTORCAT_NPC, FLAGS, @@ -106,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; @@ -142,7 +153,7 @@ void EnMaYto_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk320 = 0; this->eyeTexIndex = 0; - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { EnMaYto_SetFaceExpression(this, 0, 1); } else { EnMaYto_SetFaceExpression(this, 5, 2); @@ -150,45 +161,44 @@ 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)) { - Actor_MarkForDeath(&this->actor); + this->type = EN_MA_YTO_GET_TYPE(&this->actor); + if (!EnMaYto_CheckValidSpawn(this, play)) { + Actor_Kill(&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)) { + if (CURRENT_DAY == 3 && !CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { return false; } break; case MA_YTO_TYPE_DINNER: - if (CURRENT_DAY != 1 && (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY != 1 && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { return false; } break; case MA_YTO_TYPE_BARN: - if (gSaveContext.save.weekEventReg[22] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { if (((this->actor.params & 0x0F00) >> 8) != 0) { return false; } @@ -201,9 +211,8 @@ s32 EnMaYto_CheckValidSpawn(EnMaYto* this, GlobalContext* globalCtx) { break; case MA_YTO_TYPE_AFTERMILKRUN: - // if (!(ProtectedCremia) && !(gSaveContext.save.weekEventReg[52] & 2)) || (PlayedMilkMinigame)) - if ((!(gSaveContext.save.weekEventReg[52] & 1) && !(gSaveContext.save.weekEventReg[52] & 2)) || - (gSaveContext.save.weekEventReg[14] & 1)) { + if ((!CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_52_02)) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_14_01)) { return false; } break; @@ -215,7 +224,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); @@ -230,8 +239,7 @@ void EnMaYto_InitAnimation(EnMaYto* this, GlobalContext* globalCtx) { break; case MA_YTO_TYPE_BARN: - // if (AliensDefeated) - if (gSaveContext.save.weekEventReg[22] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { EnMaYto_ChangeAnim(this, 12); } else { EnMaYto_ChangeAnim(this, 8); @@ -252,7 +260,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); @@ -269,7 +277,7 @@ void EnMaYto_ChooseAction(EnMaYto* this, GlobalContext* globalCtx) { case MA_YTO_TYPE_AFTERMILKRUN: this->unk310 = 0; - if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI && (gSaveContext.save.weekEventReg[52] & 1) && + if ((INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) && CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01) && (Rand_Next() & 0x80)) { EnMaYto_SetupBeginWarmFuzzyFeelingCs(this); } else { @@ -288,13 +296,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)) { @@ -318,24 +326,23 @@ 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; case MA_YTO_TYPE_DINNER: - if (!(gSaveContext.save.weekEventReg[22] & 1) && CURRENT_DAY == 2) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01) && (CURRENT_DAY == 2)) { return 0; } - if (EnMaYto_SearchRomani(this, globalCtx)) { + if (EnMaYto_SearchRomani(this, play)) { return 2; } return 1; case MA_YTO_TYPE_BARN: - // if (AliensDefeated) - if (gSaveContext.save.weekEventReg[22] & 1) { - if (EnMaYto_SearchRomani(this, globalCtx)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + if (EnMaYto_SearchRomani(this, play)) { return 2; } return 1; @@ -352,28 +359,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); } @@ -382,22 +389,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); } } @@ -407,88 +414,88 @@ 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; } } } void EnMaYto_SetupDinnerWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { func_80B90E50(this, 0); this->unk31E = 0; } else { @@ -500,28 +507,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); } } } @@ -529,7 +536,7 @@ void EnMaYto_DinnerWait(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupDinnerDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -539,148 +546,148 @@ 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; } } } void EnMaYto_SetupBarnWait(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { EnMaYto_ChangeAnim(this, 13); func_80B90E50(this, 0); this->unk31E = 0; @@ -694,33 +701,33 @@ 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); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01) || ABS_ALT(direction) < 0x2000) { + 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); } } } } void EnMaYto_SetupBarnDialogueHandler(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { func_80B90E50(this, 1); } else { func_80B90E50(this, 2); @@ -729,136 +736,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: @@ -868,40 +875,39 @@ void EnMaYto_BarnChooseNextDialogue(EnMaYto* this, GlobalContext* globalCtx) { } void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { - if (gSaveContext.save.weekEventReg[52] & 1) { // if (ProtectedCremia) + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01)) { EnMaYto_SetFaceExpression(this, 3, 1); } else { - func_801A3098(NA_BGM_FAILURE_1); + Audio_PlayFanfare(NA_BGM_FAILURE_1); EnMaYto_SetFaceExpression(this, 5, 2); } 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01)) { + Message_StartTextbox(play, 0x33C1, &this->actor); this->textId = 0x33C1; } else { - // Fails milk minigame + // Failed 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; + SET_WEEKEVENTREG(WEEKEVENTREG_14_01); 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); } } @@ -909,38 +915,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; } } @@ -950,14 +956,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; } } @@ -966,33 +972,31 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_14_01); 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; + SET_WEEKEVENTREG(WEEKEVENTREG_14_01); 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_IA_MINUS1); } } @@ -1000,7 +1004,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); @@ -1019,12 +1023,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) {} @@ -1036,8 +1040,7 @@ void EnMaYto_WarmFuzzyFeelingCs(EnMaYto* this, GlobalContext* globalCtx) { break; case 2: - // Attempted Cremia Cart Ride - gSaveContext.save.weekEventReg[14] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_14_01); EnMaYto_ChangeAnim(this, 18); break; @@ -1048,8 +1051,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); } @@ -1062,15 +1065,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, PLAYER_CSMODE_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); } } @@ -1079,115 +1082,113 @@ 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_HasSpokenToPlayer()) { - Message_StartTextbox(globalCtx, 0x3394, &this->actor); + 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_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_HasSpokenToPlayer()) { - Message_StartTextbox(globalCtx, 0x339F, &this->actor); + 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; } } @@ -1195,52 +1196,51 @@ void EnMaYto_DinnerStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { case 2: if (EnMaYto_HasSpokenToPlayer()) { - Message_StartTextbox(globalCtx, 0x33A6, &this->actor); + 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_HasSpokenToPlayer()) { - Message_StartTextbox(globalCtx, 0x33A8, &this->actor); + 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) { - // if (AliensDefeated) - if (gSaveContext.save.weekEventReg[22] & 1) { +void EnMaYto_BarnStartDialogue(EnMaYto* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { 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; } } @@ -1248,26 +1248,26 @@ void EnMaYto_BarnStartDialogue(EnMaYto* this, GlobalContext* globalCtx) { 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); @@ -1296,10 +1296,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); } } @@ -1344,7 +1344,7 @@ void EnMaYto_SetFaceExpression(EnMaYto* this, s16 overrideEyeTexIndex, s16 mouth } void EnMaYto_InitFaceExpression(EnMaYto* this) { - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { EnMaYto_SetFaceExpression(this, 0, 1); EnMaYto_SetRomaniFaceExpression(this, 0, 0); } else { @@ -1356,19 +1356,19 @@ void EnMaYto_InitFaceExpression(EnMaYto* this) { s32 EnMaYto_HasSpokenToPlayerToday(void) { switch (CURRENT_DAY) { case 1: - if (gSaveContext.save.weekEventReg[13] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_04)) { return true; } break; case 2: - if (gSaveContext.save.weekEventReg[13] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_08)) { return true; } break; case 3: - if (gSaveContext.save.weekEventReg[13] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_10)) { return true; } break; @@ -1377,20 +1377,20 @@ s32 EnMaYto_HasSpokenToPlayerToday(void) { } s32 EnMaYto_HasSpokenToPlayer(void) { - // Please note each case doesn't have their respective `break`s. + // Please note no case here has a `break`. switch (CURRENT_DAY) { case 3: - if (gSaveContext.save.weekEventReg[13] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_10)) { return true; } case 2: - if (gSaveContext.save.weekEventReg[13] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_08)) { return true; } case 1: - if (gSaveContext.save.weekEventReg[13] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_04)) { return true; } } @@ -1400,46 +1400,44 @@ s32 EnMaYto_HasSpokenToPlayer(void) { void EnMaYto_SetTalkedFlag(void) { switch (CURRENT_DAY) { case 1: - gSaveContext.save.weekEventReg[13] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_13_04); break; case 2: - gSaveContext.save.weekEventReg[13] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_13_08); break; case 3: - gSaveContext.save.weekEventReg[13] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_13_10); break; } } -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; } } @@ -1447,30 +1445,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) { + 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); - 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); + OPEN_DISPS(play->state.gfxCtx); + if (this->type == MA_YTO_TYPE_BARN && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + 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..0955cd8e8 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; @@ -56,8 +30,6 @@ typedef struct EnMaYto { /* 0x322 */ u16 textId; } EnMaYto; // size = 0x324 -extern const ActorInit En_Ma_Yto_InitVars; - typedef enum { /* 0 */ MA_YTO_TYPE_DEFAULT, // Strokes cow on day 1 /* 1 */ MA_YTO_TYPE_BARN, @@ -66,7 +38,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/overlay.cfg b/src/overlays/actors/ovl_En_Ma_Yts/overlay.cfg deleted file mode 100644 index c185a0e53..000000000 --- a/src/overlays/actors/ovl_En_Ma_Yts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ma_Yts -z_en_ma_yts.c 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 f5bf0625b..64a6d138c 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,32 +5,31 @@ */ #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 = { +ActorInit En_Ma_Yts_InitVars = { ACTOR_EN_MA_YTS, ACTORCAT_NPC, FLAGS, @@ -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; @@ -145,7 +144,7 @@ void EnMaYts_InitAnimation(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SITTING: this->actor.targetMode = 6; // Day 1 or "Winning" the alien invasion - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { EnMaYts_ChangeAnim(this, 14); } else { EnMaYts_ChangeAnim(this, 18); @@ -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) { @@ -178,14 +177,14 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case 2: // Failing the alien invasion - if (!(gSaveContext.save.weekEventReg[22] & 1)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { return false; } break; case 3: // "Winning" the alien invasion - if (gSaveContext.save.weekEventReg[22] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { return false; } break; @@ -194,7 +193,7 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_BARN: // Failing the alien invasion - if (!(gSaveContext.save.weekEventReg[22] & 1)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { return false; } else if (gSaveContext.save.time >= CLOCK_TIME(20, 0) && CURRENT_DAY == 3) { return false; @@ -203,7 +202,7 @@ s32 EnMaYts_CheckValidSpawn(EnMaYts* this, GlobalContext* globalCtx) { case MA_YTS_TYPE_SLEEPING: // "Winning" the alien invasion - if (gSaveContext.save.weekEventReg[22] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { return false; } break; @@ -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)) { - Actor_MarkForDeath(&this->actor); + this->type = EN_MA_YTS_GET_TYPE(thisx); + if (!EnMaYts_CheckValidSpawn(this, play)) { + Actor_Kill(&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; @@ -250,7 +248,7 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->hasBow = false; } - if (CURRENT_DAY == 1 || (gSaveContext.save.weekEventReg[22] & 1)) { + if (CURRENT_DAY == 1 || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { this->overrideEyeTexIndex = 0; this->eyeTexIndex = 0; this->mouthTexIndex = 0; @@ -268,24 +266,24 @@ void EnMaYts_Init(Actor* thisx, GlobalContext* globalCtx) { this->mouthTexIndex = 0; this->unk_32C = 2; EnMaYts_SetupEndCreditsHandler(this); - } else if (CURRENT_DAY == 2 && gSaveContext.save.isNight == 1 && (gSaveContext.save.weekEventReg[22] & 1)) { + } else if (CURRENT_DAY == 2 && gSaveContext.save.isNight == 1 && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { EnMaYts_SetupStartDialogue(this); } else { EnMaYts_SetupDoNothing(this); } } -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)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_80)) { // Saying to non-human Link: "Cremia went to town." - gSaveContext.save.weekEventReg[65] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_65_80); 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) { - if (!(gSaveContext.save.weekEventReg[65] & 0x40)) { - gSaveContext.save.weekEventReg[65] |= 0x40; + } else if (Player_GetMask(play) != PLAYER_MASK_NONE) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_40)) { + SET_WEEKEVENTREG(WEEKEVENTREG_65_40); 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)) { + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_21_20)) { 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)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_65_20)) { // Saying to Grasshopper: "Cremia went to town." - gSaveContext.save.weekEventReg[65] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_65_20); 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)) { + 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)) { +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) { + if (limbIndex == ROMANI_LIMB_HEAD) { Matrix_MultZero(&this->actor.focus.pos); - } else if (limbIndex == MA1_LIMB_HAND_LEFT) { + } 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..eb700d8c2 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,24 +15,22 @@ 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; } EnMaYts; // size = 0x33C -extern const ActorInit En_Ma_Yts_InitVars; - typedef enum { /* 0 */ MA_YTS_TYPE_BARN, /* 1 */ MA_YTS_TYPE_SITTING, @@ -66,7 +38,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/overlay.cfg b/src/overlays/actors/ovl_En_Mag/overlay.cfg deleted file mode 100644 index 14fce0372..000000000 --- a/src/overlays/actors/ovl_En_Mag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mag -z_en_mag.c 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..3a72258cc 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 @@ -85,7 +85,7 @@ static s16 sZeldaEffectColorTargetIndex = 0; static s16 sTextAlphaTargetIndex = 0; static s16 sTextAlphaTimer = 20; -const ActorInit En_Mag_InitVars = { +ActorInit En_Mag_InitVars = { ACTOR_EN_MAG, ACTORCAT_PROP, FLAGS, @@ -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; @@ -135,7 +135,7 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk11F02 = 30; this->unk11F00 = this->state = MAG_STATE_INITIAL; - if (gSaveContext.unk_3F1E != 0) { + if (gSaveContext.hudVisibilityForceButtonAlphasByStatus) { this->mainTitleAlpha = 210; this->unk11F32 = 255; this->copyrightAlpha = 255; @@ -158,11 +158,11 @@ void EnMag_Init(Actor* thisx, GlobalContext* globalCtx) { this->displayEffectEnvColor[1] = 255; this->displayEffectEnvColor[2] = 155; - gSaveContext.unk_3F1E = 0; + gSaveContext.hudVisibilityForceButtonAlphasByStatus = false; 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,11 +389,11 @@ 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; + gSaveContext.sceneLayer = 0; } this->unk11F54 = 15; this->unk11F56 = 25; @@ -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..9515abc71 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 @@ -48,6 +47,4 @@ typedef struct EnMag { /* 0x11F74 */ UNK_TYPE1 unk11F74[4]; } EnMag; // size = 0x11F78 -extern const ActorInit En_Mag_InitVars; - #endif // Z_EN_MAG_H diff --git a/src/overlays/actors/ovl_En_Maruta/overlay.cfg b/src/overlays/actors/ovl_En_Maruta/overlay.cfg deleted file mode 100644 index 6816a8c92..000000000 --- a/src/overlays/actors/ovl_En_Maruta/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Maruta -z_en_maruta.c 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 cc56a5e5e..65e3d8b38 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -12,31 +12,31 @@ #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 = { +ActorInit En_Maruta_InitVars = { ACTOR_EN_MARUTA, ACTORCAT_PROP, FLAGS, @@ -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; @@ -284,7 +317,7 @@ void func_80B37428(EnMaruta* this, GlobalContext* globalCtx) { kendoJs->unk_28C--; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -297,9 +330,9 @@ 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); + Actor_Kill(&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,10 +473,10 @@ 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); + Actor_Kill(&this->actor); return; } Math_SmoothStepToF(&this->actor.scale.x, 0.0f, 0.2f, 0.01f, 0.001f); @@ -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); @@ -627,7 +663,7 @@ void func_80B3828C(Vec3f* arg0, Vec3f* arg1, s16 arg2, s16 arg3, s32 arg4) { Matrix_Pop(); } -void func_80B382E4(GlobalContext* globalCtx, Vec3f arg1) { +void func_80B382E4(PlayState* play, Vec3f arg1) { Vec3f sp84 = arg1; Vec3f sp78; Vec3f sp6C; @@ -644,30 +680,30 @@ 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]; @@ -677,7 +713,7 @@ void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { 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)) { @@ -695,5 +731,5 @@ void EnMaruta_Draw(Actor* thisx, GlobalContext* globalCtx) { 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..0216ba383 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.h @@ -5,28 +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; - #endif // Z_EN_MARUTA_H diff --git a/src/overlays/actors/ovl_En_Minideath/overlay.cfg b/src/overlays/actors/ovl_En_Minideath/overlay.cfg deleted file mode 100644 index deffea103..000000000 --- a/src/overlays/actors/ovl_En_Minideath/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Minideath -z_en_minideath.c 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..d47992114 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.c @@ -10,26 +10,26 @@ #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 = { +ActorInit En_Minideath_InitVars = { ACTOR_EN_MINIDEATH, ACTORCAT_ENEMY, FLAGS, @@ -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..0a08318ab 100644 --- a/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h +++ b/src/overlays/actors/ovl_En_Minideath/z_en_minideath.h @@ -5,14 +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; - #endif // Z_EN_MINIDEATH_H diff --git a/src/overlays/actors/ovl_En_Minifrog/overlay.cfg b/src/overlays/actors/ovl_En_Minifrog/overlay.cfg deleted file mode 100644 index db7e2a842..000000000 --- a/src/overlays/actors/ovl_En_Minifrog/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Minifrog -z_en_minifrog.c 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 d8b4296cb..f459a6a41 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -12,21 +12,21 @@ #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 = { +ActorInit En_Minifrog_InitVars = { ACTOR_EN_MINIFROG, ACTORCAT_NPC, FLAGS, @@ -66,14 +66,8 @@ static TexturePtr D_808A4D74[] = { object_fr_Tex_005BA0, }; -// gSaveContext.save.weekEventReg[KEY] = VALUE -// KEY | VALUE static u16 isFrogReturnedFlags[] = { - (0 << 8) | 0x00, // NULL - (32 << 8) | 0x40, // Woodfall Temple Frog Returned - (32 << 8) | 0x80, // Great Bay Temple Frog Returned - (33 << 8) | 0x01, // Southern Swamp Frog Returned - (33 << 8) | 0x02, // Laundry Pool Frog Returned + 0, WEEKEVENTREG_32_40, WEEKEVENTREG_32_80, WEEKEVENTREG_33_01, WEEKEVENTREG_33_02, }; static s32 isInitialized = false; @@ -82,19 +76,19 @@ 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++) { + for (i = 0; i < ARRAY_COUNT(D_808A4D74); i++) { D_808A4D74[i] = Lib_SegmentedToVirtual(D_808A4D74[i]); } isInitialized = true; @@ -112,36 +106,34 @@ void EnMinifrog_Init(Actor* thisx, GlobalContext* globalCtx) { this->timer = 0; if (1) {} - if (!EN_MINIFROG_IS_RETURNED(this)) { - if ((this->frogIndex == MINIFROG_YELLOW) || - ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & - (u8)isFrogReturnedFlags[this->frogIndex]))) { - Actor_MarkForDeath(&this->actor); - } else { - this->timer = 30; - this->actionFunc = EnMinifrog_SpawnGrowAndShrink; - this->actor.textId = 0xD81; // "Ah! Don Gero! It has been so long." - this->actor.colChkInfo.mass = 30; + + if (!EN_MINIFROG_IS_RETURNED(&this->actor)) { + if ((this->frogIndex == MINIFROG_YELLOW) || CHECK_WEEKEVENTREG(isFrogReturnedFlags[this->frogIndex])) { + Actor_Kill(&this->actor); + return; } + + this->timer = 30; + this->actionFunc = EnMinifrog_SpawnGrowAndShrink; + this->actor.textId = 0xD81; // "Ah! Don Gero! It has been so long." + this->actor.colChkInfo.mass = 30; } else { // Frogs in mountain village if (this->frogIndex == MINIFROG_YELLOW) { this->actor.textId = 0; this->actionFunc = EnMinifrog_SetupYellowFrogDialog; - // Not spoken to MINIFROG_YELLOW - if (!(gSaveContext.save.weekEventReg[34] & 1)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_34_01)) { this->actor.flags |= ACTOR_FLAG_10000; } this->actor.home.rot.x = this->actor.home.rot.z = 0; this->frog = NULL; } else { - this->frog = EnMinifrog_GetFrog(globalCtx); + this->frog = EnMinifrog_GetFrog(play); this->actor.flags &= ~ACTOR_FLAG_1; // Frog has been returned - if ((gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] & - (u8)isFrogReturnedFlags[this->frogIndex])) { + if (CHECK_WEEKEVENTREG(isFrogReturnedFlags[this->frogIndex])) { this->actionFunc = EnMinifrog_SetupNextFrogInit; } else { this->actor.draw = NULL; @@ -151,17 +143,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 +169,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 +216,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,50 +242,48 @@ 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) { +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?" + case 0xD82: // "What has brought you all this way?" + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + 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?" } - gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8] = - ((void)0, gSaveContext.save.weekEventReg[isFrogReturnedFlags[this->frogIndex] >> 8]) | - (u8)isFrogReturnedFlags[this->frogIndex]; + SET_WEEKEVENTREG(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); } } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } @@ -312,7 +302,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)))); @@ -323,22 +313,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; @@ -361,12 +351,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!" } @@ -375,14 +365,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); @@ -393,7 +383,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) { @@ -403,7 +393,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--; @@ -411,11 +401,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, &gPlayerAnim_link_normal_talk_free_wait, 0); } } -void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, GlobalContext* globalCtx) { +void EnMinifrog_SetupNextFrogChoir(EnMinifrog* this, PlayState* play) { u8 frogIndex; EnMinifrog_Jump(this); @@ -442,14 +432,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, &gPlayerAnim_link_normal_talk_free_wait, 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; @@ -462,137 +452,139 @@ 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, &gPlayerAnim_pn_gakkiplay, 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_IA_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_IA_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 + SET_WEEKEVENTREG(WEEKEVENTREG_34_01); break; case 0xD78: // "Unfortunately, it seems not all of our members have gathered." case 0xD79: // "Perhaps it is because winter was too long? They must not have realized that spring // has come to the mountains..." case 0xD7A: // "And when the great Don Gero has come for us, too...What a pity." case 0xD7F: // "Well, if it isn't the great Don Gero." - func_80151938(globalCtx, globalCtx->msgCtx.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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_35_80)) { // Obtained Heart Piece + func_80151938(play, 0xD7E); } else { - func_80151938(globalCtx, 0xD7D); // Get Heart Piece - gSaveContext.save.weekEventReg[35] |= 0x80; + func_80151938(play, 0xD7D); // Get Heart Piece + SET_WEEKEVENTREG(WEEKEVENTREG_35_80); } 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, + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_34_01)) { + 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; @@ -602,8 +594,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; } @@ -615,15 +606,15 @@ 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_ReplaceRotation(&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) { @@ -635,17 +626,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..9a3801d91 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 @@ -38,6 +38,4 @@ typedef struct EnMinifrog { /* 0x2B8 */ ColliderCylinder collider; } EnMinifrog; // size = 0x304 -extern const ActorInit En_Minifrog_InitVars; - #endif // Z_EN_MINIFROG_H diff --git a/src/overlays/actors/ovl_En_Minislime/overlay.cfg b/src/overlays/actors/ovl_En_Minislime/overlay.cfg deleted file mode 100644 index 795b335cb..000000000 --- a/src/overlays/actors/ovl_En_Minislime/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Minislime -z_en_minislime.c 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..1ab5f2cc6 100644 --- a/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c +++ b/src/overlays/actors/ovl_En_Minislime/z_en_minislime.c @@ -11,37 +11,37 @@ #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 = { +ActorInit En_Minislime_InitVars = { ACTOR_EN_MINISLIME, ACTORCAT_BOSS, FLAGS, @@ -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,8 +620,8 @@ void EnMinislime_SetupDespawn(EnMinislime* this) { this->actionFunc = EnMinislime_Despawn; } -void EnMinislime_Despawn(EnMinislime* this, GlobalContext* globalCtx) { - Actor_MarkForDeath(&this->actor); +void EnMinislime_Despawn(EnMinislime* this, PlayState* play) { + Actor_Kill(&this->actor); } void EnMinislime_SetupMoveToGekko(EnMinislime* this) { @@ -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..77cabe9b6 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 @@ -50,6 +50,4 @@ typedef struct EnMinislime { /* 0x160 */ ColliderCylinder collider; } EnMinislime; // size = 0x1AC -extern const ActorInit En_Minislime_InitVars; - #endif // Z_EN_MINISLIME_H diff --git a/src/overlays/actors/ovl_En_Mk/overlay.cfg b/src/overlays/actors/ovl_En_Mk/overlay.cfg deleted file mode 100644 index 7463d059a..000000000 --- a/src/overlays/actors/ovl_En_Mk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mk -z_en_mk.c 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 b0e468ab2..894d73a6f 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -10,20 +10,20 @@ #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 = { +ActorInit En_Mk_InitVars = { ACTOR_EN_MK, ACTORCAT_NPC, FLAGS, @@ -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->sceneId].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,13 +141,13 @@ 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) { if (this->unk_27A & 4) { textId = 0xFB9; - } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { textId = 0xFBC; } else { textId = 0xFBB; @@ -156,64 +155,64 @@ 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) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_40)) { textId = 0xFB9; - } else if (gSaveContext.save.weekEventReg[19] & 0x40) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_40)) { textId = 0xFB5; - } else if (func_80959524(globalCtx) >= 7) { + } else if (func_80959524(play) >= 7) { textId = 0xFB3; } else { switch (gSaveContext.save.playerForm) { case PLAYER_FORM_DEKU: - if (gSaveContext.save.weekEventReg[19] & 0x10) { - if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_10)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { textId = 0xFAF; } else { textId = 0xFAE; @@ -224,8 +223,8 @@ void func_80959844(EnMk* this, GlobalContext* globalCtx) { break; case PLAYER_FORM_GORON: - if (gSaveContext.save.weekEventReg[19] & 8) { - if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_08)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { textId = 0xFAB; } else { textId = 0xFAA; @@ -237,10 +236,10 @@ 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) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_04)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { textId = 0xFBF; } else { textId = 0xFA6; @@ -251,9 +250,9 @@ 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) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_20)) { textId = 0xFB2; } else { textId = 0xFB1; @@ -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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + func_801477B4(play); this->actionFunc = func_80959E18; - break; + } else { + func_80151938(play, play->msgCtx.currentTextId + 1); } - func_80151938(globalCtx, globalCtx->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); + SET_WEEKEVENTREG(WEEKEVENTREG_19_04); + func_80151938(play, 0xFA1); break; case 0xFA8: - gSaveContext.save.weekEventReg[19] |= 8; - if (gSaveContext.save.weekEventReg[55] & 0x80) { - func_80151938(globalCtx, 0xFBD); - break; + SET_WEEKEVENTREG(WEEKEVENTREG_19_08); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + func_80151938(play, 0xFBD); + } else { + func_80151938(play, 0xFA9); } - func_80151938(globalCtx, 0xFA9); break; case 0xFAC: - gSaveContext.save.weekEventReg[19] |= 0x10; - if (gSaveContext.save.weekEventReg[55] & 0x80) { - func_80151938(globalCtx, 0xFBE); - break; + SET_WEEKEVENTREG(WEEKEVENTREG_19_10); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + func_80151938(play, 0xFBE); + } else { + func_80151938(play, 0xFAD); } - func_80151938(globalCtx, 0xFAD); break; case 0xFB1: - gSaveContext.save.weekEventReg[19] |= 0x20; - func_801477B4(globalCtx); + SET_WEEKEVENTREG(WEEKEVENTREG_19_20); + 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,22 +358,22 @@ 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_IA_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 (gSaveContext.save.weekEventReg[20] & 0x40) { + if ((play->csCtx.state == 0) && (this->actor.cutscene == -1)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_40)) { this->unk_27A &= ~1; this->actionFunc = func_80959774; this->actor.home.rot.y += 0x4E20; @@ -392,73 +391,73 @@ 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; SkelAnime_Update(&this->skelAnime); - if (gSaveContext.save.weekEventReg[20] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_40)) { this->unk_27A &= ~1; this->actionFunc = func_80959774; this->actor.home.rot.y += 0x4E20; return; } - if (func_800B8718(&this->actor, &globalCtx->state)) { - globalCtx->msgCtx.ocarinaMode = 4; + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_20_40); + 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); - if (!(gSaveContext.save.weekEventReg[20] & 0x40) && (gSaveContext.save.weekEventReg[19] & 0x40)) { - func_800B874C(&this->actor, globalCtx, 200.0f, 100.0f); + func_800B8614(&this->actor, play, 200.0f); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_40) && CHECK_WEEKEVENTREG(WEEKEVENTREG_19_40)) { + 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,7 +469,7 @@ 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) { @@ -478,10 +477,10 @@ void EnMk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -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..bbf126f4e 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -6,21 +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; - #endif // Z_EN_MK_H diff --git a/src/overlays/actors/ovl_En_Mkk/overlay.cfg b/src/overlays/actors/ovl_En_Mkk/overlay.cfg deleted file mode 100644 index 490c7cd58..000000000 --- a/src/overlays/actors/ovl_En_Mkk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mkk -z_en_mkk.c 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..cbbaffca9 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.c @@ -5,26 +5,37 @@ */ #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 = { +ActorInit En_Mkk_InitVars = { ACTOR_EN_MKK, ACTORCAT_ENEMY, FLAGS, @@ -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_Kill(&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..80efcd577 100644 --- a/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h +++ b/src/overlays/actors/ovl_En_Mkk/z_en_mkk.h @@ -3,16 +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; - #endif // Z_EN_MKK_H diff --git a/src/overlays/actors/ovl_En_Mm/overlay.cfg b/src/overlays/actors/ovl_En_Mm/overlay.cfg deleted file mode 100644 index db9f54ab3..000000000 --- a/src/overlays/actors/ovl_En_Mm/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mm -z_en_mm.c 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 7cdddfcfd..d9b0bf507 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -11,17 +11,17 @@ #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 = { +ActorInit En_Mm_InitVars = { ACTOR_EN_MM, ACTORCAT_ITEMACTION, FLAGS, @@ -70,19 +70,19 @@ void func_80965BBC(EnMm* this) { } } -void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnMm_Init(Actor* thisx, PlayState* play) { EnMm* this = THIS; EnMmActionFunc action; - if ((this->actor.params >= 0) && ((!(gSaveContext.save.weekEventReg[37] & 0x10)) || - (gSaveContext.save.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { - Actor_MarkForDeath(&this->actor); + if ((this->actor.params >= 0) && (!CHECK_WEEKEVENTREG(WEEKEVENTREG_37_10) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_37_08) || (gSaveContext.unk_1014 != 0))) { + Actor_Kill(&this->actor); return; } 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,17 +112,17 @@ 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; + Vec3f slopeNormal; + s16 downwardSlopeYaw; f32 temp_f14; f32 temp_f12; f32 temp_f2; 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); } @@ -143,15 +143,15 @@ void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { } else { temp_f14 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; temp_f12 = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; - func_800B75A0(this->actor.floorPoly, &sp50, &unused); - temp_f14 += 3.0f * sp50.x; - temp_f12 += 3.0f * sp50.z; + Actor_GetSlopeDirection(this->actor.floorPoly, &slopeNormal, &downwardSlopeYaw); + temp_f14 += 3.0f * slopeNormal.x; + temp_f12 += 3.0f * slopeNormal.z; 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); + this->actor.world.rot.y = Math_Atan2S_XY(temp_f12, temp_f14); } if (!Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f)) { @@ -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.curRoom.num; this->actor.bgCheckFlags &= ~1; Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); gSaveContext.unk_1014 = 0; @@ -195,20 +195,20 @@ 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; @@ -216,7 +216,7 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { 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/overlay.cfg b/src/overlays/actors/ovl_En_Mm2/overlay.cfg deleted file mode 100644 index ee3394df9..000000000 --- a/src/overlays/actors/ovl_En_Mm2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mm2 -z_en_mm2.c 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..14c8d1170 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.c @@ -10,15 +10,15 @@ #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 = { +ActorInit En_Mm2_InitVars = { ACTOR_EN_MM2, ACTORCAT_ITEMACTION, FLAGS, @@ -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..4f961e1c0 100644 --- a/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h +++ b/src/overlays/actors/ovl_En_Mm2/z_en_mm2.h @@ -5,15 +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; - #endif // Z_EN_MM2_H diff --git a/src/overlays/actors/ovl_En_Mm3/overlay.cfg b/src/overlays/actors/ovl_En_Mm3/overlay.cfg deleted file mode 100644 index d1162759f..000000000 --- a/src/overlays/actors/ovl_En_Mm3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mm3 -z_en_mm3.c 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 6ee806d2e..3e58691cc 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.c @@ -11,25 +11,25 @@ #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 = { +ActorInit En_Mm3_InitVars = { ACTOR_EN_MM3, ACTORCAT_NPC, FLAGS, @@ -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); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + 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,167 +142,168 @@ 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); + if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] == SECONDS_TO_TIMER(10)) { + Message_StartTextbox(play, 0x2792, &this->actor); this->unk_2B4 = 0x2792; - } else if ((gSaveContext.unk_3DE0[0] >= 1500)) { - Message_StartTextbox(globalCtx, 0x2797, &this->actor); + } else if ((gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] >= SECONDS_TO_TIMER(15))) { + 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); + } else if ((gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] <= SECONDS_TO_TIMER_PRECISE(10, 50)) && + (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] >= SECONDS_TO_TIMER_PRECISE(9, 50))) { + 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + 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; } } else if ((this->unk_2AC > 0) && (this->unk_2B4 == 0x2791)) { this->unk_2AC--; if (this->unk_2AC == 0) { - if (gSaveContext.unk_3DE0[0] == 1000) { - func_801A3098(0x922); + if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] == SECONDS_TO_TIMER(10)) { + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { play_sound(NA_SE_SY_ERROR); } @@ -310,44 +315,44 @@ 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) { - func_8010EA9C(0, 2); + player->stateFlags1 |= PLAYER_STATE1_20; + if (Player_GetMask(play) == PLAYER_MASK_BUNNY) { + Interface_StartPostmanTimer(0, POSTMAN_MINIGAME_BUNNY_HOOD_ON); } else { - func_8010EA9C(0, 0); + Interface_StartPostmanTimer(0, POSTMAN_MINIGAME_BUNNY_HOOD_OFF); } - func_801477B4(globalCtx); + func_801477B4(play); play_sound(NA_SE_SY_START_SHOT); func_80A6FBA0(this); } else { - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); func_80A6F270(this); } } @@ -355,7 +360,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,44 +371,47 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); this->actionFunc = func_80A6FBFC; } -void func_80A6FBFC(EnMm3* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_80A6FBFC(EnMm3* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (gSaveContext.unk_3DD0[0] == 0x10) { - player->stateFlags1 &= ~0x20; + if (gSaveContext.timerStates[TIMER_ID_POSTMAN] == TIMER_STATE_POSTMAN_END) { + player->stateFlags1 &= ~PLAYER_STATE1_20; this->actor.flags |= ACTOR_FLAG_10000; - if (gSaveContext.unk_3DE0[0] > 1500) { - gSaveContext.unk_3DE0[0] = 1500; - } else if ((((void)0, gSaveContext.unk_3DE0[0]) >= (OSTime)(995 - XREG(16))) && - (((void)0, gSaveContext.unk_3DE0[0]) <= (OSTime)(1005 + XREG(17)))) { - gSaveContext.unk_3DE0[0] = 1000; + if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] > SECONDS_TO_TIMER(15)) { + gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(15); + } else if ((((void)0, gSaveContext.timerCurTimes[TIMER_ID_POSTMAN]) >= + (OSTime)(SECONDS_TO_TIMER_PRECISE(10, -5) - XREG(16))) && + (((void)0, gSaveContext.timerCurTimes[TIMER_ID_POSTMAN]) <= + (OSTime)(SECONDS_TO_TIMER_PRECISE(10, 5) + XREG(17)))) { + gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] = SECONDS_TO_TIMER(10); } - } else if (gSaveContext.unk_3DE0[0] > 1500) { - gSaveContext.unk_3DD0[0] = 15; - gSaveContext.unk_3DC8 = osGetTime(); + } else if (gSaveContext.timerCurTimes[TIMER_ID_POSTMAN] > SECONDS_TO_TIMER(15)) { + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_POSTMAN_STOP; + gSaveContext.postmanTimerStopOsTime = 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; + gSaveContext.timerStates[TIMER_ID_POSTMAN] = TIMER_STATE_OFF; this->actor.flags &= ~ACTOR_FLAG_10000; play_sound(NA_SE_SY_START_SHOT); func_80A6F9C8(this); } else { - func_800B8614(&this->actor, globalCtx, this->actor.xzDistToPlayer + 10.0f); - func_80123E90(globalCtx, &this->actor); - if (Player_GetMask(globalCtx) == PLAYER_MASK_BUNNY) { + 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); @@ -415,17 +423,17 @@ void func_80A6FE1C(EnMm3* this) { this->actionFunc = func_80A6FE30; } -void func_80A6FE30(EnMm3* this, GlobalContext* globalCtx) { - if (Actor_HasParent(&this->actor, globalCtx)) { - if (!(gSaveContext.save.weekEventReg[77] & 1)) { - gSaveContext.save.weekEventReg[77] |= 1; +void func_80A6FE30(EnMm3* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_77_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_77_01); } this->actor.parent = NULL; func_80A6FED8(this); - } else if (gSaveContext.save.weekEventReg[77] & 1) { - Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_01)) { + 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); } } @@ -433,26 +441,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)) { - player->stateFlags1 &= ~0x20; - Message_StartTextbox(globalCtx, 0x2794, &this->actor); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + 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; } @@ -483,10 +491,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 { @@ -508,23 +516,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) { @@ -533,14 +541,14 @@ 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)) { + 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) { @@ -548,18 +556,18 @@ void EnMm3_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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..e6b512723 100644 --- a/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h +++ b/src/overlays/actors/ovl_En_Mm3/z_en_mm3.h @@ -5,26 +5,29 @@ struct EnMm3; -typedef void (*EnMm3ActionFunc)(struct EnMm3*, GlobalContext*); +typedef void (*EnMm3ActionFunc)(struct EnMm3*, PlayState*); + +typedef enum { + /* 0 */ POSTMAN_MINIGAME_BUNNY_HOOD_OFF, + /* 2 */ POSTMAN_MINIGAME_BUNNY_HOOD_ON = 2 +} PostmanMinigameBunnyHoodState; 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; - #endif // Z_EN_MM3_H diff --git a/src/overlays/actors/ovl_En_Mnk/overlay.cfg b/src/overlays/actors/ovl_En_Mnk/overlay.cfg deleted file mode 100644 index 456c850ac..000000000 --- a/src/overlays/actors/ovl_En_Mnk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mnk -z_en_mnk.c 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..ef064969e 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c @@ -10,13 +10,13 @@ #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 = { +ActorInit En_Mnk_InitVars = { ACTOR_EN_MNK, ACTORCAT_NPC, FLAGS, @@ -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..e2f739ada 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.h @@ -2,17 +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; - #endif // Z_EN_MNK_H diff --git a/src/overlays/actors/ovl_En_Ms/overlay.cfg b/src/overlays/actors/ovl_En_Ms/overlay.cfg deleted file mode 100644 index f8f57266e..000000000 --- a/src/overlays/actors/ovl_En_Ms/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ms -z_en_ms.c 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 4135fe701..6aac1355d 100644 --- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -11,17 +11,17 @@ #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 = { +ActorInit En_Ms_InitVars = { ACTOR_EN_MS, ACTORCAT_NPC, FLAGS, @@ -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)) { +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)) { - 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)) { - 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_IA_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_IA_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..aa46b820d 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; @@ -16,6 +16,4 @@ typedef struct EnMs { /* 0x1F8 */ ColliderCylinder collider; } EnMs; // size = 0x244 -extern const ActorInit En_Ms_InitVars; - #endif // Z_EN_MS_H diff --git a/src/overlays/actors/ovl_En_Mt_tag/overlay.cfg b/src/overlays/actors/ovl_En_Mt_tag/overlay.cfg deleted file mode 100644 index dcf4dadff..000000000 --- a/src/overlays/actors/ovl_En_Mt_tag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mt_tag -z_en_mt_tag.c 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 aa96b13c1..a077ee1bf 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, @@ -28,7 +28,7 @@ typedef enum { GORON_RACE_CHEAT_TRYING_TO_REACH_GOAL_FROM_BEHIND, } PlayerCheatStatus; -const ActorInit En_Mt_tag_InitVars = { +ActorInit En_Mt_tag_InitVars = { ACTOR_EN_MT_TAG, ACTORCAT_BG, FLAGS, @@ -77,7 +77,7 @@ s32 EnMttag_IsInFinishLine(Vec3f* pos) { * and, if so, what kind of cheating the player is performing. */ s32 EnMttag_CheckPlayerCheatStatus(Vec3f* pos) { - if (!(gSaveContext.eventInf[1] & 1)) { + if (!CHECK_EVENTINF(EVENTINF_10)) { if (Math3D_XZBoundCheck(-466.0f, -386.0f, -687.0f, 193.0f, pos->x, pos->z)) { // The race hasn't started yet, but the player is beyond the starting line. return GORON_RACE_CHEAT_FALSE_START; @@ -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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { // 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) { - gSaveContext.unk_3DD0[4] = 0; - Message_StartTextbox(globalCtx, 0xE95, NULL); // An entrant made a false start - func_800B7298(globalCtx, &this->actor, 7); +void EnMttag_ShowFalseStartMessage(EnMttag* this, PlayState* play) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; + Message_StartTextbox(play, 0xE95, NULL); // An entrant made a false start + func_800B7298(play, &this->actor, PLAYER_CSMODE_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, PLAYER_CSMODE_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,9 +286,9 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_12_02); 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); - gSaveContext.eventInf[1] |= 8; + EnMttag_ShowFalseStartMessage(this, play); + SET_EVENTINF(EVENTINF_13); } else { if (DECR(this->timer) == 60) { - func_8010E9F0(4, 0); - globalCtx->interfaceCtx.unk_280 = 1; + Interface_StartTimer(TIMER_ID_MINIGAME_2, 0); + play->interfaceCtx.minigameState = MINIGAME_STATE_COUNTDOWN_SETUP_3; Audio_QueueSeqCmd(NA_BGM_GORON_RACE | 0x8000); - globalCtx->envCtx.unk_E4 = 0xFE; - player->stateFlags1 &= ~0x20; - } else if ((this->timer < 60) && (globalCtx->interfaceCtx.unk_280 == 8)) { + play->envCtx.unk_E4 = 0xFE; + player->stateFlags1 &= ~PLAYER_STATE1_20; + } else if ((this->timer < 60) && (play->interfaceCtx.minigameState == MINIGAME_STATE_COUNTDOWN_GO)) { this->timer = 0; - gSaveContext.eventInf[1] |= 1; + SET_EVENTINF(EVENTINF_10); this->actionFunc = EnMttag_Race; } } } else { - if (EnMttag_AreFourRaceGoronsPresent(this, globalCtx)) { + if (EnMttag_AreFourRaceGoronsPresent(this, play)) { this->raceInitialized = true; } } @@ -353,24 +353,24 @@ 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; if (EnMttag_IsInFinishLine(playerPos)) { - gSaveContext.unk_3DD0[4] = 6; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; play_sound(NA_SE_SY_START_SHOT); Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); this->timer = 55; - gSaveContext.eventInf[1] |= 2; + SET_EVENTINF(EVENTINF_11); this->actionFunc = EnMttag_RaceFinish; } else if (EnMttag_IsAnyRaceGoronOverFinishLine(this)) { - gSaveContext.unk_3DD0[4] = 6; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; play_sound(NA_SE_SY_START_SHOT); Audio_QueueSeqCmd(NA_BGM_GORON_GOAL | 0x8000); this->timer = 55; - gSaveContext.eventInf[1] |= 4; + SET_EVENTINF(EVENTINF_12); this->actionFunc = EnMttag_RaceFinish; } else { playerCheatStatus = EnMttag_CheckPlayerCheatStatus(playerPos); @@ -381,11 +381,11 @@ void EnMttag_Race(EnMttag* this, GlobalContext* globalCtx) { this->shouldRestartRace = false; } - EnMttag_ShowFalseStartMessage(this, globalCtx); - gSaveContext.eventInf[1] |= 8; - } else if ((EnMttag_UpdateCheckpoints(this, globalCtx)) && (this->timer == 0)) { - EnMttag_ShowCantWinMessage(this, globalCtx); - gSaveContext.eventInf[1] |= 8; + EnMttag_ShowFalseStartMessage(this, play); + SET_EVENTINF(EVENTINF_13); + } else if ((EnMttag_UpdateCheckpoints(this, play)) && (this->timer == 0)) { + EnMttag_ShowCantWinMessage(this, play); + SET_EVENTINF(EVENTINF_13); } } } @@ -394,17 +394,17 @@ 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)) { + if (CHECK_EVENTINF(EVENTINF_11)) { // 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); + Actor_Kill(&this->actor); } } @@ -413,14 +413,14 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { // Spring gSaveContext.nextCutsceneIndex = 0xFFF0; } else { @@ -428,23 +428,22 @@ 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, - ((void)0, gSaveContext.unk_3F30) + (gSaveContext.save.playerData.doubleMagic * 48) + 48); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_02; + func_801477B4(play); + func_800B7298(play, &this->actor, PLAYER_CSMODE_7); + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); - gSaveContext.eventInf[1] &= (u8)~1; - gSaveContext.eventInf[1] &= (u8)~2; - gSaveContext.eventInf[1] &= (u8)~4; - gSaveContext.eventInf[1] &= (u8)~8; + CLEAR_EVENTINF(EVENTINF_10); + CLEAR_EVENTINF(EVENTINF_11); + CLEAR_EVENTINF(EVENTINF_12); + CLEAR_EVENTINF(EVENTINF_13); 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); + Actor_Kill(&this->actor); } } @@ -452,44 +451,45 @@ 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); - gSaveContext.eventInf[1] &= (u8)~8; - gSaveContext.eventInf[1] |= 4; - Actor_MarkForDeath(&this->actor); - } else { - // Keep racing - func_8019F208(); - func_801477B4(globalCtx); - func_800B7298(globalCtx, &this->actor, 6); - gSaveContext.eventInf[1] &= (u8)~8; - this->timer = 100; - this->actionFunc = EnMttag_Race; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_OFF; + EnMttag_ExitRace(play, TRANS_TYPE_02, TRANS_TYPE_02); + CLEAR_EVENTINF(EVENTINF_13); + SET_EVENTINF(EVENTINF_12); + Actor_Kill(&this->actor); + return; } + + // Keep racing + func_8019F208(); + func_801477B4(play); + func_800B7298(play, &this->actor, PLAYER_CSMODE_6); + CLEAR_EVENTINF(EVENTINF_13); + this->timer = 100; + this->actionFunc = EnMttag_Race; } } -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); - player->stateFlags1 |= 0x20; + if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) { + player = GET_PLAYER(play); + player->stateFlags1 |= PLAYER_STATE1_20; this->raceInitialized = false; this->timer = 100; - gSaveContext.eventInf[1] &= (u8)~1; - gSaveContext.eventInf[1] &= (u8)~2; - gSaveContext.eventInf[1] &= (u8)~4; - gSaveContext.eventInf[1] &= (u8)~8; + CLEAR_EVENTINF(EVENTINF_10); + CLEAR_EVENTINF(EVENTINF_11); + CLEAR_EVENTINF(EVENTINF_12); + CLEAR_EVENTINF(EVENTINF_13); - if (!(gSaveContext.save.weekEventReg[12] & 2)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_02)) { this->actionFunc = EnMttag_ShowIntroCutscene; } else { s32 requiredScopeTemp; @@ -497,18 +497,20 @@ void EnMttag_Init(Actor* thisx, GlobalContext* globalCtx) { this->actionFunc = EnMttag_RaceStart; } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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; + + if (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] != TIMER_STATE_6) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } } -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..19ebdb8d8 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; @@ -18,6 +18,4 @@ typedef struct EnMttag { /* 0x164 */ s32 shouldRestartRace; } EnMttag; // size = 0x168 -extern const ActorInit En_Mt_tag_InitVars; - #endif // Z_EN_MT_TAG_H diff --git a/src/overlays/actors/ovl_En_Mushi2/overlay.cfg b/src/overlays/actors/ovl_En_Mushi2/overlay.cfg deleted file mode 100644 index d8a7c2e85..000000000 --- a/src/overlays/actors/ovl_En_Mushi2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Mushi2 -z_en_mushi2.c 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 4afae5793..c10244e55 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.c @@ -12,27 +12,27 @@ #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 = { +ActorInit En_Mushi2_InitVars = { ACTOR_EN_MUSHI2, ACTORCAT_ITEMACTION, FLAGS, @@ -67,7 +67,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -120,11 +120,11 @@ void func_80A68808(EnMushi2* this) { 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, @@ -439,11 +438,11 @@ void func_80A69388(EnMushi2* this) { 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; @@ -659,7 +658,7 @@ void func_80A69D3C(EnMushi2* this) { sp38 = Math3D_XZLengthSquared(sp40, sp3C); if (fabsf(sp38) > 0.010000001f) { - s16 temp_v0 = Math_FAtan2F(sp3C, sp40); + s16 temp_v0 = Math_Atan2S_XY(sp3C, sp40); temp_v0 = CLAMP(temp_v0, -3000, 3000); func_80A68F9C(this, temp_v0); } @@ -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) && @@ -818,8 +816,11 @@ void func_80A6A36C(EnMushi2* this, GlobalContext* globalCtx) { } if (sp20 && (this->unk_36A <= 0)) { - Actor_MarkForDeath(&this->actor); - } else if (this->actor.bgCheckFlags & 0x20) { + Actor_Kill(&this->actor); + return; + } + + if (this->actor.bgCheckFlags & 0x20) { func_80A6AAA4(this); } else if (this->actor.bgCheckFlags & 1) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_GERUDOFT_WALK); @@ -848,7 +849,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 +861,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 +877,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 +893,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 +929,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 +958,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 +969,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 +998,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 +1020,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,17 +1031,17 @@ 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); } if (this->unk_368 <= 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -1053,7 +1054,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 +1070,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 +1088,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 +1096,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); } @@ -1107,11 +1108,11 @@ void func_80A6B0D8(EnMushi2* this, GlobalContext* globalCtx) { func_80A6A094(this); func_80A6A0D8(this); } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -void EnMushi2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnMushi2_Update(Actor* thisx, PlayState* play) { EnMushi2* this = THIS; s32 pad; f32 sp4C; @@ -1122,10 +1123,10 @@ 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); + Actor_Kill(&this->actor); return; } @@ -1158,11 +1159,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 +1219,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..1a776a52a 100644 --- a/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h +++ b/src/overlays/actors/ovl_En_Mushi2/z_en_mushi2.h @@ -5,46 +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; - #endif // Z_EN_MUSHI2_H diff --git a/src/overlays/actors/ovl_En_Muto/overlay.cfg b/src/overlays/actors/ovl_En_Muto/overlay.cfg deleted file mode 100644 index 3fd3e42b5..000000000 --- a/src/overlays/actors/ovl_En_Muto/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Muto -z_en_muto.c 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 c4b2beffc..f9d17ca96 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.c +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.c @@ -11,20 +11,20 @@ #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* play2); +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 = { +ActorInit En_Muto_InitVars = { ACTOR_EN_MUTO, ACTORCAT_NPC, FLAGS, @@ -58,45 +58,45 @@ 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) { this->shouldSetHeadRotation = true; this->textIdIndex = 2; - if (gSaveContext.save.weekEventReg[60] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_60_80)) { this->textIdIndex = 3; } if (gSaveContext.save.day != 3 || !gSaveContext.save.isNight) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else { this->collider.dim.radius = 30; this->collider.dim.height = 60; this->collider.dim.yShift = 0; - if (gSaveContext.save.weekEventReg[63] & 0x80 || (gSaveContext.save.day == 3 && gSaveContext.save.isNight)) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_80) || ((gSaveContext.save.day == 3) && gSaveContext.save.isNight)) { + Actor_Kill(&this->actor); } } 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,14 +129,14 @@ 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); + player = GET_PLAYER(play); if (player->transformation == PLAYER_FORM_DEKU) { - if (!(gSaveContext.save.weekEventReg[88] & 8)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_88_08)) { this->actor.textId = 0x62C; } else { this->actor.textId = 0x62B; @@ -146,12 +146,12 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { 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,23 +164,23 @@ void EnMuto_Idle(EnMuto* this, GlobalContext* globalCtx) { } } else { this->textIdIndex = 0; - if (gSaveContext.save.weekEventReg[60] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_60_08)) { 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; } @@ -188,24 +188,24 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_88_08); } if (this->actor.textId == 0x624) { - gSaveContext.save.weekEventReg[60] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_60_80); } this->textIdIndex = 3; @@ -229,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; } @@ -244,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); @@ -255,11 +255,11 @@ void EnMuto_Update(Actor* thisx, GlobalContext* globalCtx2) { } if (this->isInMayorsRoom && gSaveContext.save.day == 3 && gSaveContext.save.isNight) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); DECR(this->unusedCounter); @@ -272,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) { @@ -296,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..6ac984c8d 100644 --- a/src/overlays/actors/ovl_En_Muto/z_en_muto.h +++ b/src/overlays/actors/ovl_En_Muto/z_en_muto.h @@ -5,31 +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; - #endif // Z_EN_MUTO_H diff --git a/src/overlays/actors/ovl_En_Nb/overlay.cfg b/src/overlays/actors/ovl_En_Nb/overlay.cfg deleted file mode 100644 index 27d485b84..000000000 --- a/src/overlays/actors/ovl_En_Nb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Nb -z_en_nb.c 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..385325080 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -5,21 +5,112 @@ */ #include "z_en_nb.h" +#include "objects/object_nb/object_nb.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #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 EnNb_FollowSchedule(EnNb* this, PlayState* play); +void func_80BC0EAC(EnNb* this, PlayState* play); -#if 0 -const ActorInit En_Nb_InitVars = { +void func_80BC08E0(EnNb* this, PlayState* play); +void func_80BC0978(EnNb* this, PlayState* play); + +s32 func_80BC00AC(Actor* thisx, PlayState* play); +s32 func_80BC01DC(Actor* thisx, PlayState* play); + +#define EN_NB_FLAG_NONE (0) +#define EN_NB_FLAG_1 (1 << 0) +#define EN_NB_FLAG_2 (1 << 1) +#define EN_NB_FLAG_4 (1 << 2) +#define EN_NB_FLAG_8 (1 << 3) +#define EN_NB_FLAG_10 (1 << 4) +#define EN_NB_FLAG_20 (1 << 5) +#define EN_NB_FLAG_40 (1 << 6) +#define EN_NB_FLAG_80 (1 << 7) +#define EN_NB_FLAG_100 (1 << 8) +#define EN_NB_FLAG_200 (1 << 9) +#define EN_NB_FLAG_400 (1 << 10) + +typedef enum EnNbScheduleResult { + /* 0 */ EN_NB_SCH_NONE, + /* 1 */ EN_NB_SCH_1, + /* 2 */ EN_NB_SCH_2, + /* 3 */ EN_NB_SCH_3, + /* 4 */ EN_NB_SCH_4, +} EnNbScheduleResult; + +static u8 sScheduleScript[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x21 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x12 - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x0F - 0x0E), + /* 0x0E */ SCHEDULE_CMD_RET_NONE(), + /* 0x0F */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_3), + /* 0x12 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_OMOYA, 0x20 - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x1D - 0x1C), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_4), + /* 0x20 */ SCHEDULE_CMD_RET_NONE(), + /* 0x21 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x72 - 0x25), + /* 0x25 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x47 - 0x29), + /* 0x29 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 12, 0, 0x44 - 0x2F), + /* 0x2F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 12, 15, 0x41 - 0x35), + /* 0x35 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 18, 0, 0x3E - 0x3B), + /* 0x3B */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_3), + /* 0x3E */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_1), + /* 0x41 */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_2), + /* 0x44 */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_1), + /* 0x47 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_50_20, 0x57 - 0x4B), + /* 0x4B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 18, 0, 0x54 - 0x51), + /* 0x51 */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_3), + /* 0x54 */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_1), + /* 0x57 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 12, 0, 0x70 - 0x5D), + /* 0x5D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 12, 15, 0x6E - 0x63), + /* 0x63 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 18, 0, 0x6C - 0x69), + /* 0x69 */ SCHEDULE_CMD_RET_VAL_L(EN_NB_SCH_3), + /* 0x6C */ SCHEDULE_CMD_RET_VAL_S(EN_NB_SCH_1), + /* 0x6E */ SCHEDULE_CMD_RET_VAL_S(EN_NB_SCH_2), + /* 0x70 */ SCHEDULE_CMD_RET_VAL_S(EN_NB_SCH_1), + /* 0x72 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80BC1464[] = { + 0x1B, 0x04, 0x08, 0x00, 0x6A, 0x0A, 0x00, 0x10, 0x00, 0x08, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x0E, + 0x29, 0x12, 0x2D, 0x00, 0x0E, 0x0C, 0x10, 0x0E, 0x29, 0x01, 0x2D, 0x00, 0x0E, 0x0C, 0x10, 0x0E, 0x29, 0x02, 0x0C, + 0x0F, 0x29, 0x03, 0x0C, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x22, 0x31, 0x2D, 0x00, 0x0E, 0x12, 0x10, 0x30, 0x1C, + 0x04, 0x04, 0x0E, 0x29, 0x04, 0x0C, 0x20, 0x00, 0x03, 0x00, 0x04, 0x15, 0x09, 0x00, 0xC4, 0x09, 0x00, 0x00, 0x0F, + 0x29, 0x05, 0x0C, 0x15, 0x09, 0x00, 0xB9, 0x30, 0x1D, 0x04, 0x04, 0x0E, 0x29, 0x0B, 0x0C, 0x20, 0x00, 0x03, 0x00, + 0x04, 0x15, 0x09, 0x00, 0xA8, 0x09, 0x00, 0x00, 0x0F, 0x29, 0x0C, 0x0C, 0x15, 0x09, 0x00, 0x9D, 0x20, 0x00, 0x03, + 0x00, 0x17, 0x1B, 0x04, 0x04, 0x00, 0x09, 0x0E, 0x29, 0x11, 0x2D, 0x00, 0x0E, 0x0C, 0x16, 0x10, 0x0E, 0x29, 0x0A, + 0x2D, 0x00, 0x0E, 0x0C, 0x16, 0x10, 0x1B, 0x04, 0x04, 0x00, 0x3B, 0x0E, 0x29, 0x0D, 0x0C, 0x05, 0x00, 0x00, 0x00, + 0x0A, 0x00, 0x00, 0x0E, 0x29, 0x10, 0x2D, 0x00, 0x0E, 0x0C, 0x12, 0x16, 0x10, 0x0E, 0x29, 0x0E, 0x00, 0x32, 0x04, + 0x00, 0x59, 0x0C, 0x0F, 0x29, 0x0F, 0x0C, 0x12, 0x06, 0x00, 0x0C, 0x00, 0x00, 0x13, 0x00, 0x0C, 0x2F, 0x00, 0x00, + 0x2E, 0x2D, 0x00, 0x2A, 0x2D, 0x00, 0x0E, 0x11, 0x32, 0x04, 0x0C, 0x16, 0x10, 0x0E, 0x29, 0x06, 0x0C, 0x05, 0x00, + 0x0A, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x29, 0x07, 0x2D, 0x00, 0x0E, 0x0C, 0x12, 0x16, 0x10, 0x0E, 0x29, 0x08, 0x00, + 0x32, 0x02, 0x00, 0x1E, 0x0C, 0x0F, 0x29, 0x09, 0x0C, 0x12, 0x06, 0x00, 0x0C, 0x00, 0x00, 0x13, 0x00, 0x0C, 0x2F, + 0x00, 0x00, 0x2E, 0x2D, 0x00, 0x29, 0x2D, 0x00, 0x0E, 0x11, 0x32, 0x02, 0x0C, 0x16, 0x10, 0x2D, 0x00, 0x0E, 0x0C, + 0x12, 0x16, 0x10, 0x00, 0x00, 0x00, +}; + +u8 D_80BC1574[] = { + 0x09, 0x00, 0x00, 0x0E, 0x28, 0xC7, 0x0C, 0x09, 0x00, 0x00, 0x17, 0x0E, 0x28, 0xC8, 0x0C, 0x09, 0x00, + 0x00, 0x18, 0x0E, 0x28, 0xC9, 0x0C, 0x09, 0x00, 0x00, 0x17, 0x0E, 0x28, 0xCA, 0x0C, 0x09, 0x00, 0x00, + 0x18, 0x0E, 0x28, 0xCB, 0x0C, 0x09, 0x00, 0x00, 0x17, 0x0E, 0x28, 0xCC, 0x0C, 0x09, 0x00, 0x00, 0x18, + 0x0E, 0x28, 0xCD, 0x0C, 0x09, 0x00, 0x00, 0x17, 0x0E, 0x28, 0xCE, 0x0C, 0x09, 0x00, 0x00, 0x18, 0x0E, + 0x28, 0xCF, 0x2D, 0x00, 0x01, 0x2D, 0x00, 0x0E, 0x0C, 0x09, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, +}; + +u8 D_80BC15C8[] = { + 0x0E, 0x23, 0x62, 0x2D, 0x00, 0x0E, 0x0C, 0x10, +}; + +ActorInit En_Nb_InitVars = { ACTOR_EN_NB, ACTORCAT_NPC, FLAGS, @@ -31,81 +122,676 @@ const ActorInit En_Nb_InitVars = { (ActorFunc)EnNb_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BC15F0 = { - { 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_80BC161C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +static AnimationInfoS sAnimationInfo[] = { + { &gNbIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // EN_NB_ANIM_0 + { &gNbIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // EN_NB_ANIM_1 + { &gNbTalkAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // EN_NB_ANIM_TALK_ONCE + { &gNbTalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // EN_NB_ANIM_TALK_LOOP + { &gNbAngryAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // EN_NB_ANIM_ANGRY + { &gNbRelievedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, // EN_NB_ANIM_RELIEVED +}; -extern ColliderCylinderInit D_80BC15F0; -extern CollisionCheckInfoInit2 D_80BC161C; +Actor* EnNb_FindActor(EnNb* this, PlayState* play, u8 actorCategory, s16 actorId) { + Actor* thisx; + Actor* actor = NULL; -extern UNK_TYPE D_06008C40; + while (true) { + actor = SubS_FindActor(play, actor, actorCategory, actorId); + if (actor == NULL) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BBFDB0.s") + thisx = &this->actor; + if ((actor != thisx) && (actor->update != NULL)) { + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BBFE60.s") + if (actor->next == NULL) { + actor = NULL; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BBFE8C.s") + actor = actor->next; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BBFF24.s") + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BBFF90.s") +void EnNb_UpdateSkelAnime(EnNb* this) { + this->skelAnime.playSpeed = this->animPlaySpeed; + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BBFFD4.s") +s32 EnNb_ChangeAnim(EnNb* this, EnNbAnimation animIndex) { + s32 shouldChange = false; + s32 didAnimationChange = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0050.s") + if ((animIndex == EN_NB_ANIM_0) || (animIndex == EN_NB_ANIM_1)) { + if ((this->animIndex != EN_NB_ANIM_0) && (this->animIndex != EN_NB_ANIM_1)) { + shouldChange = true; + } + } else if (animIndex != this->animIndex) { + shouldChange = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC00AC.s") + if (shouldChange) { + this->animIndex = animIndex; + didAnimationChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->animPlaySpeed = this->skelAnime.playSpeed; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC01DC.s") + return didAnimationChange; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC045C.s") +void func_80BBFF24(EnNb* this, PlayState* play) { + f32 yDiff; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC04FC.s") + Collider_UpdateCylinder(&this->actor, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC05A8.s") + yDiff = this->actor.focus.pos.y - this->actor.world.pos.y; + this->collider.dim.height = yDiff; + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC06C4.s") +Actor* func_80BBFF90(EnNb* this, PlayState* play) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0800.s") + if (this->scheduleResult == EN_NB_SCH_2) { + actor = EnNb_FindActor(this, play, ACTORCAT_NPC, ACTOR_EN_AN); + } else { + actor = &GET_PLAYER(play)->actor; + } + return actor; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC08E0.s") +s32 func_80BBFFD4(EnNb* this, s16 index) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0978.s") + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(index); + } else if (ActorCutscene_GetCanPlayNext(index)) { + ActorCutscene_StartAndSetUnkLinkFields(index, &this->actor); + ret = true; + } else { + ActorCutscene_SetIntentToPlay(index); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0A18.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0B98.s") +s16 func_80BC0050(EnNb* this, s32 arg1) { + s16 cutscene = this->actor.cutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0C0C.s") + for (i = 0; i < arg1; i++) { + cutscene = ActorCutscene_GetAdditionalCutscene(cutscene); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0C80.s") + return cutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0D08.s") +typedef enum EnNbBehaviour { + /* 0 */ ENNB_BEHAVIOUR_0, + /* 1 */ ENNB_BEHAVIOUR_1, + /* 2 */ ENNB_BEHAVIOUR_2, + /* 3 */ ENNB_BEHAVIOUR_3, + /* 4 */ ENNB_BEHAVIOUR_4, + /* 5 */ ENNB_BEHAVIOUR_5, + /* 6 */ ENNB_BEHAVIOUR_6, + /* 7 */ ENNB_BEHAVIOUR_7, + /* 8 */ ENNB_BEHAVIOUR_8, + /* 9 */ ENNB_BEHAVIOUR_9 +} EnNbBehaviour; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0D1C.s") +s32 func_80BC00AC(Actor* thisx, PlayState* play) { + EnNb* this = THIS; + s16 cutscene = func_80BC0050(this, 0); + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0D84.s") + switch (this->behaviour) { + case ENNB_BEHAVIOUR_0: + if (!func_80BBFFD4(this, cutscene)) { + break; + } + // fallthrough + case ENNB_BEHAVIOUR_2: + case ENNB_BEHAVIOUR_4: + case ENNB_BEHAVIOUR_6: + case ENNB_BEHAVIOUR_8: + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(cutscene)), &this->actor); + this->behaviour++; + ret = true; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC0EAC.s") + case ENNB_BEHAVIOUR_1: + case ENNB_BEHAVIOUR_3: + case ENNB_BEHAVIOUR_5: + case ENNB_BEHAVIOUR_7: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(play, ActorCutscene_GetCurrentSubCamId(cutscene)), + this->actor.child); + } + this->behaviour++; + ret = true; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/EnNb_Init.s") + case ENNB_BEHAVIOUR_9: + ActorCutscene_Stop(cutscene); + this->behaviour++; + ret = true; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/EnNb_Destroy.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/EnNb_Update.s") +s32 func_80BC01DC(Actor* thisx, PlayState* play) { + EnNb* this = THIS; + s32 pad; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC1174.s") + switch (this->behaviour) { + case ENNB_BEHAVIOUR_0: + if (Player_GetMask(play) == PLAYER_MASK_ALL_NIGHT) { + this->behaviour = ENNB_BEHAVIOUR_1; + } else { + this->behaviour = ENNB_BEHAVIOUR_5; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC11B4.s") + case ENNB_BEHAVIOUR_1: + // Setup a black fill-screen, although initialize to 0 alpha + Play_FillScreen(&play->state, true, 0, 0, 0, 0); + this->storyTimer = 40; + this->behaviour = (u16)(this->behaviour + 1); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/func_80BC1278.s") + case ENNB_BEHAVIOUR_2: + // Slowly increase alpha to fill the screen with a black rectangle + R_PLAY_FILL_SCREEN_ALPHA = (s16)(s32)(255.0f - (((f32)ABS_ALT(20 - this->storyTimer) / 20.0f) * 255.0f)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nb/EnNb_Draw.s") + if (this->storyTimer == 20) { + if (gSaveContext.eventInf[4] & 4) { + // play->interfaceCtx.storyType = STORY_TYPE_MASK_FESTIVAL; + play->interfaceCtx.storyType = 0; + } else { + // play->interfaceCtx.storyType = STORY_TYPE_GIANTS_LEAVING; + play->interfaceCtx.storyType = 1; + } + // play->interfaceCtx.storyState = STORY_STATE_FADE_IN; + play->interfaceCtx.storyState = 6; + R_STORY_FILL_SCREEN_ALPHA = 255; + } + + if (DECR(this->storyTimer) == 0) { + this->behaviour++; + } + break; + + case ENNB_BEHAVIOUR_3: + // play->interfaceCtx.storyState = STORY_STATE_SETUP_IDLE; + play->interfaceCtx.storyState = 4; + this->behaviour++; + ret = true; + break; + + case ENNB_BEHAVIOUR_4: + // play->interfaceCtx.storyState = STORY_STATE_FADE_OUT; + play->interfaceCtx.storyState = 5; + this->behaviour++; + // fallthrough + case ENNB_BEHAVIOUR_5: + if (!(gSaveContext.eventInf[4] & 4)) { + gSaveContext.save.time = CLOCK_TIME(8, 0); + Sram_IncrementDay(); + } else { + func_800FE658(120.0f); + } + + this->behaviour++; + play->nextEntrance = ENTRANCE(STOCK_POT_INN, 2); + gSaveContext.nextCutsceneIndex = 0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.nextTransitionType = TRANS_TYPE_06; + gSaveContext.eventInf[4] |= 8; + break; + } + + return ret; +} + +u8* func_80BC045C(EnNb* this, PlayState* play) { + if (gSaveContext.eventInf[4] & 8) { + this->msgEventCallback = func_80BC01DC; + return D_80BC1464; + } else if (this->scheduleResult == EN_NB_SCH_2) { + this->msgEventCallback = func_80BC00AC; + return D_80BC1574; + } else if (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK) { + return D_80BC15C8; + } else { + this->msgEventCallback = func_80BC01DC; + return D_80BC1464; + } +} + +s32 func_80BC04FC(EnNb* this, PlayState* play) { + s32 ret = false; + + if (this->stateFlags & (EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->stateFlags |= EN_NB_FLAG_20; + SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_NONE, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); + this->behaviour = ENNB_BEHAVIOUR_0; + this->msgEventCallback = NULL; + this->actor.child = this->unk_1E8; + this->msgEventScript = func_80BC045C(this, play); + this->stateFlags |= EN_NB_FLAG_20; + this->actionFunc = func_80BC0EAC; + ret = true; + } + } + return ret; +} + +void func_80BC05A8(EnNb* this, PlayState* play) { + Player* player = GET_PLAYER(play); + TextState talkState = Message_GetState(&play->msgCtx); + u16 textId = play->msgCtx.currentTextId; + + if ((&this->actor == player->talkActor) && ((textId < 0xFF) || (textId > 0x200)) && (talkState == TEXT_STATE_3) && + (this->prevTalkState == TEXT_STATE_3)) { + if ((play->state.frames % 3) == 0) { + if (this->unk_26C == 120.0f) { + this->unk_26C = 0.0f; + } else { + this->unk_26C = 120.0f; + } + } + } else { + this->unk_26C = 0.0f; + } + + Math_SmoothStepToF(&this->unk_270, this->unk_26C, 0.8f, 40.0f, 10.0f); + Matrix_Translate(this->unk_270, 0.0f, 0.0f, MTXMODE_APPLY); + this->prevTalkState = talkState; +} + +void func_80BC06C4(EnNb* this) { + s32 pad; + Vec3f sp40; + Vec3f sp34; + Player* player; + + Math_Vec3f_Copy(&sp40, &this->unk_1E8->world.pos); + Math_Vec3f_Copy(&sp34, &this->actor.world.pos); + Math_ApproachS(&this->headRotY, Math_Vec3f_Yaw(&sp34, &sp40) - this->actor.shape.rot.y, 4, 0x2AA8); + + this->headRotY = CLAMP(this->headRotY, -0x1FFE, 0x1FFE); + + Math_Vec3f_Copy(&sp34, &this->actor.focus.pos); + + if (this->unk_1E8->id == ACTOR_PLAYER) { + player = (Player*)this->unk_1E8; + + sp40.y = player->bodyPartsPos[7].y + 3.0f; + } else { + Math_Vec3f_Copy(&sp40, &this->unk_1E8->focus.pos); + } + + Math_ApproachS(&this->headRotZ, Math_Vec3f_Pitch(&sp34, &sp40), 4, 0x2AA8); + + this->headRotZ = CLAMP(this->headRotZ, -0x1554, 0x1554); +} + +void func_80BC0800(EnNb* this) { + if (this->stateFlags & EN_NB_FLAG_20) { + if ((this->unk_1E8 != NULL) && (this->unk_1E8->update != NULL)) { + if (DECR(this->unk_282) == 0) { + func_80BC06C4(this); + this->stateFlags &= ~EN_NB_FLAG_400; + this->stateFlags |= EN_NB_FLAG_100; + return; + } + } + } + + if (this->stateFlags & EN_NB_FLAG_100) { + this->stateFlags &= ~EN_NB_FLAG_100; + this->headRotZ = 0; + this->headRotY = 0; + this->unk_282 = 20; + } else if (DECR(this->unk_282) == 0) { + this->stateFlags |= EN_NB_FLAG_400; + } +} + +// Related to both stories? +void func_80BC08E0(EnNb* this, PlayState* play) { + if (this->unk_284 == 0) { + EnNb_ChangeAnim(this, EN_NB_ANIM_TALK_ONCE); + this->stateFlags |= EN_NB_FLAG_400; + this->unk_284++; + } else if ((this->unk_284 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + EnNb_ChangeAnim(this, EN_NB_ANIM_1); + this->stateFlags &= ~EN_NB_FLAG_400; + this->unk_284++; + } +} + +void func_80BC0978(EnNb* this, PlayState* play) { + if (this->unk_284 == 0) { + EnNb_ChangeAnim(this, EN_NB_ANIM_RELIEVED); + this->stateFlags &= ~EN_NB_FLAG_20; + this->stateFlags |= EN_NB_FLAG_400; + this->unk_284++; + } else if ((this->unk_284 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + EnNb_ChangeAnim(this, EN_NB_ANIM_TALK_LOOP); + this->stateFlags &= ~EN_NB_FLAG_400; + this->unk_284++; + } +} + +s32 func_80BC0A18(EnNb* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u16 currentTextId = play->msgCtx.currentTextId; + + if (player->stateFlags1 & PLAYER_STATE1_40) { + this->stateFlags |= EN_NB_FLAG_80; + + if (this->textId != currentTextId) { + switch (currentTextId) { + case 0x28CF: + this->stateFlags |= EN_NB_FLAG_20; + EnNb_ChangeAnim(this, EN_NB_ANIM_TALK_LOOP); + break; + + case 0x2904: // "You want to hear the carnival of time story? ..." + case 0x290B: // "You want to hear the four giants story? ..." + this->unk_18C = func_80BC08E0; + this->unk_284 = 0; + break; + + case 0x28CD: + this->unk_18C = func_80BC0978; + this->unk_284 = 0; + break; + + case 0x28CB: // "I told you I already ate!" + EnNb_ChangeAnim(this, EN_NB_ANIM_ANGRY); + break; + + case 0x28C7: + case 0x2901: + case 0x2902: + case 0x2906: + case 0x290D: + case 0x2912: + EnNb_ChangeAnim(this, EN_NB_ANIM_TALK_LOOP); + break; + } + } + + this->textId = currentTextId; + } else if (this->stateFlags & EN_NB_FLAG_80) { + this->unk_18C = NULL; + this->textId = 0; + this->stateFlags &= ~EN_NB_FLAG_80; + EnNb_ChangeAnim(this, EN_NB_ANIM_1); + } + + if (this->unk_18C != NULL) { + this->unk_18C(this, play); + } + + return 0; +} + +s32 func_80BC0B98(EnNb* this, PlayState* play, ScheduleOutput* scheduleOutput) { + s32 success = false; + + if (EnNb_FindActor(this, play, ACTORCAT_NPC, ACTOR_EN_AN) != NULL) { + SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_1 | EN_NB_FLAG_2, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); + this->stateFlags |= EN_NB_FLAG_20; + EnNb_ChangeAnim(this, EN_NB_ANIM_0); + success = true; + } + + return success; +} + +s32 func_80BC0C0C(EnNb* this, PlayState* play, ScheduleOutput* scheduleOutput) { + if (!(gSaveContext.eventInf[4] & 8)) { + SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_1 | EN_NB_FLAG_2, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); + } else { + SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_4, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); + } + EnNb_ChangeAnim(this, EN_NB_ANIM_0); + + return true; +} + +s32 EnNb_ProcessScheduleOutput(EnNb* this, PlayState* play, ScheduleOutput* scheduleOutput) { + s32 success; + + this->actor.flags |= ACTOR_FLAG_1; + this->actor.targetMode = 0; + this->stateFlags = EN_NB_FLAG_NONE; + this->unk_274 = 40.0f; + + switch (scheduleOutput->result) { + default: + success = false; + break; + + case EN_NB_SCH_1: + case EN_NB_SCH_3: + case EN_NB_SCH_4: + success = func_80BC0C0C(this, play, scheduleOutput); + break; + + case EN_NB_SCH_2: + success = func_80BC0B98(this, play, scheduleOutput); + break; + } + return success; +} + +s32 func_80BC0D08(EnNb* this, PlayState* play) { + return 0; +} + +void EnNb_HandleSchedule(EnNb* this, PlayState* play) { + if ((this->scheduleResult == EN_NB_SCH_1) || (this->scheduleResult == EN_NB_SCH_2) || + (this->scheduleResult == EN_NB_SCH_3) || (this->scheduleResult == EN_NB_SCH_4)) { + func_80BC0D08(this, play); + } + + Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); +} + +void EnNb_FollowSchedule(EnNb* this, PlayState* play) { + ScheduleOutput scheduleOutput; + + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); + + if (gSaveContext.eventInf[4] & 8) { + scheduleOutput.result = EN_NB_SCH_1; + EnNb_ProcessScheduleOutput(this, play, &scheduleOutput); + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } else if (!Schedule_RunScript(play, sScheduleScript, &scheduleOutput) || + ((this->scheduleResult != scheduleOutput.result) && + !EnNb_ProcessScheduleOutput(this, play, &scheduleOutput))) { + this->actor.shape.shadowDraw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + scheduleOutput.result = EN_NB_SCH_NONE; + } else { + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.flags |= ACTOR_FLAG_1; + } + + this->scheduleResult = scheduleOutput.result; + this->unk_1E8 = func_80BBFF90(this, play); + EnNb_HandleSchedule(this, play); +} + +void func_80BC0EAC(EnNb* this, PlayState* play) { + if (func_8010BF58(&this->actor, play, this->msgEventScript, this->msgEventCallback, &this->msgEventArg4)) { + if (gSaveContext.eventInf[4] & 8) { + gSaveContext.eventInf[4] &= (u8)~4; + gSaveContext.eventInf[4] &= (u8)~8; + } + + SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_1 | EN_NB_FLAG_2, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); + if (this->scheduleResult != EN_NB_SCH_2) { + this->stateFlags &= ~EN_NB_FLAG_20; + } + + this->actor.child = NULL; + this->stateFlags |= EN_NB_FLAG_400; + this->unk_282 = 20; + this->msgEventArg4 = 0; + this->actionFunc = EnNb_FollowSchedule; + } +} + +void EnNb_Init(Actor* thisx, PlayState* play) { + EnNb* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gNbSkel, NULL, this->jointTable, this->morphTable, NB_LIMB_MAX); + + this->animIndex = EN_NB_ANIM_INVALID; + EnNb_ChangeAnim(this, EN_NB_ANIM_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->stateFlags = EN_NB_FLAG_NONE; + + if (gSaveContext.eventInf[4] & 8) { + SubS_UpdateFlags(&this->stateFlags, EN_NB_FLAG_4, EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4); + } else { + gSaveContext.eventInf[4] &= (u8)~4; + gSaveContext.eventInf[4] &= (u8)~8; + } + + this->actionFunc = EnNb_FollowSchedule; + this->actionFunc(this, play); +} + +void EnNb_Destroy(Actor* thisx, PlayState* play) { + EnNb* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); + play->interfaceCtx.storyState = 3; +} + +void EnNb_Update(Actor* thisx, PlayState* play) { + EnNb* this = THIS; + + func_80BC04FC(this, play); + this->actionFunc(this, play); + func_80BC0A18(this, play); + + if (this->scheduleResult != EN_NB_SCH_NONE) { + EnNb_UpdateSkelAnime(this); + func_80BC0800(this); + if (Actor_IsFacingPlayer(&this->actor, 0x38E0)) { + func_8013C964(&this->actor, play, this->unk_274, 30.0f, ITEM_OCARINA, + this->stateFlags & (EN_NB_FLAG_1 | EN_NB_FLAG_2 | EN_NB_FLAG_4)); + } + func_80BBFF24(this, play); + } +} + +s32 EnNb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnNb* this = THIS; + + if (limbIndex == NB_LIMB_HEAD) { + func_80BC05A8(this, play); + } + + return false; +} + +void EnNb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnNb* this = THIS; + Vec3f focusTarget; + + if ((ActorCutscene_GetCurrentIndex() == -1) && (limbIndex == NB_LIMB_HEAD)) { + Matrix_MultVec3f(&gZeroVec3f, &focusTarget); + Math_ApproachF(&thisx->focus.pos.x, focusTarget.x, 0.6f, 10000.0f); + Math_ApproachF(&thisx->focus.pos.y, focusTarget.y, 0.6f, 10000.0f); + Math_ApproachF(&thisx->focus.pos.z, focusTarget.z, 0.6f, 10000.0f); + Math_Vec3s_Copy(&thisx->focus.rot, &thisx->world.rot); + } +} + +void EnNb_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { + EnNb* this = THIS; + s32 stepRot; + s32 overrideRot; + + if (!(this->stateFlags & EN_NB_FLAG_400)) { + overrideRot = false; + if (this->stateFlags & EN_NB_FLAG_100) { + overrideRot = true; + stepRot = true; + } else { + stepRot = true; + } + } else { + overrideRot = false; + stepRot = false; + } + + if (limbIndex == NB_LIMB_HEAD) { + SubS_UpdateLimb(this->headRotZ + 0x4000, this->headRotY + this->actor.shape.rot.y + 0x4000, + &this->headComputedPos, &this->headComputedRot, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->headComputedPos.x, this->headComputedPos.y, this->headComputedPos.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headComputedRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headComputedRot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headComputedRot.z, MTXMODE_APPLY); + Matrix_Push(); + } +} + +void EnNb_Draw(Actor* thisx, PlayState* play) { + EnNb* this = THIS; + + if (this->scheduleResult != EN_NB_SCH_NONE) { + func_8012C5B0(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnNb_OverrideLimbDraw, EnNb_PostLimbDraw, + EnNb_TransformLimbDraw, &this->actor); + } +} 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..f11464c79 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.h +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.h @@ -2,18 +2,57 @@ #define Z_EN_NB_H #include "global.h" +#include "objects/object_nb/object_nb.h" struct EnNb; -typedef void (*EnNbActionFunc)(struct EnNb*, GlobalContext*); +typedef void (*EnNbActionFunc)(struct EnNb*, PlayState*); +typedef s32 (*EnNbUnkFunc)(Actor*, PlayState*); +typedef void (*EnNbUnkFunc2)(struct EnNb*, PlayState*); + +typedef enum EnNbAnimation { + /* -1 */ EN_NB_ANIM_INVALID = -1, + /* 0 */ EN_NB_ANIM_0, + /* 1 */ EN_NB_ANIM_1, + /* 2 */ EN_NB_ANIM_TALK_ONCE, + /* 3 */ EN_NB_ANIM_TALK_LOOP, + /* 4 */ EN_NB_ANIM_ANGRY, + /* 5 */ EN_NB_ANIM_RELIEVED, +} EnNbAnimation; typedef struct EnNb { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnNbActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x110]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnNbActionFunc actionFunc; + /* 0x18C */ EnNbUnkFunc2 unk_18C; + /* 0x190 */ ColliderCylinder collider; + /* 0x1DC */ u8 scheduleResult; + /* 0x1E0 */ u8* msgEventScript; + /* 0x1E4 */ s32 msgEventArg4; + /* 0x1E8 */ Actor* unk_1E8; + /* 0x1EC */ UNK_TYPE1 unk_1EC[4]; + /* 0x1F0 */ Vec3f headComputedPos; + /* 0x1FC */ Vec3s headComputedRot; + /* 0x202 */ Vec3s jointTable[NB_LIMB_MAX]; + /* 0x232 */ Vec3s morphTable[NB_LIMB_MAX]; + /* 0x262 */ u16 stateFlags; + /* 0x264 */ u16 textId; + /* 0x268 */ f32 animPlaySpeed; + /* 0x26C */ f32 unk_26C; // Related to unk_270 + /* 0x270 */ f32 unk_270; // headDisplacement? controls how much the upper part of the head moves when she talks + /* 0x274 */ f32 unk_274; + /* 0x278 */ UNK_TYPE1 unk_278[4]; + /* 0x27C */ s16 headRotZ; // Slightly rotates head when talking + /* 0x27E */ s16 headRotY; + /* 0x280 */ s16 timePathTimeSpeed; + /* 0x282 */ s16 unk_282; // timer? + /* 0x284 */ s16 unk_284; // storyState? + /* 0x286 */ s16 storyTimer; + /* 0x288 */ s16 behaviour; + /* 0x28C */ EnNbUnkFunc msgEventCallback; + /* 0x290 */ EnNbAnimation animIndex; + /* 0x294 */ UNK_TYPE1 unk_294[4]; + /* 0x294 */ TextState prevTalkState; } EnNb; // size = 0x29C -extern const ActorInit En_Nb_InitVars; - #endif // Z_EN_NB_H diff --git a/src/overlays/actors/ovl_En_Neo_Reeba/overlay.cfg b/src/overlays/actors/ovl_En_Neo_Reeba/overlay.cfg deleted file mode 100644 index b5d488d53..000000000 --- a/src/overlays/actors/ovl_En_Neo_Reeba/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Neo_Reeba -z_en_neo_reeba.c 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..86099a214 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,32 +11,32 @@ #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 = { +ActorInit En_Neo_Reeba_InitVars = { ACTOR_EN_NEO_REEBA, ACTORCAT_ENEMY, FLAGS, @@ -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)) { @@ -134,7 +134,7 @@ void EnNeoReeba_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.targetMode = 2; - this->actor.hintId = 0x47; + this->actor.hintId = TATL_HINT_ID_LEEVER; this->actor.gravity = -0.5f; this->targetPos = gZeroVec3f; @@ -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,9 +464,9 @@ 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); - Actor_MarkForDeath(&this->actor); + func_800B3030(play, &this->actor.world.pos, &sDeadDbAccel, &sDeadDbVel, 120, 0, 0); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x60); + Actor_Kill(&this->actor); } } else { if (this->actionTimer <= 10) { @@ -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..2cd24c88e 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; @@ -31,6 +31,4 @@ typedef struct EnNeoReeba { /* 0x310 */ u8 drawEffectType; } EnNeoReeba; // size = 0x314 -extern const ActorInit En_Neo_Reeba_InitVars; - #endif // Z_EN_NEO_REEBA_H diff --git a/src/overlays/actors/ovl_En_Nimotsu/overlay.cfg b/src/overlays/actors/ovl_En_Nimotsu/overlay.cfg deleted file mode 100644 index 8558fc330..000000000 --- a/src/overlays/actors/ovl_En_Nimotsu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Nimotsu -z_en_nimotsu.c 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..abaf6c3e0 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.c @@ -5,18 +5,20 @@ */ #include "z_en_nimotsu.h" +#include "assets/objects/object_boj/object_boj.h" #define FLAGS (ACTOR_FLAG_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 = { +void EnNimotsu_UpdateCollision(EnNimotsu* this, PlayState* play); + +ActorInit En_Nimotsu_InitVars = { ACTOR_EN_NIMOTSU, ACTORCAT_PROP, FLAGS, @@ -28,25 +30,93 @@ const ActorInit En_Nimotsu_InitVars = { (ActorFunc)EnNimotsu_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BE1FB0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, 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_TYPE_ALL, + 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 EnNimotsu_UpdateCollision(EnNimotsu* 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_80BE1FB0; +void EnNimotsu_Init(Actor* thisx, PlayState* play) { + EnNimotsu* this = THIS; -extern UNK_TYPE D_06013380; + Collider_InitCylinder(play, &this->collider); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/func_80BE1C80.s") + this->timer = 10; + this->actor.gravity = -0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/EnNimotsu_Init.s") + Actor_SetScale(&this->actor, 0.01f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/EnNimotsu_Destroy.s") +void EnNimotsu_Destroy(Actor* thisx, PlayState* play) { + EnNimotsu* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/EnNimotsu_Update.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Nimotsu/EnNimotsu_Draw.s") +void EnNimotsu_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnNimotsu* this = THIS; + Vec3f dustPosition; + + Actor_MoveWithGravity(&this->actor); + + if (!(this->dustDone & 1) && (this->actor.bgCheckFlags & 1)) { + if (DECR(this->timer) == 0) { + this->dustDone |= 1; + } + + if ((play->state.frames % 3) == 0) { + dustPosition.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); + dustPosition.y = this->actor.world.pos.y; + dustPosition.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); + Actor_SpawnFloorDustRing(play, &this->actor, &dustPosition, 20.0f, 0, 2.0f, 0, 0, 0); + } + } + + EnNimotsu_UpdateCollision(this, play); +} + +void EnNimotsu_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnNimotsu* this = THIS; + Vec3f position; + Vec3f scale; + + 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++, &gBombShopBagDL); + func_8012C2DC(play->state.gfxCtx); + + position.x = this->actor.world.pos.x + 7.0f; + position.y = this->actor.world.pos.y; + position.z = this->actor.world.pos.z + 2.0f; + + scale.x = 0.2f; + scale.y = 0.2f; + scale.z = 0.2f; + + func_800BC620(&position, &scale, 255, play); + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.h b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.h index 634697736..88e4a1f42 100644 --- a/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.h +++ b/src/overlays/actors/ovl_En_Nimotsu/z_en_nimotsu.h @@ -7,9 +7,10 @@ struct EnNimotsu; typedef struct EnNimotsu { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x98]; + /* 0x144 */ UNK_TYPE1 unk_144[0x48]; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ u16 dustDone; + /* 0x1DA */ s16 timer; } EnNimotsu; // size = 0x1DC -extern const ActorInit En_Nimotsu_InitVars; - #endif // Z_EN_NIMOTSU_H diff --git a/src/overlays/actors/ovl_En_Niw/overlay.cfg b/src/overlays/actors/ovl_En_Niw/overlay.cfg deleted file mode 100644 index 26dacb3bb..000000000 --- a/src/overlays/actors/ovl_En_Niw/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Niw -z_en_niw.c 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 493666856..1c9212a63 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -11,26 +11,26 @@ #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 EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationState); +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); s16 sCuccoStormActive = false; @@ -48,7 +48,7 @@ enum EnNiwState { /* 8 */ NIW_STATE_HOPPING, }; -const ActorInit En_Niw_InitVars = { +ActorInit En_Niw_InitVars = { ACTOR_EN_NIW, ACTORCAT_PROP, FLAGS, @@ -112,7 +112,7 @@ 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; @@ -129,7 +129,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 25.0f); - SkelAnime_InitFlex(globalCtx, &this->skelanime, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, this->morphTable, + 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); @@ -150,7 +150,7 @@ void EnNiw_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; if (this->niwType == NIW_TYPE_REGULAR) { - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); } if (this->niwType == NIW_TYPE_HELD) { @@ -169,11 +169,11 @@ 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 == NIW_TYPE_REGULAR) { - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } } @@ -182,12 +182,12 @@ void EnNiw_Destroy(Actor* thisx, GlobalContext* globalCtx) { * * AttackNiw has a copy of this function that it barely uses */ -void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationState) { +void EnNiw_AnimateWingHead(EnNiw* this, PlayState* play, s16 animationState) { f32 tempOne = 1.0f; // hopefully fake match, but no luck if (this->unkTimer24C == 0) { // targetLimbRots[0] is bodyRotY - if (animationState == NIW_ANIMATION_STILL) { + if (animationState == NIW_ANIM_STILL) { this->targetLimbRots[0] = 0.0f; } else { this->targetLimbRots[0] = -10000.0f * tempOne; @@ -197,7 +197,7 @@ void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationS this->unkTimer24C = 3; if ((this->unk292 % 2) == 0) { this->targetLimbRots[0] = 0.0f; - if (animationState == NIW_ANIMATION_STILL) { + if (animationState == NIW_ANIM_STILL) { this->unkTimer24C = Rand_ZeroFloat(30.0f); } } @@ -208,11 +208,11 @@ void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationS this->unkToggle296 &= 1; switch (animationState) { - case NIW_ANIMATION_STILL: + case NIW_ANIM_STILL: this->targetLimbRots[2] = 0.0f; // both wingRotZ this->targetLimbRots[1] = 0.0f; break; - case NIW_ANIMATION_HEAD_PECKING: + case NIW_ANIM_HEAD_PECKING: this->unkTimer24E = 3; this->targetLimbRots[2] = 7000.0f * tempOne; // both wingRotZ this->targetLimbRots[1] = 7000.0f * tempOne; @@ -222,7 +222,7 @@ void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationS } break; - case NIW_ANIMATION_PECKING_AND_WAVING: + case NIW_ANIM_PECKING_AND_WAVING: this->unkTimer24E = 2; this->targetLimbRots[2] = -10000.0f; // both wingRotZ this->targetLimbRots[1] = -10000.0f; @@ -236,7 +236,7 @@ void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationS } break; - case NIW_ANIMATION_PECKING_AND_FORFLAPPING: + case NIW_ANIM_PECKING_AND_FORFLAPPING: this->unkTimer24E = 2; this->targetLimbRots[5] = 10000.0f; // both wingRotY this->targetLimbRots[7] = 10000.0f; @@ -246,11 +246,11 @@ void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationS } break; - case NIW_ANIMATION_FREEZE: + case NIW_ANIM_FREEZE: this->unkTimer24C = 5; break; - case NIW_ANIMATION_PECKING_SLOW_FORFLAPPING: + case NIW_ANIM_PECKING_SLOW_FORFLAPPING: this->unkTimer24E = 5; this->targetLimbRots[5] = 14000.0f; // both wingRotY this->targetLimbRots[7] = 14000.0f; @@ -288,7 +288,7 @@ void EnNiw_AnimateWingHead(EnNiw* this, GlobalContext* globalCtx, s16 animationS } } -void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_SpawnAttackNiw(EnNiw* this, PlayState* play) { f32 xView; f32 yView; f32 zView; @@ -296,13 +296,13 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { Actor* attackNiw; if (this->attackNiwSpawnTimer == 0 && this->attackNiwCount < 7) { - xView = globalCtx->view.at.x - globalCtx->view.eye.x; - yView = globalCtx->view.at.y - globalCtx->view.eye.y; - zView = globalCtx->view.at.z - globalCtx->view.eye.z; - 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, + 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 != NULL) { @@ -312,7 +312,7 @@ void EnNiw_SpawnAttackNiw(EnNiw* this, GlobalContext* globalCtx) { } } -void EnNiw_UpdateRunning(EnNiw* this, GlobalContext* globalCtx, s32 isStormCucco) { +void EnNiw_UpdateRunning(EnNiw* this, PlayState* play, s32 isStormCucco) { f32 runningDirection; f32 targetRotY; f32* runningAngles = sRunningAngles; @@ -348,24 +348,25 @@ void EnNiw_UpdateRunning(EnNiw* this, GlobalContext* globalCtx, s32 isStormCucco 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); - EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_SLOW_FORFLAPPING); + EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_SLOW_FORFLAPPING); } void EnNiw_SetupIdle(EnNiw* this) { - Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), ANIMMODE_LOOP, + -10.0f); this->niwState = NIW_STATE_IDLE; this->actionFunc = EnNiw_Idle; } -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 nextAnimation; + s16 nextAnimIndex; if (this->niwType == NIW_TYPE_REGULAR) { - if (Actor_HasParent(&this->actor, globalCtx)) { // picked up + if (Actor_HasParent(&this->actor, play)) { // picked up Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICKEN_CRY_M); // crow this->sfxTimer1 = 30; this->heldTimer = 30; @@ -375,13 +376,13 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { this->actionFunc = EnNiw_Held; return; } else { - Actor_LiftActor(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, play); } } else { // NIW_TYPE_UNK1 || NIW_TYPE_HELD this->unkIdleTimer2 = 10; } - nextAnimation = NIW_ANIMATION_STILL; // probably a scoped variable here, where their scope was different + 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->headRotationToggle++; @@ -422,7 +423,7 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { if (this->unkIdleTimer != 0) { Math_ApproachZeroF(&this->targetLimbRots[9], 0.5f, 4000.0f); // head rot - nextAnimation = NIW_ANIMATION_HEAD_PECKING; + 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); @@ -446,10 +447,10 @@ void EnNiw_Idle(EnNiw* this, GlobalContext* globalCtx) { Math_ApproachF(&this->unk304, 10000.0f, 1.0f, 1000.0f); } - EnNiw_AnimateWingHead(this, globalCtx, nextAnimation); + 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; @@ -462,7 +463,7 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { 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 == NIW_TYPE_REGULAR) { - if (Actor_HasNoParent(&this->actor, globalCtx)) { + if (Actor_HasNoParent(&this->actor, play)) { this->actor.shape.rot.z = 0; rotZ = this->actor.shape.rot.z; this->niwState = NIW_STATE_FALLING; @@ -482,16 +483,16 @@ void EnNiw_Held(EnNiw* this, GlobalContext* globalCtx) { 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; } - EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } -void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_Thrown(EnNiw* this, PlayState* play) { if (this->unk2EC == 0) { if (this->actor.bgCheckFlags & 1) { // hit floor this->unk2EC = 1; @@ -516,7 +517,7 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { } } - 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; @@ -528,19 +529,19 @@ void EnNiw_Thrown(EnNiw* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; } else { if (this->hoppingTimer > 5) { - Actor_LiftActor(&this->actor, globalCtx); + Actor_LiftActor(&this->actor, play); } - EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } } -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; @@ -554,7 +555,7 @@ void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { 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) { // hit a wall this->actor.velocity.y = 10.0f; // fly up in straight line @@ -584,10 +585,10 @@ void EnNiw_Swimming(EnNiw* this, GlobalContext* globalCtx) { } } - EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } -void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_Trigger(EnNiw* this, PlayState* play) { s32 state; // Possible Fake Match: the weird way this state is set @@ -596,26 +597,26 @@ void EnNiw_Trigger(EnNiw* this, GlobalContext* globalCtx) { } this->cuccoStormTimer = 10; - this->niwState = this->nextAnimation = state; // NIW_ANIMATION_HEAD_PECKING + 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->cuccoStormTimer == 0) { this->cuccoStormTimer = 60; this->unkTimer24C = 10; - this->nextAnimation = NIW_ANIMATION_FREEZE; + this->nextAnimIndex = NIW_ANIM_FREEZE; this->niwState = NIW_STATE_ANGRY2; this->actionFunc = EnNiw_SetupCuccoStorm; } - EnNiw_AnimateWingHead(this, globalCtx, this->nextAnimation); + 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; @@ -639,11 +640,11 @@ void EnNiw_SetupCuccoStorm(EnNiw* this, GlobalContext* globalCtx) { this->actionFunc = EnNiw_CuccoStorm; } - EnNiw_AnimateWingHead(this, globalCtx, this->nextAnimation); + EnNiw_AnimateWingHead(this, play, this->nextAnimIndex); } -void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx) { - EnNiw_SpawnAttackNiw(this, globalCtx); +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->isRunningRight = Rand_ZeroFloat(1.99f); @@ -651,20 +652,21 @@ void EnNiw_CuccoStorm(EnNiw* this, GlobalContext* globalCtx) { this->unkTimer24E = this->generalTimer1; this->unkTimer24C = this->generalTimer1; } else { - EnNiw_UpdateRunning(this, globalCtx, true); + EnNiw_UpdateRunning(this, play, true); } } void EnNiw_SetupRunAway(EnNiw* this) { - Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, -10.0f); + Animation_Change(&this->skelanime, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), ANIMMODE_LOOP, + -10.0f); this->isRunningRight = Rand_ZeroFloat(1.99f); this->niwState = NIW_STATE_RUNNING; this->actionFunc = EnNiw_RunAway; 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; @@ -694,18 +696,18 @@ void EnNiw_RunAway(EnNiw* this, GlobalContext* globalCtx) { dZ = this->actor.world.pos.z - player->actor.world.pos.z; } this->yawTowardsPlayer = Math_Atan2S(dX, dZ); - EnNiw_UpdateRunning(this, globalCtx, false); - EnNiw_AnimateWingHead(this, globalCtx, NIW_ANIMATION_PECKING_AND_WAVING); + EnNiw_UpdateRunning(this, play, false); + EnNiw_AnimateWingHead(this, play, NIW_ANIM_PECKING_AND_WAVING); } } -void EnNiw_LandBeforeIdle(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_LandBeforeIdle(EnNiw* this, PlayState* play) { if (this->actor.bgCheckFlags & 1) { // hit floor EnNiw_SetupIdle(this); } } -void EnNiw_CheckRage(EnNiw* this, GlobalContext* globalCtx) { +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 @@ -759,11 +761,11 @@ 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; @@ -815,7 +817,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk29E = 0; } - EnNiw_UpdateFeather(this, globalCtx); + EnNiw_UpdateFeather(this, play); DECR(this->unkTimer24C); DECR(this->unkTimer24E); @@ -831,25 +833,25 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.rot = this->actor.world.rot; this->actor.shape.shadowScale = 15.0f; - this->actionFunc(this, globalCtx); + 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 (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; @@ -875,7 +877,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { this->headRotY = 0.0f; // clang-format off - this->isStormActive = this->unusedCounter28C = this->unk292 = this->unk29E = this->unk298 = this->isRunningRight = this->nextAnimation = 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++) { @@ -895,7 +897,7 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_Copy(&pos, &this->actor.world.pos); pos.y += this->actor.depthInWater; this->swimRippleTimer = 30; - EffectSsGSplash_Spawn(globalCtx, &pos, 0, 0, 0, 400); + EffectSsGSplash_Spawn(play, &pos, 0, 0, 0, 400); this->generalTimer2 = 0; this->niwState = NIW_STATE_SWIMMING; this->actionFunc = EnNiw_Swimming; @@ -903,10 +905,10 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { } 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); + func_800B8D50(play, &this->actor, 2.0f, this->actor.world.rot.y, 0.0f, 0x10); } - EnNiw_CheckRage(this, globalCtx); + 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); @@ -924,17 +926,17 @@ void EnNiw_Update(Actor* thisx, GlobalContext* globalCtx) { if (!this->isStormActive && this->niwType == NIW_TYPE_REGULAR) { Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); - if (globalCtx) {} + if (play) {} if (this->niwState != NIW_STATE_HELD && this->niwState != NIW_STATE_FALLING) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + 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 == NIW_LIMB_UPPER_BODY) { @@ -956,13 +958,13 @@ s32 EnNiw_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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) { @@ -984,7 +986,7 @@ void EnNiw_SpawnFeather(EnNiw* this, Vec3f* pos, Vec3f* vel, Vec3f* accel, f32 s } } -void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { +void EnNiw_UpdateFeather(EnNiw* this, PlayState* play) { EnNiwFeather* feather = &this->feathers[0]; f32 featherVelocityGoal = 0.05f; s16 i; @@ -1016,14 +1018,14 @@ void EnNiw_UpdateFeather(EnNiw* this, GlobalContext* globalCtx) { } } -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) { @@ -1034,7 +1036,7 @@ void EnNiw_DrawFeathers(EnNiw* this, GlobalContext* globalCtx) { } Matrix_Translate(feather->pos.x, feather->pos.y, feather->pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(feather->scale, feather->scale, 1.0f, MTXMODE_APPLY); Matrix_RotateZF(feather->zRot, MTXMODE_APPLY); Matrix_Translate(0.0f, -1000.0f, 0.0f, MTXMODE_APPLY); 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 7c8b3e07e..c1cec3b88 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.h +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.h @@ -6,18 +6,18 @@ 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 NIW_FEATHER_COUNT 20 @@ -61,7 +61,7 @@ typedef struct EnNiw { /* 0x296 */ s16 unkToggle296; /* 0x298 */ s16 unk298; /* 0x29C */ s16 isRunningRight; // toggle (direction cucco is turning while running) - /* 0x29C */ u16 nextAnimation; + /* 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; @@ -100,13 +100,12 @@ typedef struct EnNiw { // the attacking cuccos are not here, they are a different actor: [ ovl_En_Attack_Niw ] typedef enum { - /* 0 */ NIW_ANIMATION_STILL, - /* 1 */ NIW_ANIMATION_HEAD_PECKING, // forward and backward, feeding - /* 2 */ NIW_ANIMATION_PECKING_AND_WAVING, // wings move along their axis, like human hand waving - /* 3 */ NIW_ANIMATION_PECKING_AND_FORFLAPPING, // (unused) low (yaw based) flapping, forward and back - /* 4 */ NIW_ANIMATION_FREEZE, // used during Cucco Storm - /* 5 */ NIW_ANIMATION_PECKING_SLOW_FORFLAPPING, // wing speed half that of 3 - + /* 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; diff --git a/src/overlays/actors/ovl_En_Nnh/overlay.cfg b/src/overlays/actors/ovl_En_Nnh/overlay.cfg deleted file mode 100644 index 01d2bec04..000000000 --- a/src/overlays/actors/ovl_En_Nnh/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Nnh -z_en_nnh.c 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..0187e1c88 100644 --- a/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c +++ b/src/overlays/actors/ovl_En_Nnh/z_en_nnh.c @@ -11,17 +11,17 @@ #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 = { +ActorInit En_Nnh_InitVars = { ACTOR_EN_NNH, ACTORCAT_PROP, FLAGS, @@ -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..bcbf9caeb 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; @@ -13,6 +13,4 @@ typedef struct EnNnh { /* 0x190 */ EnNnhActionFunc actionFunc; } EnNnh; // size = 0x194 -extern const ActorInit En_Nnh_InitVars; - #endif // Z_EN_NNH_H diff --git a/src/overlays/actors/ovl_En_Nutsball/overlay.cfg b/src/overlays/actors/ovl_En_Nutsball/overlay.cfg deleted file mode 100644 index cc188400c..000000000 --- a/src/overlays/actors/ovl_En_Nutsball/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Nutsball -z_en_nutsball.c 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 87100d17f..ad872cd21 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -12,14 +12,14 @@ #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* play2); +void EnNutsball_Draw(Actor* thisx, PlayState* play); void EnNutsball_InitColliderParams(EnNutsball* this); -const ActorInit En_Nutsball_InitVars = { +ActorInit En_Nutsball_InitVars = { ACTOR_EN_NUTSBALL, ACTORCAT_PROP, FLAGS, @@ -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; @@ -97,13 +97,14 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { s32 bgId; CollisionPoly* poly; - if (!(player->stateFlags1 & 0x300000C0)) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_40 | PLAYER_STATE1_80 | PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000))) { this->timer--; if (this->timer < 0) { this->actor.velocity.y += this->actor.gravity; spdXZ = sqrtf((this->actor.velocity.x * this->actor.velocity.x) + (this->actor.velocity.z * this->actor.velocity.z)); - this->actor.world.rot.x = Math_FAtan2F(spdXZ, this->actor.velocity.y); + this->actor.world.rot.x = Math_Atan2S_XY(spdXZ, this->actor.velocity.y); } this->actor.home.rot.z += 0x2AA8; if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->actor.bgCheckFlags & 16) || @@ -119,30 +120,30 @@ void EnNutsball_Update(Actor* thisx, GlobalContext* globalCtx2) { 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); + Actor_Kill(&this->actor); } } else { if (this->timer == -300) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } Actor_MoveWithoutGravity(&this->actor); Math_Vec3f_Copy(&worldPos, &this->actor.world.pos); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 5.0f, 10.0f, 0x7); + 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 +158,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_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + 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(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); } diff --git a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.h b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.h index a8ae31da2..04e807727 100644 --- a/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.h +++ b/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.h @@ -12,6 +12,4 @@ typedef struct EnNutsball { /* 0x148 */ ColliderCylinder collider; } EnNutsball; // size = 0x194 -extern const ActorInit En_Nutsball_InitVars; - #endif // Z_EN_NUTSBALL_H diff --git a/src/overlays/actors/ovl_En_Nwc/overlay.cfg b/src/overlays/actors/ovl_En_Nwc/overlay.cfg deleted file mode 100644 index d479e7da4..000000000 --- a/src/overlays/actors/ovl_En_Nwc/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Nwc -z_en_nwc.c 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 8d254b728..74ac78b5f 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.c @@ -15,22 +15,22 @@ #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 EnNwc_LoadNiwSkeleton(EnNwc* this, GlobalContext* globalCtx); -void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx); -void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx); -void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx); -void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx); -void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx); -void EnNwc_CheckForBreman(EnNwc* this, GlobalContext* globalCtx); +void EnNwc_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, GlobalContext* globalCtx); -s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); -EnHs* EnNwc_FindGrog(GlobalContext* globalCtx); +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 @@ -41,7 +41,7 @@ enum EnNiwState { /* 4 */ NWC_STATE_RUNNING, // running from the player after failed breman march }; -const ActorInit En_Nwc_InitVars = { +ActorInit En_Nwc_InitVars = { ACTOR_EN_NWC, ACTORCAT_PROP, FLAGS, @@ -57,28 +57,27 @@ Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; Color_RGBA8 sEnvColor = { 80, 80, 80, 255 }; -void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnNwc_Init(Actor* thisx, PlayState* play) { s32 niwObjectIndex; EnNwc* this = THIS; - niwObjectIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_NIW); + 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); + Actor_Kill(&this->actor); return; } - if (gSaveContext.save.weekEventReg[25] & 8) { - // if breman mask was already used, replace with adult EnNiw - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_NIW, this->actor.world.pos.x, this->actor.world.pos.y, + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_08)) { + 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); + Actor_Kill(&this->actor); return; } this->niwObjectIndex = niwObjectIndex; this->nwcObjectIndex = this->actor.objBankIndex; - this->grog = EnNwc_FindGrog(globalCtx); + this->grog = EnNwc_FindGrog(play); this->footRotY = this->footRotZ = 0; Actor_SetScale(&this->actor, 0.01f); @@ -90,18 +89,18 @@ void EnNwc_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; } -void EnNwc_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnNwc_Destroy(Actor* thisx, PlayState* play) { EnNwc* this = THIS; } -void EnNwc_SpawnDust(EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_SpawnDust(EnNwc* 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); @@ -121,12 +120,12 @@ void EnNwc_SpawnDust(EnNwc* this, GlobalContext* globalCtx) { 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); } } -EnHs* EnNwc_FindGrog(GlobalContext* globalCtx) { - Actor* grogSearch = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; +EnHs* EnNwc_FindGrog(PlayState* play) { + Actor* grogSearch = play->actorCtx.actorLists[ACTORCAT_NPC].first; while (grogSearch != NULL) { if (grogSearch->id == ACTOR_EN_HS) { @@ -138,8 +137,8 @@ EnHs* EnNwc_FindGrog(GlobalContext* globalCtx) { return NULL; } -s32 EnNwc_PlayerReleasedBremanMarch(EnNwc* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnNwc_PlayerReleasedBremanMarch(EnNwc* this, PlayState* play) { + Player* player = GET_PLAYER(play); // 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. @@ -147,7 +146,7 @@ s32 EnNwc_PlayerReleasedBremanMarch(EnNwc* this, GlobalContext* globalCtx) { return false; } - if (player->stateFlags3 & 0x20000000) { // breman mask march + if (player->stateFlags3 & PLAYER_STATE3_20000000) { return false; } @@ -158,15 +157,14 @@ s32 EnNwc_PlayerReleasedBremanMarch(EnNwc* this, GlobalContext* globalCtx) { * Summary: Checks 1) if grog exists, 2) player is using breman mask, 3) and within range. * Used to identify if the chick should be captured by breman mask. */ -s32 EnNwc_IsFound(EnNwc* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnNwc_IsFound(EnNwc* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->grog == NULL) { return false; } - if (player->stateFlags3 & 0x20000000 && // breman mask march - this->actor.xzDistToPlayer < 100.0f) { + if ((player->stateFlags3 & PLAYER_STATE3_20000000) && this->actor.xzDistToPlayer < 100.0f) { return true; } @@ -219,8 +217,8 @@ void EnNwc_ToggleState(EnNwc* this) { } } -void EnNwc_CheckFound(EnNwc* this, GlobalContext* globalCtx) { - if (EnNwc_IsFound(this, globalCtx)) { +void EnNwc_CheckFound(EnNwc* this, PlayState* play) { + if (EnNwc_IsFound(this, play)) { u8 currentChickCount = (this->grog->actor.home.rot.z / 2); if (currentChickCount > 9) { @@ -236,25 +234,26 @@ void EnNwc_CheckFound(EnNwc* this, GlobalContext* globalCtx) { } EnNwc_ChangeState(this, NWC_STATE_FOLLOWING); - func_801A0868(&D_801DB4A4, NA_SE_SY_CHICK_JOIN_CHIME, currentChickCount); + func_801A0868(&gSfxDefaultPos, NA_SE_SY_CHICK_JOIN_CHIME, currentChickCount); } } -void EnNwc_LoadNiwSkeleton(EnNwc* this, GlobalContext* globalCtx) { - if (Object_IsLoaded(&globalCtx->objectCtx, this->niwObjectIndex)) { - gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[this->niwObjectIndex].segment); +void EnNwc_LoadNiwSkeleton(EnNwc* this, PlayState* play) { + if (Object_IsLoaded(&play->objectCtx, this->niwObjectIndex)) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->niwObjectIndex].segment); - SkelAnime_InitFlex(globalCtx, &this->niwSkeleton, &gNiwSkeleton, &gNiwIdleAnim, this->jointTable, - this->morphTable, NIW_LIMB_MAX); - Animation_Change(&this->niwSkeleton, &gNiwIdleAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gNiwIdleAnim), 0, 0.0f); + 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(globalCtx->objectCtx.status[this->nwcObjectIndex].segment); + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->nwcObjectIndex].segment); this->state = NWC_STATE_NIW_LOADED; EnNwc_ToggleState(this); } } -void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx) { +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); @@ -266,7 +265,7 @@ void EnNwc_CrowAtTheEnd(EnNwc* this, GlobalContext* globalCtx) { * * ActionFunc for NWC Type: NWC_STATE_FOLLOWING */ -void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_Follow(EnNwc* this, PlayState* play) { Vec3f* chickCoords = this->grog->nwcPos; Vec3f targetVector; s32 pad; @@ -305,7 +304,7 @@ void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx) { // it is our turn to transform this->hasGrownUp |= 1; this->grog->actor.home.rot.x += 2; // increment grog's adult tranformation counter - EnNwc_SpawnDust(this, globalCtx); + EnNwc_SpawnDust(this, play); Actor_SetScale(&this->actor, 0.002f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_CHICK_TO_CHICKEN); } @@ -337,14 +336,14 @@ void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx) { this->actor.world.rot.y = newRotY; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0xBB8, 0xC8); - if (EnNwc_PlayerReleasedBremanMarch(this, globalCtx)) { + 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, globalCtx); + EnNwc_SpawnDust(this, play); } this->hasGrownUp &= ~1; @@ -369,7 +368,7 @@ void EnNwc_Follow(EnNwc* this, GlobalContext* globalCtx) { * * ActionFunc for NWC Type: NWC_STATE_HOPPING_FORWARD */ -void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_HopForward(EnNwc* this, PlayState* play) { if (DECR(this->stateTimer) == 0) { EnNwc_ToggleState(this); return; @@ -395,7 +394,7 @@ void EnNwc_HopForward(EnNwc* this, GlobalContext* globalCtx) { * * ActionFunc for NWC Type: NWC_STATE_RUNNING */ -void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_RunAway(EnNwc* this, PlayState* play) { if (DECR(this->stateTimer) == 0) { EnNwc_ToggleState(this); return; @@ -419,7 +418,7 @@ void EnNwc_RunAway(EnNwc* this, GlobalContext* globalCtx) { * * ActionFunc for NWC Type: NWC_STATE_TURNING */ -void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_Turn(EnNwc* this, PlayState* play) { if (DECR(this->stateTimer) == 0) { EnNwc_ToggleState(this); return; @@ -446,20 +445,20 @@ void EnNwc_Turn(EnNwc* this, GlobalContext* globalCtx) { * * ActionFunc for NWC Type: NWC_STATE_CHECK_BREMAN */ -void EnNwc_CheckForBreman(EnNwc* this, GlobalContext* globalCtx) { +void EnNwc_CheckForBreman(EnNwc* this, PlayState* play) { if (DECR(this->stateTimer) == 0) { EnNwc_ToggleState(this); } - EnNwc_CheckFound(this, globalCtx); + EnNwc_CheckFound(this, play); } -void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnNwc_Update(Actor* thisx, PlayState* play) { EnNwc* this = THIS; Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 10.0f, 5); - this->actionFunc(this, globalCtx); + 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; @@ -481,29 +480,29 @@ void EnNwc_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnNwc_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnNwc_Draw(Actor* thisx, PlayState* play) { TexturePtr eyeTextures[] = { gNwcEyeOpenTex, gNwcEyeClosedTex }; EnNwc* this = THIS; Gfx* dispHead; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->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(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { +s32 EnNwc_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnNwc* this = THIS; if (limbIndex == NIW_LIMB_UPPER_BODY) { @@ -517,10 +516,10 @@ s32 EnNwc_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, return false; } -void EnNwc_DrawAdultBody(Actor* thisx, GlobalContext* globalCtx) { +void EnNwc_DrawAdultBody(Actor* thisx, PlayState* play) { EnNwc* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->niwSkeleton.skeleton, this->niwSkeleton.jointTable, - this->niwSkeleton.dListCount, EnNwc_OverrideLimbDraw, NULL, &this->actor); + 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 3815852af..51c017dff 100644 --- a/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h +++ b/src/overlays/actors/ovl_En_Nwc/z_en_nwc.h @@ -8,7 +8,7 @@ struct EnNwc; -typedef void (*EnNwcActionFunc)(struct EnNwc*, GlobalContext*); +typedef void (*EnNwcActionFunc)(struct EnNwc*, PlayState*); typedef struct EnNwc { /* 0x000 */ Actor actor; @@ -35,6 +35,4 @@ typedef struct EnNwc { /* 0x264 */ EnNwcActionFunc actionFunc; } EnNwc; // size = 0x268 -extern const ActorInit En_Nwc_InitVars; - #endif // Z_EN_NWC_H diff --git a/src/overlays/actors/ovl_En_Okarina_Effect/overlay.cfg b/src/overlays/actors/ovl_En_Okarina_Effect/overlay.cfg deleted file mode 100644 index 02325ddea..000000000 --- a/src/overlays/actors/ovl_En_Okarina_Effect/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Okarina_Effect -z_en_okarina_effect.c 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..df778f1a7 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,20 +5,21 @@ */ #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 = { +ActorInit En_Okarina_Effect_InitVars = { ACTOR_EN_OKARINA_EFFECT, ACTORCAT_ITEMACTION, FLAGS, @@ -34,50 +35,50 @@ 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]) { - Actor_MarkForDeath(&this->actor); + if (play->envCtx.unk_F2[1]) { + Actor_Kill(&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 == PAUSE_STATE_OFF) && (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 { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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..b633ab390 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; @@ -14,6 +14,4 @@ typedef struct EnOkarinaEffect { /* 0x148 */ EnOkarinaEffectActionFunc actionFunc; } EnOkarinaEffect; // size = 0x14C -extern const ActorInit En_Okarina_Effect_InitVars; - #endif // Z_EN_OKARINA_EFFECT_H diff --git a/src/overlays/actors/ovl_En_Okarina_Tag/overlay.cfg b/src/overlays/actors/ovl_En_Okarina_Tag/overlay.cfg deleted file mode 100644 index 908da1888..000000000 --- a/src/overlays/actors/ovl_En_Okarina_Tag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Okarina_Tag -z_en_okarina_tag.c 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..d4d3db017 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,15 +10,14 @@ #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 = { +ActorInit En_Okarina_Tag_InitVars = { ACTOR_EN_OKARINA_TAG, ACTORCAT_SWITCH, FLAGS, @@ -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..0dd15c1c9 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,14 +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; - #endif // Z_EN_OKARINA_TAG_H diff --git a/src/overlays/actors/ovl_En_Okuta/overlay.cfg b/src/overlays/actors/ovl_En_Okuta/overlay.cfg deleted file mode 100644 index 8863e7169..000000000 --- a/src/overlays/actors/ovl_En_Okuta/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Okuta -z_en_okuta.c 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..8241c7e5c 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -10,25 +10,25 @@ #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 = { +ActorInit En_Okuta_InitVars = { ACTOR_EN_OKUTA, ACTORCAT_ENEMY, FLAGS, @@ -95,7 +95,7 @@ static DamageTable D_80870900 = { // static InitChainEntry sInitChain[] = { static InitChainEntry D_80870920[] = { - ICHAIN_S8(hintId, 66, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_OCTOROK, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; 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..93a68ae38 100644 --- a/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h +++ b/src/overlays/actors/ovl_En_Okuta/z_en_okuta.h @@ -5,15 +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; - #endif // Z_EN_OKUTA_H diff --git a/src/overlays/actors/ovl_En_Onpuman/overlay.cfg b/src/overlays/actors/ovl_En_Onpuman/overlay.cfg deleted file mode 100644 index 50f24d4ac..000000000 --- a/src/overlays/actors/ovl_En_Onpuman/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Onpuman -z_en_onpuman.c 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..df18de3e7 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.c @@ -10,12 +10,13 @@ #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); -#if 0 -const ActorInit En_Onpuman_InitVars = { +void func_80B121D8(EnOnpuman* this, PlayState* play); + +ActorInit En_Onpuman_InitVars = { ACTOR_EN_ONPUMAN, ACTORCAT_NPC, FLAGS, @@ -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..581ea35dd 100644 --- a/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h +++ b/src/overlays/actors/ovl_En_Onpuman/z_en_onpuman.h @@ -5,14 +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; - #endif // Z_EN_ONPUMAN_H diff --git a/src/overlays/actors/ovl_En_Osk/overlay.cfg b/src/overlays/actors/ovl_En_Osk/overlay.cfg deleted file mode 100644 index 3d963dc09..000000000 --- a/src/overlays/actors/ovl_En_Osk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Osk -z_en_osk.c 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 20c0dd19d..ac3c5ef6b 100644 --- a/src/overlays/actors/ovl_En_Osk/z_en_osk.c +++ b/src/overlays/actors/ovl_En_Osk/z_en_osk.c @@ -12,17 +12,17 @@ #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 = { +ActorInit En_Osk_InitVars = { ACTOR_EN_OSK, ACTORCAT_NPC, FLAGS, @@ -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,13 +489,13 @@ 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) { @@ -509,28 +503,28 @@ void func_80BF6C54(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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); @@ -542,7 +536,7 @@ void EnOsk_Draw(Actor* thisx, GlobalContext* globalCtx) { 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..0358911d3 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,17 +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; - #endif // Z_EN_OSK_H diff --git a/src/overlays/actors/ovl_En_Osn/overlay.cfg b/src/overlays/actors/ovl_En_Osn/overlay.cfg deleted file mode 100644 index 59f9f2343..000000000 --- a/src/overlays/actors/ovl_En_Osn/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Osn -z_en_osn.c 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 90cd6785f..7df9d843d 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -11,12 +11,74 @@ #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 = { +void EnOsn_Idle(EnOsn* this, PlayState* play); +void EnOsn_StartCutscene(EnOsn* this, PlayState* play); +void EnOsn_HandleCsAction(EnOsn* this, PlayState* play); +void EnOsn_Talk(EnOsn* this, PlayState* play); + +#define OSN_STATE_SPECIAL_CONVERSTATION (1 << 0) +#define OSN_STATE_MET_HUMAN (1 << 1) +#define OSN_STATE_MET_DEKU (1 << 2) +#define OSN_STATE_MET_GORON (1 << 3) +#define OSN_STATE_MET_ZORA (1 << 4) +#define OSN_STATE_END_CONVERSATION (1 << 5) + +#define OSN_MASK_TEXT_GREAT_FAIRY (1 << 0) +#define OSN_MASK_TEXT_GIBDO (1 << 1) +#define OSN_MASK_TEXT_TRUTH (1 << 2) +#define OSN_MASK_TEXT_GIANT (1 << 3) +#define OSN_MASK_TEXT_KAFEIS (1 << 4) +#define OSN_MASK_TEXT_DON_GERO (1 << 5) +#define OSN_MASK_TEXT_BLAST (1 << 6) +#define OSN_MASK_TEXT_COUPLE (1 << 7) +#define OSN_MASK_TEXT_SCENTS (1 << 8) +#define OSN_MASK_TEXT_KAMARO (1 << 9) +#define OSN_MASK_TEXT_STONE (1 << 10) +#define OSN_MASK_TEXT_POSTMAN (1 << 11) +#define OSN_MASK_TEXT_BUNNY (1 << 12) +#define OSN_MASK_TEXT_CAPTAIN (1 << 13) +#define OSN_MASK_TEXT_BREMEN (1 << 14) +#define OSN_MASK_TEXT_CIRCUS_LEADER (1 << 15) +#define OSN_MASK_TEXT_KEATON (1 << 16) +#define OSN_MASK_TEXT_GARO (1 << 17) +#define OSN_MASK_TEXT_ALL_NIGHT (1 << 18) +#define OSN_MASK_TEXT_ROMANI (1 << 19) + +typedef enum { + /* 0 */ OSN_ANIM_IDLE, + /* 1 */ OSN_ANIM_ARMS_OUT, + /* 2 */ OSN_ANIM_BOWING, + /* 3 */ OSN_ANIM_REMINISCE, + /* 4 */ OSN_ANIM_HANDS_CLASPED, + /* 5 */ OSN_ANIM_BELIEVE, + /* 6 */ OSN_ANIM_THINK, + /* 7 */ OSN_ANIM_SHAKE_HEAD, + /* 8 */ OSN_ANIM_ORGAN_TALK, + /* 9 */ OSN_ANIM_ORGAN_PLAY, + /* 10 */ OSN_ANIM_SHAKE, + /* 11 */ OSN_ANIM_CHOKE, + /* 12 */ OSN_ANIM_DESPAIR, + /* 13 */ OSN_ANIM_FAST_BOWS, + /* 14 */ OSN_ANIM_HAND_OUT, + /* 15 */ OSN_ANIM_LYING_DOWN_FACE_UP, + /* 16 */ OSN_ANIM_LYING_DOWN_FACE_DOWN, + /* 17 */ OSN_ANIM_MASK_LOOK_AT, + /* 18 */ OSN_ANIM_TURN_AROUND_START, + /* 19 */ OSN_ANIM_TURN_AROUND_LOOP, + /* 20 */ OSN_ANIM_WALK_AWAY, + /* 21 */ OSN_ANIM_MASK_LOOK_FROM_START, + /* 22 */ OSN_ANIM_MASK_LOOK_FROM_LOOP, + /* 23 */ OSN_ANIM_HAND_OUT_2, // Exact same as OSN_ANIM_HAND_OUT + /* 24 */ OSN_ANIM_WALK_AWAY_END, // Only the last frame of OSN_ANIM_WALK_AWAY + /* 25 */ OSN_ANIM_MAX +} OsnAnimation; + +ActorInit En_Osn_InitVars = { ACTOR_EN_OSN, ACTORCAT_NPC, FLAGS, @@ -28,20 +90,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[] = { + { &gHappyMaskSalesmanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanArmsOutAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanBowingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanReminisceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanHandsClaspedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanBelieveAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanThinkAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanShakeHeadAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanOrganTalkAnim, 1.0f, 1.0f, 39.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanOrganPlayAnim, 1.0f, 1.0f, 70.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanShakeAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanChokeAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanDespairAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanFastBowsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanHandOutAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanLyingDownAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanLyingDownAnim, 0.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanMaskLookAtAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanTurnAroundStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanTurnAroundLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanWalkAwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanMaskLookFromStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanMaskLookFromLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanHandOutAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanWalkAwayAnim, 0.0f, 77.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -105,238 +179,273 @@ 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_80AD0830(EnOsn* this, GlobalContext* globalCtx) { +void EnOsn_UpdateCollider(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 EnOsn_GetMaskText(PlayState* play) { + switch (Player_GetMask(play)) { case PLAYER_MASK_GREAT_FAIRY: return 0x1FD6; + case PLAYER_MASK_GIBDO: return 0x1FD8; + case PLAYER_MASK_TRUTH: return 0x1FDA; + case PLAYER_MASK_GIANT: return 0x1FDC; + case PLAYER_MASK_KAFEIS_MASK: return 0x1FDE; + case PLAYER_MASK_DON_GERO: return 0x1FE0; + case PLAYER_MASK_BLAST: return 0x1FE2; + case PLAYER_MASK_COUPLE: return 0x1FE4; + case PLAYER_MASK_SCENTS: return 0x1FE6; + case PLAYER_MASK_KAMARO: return 0x1FE8; + case PLAYER_MASK_STONE: return 0x1FEA; + case PLAYER_MASK_POSTMAN: return 0x1FEC; + case PLAYER_MASK_BUNNY: return 0x1FEE; + case PLAYER_MASK_CAPTAIN: return 0x1FF0; + case PLAYER_MASK_BREMEN: return 0x1FF2; + case PLAYER_MASK_CIRCUS_LEADER: return 0x1FF4; + case PLAYER_MASK_KEATON: return 0x1FF6; + case PLAYER_MASK_GARO: return 0x1FF8; + case PLAYER_MASK_ALL_NIGHT: return 0x1FFA; + case PLAYER_MASK_ROMANI: return 0x1FFC; + default: return 0; } } -void func_80AD0998(EnOsn* this) { +void EnOsn_TurnAround(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (this->unk_1EC == 0x12 && curFrame == lastFrame) { - this->unk_1EC = 0x13; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x13); + if ((this->animIndex == OSN_ANIM_TURN_AROUND_START) && (curFrame == lastFrame)) { + this->animIndex = OSN_ANIM_TURN_AROUND_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, OSN_ANIM_TURN_AROUND_LOOP); } } -void func_80AD0A24(EnOsn* this) { +void EnOsn_LookFromMask(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (this->unk_1EC == 0x15 && curFrame == lastFrame) { - this->unk_1EC = 0x16; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x16); + if ((this->animIndex == OSN_ANIM_MASK_LOOK_FROM_START) && (curFrame == lastFrame)) { + this->animIndex = OSN_ANIM_MASK_LOOK_FROM_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, OSN_ANIM_MASK_LOOK_FROM_LOOP); } } -void func_80AD0AB0(EnOsn* this) { +void EnOsn_FadeOut(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimations[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (curFrame == lastFrame) { - this->unk_1FA -= 8; - if (this->unk_1FA < 8) { - this->unk_1FA = 0; - Actor_MarkForDeath(&this->actor); + this->alpha -= 8; + if (this->alpha < 8) { + this->alpha = 0; + Actor_Kill(&this->actor); } } } -s32 func_80AD0B38(EnOsn* this, GlobalContext* globalCtx) { - switch (Player_GetMask(globalCtx)) { +s32 EnOsn_GetInitialMaskText(EnOsn* this, PlayState* play) { + switch (Player_GetMask(play)) { case PLAYER_MASK_GREAT_FAIRY: - if (!(this->unk_1F6 & 1)) { - this->unk_1F6 |= 1; + if (!(this->maskTextFlags & OSN_MASK_TEXT_GREAT_FAIRY)) { + this->maskTextFlags |= OSN_MASK_TEXT_GREAT_FAIRY; return 0x1FD1; } break; + case PLAYER_MASK_GIBDO: - if (!(this->unk_1F6 & 2)) { - this->unk_1F6 |= 2; + if (!(this->maskTextFlags & OSN_MASK_TEXT_GIBDO)) { + this->maskTextFlags |= OSN_MASK_TEXT_GIBDO; return 0x1FD1; } break; + case PLAYER_MASK_TRUTH: - if (!(this->unk_1F6 & 4)) { - this->unk_1F6 |= 4; + if (!(this->maskTextFlags & OSN_MASK_TEXT_TRUTH)) { + this->maskTextFlags |= OSN_MASK_TEXT_TRUTH; return 0x1FD1; } break; + case PLAYER_MASK_GIANT: - if (!(this->unk_1F6 & 8)) { - this->unk_1F6 |= 8; + if (!(this->maskTextFlags & OSN_MASK_TEXT_GIANT)) { + this->maskTextFlags |= OSN_MASK_TEXT_GIANT; return 0x1FD1; } break; + case PLAYER_MASK_KAFEIS_MASK: - if (!(this->unk_1F6 & 0x10)) { - this->unk_1F6 |= 0x10; + if (!(this->maskTextFlags & OSN_MASK_TEXT_KAFEIS)) { + this->maskTextFlags |= OSN_MASK_TEXT_KAFEIS; return 0x1FD1; } break; + case PLAYER_MASK_DON_GERO: - if (!(this->unk_1F6 & 0x20)) { - this->unk_1F6 |= 0x20; + if (!(this->maskTextFlags & OSN_MASK_TEXT_DON_GERO)) { + this->maskTextFlags |= OSN_MASK_TEXT_DON_GERO; return 0x1FD1; } break; + case PLAYER_MASK_BLAST: - if (!(this->unk_1F6 & 0x40)) { - this->unk_1F6 |= 0x40; + if (!(this->maskTextFlags & OSN_MASK_TEXT_BLAST)) { + this->maskTextFlags |= OSN_MASK_TEXT_BLAST; return 0x1FD1; } break; + case PLAYER_MASK_COUPLE: - if (!(this->unk_1F6 & 0x80)) { - this->unk_1F6 |= 0x80; + if (!(this->maskTextFlags & OSN_MASK_TEXT_COUPLE)) { + this->maskTextFlags |= OSN_MASK_TEXT_COUPLE; return 0x1FD1; } break; + case PLAYER_MASK_SCENTS: - if (!(this->unk_1F6 & 0x100)) { - this->unk_1F6 |= 0x100; + if (!(this->maskTextFlags & OSN_MASK_TEXT_SCENTS)) { + this->maskTextFlags |= OSN_MASK_TEXT_SCENTS; return 0x1FD1; } break; + case PLAYER_MASK_KAMARO: - if (!(this->unk_1F6 & 0x200)) { - this->unk_1F6 |= 0x200; + if (!(this->maskTextFlags & OSN_MASK_TEXT_KAMARO)) { + this->maskTextFlags |= OSN_MASK_TEXT_KAMARO; return 0x1FD1; } break; + case PLAYER_MASK_STONE: - if (!(this->unk_1F6 & 0x400)) { - this->unk_1F6 |= 0x400; + if (!(this->maskTextFlags & OSN_MASK_TEXT_STONE)) { + this->maskTextFlags |= OSN_MASK_TEXT_STONE; return 0x1FD1; } break; + case PLAYER_MASK_POSTMAN: - if (!(this->unk_1F6 & 0x800)) { - this->unk_1F6 |= 0x800; + if (!(this->maskTextFlags & OSN_MASK_TEXT_POSTMAN)) { + this->maskTextFlags |= OSN_MASK_TEXT_POSTMAN; return 0x1FD2; } break; + case PLAYER_MASK_BUNNY: - if (!(this->unk_1F6 & 0x1000)) { - this->unk_1F6 |= 0x1000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_BUNNY)) { + this->maskTextFlags |= OSN_MASK_TEXT_BUNNY; return 0x1FD2; } break; + case PLAYER_MASK_CAPTAIN: - if (!(this->unk_1F6 & 0x2000)) { - this->unk_1F6 |= 0x2000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_CAPTAIN)) { + this->maskTextFlags |= OSN_MASK_TEXT_CAPTAIN; return 0x1FD1; } break; + case PLAYER_MASK_BREMEN: - if (!(this->unk_1F6 & 0x4000)) { - this->unk_1F6 |= 0x4000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_BREMEN)) { + this->maskTextFlags |= OSN_MASK_TEXT_BREMEN; return 0x1FD1; } break; + case PLAYER_MASK_CIRCUS_LEADER: - if (!(this->unk_1F6 & 0x8000)) { - this->unk_1F6 |= 0x8000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_CIRCUS_LEADER)) { + this->maskTextFlags |= OSN_MASK_TEXT_CIRCUS_LEADER; return 0x1FD1; } break; + case PLAYER_MASK_KEATON: - if (!(this->unk_1F6 & 0x10000)) { - this->unk_1F6 |= 0x10000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_KEATON)) { + this->maskTextFlags |= OSN_MASK_TEXT_KEATON; return 0x1FD1; } break; + case PLAYER_MASK_GARO: - if (!(this->unk_1F6 & 0x20000)) { - this->unk_1F6 |= 0x20000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_GARO)) { + this->maskTextFlags |= OSN_MASK_TEXT_GARO; return 0x1FD1; } break; + case PLAYER_MASK_ALL_NIGHT: - if (!(this->unk_1F6 & 0x40000)) { - this->unk_1F6 |= 0x40000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_ALL_NIGHT)) { + this->maskTextFlags |= OSN_MASK_TEXT_ALL_NIGHT; return 0x1FD1; } break; + case PLAYER_MASK_ROMANI: - if (!(this->unk_1F6 & 0x80000)) { - this->unk_1F6 |= 0x80000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_ROMANI)) { + this->maskTextFlags |= OSN_MASK_TEXT_ROMANI; return 0x1FD1; } break; + default: break; } - this->unk_1EA |= 0x20; - if (gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0) && - gSaveContext.save.time < CLOCK_TIME(6, 0)) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } -s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 EnOsn_GetInitialText(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) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_SPECIAL_CONVERSTATION) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && @@ -349,70 +458,72 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { } if (player->transformation == PLAYER_FORM_DEKU) { - if (this->unk_1EA & 4) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_MET_DEKU) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } - this->unk_1EA |= 4; + this->stateFlags |= OSN_STATE_MET_DEKU; return 0x1FC8; } if (player->transformation == PLAYER_FORM_GORON) { - if (this->unk_1EA & 8) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_MET_GORON) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; + } else { + return 0x1FCD; } - return 0x1FCD; } - this->unk_1EA |= 8; - if (gSaveContext.save.weekEventReg[76] & 0x20) { + this->stateFlags |= OSN_STATE_MET_GORON; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_76_20)) { return 0x1FC8; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_76_20); + return 0x1FCE; } - - gSaveContext.save.weekEventReg[76] |= 0x20; - return 0x1FCE; } if (player->transformation == PLAYER_FORM_ZORA) { - if (this->unk_1EA & 0x10) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_MET_ZORA) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } - this->unk_1EA |= 0x10; - if (gSaveContext.save.weekEventReg[76] & 0x40) { + + this->stateFlags |= OSN_STATE_MET_ZORA; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_76_40)) { return 0x1FC8; } - gSaveContext.save.weekEventReg[76] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_76_40); return 0x1FD0; } - if (Player_GetMask(globalCtx) == PLAYER_MASK_NONE) { - if (this->unk_1EA & 2) { - this->unk_1EA |= 0x20; + if (Player_GetMask(play) == PLAYER_MASK_NONE) { + if (this->stateFlags & OSN_STATE_MET_HUMAN) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } - this->unk_1EA |= 2; + this->stateFlags |= OSN_STATE_MET_HUMAN; return 0x1FC8; } - return func_80AD0B38(this, globalCtx); + return EnOsn_GetInitialMaskText(this, play); } - this->unk_1EA |= 0x20; + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2004; @@ -421,123 +532,123 @@ s32 func_80AD0E10(EnOsn* this, GlobalContext* globalCtx) { return 0x1FAE; } -void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { - switch (this->unk_1F4) { +void EnOsn_HandleConversation(EnOsn* this, PlayState* play) { + switch (this->textId) { case 0x1FC8: - this->unk_1F4 = 0x1FC9; + this->textId = 0x1FC9; break; case 0x1FC9: - this->unk_1F4 = 0x1FCA; + this->textId = 0x1FCA; break; case 0x1FCA: - if ((gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0)) && - gSaveContext.save.time < CLOCK_TIME(6, 0)) { - this->unk_1F4 = 0x2007; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + this->textId = 0x2007; } else { - this->unk_1F4 = 0x1FCB; + this->textId = 0x1FCB; } break; case 0x1FCB: case 0x2007: - this->unk_1F4 = 0x1FCC; - this->unk_1EA |= 0x20; + this->textId = 0x1FCC; + this->stateFlags |= OSN_STATE_END_CONVERSATION; break; case 0x1FCE: case 0x1FD0: - this->unk_1F4 = 0x1FCF; + this->textId = 0x1FCF; break; case 0x1FCF: - this->unk_1F4 = 0x1FCA; + this->textId = 0x1FCA; break; case 0x1FD1: case 0x1FD2: - this->unk_1F4 = func_80AD08B0(globalCtx); + this->textId = EnOsn_GetMaskText(play); break; case 0x1FD6: - this->unk_1F4 = 0x1FD7; + this->textId = 0x1FD7; break; case 0x1FD8: - this->unk_1F4 = 0x1FD9; + this->textId = 0x1FD9; break; case 0x1FDA: - this->unk_1F4 = 0x1FDB; + this->textId = 0x1FDB; break; case 0x1FDC: - this->unk_1F4 = 0x1FDD; + this->textId = 0x1FDD; break; case 0x1FDE: - this->unk_1F4 = 0x1FDF; + this->textId = 0x1FDF; break; case 0x1FE0: - this->unk_1F4 = 0x1FE1; + this->textId = 0x1FE1; break; case 0x1FE2: - this->unk_1F4 = 0x1FE3; + this->textId = 0x1FE3; break; case 0x1FE4: - this->unk_1F4 = 0x1FE5; + this->textId = 0x1FE5; break; case 0x1FE6: - this->unk_1F4 = 0x1FE7; + this->textId = 0x1FE7; break; case 0x1FE8: - this->unk_1F4 = 0x1FE9; + this->textId = 0x1FE9; break; case 0x1FEA: - this->unk_1F4 = 0x1FEB; + this->textId = 0x1FEB; break; case 0x1FEC: - this->unk_1F4 = 0x1FED; + this->textId = 0x1FED; break; case 0x1FEE: - this->unk_1F4 = 0x1FEF; + this->textId = 0x1FEF; break; case 0x1FF0: - this->unk_1F4 = 0x1FF1; + this->textId = 0x1FF1; break; case 0x1FF2: - this->unk_1F4 = 0x1FF3; + this->textId = 0x1FF3; break; case 0x1FF4: - this->unk_1F4 = 0x1FF5; + this->textId = 0x1FF5; break; case 0x1FF6: - this->unk_1F4 = 0x1FF7; + this->textId = 0x1FF7; break; case 0x1FF8: - this->unk_1F4 = 0x1FF9; + this->textId = 0x1FF9; break; case 0x1FFA: - this->unk_1F4 = 0x1FFB; + this->textId = 0x1FFB; break; case 0x1FFC: - this->unk_1F4 = 0x1FFD; + this->textId = 0x1FFD; break; case 0x1FD7: @@ -551,7 +662,7 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { case 0x1FF7: case 0x1FF9: case 0x1FFB: - this->unk_1F4 = 0x1FD3; + this->textId = 0x1FD3; break; case 0x1FD9: @@ -562,24 +673,24 @@ void func_80AD10FC(EnOsn* this, GlobalContext* globalCtx) { case 0x1FEF: case 0x1FF5: case 0x1FFD: - this->unk_1F4 = 0x1FD4; + this->textId = 0x1FD4; break; case 0x1FE5: - this->unk_1F4 = 0x1FFE; + this->textId = 0x1FFE; break; case 0x1FD3: case 0x1FD4: case 0x1FFE: - this->unk_1F4 = 0x1FD5; - this->unk_1EA |= 0x20; + this->textId = 0x1FD5; + this->stateFlags |= OSN_STATE_END_CONVERSATION; } - Message_StartTextbox(globalCtx, this->unk_1F4, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } -void func_80AD1398(EnOsn* this) { +void EnOsn_InitCutscene(EnOsn* this) { this->cutscene = this->actor.cutscene; if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { @@ -592,336 +703,366 @@ void func_80AD1398(EnOsn* this) { } } -void func_80AD144C(EnOsn* this, GlobalContext* globalCtx) { - u32 sp1C = Flags_GetSwitch(globalCtx, 0); +void EnOsn_ChooseAction(EnOsn* this, PlayState* play) { + u32 isFlagSet = Flags_GetSwitch(play, 0); + this->cutscene = this->actor.cutscene; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); - if (sp1C == 0) { - this->actionFunc = func_80AD16A8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, OSN_ANIM_IDLE); + if (!isFlagSet) { + this->actionFunc = EnOsn_HandleCsAction; } else { - this->actionFunc = func_80AD14C8; + this->actionFunc = EnOsn_Idle; } } -void func_80AD14C8(EnOsn* this, GlobalContext* globalCtx) { - s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +void EnOsn_Idle(EnOsn* this, PlayState* play) { + s16 yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { - if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - this->actionFunc = func_80AD1634; - } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && - (temp_v1 > -0x4000)) { - func_800B863C(&this->actor, globalCtx); + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = EnOsn_StartCutscene; + } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (yaw < 0x4000) && + (yaw > -0x4000)) { + 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); - 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); - } + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->textId = EnOsn_GetInitialText(this, play); + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnOsn_Talk; + } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (yaw < 0x4000) && (yaw > -0x4000)) { + func_800B863C(&this->actor, play); } } -void func_80AD1634(EnOsn* this, GlobalContext* globalCtx) { +void EnOsn_StartCutscene(EnOsn* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->actionFunc = func_80AD16A8; - return; + this->actionFunc = EnOsn_HandleCsAction; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); } - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - } - ActorCutscene_SetIntentToPlay(this->cutscene); } -void func_80AD16A8(EnOsn* this, GlobalContext* globalCtx) { +void EnOsn_HandleCsAction(EnOsn* this, PlayState* play) { u8 pad; s32 actionIndex; - if (Cutscene_CheckActorAction(globalCtx, 130)) { - actionIndex = Cutscene_GetActorActionIndex(globalCtx, 130); - this->unk_1F0 = 0; - if (this->unk_1ED != globalCtx->csCtx.actorActions[actionIndex]->action) { - this->unk_1ED = globalCtx->csCtx.actorActions[actionIndex]->action; - switch (globalCtx->csCtx.actorActions[actionIndex]->action) { + if (Cutscene_CheckActorAction(play, 130)) { + actionIndex = Cutscene_GetActorActionIndex(play, 130); + this->shouldRotateHead = false; + if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = play->csCtx.actorActions[actionIndex]->action; + switch (play->csCtx.actorActions[actionIndex]->action) { case 1: - this->unk_1EC = 2; + this->animIndex = OSN_ANIM_BOWING; break; + case 2: - this->unk_1EC = 1; + this->animIndex = OSN_ANIM_ARMS_OUT; break; + case 3: - this->unk_1EC = 7; + this->animIndex = OSN_ANIM_SHAKE_HEAD; break; + case 4: - this->unk_1EC = 3; + this->animIndex = OSN_ANIM_REMINISCE; break; + case 5: - this->unk_1EC = 6; + this->animIndex = OSN_ANIM_THINK; break; + case 6: - this->unk_1EC = 5; + this->animIndex = OSN_ANIM_BELIEVE; break; + case 7: - this->unk_1EC = 4; + this->animIndex = OSN_ANIM_HANDS_CLASPED; break; + case 8: - this->unk_1EC = 0; + this->animIndex = OSN_ANIM_IDLE; break; + case 10: - this->unk_1EC = 8; + this->animIndex = OSN_ANIM_ORGAN_TALK; break; + case 11: - this->unk_1EC = 9; + this->animIndex = OSN_ANIM_ORGAN_PLAY; break; + case 13: - this->unk_1EC = 0xA; + this->animIndex = OSN_ANIM_SHAKE; break; + case 15: - this->unk_1EC = 0xB; + this->animIndex = OSN_ANIM_CHOKE; break; + case 16: - this->unk_1EC = 0xC; + this->animIndex = OSN_ANIM_DESPAIR; break; + case 17: - this->unk_1EC = 0xD; + this->animIndex = OSN_ANIM_FAST_BOWS; break; + case 18: - this->unk_1EC = 0xE; + this->animIndex = OSN_ANIM_HAND_OUT; break; + case 19: - this->unk_1EC = 0x11; + this->animIndex = OSN_ANIM_MASK_LOOK_AT; break; + case 20: - this->unk_1EC = 0x12; + this->animIndex = OSN_ANIM_TURN_AROUND_START; break; + case 21: - this->unk_1EC = 0x14; + this->animIndex = OSN_ANIM_WALK_AWAY; break; + case 22: - this->unk_1EC = 0x15; + this->animIndex = OSN_ANIM_MASK_LOOK_FROM_START; break; + case 23: - this->unk_1EC = 0x17; + this->animIndex = OSN_ANIM_HAND_OUT_2; break; + case 24: - this->unk_1EC = 0x18; + this->animIndex = OSN_ANIM_WALK_AWAY_END; break; + default: - this->unk_1EC = 0; + this->animIndex = OSN_ANIM_IDLE; break; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } - if ((this->unk_1EC == 5) && (globalCtx->sceneNum == SCENE_SPOT00) && (gSaveContext.sceneSetupIndex == 0xB) && - (globalCtx->csCtx.frames == 400)) { + if ((this->animIndex == OSN_ANIM_BELIEVE) && (play->sceneId == SCENE_SPOT00) && + (gSaveContext.sceneLayer == 0xB) && (play->csCtx.frames == 400)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); } - if (this->unk_1EC == 0x12) { - func_80AD0998(this); + + if (this->animIndex == OSN_ANIM_TURN_AROUND_START) { + EnOsn_TurnAround(this); } - if (this->unk_1EC == 0x15) { - func_80AD0A24(this); + + if (this->animIndex == OSN_ANIM_MASK_LOOK_FROM_START) { + EnOsn_LookFromMask(this); } - if (this->unk_1EC == 0x18) { - func_80AD0AB0(this); + + if (this->animIndex == OSN_ANIM_WALK_AWAY_END) { + EnOsn_FadeOut(this); } - if ((this->unk_1EC == 0x14) && + + if ((this->animIndex == OSN_ANIM_WALK_AWAY) && (((Animation_OnFrame(&this->skelAnime, 17.0f))) || (Animation_OnFrame(&this->skelAnime, 27.0f)) || (Animation_OnFrame(&this->skelAnime, 37.0f)) || (Animation_OnFrame(&this->skelAnime, 47.0f)) || (Animation_OnFrame(&this->skelAnime, 57.0f)) || (Animation_OnFrame(&this->skelAnime, 67.0f)))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_OMENYA_WALK); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex); + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); } else { - this->unk_1F0 = 1; - this->unk_1ED = 0x63; - func_80AD144C(this, globalCtx); + this->shouldRotateHead = true; + this->csAction = 0x63; + EnOsn_ChooseAction(this, play); } } -void func_80AD19A0(EnOsn* this, GlobalContext* globalCtx) { - u8 temp_v0 = Message_GetState(&globalCtx->msgCtx); +void EnOsn_Talk(EnOsn* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); - if ((temp_v0 == 6 || temp_v0 == 5) && Message_ShouldAdvance(globalCtx)) { - if (this->unk_1EA & 0x20) { - this->unk_1EA &= ~0x20; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - this->actionFunc = func_80AD14C8; + if (((talkState == TEXT_STATE_DONE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { + if (this->stateFlags & OSN_STATE_END_CONVERSATION) { + this->stateFlags &= ~OSN_STATE_END_CONVERSATION; + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + this->actionFunc = EnOsn_Idle; } else { - func_80AD10FC(this, globalCtx); + EnOsn_HandleConversation(this, play); } } } -void EnOsn_Idle(EnOsn* this, GlobalContext* globalCtx) { +void EnOsn_DoNothing(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, &gHappyMaskSalesmanSkel, &gHappyMaskSalesmanIdleAnim, 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)) { - this->unk_1EA |= 1; + this->alpha = 255; + + switch (ENOSN_GET_TYPE(&this->actor)) { + case OSN_TYPE_CHOOSE: + 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->stateFlags |= OSN_STATE_SPECIAL_CONVERSTATION; } - this->unk_1F0 = 1; - if (globalCtx->sceneNum == SCENE_INSIDETOWER) { - if ((gSaveContext.save.entranceIndex == 0xC020) || (gSaveContext.save.entranceIndex == 0xC060)) { - this->actionFunc = func_80AD16A8; - return; + this->shouldRotateHead = true; + if (play->sceneId == SCENE_INSIDETOWER) { + if ((gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 2)) || + (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 6))) { + this->actionFunc = EnOsn_HandleCsAction; + } else if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 3)) { + EnOsn_InitCutscene(this); + this->actionFunc = EnOsn_StartCutscene; + } else { + EnOsn_ChooseAction(this, play); } - if (gSaveContext.save.entranceIndex == 0xC030) { - func_80AD1398(this); - this->actionFunc = func_80AD1634; - return; - } - func_80AD144C(this, globalCtx); - return; + } else { + EnOsn_ChooseAction(this, play); } - func_80AD144C(this, globalCtx); break; - case 1: - this->unk_1EC = 0xF; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); - this->actionFunc = EnOsn_Idle; + case OSN_TYPE_LIE_FACE_DOWN: + this->animIndex = OSN_ANIM_LYING_DOWN_FACE_UP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnOsn_DoNothing; break; - case 2: - this->unk_1EC = 0x10; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->unk_1EC); - this->actionFunc = EnOsn_Idle; + case OSN_TYPE_LIE_FACE_UP: + this->animIndex = OSN_ANIM_LYING_DOWN_FACE_DOWN; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnOsn_DoNothing; break; - case 3: + case OSN_TYPE_CUTSCENE: this->actor.flags &= ~ACTOR_FLAG_1; - this->actionFunc = func_80AD16A8; + this->actionFunc = EnOsn_HandleCsAction; break; default: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); + break; } } -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; + u32 isFlagSet = Flags_GetSwitch(play, 0); - sp34 = Flags_GetSwitch(globalCtx, 0); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - if (!(ENOSN_GET_3(&this->actor))) { - if (sp34 != 0) { + + if (ENOSN_GET_TYPE(&this->actor) == OSN_TYPE_CHOOSE) { + if (isFlagSet) { this->actor.flags |= ACTOR_FLAG_1; - func_80AD0830(this, globalCtx); + EnOsn_UpdateCollider(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->headRot, &this->torsoRot, 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_RotateXS(this->unk_1D8.y, MTXMODE_APPLY); + if (this->shouldRotateHead && (limbIndex == HAPPY_MASK_SALESMAN_LIMB_HEAD)) { + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } - if ((this->unk_1EC == 9 || this->unk_1EC == 8) && limbIndex == 10) { + if (((this->animIndex == OSN_ANIM_ORGAN_PLAY) || (this->animIndex == OSN_ANIM_ORGAN_TALK)) && + (limbIndex == HAPPY_MASK_SALESMAN_LIMB_BACKPACK)) { *dList = NULL; } 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 }; + Vec3f headOffset = { 0.0f, 0.0f, 0.0f }; + Vec3s leftHandRot = { 0x9920, -0x384, -0x320 }; - if (limbIndex == 11) { - Matrix_MultVec3f(&sp30, &thisx->focus.pos); + if (limbIndex == HAPPY_MASK_SALESMAN_LIMB_HEAD) { + Matrix_MultVec3f(&headOffset, &this->actor.focus.pos); } - if (((this->unk_1EC == 17) || (this->unk_1EC == 21) || (this->unk_1EC == 22)) && (limbIndex == 6)) { + if (((this->animIndex == OSN_ANIM_MASK_LOOK_AT) || (this->animIndex == OSN_ANIM_MASK_LOOK_FROM_START) || + (this->animIndex == OSN_ANIM_MASK_LOOK_FROM_LOOP)) && + (limbIndex == HAPPY_MASK_SALESMAN_LIMB_LEFT_HAND)) { 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); + Matrix_RotateXS(leftHandRot.x, MTXMODE_APPLY); + Matrix_RotateYS(leftHandRot.y, MTXMODE_APPLY); + Matrix_RotateZS(leftHandRot.z, MTXMODE_APPLY); - gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, &object_osn_DL_0192A0); + gSPMatrix((*gfx)++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList((*gfx)++, &gHappyMaskSalesmanMajorasMaskDL); Matrix_Pop(); } } -void EnOsn_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_80AD2588 = object_osn_Tex_0166F8; - static TexturePtr D_80AD258C = object_osn_Tex_016EF8; - static TexturePtr D_80AD2590 = object_osn_Tex_0176F8; - static TexturePtr D_80AD2594 = object_osn_Tex_017EF8; - static TexturePtr D_80AD2598 = object_osn_Tex_0182F8; +void EnOsn_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sEyeClosedHappyTex = gHappyMaskSalesmanEyeClosedHappyTex; + static TexturePtr sEyeOpenTex = gHappyMaskSalesmanEyeOpenTex; + static TexturePtr sEyeClosedAngryTex = gHappyMaskSalesmanEyeClosedAngryTex; + static TexturePtr sSmileTex = gHappyMaskSalesmanSmileTex; + static TexturePtr sFrownTex = gHappyMaskSalesmanFrownTex; 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); - if ((this->unk_1EC == 0xB) || (this->unk_1EC == 0xC) || (this->unk_1EC == 0x17) || - (globalCtx->msgCtx.currentTextId == 0x1FCA)) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD258C)); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); - } else if ((this->unk_1EC == 7) || (this->unk_1EC == 3) || (this->unk_1EC == 0xD)) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2590)); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2598)); + if (this->alpha == 255) { + func_8012C28C(play->state.gfxCtx); + if ((this->animIndex == OSN_ANIM_CHOKE) || (this->animIndex == OSN_ANIM_DESPAIR) || + (this->animIndex == OSN_ANIM_HAND_OUT_2) || (play->msgCtx.currentTextId == 0x1FCA)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeOpenTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sSmileTex)); + } else if ((this->animIndex == OSN_ANIM_SHAKE_HEAD) || (this->animIndex == OSN_ANIM_REMINISCE) || + (this->animIndex == OSN_ANIM_FAST_BOWS)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeClosedAngryTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sFrownTex)); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeClosedHappyTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sSmileTex)); } 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); - 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); + func_8012C2DC(play->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeClosedHappyTex)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(sSmileTex)); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->alpha); + 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..638f31e4e 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.h +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.h @@ -5,29 +5,34 @@ struct EnOsn; -typedef void (*EnOsnActionFunc)(struct EnOsn*, GlobalContext*); +typedef void (*EnOsnActionFunc)(struct EnOsn*, PlayState*); + +#define ENOSN_GET_TYPE(this) ((thisx)->params & 3) + +typedef enum { + /* 0 */ OSN_TYPE_CHOOSE, // Will choose between Idle and Cutscene + /* 1 */ OSN_TYPE_LIE_FACE_DOWN, + /* 2 */ OSN_TYPE_LIE_FACE_UP, + /* 3 */ OSN_TYPE_CUTSCENE +} OsnType; 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 headRot; + /* 0x1DE */ Vec3s torsoRot; + /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x6]; + /* 0x1EA */ u16 stateFlags; + /* 0x1EC */ u8 animIndex; + /* 0x1ED */ u8 csAction; + /* 0x1EE */ s16 cutscene; + /* 0x1F0 */ u8 shouldRotateHead; + /* 0x1F1 */ UNK_TYPE1 unk_1F1[0x3]; + /* 0x1F4 */ u16 textId; + /* 0x1F6 */ s32 maskTextFlags; + /* 0x1FA */ u8 alpha; } EnOsn; // size = 0x1FB -extern const ActorInit En_Osn_InitVars; - -#define ENOSN_GET_3(this) ((thisx)->params & 3) - #endif // Z_EN_OSN_H diff --git a/src/overlays/actors/ovl_En_Ossan/overlay.cfg b/src/overlays/actors/ovl_En_Ossan/overlay.cfg deleted file mode 100644 index be58d6c1e..000000000 --- a/src/overlays/actors/ovl_En_Ossan/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ossan -z_en_ossan.c 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 ff85b7625..d1f7dbec9 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,39 +60,39 @@ 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 = { +ActorInit En_Ossan_InitVars = { ACTOR_EN_OSSAN, ACTORCAT_NPC, FLAGS, @@ -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) { @@ -212,68 +212,68 @@ void EnOssan_CheckValidSpawn(EnOssan* this) { case 2: if (gSaveContext.save.time <= CLOCK_TIME(21, 30) && gSaveContext.save.time > CLOCK_TIME(6, 00)) { if (this->actor.params != ENOSSAN_CURIOSITY_SHOP_MAN) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } break; case 3: if (this->actor.params == ENOSSAN_CURIOSITY_SHOP_MAN) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } if (!(gSaveContext.save.time <= CLOCK_TIME(22, 00) && gSaveContext.save.time >= CLOCK_TIME(6, 00))) { if (this->actor.params != ENOSSAN_CURIOSITY_SHOP_MAN) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } break; } } -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; //! @bug Condition is impossible, params cannot be both greater then 1 AND less then 0. - if (this->actor.params > ENOSSAN_PART_TIME_WORKER && this->actor.params < ENOSSAN_CURIOSITY_SHOP_MAN) { - Actor_MarkForDeath(&this->actor); + if ((this->actor.params > ENOSSAN_PART_TIME_WORKER) && (this->actor.params < ENOSSAN_CURIOSITY_SHOP_MAN)) { + Actor_Kill(&this->actor); 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); + Actor_Kill(&this->actor); return; } EnOssan_CheckValidSpawn(this); @@ -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->cursorIndex]->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; - Interface_ChangeAlpha(50); + Actor_ProcessTalkRequest(&this->actor, &play->state); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; - player->stateFlags2 &= ~0x20000000; - globalCtx->interfaceCtx.unk_222 = 0; - globalCtx->interfaceCtx.unk_224 = 0; + player->stateFlags2 &= ~PLAYER_STATE2_20000000; + 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,52 +321,52 @@ 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->cursorIndex]->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, DO_ACTION_NEXT); 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, DO_ACTION_DECIDE); 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)) { - player->stateFlags2 |= 0x20000000; + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, ARRAY_COUNT(this->limbRotTableY)); + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + player->stateFlags2 |= PLAYER_STATE2_20000000; EnOssan_SetupAction(this, EnOssan_BeginInteraction); if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -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; @@ -500,7 +500,7 @@ u8 EnOssan_SetCursorIndexFromNeutral(EnOssan* this, u8 shelfOffset) { u8 i; // if cursor is on the top shelf - if (this->cursorIdx & 1) { + if (this->cursorIndex & 1) { // scan top shelf for (i = shelfOffset + 1; i < shelfOffset + 4; i += 2) { if (this->items[i] != NULL) { @@ -530,96 +530,96 @@ u8 EnOssan_SetCursorIndexFromNeutral(EnOssan* this, u8 shelfOffset) { return CURSOR_INVALID; } -u8 EnOssan_CursorRight(EnOssan* this, u8 cursorIdx, u8 shelfSlotMin) { +u8 EnOssan_CursorRight(EnOssan* this, u8 cursorIndex, u8 shelfSlotMin) { u8 end = shelfSlotMin + 4; - while (cursorIdx >= shelfSlotMin && cursorIdx < end) { - cursorIdx -= 2; - if (cursorIdx >= shelfSlotMin && cursorIdx < end) { - if (this->items[cursorIdx] != NULL) { - return cursorIdx; + while (cursorIndex >= shelfSlotMin && cursorIndex < end) { + cursorIndex -= 2; + if (cursorIndex >= shelfSlotMin && cursorIndex < end) { + if (this->items[cursorIndex] != NULL) { + return cursorIndex; } } } return CURSOR_INVALID; } -u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIdx, u8 shelfSlotMax) { - while (cursorIdx < shelfSlotMax) { - cursorIdx += 2; - if (cursorIdx < shelfSlotMax) { - if (this->items[cursorIdx] != NULL) { - return cursorIdx; +u8 EnOssan_CursorLeft(EnOssan* this, u8 cursorIndex, u8 shelfSlotMax) { + while (cursorIndex < shelfSlotMax) { + cursorIndex += 2; + if (cursorIndex < shelfSlotMax) { + if (this->items[cursorIndex] != NULL) { + return cursorIndex; } } } 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, DO_ACTION_DECIDE); 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); - u8 cursorIdx; + Player* player = GET_PLAYER(play); + u8 cursorIndex; if (this->cutsceneState == ENOSSAN_CUTSCENESTATE_STOPPED) { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -629,25 +629,25 @@ 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, DO_ACTION_DECIDE); + 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; + cursorIndex = EnOssan_SetCursorIndexFromNeutral(this, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; EnOssan_SetupAction(this, EnOssan_LookToLeftShelf); - func_8011552C(globalCtx, 6); + func_8011552C(play, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } } else if (this->stickAccumX > 0) { - cursorIdx = EnOssan_SetCursorIndexFromNeutral(this, 0); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_SetCursorIndexFromNeutral(this, 0); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; EnOssan_SetupAction(this, EnOssan_LookToRightShelf); - func_8011552C(globalCtx, 6); + func_8011552C(play, DO_ACTION_DECIDE); 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->cursorIndex]->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->cursorIndex]->actor.textId); } else { ActorCutscene_SetIntentToPlay(this->cutscene); } @@ -731,16 +731,16 @@ void EnOssan_LookToRightShelf(EnOssan* this, GlobalContext* globalCtx) { } void EnOssan_CursorUpDown(EnOssan* this) { - u8 curTemp = this->cursorIdx; + u8 curTemp = this->cursorIndex; u8 curScanTemp; if (this->stickAccumY < 0) { curTemp &= (u8)~1; if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; return; } - // cursorIdx on right shelf + // cursorIndex on right shelf if (curTemp < 4) { curScanTemp = curTemp + 2; if (curScanTemp >= 4) { @@ -748,7 +748,7 @@ void EnOssan_CursorUpDown(EnOssan* this) { } while (curScanTemp != curTemp) { if (this->items[curScanTemp] != NULL) { - this->cursorIdx = curScanTemp; + this->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -757,14 +757,14 @@ void EnOssan_CursorUpDown(EnOssan* this) { } } } else { - // cursorIdx on left shelf + // cursorIndex on left shelf curScanTemp = curTemp + 2; if (curScanTemp >= 8) { curScanTemp = 4; } while (curScanTemp != curTemp) { if (this->items[curScanTemp] != NULL) { - this->cursorIdx = curScanTemp; + this->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -776,10 +776,10 @@ void EnOssan_CursorUpDown(EnOssan* this) { } else if (this->stickAccumY > 0) { curTemp |= 1; if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; return; } - // cursorIdx on right shelf + // cursorIndex on right shelf if (curTemp < 4) { curScanTemp = curTemp + 2; if (curScanTemp >= 4) { @@ -787,7 +787,7 @@ void EnOssan_CursorUpDown(EnOssan* this) { } while (curScanTemp != curTemp) { if (this->items[curScanTemp] != NULL) { - this->cursorIdx = curScanTemp; + this->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -796,14 +796,14 @@ void EnOssan_CursorUpDown(EnOssan* this) { } } } else { - // cursorIdx on left shelf + // cursorIndex on left shelf curScanTemp = curTemp + 2; if (curScanTemp >= 8) { curScanTemp = 5; } while (curScanTemp != curTemp) { if (this->items[curScanTemp] != NULL) { - this->cursorIdx = curScanTemp; + this->cursorIndex = curScanTemp; return; } curScanTemp += 2; @@ -815,16 +815,16 @@ void EnOssan_CursorUpDown(EnOssan* this) { } } -s32 EnOssan_HasPlayerSelectedItem(GlobalContext* globalCtx, EnOssan* this, Input* input) { - EnGirlA* item = this->items[this->cursorIdx]; +s32 EnOssan_HasPlayerSelectedItem(PlayState* play, EnOssan* this, Input* input) { + EnGirlA* item = this->items[this->cursorIndex]; - 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->cursorIndex]->choiceTextId); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_DECIDE); @@ -838,11 +838,11 @@ 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; + u8 prevCursorIndex = this->cursorIndex; + u8 cursorIndex; if (!EnOssan_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -851,44 +851,44 @@ 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, DO_ACTION_DECIDE); + 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; + cursorIndex = EnOssan_CursorRight(this, this->cursorIndex, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } else { - EnOssan_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX < 0) { - cursorIdx = EnOssan_CursorLeft(this, this->cursorIdx, 8); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorLeft(this, this->cursorIndex, 8); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } } } else { if (this->stickAccumX > 0 && this->stickAccumX > 500) { - cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 4); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorRight(this, this->cursorIndex, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } else { - EnOssan_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX < 0 && this->stickAccumX < -500) { - cursorIdx = EnOssan_CursorLeft(this, this->cursorIdx, 8); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorLeft(this, this->cursorIndex, 8); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } } } EnOssan_CursorUpDown(this); - if (this->cursorIdx != prevCursorIndex) { - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + if (this->cursorIndex != prevCursorIndex) { + func_80151938(play, this->items[this->cursorIndex]->actor.textId); play_sound(NA_SE_SY_CURSOR); } } @@ -896,11 +896,11 @@ 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; + u8 prevCursorIndex = this->cursorIndex; + u8 cursorIndex; if (!EnOssan_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -909,44 +909,44 @@ 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, DO_ACTION_DECIDE); + 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; + cursorIndex = EnOssan_CursorRight(this, this->cursorIndex, 0); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } else { - EnOssan_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX > 0) { - cursorIdx = EnOssan_CursorLeft(this, this->cursorIdx, 4); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorLeft(this, this->cursorIndex, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } } } else { if (this->stickAccumX < 0 && this->stickAccumX < -500) { - cursorIdx = EnOssan_CursorRight(this, this->cursorIdx, 0); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorRight(this, this->cursorIndex, 0); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } else { - EnOssan_SetupLookToShopkeeperFromShelf(globalCtx, this); + EnOssan_SetupLookToShopkeeperFromShelf(play, this); return; } } else if (this->stickAccumX > 0 && this->stickAccumX > 500) { - cursorIdx = EnOssan_CursorLeft(this, this->cursorIdx, 4); - if (cursorIdx != CURSOR_INVALID) { - this->cursorIdx = cursorIdx; + cursorIndex = EnOssan_CursorLeft(this, this->cursorIndex, 4); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; } } } EnOssan_CursorUpDown(this); - if (this->cursorIdx != prevCursorIndex) { - func_80151938(globalCtx, this->items[this->cursorIdx]->actor.textId); + if (this->cursorIndex != prevCursorIndex) { + func_80151938(play, this->items[this->cursorIndex]->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; - player->stateFlags2 &= ~0x20000000; - Interface_ChangeAlpha(50); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + player->stateFlags2 &= ~PLAYER_STATE2_20000000; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); 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) { - EnGirlA* item = this->items[this->cursorIdx]; +void EnOssan_HandleCanBuyItem(PlayState* play, EnOssan* this) { + EnGirlA* item = this->items[this->cursorIndex]; - 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, DO_ACTION_DECIDE); + 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->cursorIndex]->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->cursorIndex]->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 = this->items[this->cursorIndex]; + item->restockFunc(play, item); + this->actionFunc = this->prevActionFunc; + func_80151938(play, this->items[this->cursorIndex]->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->cursorIndex]->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,58 +1109,58 @@ 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_IA_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, DO_ACTION_DECIDE); + 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 = this->items[this->cursorIndex]; + 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); + player->stateFlags2 |= PLAYER_STATE2_20000000; + Message_StartTextbox(play, this->textId, &this->actor); + EnOssan_SetupStartShopping(play, this, true); + func_800B85E0(&this->actor, play, 100.0f, PLAYER_IA_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 = this->items[this->cursorIndex]; + 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); + player->stateFlags2 |= PLAYER_STATE2_20000000; + Message_StartTextbox(play, this->textId, &this->actor); + EnOssan_SetupStartShopping(play, this, true); + func_800B85E0(&this->actor, play, 100.0f, PLAYER_IA_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)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_20000000; EnOssan_SetupAction(this, EnOssan_ContinueShopping); this->cutsceneState = ENOSSAN_CUTSCENESTATE_PLAYING; } else { @@ -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_IA_MINUS1); } } @@ -1184,7 +1184,7 @@ void EnOssan_PositionSelectedItem(EnOssan* this) { { -35.0f, 68.0f, -130.0f }, }; EnGirlA* item; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; u8 i2; ShopItem* shopItem = &sShops[this->actor.params][i]; Vec3f worldPos; @@ -1245,7 +1245,7 @@ void EnOssan_UpdateItemSelectedProperty(EnOssan* this) { this->drawCursor == 0) { item->isSelected = false; } else { - item->isSelected = this->cursorIdx == i ? true : false; + item->isSelected = this->cursorIndex == i ? true : false; } } } @@ -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; - if (gSaveContext.save.weekEventReg[18] & 0x10) { + this->animIndex = FSN_ANIM_SLAM_COUNTER_START; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_18_10)) { return sWelcomeDekuTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_ZORA: - this->animationIndex = FSN_ANIMATION_LEAN_FORWARD_START; - if (gSaveContext.save.weekEventReg[18] & 8) { + this->animIndex = FSN_ANIM_LEAN_FORWARD_START; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_18_08)) { return sWelcomeZoraTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_CURIOSITY_SHOP_MAN]; case PLAYER_FORM_GORON: - this->animationIndex = FSN_ANIMATION_HAND_ON_FACE_START; - if (gSaveContext.save.weekEventReg[18] & 4) { + this->animIndex = FSN_ANIM_HAND_ON_FACE_START; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_18_04)) { 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; @@ -1417,17 +1417,17 @@ u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) } switch (player->transformation) { case PLAYER_FORM_DEKU: - if (gSaveContext.save.weekEventReg[55] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_10)) { return sWelcomeDekuTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeDekuFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_ZORA: - if (gSaveContext.save.weekEventReg[55] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_08)) { return sWelcomeZoraTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeZoraFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; case PLAYER_FORM_GORON: - if (gSaveContext.save.weekEventReg[55] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_04)) { return sWelcomeGoronTextIds[ENOSSAN_PART_TIME_WORKER]; } return sWelcomeGoronFirstTimeTextIds[ENOSSAN_PART_TIME_WORKER]; @@ -1438,39 +1438,39 @@ u16 EnOssan_PartTimerWorker_GetWelcome(EnOssan* this, GlobalContext* globalCtx) void EnOssan_SetHaveMet(EnOssan* this) { switch (this->textId) { case 0x06A9: - gSaveContext.save.weekEventReg[18] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_18_10); break; case 0x06C6: - gSaveContext.save.weekEventReg[55] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_55_10); break; case 0x06A7: - gSaveContext.save.weekEventReg[18] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_18_08); break; case 0x06C4: - gSaveContext.save.weekEventReg[55] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_55_08); break; case 0x06A5: - gSaveContext.save.weekEventReg[18] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_18_04); break; case 0x06C2: - gSaveContext.save.weekEventReg[55] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_55_04); break; } } -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; @@ -1479,7 +1479,7 @@ void EnOssan_InitShop(EnOssan* this, GlobalContext* globalCtx) { this->actor.colChkInfo.cylRadius = 50; this->stickAccumX = this->stickAccumY = 0; - this->cursorIdx = 0; + this->cursorIndex = 0; this->cursorPos.z = 1.5f; this->cursorColor.r = 0; this->cursorColor.g = 80; @@ -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,10 @@ 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 +1588,12 @@ 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 +1606,8 @@ 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 +1624,32 @@ 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,23 +1658,24 @@ 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) { @@ -1678,19 +1684,18 @@ s32 EnOssan_CuriosityShopMan_OverrideLimbDraw(GlobalContext* globalCtx, s32 limb 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_RotateXS(this->headRotPartTimeWorker.y, MTXMODE_APPLY); - Matrix_RotateZS(this->headRotPartTimeWorker.x, MTXMODE_APPLY); + Matrix_RotateXS(this->partTimerHeadRot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->partTimerHeadRot.x, MTXMODE_APPLY); } return false; } -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 +1704,46 @@ 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_MultVec3f(&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..a4787cc14 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; @@ -34,7 +35,7 @@ typedef struct EnOssan { /* 0x230 */ f32 cursorAnimTween; /* 0x234 */ u8 cursorAnimState; /* 0x235 */ u8 drawCursor; - /* 0x236 */ u8 cursorIdx; + /* 0x236 */ u8 cursorIndex; /* 0x238 */ StickDirectionPrompt stickLeftPrompt; /* 0x270 */ StickDirectionPrompt stickRightPrompt; /* 0x2A8 */ f32 arrowAnimTween; @@ -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 @@ -71,6 +72,4 @@ typedef enum { /* 1 */ ENOSSAN_PART_TIME_WORKER } EnOssanWorker; -extern const ActorInit En_Ossan_InitVars; - #endif // Z_EN_OSSAN_H diff --git a/src/overlays/actors/ovl_En_Ot/overlay.cfg b/src/overlays/actors/ovl_En_Ot/overlay.cfg deleted file mode 100644 index 53a5992e9..000000000 --- a/src/overlays/actors/ovl_En_Ot/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ot -z_en_ot.c 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 8ef3e1bfc..e2490bb8d 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -13,57 +13,57 @@ #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; -static EnOt* D_80B5E888; +EnOt* D_80B5E880; +EnOt* D_80B5E884; +EnOt* D_80B5E888; -const ActorInit En_Ot_InitVars = { +ActorInit En_Ot_InitVars = { ACTOR_EN_OT, ACTORCAT_NPC, FLAGS, @@ -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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_10)) { 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; @@ -195,13 +195,13 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_394.y = this->actor.world.pos.y; this->unk_394.z = (this->actor.world.pos.z + this->unk_360->actor.world.pos.z) * 0.5f; Math_Vec3f_Copy(&this->unk_360->unk_394, &this->unk_394); - if (gSaveContext.save.weekEventReg[32] & 1) { - func_80B5C244(this, globalCtx); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_32_01)) { + func_80B5C244(this, play); } else { - func_80B5C684(this, globalCtx); + func_80B5C684(this, play); } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else if ((D_80B5E888 != NULL) && (D_80B5E888->unk_32C & 1)) { this->unk_360 = D_80B5E888; @@ -211,15 +211,15 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { 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; case 1: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); break; } break; @@ -230,41 +230,41 @@ void EnOt_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_344) { case 0: Actor_SetScale(&this->actor, 0.0f); - if (!(gSaveContext.save.weekEventReg[13] & 1)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_13_01)) { 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; case 1: Actor_SetScale(&this->actor, 0.012999999f); - if (gSaveContext.save.weekEventReg[84] & 0x10) { - if (gSaveContext.save.weekEventReg[32] & 1) { - func_80B5C244(this, globalCtx); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_10)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_32_01)) { + func_80B5C244(this, play); } else { - func_80B5C684(this, globalCtx); + func_80B5C684(this, play); } } else { - func_80B5CE6C(this, globalCtx); + func_80B5CE6C(this, play); } break; } break; case 3: - if (!(gSaveContext.save.weekEventReg[26] & 8)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_26_08)) { this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Actor_SetScale(&this->actor, 0.0064999997f); @@ -272,19 +272,19 @@ 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); + Actor_Kill(&this->actor); } break; } } -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; @@ -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) { - if (gSaveContext.save.weekEventReg[32] & 1) { - this->unk_38C = GI_RUPEE_RED; +void func_80B5C154(EnOt* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_32_01)) { + this->getItemId = GI_RUPEE_RED; } else { - this->unk_38C = GI_HEART_PIECE; - gSaveContext.save.weekEventReg[32] |= 1; + this->getItemId = GI_HEART_PIECE; + SET_WEEKEVENTREG(WEEKEVENTREG_32_01); } - 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; @@ -461,7 +461,7 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } if (Animation_OnFrame(&this->skelAnime, 12.0f)) { - Matrix_RotateYS(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; @@ -477,24 +477,24 @@ void func_80B5C3D8(EnOt* this, GlobalContext* globalCtx) { } } -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) { - if (gSaveContext.save.weekEventReg[26] & 8) { - Actor_MarkForDeath(&this->actor); +void func_80B5C64C(EnOt* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_26_08)) { + Actor_Kill(&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; @@ -505,7 +505,7 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Matrix_MultVecZ(26.259998f, &sp30); } else { if (this->unk_73C == 0) { - gSaveContext.save.weekEventReg[84] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_84_10); switch (this->unk_388) { case 0: ActorCutscene_Stop(this->cutscenes[2]); @@ -527,22 +527,22 @@ void func_80B5C6DC(EnOt* this, GlobalContext* globalCtx) { Math_SmoothStepToF(&this->actor.world.pos.x, this->unk_348.x, 1.0f, 2.0f, 0.01f); Math_SmoothStepToF(&this->actor.world.pos.z, this->unk_348.z, 1.0f, 2.0f, 0.01f); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0xE38, 0x38E); - if ((gSaveContext.save.weekEventReg[84] & 0x10) && (this->unk_33C == 1)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_10) && (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); + SET_WEEKEVENTREG(WEEKEVENTREG_25_04); + 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,128 +580,128 @@ 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_IA_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_IA_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); + player->stateFlags2 |= PLAYER_STATE2_20000000; + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_23_10); + 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); + player->stateFlags2 &= ~PLAYER_STATE2_20000000; + 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_IA_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); } } - if (!(gSaveContext.save.weekEventReg[84] & 0x10) && (ENOT_GET_C000(&this->actor) == 1)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_84_10) && (ENOT_GET_C000(&this->actor) == 1)) { if ((fabsf(this->actor.xzDistToPlayer) <= 130.0f) && (fabsf(this->actor.playerHeightRel) <= 130.0f)) { player->unk_B2B = 29; } @@ -717,33 +717,33 @@ void func_80B5CEC8(EnOt* this, GlobalContext* globalCtx) { 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,8 +753,8 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } else { phi_a1 = 0x1069; } - } else if (Flags_GetSwitch(globalCtx, ENOT_GET_3F80(&this->actor))) { - if (gSaveContext.save.weekEventReg[23] & 0x10) { + } else if (Flags_GetSwitch(play, ENOT_GET_3F80(&this->actor))) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_10)) { phi_a1 = 0x106C; } else { phi_a1 = 0x106B; @@ -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) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_84_10) && !(this->unk_32C & 8)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_04)) { 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; @@ -998,8 +998,8 @@ void func_80B5DB6C(Actor* thisx, GlobalContext* globalCtx) { } else if (D_80B5E888 != NULL) { s32 sp4C = false; - if (gSaveContext.save.weekEventReg[13] & 1) { - if (!SurfaceType_IsHorseBlocked(&globalCtx->colCtx, player->actor.floorPoly, player->actor.floorBgId)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_01)) { + 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_Push(); - func_80B5E1D8(globalCtx, this->unk_3A4, 10); + 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); + 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,27 +1050,27 @@ 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_MultVec3f(&D_80B5E410, &this->unk_74C); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else if (limbIndex == 1) { 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)) { @@ -1131,13 +1131,13 @@ void func_80B5E078(GlobalContext* globalCtx, EnOtUnkStruct* arg1, s32 arg2) { } } -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_Translate(arg1->unk_0C.x, arg1->unk_0C.y, arg1->unk_0C.z, MTXMODE_NEW); - Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_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); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); + 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..7e8d7f651 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,41 +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; - #endif // Z_EN_OT_H diff --git a/src/overlays/actors/ovl_En_Owl/overlay.cfg b/src/overlays/actors/ovl_En_Owl/overlay.cfg deleted file mode 100644 index c3609f992..000000000 --- a/src/overlays/actors/ovl_En_Owl/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Owl -z_en_owl.c 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 d324c8d92..8d7b92b69 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); @@ -48,7 +48,7 @@ typedef enum { /* 0x01 */ OWL_OK } EnOwlMessageChoice; -const ActorInit En_Owl_InitVars = { +ActorInit En_Owl_InitVars = { ACTOR_EN_OWL, ACTORCAT_NPC, FLAGS, @@ -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,22 +150,22 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { switch (owlType) { case ENOWL_GET_TYPE_1: - if ((switchFlag < 0x7F) && Flags_GetSwitch(globalCtx, switchFlag)) { - Actor_MarkForDeath(&this->actor); + if ((switchFlag < 0x7F) && Flags_GetSwitch(play, switchFlag)) { + Actor_Kill(&this->actor); return; } break; case ENOWL_GET_TYPE_2: if (gSaveContext.save.inventory.items[ITEM_LENS] == ITEM_LENS) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } break; case ENOWL_GET_TYPE_3: if (CHECK_QUEST_ITEM(QUEST_SONG_SOARING)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } break; @@ -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: @@ -183,7 +183,7 @@ void EnOwl_Init(Actor* thisx, GlobalContext* globalCtx) { case ENOWL_GET_TYPE_2: this->actionFunc = func_8095BE0C; - if (gSaveContext.save.weekEventReg[9] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_09_20)) { this->actor.textId = 0xBF0; } else { this->actor.textId = 0xBEA; @@ -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_IA_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_IA_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,69 +323,69 @@ 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)) { - func_801A3098(NA_BGM_OWL); +void func_8095AEC0(EnOwl* this, PlayState* play) { + func_8095A920(this, play); + if (func_8095A978(this, play, 0x7D0, 360.0f, 200.0f)) { + Audio_PlayFanfare(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)) { - func_801A3098(NA_BGM_OWL); +void func_8095AFEC(EnOwl* this, PlayState* play) { + func_8095A920(this, play); + if (func_8095A978(this, play, 0xBF6, 200.0f, 100.0f)) { + Audio_PlayFanfare(NA_BGM_OWL); this->actionFunc = func_8095AF2C; this->unk_406 = 0; this->actionFlags |= 0x40; @@ -411,7 +411,7 @@ void func_8095B0C8(EnOwl* this) { Vec3s* points = Lib_SegmentedToVirtual(this->path->points); points += this->unk_3F8; - this->unk_3EC = Math_FAtan2F(points->z - this->actor.world.pos.z, points->x - this->actor.world.pos.x); + this->unk_3EC = Math_Atan2S_XY(points->z - this->actor.world.pos.z, points->x - this->actor.world.pos.x); this->unk_3F0 = points->y; } @@ -423,17 +423,17 @@ 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; } if (this->actor.xzDistToPlayer > 6000.0f) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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,10 +475,10 @@ 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) { + if (player->stateFlags3 & PLAYER_STATE3_10000000) { this->actor.textId = 0xBF1; EnOwl_ChangeMode(this, func_8095BF58, func_8095C484, &this->skelAnime2, &object_owl_Anim_00CDB0, 0.0f); this->eyeTexIndex = 0; @@ -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); + Audio_PlayFanfare(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_IA_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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_09_40)) { + func_80151938(play, 0xBF4); } else { - gSaveContext.save.weekEventReg[9] |= 0x40; - func_80151938(globalCtx, 0xBED); + SET_WEEKEVENTREG(WEEKEVENTREG_09_40); + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_09_20); + 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,38 +709,38 @@ 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); + Audio_PlayFanfare(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_IA_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_IA_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); + Actor_Kill(&this->actor); } Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_3EC, 2, 0x80, 0x40); @@ -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,28 +1062,28 @@ 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); + if (player->stateFlags3 & PLAYER_STATE3_10000000) { + Actor_Kill(&this->actor); return; } if (this->actor.world.pos.y < (this->unk_3F0 - 1000.0f)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } 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) { this->unk_3DC--; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } @@ -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; @@ -1140,7 +1140,7 @@ void EnOwl_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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_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..033857886 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,41 +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; - #endif // Z_EN_OWL_H diff --git a/src/overlays/actors/ovl_En_Pamera/overlay.cfg b/src/overlays/actors/ovl_En_Pamera/overlay.cfg deleted file mode 100644 index 544499e92..000000000 --- a/src/overlays/actors/ovl_En_Pamera/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Pamera -z_en_pamera.c 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 e17cba0e2..2b0aae48a 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -5,72 +5,71 @@ */ #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 = { +ActorInit En_Pamera_InitVars = { ACTOR_EN_PAMERA, ACTORCAT_NPC, FLAGS, @@ -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,19 +149,23 @@ 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)) { - Actor_MarkForDeath(&this->actor); + + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || (gSaveContext.save.entrance == ENTRANCE(IKANA_CANYON, 9))) { + Actor_Kill(&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)) { - gSaveContext.save.weekEventReg[59] &= (u8)~1; + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_61_04)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_59_01) || (gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 2))) { + if ((gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 2)) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_59_01)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_59_01); } func_80BD8700(this); } else { @@ -173,14 +176,14 @@ void EnPamera_Init(Actor* thisx, GlobalContext* globalCtx) { func_80BD8CCC(this); } } else { - gSaveContext.save.weekEventReg[59] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_59_01); func_80BD8FF0(this); } } } -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 +196,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); + Actor_Kill(&this->actor); } - if (gSaveContext.save.weekEventReg[61] & 4) { - path = &globalCtx->setupPathList[path->unk1]; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_61_04)) { + path = &play->setupPathList[path->unk1]; } this->pathPoints = Lib_SegmentedToVirtual(path->points); this->pathIndex = 0; @@ -224,39 +227,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 +269,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 +278,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,26 +291,26 @@ 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); - gSaveContext.save.weekEventReg[59] |= 1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + SET_WEEKEVENTREG(WEEKEVENTREG_59_01); 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); - gSaveContext.save.weekEventReg[61] |= 4; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_59_01); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_61_04)) { + func_80BD92D0(this, play); + SET_WEEKEVENTREG(WEEKEVENTREG_61_04); } func_80BD8700(this); } @@ -318,7 +321,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 +338,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 +365,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 +379,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 +412,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 +431,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 +442,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 +456,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 +469,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 +496,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,67 +510,66 @@ 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) { + 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; - if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { func_80BD9E60(this); func_80BD9938(this); } else { @@ -575,7 +577,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { func_80BD9E60(this); func_80BD9904(this); } - if (gSaveContext.save.weekEventReg[14] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { func_801A0204(NA_BGM_INSIDE_A_HOUSE); @@ -587,39 +589,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)))) { + (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20))) { 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 +629,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 +655,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 +727,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) && CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20)) { if ((this->actionFunc != func_80BD994C) && (this->actionFunc != EnPamera_HandleDialogue)) { this->actor.shape.rot.y = this->actor.world.rot.y; func_80BD9904(this); @@ -742,26 +747,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 +777,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 +812,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 +825,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,43 +833,43 @@ 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; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_59_01)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_59_01); } - if (!(gSaveContext.save.weekEventReg[61] & 4)) { - gSaveContext.save.weekEventReg[61] |= 4; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_61_04)) { + SET_WEEKEVENTREG(WEEKEVENTREG_61_04); } - 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]++; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { + 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..34f18e815 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; @@ -63,6 +37,4 @@ typedef struct EnPamera { /* 0x326 */ u16 unk_326; } EnPamera; // size = 0x328 -extern const ActorInit En_Pamera_InitVars; - #endif // Z_EN_PAMERA_H diff --git a/src/overlays/actors/ovl_En_Pametfrog/overlay.cfg b/src/overlays/actors/ovl_En_Pametfrog/overlay.cfg deleted file mode 100644 index de6a9fa77..000000000 --- a/src/overlays/actors/ovl_En_Pametfrog/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Pametfrog -z_en_pametfrog.c 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 86b2eb671..82b424657 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -5,68 +5,69 @@ */ #include "z_en_pametfrog.h" +#include "z64quake.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 = { +ActorInit En_Pametfrog_InitVars = { ACTOR_EN_PAMETFROG, ACTORCAT_BOSS, FLAGS, @@ -156,67 +157,64 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 2, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; static CollisionCheckInfoInit sColChkInit = { 3, 30, 60, 50 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 69, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GEKKO_SNAPPER, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(targetArrowOffset, -13221, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 7, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 10, ICHAIN_STOP), }; -// gSaveContext.save.weekEventReg[KEY] = VALUE -// KEY | VALUE static s32 isFrogReturnedFlags[] = { - (32 << 8) | 0x40, // Woodfall Temple Frog Returned - (32 << 8) | 0x80, // Great Bay Temple Frog Returned - (33 << 8) | 0x01, // Southern Swamp Frog Returned - (33 << 8) | 0x02, // Laundry Pool Frog Returned + WEEKEVENTREG_32_40, + WEEKEVENTREG_32_80, + WEEKEVENTREG_33_01, + WEEKEVENTREG_33_02, }; -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)) { - 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); + if (Flags_GetClear(play, play->roomCtx.curRoom.num)) { + Actor_Kill(&this->actor); + if (!CHECK_WEEKEVENTREG(isFrogReturnedFlags[this->actor.params - 1])) { + 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) { - Actor_MarkForDeath(&this->actor); - } else { - this->actor.params = GEKKO_PRE_SNAPPER; - EnPametfrog_SetupLookAround(this); + 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_Kill(&this->actor); + return; } + + this->actor.params = GEKKO_PRE_SNAPPER; + EnPametfrog_SetupLookAround(this); } } -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 +237,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); } } @@ -324,8 +322,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 +331,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, PLAYER_CSMODE_6); } } -void EnPametfrog_PlaceSnapper(EnPametfrog* this, GlobalContext* globalCtx) { +void EnPametfrog_PlaceSnapper(EnPametfrog* this, PlayState* play) { CollisionPoly* poly; s32 bgId; Vec3f vec1; @@ -366,7 +364,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 +374,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 +392,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 +429,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 +442,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 +461,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 +480,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 +491,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 +508,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 +524,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 +540,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 +585,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 +610,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 +639,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 +672,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) { @@ -688,7 +685,7 @@ void EnPametfrog_WallPause(EnPametfrog* this, GlobalContext* globalCtx) { 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 +699,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 +717,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 +733,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 +769,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 +794,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 +825,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 +838,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 +855,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 +896,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 +905,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,61 +930,61 @@ 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.curRoom.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); - Actor_MarkForDeath(&this->actor); + EnPametfrog_StopCutscene(this, play); + Actor_Kill(&this->actor); } } @@ -1004,19 +1001,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, PLAYER_CSMODE_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,13 +1028,13 @@ 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); + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); this->unk_2AE = true; } EnPametfrog_SetupJumpToLink(this); @@ -1051,11 +1048,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 +1080,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 +1121,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 +1150,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 +1188,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->actor.hintId = TATL_HINT_ID_GEKKO_GIANT_SLIME; 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,53 +1220,60 @@ 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); - 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); + Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye); + + this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_6); + Quake_SetSpeed(this->quakeIndex, 18000); + Quake_SetQuakeValues(this->quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(this->quakeIndex, 15); + + 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); - 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); + + Quake_Remove(this->quakeIndex); + + this->quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + Quake_SetSpeed(this->quakeIndex, 20000); + Quake_SetQuakeValues(this->quakeIndex, 17, 0, 0, 0); + Quake_SetCountdown(this->quakeIndex, 12); + + 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); + Audio_PlayBgm_StorePrevBgm(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) || !(this->collider.elements->info.acHitInfo->toucher.dmgFlags & 0xDB0B3)) { if (this->actor.params == GEKKO_PRE_SNAPPER) { if (Actor_ApplyDamage(&this->actor) == 0) { - func_801A2ED8(); + Audio_RestorePrevBgm(); } if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { @@ -1284,7 +1288,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,34 +1297,33 @@ 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(); + Audio_RestorePrevBgm(); EnPametfrog_SetupCutscene(this); } else if (this->actor.colChkInfo.damageEffect == GEKKO_DMGEFF_ZORA_BARRIER) { EnPametfrog_ApplyElectricStun(this); } 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 +1331,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 +1349,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,23 +1375,23 @@ 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; @@ -1414,13 +1417,13 @@ void EnPametfrog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } } -void EnPametfrog_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnPametfrog_Draw(Actor* thisx, PlayState* play) { EnPametfrog* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); Matrix_RotateYS(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, + 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 1a10575cf..9ae2f76df 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; @@ -59,7 +32,7 @@ typedef struct EnPametfrog { /* 0x2AE */ u8 unk_2AE; // True/False /* 0x2B0 */ s16 cutscene; /* 0x2B2 */ s16 params; - /* 0x2B4 */ s16 quake; + /* 0x2B4 */ s16 quakeIndex; /* 0x2B6 */ s16 timer; /* 0x2B8 */ s16 spinYaw; /* 0x2BA */ s16 subCamId; @@ -76,6 +49,4 @@ typedef struct EnPametfrog { /* 0x3A4 */ ColliderJntSphElement colElement[2]; } EnPametfrog; // size = 0x424 -extern const ActorInit En_Pametfrog_InitVars; - #endif // Z_EN_PAMETFROG_H diff --git a/src/overlays/actors/ovl_En_Paper/overlay.cfg b/src/overlays/actors/ovl_En_Paper/overlay.cfg deleted file mode 100644 index f2b122194..000000000 --- a/src/overlays/actors/ovl_En_Paper/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Paper -z_en_paper.c 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..a3f158cbd 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.c +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.c @@ -1,25 +1,33 @@ -/* - * File: z_en_paper.c +/** + * @file z_en_paper.c * Overlay: ovl_En_Paper - * Description: Tingle Confetti + * Description: Tingle confetti group + * + * Complex actor for its length, that creates and manages a group of confetti effects. Each is a triangle of a + * particular colour, that rotates around a fixed axis at a randomly-chosen fixed velocity, and is subject to gravity, + * drag and wind forces. */ #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 EnPaper_SetupSpreadConfettiGroup(EnPaper* this); +void EnPaper_SpreadConfettiGroup(EnPaper* this, PlayState* play); +void EnPaper_SetupFlyConfettiGroup(EnPaper* this); +void EnPaper_FlyConfettiGroup(EnPaper* this, PlayState* play); +void EnPaper_InitConfettiPiece(EnPaper* this, EnPaperConfetto* piece); +void EnPaper_FlyConfettiPiece(EnPaper* this, EnPaperConfetto* piece); -#if 0 -const ActorInit En_Paper_InitVars = { +ActorInit En_Paper_InitVars = { ACTOR_EN_PAPER, ACTORCAT_ITEMACTION, FLAGS, @@ -31,28 +39,209 @@ const ActorInit En_Paper_InitVars = { (ActorFunc)EnPaper_Draw, }; -#endif +static Vec3f sUnitVecZ = { 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->windForce = sUnitVecZ; + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + EnPaper_SetupSpreadConfettiGroup(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 EnPaper_SetupSpreadConfettiGroup(EnPaper* this) { + this->actionFunc = EnPaper_SpreadConfettiGroup; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F480.s") +/** + * Set up the pieces of confetti. + */ +void EnPaper_SpreadConfettiGroup(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->pieces); i++) { + EnPaper_InitConfettiPiece(this, &this->pieces[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F4FC.s") + EnPaper_SetupFlyConfettiGroup(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F55C.s") +void EnPaper_SetupFlyConfettiGroup(EnPaper* this) { + this->actionFunc = EnPaper_FlyConfettiGroup; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F6E0.s") +/** + * Main action function for the group. + */ +void EnPaper_FlyConfettiGroup(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->pieces); i++) { + EnPaper_FlyConfettiPiece(this, &this->pieces[i]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Update.s") +void EnPaper_InitConfettiPiece(EnPaper* this, EnPaperConfetto* piece) { + // Pick rotation axis randomly (significantly biased towards the z = 0 plane) + Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); + Matrix_MultVec3f(&sUnitVecZ, &piece->rotAxis); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Draw.s") + // copy actor position and distribute uniformly in a cube of side 2 around it + piece->pos = this->actor.world.pos; + piece->pos.x += Rand_Centered() * 4.0f; + piece->pos.y += Rand_Centered() * 4.0f; + piece->pos.z += Rand_Centered() * 4.0f; + + // copy actor velocity and distrbute uniformly in a cuboid with sides 9, 6, 9 with actor.velocity in the middle + // of the base. + piece->vel = this->actor.velocity; + piece->vel.x += Rand_Centered() * 9.0f; + piece->vel.y += Rand_ZeroOne() * 6.0f; + piece->vel.z += Rand_Centered() * 9.0f; + + // Choose random starting angle and angular velocity + piece->angle = Rand_Next(); + piece->angVel = (Rand_Next() >> 4) + (0x10000 / 180); + + // Rotate the unit Z-vector by the random starting axis and angle + Matrix_RotateAxisS(piece->angle, &piece->rotAxis, MTXMODE_NEW); + Matrix_MultVec3f(&sUnitVecZ, &piece->normal); +} + +/** + * Main falling function for a single piece, handles dynamics. + * + * Position \f$ \mathbf{x} \f$ essentially satisfies discretised version of the equation + * + * \f[ + * \ddot{\mathbf{x}} = -0.2 \mathbf{n} (\dot{\mathbf{x}} + \mathbf{W}) + \mathbf{g} , + * \f] + * + * where + * + * - \f$ \mathbf{n} \f$ is the unit normal to the confetti triangle's plane + * - \f$ \mathbf{W} \f$ is the random wind pressure + * - \f$ \mathbf{g} \f$ is gravity + * + * and the product is componentwise: the normal is being used as a cross-sectional area measure rather than vectorially. + */ +void EnPaper_FlyConfettiPiece(EnPaper* this, EnPaperConfetto* piece) { + f32 cos = Math_CosS(piece->angle); + f32 sin = Math_SinS(piece->angle); + f32 versin = 1.0f - cos; + + if (piece->pos.y < (this->actor.floorHeight - 40.0f)) { + return; + } + + // acceleration due to gravity + piece->vel.y += this->actor.gravity; + + // drag and wind force: normal is used to simulate cross-section size of piece, although + piece->vel.x -= 0.2f * fabsf(piece->normal.x) * (piece->vel.x + this->windForce.x); + piece->vel.y -= 0.2f * fabsf(piece->normal.y) * (piece->vel.y + this->windForce.y); + piece->vel.z -= 0.2f * fabsf(piece->normal.z) * (piece->vel.z + this->windForce.z); + + // rotate around axis + piece->angle += piece->angVel; + + // move + piece->pos.x += piece->vel.x; + piece->pos.y += piece->vel.y; + piece->pos.z += piece->vel.z; + + // Rotate unit Z vector about `axis` by `angle` to get forward direction. This is the same calculation as at the + // bottom of EnPaper_InitConfettiPiece(), but done manually instead of using any matrix functions. + piece->normal.x = (versin * piece->rotAxis.x * piece->rotAxis.z) - (piece->rotAxis.y * sin); + piece->normal.y = (versin * piece->rotAxis.y * piece->rotAxis.z) + (piece->rotAxis.x * sin); + piece->normal.z = (versin * piece->rotAxis.z * piece->rotAxis.z) + cos; +} + +#define WIND_PITCH_BOUND (0x10000 / 12) + +/** + * Sets the wind force for the whole group, using the shape.rot from the previous frame, and picks a new random one + * for the next frame. + */ +void EnPaper_UpdateWind(EnPaper* this) { + f32 strength = (Rand_Centered() * 4.0f) + 6.0f; + f32 cosX; + + this->windForce.y = Math_SinS(this->actor.shape.rot.x) * -strength; + cosX = Math_CosS(this->actor.shape.rot.x) * -strength; + this->windForce.x = Math_SinS(this->actor.shape.rot.y) * cosX; + this->windForce.z = Math_CosS(this->actor.shape.rot.y) * cosX; + + // New random wind direction. A uniform distribution of the angles in spherical coordinates is not uniformly + // distributed on the sphere, so this is biased more towards up and down. + this->actor.shape.rot.x += (s16)(Rand_Next() >> 8); + this->actor.shape.rot.y += (s16)(Rand_Next() >> 6); + + // Essentially a clamp + if (ABS_ALT(this->actor.shape.rot.x) > WIND_PITCH_BOUND) { + if (this->actor.shape.rot.x > 0) { + this->actor.shape.rot.x = WIND_PITCH_BOUND; + } else { + this->actor.shape.rot.x = -WIND_PITCH_BOUND; + } + } +} + +void EnPaper_Update(Actor* thisx, PlayState* play) { + EnPaper* this = THIS; + + this->actionFunc(this, play); + EnPaper_UpdateWind(this); + + if (this->timer == 0) { + Actor_Kill(&this->actor); + return; + } + + this->timer--; +} + +void EnPaper_Draw(Actor* thisx, PlayState* play) { + EnPaper* this = THIS; + EnPaperConfetto* piece = this->pieces; + 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->pieces); i++, piece++) { + // colour the first 30 white and 10 each of the other 3 colours + 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) < piece->pos.y) { + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx)); + + Mtx_SetTranslationRotationScaleMtx(mtx, this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, + piece->angle, piece->rotAxis.x, piece->rotAxis.y, piece->rotAxis.z, + piece->pos.x, piece->pos.y, piece->pos.z); + + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gTingleConfettiDL); + } + } + + 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..a48c6ae88 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.h +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.h @@ -5,14 +5,25 @@ struct EnPaper; -typedef void (*EnPaperActionFunc)(struct EnPaper*, GlobalContext*); +typedef void (*EnPaperActionFunc)(struct EnPaper*, PlayState*); + +#define ENPAPER_PIECES_COUNT 60 + +typedef struct { + /* 0x00 */ Vec3f normal; // normal to the plane of the confetti piece + /* 0x0C */ Vec3f rotAxis; // axis to spin around + /* 0x18 */ Vec3f pos; + /* 0x24 */ Vec3f vel; + /* 0x30 */ s16 angle; // angle to rotate around `rotAxis` + /* 0x32 */ s16 angVel; // angular velocity of `angle` +} EnPaperConfetto; // size = 0x34 typedef struct EnPaper { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnPaperActionFunc actionFunc; - /* 0x0148 */ char unk_148[0xC40]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnPaperActionFunc actionFunc; + /* 0x148 */ EnPaperConfetto pieces[ENPAPER_PIECES_COUNT]; + /* 0xD78 */ Vec3f windForce; + /* 0xD84 */ s16 timer; } EnPaper; // size = 0xD88 -extern const ActorInit En_Paper_InitVars; - #endif // Z_EN_PAPER_H diff --git a/src/overlays/actors/ovl_En_Part/overlay.cfg b/src/overlays/actors/ovl_En_Part/overlay.cfg deleted file mode 100644 index 883554d5b..000000000 --- a/src/overlays/actors/ovl_En_Part/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Part -z_en_part.c 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..527a91b3d 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.c +++ b/src/overlays/actors/ovl_En_Part/z_en_part.c @@ -5,18 +5,21 @@ */ #include "z_en_part.h" +#include "overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h" #define FLAGS (ACTOR_FLAG_10) #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); -#if 0 -const ActorInit En_Part_InitVars = { +void func_80865390(EnPart* this, PlayState* play); +void func_808654C4(EnPart* this, PlayState* play); + +ActorInit En_Part_InitVars = { ACTOR_EN_PART, ACTORCAT_ITEMACTION, FLAGS, @@ -28,16 +31,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_Kill(&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, + DTBUBBLE_COLOR_PROFILE_RED, true); + } + break; + } + Actor_Kill(&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..662e8574e 100644 --- a/src/overlays/actors/ovl_En_Part/z_en_part.h +++ b/src/overlays/actors/ovl_En_Part/z_en_part.h @@ -5,12 +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; - #endif // Z_EN_PART_H diff --git a/src/overlays/actors/ovl_En_Peehat/overlay.cfg b/src/overlays/actors/ovl_En_Peehat/overlay.cfg deleted file mode 100644 index 588e53bd7..000000000 --- a/src/overlays/actors/ovl_En_Peehat/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Peehat -z_en_peehat.c 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 708bae3ef..3e2fdcfac 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -6,38 +6,39 @@ #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* play2); +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 = { +ActorInit En_Peehat_InitVars = { ACTOR_EN_PEEHAT, ACTORCAT_ENEMY, FLAGS, @@ -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); @@ -193,7 +194,7 @@ void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = -1000.0f; } Actor_SetScale(&this->actor, 0.036f); - this->actor.hintId = 0x48; + this->actor.hintId = TATL_HINT_ID_PEAHAT; func_80897498(this); } else { CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); @@ -204,19 +205,19 @@ void EnPeehat_Init(Actor* thisx, GlobalContext* globalCtx) { this->colliderCylinder.dim.radius = 20; this->colliderCylinder.dim.height = 15; this->colliderCylinder.dim.yShift = -5; - this->actor.hintId = 0x49; + this->actor.hintId = TATL_HINT_ID_PEAHAT_LARVA; this->colliderCylinder.base.ocFlags1 &= ~OC1_ON; func_80897A34(this); } } -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,12 +433,12 @@ 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); + Actor_Kill(&this->actor); } else if (this->colliderTris.base.atFlags & AT_HIT) { this->colliderTris.base.atFlags &= ~AT_HIT; if (BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.world.rot.y) > 0) { @@ -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,16 +579,16 @@ 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); - Actor_MarkForDeath(&this->actor); + 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_Kill(&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); - Actor_MarkForDeath(&this->actor); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xE0); + Actor_Kill(&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); } } @@ -788,8 +788,8 @@ 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); + thisx->flags |= ACTOR_FLAG_1000000; + 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,7 +839,7 @@ 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_Push(); @@ -852,20 +851,20 @@ s32 EnPeehat_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi 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_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,7 +874,7 @@ 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]; @@ -900,7 +899,7 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList 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_Translate(-1000.0f, 0.0f, 0.0f, MTXMODE_APPLY); @@ -909,26 +908,26 @@ void EnPeehat_PostLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Gfx** dList 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)) { @@ -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..248599c63 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; @@ -35,6 +35,4 @@ typedef struct EnPeehat { /* 0x488 */ ColliderTrisElement colliderTriElements[2]; } EnPeehat; // size = 0x540 -extern const ActorInit En_Peehat_InitVars; - #endif // Z_EN_PEEHAT_H diff --git a/src/overlays/actors/ovl_En_Pm/overlay.cfg b/src/overlays/actors/ovl_En_Pm/overlay.cfg deleted file mode 100644 index 43905ae8c..000000000 --- a/src/overlays/actors/ovl_En_Pm/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Pm -z_en_pm.c 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 bc41461d9..c2846a26b 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -12,13 +12,13 @@ #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); static u8 D_80AFAD80[] = { /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x240 - 0x005), @@ -132,7 +132,7 @@ static u8 D_80AFAD80[] = { /* 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), + /* 0x245 */ SCHEDULE_CMD_CHECK_FLAG_L(WEEKEVENTREG_28_08, 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), @@ -226,8 +226,8 @@ static u8 D_80AFAD80[] = { /* 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), + /* 0x419 */ SCHEDULE_CMD_CHECK_FLAG_L(WEEKEVENTREG_28_08, 0x55D - 0x41E), + /* 0x41E */ SCHEDULE_CMD_CHECK_FLAG_L(WEEKEVENTREG_28_10, 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), @@ -472,7 +472,7 @@ static UNK_TYPE D_80AFB764[] = { 0x52801210, }; -const ActorInit En_Pm_InitVars = { +ActorInit En_Pm_InitVars = { ACTOR_EN_PM, ACTORCAT_NPC, FLAGS, @@ -526,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 }, @@ -544,19 +544,19 @@ static AnimationInfoS sAnimations[] = { }; s32 func_80AF7B40(void) { - if (gSaveContext.save.weekEventReg[90] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_90_01)) { return 4; } - if (gSaveContext.save.weekEventReg[89] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_89_40)) { return 3; } - if (gSaveContext.save.weekEventReg[89] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_89_08)) { return 2; } - if (gSaveContext.save.weekEventReg[86] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_01)) { return 1; } @@ -566,28 +566,28 @@ s32 func_80AF7B40(void) { s32 func_80AF7BAC(EnPm* this) { switch (this->unk_38C) { case 0: - if (gSaveContext.save.weekEventReg[86] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_01)) { D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; case 1: - if (gSaveContext.save.weekEventReg[89] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_89_08)) { D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } break; case 2: - if (gSaveContext.save.weekEventReg[89] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_89_40)) { D_801F4E78 = 0; this->unk_38C++; } break; case 3: - if (gSaveContext.save.weekEventReg[90] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_90_01)) { D_801F4E78 = gSaveContext.save.time; this->unk_38C++; } @@ -597,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) { @@ -625,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) { @@ -654,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) { @@ -718,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; @@ -737,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: @@ -770,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; } @@ -818,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; @@ -833,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; @@ -843,10 +842,10 @@ s32 func_80AF81E8(EnPm* this, GlobalContext* globalCtx) { case 1: case 3: case 5: - if ((gSaveContext.save.weekEventReg[86] & 8) && (this->unk_378 == 3)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_86_08) && (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; @@ -861,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; @@ -876,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; @@ -886,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; @@ -903,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; @@ -928,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; @@ -960,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; } @@ -996,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; @@ -1016,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->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 9) && + (play->curSpawn == 1)) { if (!this->unk_380) { func_80AF7E98(this, 0); this->unk_258 = 255; @@ -1105,41 +1103,39 @@ void func_80AF8AC8(EnPm* this) { void func_80AF8BA8(s32 arg0) { static u16 D_80AFB8D4[] = { - 0x1B02, 0x1B04, 0x1B08, 0x1B10, 0x1B20, + WEEKEVENTREG_27_02, WEEKEVENTREG_27_04, WEEKEVENTREG_27_08, WEEKEVENTREG_27_10, WEEKEVENTREG_27_20, }; static u16 D_80AFB8E0[] = { - 0x1B40, 0x1B80, 0x1C01, 0x1C02, 0x1C04, + WEEKEVENTREG_27_40, WEEKEVENTREG_27_80, WEEKEVENTREG_28_01, WEEKEVENTREG_28_02, WEEKEVENTREG_28_04, }; - if (!(gSaveContext.save.weekEventReg[88] & 2)) { - if (gSaveContext.save.weekEventReg[D_80AFB8D4[arg0] >> 8] & - (D_80AFB8D4[arg0] & (1 | 2 | 4 | 0x38 | 0x40 | 0x80))) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_88_02)) { + if (CHECK_WEEKEVENTREG(D_80AFB8D4[arg0])) { switch (gSaveContext.save.day) { case 2: - gSaveContext.save.weekEventReg[28] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_28_08); break; case 3: - gSaveContext.save.weekEventReg[28] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_28_10); break; } - gSaveContext.save.weekEventReg[51] |= 2; - gSaveContext.save.weekEventReg[90] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_51_02); + SET_WEEKEVENTREG(WEEKEVENTREG_90_08); } } - gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8] = - ((void)0, gSaveContext.save.weekEventReg[D_80AFB8E0[arg0] >> 8]) | (u8)D_80AFB8E0[arg0]; + SET_WEEKEVENTREG(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->talkActor == &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 { @@ -1151,10 +1147,10 @@ void func_80AF8C68(EnPm* this, GlobalContext* globalCtx) { } Math_SmoothStepToF(&this->unk_364, this->unk_360, 0.8f, 40.0f, 10.0f); Matrix_Translate(this->unk_364, 0.0f, 0.0f, MTXMODE_APPLY); - this->unk_388 = sp28; + this->prevTalkState = talkState; } -s32 func_80AF8D84(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AF8D84(EnPm* this, PlayState* play) { switch (this->unk_384) { case 10: func_80AF7E98(this, 9); @@ -1167,38 +1163,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)) { + if (player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_400)) { 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, ScheduleResult* arg2, u8 actorCat, s16 actorId) { +s32 func_80AF8ED4(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput, u8 actorCat, s16 actorId) { u8 sp4F = this->actor.params & 0xFF; Vec3s* sp48; Vec3f sp3C; @@ -1207,17 +1203,17 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 s32 pad; s32 ret = false; - this->unk_234 = NULL; - sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); - if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); + 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); @@ -1228,7 +1224,7 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 return ret; } -s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = this->actor.params & 0xFF; EnDoor* door; @@ -1238,15 +1234,15 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s16 temp; s32 ret = false; - this->unk_234 = NULL; - door = func_80AF7D60(globalCtx, arg2->result); - if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); + 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); @@ -1260,10 +1256,10 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { this->unk_260 = 0x4B; } - this->unk_36C = arg2->time1 - arg2->time0; - this->unk_36E = sp56 - arg2->time0; + this->unk_36C = scheduleOutput->time1 - scheduleOutput->time0; + this->unk_36E = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_1; - if (gSaveContext.save.weekEventReg[90] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_90_08)) { this->unk_356 |= 0x800; } this->unk_356 |= 0x9000; @@ -1276,48 +1272,50 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80AF91E8(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = this->actor.params & 0xFF; - s32 pad; + u16 tmp; + s16 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; - if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); + 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->time0; + phi_v1 = scheduleOutput->time0; } - if (arg2->time1 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; + if (scheduleOutput->time1 < phi_v1) { + this->timePathTotalTime = (phi_v1 - scheduleOutput->time1) + 0xFFFF; } else { - this->unk_248 = arg2->time1 - 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->result) { + switch (scheduleOutput->result) { case 83: case 84: case 85: @@ -1341,7 +1339,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { default: SubS_UpdateFlags(&this->unk_356, 3, 7); func_80AF7E98(this, 0); - if (gSaveContext.save.weekEventReg[90] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_90_08)) { this->unk_356 |= 0x800; } this->unk_356 |= 0x9000; @@ -1356,7 +1354,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80AF94AC(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1364,23 +1362,23 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; - if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); + 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->result == 24) { - Flags_UnsetSwitch(globalCtx, 0); - Flags_UnsetSwitch(globalCtx, 1); - this->unk_394 = EXCH_ITEM_NONE; + if (scheduleOutput->result == 24) { + Flags_UnsetSwitch(play, 0); + Flags_UnsetSwitch(play, 1); + this->unk_394 = PLAYER_IA_NONE; this->unk_368 = 60.0f; func_80AF7E98(this, 9); } @@ -1389,7 +1387,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80AF95E8(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1398,13 +1396,13 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; s32 phi_a3 = -1; - switch (arg2->result) { + switch (scheduleOutput->result) { case 3: case 4: case 5: case 6: case 7: - phi_a3 = arg2->result - 3; + phi_a3 = scheduleOutput->result - 3; break; case 19: @@ -1412,29 +1410,29 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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->result]; + 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->result) { + 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); @@ -1457,13 +1455,13 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { break; case 23: - if (gSaveContext.save.weekEventReg[90] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_90_08)) { this->unk_356 |= 0x800; } - gSaveContext.save.weekEventReg[60] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_60_04); default: - if (arg2->result == 0x1D) { + if (scheduleOutput->result == 29) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } SubS_UpdateFlags(&this->unk_356, 3, 7); @@ -1476,18 +1474,18 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* 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) { - Actor_MarkForDeath(&this->actor); + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, -0x3F46, 0, + 0) != NULL) { + Actor_Kill(&this->actor); ret = true; } return ret; } -s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80AF992C(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { static Vec3f D_80AFB8EC = { 116.0f, 26.0f, -219.0f }; static Vec3s D_80AFB8F8 = { 0x0000, 0xC0BA, 0x0000 }; s32 pad; @@ -1499,7 +1497,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; - if (arg2->result == 14) { + if (scheduleOutput->result == 14) { this->unk_356 &= ~0x200; func_80AF7E98(this, 13); } else { @@ -1509,10 +1507,10 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return true; } -s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* 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; @@ -1527,10 +1525,10 @@ s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* 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; @@ -1545,10 +1543,10 @@ s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, ScheduleResult* 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; @@ -1563,34 +1561,34 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* 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 = EXCH_ITEM_NONE; + this->unk_394 = PLAYER_IA_NONE; this->unk_356 = 0; this->unk_368 = 40.0f; - switch (arg2->result) { + 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: @@ -1605,7 +1603,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { case 35: case 36: case 37: - ret = func_80AF9008(this, globalCtx, arg2); + ret = func_80AF9008(this, play, scheduleOutput); break; case 3: @@ -1618,11 +1616,11 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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: @@ -1630,7 +1628,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { case 20: case 21: case 22: - ret = func_80AF992C(this, globalCtx, arg2); + ret = func_80AF992C(this, play, scheduleOutput); break; case 38: @@ -1687,7 +1685,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { case 89: case 90: case 91: - ret = func_80AF91E8(this, globalCtx, arg2); + ret = func_80AF91E8(this, play, scheduleOutput); break; default: @@ -1697,13 +1695,13 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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 (!SubS_InCsMode(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; @@ -1717,7 +1715,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); } @@ -1725,78 +1723,78 @@ 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 (SubS_InCsMode(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 (SubS_InCsMode(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); } if ((this->unk_356 & 0x10) && (this->unk_258 == 90)) { - u8 val = gSaveContext.save.weekEventReg[89] | 0x40; - - gSaveContext.save.weekEventReg[89] = val; - if (val == 0) { - gSaveContext.save.weekEventReg[89] |= 0x40; + //! @bug Uses SET_WEEKEVENTREG instead of CHECK_WEEKEVENTREG + if (!SET_WEEKEVENTREG(WEEKEVENTREG_89_40)) { + SET_WEEKEVENTREG(WEEKEVENTREG_89_40); } } return false; } -s32 func_80AFA170(EnPm* this, GlobalContext* globalCtx) { +s32 func_80AFA170(EnPm* this, PlayState* play) { Vec3f sp34; Vec3f sp28; switch (this->unk_258) { case 28: if (gSaveContext.save.time >= CLOCK_TIME(1, 39)) { - gSaveContext.save.weekEventReg[89] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_89_08); } case 16: @@ -1842,7 +1840,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) { @@ -1858,7 +1856,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; @@ -1878,7 +1876,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: @@ -1889,7 +1887,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: @@ -1904,7 +1902,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: @@ -1917,7 +1915,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: @@ -1974,30 +1972,30 @@ 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) { +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; - ScheduleResult sp2C; + ScheduleOutput sp2C; - this->unk_374 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); if (this->unk_38C != 0) { time = gSaveContext.save.time - D_801F4E78; sp3C = gSaveContext.save.time; gSaveContext.save.time = time; } - if (!Schedule_RunScript(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || - ((this->unk_258 != sp2C.result) && !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.result = 0; @@ -2007,19 +2005,19 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { } this->unk_258 = sp2C.result; - this->unk_268 = func_80AF8040(this, globalCtx); - func_80AFA438(this, globalCtx); + 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; @@ -2042,73 +2040,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; @@ -2119,7 +2116,7 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec 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)) { + if ((this->unk_356 & 0x8000) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_90_04)) { func_80AF8890(this, gfx, 1); } break; @@ -2143,7 +2140,7 @@ void EnPm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx, Gfx** gfx) { +void EnPm_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx, Gfx** gfx) { EnPm* this = THIS; s32 stepRot; s32 overrideRot; @@ -2173,7 +2170,7 @@ void EnPm_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* this } } -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, @@ -2182,18 +2179,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..c7bf76e37 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -5,59 +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; - #endif // Z_EN_PM_H diff --git a/src/overlays/actors/ovl_En_Po_Composer/overlay.cfg b/src/overlays/actors/ovl_En_Po_Composer/overlay.cfg deleted file mode 100644 index 25791e887..000000000 --- a/src/overlays/actors/ovl_En_Po_Composer/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Po_Composer -z_en_po_composer.c 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..6d14ca25a 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,25 +10,25 @@ #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 = { +ActorInit En_Po_Composer_InitVars = { ACTOR_EN_PO_COMPOSER, ACTORCAT_ITEMACTION, FLAGS, @@ -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..a42b5048f 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,15 +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; - #endif // Z_EN_PO_COMPOSER_H diff --git a/src/overlays/actors/ovl_En_Po_Fusen/overlay.cfg b/src/overlays/actors/ovl_En_Po_Fusen/overlay.cfg deleted file mode 100644 index 71a747b65..000000000 --- a/src/overlays/actors/ovl_En_Po_Fusen/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Po_Fusen -z_en_po_fusen.c 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 42fd2b418..a9fcf95e3 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,24 +12,20 @@ #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 = { +ActorInit En_Po_Fusen_InitVars = { ACTOR_EN_PO_FUSEN, ACTORCAT_PROP, FLAGS, @@ -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,18 +100,18 @@ 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) { - Actor_MarkForDeath(&this->actor); + if (!EnPoFusen_CheckParent(this, play)) { + Actor_Kill(&this->actor); } heightTemp = this->actor.floorHeight + 90.0f; @@ -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); + Actor_Kill(&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; @@ -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..740d65968 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; @@ -27,6 +30,4 @@ typedef struct EnPoFusen { /* 0x270 */ s16 fuse; } EnPoFusen; // size = 0x274 -extern const ActorInit En_Po_Fusen_InitVars; - #endif // Z_EN_PO_FUSEN_H diff --git a/src/overlays/actors/ovl_En_Po_Sisters/overlay.cfg b/src/overlays/actors/ovl_En_Po_Sisters/overlay.cfg deleted file mode 100644 index 7c59c1704..000000000 --- a/src/overlays/actors/ovl_En_Po_Sisters/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Po_Sisters -z_en_po_sisters.c 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 bb128935d..a89a55d9e 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,68 +1,67 @@ /* * 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 = { +ActorInit En_Po_Sisters_InitVars = { ACTOR_EN_PO_SISTERS, ACTORCAT_ENEMY, FLAGS, @@ -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 + TATL_HINT_ID_POE_SISTER_MEG; + 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) { // An else would be sufficient - 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,712 @@ 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) { - Actor_MarkForDeath(&this->actor); - } else { - func_80B1A648(this, this->unk_192, &this->actor.world.pos); +void EnPoSisters_DeathStage2(EnPoSisters* this, PlayState* play) { + this->deathTimer++; + + if (this->deathTimer == 32) { + Actor_Kill(&this->actor); + return; + } + + EnPoSisters_UpdateDeathFlameSwirl(this, this->deathTimer, &this->actor.world.pos); +} + +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 we cannot spawn all clones: abort + if ((clone1 == NULL) || (clone2 == NULL) || (clone3 == NULL)) { + if (clone1 != NULL) { + Actor_Kill(clone1); + } + if (clone2 != NULL) { + Actor_Kill(clone2); + } + if (clone3 != NULL) { + Actor_Kill(clone3); + } + Actor_Kill(&this->actor); } } -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); - - if ((sp4C == NULL) || (sp48 == NULL) || (sp44 == NULL)) { - if (sp4C != NULL) { - Actor_MarkForDeath(sp4C); - } - - if (sp48 != NULL) { - Actor_MarkForDeath(sp48); - } - - if (sp44 != NULL) { - Actor_MarkForDeath(sp44); - } - 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) { - Actor_MarkForDeath(&this->actor); + EnPoSisters_SetupSpinBackToVisible(this, play); + + } else if (parent->actionFunc == EnPoSisters_DeathStage1) { + Actor_Kill(&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 +998,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 +1086,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) { + if (D_80B1DB08[limbIndex] != POSISTER_LIMBPOS_INVALID) { Matrix_MultZero(&this->limbPos[D_80B1DB08[limbIndex]]); - } else if (limbIndex == 9) { + } else if (limbIndex == POSISTERS_LIMB_MAIN_BODY) { Matrix_MultVecY(-2500.0f, &this->limbPos[4]); Matrix_MultVecY(3000.0f, &this->limbPos[5]); - } else if (limbIndex == 10) { + } else if (limbIndex == POSISTERS_LIMB_FACE) { Matrix_MultVecY(-4000.0f, &this->limbPos[6]); - } else if (limbIndex == 11) { + } 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_MultVec3f(&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_Get(&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_Put(&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_Translate(this->unk_22C[i].x, this->unk_22C[i].y, this->unk_22C[i].z, MTXMODE_NEW); - Matrix_RotateZYX(0, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), 0, MTXMODE_APPLY); + 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..5e549c4d7 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,44 +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; - #endif // Z_EN_PO_SISTERS_H diff --git a/src/overlays/actors/ovl_En_Poh/overlay.cfg b/src/overlays/actors/ovl_En_Poh/overlay.cfg deleted file mode 100644 index d83d8bd2f..000000000 --- a/src/overlays/actors/ovl_En_Poh/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Poh -z_en_poh.c 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 478c306b0..f1b0f74d4 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.c +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.c @@ -11,42 +11,42 @@ #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* play2); +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 = { +ActorInit En_Poh_InitVars = { ACTOR_EN_POH, ACTORCAT_ENEMY, FLAGS, @@ -101,7 +101,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -143,44 +143,44 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 3, 25, 50, 50 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 68, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_POE, ICHAIN_CONTINUE), 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); @@ -388,12 +388,12 @@ void func_80B2D2C0(EnPoh* this) { this->actor.speedXZ = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; this->unk_18E = 0; - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; this->actor.flags &= ~ACTOR_FLAG_1; 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,7 +563,7 @@ 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; @@ -576,20 +576,19 @@ void func_80B2DC50(EnPoh* this, GlobalContext* globalCtx) { 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,10 +650,10 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (Actor_HasParent(&this->actor, play)) { + Actor_Kill(&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); + Actor_Kill(&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); } @@ -889,7 +887,7 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve MTXMODE_APPLY); } Matrix_Get(&this->unk_3D8); - func_80B2C910(&sp60, globalCtx); + 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, @@ -917,11 +915,11 @@ void EnPoh_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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; @@ -954,21 +952,21 @@ void EnPoh_Draw(Actor* thisx, GlobalContext* globalCtx) { 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,28 +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_RotateYF((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..b07be6195 100644 --- a/src/overlays/actors/ovl_En_Poh/z_en_poh.h +++ b/src/overlays/actors/ovl_En_Poh/z_en_poh.h @@ -5,38 +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; - #endif // Z_EN_POH_H diff --git a/src/overlays/actors/ovl_En_Pp/overlay.cfg b/src/overlays/actors/ovl_En_Pp/overlay.cfg deleted file mode 100644 index 3cca2c18d..000000000 --- a/src/overlays/actors/ovl_En_Pp/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Pp -z_en_pp.c 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..fad487e62 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.c +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.c @@ -5,54 +5,117 @@ */ #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 = { +ActorInit En_Pp_InitVars = { ACTOR_EN_PP, ACTORCAT_ENEMY, FLAGS, @@ -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_Kill(&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 (!CHECK_FLAG_ALL(this->actor.flags, 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_Kill(&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_Kill(&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->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 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..aabbd9e2e 100644 --- a/src/overlays/actors/ovl_En_Pp/z_en_pp.h +++ b/src/overlays/actors/ovl_En_Pp/z_en_pp.h @@ -2,18 +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 bodyPartsPosIndex; + /* 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; - #endif // Z_EN_PP_H diff --git a/src/overlays/actors/ovl_En_Pr/overlay.cfg b/src/overlays/actors/ovl_En_Pr/overlay.cfg deleted file mode 100644 index efb1dfb56..000000000 --- a/src/overlays/actors/ovl_En_Pr/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Pr -z_en_pr.c 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 8f3a30d75..5068c96ee 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* play2); +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), @@ -68,7 +68,7 @@ static DamageTable sDamageTable = { f32 D_80A338C0[PLAYER_FORM_MAX] = { 30.0f, 30.0f, 30.0f, 15.0f, 15.0f }; -const ActorInit En_Pr_InitVars = { +ActorInit En_Pr_InitVars = { ACTOR_EN_PR, ACTORCAT_ENEMY, FLAGS, @@ -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; @@ -118,9 +118,9 @@ void EnPr_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actor.colChkInfo.health = 3; this->actor.colChkInfo.mass = 50; - this->actor.hintId = 0x5C; + this->actor.hintId = TATL_HINT_ID_DESBREKO; - 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; @@ -262,7 +262,7 @@ void func_80A32740(EnPr* this, GlobalContext* globalCtx) { if (this->unk_2C8 < sqrtf(SQ(this->actor.world.pos.x - this->actor.home.pos.x) + SQ(this->actor.world.pos.z - this->actor.home.pos.z))) { func_80A32854(this); - } else if ((this->unk_20E == 0) && (player->stateFlags1 & 0x8000000)) { + } else if ((this->unk_20E == 0) && (player->stateFlags1 & PLAYER_STATE1_8000000)) { if (sqrtf(SQ(player->actor.world.pos.x - this->actor.home.pos.x) + SQ(player->actor.world.pos.z - this->actor.home.pos.z)) < this->unk_2C8) { func_80A32AF8(this); @@ -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)) { + if ((player->stateFlags1 & PLAYER_STATE1_8000000) && (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,15 +340,15 @@ 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); + this->unk_2B8 = D_80A338C0[GET_PLAYER_FORM] + player->actor.world.pos.y; + func_80A324E0(this, play); - if (!(player->stateFlags1 & 0x8000000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_8000000)) { this->skelAnime.playSpeed = 1.0f; this->actor.speedXZ = 1.0f; func_80A32854(this); @@ -372,18 +372,18 @@ 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)) { + if (!(player->stateFlags1 & PLAYER_STATE1_8000000)) { this->skelAnime.playSpeed = 1.0f; this->actor.speedXZ = 1.0f; func_80A32854(this); } else { Math_SmoothStepToS(&this->unk_22C, this->actor.yawTowardsPlayer, BREG(49) + 1, BREG(50) + 1000, BREG(51)); func_80A325E4(this); - this->unk_2B8 = D_80A338C0[(void)0, gSaveContext.save.playerForm] + player->actor.world.pos.y; - func_80A324E0(this, globalCtx); + this->unk_2B8 = D_80A338C0[GET_PLAYER_FORM] + player->actor.world.pos.y; + 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); @@ -445,13 +445,13 @@ void func_80A32F48(EnPr* this, GlobalContext* globalCtx) { if (this->unk_2D2 != 0) { Math_SmoothStepToS(&this->unk_2D0, 0, 1, 15, 50); if (this->unk_2D0 < 2) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } -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,11 +459,11 @@ 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)) { + if ((player->stateFlags1 & PLAYER_STATE1_8000000) && (this->actor.colChkInfo.damageEffect == 5)) { this->drawDmgEffAlpha = 40; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; } @@ -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,7 +569,7 @@ 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; @@ -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..dfa3081ca 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,47 +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; - #endif // Z_EN_PR_H diff --git a/src/overlays/actors/ovl_En_Pr2/overlay.cfg b/src/overlays/actors/ovl_En_Pr2/overlay.cfg deleted file mode 100644 index 11a975ed0..000000000 --- a/src/overlays/actors/ovl_En_Pr2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Pr2 -z_en_pr2.c 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 797433892..0cc6dc134 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), @@ -81,7 +81,7 @@ static ColliderCylinderInit sCylinderInit = { { 17, 32, -10, { 0, 0, 0 } }, }; -const ActorInit En_Pr2_InitVars = { +ActorInit En_Pr2_InitVars = { ACTOR_EN_PR2, ACTORCAT_ENEMY, FLAGS, @@ -99,22 +99,22 @@ 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; - this->actor.hintId = 0x5B; + this->actor.hintId = TATL_HINT_ID_SKULLFISH; this->unk_1EC = 255; 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; @@ -160,7 +160,7 @@ void EnPr2_Init(Actor* thisx, GlobalContext* globalCtx) { } func_80A745C4(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } else { @@ -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); + Actor_Kill(&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,19 +194,19 @@ 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)) { return false; } - if (!(player->stateFlags1 & 0x8000000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_8000000)) { return false; } else { return true; @@ -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; @@ -277,7 +277,7 @@ void func_80A745FC(EnPr2* this, GlobalContext* globalCtx) { } if ((this->path != NULL) && !SubS_CopyPointFromPath(this->path, this->unk_1D0, &this->unk_21C)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } Math_ApproachF(&this->actor.world.pos.y, this->unk_21C.y, 0.3f, 5.0f); @@ -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; @@ -337,15 +337,15 @@ void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); if (this->unk_1F4 < 2) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else { switch (this->unk_1E0) { case 1: if (this->unk_1DC == 0) { sp4C = true; - func_80A74DEC(this, globalCtx); - } else if (!func_80A7429C(this, globalCtx) && (this->unk_1F4 == 255)) { + func_80A74DEC(this, play); + } else if (!func_80A7429C(this, play) && (this->unk_1F4 == 255)) { this->unk_1F4 = 254; } break; @@ -356,9 +356,9 @@ void func_80A748E8(EnPr2* this, GlobalContext* globalCtx) { temp_f12 = player->actor.world.pos.z - this->unk_228.z; sqrtXZ = sqrtf(SQ(temp_f2) + SQ(temp_f12)); - if (sp48 && (player->stateFlags1 & 0x8000000) && (sqrtXZ < this->unk_208)) { + if (sp48 && (player->stateFlags1 & PLAYER_STATE1_8000000) && (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,12 +441,12 @@ 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); - if ((this->unk_1D8 == 0) || !(player->stateFlags1 & 0x8000000) || (this->unk_1E0 == 0)) { + if ((this->unk_1D8 == 0) || !(player->stateFlags1 & PLAYER_STATE1_8000000) || (this->unk_1E0 == 0)) { func_80A74888(this); return; } @@ -455,7 +455,7 @@ void func_80A74E90(EnPr2* this, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; Math_SmoothStepToS(&this->unk_1F4, 0, 1, 30, 100); if (this->unk_1F4 < 2) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else { SkelAnime_Update(&this->skelAnime); @@ -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,12 +553,12 @@ 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); } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } else { @@ -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,27 +598,27 @@ 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); + Actor_Kill(&this->actor); } } } } -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,7 +706,7 @@ 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) { @@ -717,8 +718,7 @@ void func_80A75950(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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..617a5cc73 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h @@ -5,52 +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; - #endif // Z_EN_PR2_H diff --git a/src/overlays/actors/ovl_En_Prz/overlay.cfg b/src/overlays/actors/ovl_En_Prz/overlay.cfg deleted file mode 100644 index dc79492a0..000000000 --- a/src/overlays/actors/ovl_En_Prz/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Prz -z_en_prz.c 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 99cc24158..dad8fc126 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), @@ -82,7 +82,7 @@ static ColliderCylinderInit sCylinderInit = { { 10, 10, 0, { 0, 0, 0 } }, }; -const ActorInit En_Prz_InitVars = { +ActorInit En_Prz_InitVars = { ACTOR_EN_PRZ, ACTORCAT_ENEMY, FLAGS, @@ -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; @@ -110,11 +110,11 @@ void EnPrz_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.targetMode = 3; this->unk_1E8 = 255; - this->actor.hintId = 0x5B; + this->actor.hintId = TATL_HINT_ID_SKULLFISH; 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; @@ -234,13 +234,13 @@ void func_80A763E8(EnPrz* this, GlobalContext* globalCtx) { return; } - if ((player->stateFlags1 & 0x8000000) && (this->unk_1F2 == 0)) { + if ((player->stateFlags1 & PLAYER_STATE1_8000000) && (this->unk_1F2 == 0)) { func_80A76748(this); return; } - if (func_80A762C0(this, globalCtx)) { - func_80A76604(this, globalCtx); + if (func_80A762C0(this, play)) { + func_80A76604(this, play); return; } @@ -272,26 +272,26 @@ 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)) { + } else if ((player->stateFlags1 & PLAYER_STATE1_8000000) && (player->actor.floorHeight < 30.0f)) { this->actionFunc = func_80A763E8; } else { this->unk_1EE = 10; @@ -309,23 +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 distXZ; s32 pad[2]; - 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; } distXZ = sqrtf(SQ(player->actor.world.pos.x - this->actor.parent->home.pos.x) + SQ(player->actor.world.pos.z - this->actor.parent->home.pos.z)); - if (!(player->stateFlags1 & 0x8000000) || (pr->unk_2C8 < distXZ)) { + if (!(player->stateFlags1 & PLAYER_STATE1_8000000) || (pr->unk_2C8 < distXZ)) { this->unk_1F2 = 100; this->skelAnime.playSpeed = 1.0f; func_80A76388(this); @@ -353,9 +353,9 @@ void func_80A767A8(EnPrz* this, GlobalContext* globalCtx) { this->unk_1C8 = 1; } - this->unk_1D8.y = (player->actor.world.pos.y + D_80A771E0[((void)0, gSaveContext.save.playerForm)]) + + this->unk_1D8.y = (player->actor.world.pos.y + D_80A771E0[GET_PLAYER_FORM]) + randPlusMinusPoint5Scaled((2.0f * this->unk_1E6) + 1.0f); - func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), globalCtx); + func_80A76070(this, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_1D8), play); } void func_80A76A1C(EnPrz* this) { @@ -383,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; @@ -393,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 { @@ -413,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); + Actor_Kill(&this->actor); } } } -void EnPrz_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnPrz_Update(Actor* thisx, PlayState* play) { s32 pad; EnPrz* this = THIS; s32 sp44 = false; @@ -430,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--; @@ -441,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); @@ -464,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); @@ -475,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) { @@ -489,7 +489,7 @@ 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; @@ -499,29 +499,29 @@ void func_80A76FCC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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..db91c7c03 100644 --- a/src/overlays/actors/ovl_En_Prz/z_en_prz.h +++ b/src/overlays/actors/ovl_En_Prz/z_en_prz.h @@ -5,43 +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; - #endif // Z_EN_PRZ_H diff --git a/src/overlays/actors/ovl_En_Pst/overlay.cfg b/src/overlays/actors/ovl_En_Pst/overlay.cfg deleted file mode 100644 index 857d2ee7e..000000000 --- a/src/overlays/actors/ovl_En_Pst/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Pst -z_en_pst.c 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..c49852746 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.c +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.c @@ -10,16 +10,115 @@ #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); -#if 0 -const ActorInit En_Pst_InitVars = { +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 }; + +ActorInit En_Pst_InitVars = { ACTOR_EN_PST, ACTORCAT_PROP, FLAGS, @@ -31,51 +130,314 @@ 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 CHECK_WEEKEVENTREG(WEEKEVENTREG_27_02); + case POSTBOX_NORTH_CLOCKTOWN: + return CHECK_WEEKEVENTREG(WEEKEVENTREG_27_04); + case POSTBOX_EAST_UPPER_CLOCKTOWN: + return CHECK_WEEKEVENTREG(WEEKEVENTREG_27_08); + case POSTBOX_EAST_LOWER_CLOCKTOWN: + return CHECK_WEEKEVENTREG(WEEKEVENTREG_27_10); + case POSTBOX_SOUTH_LOWER_CLOCKTOWN: + return CHECK_WEEKEVENTREG(WEEKEVENTREG_27_20); + 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 CHECK_WEEKEVENTREG(WEEKEVENTREG_27_40); + case POSTBOX_NORTH_CLOCKTOWN: + return CHECK_WEEKEVENTREG(WEEKEVENTREG_27_80); + case POSTBOX_EAST_UPPER_CLOCKTOWN: + return CHECK_WEEKEVENTREG(WEEKEVENTREG_28_01); + case POSTBOX_EAST_LOWER_CLOCKTOWN: + return CHECK_WEEKEVENTREG(WEEKEVENTREG_28_02); + case POSTBOX_SOUTH_LOWER_CLOCKTOWN: + return CHECK_WEEKEVENTREG(WEEKEVENTREG_28_04); + default: + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/func_80B2B874.s") +s32 EnPst_ChooseBehaviour(Actor* thisx, PlayState* play) { + PlayerItemAction itemAction = PLAYER_IA_NONE; + 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: + itemAction = func_80123810(play); + scriptBranch = 0; + if ((itemAction == PLAYER_IA_LETTER_TO_KAFEI) || (itemAction == PLAYER_IA_LETTER_MAMA)) { + this->exchangeItemId = itemAction; + this->behaviour++; + scriptBranch = 1; + } else if (itemAction <= PLAYER_IA_MINUS1) { + this->behaviour++; + scriptBranch = 3; + } else if (itemAction != PLAYER_IA_NONE) { + this->behaviour++; + scriptBranch = 2; + } + } + break; + } + break; + case POSTBOX_BEHAVIOUR_TAKE_ITEM: + if (this->exchangeItemId == PLAYER_IA_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_IA_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_IA_LETTER_TO_KAFEI) { + this->stateFlags |= 0x10; + this->exchangeItemId = player->exchangeItemId; + } else if (player->exchangeItemId != PLAYER_IA_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: + SET_WEEKEVENTREG(WEEKEVENTREG_91_04); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Pst/EnPst_Draw.s") + case 2: + if (EnPst_HandleLetterDay2(this)) { + SET_WEEKEVENTREG(WEEKEVENTREG_91_08); + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_91_04); + } + break; + + default: + SET_WEEKEVENTREG(WEEKEVENTREG_91_08); + 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..6051924da 100644 --- a/src/overlays/actors/ovl_En_Pst/z_en_pst.h +++ b/src/overlays/actors/ovl_En_Pst/z_en_pst.h @@ -2,18 +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; - #endif // Z_EN_PST_H diff --git a/src/overlays/actors/ovl_En_Racedog/overlay.cfg b/src/overlays/actors/ovl_En_Racedog/overlay.cfg deleted file mode 100644 index 6461b9ff5..000000000 --- a/src/overlays/actors/ovl_En_Racedog/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Racedog -z_en_racedog.c 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 cf6b1d63f..0caa2f8ca 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.c @@ -15,26 +15,28 @@ #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); +//! TODO: this file require macros for its uses of weekEventReg -void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx); -void EnRacedog_Race(EnRacedog* this, 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 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, GlobalContext* globalCtx); -void EnRacedog_PlayWalkSfx(EnRacedog* this); +s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates); +void EnRacedog_SpawnFloorDustRing(EnRacedog* this, PlayState* play); +void EnRacedog_PlaySfxWalk(EnRacedog* this); /** - * Dogs can be in three conditions, which is indicated by the message it says when - * you pick it up prior to entering the race. + * Dogs can be in three conditions, which is, for the most part, indicated by the + * message it says when you pick it up prior to entering the race. * If it starts with "Ruff!", it's in good condition. * If it starts with "Rrr-Ruff!", it's in normal condition. * If it starts with "Hoo-whine", it's in bad condition. @@ -42,30 +44,21 @@ void EnRacedog_PlayWalkSfx(EnRacedog* this); * - 0x3538 - 0x353D: Good condition * - 0x353E - 0x3541: Normal condition * - 0x3542 - 0x3546: Bad condition + * + * There are two caveats, though, that are useful to keep in mind: + * - Because of differences between how EnDg computes the text ID and how EnRacedog + * computes it, there are two dogs whose text upon picking them up does not + * accurately reflect their condition during the race. Check the comment above + * EnRacedog_UpdateTextId for more information on this phenomenon. + * - Note that text ID 0x353D is actually used for the Romani Ranch dog; its text + * just so happens to be in the middle of the race dog text block. In EnDg, the + * dog that gets this text ID will instead use text ID 0x3538 when the player + * picks it up. Since EnRacedog cannot be picked up, however, it can use 0x353D + * as an additional good condition text ID. */ #define DOG_IS_IN_GOOD_CONDITION(this) (sDogInfo[this->index].textId < 0x353E) #define DOG_IS_IN_BAD_CONDITION(this) (sDogInfo[this->index].textId >= 0x3542) -typedef enum { - /* 0 */ RACEDOG_ANIMATION_IDLE, - /* 1 */ RACEDOG_ANIMATION_WALK_1, - /* 2 */ RACEDOG_ANIMATION_RUN, - /* 3 */ RACEDOG_ANIMATION_BARK, - /* 4 */ RACEDOG_ANIMATION_SIT_DOWN_1, - /* 5 */ RACEDOG_ANIMATION_SIT_DOWN_2, - /* 6 */ RACEDOG_ANIMATION_LYING_DOWN_START_1, - /* 7 */ RACEDOG_ANIMATION_LYING_DOWN_LOOP, - /* 8 */ RACEDOG_ANIMATION_LYING_DOWN_START_2, - /* 9 */ RACEDOG_ANIMATION_LYING_DOWN_START_3, - /* 10 */ RACEDOG_ANIMATION_LYING_DOWN_START_4, - /* 11 */ RACEDOG_ANIMATION_WALK_2, - /* 12 */ RACEDOG_ANIMATION_JUMP, - /* 13 */ RACEDOG_ANIMATION_LONG_JUMP, - /* 14 */ RACEDOG_ANIMATION_JUMP_2, - /* 15 */ RACEDOG_ANIMATION_WALK_3, - /* 16 */ RACEDOG_ANIMATION_MAX -} RacedogAnimationIndex; - /** * Stores various information for each dog in the race, mostly related to speed. */ @@ -78,7 +71,7 @@ typedef struct { s16 textId; // Used to determine the dog's condition } RaceDogInfo; -const ActorInit En_Racedog_InitVars = { +ActorInit En_Racedog_InitVars = { ACTOR_EN_RACEDOG, ACTORCAT_NPC, FLAGS, @@ -212,7 +205,27 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS sAnimations[] = { +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 }, @@ -220,17 +233,17 @@ 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 EnRacedog_ChangeAnimation(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 index) { +void EnRacedog_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 animIndex) { f32 frameCount; - animationInfo += index; + animationInfo += animIndex; if (animationInfo->frameCount < 0) { frameCount = Animation_GetLastFrame(animationInfo->animation); } else { @@ -241,12 +254,12 @@ void EnRacedog_ChangeAnimation(SkelAnime* skelAnime, AnimationInfoS* animationIn animationInfo->startFrame, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void EnRacedog_UpdateCollision(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); } /** @@ -255,27 +268,27 @@ void EnRacedog_UpdateCollision(EnRacedog* this, GlobalContext* globalCtx) { */ s16 EnRacedog_GetYRotation(Path* path, s32 pointIndex, Vec3f* pos, f32* distSQ) { Vec3s* point; - f32 xDiffRand; - f32 zDiffRand; - f32 xDiff; - f32 zDiff; + f32 diffXRand; + f32 diffZRand; + f32 diffX; + f32 diffZ; if (path != NULL) { point = Lib_SegmentedToVirtual(path->points); point = &point[pointIndex]; - xDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; - zDiffRand = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; - xDiff = point->x - pos->x; - zDiff = point->z - pos->z; + diffXRand = (randPlusMinusPoint5Scaled(100.0f) + point->x) - pos->x; + diffZRand = (randPlusMinusPoint5Scaled(100.0f) + point->z) - pos->z; + diffX = point->x - pos->x; + diffZ = point->z - pos->z; } else { - xDiffRand = 0.0f; - zDiffRand = 0.0f; - xDiff = 0.0f; - zDiff = 0.0f; + diffXRand = 0.0f; + diffZRand = 0.0f; + diffX = 0.0f; + diffZ = 0.0f; } - *distSQ = SQ(xDiff) + SQ(zDiff); - return RADF_TO_BINANG(Math_Acot2F(zDiffRand, xDiffRand)); + *distSQ = SQ(diffX) + SQ(diffZ); + return RADF_TO_BINANG(Math_Atan2F_XY(diffZRand, diffXRand)); } void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { @@ -286,28 +299,28 @@ void EnRacedog_GetFloorRot(EnRacedog* this, Vec3f* floorRot) { ny = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.y); nz = COLPOLY_GET_NORMAL(this->actor.floorPoly->normal.z); - floorRot->x = -Math_Acot2F(1.0f, -nz * ny); + floorRot->x = -Math_Atan2F_XY(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->path = 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_INDEX(&this->actor) < 14) { this->index = ENRACEDOG_GET_INDEX(&this->actor); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } this->selectionArrowGreenPrimColor = 255; @@ -343,29 +356,29 @@ void EnRacedog_Init(Actor* thisx, GlobalContext* globalCtx) { sSelectedDogInfo = sDogInfo[(s16)((gSaveContext.eventInf[0] & 0xF8) >> 3)]; this->selectedDogIndex = sSelectedDogInfo.index; - EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_IDLE); - sAnimations[RACEDOG_ANIMATION_IDLE].playSpeed = Rand_ZeroFloat(0.5f) + 1.0f; + 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); } /** * This function makes the dog wait at the starting line until the race actually begins. * It's also responsible for playing the starting shot sound once the race begins. */ -void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx) { +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); } - EnRacedog_ChangeAnimation(&this->skelAnime, sAnimations, RACEDOG_ANIMATION_RUN); + EnRacedog_ChangeAnim(&this->skelAnime, sAnimationInfo, RACEDOG_ANIM_RUN); this->actionFunc = EnRacedog_Race; } } @@ -373,7 +386,7 @@ void EnRacedog_RaceStart(EnRacedog* this, GlobalContext* globalCtx) { /** * This function handles the dog's behavior and state for the entire time the race is going. */ -void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_Race(EnRacedog* this, PlayState* play) { s16 yRotation; f32 distSq; @@ -409,26 +422,34 @@ void EnRacedog_Race(EnRacedog* this, GlobalContext* globalCtx) { } EnRacedog_UpdateRunAnimationPlaySpeed(this); - EnRacedog_PlayWalkSfx(this); - EnRacedog_SpawnFloorDustRing(this, globalCtx); + EnRacedog_PlaySfxWalk(this); + EnRacedog_SpawnFloorDustRing(this, play); } /** * Updates the text ID in sDogInfo based on what was set in the weekEventRegs by * En_Aob_01. This makes it so sDogInfo can be used in other functions to determine * the condition of the dog. + * + * Note that the text IDs generated by this function are off-by-one compared to the + * similar function in EnDg. The end result of this is that one of the dogs that says + * it's in good condition when you pick it up is actually in normal condition once the + * race starts, and one of the dogs that says it's in normal condition when you pick + * it up is actually in bad condition. It's unknown whether this is a simple oversight + * or an intentional choice to introduce a bit of extra variance to the race. */ void EnRacedog_UpdateTextId(EnRacedog* this) { + // Assuming that the weekEventRegs haven't been tampered with, then this will produce a text ID in the + // range of 0x3539 to 0x3546. if (this->index % 2) { sDogInfo[this->index].textId = - (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (0x10 | 0x20 | 0x40 | 0x80)) >> 4) + 0x3539; + (((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & 0xF0) >> 4) + 0x3539; } else { - sDogInfo[this->index].textId = - ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & (1 | 2 | 4 | 8)) + 0x3539; + sDogInfo[this->index].textId = ((gSaveContext.save.weekEventReg[42 + (this->index / 2)]) & 0x0F) + 0x3539; } - // This makes sure the text ID is something in the range of 0x3539 to 0x3547. - if ((sDogInfo[this->index].textId >= 0x3547) || (sDogInfo[this->index].textId < 0x3539)) { + // As a sanity check, this makes sure the text ID is something in the expected range of 0x3539 to 0x3546. + if ((sDogInfo[this->index].textId > 0x3546) || (sDogInfo[this->index].textId < 0x3539)) { sDogInfo[this->index].textId = 0x353E; } @@ -582,9 +603,9 @@ void EnRacedog_CheckForFinish(EnRacedog* this) { */ void EnRacedog_UpdateRunAnimationPlaySpeed(EnRacedog* this) { if (this->actor.speedXZ < 3.0f) { - sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 0.9f; + sAnimationInfo[RACEDOG_ANIM_RUN].playSpeed = 0.9f; } else { - sAnimations[RACEDOG_ANIMATION_RUN].playSpeed = 1.0f; + sAnimationInfo[RACEDOG_ANIM_RUN].playSpeed = 1.0f; } } @@ -637,7 +658,7 @@ s32 EnRacedog_IsOverFinishLine(EnRacedog* this, Vec2f* finishLineCoordinates) { return true; } -void EnRacedog_SpawnFloorDustRing(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 pos; @@ -646,11 +667,11 @@ void EnRacedog_SpawnFloorDustRing(EnRacedog* this, GlobalContext* globalCtx) { pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(15.0f); pos.y = this->actor.world.pos.y; pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(15.0f); - Actor_SpawnFloorDustRing(globalCtx, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); + Actor_SpawnFloorDustRing(play, &this->actor, &pos, 10.0f, 0, 2.0f, 300, 0, true); } } -void EnRacedog_PlayWalkSfx(EnRacedog* this) { +void EnRacedog_PlaySfxWalk(EnRacedog* this) { s16 curFrame = this->skelAnime.curFrame; if ((curFrame == 1) || (curFrame == 7)) { @@ -658,16 +679,16 @@ void EnRacedog_PlayWalkSfx(EnRacedog* this) { } } -void EnRacedog_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRacedog_Update(Actor* thisx, PlayState* play) { s32 pad; EnRacedog* this = THIS; Vec3f floorRot = { 0.0f, 0.0f, 0.0f }; this->selectedDogIndex = sSelectedDogInfo.index; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - EnRacedog_UpdateCollision(this, globalCtx); + EnRacedog_UpdateCollision(this, play); EnRacedog_GetFloorRot(this, &floorRot); Math_ApproachF(&this->curRot.x, floorRot.x, 0.2f, 0.1f); @@ -704,14 +725,14 @@ void EnRacedog_UpdateSelectionArrow(EnRacedog* this) { } } -void EnRacedog_DrawSelectionArrow(EnRacedog* this, GlobalContext* globalCtx) { +void EnRacedog_DrawSelectionArrow(EnRacedog* this, PlayState* play) { Vec3s rotation = gZeroVec3s; s32 shouldDrawSelectionArrow = (this->index == this->selectedDogIndex) ? true : false; if (shouldDrawSelectionArrow) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + 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); @@ -721,20 +742,19 @@ void EnRacedog_DrawSelectionArrow(EnRacedog* this, GlobalContext* globalCtx) { gDPSetEnvColor(POLY_OPA_DISP++, 255, this->selectionArrowGreenEnvColor, 0, 255); Matrix_Scale(this->selectionArrowScale * 2.0f, this->selectionArrowScale * 2.0f, this->selectionArrowScale * 2.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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 focusOffset = { 0.0f, 20.0f, 0.0f }; @@ -744,16 +764,16 @@ void EnRacedog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if (limbIndex == DOG_LIMB_TAIL) { - EnRacedog_DrawSelectionArrow(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++); @@ -792,8 +812,8 @@ void EnRacedog_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 a4406b04c..9d49ea4c2 100644 --- a/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h +++ b/src/overlays/actors/ovl_En_Racedog/z_en_racedog.h @@ -20,7 +20,7 @@ typedef enum { struct EnRacedog; -typedef void (*EnRacedogActionFunc)(struct EnRacedog*, GlobalContext*); +typedef void (*EnRacedogActionFunc)(struct EnRacedog*, PlayState*); typedef struct EnRacedog { /* 0x000 */ Actor actor; @@ -51,6 +51,4 @@ typedef struct EnRacedog { /* 0x2C4 */ f32 selectionArrowScale; } EnRacedog; // size = 0x2C8 -extern const ActorInit En_Racedog_InitVars; - #endif // Z_EN_RACEDOG_H diff --git a/src/overlays/actors/ovl_En_Raf/overlay.cfg b/src/overlays/actors/ovl_En_Raf/overlay.cfg deleted file mode 100644 index 086e64a72..000000000 --- a/src/overlays/actors/ovl_En_Raf/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Raf -z_en_raf.c 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 fb3b1070e..8421b20ac 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.c +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.c @@ -10,38 +10,38 @@ #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 EnRaf_SetupIdle(EnRaf* this); -void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Idle(EnRaf* this, PlayState* play); void EnRaf_SetupGrab(EnRaf* this); -void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_Grab(EnRaf* this, PlayState* play); void EnRaf_SetupChew(EnRaf* this); -void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx); +void EnRaf_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, GlobalContext* globalCtx); +void EnRaf_Dissolve(EnRaf* this, PlayState* play); void EnRaf_SetupDormant(EnRaf* this); -void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, s16 timer); -void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx); -void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx); +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_ANIMATION_IDLE, - /* 1 */ EN_RAF_ANIMATION_CLOSE, - /* 2 */ EN_RAF_ANIMATION_CHEW, - /* 3 */ EN_RAF_ANIMATION_SPIT, - /* 4 */ EN_RAF_ANIMATION_CONVULSE, - /* 5 */ EN_RAF_ANIMATION_DEATH, -} EnRafAnimationIndex; + /* 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, @@ -67,7 +67,7 @@ typedef enum { /* 3 */ EN_RAF_PETAL_SCALE_TYPE_IDLE_OR_THROW } EnRafPetalScaleType; -const ActorInit En_Raf_InitVars = { +ActorInit En_Raf_InitVars = { ACTOR_EN_RAF, ACTORCAT_PROP, FLAGS, @@ -198,7 +198,7 @@ void EnRaf_ClearPixelPetal(u16* texture, u8* clearPixelTable, s32 index) { } } -void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnRaf_Init(Actor* thisx, PlayState* play) { EnRaf* this = THIS; Vec3f limbScale = { 1.0f, 1.0f, 1.0f }; s32 pad; @@ -207,12 +207,12 @@ void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx) { DynaPolyActor_Init(&this->dyna, 0); CollisionHeader_GetVirtual(&gCarnivorousLilyPadCol, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->dyna.actor, &sCylinderInit); + this->dyna.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(globalCtx, &this->skelAnime, &gCarnivorousLilyPadSkel, &gCarnivorousLilyPadSpitAnim, - this->jointTable, this->morphTable, CARNIVOROUS_LILY_PAD_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gCarnivorousLilyPadSkel, &gCarnivorousLilyPadSpitAnim, this->jointTable, + this->morphTable, CARNIVOROUS_LILY_PAD_LIMB_MAX); for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { Math_Vec3f_Copy(&this->targetLimbScale[i], &limbScale); @@ -235,8 +235,8 @@ void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx) { } if (((this->switchFlag >= 0) || (this->mainType == EN_RAF_TYPE_DORMANT) || - (gSaveContext.save.weekEventReg[12] & 1)) && - ((Flags_GetSwitch(globalCtx, this->switchFlag)) || (this->mainType == EN_RAF_TYPE_DORMANT))) { + CHECK_WEEKEVENTREG(WEEKEVENTREG_12_01)) && + (Flags_GetSwitch(play, this->switchFlag) || (this->mainType == EN_RAF_TYPE_DORMANT))) { s32 i; for (i = CARNIVOROUS_LILY_PAD_LIMB_TRAP_1_LOWER_SEGMENT; i <= CARNIVOROUS_LILY_PAD_LIMB_TRAP_3_UPPER_SEGMENT; @@ -253,14 +253,14 @@ void EnRaf_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnRaf_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnRaf_Destroy(Actor* thisx, PlayState* play) { EnRaf* 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 EnRaf_ChangeAnimation(EnRaf* this, s32 index) { +void EnRaf_ChangeAnim(EnRaf* this, s32 animIndex) { static AnimationHeader* sAnimations[] = { &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadCloseAnim, &gCarnivorousLilyPadChewAnim, &gCarnivorousLilyPadSpitAnim, &gCarnivorousLilyPadConvulseAnim, &gCarnivorousLilyPadDeathAnim, @@ -271,22 +271,22 @@ void EnRaf_ChangeAnimation(EnRaf* this, s32 index) { f32 startFrame = 0.0f; f32 playSpeed = 1.0f; - this->endFrame = Animation_GetLastFrame(sAnimations[index]); - if (index == EN_RAF_ANIMATION_IDLE) { + this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); + if (animIndex == EN_RAF_ANIM_IDLE) { startFrame = this->endFrame; - } else if (index == EN_RAF_ANIMATION_CLOSE) { + } else if (animIndex == EN_RAF_ANIM_CLOSE) { playSpeed = 2.0f; } - Animation_Change(&this->skelAnime, sAnimations[index], playSpeed, startFrame, this->endFrame, - sAnimationModes[index], -4.0f); + Animation_Change(&this->skelAnime, sAnimations[animIndex], playSpeed, startFrame, this->endFrame, + sAnimationModes[animIndex], -4.0f); } void EnRaf_SetupIdle(EnRaf* this) { Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; s32 i; - EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_IDLE); + EnRaf_ChangeAnim(this, EN_RAF_ANIM_IDLE); 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); @@ -300,8 +300,8 @@ void EnRaf_SetupIdle(EnRaf* this) { /** * Sits around waiting for the player or an explosive to get near in order to grab them. */ -void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRaf_Idle(EnRaf* this, PlayState* play) { + Player* player = GET_PLAYER(play); Actor* explosive; f32 xDiff; f32 yDiff; @@ -310,8 +310,8 @@ void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { if (this->timer == 0) { if ((player->transformation != PLAYER_FORM_DEKU) && (this->dyna.actor.xzDistToPlayer < (BREG(48) + 80.0f) && (player->invincibilityTimer == 0) && - DynaPolyActor_IsInRidingMovingState(&this->dyna) && !(player->stateFlags1 & 0x8000000) && - globalCtx->grabPlayer(globalCtx, player))) { + DynaPolyActor_IsInRidingMovingState(&this->dyna) && !(player->stateFlags1 & PLAYER_STATE1_8000000) && + play->grabPlayer(play, player))) { player->actor.parent = &this->dyna.actor; this->grabTarget = EN_RAF_GRAB_TARGET_PLAYER; @@ -326,11 +326,11 @@ void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { return; } - if ((globalCtx->gameplayFrames % 2) == 0) { + if ((play->gameplayFrames % 2) == 0) { return; } - explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first; + 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) { @@ -343,7 +343,7 @@ void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { 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); + Actor_Kill(explosive); this->grabTarget = EN_RAF_GRAB_TARGET_EXPLOSIVE; this->collider.dim.radius = 30; this->collider.dim.height = 90; @@ -358,7 +358,7 @@ void EnRaf_Idle(EnRaf* this, GlobalContext* globalCtx) { } void EnRaf_SetupGrab(EnRaf* this) { - EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CLOSE); + 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; @@ -368,11 +368,11 @@ void EnRaf_SetupGrab(EnRaf* this) { /** * Grabs the player or explosive that entered its range. */ -void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRaf_Grab(EnRaf* this, PlayState* play) { + Player* player = GET_PLAYER(play); f32 curFrame = this->skelAnime.curFrame; - if ((this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && (player->stateFlags2 & 0x80) && + if ((this->grabTarget != EN_RAF_GRAB_TARGET_EXPLOSIVE) && (player->stateFlags2 & PLAYER_STATE2_80) && (&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); @@ -387,7 +387,7 @@ void EnRaf_Grab(EnRaf* this, GlobalContext* globalCtx) { void EnRaf_SetupChew(EnRaf* this) { s32 i; - EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CHEW); + 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; @@ -405,16 +405,16 @@ void EnRaf_SetupChew(EnRaf* this) { * damage to them and eventually throw them. If it grabbed a Goron player or explosive, it will * instead explode after chewing them a bit. */ -void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_Chew(EnRaf* this, PlayState* play) { f32 targetChewScale; f32 curFrame; - Player* player = GET_PLAYER(globalCtx); + 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) && + if ((player->stateFlags2 & PLAYER_STATE2_80) && (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); @@ -429,12 +429,12 @@ void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EN_SUISEN_EAT); switch (this->grabTarget) { case EN_RAF_GRAB_TARGET_PLAYER: - globalCtx->damagePlayer(globalCtx, -2); - func_800B8E58((Player*)this, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); - CollisionCheck_GreenBlood(globalCtx, NULL, &player->actor.world.pos); - if ((this->chewCount > (BREG(53) + 5)) || !(player->stateFlags2 & 0x80)) { + play->damagePlayer(play, -2); + func_800B8E58((Player*)this, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); + CollisionCheck_GreenBlood(play, NULL, &player->actor.world.pos); + if ((this->chewCount > (BREG(53) + 5)) || !(player->stateFlags2 & PLAYER_STATE2_80)) { player->actor.freezeTimer = 10; - EnRaf_SetupThrow(this, globalCtx); + EnRaf_SetupThrow(this, play); return; } break; @@ -442,7 +442,7 @@ void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx) { case EN_RAF_GRAB_TARGET_EXPLOSIVE: Actor_ApplyDamage(&this->dyna.actor); if (this->chewCount > (BREG(54) + 4)) { - EnRaf_Explode(this, globalCtx); + EnRaf_Explode(this, play); return; } break; @@ -451,17 +451,17 @@ void EnRaf_Chew(EnRaf* this, GlobalContext* globalCtx) { if (this->chewCount > (BREG(54) + 4)) { player->actor.parent = NULL; player->unk_AE8 = 1000; - EnRaf_Explode(this, globalCtx); + EnRaf_Explode(this, play); } break; } } } -void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnRaf_SetupThrow(EnRaf* this, PlayState* play) { + Player* player = GET_PLAYER(play); - EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + 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; @@ -471,16 +471,16 @@ void EnRaf_SetupThrow(EnRaf* this, GlobalContext* globalCtx) { /** * Spits out the grabbed player. */ -void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +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(globalCtx, &this->dyna.actor, BREG(55) + 3.0f, this->playerRotYWhenGrabbed + 0x8000, - BREG(56) + 10.0f, 0); + 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; } @@ -494,11 +494,11 @@ void EnRaf_Throw(EnRaf* this, GlobalContext* globalCtx) { } /** - * Creates an explosion effect/sound and spawns particles. + * Creates an explosion effect/sound and spawns effects. */ -void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_Explode(EnRaf* 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 }; Vec3f explosionPos; s32 i; s32 pad; @@ -506,24 +506,24 @@ void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { this->action = EN_RAF_ACTION_EXPLODE; Math_Vec3f_Copy(&explosionPos, &this->dyna.actor.world.pos); explosionPos.y += 10.0f; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, explosionPos.x, explosionPos.y, explosionPos.z, 0, - 0, 0, CLEAR_TAG_SMALL_EXPLOSION); + Actor_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(globalCtx, this->switchFlag); + Flags_SetSwitch(play, this->switchFlag); } this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; for (i = 0; i < BREG(57) + 30; i++) { - acceleration.x = (Rand_ZeroOne() - 0.5f) * 0.5f; - acceleration.y = -0.3f; - acceleration.z = (Rand_ZeroOne() - 0.5f) * 0.5f; + 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_InitializeParticle(this, &this->dyna.actor.world.pos, &velocity, &acceleration, - (Rand_ZeroFloat(1.0f) / 500.0f) + 0.002f, 90); + 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++) { @@ -532,7 +532,7 @@ void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { this->timer = 5; if (this->grabTarget == EN_RAF_GRAB_TARGET_EXPLOSIVE) { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 5); + func_800BC154(play, &play->actorCtx, &this->dyna.actor, 5); this->dyna.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_4); } @@ -542,22 +542,22 @@ void EnRaf_Explode(EnRaf* this, GlobalContext* globalCtx) { /** * Switches the lily pad to the "dead" state once the timer reaches 0. */ -void EnRaf_PostDetonation(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_PostDetonation(EnRaf* this, PlayState* play) { if (this->timer == 0) { this->collider.dim.radius = 50; this->collider.dim.height = 10; - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 6); + 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(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } } void EnRaf_SetupConvulse(EnRaf* this) { - EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_CONVULSE); + EnRaf_ChangeAnim(this, EN_RAF_ANIM_CONVULSE); this->chewCount = 0; this->action = EN_RAF_ACTION_CONVULSE; this->actionFunc = EnRaf_Convulse; @@ -568,14 +568,14 @@ void EnRaf_SetupConvulse(EnRaf* this) { * ever coming back to life. When the water in Woodfall Temple is purified, this function * and EnRaf_Dissolve are jointly responsible for controlling the lily pad's death. */ -void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx) { +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(globalCtx, this->switchFlag); + Flags_SetSwitch(play, this->switchFlag); } EnRaf_SetupDissolve(this); @@ -584,7 +584,7 @@ void EnRaf_Convulse(EnRaf* this, GlobalContext* globalCtx) { } void EnRaf_SetupDissolve(EnRaf* this) { - EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_DEATH); + EnRaf_ChangeAnim(this, EN_RAF_ANIM_DEATH); this->action = EN_RAF_ACTION_DISSOLVE; this->dissolveTimer = 0; this->actionFunc = EnRaf_Dissolve; @@ -595,7 +595,7 @@ void EnRaf_SetupDissolve(EnRaf* this) { * When the water in Woodfall Temple is purified, this function and EnRaf_Convulse are jointly * responsible for controlling the lily pad's death. */ -void EnRaf_Dissolve(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_Dissolve(EnRaf* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; s32 i; @@ -659,7 +659,7 @@ void EnRaf_SetupDormant(EnRaf* this) { * Simply sits around doing nothing. If the revive timer is non-zero, then this function * will decrement the revive timer and revive the trap petals once it reaches 0. */ -void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_Dormant(EnRaf* this, PlayState* play) { Vec3f targetLimbScale = { 1.0f, 1.0f, 1.0f }; s32 i; @@ -671,7 +671,7 @@ void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx) { DECR(this->reviveTimer); if (this->reviveTimer == 0) { - EnRaf_ChangeAnimation(this, EN_RAF_ANIMATION_SPIT); + 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++) { @@ -687,7 +687,7 @@ void EnRaf_Dormant(EnRaf* this, GlobalContext* globalCtx) { } } -void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnRaf_Update(Actor* thisx, PlayState* play) { s32 pad; EnRaf* this = THIS; WaterBox* waterBox; @@ -698,9 +698,9 @@ void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { SkelAnime_Update(&this->skelAnime); DECR(this->rippleTimer); DECR(this->timer); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); - if ((this->action == EN_RAF_ACTION_IDLE) && (gSaveContext.save.weekEventReg[12] & 1)) { + if ((this->action == EN_RAF_ACTION_IDLE) && CHECK_WEEKEVENTREG(WEEKEVENTREG_12_01)) { this->petalScaleType = EN_RAF_PETAL_SCALE_TYPE_DEAD; EnRaf_SetupConvulse(this); return; @@ -720,8 +720,8 @@ void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { this->bobOffset = 2.0f * Math_SinS(this->bobPhase); if (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { ySurface = BREG(60) + (this->dyna.actor.world.pos.y - 60.0f); - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, this->dyna.actor.world.pos.x, - this->dyna.actor.world.pos.z, &ySurface, &waterBox)) { + 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) { @@ -732,7 +732,7 @@ void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { Math_Vec3f_Copy(&ripplePos, &this->dyna.actor.world.pos); ripplePos.y = ySurface; - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 650, 3150, 0); + EffectSsGRipple_Spawn(play, &ripplePos, 650, 3150, 0); } } } else { @@ -742,7 +742,7 @@ void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { Math_ApproachZeroF(&this->heightDiffFromPlayer, 0.3f, 2.0f); if (this->action == EN_RAF_ACTION_EXPLODE) { - EnRaf_UpdateParticles(this, globalCtx); + EnRaf_UpdateEffects(this, play); } for (i = 0; i < ARRAY_COUNT(this->limbScale); i++) { @@ -759,7 +759,7 @@ void EnRaf_Update(Actor* thisx, GlobalContext* globalCtx) { Collider_UpdateCylinder(&this->dyna.actor, &this->collider); if (this->action < EN_RAF_ACTION_EXPLODE) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } @@ -787,8 +787,8 @@ static Vec3f sUpperSegmentTargetScaleDuringSpit[] = { { 1.5f, 1.5f, 1.7f }, { 1.5f, 1.5f, 1.3f }, { 3.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 0.5f }, { 1.0f, 1.0f, 1.0f }, }; -void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* thisx) { - GlobalContext* globalCtx = globalCtx2; +void EnRaf_TransformLimbDraw(PlayState* play2, s32 limbIndex, Actor* thisx) { + PlayState* play = play2; EnRaf* this = THIS; s32 i; @@ -829,13 +829,13 @@ void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* th // These matrix operations make the trap petals look a bit more "wobbly" as it chews // by stretching the limbs in various random directions. if ((limbIndex > CARNIVOROUS_LILY_PAD_LIMB_FLOWER) && (limbIndex < CARNIVOROUS_LILY_PAD_LIMB_ROOTS)) { - Matrix_RotateYS((this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_RotateXS((this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_RotateZS((this->chewLimbRot[limbIndex].z * globalCtx->gameplayFrames), MTXMODE_APPLY); + Matrix_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 * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_RotateXS(-(this->chewLimbRot[limbIndex].x * globalCtx->gameplayFrames), MTXMODE_APPLY); - Matrix_RotateYS(-(this->chewLimbRot[limbIndex].y * globalCtx->gameplayFrames), 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; @@ -866,93 +866,92 @@ void EnRaf_TransformLimbDraw(GlobalContext* globalCtx2, s32 limbIndex, Actor* th MTXMODE_APPLY); } -void EnRaf_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnRaf_Draw(Actor* thisx, PlayState* play) { EnRaf* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); - SkelAnime_DrawTransformFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + 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_DrawParticles(this, globalCtx); + EnRaf_DrawEffects(this, play); } } -void EnRaf_InitializeParticle(EnRaf* this, Vec3f* position, Vec3f* velocity, Vec3f* acceleration, f32 scale, - s16 timer) { +void EnRaf_InitializeEffect(EnRaf* this, Vec3f* pos, Vec3f* velocity, Vec3f* accel, f32 scale, s16 timer) { s16 i; - EnRafParticle* particle = this->particles; + EnRafEffect* 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 = randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.y = randPlusMinusPoint5Scaled(30000.0f); - particle->rotation.z = 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 = randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.y = randPlusMinusPoint5Scaled(30000.0f); + effect->rotation.z = randPlusMinusPoint5Scaled(30000.0f); return; } } } -void EnRaf_UpdateParticles(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_UpdateEffects(EnRaf* this, PlayState* play) { s32 i; - EnRafParticle* particle = this->particles; + EnRafEffect* 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 (this->mainType != EN_RAF_TYPE_NO_WATER_INTERACTIONS) { - if (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { - EffectSsGSplash_Spawn(globalCtx, &particle->position, NULL, NULL, 0, particle->scale * 200000.0f); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &particle->position, 50, NA_SE_EV_BOMB_DROP_WATER); - particle->isVisible = false; + 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 (particle->position.y < (this->dyna.actor.world.pos.y - 10.0f)) { - Math_ApproachZeroF(&particle->scale, 0.2f, 0.001f); - if (particle->scale <= 0.0001f) { - particle->timer = 0; + } 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 (particle->timer != 0) { - particle->timer--; + if (effect->timer != 0) { + effect->timer--; } else { - particle->isVisible = false; + effect->isEnabled = false; } } } } -void EnRaf_DrawParticles(EnRaf* this, GlobalContext* globalCtx) { +void EnRaf_DrawEffects(EnRaf* this, PlayState* play) { s16 i; - EnRafParticle* particle = this->particles; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + EnRafEffect* 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_Translate(particle->position.x, particle->position.y, particle->position.z, MTXMODE_NEW); - Matrix_Scale(particle->scale, particle->scale, particle->scale, MTXMODE_APPLY); - Matrix_RotateXS(particle->rotation.x, MTXMODE_APPLY); - Matrix_RotateYS(particle->rotation.y, MTXMODE_APPLY); - Matrix_RotateZS(particle->rotation.z, 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_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); 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 f63924402..f4659f48b 100644 --- a/src/overlays/actors/ovl_En_Raf/z_en_raf.h +++ b/src/overlays/actors/ovl_En_Raf/z_en_raf.h @@ -11,22 +11,24 @@ 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 particles won't produce splashes + /* 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 isVisible; - /* 0x04 */ Vec3f position; + /* 0x00 */ u8 isEnabled; + /* 0x04 */ Vec3f pos; /* 0x10 */ Vec3f velocity; - /* 0x1C */ Vec3f acceleration; + /* 0x1C */ Vec3f accel; /* 0x28 */ Vec3s rotation; /* 0x30 */ f32 scale; /* 0x34 */ s16 timer; -} EnRafParticle; // size = 0x38 +} EnRafEffect; // size = 0x38 + +#define EN_RAF_EFFECT_COUNT 31 typedef struct EnRaf { /* 0x000 */ DynaPolyActor dyna; @@ -59,9 +61,7 @@ typedef struct EnRaf { /* 0x3CC */ s16 petalClearPixelSecondPassIndex; /* 0x3CE */ s16 teethClearPixelSecondPassIndex; /* 0x3D0 */ ColliderCylinder collider; - /* 0x41C */ EnRafParticle particles[31]; + /* 0x41C */ EnRafEffect effects[EN_RAF_EFFECT_COUNT]; } EnRaf; // size = 0xAE4 -extern const ActorInit En_Raf_InitVars; - #endif // Z_EN_RAF_H diff --git a/src/overlays/actors/ovl_En_Rail_Skb/overlay.cfg b/src/overlays/actors/ovl_En_Rail_Skb/overlay.cfg deleted file mode 100644 index df550bd19..000000000 --- a/src/overlays/actors/ovl_En_Rail_Skb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Rail_Skb -z_en_rail_skb.c 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 99d30f14c..073f2045a 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,53 +4,53 @@ * 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); -const ActorInit En_Rail_Skb_InitVars = { +ActorInit En_Rail_Skb_InitVars = { ACTOR_EN_RAIL_SKB, ACTORCAT_ENEMY, FLAGS, @@ -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,13 +242,13 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, (actor->params & 0xFF00) >> 8)) { + Actor_Kill(&this->actor); return; } this->unk_22C = (ObjHakaisi*)actor; @@ -256,7 +256,7 @@ void func_80B70D24(EnRailSkb* this, GlobalContext* globalCtx) { } actor = actor->next; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } static InitChainEntry sInitChain[] = { @@ -264,25 +264,25 @@ 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))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, ENRAILSKB_GET_FF(&this->actor))) { + Actor_Kill(&this->actor); } Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.speedXZ = 1.6f; - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->unk_3F2 = 0; this->unk_2E4 = -1; this->unk_3FC = 0; @@ -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->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 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); @@ -636,23 +635,23 @@ void func_80B71BB8(EnRailSkb* this, GlobalContext* globalCtx) { } if (this->actor.bgCheckFlags & 2) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } 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; @@ -826,18 +825,18 @@ void func_80B723F8(EnRailSkb* this) { this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_4); this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); this->actor.flags |= ACTOR_FLAG_100000; - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; 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,30 +919,30 @@ 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; - this->actor.hintId = 0xFF; + this->actor.hintId = TATL_HINT_ID_NONE; 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); - this->actor.hintId = 0x55; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->actor.textId = 0; func_80B70FA0(this); } } } -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,48 +1055,47 @@ 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 }; @@ -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,10 +1119,10 @@ 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) { @@ -1139,15 +1139,15 @@ void EnRailSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } -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..10c2653c4 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) @@ -42,6 +43,4 @@ typedef struct EnRailSkb { /* 0x403 */ u8 drawDmgEffType; } EnRailSkb; // size = 0x404 -extern const ActorInit En_Rail_Skb_InitVars; - #endif // Z_EN_RAIL_SKB_H diff --git a/src/overlays/actors/ovl_En_Railgibud/overlay.cfg b/src/overlays/actors/ovl_En_Railgibud/overlay.cfg deleted file mode 100644 index 6c055c27c..000000000 --- a/src/overlays/actors/ovl_En_Railgibud/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Railgibud -z_en_railgibud.c 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 ba6043f52..50a203c81 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,73 @@ */ #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* basePos, f32 randomnessScale, s32 dustCount, s16 dustScale, + s16 scaleStep); +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, @@ -82,7 +84,7 @@ typedef enum { /* 2 */ EN_RAILGIBUD_GRAB_RELEASE, } EnRailgibudGrabState; -const ActorInit En_Railgibud_InitVars = { +ActorInit En_Railgibud_InitVars = { ACTOR_EN_RAILGIBUD, ACTORCAT_ENEMY, FLAGS, @@ -94,7 +96,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 +192,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 +211,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,20 +241,20 @@ 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; Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.targetMode = 0; - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; 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,31 +267,31 @@ 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { + Actor_Kill(&this->actor); } 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 +300,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 +337,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 +370,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 +379,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 +387,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 +403,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 +413,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); - } else if (!(player->stateFlags2 & 0x80)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, EN_RAILGIBUD_ANIMATION_GRAB_END); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_GRAB_ATTACK); + } else if (!(player->stateFlags2 & PLAYER_STATE2_80)) { + 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; @@ -449,10 +450,10 @@ void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { if (this->grabDamageTimer == 20) { s16 requiredScopeTemp; - damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; - globalCtx->damagePlayer(globalCtx, -8); + damageSfxId = player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S; + 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++; @@ -462,13 +463,13 @@ void EnRailgibud_Grab(EnRailgibud* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } - if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { - if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { - player->stateFlags2 &= ~0x80; + if (!(player->stateFlags2 & PLAYER_STATE2_80) || (player->unk_B62 != 0)) { + if ((player->unk_B62 != 0) && (player->stateFlags2 & PLAYER_STATE2_80)) { + player->stateFlags2 &= ~PLAYER_STATE2_80; 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 +489,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 +511,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 +529,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 +553,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 +562,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 +571,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; } @@ -580,8 +581,8 @@ void EnRailgibud_Damage(EnRailgibud* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; 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, + this->actor.hintId = TATL_HINT_ID_REDEAD; + SkelAnime_InitFlex(play, &this->skelAnime, &gRedeadSkel, NULL, this->jointTable, this->morphTable, GIBDO_LIMB_MAX); this->type = EN_RAILGIBUD_TYPE_REDEAD; } @@ -603,7 +604,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,18 +619,18 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { // Don't delete the "main" Gibdo, since that will break the surviving // Gibdos' ability to start and stop walking forward. Instead, just @@ -653,33 +654,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 +700,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 +724,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,16 +743,17 @@ 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; } - if ((Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f) && - !(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && - !(player->stateFlags2 & (0x4000 | 0x80))) { + if (Actor_DistanceToPoint(&player->actor, &this->actor.home.pos) < 100.0f && + !(player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_80000 | PLAYER_STATE1_200000)) && + !(player->stateFlags2 & (PLAYER_STATE2_80 | PLAYER_STATE2_4000))) { return true; } @@ -763,8 +765,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 +775,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 +855,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 +880,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 +895,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 +914,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,118 +927,118 @@ 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; + this->actor.hintId = TATL_HINT_ID_NONE; this->actor.textId = 0; if ((this->actionFunc != EnRailgibud_WalkInCircles) && (this->actionFunc != EnRailgibud_WalkToHome)) { 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) { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } else { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } 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 +1050,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) && @@ -1065,41 +1066,41 @@ void EnRailgibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } } -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,13 +1109,14 @@ 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 - Actor_MarkForDeath(&this->actor); + + if (gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 9)) { // NOT Cutscene: Music Box House Opens + Actor_Kill(&this->actor); } EnRailgibud_SetupDoNothing(this); @@ -1153,7 +1155,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 +1163,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); + Actor_Kill(&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 +1230,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 +1239,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 +1247,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..cf06d1996 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,18 +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; - #endif // Z_EN_RAILGIBUD_H diff --git a/src/overlays/actors/ovl_En_Rat/overlay.cfg b/src/overlays/actors/ovl_En_Rat/overlay.cfg deleted file mode 100644 index 3562582ca..000000000 --- a/src/overlays/actors/ovl_En_Rat/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Rat -z_en_rat.c 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..da0b27e6d 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -5,18 +5,37 @@ */ #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); -#if 0 -const ActorInit En_Rat_InitVars = { +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; + +ActorInit En_Rat_InitVars = { ACTOR_EN_RAT, ACTORCAT_ENEMY, FLAGS, @@ -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[] = { - ICHAIN_S8(hintId, 97, ICHAIN_CONTINUE), +static TexturePtr sSparkTextures[] = { + gElectricSpark1Tex, + gElectricSpark2Tex, + gElectricSpark3Tex, + gElectricSpark4Tex, +}; + +static InitChainEntry sInitChain[] = { + ICHAIN_S8(hintId, TATL_HINT_ID_REAL_BOMBCHU, 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_Kill(&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 (!CHECK_FLAG_ALL(this->actor.flags, 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..9472e8c31 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.h +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.h @@ -2,14 +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; - #endif // Z_EN_RAT_H diff --git a/src/overlays/actors/ovl_En_Rd/overlay.cfg b/src/overlays/actors/ovl_En_Rd/overlay.cfg deleted file mode 100644 index 3864774ca..000000000 --- a/src/overlays/actors/ovl_En_Rd/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Rd -z_en_rd.c 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 c24a5e5a9..3e46c9f04 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, @@ -96,7 +97,7 @@ typedef enum { /* 4 */ EN_RD_GRAB_END, } EnRdGrabState; -const ActorInit En_Rd_InitVars = { +ActorInit En_Rd_InitVars = { ACTOR_EN_RD, ACTORCAT_ENEMY, FLAGS, @@ -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,43 +207,43 @@ 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; + this->actor.hintId = TATL_HINT_ID_REDEAD; EnRd_SetupIdle(this); } this->setupDanceFunc = EnRd_SetupSquattingDance; break; case EN_RD_TYPE_CLAPPING_DANCE: - if (!EnRd_ShouldNotDance(globalCtx)) { + if (!EnRd_ShouldNotDance(play)) { EnRd_SetupClappingDance(this); } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; EnRd_SetupIdle(this); } this->setupDanceFunc = EnRd_SetupClappingDance; break; case EN_RD_TYPE_PIROUETTE: - if (!EnRd_ShouldNotDance(globalCtx)) { + if (!EnRd_ShouldNotDance(play)) { EnRd_SetupPirouette(this); } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; EnRd_SetupIdle(this); } this->setupDanceFunc = EnRd_SetupPirouette; @@ -250,9 +251,9 @@ void EnRd_Init(Actor* thisx, GlobalContext* globalCtx) { default: if (EN_RD_GET_TYPE(&this->actor) == EN_RD_TYPE_GIBDO) { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } EnRd_SetupIdle(this); this->setupDanceFunc = EnRd_SetupIdle; @@ -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,26 +434,26 @@ 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; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } - 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; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } 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,33 +478,33 @@ 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; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } - 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; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } 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,25 +539,25 @@ 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; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } 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; + this->actor.hintId = TATL_HINT_ID_GIBDO; } else { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } 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,24 +650,25 @@ 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)) { - if (!(player->stateFlags1 & (0x200000 | 0x80000 | 0x40000 | 0x4000 | 0x2000 | 0x80)) && - !(player->stateFlags2 & (0x4000 | 0x80))) { + if (!(player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_80000 | PLAYER_STATE1_200000)) && + !(player->stateFlags2 & (PLAYER_STATE2_80 | PLAYER_STATE2_4000))) { 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 +685,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 +701,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 +741,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 +752,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 +760,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 +772,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 +795,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 +803,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 +818,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 +830,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: @@ -837,13 +839,13 @@ void EnRd_Grab(EnRd* this, GlobalContext* globalCtx) { Math_SmoothStepToS(&this->upperBodyYRotation, 0, 1, 1500, 0); case EN_RD_GRAB_ATTACK: - if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { - if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { - player->stateFlags2 &= ~0x80; + if (!(player->stateFlags2 & PLAYER_STATE2_80) || (player->unk_B62 != 0)) { + if ((player->unk_B62 != 0) && (player->stateFlags2 & PLAYER_STATE2_80)) { + player->stateFlags2 &= ~PLAYER_STATE2_80; 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,10 +878,10 @@ 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); + func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); } break; @@ -897,31 +899,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 +936,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 +953,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 +978,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 +990,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 +1014,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 +1030,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 +1048,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,18 +1058,18 @@ 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; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else { this->deathTimer--; @@ -1095,7 +1097,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 +1118,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 +1146,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 +1222,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 +1257,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 +1271,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 +1279,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 +1307,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) && @@ -1322,43 +1324,43 @@ void EnRd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -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..f5fbf82cb 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,47 +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; - #endif // Z_EN_RD_H diff --git a/src/overlays/actors/ovl_En_Recepgirl/overlay.cfg b/src/overlays/actors/ovl_En_Recepgirl/overlay.cfg deleted file mode 100644 index bec7425de..000000000 --- a/src/overlays/actors/ovl_En_Recepgirl/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Recepgirl -z_en_recepgirl.c 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 13ab86f52..051cc8b33 100644 --- a/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c +++ b/src/overlays/actors/ovl_En_Recepgirl/z_en_recepgirl.c @@ -11,17 +11,17 @@ #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 = { +ActorInit En_Recepgirl_InitVars = { ACTOR_EN_RECEPGIRL, ACTORCAT_NPC, FLAGS, @@ -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,7 +119,7 @@ void EnRecepgirl_SetupTalk(EnRecepgirl* this) { this->actionFunc = EnRecepgirl_Talk; } -void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { +void EnRecepgirl_Talk(EnRecepgirl* this, PlayState* play) { u8 talkState; if (SkelAnime_Update(&this->skelAnime)) { @@ -140,17 +140,17 @@ void EnRecepgirl_Talk(EnRecepgirl* this, GlobalContext* globalCtx) { } } - talkState = Message_GetState(&globalCtx->msgCtx); - if (talkState == 2) { + talkState = Message_GetState(&play->msgCtx); + if (talkState == TEXT_STATE_CLOSING) { this->actor.textId = 0x2ADC; // hear directions again? EnRecepgirl_SetupWait(this); - } else if ((talkState == 5) && Message_ShouldAdvance(globalCtx)) { + } 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 - this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_80)) { + this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended) } else { this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing) } @@ -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,7 +191,7 @@ 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) { @@ -201,17 +200,17 @@ void EnRecepgirl_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Acto } } -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..a0fba9fdc 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; @@ -17,6 +17,4 @@ typedef struct EnRecepgirl { /* 0x2AE */ Vec3s headRot; } EnRecepgirl; // size = 0x2B4 -extern const ActorInit En_Recepgirl_InitVars; - #endif // Z_EN_RECEPGIRL_H diff --git a/src/overlays/actors/ovl_En_Rg/overlay.cfg b/src/overlays/actors/ovl_En_Rg/overlay.cfg deleted file mode 100644 index 4cbc29697..000000000 --- a/src/overlays/actors/ovl_En_Rg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Rg -z_en_rg.c 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 c5f2954f9..7f6d39886 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -12,17 +12,17 @@ #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; -const ActorInit En_Rg_InitVars = { +ActorInit En_Rg_InitVars = { ACTOR_EN_RG, ACTORCAT_NPC, FLAGS, @@ -119,12 +119,12 @@ 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[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, +static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; Color_RGBA8 D_80BF5954[] = { @@ -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_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, @@ -187,19 +186,18 @@ void func_80BF3920(EnRgStruct* ptr, GlobalContext* globalCtx) { 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_ReplaceRotation(&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); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[idx])); + gSPDisplayList(POLY_XLU_DISP++, gGoronDustModelDL); 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; @@ -397,8 +395,8 @@ s32 func_80BF43FC(EnRg* this) { return phi_s4; } -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; @@ -457,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; @@ -546,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; @@ -566,13 +564,14 @@ void func_80BF4AB8(EnRg* this, GlobalContext* globalCtx) { } while (phi_s0 != NULL); } - if ((phi_s0 == NULL) && (D_80BF5C10 == 0) && (this->unk_326 == 0) && (player->stateFlags3 & 0x80000) && - (player->invincibilityTimer == 0) && func_80BF4220(this, globalCtx, &player->actor)) { + if ((phi_s0 == NULL) && (D_80BF5C10 == 0) && (this->unk_326 == 0) && + (player->stateFlags3 & PLAYER_STATE3_80000) && (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; } @@ -588,7 +587,7 @@ void func_80BF4AB8(EnRg* this, GlobalContext* globalCtx) { this->unk_320 = CLAMP_MAX(this->unk_320, 0x190); } else if (this->collider2.base.at->id == ACTOR_PLAYER) { this->unk_326 = 0x28; - if (player->stateFlags3 & 0x1000) { + if (player->stateFlags3 & PLAYER_STATE3_1000) { player->linearVelocity *= 0.5f; player->unk_B08[0] = player->linearVelocity; player->unk_B08[1] += player->linearVelocity * 0.05f; @@ -651,7 +650,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; @@ -660,7 +659,7 @@ void func_80BF4EBC(EnRg* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = 14.0f; this->actionFunc = func_80BF4FC4; } - } else if (gSaveContext.save.weekEventReg[12] & 2) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_02)) { if (DECR(this->unk_318) == 0) { func_80BF409C(this, 1); this->unk_310 &= ~8; @@ -670,13 +669,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; @@ -699,12 +698,12 @@ void func_80BF4FC4(EnRg* this, GlobalContext* globalCtx) { this->unk_310 &= ~0x800; } - if (gSaveContext.eventInf[1] & 1) { + if (CHECK_EVENTINF(EVENTINF_10)) { 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)) { @@ -715,7 +714,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; } } @@ -723,26 +722,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; } @@ -752,7 +751,7 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.gravity = -1.0f; SubS_UpdateFlags(&this->unk_310, 3, 7); - if (!(gSaveContext.save.weekEventReg[12] & 2)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_02)) { this->unk_318 = Rand_S16Offset(30, 30); } @@ -760,50 +759,50 @@ void EnRg_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_31E = 0; this->actionFunc = func_80BF4EBC; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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); + 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); @@ -813,13 +812,13 @@ void func_80BF547C(EnRg* this, GlobalContext* globalCtx) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 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; @@ -849,22 +848,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..4db0b58e0 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,36 +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; - #endif // Z_EN_RG_H diff --git a/src/overlays/actors/ovl_En_River_Sound/overlay.cfg b/src/overlays/actors/ovl_En_River_Sound/overlay.cfg deleted file mode 100644 index 82d1e4c4a..000000000 --- a/src/overlays/actors/ovl_En_River_Sound/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_River_Sound -z_en_river_sound.c 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..0fd1007d0 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,11 +10,11 @@ #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 = { +ActorInit En_River_Sound_InitVars = { ACTOR_EN_RIVER_SOUND, ACTORCAT_ITEMACTION, FLAGS, @@ -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; @@ -36,22 +36,22 @@ void EnRiverSound_Init(Actor* thisx, GlobalContext* globalCtx) { pathIndex = RS_GET_PATH_INDEX(&this->actor); this->actor.params = RS_GET_TYPE(&this->actor); if (pathIndex == 0xFF) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); 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_River_Sound/z_en_river_sound.h b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h index b8dbcc513..eff4fbb47 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.h @@ -45,6 +45,4 @@ typedef struct EnRiverSound { /* 0x148 */ Vec3s* pathPoints; } EnRiverSound; // size = 0x14C -extern const ActorInit En_River_Sound_InitVars; - #endif // Z_EN_RIVER_SOUND_H diff --git a/src/overlays/actors/ovl_En_Rr/overlay.cfg b/src/overlays/actors/ovl_En_Rr/overlay.cfg deleted file mode 100644 index d7730c1f0..000000000 --- a/src/overlays/actors/ovl_En_Rr/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Rr -z_en_rr.c 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 2ad27aab5..6c7ac273c 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -5,29 +5,30 @@ */ #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* play2); -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 = { +ActorInit En_Rr_InitVars = { ACTOR_EN_RR, ACTORCAT_ENEMY, FLAGS, @@ -117,20 +118,20 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 3, 45, 60, 250 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 55, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_LIKE_LIKE, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -400, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 2000, ICHAIN_CONTINUE), 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,14 +289,14 @@ 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; f32 sp2C; - if (player->stateFlags2 & 0x80) { + if (player->stateFlags2 & PLAYER_STATE2_80) { player->actor.parent = NULL; player->unk_AE8 = 100; this->actor.flags |= ACTOR_FLAG_1; @@ -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,13 @@ 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 & PLAYER_STATE2_80) && + (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 +580,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 +627,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 +649,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 +660,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 +694,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,18 +712,21 @@ 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); - Actor_MarkForDeath(&this->actor); - } else if (this->unk_1E4 == 88) { + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); + Actor_Kill(&this->actor); + return; + } + + if (this->unk_1E4 == 88) { Vec3f sp74; 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 +736,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 +748,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 +792,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,13 +807,13 @@ 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)) { + if (!(player->stateFlags2 & PLAYER_STATE2_80)) { this->unk_1FC--; if (this->unk_1FC == 0) { this->collider1.base.ocFlags1 |= OC1_TYPE_PLAYER; @@ -819,11 +824,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 +840,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,26 +871,24 @@ 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; + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Mtx)); Vec3f* vecPtr; s32 i; EnRrStruct* ptr; Vec3f spA4; f32 temp_f20; - matrix = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Mtx) * 4); + OPEN_DISPS(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - - gSPSegment(POLY_OPA_DISP++, 0x0C, matrix); + gSPSegment(POLY_OPA_DISP++, 0x0C, mtx); 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_Push(); Matrix_Scale((1.0f + this->unk_324[0].unk_10) * this->unk_324[0].unk_08, 1.0f, @@ -893,7 +896,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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_MultVecZ(1842.1053f, vecPtr++); Matrix_MultVecZ(-1842.1053f, vecPtr++); @@ -909,7 +912,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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); + Matrix_ToMtx(mtx); if ((i & 1) != 0) { Matrix_RotateYS(0x2000, MTXMODE_APPLY); @@ -920,7 +923,7 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_MultVecX(1842.1053f, vecPtr++); Matrix_MultVecX(-1842.1053f, vecPtr++); Matrix_Pop(); - matrix++; + mtx++; if (i == 3) { Matrix_MultZero(&spA4); } @@ -933,9 +936,9 @@ void EnRr_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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..e996cfb12 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, @@ -62,6 +62,4 @@ typedef struct EnRr { /* 0x324 */ EnRrStruct unk_324[5]; } EnRr; // size = 0x3C4 -extern const ActorInit En_Rr_InitVars; - #endif // Z_EN_RR_H diff --git a/src/overlays/actors/ovl_En_Rsn/overlay.cfg b/src/overlays/actors/ovl_En_Rsn/overlay.cfg deleted file mode 100644 index f99efb1a6..000000000 --- a/src/overlays/actors/ovl_En_Rsn/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Rsn -z_en_rsn.c 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 3a29b5081..4f6dd1dc1 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.c @@ -11,14 +11,14 @@ #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 = { +ActorInit En_Rsn_InitVars = { ACTOR_EN_RSN, ACTORCAT_NPC, FLAGS, @@ -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) { + 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_MultVec3f(&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..438a49b1e 100644 --- a/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h +++ b/src/overlays/actors/ovl_En_Rsn/z_en_rsn.h @@ -5,17 +5,15 @@ 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; /* 0x1DE */ Vec3s unk1DE; } EnRsn; // size = 0x1E4 -extern const ActorInit En_Rsn_InitVars; - #endif // Z_EN_RSN_H diff --git a/src/overlays/actors/ovl_En_Ru/overlay.cfg b/src/overlays/actors/ovl_En_Ru/overlay.cfg deleted file mode 100644 index 408030385..000000000 --- a/src/overlays/actors/ovl_En_Ru/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ru -z_en_ru.c 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..042f2e46f 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.c +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.c @@ -10,15 +10,14 @@ #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 EnRu_DoNothing(EnRu* this, PlayState* play); -#if 0 -const ActorInit En_Ru_InitVars = { +ActorInit En_Ru_InitVars = { ACTOR_EN_RU, ACTORCAT_NPC, FLAGS, @@ -30,18 +29,29 @@ const ActorInit En_Ru_InitVars = { (ActorFunc)EnRu_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A39450 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80A3947C = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_80A39488 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -76,34 +86,268 @@ static DamageTable D_80A39488 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfoS sAnimationInfo[] = { + { &gAdultRutoIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gAdultRutoIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoRaisingArmsUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoCrossingArmsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoLookingDownLeftAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoIdleHandsOnHipsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoHeadTurnDownLeftAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gAdultRutoSwimmingUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, +}; -extern ColliderCylinderInit D_80A39450; -extern CollisionCheckInfoInit2 D_80A3947C; -extern DamageTable D_80A39488; +// in PostLimbdraw, converts limbIndex to bodyPartsPos index +static s8 sBodyPartPosIndices[] = { + -1, -1, 12, 13, 14, -1, 9, 10, 11, -1, 0, 6, -1, -1, 7, 8, 2, -1, -1, 3, 4, 2, 1, +}; -extern UNK_TYPE D_0600C700; +static s8 sRuBodyParts[RU_BODYPARTSPOS_COUNT] = { + 0, 0, 0, 0, 3, 4, 0, 6, 7, 0, 9, 10, 0, 12, 13, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A389A0.s") +static u8 sRuShadowSizes[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38A68.s") +static TrackOptionsSet sTrackOptions = { + { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 } +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38B7C.s") +s32 EnRu_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { + s16 lastFrame; + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38BF0.s") + if ((animIndex >= 0) && (animIndex < ARRAY_COUNT(sAnimationInfo))) { + lastFrame = sAnimationInfo[animIndex].frameCount; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38C70.s") + ret = true; + if (lastFrame < 0) { + lastFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38DF4.s") + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + sAnimationInfo[animIndex].startFrame, lastFrame, sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].morphFrames); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/EnRu_Init.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/EnRu_Destroy.s") +// En_Zo has a copy of this function +s32 EnRu_PlayWalkingSound(EnRu* this, PlayState* play) { + u8 leftWasGrounded; + u8 rightWasGrounded; + s32 waterSfxId; + s16 sfxId; + u8 isFootGrounded; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/EnRu_Update.s") + leftWasGrounded = this->isLeftFootGrounded; + rightWasGrounded = this->isRightFootGrounded; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A38FB4.s") + if (this->actor.bgCheckFlags & 0x20) { + if (this->actor.depthInWater < 20.0f) { + waterSfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG; + } else { + waterSfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/func_80A390F8.s") + sfxId = waterSfxId + SFX_FLAG; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ru/EnRu_Draw.s") + } else { + sfxId = SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) + SFX_FLAG; + } + + 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(play, &this->rightFootPos, -6.0f); + if (this->isRightFootGrounded && !rightWasGrounded && isFootGrounded) { + Actor_PlaySfxAtPos(&this->actor, sfxId); + } + + return false; +} + +// This function is only ever called with eyeStateMax == 3 +void EnRu_UpdateEyes(EnRu* this, s32 eyeStateMax) { + if (DECR(this->blinkTimer) == 0) { + this->eyeState++; + if (this->eyeState >= eyeStateMax) { + this->eyeState = 0; + this->blinkTimer = Rand_S16Offset(30, 30); + } + } +} + +void EnRu_UpdateCollider(EnRu* 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(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} + +void EnRu_UpdateModel(EnRu* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + + // Head and Torso tracking to Player if in front of Ru. + if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { + Vec3f playerPos; + + playerPos.x = player->actor.world.pos.x; + playerPos.y = player->bodyPartsPos[7].y + 3.0f; + playerPos.z = player->actor.world.pos.z; + SubS_TrackPoint(&playerPos, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); + + } else { // smooth her back to facing forward + 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); + } + + EnRu_UpdateEyes(this, 3); + EnRu_PlayWalkingSound(this, play); + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, RU2_LIMB_MAX); +} + +void EnRu_DoNothing(EnRu* this, PlayState* play) { +} + +void EnRu_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnRu* this = THIS; + + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gAdultRutoSkel, NULL, this->jointTable, this->morphTable, RU2_LIMB_MAX); + EnRu_ChangeAnim(&this->skelAnime, 0); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + + this->path = SubS_GetPathByIndex(play, RU_GET_PATH(thisx), 0x3F); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = EnRu_DoNothing; + this->actor.gravity = -4.0f; +} + +void EnRu_Destroy(Actor* thisx, PlayState* play) { + EnRu* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); +} + +void EnRu_Update(Actor* thisx, PlayState* play) { + EnRu* this = THIS; + + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + EnRu_UpdateModel(this, play); + EnRu_UpdateCollider(this, play); +} + +s32 EnRu_OverrideLimbdraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnRu* this = THIS; + + if (limbIndex == RU2_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 == RU2_LIMB_TORSO) { + Matrix_RotateYS(this->torsoRot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->torsoRot.x, MTXMODE_APPLY); + } + + if ((limbIndex == RU2_LIMB_TORSO) || (limbIndex == RU2_LIMB_LEFT_UPPER_ARM) || + (limbIndex == RU2_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)(Math_SinS(this->limbRotTableY[limbIndex]) * 200.0f); + rot->z += (s16)(Math_CosS(this->limbRotTableZ[limbIndex]) * 200.0f); + } + + return false; +} + +void EnRu_PostLimbdraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnRu* this = THIS; + Vec3f headFocus = { 800.0f, 0, 0 }; + Vec3f bodyPartPos = { 0, 0, 0 }; + + if (sBodyPartPosIndices[limbIndex] >= 0) { + Matrix_MultVec3f(&bodyPartPos, &this->bodyPartsPos[sBodyPartPosIndices[limbIndex]]); + } + if (limbIndex == RU2_LIMB_HEAD) { + Matrix_MultVec3f(&headFocus, &thisx->focus.pos); + } + + if (limbIndex == RU2_LIMB_LEFT_FOOT) { + Matrix_MultVec3f(&bodyPartPos, &this->leftFootPos); + } + if (limbIndex == RU2_LIMB_RIGHT_FOOT) { + Matrix_MultVec3f(&bodyPartPos, &this->rightFootPos); + } +} + +// This is a copy of displaylist found in En_Zo +static Gfx sTransparencyDlist[] = { + gsDPSetRenderMode(AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)), + gsDPSetAlphaCompare(G_AC_THRESHOLD), + gsSPEndDisplayList(), +}; + +void EnRu_Draw(Actor* thisx, PlayState* play) { + EnRu* this = THIS; + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); + u8* shadowTexIter; + s32 i; + TexturePtr eyeTextures[] = { gAdultRutoEyeOpenTex, gAdultRutoEyeHalfTex, gAdultRutoEyeClosedTex }; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + gDPPipeSync(POLY_OPA_DISP++); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(eyeTextures[this->eyeState])); + + // only runs the last command of the display list, which is gsSPEndDisplayList + gSPSegment(POLY_OPA_DISP++, 0x0C, &sTransparencyDlist[2]); + + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnRu_OverrideLimbdraw, EnRu_PostLimbdraw, &this->actor, POLY_OPA_DISP); + + Matrix_RotateXS(0, MTXMODE_NEW); + + for (i = 0, shadowTexIter = shadowTex; i < SUBS_SHADOW_TEX_SIZE; i++) { + *shadowTexIter++ = 0; + } + + for (i = 0; i < 5; i++) { + SubS_GenShadowTex(&this->bodyPartsPos[0], &this->actor.world.pos, shadowTex, (i / 5.0f), + (ARRAY_COUNT(sRuBodyParts)), sRuShadowSizes, sRuBodyParts); + } + + SubS_DrawShadowTex(&this->actor, &play->state, shadowTex); + + CLOSE_DISPS(play->state.gfxCtx); +} 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..081f3bbd8 100644 --- a/src/overlays/actors/ovl_En_Ru/z_en_ru.h +++ b/src/overlays/actors/ovl_En_Ru/z_en_ru.h @@ -2,17 +2,40 @@ #define Z_EN_RU_H #include "global.h" +#include "objects/object_ru2/object_ru2.h" + +#define RU_GET_PATH(thisx) ((thisx->params & 0x7E00) >> 9) struct EnRu; -typedef void (*EnRuActionFunc)(struct EnRu*, GlobalContext*); +typedef void (*EnRuActionFunc)(struct EnRu*, PlayState*); + +#define RU_BODYPARTSPOS_COUNT 15 typedef struct EnRu { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnRuActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x30C]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnRuActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ UNK_TYPE1 pad1D8[0x4]; + /* 0x1DC */ Path* path; // path is prepared in EnRu_Init, but unused after + /* 0x1E0 */ UNK_TYPE1 pad1E0[0x4]; + /* 0x1E4 */ Vec3f leftFootPos; + /* 0x1F0 */ Vec3f rightFootPos; + /* 0x1FC */ u8 isLeftFootGrounded; + /* 0x1FD */ u8 isRightFootGrounded; + /* 0x1FE */ Vec3s jointTable[RU2_LIMB_MAX]; + /* 0x288 */ Vec3s morphTable[RU2_LIMB_MAX]; + /* 0x312 */ Vec3s trackTarget; + /* 0x318 */ Vec3s headRot; + /* 0x31E */ Vec3s torsoRot; + /* 0x324 */ UNK_TYPE1 pad324[0x12]; + /* 0x336 */ s16 limbRotTableY[RU2_LIMB_MAX]; + /* 0x364 */ s16 limbRotTableZ[RU2_LIMB_MAX]; + /* 0x394 */ Vec3f bodyPartsPos[RU_BODYPARTSPOS_COUNT]; + /* 0x348 */ UNK_TYPE1 padUNK[6]; + /* 0x44E */ s16 eyeState; + /* 0x450 */ s16 blinkTimer; } EnRu; // size = 0x454 -extern const ActorInit En_Ru_InitVars; - #endif // Z_EN_RU_H diff --git a/src/overlays/actors/ovl_En_Ruppecrow/overlay.cfg b/src/overlays/actors/ovl_En_Ruppecrow/overlay.cfg deleted file mode 100644 index 63f0bbb60..000000000 --- a/src/overlays/actors/ovl_En_Ruppecrow/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ruppecrow -z_en_ruppecrow.c 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..f77993e5d 100644 --- a/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c +++ b/src/overlays/actors/ovl_En_Ruppecrow/z_en_ruppecrow.c @@ -17,30 +17,30 @@ 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* play2); +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 = { +ActorInit En_Ruppecrow_InitVars = { ACTOR_EN_RUPPECROW, ACTORCAT_ENEMY, FLAGS, @@ -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: @@ -240,7 +240,7 @@ s32 EnRuppecrow_CanSpawnBlueRupees(GlobalContext* globalCtx) { case PLAYER_FORM_ZORA: return false; case PLAYER_FORM_HUMAN: - if (player->stateFlags1 & 0x800000) { + if (player->stateFlags1 & PLAYER_STATE1_800000) { return true; } else { return false; @@ -257,28 +257,28 @@ void EnRuppecrow_UpdateRupees(EnRuppecrow* this) { for (rupeeIndex = 0; rupeeIndex < ENRUPPECROW_RUPEE_COUNT; rupeeIndex++) { rupee = this->rupees[rupeeIndex]; if (rupee != NULL && rupee->unk152 == 0) { - Actor_MarkForDeath(&rupee->actor); + Actor_Kill(&rupee->actor); } } } -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; - if (!(player->stateFlags3 & 0x1000)) { + if (!(player->stateFlags3 & PLAYER_STATE3_1000)) { xOffset = (this->rupeeIndex & 1) ? 10.0f : -10.0f; } else { 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,15 +399,15 @@ 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: this->speedModifier = 7.0f; break; case PLAYER_FORM_GORON: - if (player->stateFlags3 & 0x1000) { // Goron Link is curled + if (player->stateFlags3 & PLAYER_STATE3_1000) { // Goron Link is curled this->speedModifier = 19.0f; } else { this->speedModifier = 7.0f; @@ -417,7 +417,7 @@ void EnRuppecrow_UpdateSpeed(EnRuppecrow* this, GlobalContext* globalCtx) { this->speedModifier = 7.0f; break; case PLAYER_FORM_HUMAN: - if (player->stateFlags1 & 0x800000) { + if (player->stateFlags1 & PLAYER_STATE1_800000) { this->speedModifier = 16.0f; } else { this->speedModifier = 7.0f; @@ -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; @@ -507,7 +507,7 @@ void EnRuppecrow_HandleSong(EnRuppecrow* this, GlobalContext* globalCtx) { this->actionFunc = EnRuppecrow_HandleSongCutscene; } - if (player->stateFlags2 & 0x8000000) { + if (player->stateFlags2 & PLAYER_STATE2_8000000) { Math_ApproachF(&this->actor.speedXZ, 0.0f, 0.1f, 1.0f); } else { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.1f, 0.1f); @@ -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; } @@ -577,20 +577,20 @@ void EnRuppecrow_FlyToDespawn(EnRuppecrow* this, GlobalContext* globalCtx) { Math_ApproachF(&this->actor.velocity.y, 3.0f, 0.2f, 0.5f); if (this->actor.world.pos.y > 1000.0f || this->actor.xzDistToPlayer > 2000.0f) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->yOffset += 0x800; this->actor.shape.yOffset = Math_SinS(this->yOffset) * 500.0f; Actor_MoveWithGravity(&this->actor); - if ((globalCtx->state.frames % 43) == 0) { + 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,12 +609,12 @@ 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); - Actor_MarkForDeath(&this->actor); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 0xB, NA_SE_EN_EXTINCT); + Actor_Kill(&this->actor); return; } } @@ -622,52 +622,52 @@ 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 { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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..887cd8c6b 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; @@ -37,6 +37,4 @@ typedef struct EnRuppecrow { /* 0x2D4 */ Vec3f limbPos[ENRUPPECROW_LIMB_POS_COUNT]; } EnRuppecrow; // size = 0x304 -extern const ActorInit En_Ruppecrow_InitVars; - #endif // Z_EN_RUPPECROW_H diff --git a/src/overlays/actors/ovl_En_Rz/overlay.cfg b/src/overlays/actors/ovl_En_Rz/overlay.cfg deleted file mode 100644 index 10c34f949..000000000 --- a/src/overlays/actors/ovl_En_Rz/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Rz -z_en_rz.c 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..108d88023 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -5,32 +5,51 @@ */ #include "z_en_rz.h" +#include "assets/objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #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 EnRz_ActorShadowFunc(Actor* thisx, Lights* mapper, PlayState* play); +void EnRz_ChangeAnim(PlayState*, EnRz*, s16 animIndex, u8 animMode, f32 morphFrames); +s32 EnRz_SetupPath(EnRz* this, PlayState* play); +EnRz* EnRz_FindSister(EnRz* this, PlayState*); +void func_80BFC058(EnRz* this, PlayState* play); +void func_80BFC078(EnRz* this, PlayState* play); +void func_80BFC3F8(EnRz* this, PlayState* play); +void func_80BFC674(EnRz* this, PlayState* play); +void func_80BFC7E0(EnRz* this, PlayState* play); +void EnRz_Walk(EnRz* this, PlayState* play); -#if 0 -const ActorInit En_Rz_InitVars = { +#define EN_RZ_STATE_1 (1 << 0) +#define EN_RZ_STATE_2 (1 << 1) + +typedef enum { + /* 0 */ EN_RZ_ANIM_THINKING, + /* 1 */ EN_RZ_ANIM_STANDING, + /* 2 */ EN_RZ_ANIM_WALKING, + /* 3 */ EN_RZ_ANIM_SITTING, + /* 4 */ EN_RZ_ANIM_APPLAUDING, + /* 5 */ EN_RZ_ANIM_ON_KNEES, + /* 6 */ EN_RZ_ANIM_DANCE, + /* 7 */ EN_RZ_ANIM_LINK_NORMAL_WAIT_FREE, + /* 8 */ EN_RZ_ANIM_LINK_DANCE, + /* 9 */ EN_RZ_ANIM_MAX +} EnRzAnimation; + +typedef enum { + /* 0 */ EN_RZ_PATHSTATUS_NORMAL, //!< not near waypoint + /* 1 */ EN_RZ_PATHSTATUS_AT_POINT, //!< no path or new waypoint + /* 2 */ EN_RZ_PATHSTATUS_END //!< reached end of path +} EnRzPathStatus; + +ActorInit En_Rz_InitVars = { ACTOR_EN_RZ, ACTORCAT_NPC, FLAGS, @@ -42,80 +61,647 @@ const ActorInit En_Rz_InitVars = { (ActorFunc)EnRz_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BFCCF4 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static TexturePtr sEyeTextures[] = { + object_rz_Tex_00BC50, object_rz_Tex_00C190, object_rz_Tex_00C590, object_rz_Tex_00C990, object_rz_Tex_00CD90, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +void EnRz_Init(Actor* thisx, PlayState* play) { + EnRz* this = THIS; + s16 tempCutscene = this->actor.cutscene; + s32 i; -extern ColliderCylinderInit D_80BFCCF4; + for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { + this->cutscenes[i] = tempCutscene; + if (tempCutscene != -1) { + this->actor.cutscene = tempCutscene; + tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -extern UNK_TYPE D_06003A20; -extern UNK_TYPE D_0600D768; + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, EnRz_ActorShadowFunc, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/EnRz_Init.s") + // @bug this alignment is because of player animations, but should be using ALIGN16 + SkelAnime_InitFlex(play, &this->skelAnime, &object_rz_Skel_00D8D8, &gRosaSistersStandingAnim, + (uintptr_t)this->jointTable & ~0xF, (uintptr_t)this->morphTable & ~0xF, OBJECT_RZ_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gRosaSistersStandingAnim); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFB780.s") + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFB864.s") + this->actionFunc = func_80BFC058; + EnRz_SetupPath(this, play); + this->animIndex = EN_RZ_ANIM_MAX; + this->actor.targetMode = 0; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFB9E4.s") + switch (EN_RZ_GET_TYPE(thisx)) { + case EN_RZ_TYPE_1: + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_77_04)) { + Actor_Kill(&this->actor); + return; + } + EnRz_ChangeAnim(play, this, EN_RZ_ANIM_SITTING, ANIMMODE_LOOP, 0.0f); + this->actionFunc = func_80BFC674; + this->actor.shape.yOffset = -1500.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBA1C.s") + case EN_RZ_TYPE_2: + this->actor.flags |= ACTOR_FLAG_10; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_04)) { + EnRz_ChangeAnim(play, this, EN_RZ_ANIM_LINK_DANCE, ANIMMODE_LOOP, 0.0f); + } else { + EnRz_ChangeAnim(play, this, EN_RZ_ANIM_DANCE, ANIMMODE_LOOP, 0.0f); + } + this->actionFunc = func_80BFC3F8; + this->sister = EnRz_FindSister(this, play); + this->actor.uncullZoneForward = 300.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBA50.s") + default: // EN_RZ_TYPE_0 + this->stateFlags |= EN_RZ_STATE_2; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_04)) { + Actor_Kill(&this->actor); + return; + } + EnRz_ChangeAnim(play, this, EN_RZ_ANIM_WALKING, ANIMMODE_LOOP, 0.0f); + this->actionFunc = EnRz_Walk; + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + this->actor.textId = 0x291C; + } else { // EN_RZ_MARILLA + this->actor.textId = 0x2920; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBB44.s") + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + this->csAction = 0x226; + } else { // EN_RZ_MARILLA + this->csAction = 0x227; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBC78.s") + this->actionIndex = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBCEC.s") +/** + * Custom shadow draw function of type ActorShadowFunc. + */ +void EnRz_ActorShadowFunc(Actor* thisx, Lights* mapper, PlayState* play) { + Vec3f oldPos; + EnRz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBD54.s") + if (this->animIndex == EN_RZ_ANIM_LINK_DANCE) { + f32 tempScale = (((27.0f - this->shadowPos.y) + this->actor.world.pos.y) * ((1 / 2.25f) * 0.001f)) + 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBDA0.s") + this->actor.scale.x = tempScale; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBDFC.s") + Math_Vec3f_Copy(&oldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&this->actor.world.pos, &this->shadowPos); + func_800B4AEC(play, &this->actor, 50.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/EnRz_Destroy.s") + if (oldPos.y < this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + } else { + this->actor.world.pos.y = oldPos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBE70.s") + ActorShadow_DrawCircle(&this->actor, mapper, play); + Math_Vec3f_Copy(&this->actor.world.pos, &oldPos); + this->actor.scale.x = 0.01f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBFAC.s") +void EnRz_ChangeAnim(PlayState* play, EnRz* this, s16 animIndex, u8 animMode, f32 morphFrames) { + // N.B. both of these arrays must be the same length due to how the animations are chosen + static AnimationHeader* sJudoAnimations[] = { + &gRosaSistersThinkingAnim, &gRosaSistersStandingAnim, &gRosaSistersWalkingWhileThinkingAnim, + &gRosaSistersSittingAnim, &gRosaSistersApplaudingAnim, &gRosaSistersOnKneesAnim, + &gRosaSistersDancingAnim, + }; + static AnimationHeader* sMarillaAnimations[] = { + &gRosaSistersStandingAnim, &gRosaSistersStandingAnim, &gRosaSistersWalkingAnim, &gRosaSistersSittingAnim, + &gRosaSistersApplaudingAnim, &gRosaSistersOnKneesAnim, &gRosaSistersDancingAnim, + }; + static LinkAnimationHeader* sLinkAnimations[] = { + &gPlayerAnim_link_normal_wait_free, + &gPlayerAnim_alink_dance_loop, + }; + f32 endFrame; + AnimationHeader** animationPtr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC058.s") + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + animationPtr = sJudoAnimations; + } else { // EN_RZ_MARILLA + animationPtr = sMarillaAnimations; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC078.s") + if ((animIndex >= EN_RZ_ANIM_THINKING) && (animIndex < EN_RZ_ANIM_MAX) && + ((animIndex != this->animIndex) || (animMode != ANIMMODE_LOOP))) { + if (animIndex >= ARRAY_COUNT(sJudoAnimations)) { + endFrame = Animation_GetLastFrame(sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)]); + if (animMode == ANIMMODE_LOOP) { + LinkAnimation_Change(play, &this->skelAnime, sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], + 2.0f / 3.0f, 0.0f, endFrame, ANIMMODE_LOOP, morphFrames); + } else { + LinkAnimation_Change(play, &this->skelAnime, sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], + 2.0f / 3.0f, 0.0f, endFrame, ANIMMODE_LOOP, morphFrames); + } + } else { + Animation_Change(&this->skelAnime, animationPtr[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(animationPtr[animIndex]), animMode, morphFrames); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC19C.s") + this->animIndex = animIndex; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC214.s") +void func_80BFB9E4(PlayState* play, EnRz* this, s16 animIndex) { + EnRz_ChangeAnim(play, this, animIndex, ANIMMODE_LOOP, -5.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC270.s") +void func_80BFBA1C(PlayState* play, EnRz* this, s16 animIndex) { + EnRz_ChangeAnim(play, this, animIndex, ANIMMODE_LOOP, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC2F4.s") +s32 EnRz_SetupPath(EnRz* this, PlayState* play) { + if (EN_RZ_GET_PATH(&this->actor) != 0x3F) { + this->path = &play->setupPathList[EN_RZ_GET_PATH(&this->actor)]; + if (this->path != NULL) { + Path* path = this->path; + Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + f32 diffX = points->x - this->actor.world.pos.x; + f32 diffY = points->z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC36C.s") + if ((SQ(diffX) + SQ(diffY)) < SQ(10.0f)) { + this->curPointIndex = 0; + this->stateFlags &= ~EN_RZ_STATE_1; + } else { + this->curPointIndex = path->count - 1; + this->stateFlags |= EN_RZ_STATE_1; + return true; + } + } + } else { + this->path = NULL; + this->curPointIndex = 0; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC3F8.s") +EnRzPathStatus EnRz_GetPathStatus(EnRz* this) { + Path* path = this->path; + Vec3s* curPoint; + f32 diffX; + f32 diffZ; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC608.s") + if (path == NULL) { + return EN_RZ_PATHSTATUS_AT_POINT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC674.s") + curPoint = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->curPointIndex]; + diffX = curPoint->x - this->actor.world.pos.x; + diffZ = curPoint->z - this->actor.world.pos.z; + this->actor.world.rot.y = Math_Atan2S(diffX, diffZ); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x07D0, 0xC8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC728.s") + if ((SQ(diffX) + SQ(diffZ)) < SQ(10.0f)) { + if (this->stateFlags & EN_RZ_STATE_1) { + this->curPointIndex--; + if (this->curPointIndex < 0) { + return EN_RZ_PATHSTATUS_END; + } + } else { + this->curPointIndex++; + if (this->curPointIndex >= path->count) { + return EN_RZ_PATHSTATUS_END; + } + } + return EN_RZ_PATHSTATUS_AT_POINT; + } + return EN_RZ_PATHSTATUS_NORMAL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC7E0.s") +s32 EnRz_CanTalk(EnRz* this, PlayState* play) { + if ((this->actor.xzDistToPlayer < 80.0f) && (fabsf(this->actor.playerHeightRel) < 20.0f) && + Player_IsFacingActor(&this->actor, 0x3000, play)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC8AC.s") +s32 func_80BFBCEC(EnRz* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC8F8.s") + if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsFacingPlayer(&this->actor, 0x3000) && + (player->stateFlags2 & PLAYER_STATE2_2000000)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/EnRz_Update.s") +s32 EnRz_UpdateSkelAnime(EnRz* this, PlayState* play) { + if (this->animIndex < EN_RZ_ANIM_LINK_NORMAL_WAIT_FREE) { + return SkelAnime_Update(&this->skelAnime); + } else { + return LinkAnimation_Update(play, &this->skelAnime); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFCAD0.s") +EnRz* EnRz_FindSister(EnRz* this, PlayState* play) { + Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/EnRz_Draw.s") + while (npc != NULL) { + if ((npc->id == ACTOR_EN_RZ) && (EN_RZ_GET_TYPE(&this->actor) == EN_RZ_GET_TYPE(npc))) { + if (&this->actor != npc) { + return (EnRz*)npc; + } + } + npc = npc->next; + } + return NULL; +} + +void func_80BFBDFC(PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_80)) { + func_80151BB4(play, 0x27); + } + func_80151BB4(play, 0xC); +} + +void EnRz_Destroy(Actor* thisx, PlayState* play) { + EnRz* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); +} + +s32 func_80BFBE70(EnRz* this, PlayState* play) { + u16 action; + + if ((EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) && (this->animIndex == EN_RZ_ANIM_APPLAUDING)) { + func_800B9010(&this->actor, NA_SE_EV_CLAPPING_2P - SFX_FLAG); + } + + if (Cutscene_CheckActorAction(play, this->csAction)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); + action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action; + if (this->actionIndex != action) { + this->actionIndex = action; + switch (this->actionIndex) { + case 1: + func_80BFBA1C(play, this, EN_RZ_ANIM_STANDING); + break; + + case 2: + func_80BFBA1C(play, this, EN_RZ_ANIM_ON_KNEES); + break; + + case 3: + func_80BFBA1C(play, this, EN_RZ_ANIM_APPLAUDING); + break; + + case 4: + func_80BFBA1C(play, this, EN_RZ_ANIM_LINK_DANCE); + break; + } + } + return true; + } + + return false; +} + +s32 func_80BFBFAC(EnRz* this, PlayState* play) { + if (this->actor.cutscene == -1) { + Message_StartTextbox(play, 0x2925, &this->actor); + this->actionFunc = func_80BFC078; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + return false; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + return true; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + return false; +} + +void func_80BFC058(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); +} + +void func_80BFC078(EnRz* this, PlayState* play) { + s32 pad; + Vec3f sp28; + + EnRz_UpdateSkelAnime(this, play); + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x2927: + case 0x2928: + func_80151938(play, play->msgCtx.currentTextId + 1); + SET_WEEKEVENTREG(WEEKEVENTREG_77_04); + break; + + default: + func_801477B4(play); + this->actionFunc = func_80BFC3F8; + if (this->animIndex != EN_RZ_ANIM_LINK_DANCE) { + func_80BFB9E4(play, this, EN_RZ_ANIM_DANCE); + if (this->sister != NULL) { + func_80BFB9E4(play, this->sister, EN_RZ_ANIM_DANCE); + } + } + break; + } + } + + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + sp28.x = this->actor.projectedPos.x; + sp28.y = this->actor.projectedPos.y; + sp28.z = this->actor.projectedPos.z; + func_801A1FB4(3, &sp28, NA_BGM_ROSA_SISTERS, 900.0f); + } +} + +void func_80BFC19C(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (!func_80BFBE70(this, play)) { + this->actionFunc = func_80BFC3F8; + func_80BFBA1C(play, this, EN_RZ_ANIM_LINK_DANCE); + if (this->sister != NULL) { + func_80BFBA1C(play, this->sister, EN_RZ_ANIM_LINK_DANCE); + } + } +} + +void func_80BFC214(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (!func_80BFBE70(this, play) && func_80BFBFAC(this, play)) { + this->actionFunc = func_80BFC19C; + } +} + +void func_80BFC270(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + this->actionFunc = func_80BFC214; + func_80BFBDFC(play); + } else { + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 2000.0f, 1000.0f); + } +} + +void func_80BFC2F4(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (!func_80BFBE70(this, play)) { + func_801477B4(play); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 2000.0f, 1000.0f); + this->actionFunc = func_80BFC270; + } +} + +void func_80BFC36C(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (func_80BFBFAC(this, play)) { + SET_WEEKEVENTREG(WEEKEVENTREG_77_04); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_80)) { + this->actionFunc = func_80BFC214; + } else { + this->actionFunc = func_80BFC2F4; + SET_WEEKEVENTREG(WEEKEVENTREG_75_80); + } + this->actor.cutscene = this->cutscenes[1]; + } +} + +void func_80BFC3F8(EnRz* this, PlayState* play) { + s32 pad; + Vec3f bgmPos; + + EnRz_UpdateSkelAnime(this, play); + + if (this->sister == NULL) { + this->sister = EnRz_FindSister(this, play); + } + + if (!func_80BFBE70(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80BFC078; + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { + this->actionFunc = func_80BFC36C; + this->actor.cutscene = this->cutscenes[0]; + this->actor.flags &= ~ACTOR_FLAG_10000; + } else if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_04)) { + Message_StartTextbox(play, 0x2925, &this->actor); + func_80BFBDFC(play); + } else { + Message_StartTextbox(play, 0x2926, &this->actor); + func_80BFBDFC(play); + } + } else { + Message_StartTextbox(play, 0x2926, &this->actor); + func_80BFBDFC(play); + } + + } else if (EnRz_CanTalk(this, play)) { + if (func_80BFBCEC(this, play) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_77_04) && this->sister != NULL) { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_IA_MINUS1); + } else { + this->actor.flags &= ~ACTOR_FLAG_10000; + func_800B8614(&this->actor, play, 120.0f); + } + } + + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + bgmPos.x = this->actor.projectedPos.x; + bgmPos.y = this->actor.projectedPos.y; + bgmPos.z = this->actor.projectedPos.z; + func_801A1FB4(3, &bgmPos, NA_BGM_ROSA_SISTERS, 900.0f); + } + } +} + +void func_80BFC608(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = func_80BFC674; + } +} + +void func_80BFC674(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80BFC608; + if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { + Message_StartTextbox(play, 0x2925, &this->actor); + } else { + Message_StartTextbox(play, 0x2924, &this->actor); + } + } else if (EnRz_CanTalk(this, play)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void func_80BFC728(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = func_80BFC7E0; + this->actor.textId++; + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + if (this->actor.textId >= 0x2920) { + this->actor.textId = 0x291C; + } + } else if (this->actor.textId >= 0x2924) { + this->actor.textId = 0x2920; + } + } +} + +void func_80BFC7E0(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + + if (this->timer > 0) { + this->timer--; + } else { + this->actionFunc = EnRz_Walk; + func_80BFB9E4(play, this, EN_RZ_ANIM_WALKING); + } + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80BFC728; + func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); + this->actor.speedXZ = 0.0f; + func_80BFBDFC(play); + } else if (EnRz_CanTalk(this, play)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void EnRz_StopToThink(EnRz* this, PlayState* play) { + this->timer = 100; + this->actionFunc = func_80BFC7E0; + this->actor.speedXZ = 0.0f; + func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); +} + +void EnRz_Walk(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + this->actor.speedXZ = 1.5f; + + switch (EnRz_GetPathStatus(this)) { + case EN_RZ_PATHSTATUS_END: + EnRz_SetupPath(this, play); + EnRz_StopToThink(this, play); + break; + + case EN_RZ_PATHSTATUS_AT_POINT: + EnRz_StopToThink(this, play); + break; + + default: + break; + } + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80BFC728; + func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); + this->actor.speedXZ = 0.0f; + func_80BFBDFC(play); + } else if (EnRz_CanTalk(this, play)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void EnRz_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnRz* 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, 40.0f, 25.0f, 40.0f, 5); + + this->actionFunc(this, play); + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + + this->eyeIndex = this->blinkTimer; + if (this->eyeIndex > 2) { + this->eyeIndex = 0; + } +} + +void EnRz_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sFocusOffsetPos = { 500.0f, -500.0f, 0.0f }; + EnRz* this = THIS; + + if (limbIndex == OBJECT_RZ_LIMB_0B) { + Matrix_MultVec3f(&sFocusOffsetPos, &thisx->focus.pos); + } + if (limbIndex == OBJECT_RZ_LIMB_03) { + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); + } +} + +void EnRz_Draw(Actor* thisx, PlayState* play) { + EnRz* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + AnimatedMat_DrawStepOpa(play, Lib_SegmentedToVirtual(&object_rz_Matanimheader_00D768), 0); + } else { // EN_RZ_MARILLA + AnimatedMat_DrawStepOpa(play, Lib_SegmentedToVirtual(&object_rz_Matanimheader_00D768), 1); + } + + if (this->animIndex == EN_RZ_ANIM_APPLAUDING) { + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[4])); + } else if (this->stateFlags & EN_RZ_STATE_2) { + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[3])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + } + + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnRz_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} 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..38a7088e8 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.h +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.h @@ -2,17 +2,48 @@ #define Z_EN_RZ_H #include "global.h" +#include "assets/objects/object_rz/object_rz.h" + +#define EN_RZ_GET_SISTER(thisx) ((thisx)->params & 0x8000) +#define EN_RZ_GET_TYPE(thisx) ((thisx)->params & 0xF) +#define EN_RZ_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) + +typedef enum { + /* 0 */ EN_RZ_JUDO, // in red + /* 1 */ EN_RZ_MARILLA // in blue +} EnRzSister; + +typedef enum { + /* 0 */ EN_RZ_TYPE_0, + /* 1 */ EN_RZ_TYPE_1, + /* 2 */ EN_RZ_TYPE_2 +} EnRzType; 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 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_RZ_LIMB_MAX]; + /* 0x20C */ UNK_TYPE1 pad20C[0x94]; + /* 0x2A0 */ Vec3s morphTable[OBJECT_RZ_LIMB_MAX]; + /* 0x324 */ UNK_TYPE1 pad324[0x94]; + /* 0x3B8 */ Path* path; + /* 0x3BC */ s32 curPointIndex; + /* 0x3C0 */ ColliderCylinder collider; + /* 0x40C */ struct EnRz* sister; + /* 0x410 */ s16 eyeIndex; + /* 0x412 */ s16 blinkTimer; + /* 0x414 */ Vec3f shadowPos; + /* 0x420 */ u16 stateFlags; + /* 0x422 */ s16 animIndex; + /* 0x424 */ s16 timer; + /* 0x426 */ u16 csAction; + /* 0x428 */ u16 actionIndex; + /* 0x42A */ s16 cutscenes[2]; + /* 0x430 */ EnRzActionFunc actionFunc; } EnRz; // size = 0x434 -extern const ActorInit En_Rz_InitVars; - #endif // Z_EN_RZ_H diff --git a/src/overlays/actors/ovl_En_S_Goro/overlay.cfg b/src/overlays/actors/ovl_En_S_Goro/overlay.cfg deleted file mode 100644 index 195f952ea..000000000 --- a/src/overlays/actors/ovl_En_S_Goro/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_S_Goro -z_en_s_goro.c 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..cc3cd2455 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,19 +4,97 @@ * 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) -#if 0 -const ActorInit En_S_Goro_InitVars = { +#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; + +ActorInit En_S_Goro_InitVars = { ACTOR_EN_S_GORO, ACTORCAT_NPC, FLAGS, @@ -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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_36_02)) { + switch (this->textId) { + case 0xCFB: + return 0xCFC; + case 0xCFC: + return 0xCFD; + case 0xCFD: + SET_WEEKEVENTREG(WEEKEVENTREG_36_02); + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xCFE; + default: + return 0xCFB; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xCFE; + } + } else { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_36_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_36_01); + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_36_08)) { + if (this->textId == 0xD02) { + SET_WEEKEVENTREG(WEEKEVENTREG_36_08); + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD03; + } + return 0xD02; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD04; + } + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_36_04)) { + if (this->textId == 0xCFF) { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + SET_WEEKEVENTREG(WEEKEVENTREG_36_04); + return 0xD00; + } + return 0xCFF; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD01; + } + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_36_10)) { + if (this->textId == 0xD05) { + SET_WEEKEVENTREG(WEEKEVENTREG_36_10); + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_36_40)) { + switch (this->textId) { + case 0xD15: + return 0xD16; + case 0xD16: + SET_WEEKEVENTREG(WEEKEVENTREG_36_40); + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD17; + default: + return 0xD15; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD17; + } + } else { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_36_20)) { + SET_WEEKEVENTREG(WEEKEVENTREG_36_20); + return 0xD13; + } + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD14; + } + } else if (player->transformation == PLAYER_FORM_GORON) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_37_01)) { + switch (this->textId) { + case 0xD1E: + return 0xD1F; + case 0xD1F: + SET_WEEKEVENTREG(WEEKEVENTREG_37_01); + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD20; + default: + return 0xD1E; + } + } else { + this->actionFlags |= EN_S_GORO_ACTIONFLAG_LASTMESSAGE; + return 0xD21; + } + } else { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_36_80)) { + switch (this->textId) { + case 0xD18: + return 0xD19; + case 0xD19: + return 0xD1A; + case 0xD1A: + return 0xD1B; + case 0xD1B: + SET_WEEKEVENTREG(WEEKEVENTREG_36_80); + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { + if (player->transformation == PLAYER_FORM_GORON) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_37_02)) { + switch (this->textId) { + case 0xD09: + return 0xD0A; + case 0xD0A: + return 0xD0B; + case 0xD0B: + SET_WEEKEVENTREG(WEEKEVENTREG_37_02); + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_37_04)) { + switch (this->textId) { + case 0xD0E: + return 0xD0F; + case 0xD0F: + SET_WEEKEVENTREG(WEEKEVENTREG_37_04); + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_80)) { + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_80)) { + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_80)) { + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_80)) { + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_80)) { + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_80)) { + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { + 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] = VIRTUAL_TO_PHYSICAL(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] = VIRTUAL_TO_PHYSICAL(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) || CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04))) { + + 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[PLAYER_BODYPART_HEAD].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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_04)) { + 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_Kill(&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_Kill(&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] = VIRTUAL_TO_PHYSICAL(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..5777af17b 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,57 @@ #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 void (*EnSGoroActionFunc)(struct EnSGoro*, PlayState*); typedef struct EnSGoro { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x48]; - /* 0x018C */ EnSGoroActionFunc actionFunc; - /* 0x0190 */ char unk_190[0x180]; + /* 0x000 */ Actor actor; + /* 0x144 */ 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 -extern const ActorInit En_S_Goro_InitVars; +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/overlay.cfg b/src/overlays/actors/ovl_En_Sb/overlay.cfg deleted file mode 100644 index 12658e763..000000000 --- a/src/overlays/actors/ovl_En_Sb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sb -z_en_sb.c 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..868b48923 100644 --- a/src/overlays/actors/ovl_En_Sb/z_en_sb.c +++ b/src/overlays/actors/ovl_En_Sb/z_en_sb.c @@ -11,21 +11,21 @@ #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 = { +ActorInit En_Sb_InitVars = { ACTOR_EN_SB, ACTORCAT_ENEMY, FLAGS, @@ -92,7 +92,7 @@ static DamageTable sDamageTable = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 39, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_SHELLBLADE, ICHAIN_CONTINUE), ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 30, ICHAIN_STOP), }; @@ -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,34 @@ void EnSb_Update(Actor* thisx, GlobalContext* globalCtx) { } else { this->actor.params = 1; } - Item_DropCollectibleRandom(globalCtx, &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); - if (player->stateFlags1 & 0x8000000) { - Collider_UpdateCylinder(&this->actor, &this->collider); - if (this->vulnerableTimer == 0) { - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - } - SkelAnime_Update(&this->skelAnime); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x80); + Actor_Kill(&this->actor); + return; } + + Actor_SetFocus(&this->actor, 20.0f); + Actor_MoveWithGravity(&this->actor); + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 25.0f, 20.0f, 5); + EnSb_UpdateDamage(this, play); + if (player->stateFlags1 & PLAYER_STATE1_8000000) { + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->vulnerableTimer == 0) { + CollisionCheck_SetAT(play, &play->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 +403,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 +420,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..b27322226 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 { @@ -33,6 +33,4 @@ typedef struct EnSb { /* 0x253 */ u8 isDrawn; } EnSb; // size = 0x254 -extern const ActorInit En_Sb_InitVars; - #endif // Z_EN_SB_H diff --git a/src/overlays/actors/ovl_En_Sc_Ruppe/overlay.cfg b/src/overlays/actors/ovl_En_Sc_Ruppe/overlay.cfg deleted file mode 100644 index 2262aa0bb..000000000 --- a/src/overlays/actors/ovl_En_Sc_Ruppe/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sc_Ruppe -z_en_sc_ruppe.c 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..fa017af87 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,21 +5,25 @@ */ #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); -#if 0 -const ActorInit En_Sc_Ruppe_InitVars = { +typedef struct { + /* 0x0 */ TexturePtr tex; + /* 0x4 */ s16 amount; +} RuppeInfo; + +ActorInit En_Sc_Ruppe_InitVars = { ACTOR_EN_SC_RUPPE, ACTORCAT_NPC, FLAGS, @@ -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[] = { + { gRupeeGreenTex, 1 }, // Green rupee + { gRupeeBlueTex, 5 }, // Blue rupee + { gRupeeRedTex, 20 }, // Red rupee + { gRupeeOrangeTex, 200 }, // Orange rupee + { gRupeePurpleTex, 50 }, // Purple rupee + { gRupeeSilverTex, 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_04)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_53_04); + return true; + } + break; + case RUPEE_BLUE: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_80)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_53_80); + return true; + } + break; + case RUPEE_RED: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_01)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_54_01); + return true; + } + break; + case RUPEE_ORANGE: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_02)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_54_02); + return true; + } + break; + case RUPEE_PURPLE: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_04)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_54_04); + return true; + } + break; + case RUPEE_UNUSED: + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_08)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_54_08); + 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_Kill(&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++, gRupeeDL); + + 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..8ef0f4c56 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,27 @@ #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 -extern const ActorInit En_Sc_Ruppe_InitVars; +typedef enum { + /* 0 */ RUPEE_GREEN, + /* 1 */ RUPEE_BLUE, + /* 2 */ RUPEE_RED, + /* 3 */ RUPEE_ORANGE, + /* 4 */ RUPEE_PURPLE, + /* 5 */ RUPEE_UNUSED, +} RupeeType; #endif // Z_EN_SC_RUPPE_H diff --git a/src/overlays/actors/ovl_En_Scopecoin/overlay.cfg b/src/overlays/actors/ovl_En_Scopecoin/overlay.cfg deleted file mode 100644 index 2c605c8bc..000000000 --- a/src/overlays/actors/ovl_En_Scopecoin/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Scopecoin -z_en_scopecoin.c 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..d2a9d525e 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.c @@ -11,15 +11,12 @@ #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); - -const ActorInit En_Scopecoin_InitVars = { +ActorInit En_Scopecoin_InitVars = { ACTOR_EN_SCOPECOIN, ACTORCAT_NPC, FLAGS, @@ -31,75 +28,76 @@ const ActorInit En_Scopecoin_InitVars = { (ActorFunc)EnScopecoin_Draw, }; -void func_80BFCFA0(EnScopecoin* this, GlobalContext* globalCtx) { - this->actor.shape.rot.y += 500; +void EnScopecoin_Spin(EnScopecoin* this, PlayState* play) { + this->actor.shape.rot.y += 0x1F4; } -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); - Actor_MarkForDeath(&this->actor); +void EnScopecoin_CheckCollectible(EnScopecoin* this, PlayState* play) { + if (Flags_GetCollectible(play, OBJMUPICT_GET_RUPEE_FLAG(&this->actor))) { + Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_RED); + Actor_Kill(&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); ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 10.0f); - this->unk148 = (this->actor.params & 0xF); - if (this->unk148 < 0 || this->unk148 >= 8) { - this->unk148 = 0; + + this->rupeeIndex = OBJMUPICT_GET_RUPEE_INDEX(&this->actor); + if ((this->rupeeIndex < 0) || (this->rupeeIndex > 7)) { + this->rupeeIndex = 0; } - if (globalCtx->actorCtx.unk5 & 2) { - if (this->unk148 == 2 || this->unk148 == 6) { - if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { - Actor_MarkForDeath(&this->actor); + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + if ((this->rupeeIndex == 2) || (this->rupeeIndex == 6)) { + if (Flags_GetCollectible(play, OBJMUPICT_GET_RUPEE_FLAG(&this->actor))) { + Actor_Kill(&this->actor); return; } } this->actor.shape.yOffset = 700.0f; - this->actionFunc = func_80BFCFA0; - return; - } - if (this->unk148 == 2 || this->unk148 == 6) { - if (Flags_GetCollectible(globalCtx, (this->actor.params & 0x7F0) >> 4)) { - Actor_MarkForDeath(&this->actor); - } else { - this->actor.draw = NULL; - this->actionFunc = func_80BFCFB8; - } + this->actionFunc = EnScopecoin_Spin; } else { - Actor_MarkForDeath(&this->actor); + if ((this->rupeeIndex == 2) || (this->rupeeIndex == 6)) { + if (Flags_GetCollectible(play, OBJMUPICT_GET_RUPEE_FLAG(&this->actor))) { + Actor_Kill(&this->actor); + return; + } + this->actor.draw = NULL; + this->actionFunc = EnScopecoin_CheckCollectible; + } else { + Actor_Kill(&this->actor); + } } } -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[] = { - gameplay_keep_Tex_061FC0, gameplay_keep_Tex_061FE0, gameplay_keep_Tex_062000, gameplay_keep_Tex_062040, - gameplay_keep_Tex_062020, gameplay_keep_Tex_062060, gameplay_keep_Tex_062000, +static TexturePtr sRupeeTextures[] = { + gRupeeGreenTex, gRupeeBlueTex, gRupeeRedTex, gRupeeOrangeTex, gRupeePurpleTex, gRupeeSilverTex, gRupeeRedTex, }; -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(play->state.gfxCtx); + func_800B8050(&this->actor, play, 0); - func_8012C28C(globalCtx->state.gfxCtx); - func_800B8050(&this->actor, globalCtx, 0); OPEN_DISPS(gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80BFD280[this->unk148])); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); + 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(sRupeeTextures[this->rupeeIndex])); + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); CLOSE_DISPS(gfxCtx); } 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..4dda736f8 100644 --- a/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h +++ b/src/overlays/actors/ovl_En_Scopecoin/z_en_scopecoin.h @@ -5,15 +5,15 @@ struct EnScopecoin; -typedef void (*EnScopecoinActionFunc)(struct EnScopecoin*, GlobalContext*); +#define OBJMUPICT_GET_RUPEE_INDEX(thisx) ((thisx)->params & 0xF) +#define OBJMUPICT_GET_RUPEE_FLAG(thisx) (((thisx)->params & 0x7F0) >> 4) + +typedef void (*EnScopecoinActionFunc)(struct EnScopecoin*, PlayState*); typedef struct EnScopecoin { /* 0x000 */ Actor actor; /* 0x144 */ EnScopecoinActionFunc actionFunc; - /* 0x148 */ s16 unk148; - /* 0x14A */ s16 unk14A; + /* 0x148 */ s16 rupeeIndex; } EnScopecoin; // size = 0x14C -extern const ActorInit En_Scopecoin_InitVars; - #endif // Z_EN_SCOPECOIN_H diff --git a/src/overlays/actors/ovl_En_Scopecrow/overlay.cfg b/src/overlays/actors/ovl_En_Scopecrow/overlay.cfg deleted file mode 100644 index 880bf5539..000000000 --- a/src/overlays/actors/ovl_En_Scopecrow/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Scopecrow -z_en_scopecrow.c 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 5743f4a48..b37190ee1 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,15 @@ #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); -const ActorInit En_Scopecrow_InitVars = { +ActorInit En_Scopecrow_InitVars = { ACTOR_EN_SCOPECROW, ACTORCAT_NPC, FLAGS, @@ -57,52 +57,58 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -void func_80BCD000(EnScopecrow* this, GlobalContext* globalCtx) { +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; - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } s32 func_80BCD09C(s16 arg0) { switch (arg0) { case 0: - if (gSaveContext.save.weekEventReg[53] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_04)) { return true; + } else { + return false; } - return false; case 1: - if (gSaveContext.save.weekEventReg[53] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_80)) { return true; + } else { + return false; } - return false; case 2: - if (gSaveContext.save.weekEventReg[54] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_01)) { return true; + } else { + return false; } - return false; case 3: - if (gSaveContext.save.weekEventReg[54] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_02)) { return true; + } else { + return false; } - return false; case 4: - if (gSaveContext.save.weekEventReg[54] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_04)) { return true; + } else { + return false; } - return false; case 5: - if (gSaveContext.save.weekEventReg[54] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_54_08)) { return true; + } else { + return false; } - return false; } return false; @@ -111,43 +117,43 @@ s32 func_80BCD09C(s16 arg0) { s32 func_80BCD1AC(s16 arg0) { switch (arg0) { case 0: - if (!(gSaveContext.save.weekEventReg[53] & 4)) { - gSaveContext.save.weekEventReg[53] |= 4; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_53_04)) { + SET_WEEKEVENTREG(WEEKEVENTREG_53_04); return true; } break; case 1: - if (!(gSaveContext.save.weekEventReg[53] & 0x80)) { - gSaveContext.save.weekEventReg[53] |= 0x80; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_53_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_53_80); return true; } break; case 2: - if (!(gSaveContext.save.weekEventReg[54] & 1)) { - gSaveContext.save.weekEventReg[54] |= 1; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_54_01)) { + SET_WEEKEVENTREG(WEEKEVENTREG_54_01); return true; } break; case 3: - if (!(gSaveContext.save.weekEventReg[54] & 2)) { - gSaveContext.save.weekEventReg[54] |= 2; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_54_02)) { + SET_WEEKEVENTREG(WEEKEVENTREG_54_02); return true; } break; case 4: - if (!(gSaveContext.save.weekEventReg[54] & 4)) { - gSaveContext.save.weekEventReg[54] |= 4; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_54_04)) { + SET_WEEKEVENTREG(WEEKEVENTREG_54_04); return true; } break; case 5: - if (!(gSaveContext.save.weekEventReg[54] & 8)) { - gSaveContext.save.weekEventReg[54] |= 8; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_54_08)) { + SET_WEEKEVENTREG(WEEKEVENTREG_54_08); return true; } break; @@ -156,8 +162,8 @@ s32 func_80BCD1AC(s16 arg0) { return false; } -void func_80BCD2BC(EnScopecrow* this, GlobalContext* globalCtx) { - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SC_RUPPE, this->actor.world.pos.x, +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); @@ -213,18 +219,19 @@ f32 func_80BCD4D0(Path* path, s32 count, Vec3f* arg2, Vec3s* arg3) { return sp20.y - arg2->y; } -void func_80BCD590(EnScopecrow* this, GlobalContext* globalCtx) { - Vec3f sp1C; +void func_80BCD590(EnScopecrow* this, PlayState* play) { + Vec3f screenPos; - func_80169474(globalCtx, &this->actor.world.pos, &sp1C); + Play_GetScreenPos(play, &this->actor.world.pos, &screenPos); - if ((sp1C.x >= 130.0f) && (sp1C.x < 190.0f) && (sp1C.y >= 90.0f) && (sp1C.y < 150.0f)) { + 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, GlobalContext* globalCtx) { +void func_80BCD640(EnScopecrow* this, PlayState* play) { Vec3s sp30; if (this->path != NULL) { @@ -239,11 +246,11 @@ void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx) { if (func_80BCD334(this, this->path, this->unk_1FC)) { if ((this->unk_1FC == this->unk_262) && func_80BCD1AC(this->unk_260)) { - func_80BCD2BC(this, globalCtx); + func_80BCD2BC(this, play); } if (this->unk_1FC >= (this->path->count - 1)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->unk_1FC++; } @@ -256,7 +263,7 @@ void func_80BCD640(EnScopecrow* this, GlobalContext* globalCtx) { this->actor.shape.yOffset = Math_SinS(this->unk_264) * 500.0f; } -void EnScopecrow_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnScopecrow_Init(Actor* thisx, PlayState* play) { EnScopecrow* this = THIS; Vec3s* temp; CollisionPoly* sp4C; @@ -269,7 +276,7 @@ void EnScopecrow_Init(Actor* thisx, GlobalContext* globalCtx) { } if (func_80BCD09C(this->unk_260)) { - this->path = SubS_GetPathByIndex(globalCtx, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); this->unk_262 = ENSCOPECROW_GET_3E0(&this->actor); if (this->path != NULL) { @@ -285,31 +292,31 @@ void EnScopecrow_Init(Actor* thisx, GlobalContext* globalCtx) { sp3C.z = points->z; this->actor.world.pos = sp3C; - this->actor.world.pos.y = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp4C, &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); + Actor_Kill(&this->actor); } - func_80BCD2BC(this, globalCtx); - Actor_MarkForDeath(&this->actor); + func_80BCD2BC(this, play); + Actor_Kill(&this->actor); return; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - if (globalCtx->actorCtx.unk5 & 2) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGuaySkel, &gGuayFlyAnim, this->jointTable, this->morphTable, + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + 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(globalCtx, &this->collider); - Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + 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(globalCtx, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); + this->path = SubS_GetPathByIndex(play, ENSCOPECROW_GET_PATH(&this->actor), 0x3F); this->unk_262 = ENSCOPECROW_GET_3E0(&this->actor); if (this->path != NULL) { @@ -322,32 +329,32 @@ void EnScopecrow_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } -void EnScopecrow_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnScopecrow_Destroy(Actor* thisx, PlayState* play) { EnScopecrow* this = THIS; - Collider_DestroyJntSph(globalCtx, &this->collider); + Collider_DestroyJntSph(play, &this->collider); } -void EnScopecrow_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnScopecrow_Update(Actor* thisx, PlayState* play) { EnScopecrow* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - func_80BCD000(this, globalCtx); + func_80BCD000(this, play); } -void EnScopecrow_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnScopecrow_Draw(Actor* thisx, PlayState* play) { EnScopecrow* 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_Scopecrow/z_en_scopecrow.h b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h index 72469bd75..30f002fb5 100644 --- a/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h +++ b/src/overlays/actors/ovl_En_Scopecrow/z_en_scopecrow.h @@ -6,7 +6,7 @@ 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) @@ -27,6 +27,4 @@ typedef struct EnScopecrow { /* 0x264 */ s16 unk_264; } EnScopecrow; // size = 0x268 -extern const ActorInit En_Scopecrow_InitVars; - #endif // Z_EN_SCOPECROW_H diff --git a/src/overlays/actors/ovl_En_Scopenuts/overlay.cfg b/src/overlays/actors/ovl_En_Scopenuts/overlay.cfg deleted file mode 100644 index 5989378a1..000000000 --- a/src/overlays/actors/ovl_En_Scopenuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Scopenuts -z_en_scopenuts.c 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 3f0ae6154..4f8207046 100644 --- a/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c +++ b/src/overlays/actors/ovl_En_Scopenuts/z_en_scopenuts.c @@ -12,28 +12,28 @@ #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); -const ActorInit En_Scopenuts_InitVars = { +ActorInit En_Scopenuts_InitVars = { ACTOR_EN_SCOPENUTS, ACTORCAT_NPC, FLAGS, @@ -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,21 +156,21 @@ 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); } } s16 func_80BCAF0C(EnScopenuts* this) { switch (this->unk_33C) { case 0x0: - if (gSaveContext.save.weekEventReg[53] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_02)) { this->unk_328 |= 1; return 0x1638; } @@ -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,18 +235,18 @@ 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) { - gSaveContext.save.weekEventReg[52] |= 0x40; - Actor_MarkForDeath(&this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_52_40); + Actor_Kill(&this->actor); } } -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)) { - 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; + SET_WEEKEVENTREG(WEEKEVENTREG_53_02); 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; @@ -594,7 +594,7 @@ void func_80BCBFFC(EnScopenuts* this, GlobalContext* globalCtx) { if (sp32 == 3) { if (this->unk_334 >= (this->path->count - 1)) { ActorCutscene_Stop(this->unk_338); - gSaveContext.save.weekEventReg[52] &= (u8)~0x40; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_40); this->actionFunc = func_80BCC288; } else { this->unk_334++; @@ -625,8 +625,8 @@ void func_80BCBFFC(EnScopenuts* this, GlobalContext* globalCtx) { this->unk_36E++; } -void func_80BCC288(EnScopenuts* this, GlobalContext* globalCtx) { - Actor_MarkForDeath(&this->actor); +void func_80BCC288(EnScopenuts* this, PlayState* play) { + Actor_Kill(&this->actor); } s32 func_80BCC2AC(EnScopenuts* this, Path* path, s32 arg2_) { @@ -680,21 +680,20 @@ 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; - if (!(gSaveContext.save.weekEventReg[74] & 0x40) && - (gSaveContext.save.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_74_40) && (gSaveContext.save.inventory.items[ITEM_OCARINA] == ITEM_NONE)) { + Actor_Kill(&this->actor); return; } 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); @@ -705,21 +704,21 @@ void EnScopenuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.speedXZ = 0.0f; 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_40)) { + Actor_Kill(&this->actor); + } else if (play->actorCtx.flags & ACTORCTX_FLAG_1) { + this->path = SubS_GetPathByIndex(play, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); this->actor.draw = NULL; this->actionFunc = func_80BCAFA8; this->actor.gravity = 0.0f; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_40)) { + this->path = SubS_GetPathByIndex(play, ENSCOPENUTS_GET_FC00(&this->actor), 0x3F); if (this->path == NULL) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { this->actor.gravity = -1.0f; this->actor.draw = EnScopenuts_Draw; @@ -728,40 +727,39 @@ 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 { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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 +800,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))) { @@ -821,11 +819,11 @@ void EnScopenuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Acto } } -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..5ea0d15eb 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,39 +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; - #endif // Z_EN_SCOPENUTS_H diff --git a/src/overlays/actors/ovl_En_Sda/overlay.cfg b/src/overlays/actors/ovl_En_Sda/overlay.cfg deleted file mode 100644 index 694122dd7..000000000 --- a/src/overlays/actors/ovl_En_Sda/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sda -z_en_sda.c 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 fc4f91308..8835d92da 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -10,17 +10,17 @@ #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]; -const ActorInit En_Sda_InitVars = { +ActorInit En_Sda_InitVars = { ACTOR_EN_SDA, ACTORCAT_BOSS, FLAGS, @@ -50,8 +50,8 @@ u8 D_80947AEC[] = { 2, 2, 2, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 3, }; -s8 D_80947AFC[] = { - 2, 9, 10, 11, 12, 13, 14, 0, 15, -1, 3, 4, 5, 6, 7, 8, -1, 1, 0, 0, +s8 D_80947AFC[PLAYER_BODYPART_MAX] = { + 2, 9, 10, 11, 12, 13, 14, 0, 15, -1, 3, 4, 5, 6, 7, 8, -1, 1, }; Vec3f D_80947B10[] = { @@ -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* shadowTex = 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, shadowTex, player, play); if (KREG(0) < 5) { - func_80947668(shadowTexture, player, globalCtx); + func_80947668(shadowTex, player, play); } } @@ -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; @@ -242,7 +242,7 @@ void func_8094702C(EnSda* this, u8* shadowTexture, Player* player, GlobalContext Matrix_RotateXFNew((BREG(50) + 70) / 100.0f); - for (i = 0; i < 18; i++) { + for (i = 0; i < PLAYER_BODYPART_MAX; i++) { if (D_80947AFC[i] >= 0) { D_80947EA0[D_80947AFC[i]] = player->bodyPartsPos[i]; } @@ -315,15 +315,15 @@ 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); @@ -339,7 +339,7 @@ void func_80947668(u8* shadowTexture, Player* player, GlobalContext* globalCtx) 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); @@ -347,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_Sda/z_en_sda.h b/src/overlays/actors/ovl_En_Sda/z_en_sda.h index ff17a2538..fd11ad5bc 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.h +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.h @@ -11,6 +11,4 @@ typedef struct EnSda { /* 0x000 */ Actor actor; } EnSda; // size = 0x144 -extern const ActorInit En_Sda_InitVars; - #endif // Z_EN_SDA_H diff --git a/src/overlays/actors/ovl_En_Sekihi/overlay.cfg b/src/overlays/actors/ovl_En_Sekihi/overlay.cfg deleted file mode 100644 index 96c2eae2f..000000000 --- a/src/overlays/actors/ovl_En_Sekihi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sekihi -z_en_sekihi.c 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..88fab3298 100644 --- a/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c +++ b/src/overlays/actors/ovl_En_Sekihi/z_en_sekihi.c @@ -5,22 +5,26 @@ */ #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 = { +ActorInit En_Sekihi_InitVars = { ACTOR_EN_SEKIHI, ACTORCAT_PROP, FLAGS, @@ -32,20 +36,152 @@ 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_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/func_80A45130.s") + if ((params == SEKIHI_TYPE_4) && (((gSaveContext.save.skullTokenCount & 0xFFFF)) >= 30)) { + SET_WEEKEVENTREG(WEEKEVENTREG_13_20); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sekihi/EnSekihi_Update.s") + 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_80A45164.s") +void EnSekihi_Destroy(Actor* thisx, PlayState* play) { + EnSekihi* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +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_Kill(&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..fb4ad7e60 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,27 @@ #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 -extern const ActorInit En_Sekihi_InitVars; +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; #endif // Z_EN_SEKIHI_H diff --git a/src/overlays/actors/ovl_En_Sellnuts/overlay.cfg b/src/overlays/actors/ovl_En_Sellnuts/overlay.cfg deleted file mode 100644 index f3b9a3eca..000000000 --- a/src/overlays/actors/ovl_En_Sellnuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sellnuts -z_en_sellnuts.c 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 0d53b127e..b16153a53 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); @@ -49,7 +49,7 @@ static u16 D_80ADD938[] = { 0x0615, 0x060F, 0x060F }; static u8 D_80ADD940 = 0; -const ActorInit En_Sellnuts_InitVars = { +ActorInit En_Sellnuts_InitVars = { ACTOR_EN_SELLNUTS, ACTORCAT_NPC, FLAGS, @@ -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,79 +298,79 @@ 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_IA_MOON_TEAR) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; this->actionFunc = func_80ADBAB8; } else { switch (this->unk_340) { case 0x60E: - gSaveContext.save.weekEventReg[17] |= 0x20; - gSaveContext.save.weekEventReg[86] |= 4; - Message_StartTextbox(globalCtx, this->unk_340, &this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_17_20); + SET_WEEKEVENTREG(WEEKEVENTREG_86_04); + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_77_40); + SET_WEEKEVENTREG(WEEKEVENTREG_86_04); + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_17_40); + 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,24 +382,24 @@ 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_IA_MOON_TEAR); if (player->transformation == PLAYER_FORM_DEKU) { if (gSaveContext.save.day == 3) { this->unk_33A = 2; - if (gSaveContext.save.weekEventReg[77] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_77_40)) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; } } else { this->unk_33A = 1; - if (gSaveContext.save.weekEventReg[17] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_17_20)) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; } } - } else if (gSaveContext.save.weekEventReg[17] & 0x40) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_17_40)) { this->unk_340 = D_80ADD918[this->unk_33A]; } else { this->unk_340 = D_80ADD910[this->unk_33A]; @@ -409,125 +409,126 @@ 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); - s32 item; +void func_80ADB924(EnSellnuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + u8 talkState = Message_GetState(&play->msgCtx); + PlayerItemAction itemAction; - if (msgState == 0x10) { - item = func_80123810(globalCtx); - if (item > EXCH_ITEM_NONE) { - if (item == EXCH_ITEM_2A) { + if (talkState == TEXT_STATE_16) { + itemAction = func_80123810(play); + + if (itemAction > PLAYER_IA_NONE) { + if (itemAction == PLAYER_IA_MOON_TEAR) { player->actor.textId = D_80ADD928[this->unk_33A]; this->unk_340 = player->actor.textId; - player->exchangeItemId = item; + player->exchangeItemId = itemAction; this->actionFunc = func_80ADBAB8; } else { player->actor.textId = D_80ADD920[this->unk_33A]; this->unk_340 = player->actor.textId; this->actionFunc = func_80ADB0D8; } - func_801477B4(globalCtx); - } else if (item < EXCH_ITEM_NONE) { + func_801477B4(play); + } else if (itemAction <= PLAYER_IA_MINUS1) { 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, PLAYER_CSMODE_19); } } -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; + SET_WEEKEVENTREG(WEEKEVENTREG_17_80); 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_IA_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_IA_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 +547,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 +556,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 +568,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 +581,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 +603,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 +631,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 +641,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,39 +690,39 @@ void func_80ADC37C(EnSellnuts* this, GlobalContext* globalCtx) { this->unk_368++; } -void func_80ADC580(EnSellnuts* this, GlobalContext* globalCtx) { - Actor_MarkForDeath(&this->actor); +void func_80ADC580(EnSellnuts* this, PlayState* play) { + Actor_Kill(&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; D_80ADD940 = 0; - player->stateFlags1 |= 0x20; + player->stateFlags1 |= PLAYER_STATE1_20; this->actionFunc = func_80ADC7B4; } else { - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_20; 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 +737,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 +750,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 +762,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 +794,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 +807,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 +822,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,18 +833,18 @@ 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; - Actor_MarkForDeath(&this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_73_04); + Actor_Kill(&this->actor); } } } -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,26 +853,26 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_04)) { this->unk_338 |= 2; this->unk_338 |= 1; this->unk_340 = 0x626; @@ -884,7 +885,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,23 +942,23 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_17_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_61_10)) { + Actor_Kill(&this->actor); } 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; @@ -969,9 +970,9 @@ void EnSellnuts_Init(Actor* thisx, GlobalContext* globalCtx) { this->unk_36C = 0.01f; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; - if (gSaveContext.save.weekEventReg[73] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_73_04)) { if (ENSELLNUTS_GET_1(&this->actor)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } this->unk_338 |= 2; @@ -989,7 +990,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 +1008,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 +1019,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 +1049,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)) || @@ -1115,10 +1115,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))) { @@ -1135,11 +1135,11 @@ void EnSellnuts_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor } } -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..b9793a6d3 100644 --- a/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h +++ b/src/overlays/actors/ovl_En_Sellnuts/z_en_sellnuts.h @@ -5,47 +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; - #endif // Z_EN_SELLNUTS_H diff --git a/src/overlays/actors/ovl_En_Shn/overlay.cfg b/src/overlays/actors/ovl_En_Shn/overlay.cfg deleted file mode 100644 index f0526f58c..000000000 --- a/src/overlays/actors/ovl_En_Shn/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Shn -z_en_shn.c 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 0b9905ba5..d606e17f4 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[] = { @@ -51,7 +51,7 @@ static UNK_TYPE D_80AE70B8[] = { static UNK_TYPE D_80AE71C4[] = { 0x00374000, 0x1C2C09DB, 0x0C2F0000, 0x0C0F09DC, 0x0C0F09DD, 0x0C0F09DE, 0x0C0F09DF, 0x0C113740, 0x102C09E0, 0x0C2F0000, 0x0C0F09E1, 0x0C0F09E2, 0x0C100000 }; -const ActorInit En_Shn_InitVars = { +ActorInit En_Shn_InitVars = { ACTOR_EN_SHN, ACTORCAT_NPC, FLAGS, @@ -63,30 +63,27 @@ const ActorInit En_Shn_InitVars = { (ActorFunc)EnShn_Draw, }; -static AnimationInfoS sAnimations[] = { - { &gBurlyGuyHandsOnTableAnim, 1.0f, 0, -1, 0, 0 }, - { &gBurlyGuyHandsOnTableAnim, 1.0f, 0, -1, 0, -4 }, - { &gSwampGuideChinScratchAnim, 1.0f, 0, -1, 0, 0 }, - { &gSwampGuideChinScratchAnim, 1.0f, 0, -1, 0, -4 }, -}; - -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_Translate(this->unk_2D4, 0.0f, 0.0f, MTXMODE_APPLY); - if ((&this->actor == player->targetActor) && - ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId >= 0x201)) && - (tempMsgState == 3) && (this->msgState == 3)) { - if (globalCtx->state.frames % 2 == 0) { + if ((&this->actor == player->talkActor) && + ((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,14 +194,14 @@ 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 (player->stateFlags1 & PLAYER_STATE1_40) { if (this->unk_1DA != temp) { if ((this->unk_1D8 & 0x80) || (this->unk_1D8 & 0x100)) { this->unk_1D8 |= 8; @@ -220,7 +216,7 @@ s32 func_80AE65F4(EnShn* this, GlobalContext* globalCtx) { this->unk_1DA = temp; this->unk_1D8 |= 0x40; } else if (this->unk_1D8 & 0x40) { - if (!(gSaveContext.save.weekEventReg[23] & 8)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_23_08)) { func_80AE615C(this, 3); } this->unk_1DA = 0; @@ -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; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_40); + func_800B7298(play, &this->actor, PLAYER_CSMODE_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,48 +286,48 @@ 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_IA_PICTO_BOX) { this->unk_1D8 |= 0x80; this->unk_2E4 = player->exchangeItemId; - } else if (player->exchangeItemId != EXCH_ITEM_NONE) { + } else if (player->exchangeItemId != PLAYER_IA_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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_08)) { 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)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_08) && EnShn_IsFacingPlayer(this)) { this->unk_1D8 |= 8; } else { this->unk_1D8 &= ~0x8; } } -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,14 +343,14 @@ 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, &gBurlyGuySkel, NULL, this->jointTable, this->morphTable, + 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_08)) { func_80AE615C(this, 0); } else { func_80AE615C(this, 2); @@ -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,40 +370,40 @@ 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, EXCH_ITEM_NONE, this->unk_1D8 & 7); + func_8013C964(&this->actor, play, 120.0f, 40.0f, PLAYER_IA_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 == BURLY_GUY_LIMB_HEAD) { - func_80AE6488(this, globalCtx); + 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) { +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 stepRot; s32 overrideRot; @@ -431,11 +433,11 @@ void EnShn_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } } -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 22e10ca32..bb4740142 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; @@ -34,14 +35,12 @@ 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; /* 0x2EC */ s32 unk_2EC; } EnShn; // size = 0x2F0 -extern const ActorInit En_Shn_InitVars; - #endif // Z_EN_SHN_H diff --git a/src/overlays/actors/ovl_En_Si/overlay.cfg b/src/overlays/actors/ovl_En_Si/overlay.cfg deleted file mode 100644 index 67fe95518..000000000 --- a/src/overlays/actors/ovl_En_Si/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Si -z_en_si.c 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..5f7e111a4 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -10,16 +10,16 @@ #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 = { +ActorInit En_Si_InitVars = { ACTOR_EN_SI, ACTORCAT_ITEMACTION, FLAGS, 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..b401e5e6a 100644 --- a/src/overlays/actors/ovl_En_Si/z_en_si.h +++ b/src/overlays/actors/ovl_En_Si/z_en_si.h @@ -5,14 +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; - #endif // Z_EN_SI_H diff --git a/src/overlays/actors/ovl_En_Skb/overlay.cfg b/src/overlays/actors/ovl_En_Skb/overlay.cfg deleted file mode 100644 index dfa528943..000000000 --- a/src/overlays/actors/ovl_En_Skb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Skb -z_en_skb.c 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 6d3a118f4..bb1fb7e0b 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, }; @@ -145,7 +145,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -const ActorInit En_Skb_InitVars = { +ActorInit En_Skb_InitVars = { ACTOR_EN_SKB, ACTORCAT_ENEMY, FLAGS, @@ -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->sceneId == SCENE_BOTI) && (gSaveContext.sceneLayer == 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); + this->actor.hintId = TATL_HINT_ID_STALCHILD; + 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.hintId = TATL_HINT_ID_STALCHILD; 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,20 +421,20 @@ 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.hintId = TATL_HINT_ID_STALCHILD; this->actor.colChkInfo.mass = MASS_HEAVY; func_8099571C(this); } } 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,20 +443,20 @@ 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.hintId = TATL_HINT_ID_STALCHILD; this->actor.colChkInfo.mass = MASS_HEAVY; func_8099571C(this); } } 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,17 +477,17 @@ 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; + this->actor.hintId = TATL_HINT_ID_STALCHILD; this->actor.colChkInfo.mass = MASS_HEAVY; this->actor.targetArrowOffset = 2000.0f; func_8099571C(this); @@ -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,40 +545,40 @@ 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); if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } 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.hintId = TATL_HINT_ID_NONE; 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) { - Actor_MarkForDeath(&this->actor); +void func_809964A0(EnSkb* this, PlayState* play) { + if (this->unk_3D0++ >= 19) { + Actor_Kill(&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->actionFunc != func_809964A0) && CHECK_WEEKEVENTREG(WEEKEVENTREG_85_40)) { 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; } @@ -1093,19 +1095,19 @@ s32 EnSkb_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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) { @@ -1121,15 +1123,15 @@ void EnSkb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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..1fbf441ea 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -5,37 +5,39 @@ struct EnSkb; -typedef void (*EnSkbActionFunc)(struct EnSkb*, GlobalContext*); +typedef void (*EnSkbActionFunc)(struct EnSkb*, PlayState*); #define ENSKB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +typedef enum { + /* 0 */ ENSKB_PARAMS_0, +} EnSkbParams; + 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; - #endif // Z_EN_SKB_H diff --git a/src/overlays/actors/ovl_En_Slime/overlay.cfg b/src/overlays/actors/ovl_En_Slime/overlay.cfg deleted file mode 100644 index ad13869e8..000000000 --- a/src/overlays/actors/ovl_En_Slime/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Slime -z_en_slime.c 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..2b8e5f4c6 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.c +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.c @@ -10,30 +10,30 @@ #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 = { +ActorInit En_Slime_InitVars = { ACTOR_EN_SLIME, ACTORCAT_ENEMY, FLAGS, 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..0381a592a 100644 --- a/src/overlays/actors/ovl_En_Slime/z_en_slime.h +++ b/src/overlays/actors/ovl_En_Slime/z_en_slime.h @@ -5,14 +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; - #endif // Z_EN_SLIME_H diff --git a/src/overlays/actors/ovl_En_Snowman/overlay.cfg b/src/overlays/actors/ovl_En_Snowman/overlay.cfg deleted file mode 100644 index 97b6aa6e9..000000000 --- a/src/overlays/actors/ovl_En_Snowman/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Snowman -z_en_snowman.c 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 ef0ad1b57..994115f89 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -10,38 +10,38 @@ #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 EnSnowman_SetupMoveSnowPile(EnSnowman* this); -void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_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, GlobalContext* globalCtx); +void EnSnowman_ReadySnowball(EnSnowman* this, PlayState* play); void EnSnowman_SetupThrowSnowball(EnSnowman* this); -void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_ThrowSnowball(EnSnowman* this, PlayState* play); void EnSnowman_SetupIdle(EnSnowman* this); -void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_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, GlobalContext* globalCtx); +void EnSnowman_Dead(EnSnowman* this, PlayState* play); void EnSnowman_SetupSplitDoNothing(EnSnowman* this); -void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_SetupMarkForDeath(EnSnowman* this); -void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SplitDoNothing(EnSnowman* this, PlayState* play); +void EnSnowman_SetupKill(EnSnowman* this); +void EnSnowman_Kill(EnSnowman* this, PlayState* play); void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot); -void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos); -void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx); -void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx); -void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx); -void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx); +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. @@ -61,7 +61,7 @@ typedef enum { /* 3 */ EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE, } EnSnowmanCombineState; -const ActorInit En_Snowman_InitVars = { +ActorInit En_Snowman_InitVars = { ACTOR_EN_SNOWMAN, ACTORCAT_ENEMY, FLAGS, @@ -178,12 +178,12 @@ static Gfx* sSnowballFragmentDLs[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 20, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_EENO, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSnowman_Init(Actor* thisx, PlayState* play) { s32 pad; EnSnowman* this = THIS; s32 attackRange; @@ -196,29 +196,29 @@ void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->params &= 7; if (EN_SNOWMAN_GET_TYPE(thisx) < EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gEenoSkel, &gEenoEmergeAnim, this->jointTable, - this->morphTable, EENO_LIMB_MAX); - SkelAnime_InitFlex(globalCtx, &this->snowPileSkelAnime, &gEenoSnowPileSkel, &gEenoSnowPileMoveAnim, + 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(globalCtx, &this->collider, thisx, &sEenoCylinderInit); + Collider_InitAndSetCylinder(play, &this->collider, thisx, &sEenoCylinderInit); if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_LARGE) { thisx->flags |= ACTOR_FLAG_400; - Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_SNOWMAN, thisx->world.pos.x, - thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, EN_SNOWMAN_TYPE_SPLIT); - thisx->parent = Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, - thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, - 0, 0, EN_SNOWMAN_TYPE_SPLIT, -1, thisx->unk20, NULL); + 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); + Actor_Kill(thisx->child); } if (thisx->parent != NULL) { - Actor_MarkForDeath(thisx->parent); + Actor_Kill(thisx->parent); } - Actor_MarkForDeath(thisx); + Actor_Kill(thisx); return; } @@ -238,10 +238,10 @@ void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx) { EnSnowman_SetupMoveSnowPile(this); } } else { - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); thisx->flags &= ~ACTOR_FLAG_1; - Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sSnowballCylinderInit); + 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); @@ -279,16 +279,16 @@ void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnSnowman_Destroy(Actor* thisx, PlayState* play) { EnSnowman* this = THIS; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } /** * Spawns a circle of snow-colored dust around the actor. */ -void EnSnowman_SpawnCircularDustEffect(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_SpawnCircularDustEffect(EnSnowman* this, PlayState* play) { s16 angle = 0; Vec3f pos; f32 offset; @@ -299,7 +299,7 @@ void EnSnowman_SpawnCircularDustEffect(EnSnowman* this, GlobalContext* globalCtx offset = (Rand_ZeroFloat(10.0f) + 20.0f) * this->eenoScale; pos.x = (Math_SinS(angle) * offset) + this->actor.world.pos.x; pos.z = (Math_CosS(angle) * offset) + this->actor.world.pos.z; - func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + func_800B0DE0(play, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, this->eenoScale * 400.0f, 10); angle += 0x1000; } @@ -308,7 +308,7 @@ void EnSnowman_SpawnCircularDustEffect(EnSnowman* this, GlobalContext* globalCtx /** * Spawns a batch of large snowball fragments and some snow-colored dust at snowballPos. */ -void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, PlayState* play) { static Vec3f sAccel = { 0.0f, -1.0f, 0.0f }; s16 altitude; s16 azimuth; @@ -319,7 +319,7 @@ void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* g for (i = 0; i < 15; i++) { altitude = Rand_S16Offset(0x1800, 0x2800); - azimuth = ((u32)Rand_Next() >> 0x10); + azimuth = Rand_Next() >> 0x10; speed = Rand_ZeroFloat(3.0f) + 8.0f; velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); velocity.y = speed * Math_SinS(altitude); @@ -327,12 +327,12 @@ void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* g pos.x = (Rand_ZeroFloat(10.0f) * velocity.x) + this->snowballPos.x; pos.y = (Rand_ZeroFloat(8.0f) * velocity.y) + this->snowballPos.y; pos.z = (Rand_ZeroFloat(10.0f) * velocity.z) + this->snowballPos.z; - EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, - Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), 452, 20, + EffectSsHahen_Spawn(play, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), OBJECT_SNOWMAN, 20, sSnowballFragmentDLs[i % 3]); } - func_800B0DE0(globalCtx, &this->snowballPos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); + func_800B0DE0(play, &this->snowballPos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); } void EnSnowman_SetupMoveSnowPile(EnSnowman* this) { @@ -350,8 +350,8 @@ void EnSnowman_SetupMoveSnowPile(EnSnowman* this) { /** * Moves around beneath the snow as a snow pile. */ -void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSnowman_MoveSnowPile(EnSnowman* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f combinePos; SkelAnime_Update(&this->snowPileSkelAnime); @@ -390,13 +390,13 @@ void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { } combinePos.y = this->actor.world.pos.y; - EnSnowman_SetupCombine((EnSnowman*)this->actor.parent, globalCtx, &combinePos); - EnSnowman_SetupCombine((EnSnowman*)this->actor.child, globalCtx, &combinePos); - EnSnowman_SetupCombine(this, globalCtx, &combinePos); + 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(globalCtx) != PLAYER_MASK_STONE) && - !(player->stateFlags1 & 0x800000)) { - EnSnowman_SetupEmerge(this, globalCtx); + (this->actor.xzDistToPlayer < this->attackRange) && (Player_GetMask(play) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & PLAYER_STATE1_800000)) { + 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; @@ -406,13 +406,13 @@ void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { } 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) + (Rand_Next() >> 0x14); + this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + ((s32)Rand_Next() >> 0x14); } else if (Rand_ZeroOne() < 0.02f) { - this->snowPileTargetRotY += (s16)((((u32)Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + this->snowPileTargetRotY += (s16)(((Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); } } -void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx) { +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; @@ -421,7 +421,7 @@ void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx) { this->actor.scale.y = this->actor.scale.x * 0.4f; this->actor.speedXZ = 0.0f; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; - EnSnowman_SpawnCircularDustEffect(this, globalCtx); + EnSnowman_SpawnCircularDustEffect(this, play); this->collider.base.acFlags &= ~AC_ON; this->actionFunc = EnSnowman_Emerge; } @@ -429,8 +429,8 @@ void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx) { /** * Emerge from beneath the snow and face the player. */ -void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSnowman_Emerge(EnSnowman* this, PlayState* play) { + Player* player = GET_PLAYER(play); Math_StepToF(&this->actor.scale.y, this->actor.scale.x, (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); @@ -438,8 +438,8 @@ void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx) { if (SkelAnime_Update(&this->skelAnime)) { if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { - EnSnowman_SetupSubmerge(this, globalCtx); - } else if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + EnSnowman_SetupSubmerge(this, play); + } else if (!(player->stateFlags1 & PLAYER_STATE1_800000) && (Player_GetMask(play) != PLAYER_MASK_STONE)) { this->collider.base.acFlags |= AC_ON; this->work.snowballsToThrowBeforeIdling = 3; EnSnowman_SetupReadySnowball(this); @@ -468,25 +468,25 @@ void EnSnowman_SetupReadySnowball(EnSnowman* this) { * Plays the animation of the Eeno creating a snowball and spawns some snow-colored dust * near the snowball at the appropriate part of their animation. */ -void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_ReadySnowball(EnSnowman* this, PlayState* play) { Vec3f pos; Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); if ((EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE) && this->isHoldingSnowball && - ((globalCtx->gameplayFrames % 2) != 0)) { + ((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(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, 30); + 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) && - ((globalCtx->gameplayFrames % 2) != 0)) { + ((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(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); + func_800B0DE0(play, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); } } @@ -522,14 +522,14 @@ void EnSnowman_SetupThrowSnowball(EnSnowman* this) { * so it can eventually throw another one. Otherwise, this function will call EnSnowman_SetupIdle * to transition the Eeno into an idle state. */ -void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void EnSnowman_ThrowSnowball(EnSnowman* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 params; Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); if (SkelAnime_Update(&this->skelAnime)) { - if ((this->work.snowballsToThrowBeforeIdling != 0) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && - !(player->stateFlags1 & 0x800000)) { + if ((this->work.snowballsToThrowBeforeIdling != 0) && (Player_GetMask(play) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & PLAYER_STATE1_800000)) { EnSnowman_SetupReadySnowball(this); } else { this->work.snowballsToThrowBeforeIdling = 0; @@ -545,7 +545,7 @@ void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_THROW); } - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, this->snowballPos.x, this->snowballPos.y, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_SNOWMAN, this->snowballPos.x, this->snowballPos.y, this->snowballPos.z, 0, this->actor.yawTowardsPlayer, 0, params); } } @@ -559,19 +559,19 @@ void EnSnowman_SetupIdle(EnSnowman* this) { /** * Simply makes the Eeno wait around for a bit before submerging back into the snow. */ -void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_Idle(EnSnowman* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->work.timer > 0) { this->work.timer--; } else { - EnSnowman_SetupSubmerge(this, globalCtx); + EnSnowman_SetupSubmerge(this, play); } } -void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx) { +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, globalCtx); + EnSnowman_SpawnCircularDustEffect(this, play); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HIDE); this->actionFunc = EnSnowman_Submerge; } @@ -579,7 +579,7 @@ void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx) { /** * Submerge beneath the snow and become a snow pile. */ -void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx) { +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)); @@ -590,7 +590,7 @@ void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx) { // Calling EnSnowman_SetupCombine while EnSnowman_Submerge is our actionFunc will result // in the broken target scale bug described in EnSnowman_SetupCombine. - EnSnowman_SetupCombine(this, globalCtx, &this->combinePos); + EnSnowman_SetupCombine(this, play, &this->combinePos); } else { EnSnowman_SetupMoveSnowPile(this); } @@ -611,7 +611,7 @@ void EnSnowman_SetupMelt(EnSnowman* this) { /** * Spawns smoke and shrinks the Eeno down until the timer runs out, then kills the Eeno. */ -void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_Melt(EnSnowman* this, PlayState* play) { Vec3f smokeVelocity; Vec3f smokePos; @@ -626,19 +626,19 @@ void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx) { smokePos.z = ((smokeVelocity.z >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + this->actor.world.pos.z; smokePos.y = this->actor.world.pos.y + 3.0f; - EffectSsIceSmoke_Spawn(globalCtx, &smokePos, &smokeVelocity, &gZeroVec3f, this->eenoScale * 300.0f); + EffectSsIceSmoke_Spawn(play, &smokePos, &smokeVelocity, &gZeroVec3f, this->eenoScale * 300.0f); } if (this->work.timer == 0) { - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + 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); + Actor_Kill(this->actor.parent); + Actor_Kill(this->actor.child); + Actor_Kill(&this->actor); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -659,7 +659,7 @@ void EnSnowman_SetupStun(EnSnowman* this) { * Simply makes the Eeno do absolutely nothing until the stun is over. * Once the stun is over, this swaps the actionFunc back to what it was before the stun. */ -void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_Stun(EnSnowman* this, PlayState* play) { if (this->actor.colorFilterTimer == 0) { this->actionFunc = this->prevActionFunc; } @@ -689,7 +689,7 @@ void EnSnowman_SetupDamaged(EnSnowman* this) { * Once it's done spinning, it will spawn three small split-off Eenos if the Eeno is a large one. * Otherwise, it will either submerge underground (if it has health remaining) or die. */ -void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_Damaged(EnSnowman* this, PlayState* play) { s32 rotationalVelocityScale; SkelAnime_Update(&this->skelAnime); @@ -707,7 +707,7 @@ void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx) { this->work.timer--; } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SPLIT); - EnSnowman_SpawnCircularDustEffect(this, globalCtx); + 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); @@ -718,10 +718,10 @@ void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx) { // This is a hack to reuse EnSnowman_SpawnBigSnowballFragmentEffects, since it // draws the fragments at snowballPos. Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); - EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + EnSnowman_SpawnBigSnowballFragmentEffects(this, play); } else if (this->actor.colChkInfo.health != 0) { this->collider.base.acFlags |= AC_ON; - EnSnowman_SetupSubmerge(this, globalCtx); + EnSnowman_SetupSubmerge(this, play); } else { EnSnowman_SetupDead(this); } @@ -735,7 +735,7 @@ void EnSnowman_SetupDead(EnSnowman* this) { /** * Spawns snow-colored dust and snowball fragments and kills the Eeno. */ -void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_Dead(EnSnowman* this, PlayState* play) { static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; Vec3f velocity; Vec3f pos; @@ -746,7 +746,7 @@ void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { for (i = 0; i < 15; i++) { altitude = Rand_S16Offset(0x1000, 0x3000); - azimuth = ((u32)Rand_Next() >> 0x10); + 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); @@ -754,19 +754,18 @@ void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { pos.x = (Rand_ZeroFloat(6.0f) * velocity.x) + this->actor.world.pos.x; pos.y = (Rand_ZeroFloat(3.0f) * velocity.y) + this->actor.world.pos.y; pos.z = (Rand_ZeroFloat(6.0f) * velocity.z) + this->actor.world.pos.z; - EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, - Rand_S16Offset((((i % 3) * 20) + 20), (((i % 3) * 10) + 10)), 452, 20, + 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(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, - 30); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_YMAJIN_DEAD_BREAK); - Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + 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); + Actor_Kill(&this->actor); } } @@ -789,32 +788,32 @@ void EnSnowman_SetupSplitDoNothing(EnSnowman* this) { 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); + EnSnowman_SetupKill((EnSnowman*)this->actor.parent); + EnSnowman_SetupKill((EnSnowman*)this->actor.child); + Actor_Kill(&this->actor); } } this->actionFunc = EnSnowman_SplitDoNothing; } -void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_SplitDoNothing(EnSnowman* this, PlayState* play) { } /** - * Turns off collision on the Eeno before calling Actor_MarkForDeath on it. + * Turns off collision on the Eeno before calling Actor_Kill on it. */ -void EnSnowman_SetupMarkForDeath(EnSnowman* this) { +void EnSnowman_SetupKill(EnSnowman* this) { this->collider.base.acFlags &= ~(AC_ON | AC_HIT); this->collider.base.ocFlags1 &= ~(OC1_ON | OC1_HIT); - this->actionFunc = EnSnowman_MarkForDeath; + this->actionFunc = EnSnowman_Kill; } /** - * Simply calls Actor_MarkForDeath on the Eeno. + * Simply calls Actor_Kill on the Eeno. */ -void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx) { - Actor_MarkForDeath(&this->actor); +void EnSnowman_Kill(EnSnowman* this, PlayState* play) { + Actor_Kill(&this->actor); } /** @@ -855,7 +854,7 @@ void EnSnowman_AbsorbEeno(EnSnowman* smallerEeno, EnSnowman* largerEeno) { smallerEeno->fwork.targetScaleDuringCombine = 0.0f; } -void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos) { +void EnSnowman_SetupCombine(EnSnowman* this, PlayState* play, Vec3f* combinePos) { if (this->actor.colChkInfo.health == 0) { this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; } else { @@ -888,7 +887,7 @@ void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* co // will be set to EnSnowman_Submerge. When the submerging animation is complete with this // combineState, EnSnowman_Submerge will call EnSnowman_SetupCombine, causing the broken // target scale bug described above. - EnSnowman_SetupSubmerge(this, globalCtx); + EnSnowman_SetupSubmerge(this, play); } } } @@ -896,7 +895,7 @@ void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* co /** * Makes the small, split-off Eenos try to combine into a large Eeno by absorbing each other. */ -void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx) { +void EnSnowman_Combine(EnSnowman* this, PlayState* play) { EnSnowman* parent; EnSnowman* child; @@ -963,19 +962,19 @@ void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx) { this->actor.scale.z = this->actor.scale.x; } -void EnSnowman_UpdateDamage(EnSnowman* this, GlobalContext* globalCtx) { +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(globalCtx, &this->actor); + 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, globalCtx); + 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); @@ -990,13 +989,13 @@ void EnSnowman_UpdateDamage(EnSnowman* this, GlobalContext* globalCtx) { } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { if (this->isHoldingSnowball == true) { this->isHoldingSnowball = false; - EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + EnSnowman_SpawnBigSnowballFragmentEffects(this, play); } EnSnowman_SetupDamaged(this); } else { if (Actor_ApplyDamage(&this->actor) == 0) { - Enemy_StartFinishingBlow(globalCtx, &this->actor); + Enemy_StartFinishingBlow(play, &this->actor); } EnSnowman_SetupDamaged(this); @@ -1007,7 +1006,7 @@ void EnSnowman_UpdateDamage(EnSnowman* this, GlobalContext* globalCtx) { this->drawDmgEffScale = 0.55f; this->drawDmgEffAlpha = 4.0f; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + 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); } @@ -1015,7 +1014,7 @@ void EnSnowman_UpdateDamage(EnSnowman* this, GlobalContext* globalCtx) { } } -void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSnowman_Update(Actor* thisx, PlayState* play) { s32 pad; EnSnowman* this = THIS; f32 wallCheckRadius; @@ -1023,10 +1022,10 @@ void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actionFunc != EnSnowman_SplitDoNothing) { DECR(this->combineTimer); - EnSnowman_UpdateDamage(this, globalCtx); - this->actionFunc(this, globalCtx); + EnSnowman_UpdateDamage(this, play); + this->actionFunc(this, play); - if (this->actionFunc != EnSnowman_MarkForDeath) { + if (this->actionFunc != EnSnowman_Kill) { Actor_MoveWithGravity(&this->actor); if ((EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) && (this->actionFunc == EnSnowman_ReadySnowball)) { @@ -1037,12 +1036,12 @@ void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { wallCheckRadius = this->collider.dim.radius; } - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, wallCheckRadius, 0.0f, 0x1D); + 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->snowPileTargetRotY = Math_Atan2S_XY(this->actor.floorPoly->normal.z * SHT_MINV, + this->actor.floorPoly->normal.x * SHT_MINV); this->turningOnSteepSlope = true; } } else { @@ -1051,9 +1050,9 @@ void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { 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->actor.draw == EnSnowman_Draw) { Actor_SetFocus(&this->actor, this->actor.scale.y * 1800.0f); @@ -1070,7 +1069,7 @@ void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { } } -void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx) { +void EnSnowman_UpdateSnowball(Actor* thisx, PlayState* play) { EnSnowman* this = THIS; s16 scale; s32 i; @@ -1087,34 +1086,35 @@ void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx) { if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { scale = 10; for (i = 0; i < 3; i++) { - EffectSsHahen_SpawnBurst(globalCtx, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, 452, 20, + EffectSsHahen_SpawnBurst(play, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, OBJECT_SNOWMAN, 20, sSnowballFragmentDLs[i]); scale *= 2; } - func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, - 500, 30); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SMALL_SNOWBALL_BROKEN); + 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. + // EnSnowman_SpawnBigSnowballFragmentEffects only works with snowballPos, so we need + // to copy the snowball actor's current position into snowballPos to make this work. Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); - EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SNOWBALL_BROKEN); + EnSnowman_SpawnBigSnowballFragmentEffects(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_SNOWBALL_BROKEN); } - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_REFLECTION_WOOD); - Actor_MarkForDeath(&this->actor); - } else { - this->actor.shape.rot.x += 0xF00; - Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius * 0.6f, - this->collider.dim.height - this->collider.dim.yShift, 0x1F); - Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_IT_REFLECTION_WOOD); + Actor_Kill(&this->actor); + return; } + + 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); } /** @@ -1135,7 +1135,7 @@ static Vec3f sBodyBottomBodyPartOffsets[] = { { 1000.0f, 0.0f, 3000.0f }, { 1000.0f, 0.0f, -3000.0f }, }; -void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +void EnSnowman_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { s32 pad; EnSnowman* this = THIS; Gfx* gfx; @@ -1152,7 +1152,7 @@ void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } if ((limbIndex == EENO_LIMB_RIGHT_HAND) && (this->isHoldingSnowball == true)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_OPA_DISP; @@ -1163,35 +1163,35 @@ void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); } - gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); Matrix_MultZero(&this->snowballPos); } } -void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSnowman_Draw(Actor* thisx, PlayState* play) { EnSnowman* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, - NULL, EnSnowman_PostLimbDraw, &this->actor); - Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + 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, GlobalContext* globalCtx) { +void EnSnowman_DrawSnowPile(Actor* thisx, PlayState* play) { EnSnowman* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - SkelAnime_DrawFlexOpa(globalCtx, this->snowPileSkelAnime.skeleton, this->snowPileSkelAnime.jointTable, + 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, GlobalContext* globalCtx) { - Gfx_DrawDListOpa(globalCtx, sSnowballDLs[EN_SNOWMAN_GET_TYPE(thisx) - EN_SNOWMAN_TYPE_SMALL_SNOWBALL]); +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 07d7f98c3..da0c0a30a 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h @@ -17,7 +17,7 @@ typedef enum { struct EnSnowman; -typedef void (*EnSnowmanActionFunc)(struct EnSnowman*, GlobalContext*); +typedef void (*EnSnowmanActionFunc)(struct EnSnowman*, PlayState*); typedef struct EnSnowman { /* 0x000 */ Actor actor; @@ -54,6 +54,4 @@ typedef struct EnSnowman { /* 0x32C */ ColliderCylinder collider; } EnSnowman; // size = 0x378 -extern const ActorInit En_Snowman_InitVars; - #endif // Z_EN_SNOWMAN_H diff --git a/src/overlays/actors/ovl_En_Snowwd/overlay.cfg b/src/overlays/actors/ovl_En_Snowwd/overlay.cfg deleted file mode 100644 index 4a4495833..000000000 --- a/src/overlays/actors/ovl_En_Snowwd/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Snowwd -z_en_snowwd.c 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..48a1cfea0 100644 --- a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c +++ b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.c @@ -10,15 +10,15 @@ #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 = { +ActorInit En_Snowwd_InitVars = { ACTOR_EN_SNOWWD, ACTORCAT_PROP, FLAGS, 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..a83e5d05a 100644 --- a/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h +++ b/src/overlays/actors/ovl_En_Snowwd/z_en_snowwd.h @@ -5,14 +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; - #endif // Z_EN_SNOWWD_H diff --git a/src/overlays/actors/ovl_En_Sob1/overlay.cfg b/src/overlays/actors/ovl_En_Sob1/overlay.cfg deleted file mode 100644 index cd2fa2a2e..000000000 --- a/src/overlays/actors/ovl_En_Sob1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sob1 -z_en_sob1.c 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 08c1a8aaf..035bc2bfa 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -5,63 +5,66 @@ */ #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 = { +ActorInit En_Sob1_InitVars = { ACTOR_EN_OSSAN, ACTORCAT_NPC, FLAGS, @@ -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,24 +173,24 @@ 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)) { return 0x648; - } else if (gSaveContext.save.weekEventReg[33] & 8) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08)) { return 0x649; } else { return 0x64A; @@ -217,19 +220,21 @@ 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: return 0x644; + case PLAYER_MASK_GORON: case PLAYER_MASK_ZORA: case PLAYER_MASK_DEKU: return 0x64B; + case PLAYER_MASK_TRUTH: case PLAYER_MASK_ALL_NIGHT: case PLAYER_MASK_KEATON: @@ -240,78 +245,96 @@ u16 EnSob1_GetWelcome(EnSob1* this, GlobalContext* globalCtx) { case PLAYER_MASK_BREMEN: case PLAYER_MASK_SCENTS: return 0x685; + case PLAYER_MASK_GARO: case PLAYER_MASK_CIRCUS_LEADER: case PLAYER_MASK_GIBDO: case PLAYER_MASK_CAPTAIN: return 0x686; + case PLAYER_MASK_COUPLE: return 0x687; + case PLAYER_MASK_STONE: return 0x688; + case PLAYER_MASK_BLAST: return 0x689; + case PLAYER_MASK_KAFEIS_MASK: return 0x68A; } } else if (this->shopType == ZORA_SHOP) { switch (player->transformation) { case PLAYER_FORM_HUMAN: - if (gSaveContext.save.weekEventReg[57] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_57_10)) { return 0x12CF; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_57_10); + return 0x12CE; } - gSaveContext.save.weekEventReg[57] |= 0x10; - return 0x12CE; + case PLAYER_FORM_DEKU: - if (gSaveContext.save.weekEventReg[57] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_57_20)) { return 0x12D1; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_57_20); + return 0x12D0; } - gSaveContext.save.weekEventReg[57] |= 0x20; - return 0x12D0; + case PLAYER_FORM_GORON: - if (gSaveContext.save.weekEventReg[57] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_57_40)) { return 0x12D3; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_57_40); + return 0x12D2; } - gSaveContext.save.weekEventReg[57] |= 0x40; - return 0x12D2; + case PLAYER_FORM_ZORA: - if (gSaveContext.save.weekEventReg[57] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_57_80)) { return 0x12D5; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_57_80); + return 0x12D4; } - gSaveContext.save.weekEventReg[57] |= 0x80; - return 0x12D4; + default: return 0x12CE; } } else if (this->shopType == GORON_SHOP) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.save.weekEventReg[58] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_58_04)) { return 0xBB9; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_58_04); + return 0xBB8; } - gSaveContext.save.weekEventReg[58] |= 4; - return 0xBB8; } else { - if (gSaveContext.save.weekEventReg[58] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_58_08)) { return 0xBBB; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_58_08); + return 0xBBA; } - gSaveContext.save.weekEventReg[58] |= 8; - return 0xBBA; } } else if (this->shopType == GORON_SHOP_SPRING) { if (player->transformation != PLAYER_FORM_GORON) { - if (gSaveContext.save.weekEventReg[58] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_58_10)) { return 0xBBD; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_58_10); + return 0xBBC; } - gSaveContext.save.weekEventReg[58] |= 0x10; - return 0xBBC; } else { - if (gSaveContext.save.weekEventReg[58] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_58_20)) { return 0xBBF; + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_58_20); + return 0xBBE; } - gSaveContext.save.weekEventReg[58] |= 0x20; - return 0xBBE; } } + return 0; } @@ -330,16 +353,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 +370,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; @@ -383,7 +406,7 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { this->shopType = ZORA_SHOP; break; case GORON_SHOP: - if (gSaveContext.save.weekEventReg[33] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { this->shopType = GORON_SHOP_SPRING; } else { this->shopType = GORON_SHOP; @@ -393,123 +416,123 @@ void EnSob1_Init(Actor* thisx, GlobalContext* globalCtx) { this->shopType = BOMB_SHOP; break; default: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } objIds = sObjectIds[this->shopType]; - this->objIndices[0] = Object_GetIndex(&globalCtx->objectCtx, objIds[0]); - if (this->objIndices[0] < 0) { - Actor_MarkForDeath(&this->actor); + this->mainObjIndex = Object_GetIndex(&play->objectCtx, objIds[0]); + if (this->mainObjIndex < 0) { + Actor_Kill(&this->actor); return; } - if (!EnSob1_GetObjIndices(this, globalCtx, objIds)) { - Actor_MarkForDeath(&this->actor); + if (!EnSob1_GetObjIndices(this, play, objIds)) { + Actor_Kill(&this->actor); return; } Actor_ProcessInitChain(&this->actor, sInitChain); 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; - Interface_ChangeAlpha(50); + Actor_ProcessTalkRequest(&this->actor, &play->state); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; - player->stateFlags2 &= ~0x20000000; - globalCtx->interfaceCtx.unk_222 = 0; - globalCtx->interfaceCtx.unk_224 = 0; + player->stateFlags2 &= ~PLAYER_STATE2_20000000; + 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, DO_ACTION_NEXT); 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, DO_ACTION_DECIDE); 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, DO_ACTION_DECIDE); 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 +540,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); @@ -530,30 +553,30 @@ void EnSob1_Idle(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } - player->stateFlags2 |= 0x20000000; - this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); + player->stateFlags2 |= PLAYER_STATE2_20000000; + 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 +619,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 +630,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 +679,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, DO_ACTION_DECIDE); + 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, DO_ACTION_DECIDE); this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } @@ -676,13 +699,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 +721,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 +774,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 +801,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); @@ -786,27 +810,27 @@ void EnSob1_Walking(EnSob1* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENSOB1_CUTSCENESTATE_WAITING; } - player->stateFlags2 |= 0x20000000; - this->welcomeTextId = EnSob1_GetWelcome(this, globalCtx); - Message_StartTextbox(globalCtx, this->welcomeTextId, &this->actor); + player->stateFlags2 |= PLAYER_STATE2_20000000; + 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)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_20000000; EnSob1_SetupAction(this, EnSob1_ContinueShopping); this->cutsceneState = ENSOB1_CUTSCENESTATE_PLAYING; } else { @@ -817,14 +841,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_IA_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 +864,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 +918,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 +931,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, DO_ACTION_DECIDE); + 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 +946,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; - player->stateFlags2 &= ~0x20000000; - Interface_ChangeAlpha(50); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + player->stateFlags2 &= ~PLAYER_STATE2_20000000; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); 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, DO_ACTION_DECIDE); + 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 +1100,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_IA_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); + player->stateFlags2 |= PLAYER_STATE2_20000000; + Message_StartTextbox(play, this->welcomeTextId, &this->actor); + EnSob1_SetupStartShopping(play, this, true); + func_800B85E0(&this->actor, play, 200.0f, PLAYER_IA_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 +1183,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; } } } @@ -1247,14 +1271,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 { @@ -1262,7 +1286,7 @@ s16 EnSob1_GetDistSqAndOrient(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq) diffZ = 0.0f; } *distSq = SQ(diffX) + SQ(diffZ); - return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); + return RADF_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); } void EnSob1_GetCutscenes(EnSob1* this) { @@ -1283,33 +1307,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] = VIRTUAL_TO_PHYSICAL(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,48 +1341,47 @@ 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] = VIRTUAL_TO_PHYSICAL(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] = VIRTUAL_TO_PHYSICAL(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; this->actor.world.pos.z += posOffset->z; shopItems = sShops[this->shopType]; - if ((this->shopType == BOMB_SHOP) && (gSaveContext.save.weekEventReg[33] & 8)) { + if ((this->shopType == BOMB_SHOP) && CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08)) { sShops[this->shopType][0].shopItemId = SI_BOMB_BAG_30_2; } @@ -1366,14 +1389,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 +1408,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 +1457,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 +1466,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 +1498,10 @@ 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 +1514,11 @@ 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 +1532,8 @@ 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 +1550,32 @@ 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,131 +1584,137 @@ 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) { + 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) { - Gfx* dList; - Gfx* dListHead; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + Gfx* gfx = gfxHead; - dList = dListHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); - gSPEndDisplayList(dListHead++); + gSPEndDisplayList(gfx++); - return dList; + return gfxHead; } -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_ReplaceRotation(&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..eee86c112 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,4 @@ 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/overlay.cfg b/src/overlays/actors/ovl_En_Ssh/overlay.cfg deleted file mode 100644 index f8a88c0be..000000000 --- a/src/overlays/actors/ovl_En_Ssh/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Ssh -z_en_ssh.c 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 b9ccdb579..7494695fa 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -11,21 +11,21 @@ #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; -const ActorInit En_Ssh_InitVars = { +ActorInit En_Ssh_InitVars = { ACTOR_EN_SSH, ACTORCAT_NPC, FLAGS, @@ -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; @@ -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) { @@ -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; @@ -602,43 +603,43 @@ s32 EnSsh_SetCylinderOC(EnSsh* this, GlobalContext* globalCtx) { 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) { - Actor_MarkForDeath(&this->actor); + if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { + Actor_Kill(&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,45 +694,45 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_08)) { phi_a1 = 0x914; } else { phi_a1 = 0x910; - gSaveContext.save.weekEventReg[34] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_34_08); } - 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..094c63f7e 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,48 +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; - #endif // Z_EN_SSH_H diff --git a/src/overlays/actors/ovl_En_St/overlay.cfg b/src/overlays/actors/ovl_En_St/overlay.cfg deleted file mode 100644 index b384f8265..000000000 --- a/src/overlays/actors/ovl_En_St/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_St -z_en_st.c 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 e2915a614..14e0c1cb5 100644 --- a/src/overlays/actors/ovl_En_St/z_en_st.c +++ b/src/overlays/actors/ovl_En_St/z_en_st.c @@ -12,18 +12,18 @@ #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 = { +ActorInit En_St_InitVars = { ACTOR_EN_ST, ACTORCAT_ENEMY, FLAGS, @@ -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,29 +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); + 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) { @@ -261,10 +260,10 @@ void func_808A54B0(EnSt* this, GlobalContext* globalCtx) { } gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(255 * temp_f0)); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025850); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_025970); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackDiskDL); + gSPDisplayList(POLY_XLU_DISP++, gSpinAttackCylinderDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -295,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]; @@ -319,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; } @@ -327,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; @@ -338,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) { @@ -412,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; } @@ -448,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; @@ -456,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); } @@ -476,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)) { @@ -484,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) { @@ -502,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; @@ -519,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; @@ -536,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; @@ -546,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; @@ -565,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; } @@ -575,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) { @@ -605,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; @@ -613,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; @@ -646,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; @@ -663,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; @@ -685,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) { @@ -706,7 +704,7 @@ void func_808A6A78(EnSt* this, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.04f); this->actor.draw = func_808A7478; - this->actor.hintId = 4; + this->actor.hintId = TATL_HINT_ID_SKULLTULA; this->actor.gravity = 0.0f; func_808A63E8(this); this->unk_18C = 0; @@ -715,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); @@ -723,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 { @@ -738,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); } @@ -753,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; @@ -765,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; @@ -793,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); @@ -807,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; @@ -823,8 +821,8 @@ void func_808A701C(EnSt* this, GlobalContext* globalCtx) { } if (count == ARRAY_COUNT(this->unk_31C)) { - Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.world.pos, 0); - Actor_MarkForDeath(&this->actor); + Item_DropCollectibleRandom(play, NULL, &this->actor.world.pos, 0); + Actor_Kill(&this->actor); } } else if (DECR(this->unk_318) == 0) { this->unk_18C |= 0x40; @@ -835,28 +833,29 @@ 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 { - this->actionFunc = func_808A6A78; + Actor_Kill(&this->actor); + return; } + + this->actionFunc = func_808A6A78; } -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) { @@ -869,14 +868,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; @@ -896,10 +895,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; @@ -913,34 +912,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..5c63a9664 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) @@ -48,6 +48,4 @@ typedef struct EnSt { /* 0x49C */ Vec3s morphTable[30]; } EnSt; // size = 0x550 -extern const ActorInit En_St_InitVars; - #endif // Z_EN_ST_H diff --git a/src/overlays/actors/ovl_En_Sth/overlay.cfg b/src/overlays/actors/ovl_En_Sth/overlay.cfg deleted file mode 100644 index 9420fb8f1..000000000 --- a/src/overlays/actors/ovl_En_Sth/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sth -z_en_sth.c 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 23b1b6223..5d1bd1471 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -13,21 +13,21 @@ #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 = { +ActorInit En_Sth_InitVars = { ACTOR_EN_STH, ACTORCAT_NPC, FLAGS, @@ -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,30 +103,30 @@ 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.flags & ACTORCTX_FLAG_1) { this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); this->actionFunc = func_80B67958; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } break; case ENSTH_F_2: - if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { this->actionFunc = func_80B67DA0; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } this->actor.textId = 0; - if (!(gSaveContext.save.weekEventReg[34] & 0x40) || !(gSaveContext.save.weekEventReg[34] & 8)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_34_40) || !CHECK_WEEKEVENTREG(WEEKEVENTREG_34_08)) { this->unk_29C |= 1; } break; case ENSTH_F_3: if ((gSaveContext.save.skullTokenCount & 0xFFFF) >= 30) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } this->actionFunc = func_80B678A8; @@ -136,21 +136,20 @@ void EnSth_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ENSTH_F_4: - if (gSaveContext.save.weekEventReg[13] & 0x20) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_20)) { + Actor_Kill(&this->actor); return; } this->actor.textId = 0; this->actionFunc = func_80B677BC; - if (gSaveContext.save.weekEventReg[13] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_80)) { this->unk_29C |= 2; } break; case ENSTH_F_5: - if (!(gSaveContext.save.weekEventReg[13] & 0x20) || - (Inventory_GetSkullTokenCount(globalCtx->sceneNum) < 30)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_13_20) || (Inventory_GetSkullTokenCount(play->sceneId) < 30)) { + Actor_Kill(&this->actor); return; } this->actionFunc = func_80B67208; @@ -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; @@ -259,7 +258,7 @@ void func_80B67348(EnSth* this, GlobalContext* globalCtx) { break; case 5: - if (gSaveContext.save.weekEventReg[13] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_40)) { phi_a1 = 0x113D; } else { phi_a1 = 0x113C; @@ -267,38 +266,38 @@ void func_80B67348(EnSth* this, GlobalContext* globalCtx) { break; default: - if (gSaveContext.save.weekEventReg[13] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_40)) { phi_a1 = 0x1142; } else { phi_a1 = 0x1141; } 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_IA_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_IA_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,34 +311,34 @@ 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; case 0x1136: - gSaveContext.save.weekEventReg[13] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_13_80); switch (sp2C) { case 0: - if (gSaveContext.save.weekEventReg[13] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_40)) { this->actor.home.rot.z = 6; } else { - gSaveContext.save.weekEventReg[13] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_13_40); switch (CUR_UPG_VALUE(UPG_WALLET)) { case 0: this->actor.home.rot.z = 8; @@ -360,152 +359,152 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_10)) { sp1E = 0x903; func_80B670A4(this, 2); - } else if (gSaveContext.save.weekEventReg[34] & 0x20) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_20)) { sp1E = 0x90F; func_80B670A4(this, 2); - } else if (gSaveContext.save.weekEventReg[34] & 0x40) { - if (!(gSaveContext.save.weekEventReg[34] & 8)) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_40)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_34_08)) { sp1E = 0x91B; } else { sp1E = 0x918; } func_80B670A4(this, 2); - } else if (Inventory_GetSkullTokenCount(globalCtx->sceneNum) >= 30) { + } else if (Inventory_GetSkullTokenCount(play->sceneId) >= 30) { if (INV_CONTENT(ITEM_MASK_TRUTH) == ITEM_MASK_TRUTH) { this->unk_29C |= 4; sp1E = 0x919; } else { sp1E = 0x916; } - } else if (gSaveContext.save.weekEventReg[34] & 2) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_02)) { sp1E = 0x8FF; } else { sp1E = 0x8FC; - gSaveContext.save.weekEventReg[34] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_34_02); } - 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); + SET_WEEKEVENTREG(WEEKEVENTREG_34_40); + 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_IA_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_IA_MINUS1); } else { this->unk_29C &= ~1; - gSaveContext.save.weekEventReg[34] |= 8; - Actor_PickUp(&this->actor, globalCtx, GI_MASK_CAPTAIN, 10000.0f, 50.0f); + SET_WEEKEVENTREG(WEEKEVENTREG_34_08); + 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,20 +512,20 @@ 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: - gSaveContext.save.weekEventReg[34] |= 0x40; - gSaveContext.save.weekEventReg[34] &= (u8)~8; + SET_WEEKEVENTREG(WEEKEVENTREG_34_40); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_34_08); case 0x902: case 0x903: @@ -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->sceneId) >= 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)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_10) || CHECK_WEEKEVENTREG(WEEKEVENTREG_34_20) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_34_40) || (Inventory_GetSkullTokenCount(play->sceneId) >= 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); } @@ -600,7 +598,7 @@ void EnSth_Update(Actor* thisx, GlobalContext* globalCtx) { break; case ENSTH_F_4: - if (gSaveContext.save.weekEventReg[13] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_13_80)) { func_80B670A4(this, 5); } else { func_80B670A4(this, 5); @@ -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->sceneId) < 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,13 +651,13 @@ 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) { @@ -668,48 +666,48 @@ void func_80B68310(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* 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)) { + 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_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..857b92505 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) @@ -32,6 +32,4 @@ typedef struct EnSth { /* 0x2A0 */ EnSthActionFunc actionFunc; } EnSth; // size = 0x2A4 -extern const ActorInit En_Sth_InitVars; - #endif // Z_EN_STH_H diff --git a/src/overlays/actors/ovl_En_Sth2/overlay.cfg b/src/overlays/actors/ovl_En_Sth2/overlay.cfg deleted file mode 100644 index 594b96573..000000000 --- a/src/overlays/actors/ovl_En_Sth2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sth2 -z_en_sth2.c 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..ac615a8dd 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.c @@ -10,12 +10,15 @@ #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); -#if 0 -const ActorInit En_Sth2_InitVars = { +void EnSth2_UpdateSkelAnime(EnSth2* this, PlayState* play); +void EnSth2_UpdateActionFunc(Actor* thisx, PlayState* play); + +ActorInit En_Sth2_InitVars = { ACTOR_EN_STH2, ACTORCAT_NPC, FLAGS, @@ -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.flags & ACTORCTX_FLAG_1) { + this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20); + } else { + Actor_Kill(&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..265332ffd 100644 --- a/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h +++ b/src/overlays/actors/ovl_En_Sth2/z_en_sth2.h @@ -2,14 +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; - #endif // Z_EN_STH2_H diff --git a/src/overlays/actors/ovl_En_Stone_heishi/overlay.cfg b/src/overlays/actors/ovl_En_Stone_heishi/overlay.cfg deleted file mode 100644 index 743a4bb0f..000000000 --- a/src/overlays/actors/ovl_En_Stone_heishi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Stone_heishi -z_en_stone_heishi.c 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..36dd9398e 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,20 +10,24 @@ #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 EnStoneheishi_CheckGivenItem(EnStoneheishi* this, PlayState* play); +void EnStoneheishi_DrinkBottleProcess(EnStoneheishi* this, PlayState* play); +void func_80BC9D28(EnStoneheishi* this, PlayState* play); +void func_80BC9E50(EnStoneheishi* this, PlayState* play); +void func_80BC94B0(EnStoneheishi* this); +void func_80BC9660(EnStoneheishi* this); +void EnStoneheishi_SetupCheckGivenItem(EnStoneheishi*); +void EnStoneheishi_GiveItemReward(EnStoneheishi* this, PlayState* play); +void EnStoneheishi_SetupDrinkBottleProcess(EnStoneheishi* this); -#if 0 -const ActorInit En_Stone_heishi_InitVars = { +ActorInit En_Stone_heishi_InitVars = { ACTOR_EN_STONE_HEISHI, ACTORCAT_NPC, FLAGS, @@ -35,54 +39,497 @@ const ActorInit En_Stone_heishi_InitVars = { (ActorFunc)EnStoneheishi_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BCA3A0 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 15, 70, 0, { 0, 0, 0 } }, }; -#endif +static u16 sEnStoneHeishiTextIds[] = { 0x1473, 0x1474, 0x1475, 0x1476, 0x1477, 0x1478, 0x1479, 0x147A, 0x1472 }; -extern ColliderCylinderInit D_80BCA3A0; +static AnimationHeader* sAnimations[] = { + &gSoldierStandHandOnHip, &gSoldierDrink, &gSoldierCheerWithSpear, &gSoldierWave, + &gSoldierSitAndReach, &gSoldierDrink, &gSoldierStandUp, +}; -extern UNK_TYPE D_06000768; -extern UNK_TYPE D_06003BFC; +static u8 sAnimationModes[] = { + ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/EnStoneheishi_Init.s") +typedef enum { + /* 0 */ EN_STONE_ACTION_0, + /* 1 */ EN_STONE_ACTION_1, + /* 2 */ EN_STONE_ACTION_CHECK_ITEM, + /* 3 */ EN_STONE_ACTION_DRINK_BOTTLE, + /* 4 */ EN_STONE_ACTION_4 +} EnStoneHeishiAction; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/EnStoneheishi_Destroy.s") +typedef enum { + /* 0 */ EN_STONE_DRINK_BOTTLE_INITIAL, + /* 1 */ EN_STONE_DRINK_BOTTLE_DRINKING, + /* 2 */ EN_STONE_DRINK_BOTTLE_EMPTY, + /* 3 */ EN_STONE_DRINK_BOTTLE_STAND_UP, + /* 4 */ EN_STONE_DRINK_BOTTLE_STANDING +} EnStoneHeishiDrinkBottle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC935C.s") +typedef enum { + /* 0 */ EN_STONE_BOTTLE_NONE, + /* 1 */ EN_STONE_BOTTLE_RED_POTION, + /* 2 */ EN_STONE_BOTTLE_EMPTY, + /* 3 */ EN_STONE_BOTTLE_BLUE_POTION, +} EnStoneHeishiBottle; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC941C.s") +typedef enum { + /* 0 */ EN_STONE_HEISHI_ANIM_STAND_HAND_ON_HIP, + /* 1 */ EN_STONE_HEISHI_ANIM_DRINK_1, + /* 2 */ EN_STONE_HEISHI_ANIM_CHEER_WITH_SPEAR, + /* 3 */ EN_STONE_HEISHI_ANIM_WAVE, + /* 4 */ EN_STONE_HEISHI_ANIM_SIT_AND_REACH, + /* 5 */ EN_STONE_HEISHI_ANIM_DRINK_2, + /* 6 */ EN_STONE_HEISHI_ANIM_STAND_UP, +} EnStoneHeishiAnimations; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC94B0.s") +void EnStoneheishi_Init(Actor* thisx, PlayState* play) { + EnStoneheishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9560.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 25.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gSoldierSkel, &gSoldierWave, this->jointTable, this->morphTable, + SOLDIER_LIMB_MAX); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9660.s") + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 6; + this->actor.gravity = -3.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9680.s") + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC98EC.s") + this->collider.dim.radius = 40; + this->collider.dim.height = 40; + this->collider.dim.yShift = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9908.s") + func_80BC94B0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9A10.s") +void EnStoneheishi_Destroy(Actor* thisx, PlayState* play) { + EnStoneheishi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9A2C.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9C88.s") +void EnStoneheishi_ChangeAnim(EnStoneheishi* this, s32 animIndex) { + f32 startFrame = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9D28.s") + this->animIndex = animIndex; + this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BC9E50.s") + // This will never pass since this animation index is never used. + if (animIndex == EN_STONE_HEISHI_ANIM_DRINK_2) { + startFrame = 55.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/EnStoneheishi_Update.s") + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, startFrame, this->endFrame, + sAnimationModes[this->animIndex], -10.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BCA0AC.s") +void EnStoneheishi_TrackPlayer(EnStoneheishi* this) { + s32 yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/func_80BCA104.s") + this->targetHeadRot.y = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Stone_heishi/EnStoneheishi_Draw.s") + if ((this->actor.xzDistToPlayer < 200.0f) && (yawDiff < 0x4E20)) { + this->targetHeadRot.y = this->actor.yawTowardsPlayer - this->actor.world.rot.y; + if (this->targetHeadRot.y > 0x2710) { + this->targetHeadRot.y = 0x2710; + } else if (this->targetHeadRot.y < -0x2710) { + this->targetHeadRot.y = -0x2710; + } + } +} + +void func_80BC94B0(EnStoneheishi* this) { + this->textIdIndex = 0; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_41_40)) { // After drinking bottle + EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_CHEER_WITH_SPEAR); + this->textIdIndex = 8; + this->actor.flags &= ~ACTOR_FLAG_80; + } else { // Initial configuration + EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_WAVE); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_41_80)) { + this->textIdIndex = 2; + } + } + this->actor.textId = sEnStoneHeishiTextIds[this->textIdIndex]; + this->action = EN_STONE_ACTION_0; + this->actionFunc = func_80BC9560; +} + +void func_80BC9560(EnStoneheishi* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 yawDiff; + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80BC9660(this); + return; + } + + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_40) && (play->actorCtx.lensMaskSize != 100)) { + this->actor.flags |= ACTOR_FLAG_8000000; + return; + } + + SkelAnime_Update(&this->skelAnime); + + this->actor.flags &= ~ACTOR_FLAG_8000000; + + yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.world.rot.y)); + + if ((yawDiff <= 0x18F0) && !(player->stateFlags1 & PLAYER_STATE1_800000)) { + func_800B8614(&this->actor, play, 70.0f); + } +} + +void func_80BC9660(EnStoneheishi* this) { + this->textIdSet = false; + this->action = EN_STONE_ACTION_1; + this->actionFunc = func_80BC9680; +} + +void func_80BC9680(EnStoneheishi* this, PlayState* play) { + f32 currentFrame = this->skelAnime.curFrame; + + if ((this->textIdIndex == 0) || (this->textIdIndex == 2)) { + if (this->animIndex != EN_STONE_HEISHI_ANIM_SIT_AND_REACH) { + if (fabsf(this->headRot.x - this->targetHeadRot.x) < 50.0f) { + EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_SIT_AND_REACH); + } + return; + } + } else if (this->textIdIndex == 3) { + if (this->animIndex != EN_STONE_HEISHI_ANIM_WAVE) { + if ((this->timer == 0) && (fabsf(this->headRot.x - this->targetHeadRot.x) < 50.0f)) { + EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_WAVE); + } + return; + } else if (!this->textIdSet && (this->endFrame <= currentFrame)) { + Player* player = GET_PLAYER(play); + + this->textIdSet = true; + player->actor.textId = sEnStoneHeishiTextIds[this->textIdIndex]; + + func_80151938(play, sEnStoneHeishiTextIds[this->textIdIndex]); + func_80151BB4(play, 0x12); + } + } + + SkelAnime_Update(&this->skelAnime); + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + + if (this->textIdIndex == 2) { + func_80151938(play, 0xFF); + EnStoneheishi_SetupCheckGivenItem(this); + } else if (this->textIdIndex == 3) { + func_80BC94B0(this); + } else if (this->textIdIndex == 6) { + EnStoneheishi_GiveItemReward(this, play); + } else { + if (this->textIdIndex < 7) { + this->textIdIndex++; + } else { + func_80151BB4(play, 0x12); + func_80BC94B0(this); + return; + } + func_80151938(play, sEnStoneHeishiTextIds[this->textIdIndex]); + } + } +} + +void EnStoneheishi_SetupCheckGivenItem(EnStoneheishi* this) { + this->action = EN_STONE_ACTION_CHECK_ITEM; + this->actionFunc = EnStoneheishi_CheckGivenItem; +} + +void EnStoneheishi_CheckGivenItem(EnStoneheishi* this, PlayState* play) { + PlayerItemAction itemAction; + + SkelAnime_Update(&this->skelAnime); + + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemAction = func_80123810(play); + + if (itemAction > PLAYER_IA_NONE) { + this->timer = 40; + func_801477B4(play); + + if ((itemAction == PLAYER_IA_BOTTLE_POTION_RED) || (itemAction == PLAYER_IA_BOTTLE_POTION_BLUE)) { + this->playerGivesBluePotion = false; + if (itemAction == PLAYER_IA_BOTTLE_POTION_BLUE) { + this->playerGivesBluePotion = true; + } + EnStoneheishi_SetupDrinkBottleProcess(this); + } else { + Player* player = GET_PLAYER(play); + + this->textIdIndex = 3; + player->actor.textId = 0; + SET_WEEKEVENTREG(WEEKEVENTREG_41_80); + this->action = EN_STONE_ACTION_1; + this->actionFunc = func_80BC9680; + } + } else if (itemAction <= PLAYER_IA_MINUS1) { + func_801477B4(play); + func_80151BB4(play, 0x12); + func_80BC94B0(this); + } + } +} + +void EnStoneheishi_SetupDrinkBottleProcess(EnStoneheishi* this) { + this->action = EN_STONE_ACTION_DRINK_BOTTLE; + this->actionFunc = EnStoneheishi_DrinkBottleProcess; +} + +void EnStoneheishi_DrinkBottleProcess(EnStoneheishi* this, PlayState* play) { + f32 currentFrame = this->skelAnime.curFrame; + Player* player = GET_PLAYER(play); + + SkelAnime_Update(&this->skelAnime); + + switch (this->drinkBottleState) { + case EN_STONE_DRINK_BOTTLE_INITIAL: + if (this->timer == 0) { + this->textIdIndex = 4; + func_80151938(play, sEnStoneHeishiTextIds[this->textIdIndex]); + player->actor.textId = sEnStoneHeishiTextIds[this->textIdIndex]; + this->drinkBottleState++; + } + + default: + break; + + case EN_STONE_DRINK_BOTTLE_DRINKING: + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + Player* player = GET_PLAYER(play); + + play->msgCtx.msgLength = 0; + player->actor.textId = 0; + player->exchangeItemId = PLAYER_IA_NONE; + this->bottleDisplay = EN_STONE_BOTTLE_RED_POTION; + + if (this->playerGivesBluePotion) { + this->bottleDisplay = EN_STONE_BOTTLE_BLUE_POTION; + } + + Player_SetModels(player, 3); + EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_DRINK_1); + this->timer = 30; + this->drinkBottleState++; + } + break; + + case EN_STONE_DRINK_BOTTLE_EMPTY: + if (this->timer != 0) { + if ((this->timer < 10) && (this->bottleDisplay != EN_STONE_BOTTLE_EMPTY)) { + this->bottleDisplay = EN_STONE_BOTTLE_EMPTY; + Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_NP_DRINK); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_BOTTLE); + } + } else { + this->drinkBottleState++; + } + break; + + case EN_STONE_DRINK_BOTTLE_STAND_UP: + if (this->endFrame <= currentFrame) { + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); + this->bottleDisplay = EN_STONE_BOTTLE_NONE; + EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_STAND_UP); + this->drinkBottleState++; + } + break; + + case EN_STONE_DRINK_BOTTLE_STANDING: + if (this->endFrame <= currentFrame) { + this->textIdIndex = 5; + func_80151938(play, sEnStoneHeishiTextIds[this->textIdIndex]); + player->actor.textId = sEnStoneHeishiTextIds[this->textIdIndex]; + EnStoneheishi_ChangeAnim(this, EN_STONE_HEISHI_ANIM_STAND_HAND_ON_HIP); + this->action = EN_STONE_ACTION_1; + this->actionFunc = func_80BC9680; + } + break; + } +} + +void EnStoneheishi_GiveItemReward(EnStoneheishi* this, PlayState* play) { + func_801477B4(play); + + if (INV_CONTENT(ITEM_MASK_STONE) == ITEM_MASK_STONE) { + Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 300.0f, 300.0f); + } else { + Actor_PickUp(&this->actor, play, GI_MASK_STONE, 300.0f, 300.0f); + } + + this->action = EN_STONE_ACTION_4; + this->actionFunc = func_80BC9D28; +} + +void func_80BC9D28(EnStoneheishi* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + this->textIdIndex++; + this->actor.textId = sEnStoneHeishiTextIds[this->textIdIndex]; + SET_WEEKEVENTREG(WEEKEVENTREG_41_40); + Actor_ProcessTalkRequest(&this->actor, &play->state); + func_800B8500(&this->actor, play, 400.0f, 400.0f, PLAYER_IA_MINUS1); + this->actionFunc = func_80BC9E50; + } else if (INV_CONTENT(ITEM_MASK_STONE) == ITEM_MASK_STONE) { + Actor_PickUp(&this->actor, play, GI_RUPEE_BLUE, 300.0f, 300.0f); + } else { + Actor_PickUp(&this->actor, play, GI_MASK_STONE, 300.0f, 300.0f); + } +} + +void func_80BC9E50(EnStoneheishi* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80151BB4(play, 0x35); + func_80151BB4(play, 0x12); + this->action = EN_STONE_ACTION_1; + this->actionFunc = func_80BC9680; + } else { + func_800B8500(&this->actor, play, 400.0f, 400.0f, PLAYER_IA_MINUS1); + } +} + +void EnStoneheishi_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnStoneheishi* this = THIS; + Player* player = GET_PLAYER(play); + + if (this->timer != 0) { + this->timer--; + } + + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actionFunc(this, play); + + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D); + Actor_SetScale(&this->actor, 0.01f); + + if ((CHECK_WEEKEVENTREG(WEEKEVENTREG_41_40) || (play->actorCtx.lensMaskSize == 100)) && + !(player->stateFlags1 & PLAYER_STATE1_800000)) { + if ((this->animIndex != EN_STONE_HEISHI_ANIM_WAVE) && + ((((this->action == EN_STONE_ACTION_0) || (this->action == EN_STONE_ACTION_1)) || + (this->action == EN_STONE_ACTION_CHECK_ITEM)) || + ((this->action == EN_STONE_ACTION_DRINK_BOTTLE) && + (this->drinkBottleState <= EN_STONE_DRINK_BOTTLE_DRINKING)))) { + EnStoneheishi_TrackPlayer(this); + } else { + this->targetHeadRot.y = 0; + } + + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_40)) { + Actor_SetFocus(&this->actor, 30.0f); + } else { + Actor_SetFocus(&this->actor, 60.0f); + } + + Math_SmoothStepToS(&this->headRot.y, this->targetHeadRot.y, 1, 0xBB8, 0); + Math_SmoothStepToS(&this->headRot.x, this->targetHeadRot.x, 1, 0x3E8, 0); + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } +} + +s32 EnStoneheishi_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfxp) { + EnStoneheishi* this = THIS; + + if (limbIndex == SOLDIER_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->y += this->headRot.x; + rot->z += this->headRot.z; + } + + return false; +} + +void EnStoneheishi_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfxp) { + static Vec3f sLeftHandPos = { 0.0f, 0.0f, 0.0f }; + EnStoneheishi* this = THIS; + Gfx* gfx; + + if ((limbIndex == SOLDIER_LIMB_LEFT_HAND) && (this->bottleDisplay != EN_STONE_BOTTLE_NONE)) { + gfx = func_8012C2B4(*gfxp); + + sLeftHandPos.x = 320.0f; + sLeftHandPos.y = 210.0f; + sLeftHandPos.z = 440.0f; + + Matrix_Translate(sLeftHandPos.x, sLeftHandPos.y, sLeftHandPos.z, MTXMODE_APPLY); + + gDPPipeSync(gfx++); + + Matrix_RotateYS(-0x1770, MTXMODE_APPLY); + Matrix_RotateXS(0x7D0, MTXMODE_APPLY); + Matrix_RotateZS(-0x7530, MTXMODE_APPLY); + + if (this->bottleDisplay != EN_STONE_BOTTLE_EMPTY) { + if (this->bottleDisplay == EN_STONE_BOTTLE_BLUE_POTION) { + gDPSetEnvColor(gfx++, 0, 0, 200, 0); // Blue Potion + } else { + gDPSetEnvColor(gfx++, 200, 0, 0, 0); // Red Potion + } + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gSoldierBottleContentsDL); + } + + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, gSoldierBottleDL); + + *gfxp = gfx++; + } +} + +void EnStoneheishi_Draw(Actor* thisx, PlayState* play) { + EnStoneheishi* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_41_40)) { + func_8012C2DC(play->state.gfxCtx); + + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnStoneheishi_OverrideLimbDraw, EnStoneheishi_PostLimbDraw, &this->actor, POLY_XLU_DISP); + } else { + func_8012C28C(play->state.gfxCtx); + + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnStoneheishi_OverrideLimbDraw, EnStoneheishi_PostLimbDraw, &this->actor, POLY_OPA_DISP); + } + + CLOSE_DISPS(play->state.gfxCtx); +} 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..715fc7139 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 @@ -2,18 +2,30 @@ #define Z_EN_STONE_HEISHI_H #include "global.h" +#include "assets/objects/object_sdn/object_sdn.h" 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 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[SOLDIER_LIMB_MAX]; + /* 0x1EE */ Vec3s morphTable[SOLDIER_LIMB_MAX]; + /* 0x254 */ EnStoneheishiActionFunc actionFunc; + /* 0x258 */ Vec3s headRot; + /* 0x25E */ Vec3s targetHeadRot; + /* 0x264 */ s32 animIndex; + /* 0x268 */ s16 timer; + /* 0x26A */ s16 drinkBottleState; + /* 0x26C */ f32 endFrame; + /* 0x270 */ s16 action; + /* 0x272 */ s16 textIdIndex; + /* 0x274 */ s16 textIdSet; + /* 0x276 */ u8 bottleDisplay; + /* 0x277 */ u8 playerGivesBluePotion; + /* 0x278 */ ColliderCylinder collider; } EnStoneheishi; // size = 0x2C4 -extern const ActorInit En_Stone_heishi_InitVars; - #endif // Z_EN_STONE_HEISHI_H diff --git a/src/overlays/actors/ovl_En_Stop_heishi/overlay.cfg b/src/overlays/actors/ovl_En_Stop_heishi/overlay.cfg deleted file mode 100644 index cf5960b30..000000000 --- a/src/overlays/actors/ovl_En_Stop_heishi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Stop_heishi -z_en_stop_heishi.c 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..c4d56b70a 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 @@ -5,21 +5,22 @@ */ #include "z_en_stop_heishi.h" +#include "z64quake.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #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 = { +ActorInit En_Stop_heishi_InitVars = { ACTOR_EN_STOP_HEISHI, ACTORCAT_NPC, FLAGS, 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..8e27f1c36 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,15 +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; - #endif // Z_EN_STOP_HEISHI_H diff --git a/src/overlays/actors/ovl_En_Stream/overlay.cfg b/src/overlays/actors/ovl_En_Stream/overlay.cfg deleted file mode 100644 index 3789ae1fe..000000000 --- a/src/overlays/actors/ovl_En_Stream/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Stream -z_en_stream.c 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..11e5ce7d6 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -11,14 +11,14 @@ #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 = { +ActorInit En_Stream_InitVars = { ACTOR_EN_STREAM, ACTORCAT_BG, FLAGS, @@ -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; @@ -104,7 +104,7 @@ void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) { if (yDistWithOffset > 0.0f) { Math_SmoothStepToF(&player->actor.velocity.y, -3.0f, 0.7f, yDistWithOffset, 0.0f); if (posDifference.y < -70.0f) { - player->stateFlags2 |= 0x80000000; + player->stateFlags2 |= PLAYER_STATE2_80000000; } } } else { @@ -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..88856c3dd 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; @@ -32,6 +32,4 @@ typedef struct EnStream { /* 0x14C */ UNK_TYPE1 unk_14C[0x4]; } EnStream; // size = 0x150 -extern const ActorInit En_Stream_InitVars; - #endif // Z_EN_STREAM_H diff --git a/src/overlays/actors/ovl_En_Suttari/overlay.cfg b/src/overlays/actors/ovl_En_Suttari/overlay.cfg deleted file mode 100644 index 9eea97af5..000000000 --- a/src/overlays/actors/ovl_En_Suttari/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Suttari -z_en_suttari.c 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 4a7e56682..93c93eef9 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -7,37 +7,38 @@ #include "z_en_suttari.h" #include "overlays/actors/ovl_En_Elf/z_en_elf.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h" #include "objects/object_boj/object_boj.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10) #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 = { +ActorInit En_Suttari_InitVars = { ACTOR_EN_SUTTARI, ACTORCAT_NPC, FLAGS, @@ -49,7 +50,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,7 +121,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xE), }; -static TurnOptionsSet sTurnOptions = { +static TrackOptionsSet sTrackOptions = { { 0xFA0, 4, 1, 3 }, { 0x1770, 4, 1, 6 }, { 0xFA0, 4, 1, 3 }, @@ -129,7 +130,7 @@ static TurnOptionsSet sTurnOptions = { 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), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_33_08, 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), @@ -181,7 +182,7 @@ 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; @@ -192,7 +193,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; @@ -200,18 +201,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) { @@ -222,19 +223,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) { - 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); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset); } -s32 func_80BAA904(EnSuttari* this, GlobalContext* globalCtx) { +s32 func_80BAA904(EnSuttari* this, PlayState* play) { Vec3f pos; s32 pad; CollisionPoly* poly; @@ -242,7 +243,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; @@ -250,7 +251,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: @@ -261,15 +262,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); } } } @@ -277,8 +278,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; @@ -290,17 +291,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: @@ -363,9 +364,9 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else if (this->flags1 & 1) { switch (this->textId) { case 0: - if (gSaveContext.save.weekEventReg[81] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_81_01)) { 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; @@ -381,13 +382,13 @@ void func_80BAAB78(EnSuttari* this, GlobalContext* globalCtx) { } else { this->flags1 |= 0x400; this->textId = 0x1452; - gSaveContext.save.weekEventReg[81] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_81_01); } break; case 0x1453: this->flags1 |= 0x400; - gSaveContext.save.weekEventReg[81] |= 1; - ((EnElf*)GET_PLAYER(globalCtx)->tatlActor)->unk_264 |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_81_01); + ((EnElf*)GET_PLAYER(play)->tatlActor)->unk_264 |= 8; this->flags2 |= 1; this->textId = 0x1454; break; @@ -412,24 +413,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; @@ -444,24 +445,25 @@ void func_80BAAFDC(EnSuttari* this, GlobalContext* globalCtx) { effectVelOffset.z = 20.0f; Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); - if (this->unk3F0 == 0) { - EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); + if (!this->playerDetected) { + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->playerDetected, + SOLDERSRCHBALL_INVISIBLE); } - if (this->unk3F0 == 1) { + if (this->playerDetected == true) { play_sound(NA_SE_SY_FOUND); - this->unk3F0 = 0; + this->playerDetected = false; this->actor.speedXZ = 0.0f; if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.save.weekEventReg[61] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_61_08); this->unk3F6 = 20; this->actionFunc = func_80BADE8C; } } } -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; @@ -476,26 +478,27 @@ void func_80BAB1A0(EnSuttari* this, GlobalContext* globalCtx) { effectVelOffset.z = 20.0f; Matrix_MultVec3f(&effectVelOffset, &effectVel); Matrix_Pop(); - if (this->unk3F0 == 0) { - EffectSsSolderSrchBall_Spawn(globalCtx, &effectPos, &effectVel, &gZeroVec3f, 50, &this->unk3F0, 1); + if (!this->playerDetected) { + EffectSsSolderSrchBall_Spawn(play, &effectPos, &effectVel, &gZeroVec3f, 50, &this->playerDetected, + SOLDERSRCHBALL_INVISIBLE); } - if (this->unk3F0 == 1) { + if (this->playerDetected == true) { play_sound(NA_SE_SY_FOUND); - this->unk3F0 = 0; + this->playerDetected = false; this->actor.speedXZ = 0.0f; if (this->unk1F4[0] != 0) { this->unk1F4[0]--; } - gSaveContext.save.weekEventReg[61] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_61_08); 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; @@ -503,7 +506,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); } } @@ -512,36 +515,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); +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)) { point.x = player->actor.world.pos.x; - point.y = player->bodyPartsPos[7].y + 3.0f; + point.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->torsoRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->torsoRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->turnTarget.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) { @@ -560,7 +563,7 @@ s16 EnSuttari_GetDistSqAndOrient(Path* path, s32 index, Vec3f* pos, f32* distSq) } *distSq = SQ(diffX) + SQ(diffZ); - return RADF_TO_BINANG(Math_Acot2F(diffZ, diffX)); + return RADF_TO_BINANG(Math_Atan2F_XY(diffZ, diffX)); } s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { @@ -673,68 +676,64 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABC48(EnSuttari* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp26 = SCHEDULE_TIME_NOW; - u16 pad1; - u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); - u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->result]; 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->time0; + phi_a0 = scheduleOutput->time0; } - if (unkStruct->time1 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->time1) + 0xFFFF; + if (scheduleOutput->time1 < phi_a0) { + this->timePathTotalTime = (phi_a0 - scheduleOutput->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->time1 - 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, ScheduleResult* 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 = SCHEDULE_TIME_NOW; 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->result]; + 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->time0; - this->unk436 = unkStruct->time1 - unkStruct->time0; - if (unkStruct->result != 10 && unkStruct->result != 11) { + this->unk434 = sp44 - scheduleOutput->time0; + this->unk436 = scheduleOutput->time1 - scheduleOutput->time0; + if (scheduleOutput->result != 10 && scheduleOutput->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -744,15 +743,15 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk return 1; } -s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABF64(EnSuttari* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; - switch (unkStruct->result) { + 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: @@ -760,7 +759,7 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk case 8: case 7: case 6: - ret = func_80BABDD8(this, globalCtx, unkStruct); + ret = func_80BABDD8(this, play, scheduleOutput); break; case 5: case 4: @@ -776,51 +775,53 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk 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 (SubS_InCsMode(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 (SubS_InCsMode(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; @@ -837,32 +838,32 @@ 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_83_04) && !(this->flags1 & 0x1000)) { if (ActorCutscene_GetCanPlayNext(this->cutscenes[0])) { ActorCutscene_Start(this->cutscenes[0], &this->actor); - if (!(player->stateFlags1 & 0x10000000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_10000000)) { this->flags2 |= 0x10; - player->stateFlags1 |= 0x10000000; + player->stateFlags1 |= PLAYER_STATE1_10000000; } this->flags1 |= 0x1000; this->flags2 |= 2; @@ -870,43 +871,43 @@ 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); + Actor_Kill(&this->actor); break; case 2: - if (!(gSaveContext.save.weekEventReg[81] & 4)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_81_04)) { this->flags1 |= 0x80; this->actor.world.pos.x = -16.0f; this->actor.world.pos.z = -16.0f; @@ -916,21 +917,21 @@ 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08)) { + if (this->animIndex == 2 || this->animIndex == 1) { + this->animIndex = 5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } this->flags1 |= 0x10; if (this->flags2 & 2) { this->flags2 &= ~2; } - if (!(player->stateFlags1 & 0x10000000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_10000000)) { this->flags2 |= 0x10; - player->stateFlags1 |= 0x10000000; + player->stateFlags1 |= PLAYER_STATE1_10000000; } this->textId = 0x2A30; - Message_StartTextbox(globalCtx, this->textId, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = func_80BAD2B4; } break; @@ -938,60 +939,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->sceneId == 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); + !CHECK_WEEKEVENTREG(WEEKEVENTREG_61_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_51_08)) { + this->animIndex = 2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = func_80BACEE0; return; } - } else if (globalCtx->sceneNum == SCENE_BACKTOWN) { + } else if (play->sceneId == SCENE_BACKTOWN) { if (gSaveContext.save.time >= CLOCK_TIME(0, 20) && gSaveContext.save.time < CLOCK_TIME(6, 00)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } - if ((gSaveContext.save.entranceIndex == 0xD670) || (gSaveContext.save.weekEventReg[58] & 0x40)) { - Actor_MarkForDeath(&this->actor); + + if ((gSaveContext.save.entrance == ENTRANCE(NORTH_CLOCK_TOWN, 7)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_58_40)) { + Actor_Kill(&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) { - if (gSaveContext.save.weekEventReg[33] & 8) { - Actor_MarkForDeath(&this->actor); + } else if (play->sceneId == SCENE_ICHIBA) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08)) { + Actor_Kill(&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) { - if (gSaveContext.save.weekEventReg[33] & 8) { - Actor_MarkForDeath(&this->actor); + } else if (play->sceneId == SCENE_AYASHIISHOP) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08)) { + Actor_Kill(&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; @@ -1003,15 +1005,15 @@ void func_80BAC6E8(EnSuttari* this, GlobalContext* globalCtx) { this->actionFunc = func_80BACA14; return; } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&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); @@ -1020,21 +1022,22 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { 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)) { + } 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, globalCtx); + 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->headRot.y; @@ -1044,7 +1047,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { 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; @@ -1064,8 +1067,8 @@ 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->headRot.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { @@ -1086,7 +1089,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; } @@ -1098,58 +1101,58 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } } -void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; +void func_80BACEE0(EnSuttari* this, PlayState* play) { + ScheduleOutput scheduleOutput; - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; - func_80BAC2FC(this, globalCtx); + this->unk428 = scheduleOutput.result; + func_80BAC2FC(this, play); func_80BAB434(this); if (this->unk428 == 5) { - gSaveContext.save.weekEventReg[58] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_58_80); 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) { - ScheduleResult unkStruct; +void func_80BAD004(EnSuttari* this, PlayState* play) { + ScheduleOutput scheduleOutput; - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; - 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) { @@ -1164,11 +1167,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; @@ -1177,181 +1180,181 @@ 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 & PLAYER_STATE1_40) && (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; + player->stateFlags1 &= ~PLAYER_STATE1_10000000; 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) { this->flags2 |= 8; func_80BAAF1C(this); } else if (this->flags1 & 0x200) { - gSaveContext.save.weekEventReg[79] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_79_40); 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_MarkForDeath(&this->actor); + 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_Kill(&this->actor); return; } if (this->unk1F4[1] == -0x63) { if (this->flags2 & 8) { - gSaveContext.save.weekEventReg[33] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_33_08); } 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->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) { - ScheduleResult 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) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; - func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { - Actor_MarkForDeath(&this->actor); + this->unk428 = scheduleOutput.result; + func_80BAC2FC(this, play); + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { + Actor_Kill(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.result != 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) { - ScheduleResult 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) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); + if (!Schedule_RunScript(play, D_80BAE820, &scheduleOutput) || + ((this->unk428 != scheduleOutput.result) && !func_80BABF64(this, play, &scheduleOutput))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleOutput.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; - func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { - Actor_MarkForDeath(&this->actor); + this->unk428 = scheduleOutput.result; + func_80BAC2FC(this, play); + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { + Actor_Kill(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.result != 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); - gSaveContext.save.weekEventReg[81] |= 4; + func_80BAAB78(this, play); + SET_WEEKEVENTREG(WEEKEVENTREG_81_04); } 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->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; @@ -1360,18 +1363,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; } } @@ -1381,7 +1384,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); @@ -1395,16 +1398,16 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_51_10)) { this->actionFunc = func_80BADE14; } 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; @@ -1415,23 +1418,23 @@ void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } -void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { +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); + Actor_Kill(&this->actor); } this->unk3F2 = this->headRot.y; if (DECR(this->unk3F6) == 0) { @@ -1440,54 +1443,54 @@ void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { Actor_MoveWithGravity(&this->actor); } -void EnSuttari_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSuttari_Init(Actor* thisx, PlayState* play) { EnSuttari* this = THIS; s32 pad; - if (gSaveContext.save.weekEventReg[79] & 0x40) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_40)) { + Actor_Kill(&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->sceneId == 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); - if ((this->flags1 & 8) && (this->flags2 & 0x10) && (player->stateFlags1 & 0x10000000)) { + this->actionFunc(this, play); + if ((this->flags1 & 8) && (this->flags2 & 0x10) && (player->stateFlags1 & PLAYER_STATE1_10000000)) { 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); } @@ -1495,8 +1498,7 @@ 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) { @@ -1519,7 +1521,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; @@ -1535,16 +1537,16 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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) { Matrix_MtxFToYXZRot(curState, &bombBag->shape.rot, false); } } else { - func_8012C28C(globalCtx->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, object_boj_DL_013380); - CLOSE_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, gBombShopBagDL); + CLOSE_DISPS(play->state.gfxCtx); } } } @@ -1554,32 +1556,32 @@ void EnSuttari_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList } } -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 2fbdff53b..669cf549e 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,40 +27,37 @@ typedef struct EnSuttari { /* 0x1FC */ UNK_TYPE1 unk_1FC[0x1A]; /* 0x216 */ Vec3s jointTable[16]; /* 0x276 */ Vec3s morphTable[16]; - /* 0x2D6 */ Vec3s turnTarget; + /* 0x2D6 */ Vec3s trackTarget; /* 0x2DC */ Vec3s headRot; /* 0x2E2 */ Vec3s torsoRot; /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x12]; /* 0x2FA */ s16 unk2FA[16]; /* 0x31A */ s16 unk31A[16]; /* 0x33A */ UNK_TYPE1 unk_33A[0xB6]; - /* 0x3F0 */ s16 unk3F0; + /* 0x3F0 */ s16 playerDetected; /* 0x3F2 */ s16 unk3F2; /* 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; } EnSuttari; // size = 0x45C -extern const ActorInit En_Suttari_InitVars; - #endif // Z_EN_SUTTARI_H diff --git a/src/overlays/actors/ovl_En_Sw/overlay.cfg b/src/overlays/actors/ovl_En_Sw/overlay.cfg deleted file mode 100644 index af7fca6ea..000000000 --- a/src/overlays/actors/ovl_En_Sw/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Sw -z_en_sw.c 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 0188b323c..d8dd72923 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -11,24 +11,24 @@ #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 = { +ActorInit En_Sw_InitVars = { ACTOR_EN_SW, ACTORCAT_NPC, FLAGS, @@ -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); } } @@ -348,19 +348,18 @@ void func_808D93BC(EnSw* this) { 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,7 +449,7 @@ void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 } } #else -void func_808D94D0(EnSw* this, GlobalContext* globalCtx, s32 arg2, s32 arg3, s16 arg4); +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 @@ -485,12 +484,12 @@ void func_808D9894(EnSw* this, Vec3f* 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; } } @@ -498,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; } @@ -514,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; @@ -544,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; @@ -630,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; @@ -646,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) { @@ -675,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) { @@ -736,21 +735,21 @@ 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)) { + if ((player->stateFlags1 & PLAYER_STATE1_200000) && (this->actor.xyzDistToPlayerSq < 8000.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_LAUGH); Math_Vec3f_Copy(&this->unk_374, &player->actor.world.pos); this->unk_410 &= ~0x20; this->unk_414 = 0.0f; 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; @@ -762,7 +761,7 @@ void func_808DA3F4(EnSw* this, GlobalContext* globalCtx) { Math_Vec3f_Copy(&sp38, &this->unk_374); func_808D9894(this, &sp38); - temp_v0 = Math_FAtan2F(sp38.z, sp38.x); + temp_v0 = Math_Atan2S_XY(sp38.z, sp38.x); if (ABS_ALT(temp_v0) < temp_s1) { this->skelAnime.curFrame = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); @@ -779,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_Atan2S_XY(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); @@ -806,37 +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 -void func_808DA578(EnSw* this, GlobalContext* globalCtx); -#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_Atan2S_XY(sp38.z, sp38.x); + func_808D94D0(this, play, 0, 0, temp2); } } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); @@ -844,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; @@ -855,12 +844,8 @@ void func_808DA6FC(EnSw* this, GlobalContext* globalCtx) { } this->unk_414 = sp4C; } -#else -void func_808DA6FC(EnSw* this, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DA6FC.s") -#endif -void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { +void func_808DA89C(EnSw* this, PlayState* play) { if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { s32 i; s32 count; @@ -883,7 +868,7 @@ 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); } } else if (ENSW_GET_3(&this->actor)) { this->actionFunc = func_808DAEB4; @@ -903,18 +888,18 @@ void func_808DA89C(EnSw* this, GlobalContext* globalCtx) { this->actor.velocity.y = 0.0f; } if ((s32)this->actor.velocity.y >= 2) { - func_808D8940(this, globalCtx); + func_808D8940(this, play); } } else { Math_ApproachF(&this->actor.shape.yOffset, 400.0f, 0.3f, 1000.0f); } Actor_MoveWithGravity(&this->actor); - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4); + 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; @@ -931,7 +916,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { if (this->unk_45E == 0) { Math_Vec3s_ToVec3f(&sp34, &sp44[this->unk_4A0]); func_808D9894(this, &sp34); - temp_v0 = Math_FAtan2F(sp34.z, sp34.x); + temp_v0 = Math_Atan2S_XY(sp34.z, sp34.x); if (ABS_ALT(temp_v0) < sp40) { this->skelAnime.curFrame = 0.0f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); @@ -964,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_Atan2S_XY(sp38.z, sp38.x); + func_808D94D0(this, play, 0, 0, temp_f6); } } else { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_STALWALL_DASH); @@ -992,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)) { @@ -1010,12 +994,8 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { } this->unk_414 = sp4C; } -#else -void func_808DACF4(EnSw* this, GlobalContext* globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sw/func_808DACF4.s") -#endif -void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { +void func_808DAEB4(EnSw* this, PlayState* play) { Vec3f sp5C; s32 i; s32 count; @@ -1043,7 +1023,7 @@ void func_808DAEB4(EnSw* this, GlobalContext* globalCtx) { } if (count == ARRAY_COUNT(this->unk_464)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } else { Math_ApproachF(&this->actor.scale.x, 0.0f, 0.08f, 1.0f); @@ -1054,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); + Actor_Kill(&this->actor); } - func_808D94D0(this, globalCtx, 0, 0, 0x1554); + func_808D94D0(this, play, 0, 0, 0x1554); } } else { phi_a0 = DECR(this->unk_45C); @@ -1076,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; } @@ -1108,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)) { @@ -1120,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; @@ -1134,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); } } @@ -1149,39 +1129,38 @@ 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; + this->actor.hintId = TATL_HINT_ID_SKULLWALLTULA; CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); this->collider.info.toucher.damage = 8; } else { - this->actor.hintId = 0x20; + this->actor.hintId = TATL_HINT_ID_GOLD_SKULLTULA; CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable2, &sColChkInfoInit2); 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; @@ -1199,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; @@ -1220,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); @@ -1231,23 +1210,23 @@ void EnSw_Init(Actor* thisx, GlobalContext* globalCtx) { break; } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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)) { @@ -1255,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)) { @@ -1307,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); + func_8012C28C(play->state.gfxCtx); Matrix_RotateXS(-0x3C72, MTXMODE_APPLY); - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, NULL, + 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..4544346a0 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -5,49 +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; - #endif // Z_EN_SW_H diff --git a/src/overlays/actors/ovl_En_Syateki_Crow/overlay.cfg b/src/overlays/actors/ovl_En_Syateki_Crow/overlay.cfg deleted file mode 100644 index 5a90d72e0..000000000 --- a/src/overlays/actors/ovl_En_Syateki_Crow/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Syateki_Crow -z_en_syateki_crow.c 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 b45da318d..1a2f8b685 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 @@ -6,27 +6,26 @@ #include "z_en_syateki_crow.h" #include "overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.h" -#include "objects/object_crow/object_crow.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_8000000) #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* play2); +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_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 EnSyatekiCrow_SetupWaitForSpawn(EnSyatekiCrow* this); +void EnSyatekiCrow_WaitForSpawn(EnSyatekiCrow* this, PlayState* play); +void EnSyatekiCrow_SetupWaitToMove(EnSyatekiCrow* this); +void EnSyatekiCrow_WaitToMove(EnSyatekiCrow* this, PlayState* play); +void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play); +void EnSyatekiCrow_Dead(EnSyatekiCrow* this, PlayState* play); -static Vec3f D_809CB050 = { 0.0f, 0.0f, 0.0f }; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; -const ActorInit En_Syateki_Crow_InitVars = { +ActorInit En_Syateki_Crow_InitVars = { ACTOR_EN_SYATEKI_CROW, ACTORCAT_ENEMY, FLAGS, @@ -61,25 +60,19 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 3000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 88, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_GUAY, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP), }; -static Vec3f D_809CB0C0 = { 0.0f, 20.0f, 0.0f }; - -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,152 +80,154 @@ 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_INDEX(&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); - this->unk_23C.elements->dim.worldSphere.radius = sJntSphInit.elements[0].dim.modelSphere.radius; + Collider_InitJntSph(play, &this->collider); + Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); + this->collider.elements[0].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)) { - Actor_MarkForDeath(&this->actor); + if ((path == NULL) || (EN_SYATEKI_CROW_GET_INDEX(&this->actor) >= 0x80)) { + Actor_Kill(&this->actor); return; } - this->unk_1C8 = Lib_SegmentedToVirtual(path->points); - this->unk_1CC = 1; - this->unk_1CE = path->count; - this->unk_1C4 = 0x14; - this->unk_1BC = 0; - func_809CA5D4(this); + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->currentPointIndex = 1; + this->maxPointIndex = path->count; + this->deathTimer = 20; + this->waitTimer = 0; + EnSyatekiCrow_SetupWaitForSpawn(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->collider); } -void func_809CA5D4(EnSyatekiCrow* this) { +void EnSyatekiCrow_SetupWaitForSpawn(EnSyatekiCrow* this) { Actor_SetScale(&this->actor, 0.03f); this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; this->actor.world = this->actor.home; this->actor.prevPos = this->actor.home.pos; this->actor.shape.rot = this->actor.world.rot; - this->unk_1CC = 1; + this->currentPointIndex = 1; this->actor.draw = NULL; - this->actionFunc = func_809CA67C; + this->actionFunc = EnSyatekiCrow_WaitForSpawn; } -void func_809CA67C(EnSyatekiCrow* this, GlobalContext* globalCtx) { +/** + * Waits until the shooting gallery man sets the appropriate Guay flag to spawn. + */ +void EnSyatekiCrow_WaitForSpawn(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)))) { - func_809CA71C(this); - } else if (syatekiMan->unk_26A != 1) { - this->unk_1C2 = 1; + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isActive == true) && + (syatekiMan->guayFlags & (1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)))) { + EnSyatekiCrow_SetupWaitToMove(this); + } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { + this->isActive = true; } - if ((syatekiMan->unk_274 == 0) && (syatekiMan->unk_274 == 0)) { - this->unk_1C2 = 1; + if ((syatekiMan->guayFlags == 0) && (syatekiMan->guayFlags == 0)) { + this->isActive = true; } } -void func_809CA71C(EnSyatekiCrow* this) { - Vec3f sp24; - s16 temp; +void EnSyatekiCrow_SetupWaitToMove(EnSyatekiCrow* this) { + Vec3f targetPos; - this->actor.world.pos.x = this->unk_1C8[0].x; - this->actor.world.pos.y = this->unk_1C8[0].y; - this->actor.world.pos.z = this->unk_1C8[0].z; - sp24.x = this->unk_1C8[this->unk_1CC].x; - sp24.y = this->unk_1C8[this->unk_1CC].y; - sp24.z = this->unk_1C8[this->unk_1CC].z; - temp = Math_Vec3f_Yaw(&this->actor.world.pos, &sp24); - this->actor.world.rot.y = temp; - this->actor.shape.rot.y = temp; - temp = Math_Vec3f_Pitch(&this->actor.world.pos, &sp24); - this->actor.shape.rot.x = temp; - this->actor.world.rot.x = temp; + this->actor.world.pos.x = this->pathPoints[0].x; + this->actor.world.pos.y = this->pathPoints[0].y; + this->actor.world.pos.z = this->pathPoints[0].z; + targetPos.x = this->pathPoints[this->currentPointIndex].x; + targetPos.y = this->pathPoints[this->currentPointIndex].y; + targetPos.z = this->pathPoints[this->currentPointIndex].z; + this->actor.world.rot.y = this->actor.shape.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPos); + this->actor.world.rot.x = this->actor.shape.rot.x = Math_Vec3f_Pitch(&this->actor.world.pos, &targetPos); this->actor.draw = EnSyatekiCrow_Draw; - this->actionFunc = func_809CA840; + this->actionFunc = EnSyatekiCrow_WaitToMove; } -void func_809CA840(EnSyatekiCrow* this, GlobalContext* globalCtx) { - if (((EN_SYATEKI_CROW_GET_PARAM_F(&this->actor) * 20) + 20) < this->unk_1BC) { +/** + * Waits until the wait timer reaches a certain point, then starts flying forward. + * How long the Guay should wait is controlled by its params. + */ +void EnSyatekiCrow_WaitToMove(EnSyatekiCrow* this, PlayState* play) { + if (((EN_SYATEKI_CROW_GET_WAIT_MOD(&this->actor) * 20) + 20) < this->waitTimer) { Actor_PlaySfxAtPos(this->actor.parent, NA_SE_EN_KAICHO_CRY); - this->unk_1BC = 0; - this->actor.speedXZ = EN_SYATEKI_CROW_GET_PARAM_F0(&this->actor) + 6.0f; + this->waitTimer = 0; + this->actor.speedXZ = EN_SYATEKI_CROW_GET_SPEED_MOD(&this->actor) + 6.0f; this->actor.gravity = -0.5f; - this->actionFunc = func_809CA8E4; + this->actionFunc = EnSyatekiCrow_Fly; } else { - this->unk_1BC++; + this->waitTimer++; } } -void func_809CA8E4(EnSyatekiCrow* this, GlobalContext* globalCtx) { - Vec3f sp34; - f32 sp30; +void EnSyatekiCrow_Fly(EnSyatekiCrow* this, PlayState* play) { + Vec3f targetPoint; + f32 distToTarget; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (syatekiMan->unk_26A != 1) { - func_809CA5D4(this); + if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { + EnSyatekiCrow_SetupWaitForSpawn(this); return; } - sp34.x = this->unk_1C8[this->unk_1CC].x; - sp34.y = this->unk_1C8[this->unk_1CC].y; - sp34.z = this->unk_1C8[this->unk_1CC].z; + targetPoint.x = this->pathPoints[this->currentPointIndex].x; + targetPoint.y = this->pathPoints[this->currentPointIndex].y; + targetPoint.z = this->pathPoints[this->currentPointIndex].z; - sp30 = Math_Vec3f_DistXZ(&this->actor.world.pos, &sp34); - this->unk_1C0 = Math_Vec3f_Yaw(&this->actor.world.pos, &sp34); - this->unk_1BE = Math_Vec3f_Pitch(&this->actor.world.pos, &sp34); + distToTarget = Math_Vec3f_DistXZ(&this->actor.world.pos, &targetPoint); + this->yawTarget = Math_Vec3f_Yaw(&this->actor.world.pos, &targetPoint); + this->pitchTarget = Math_Vec3f_Pitch(&this->actor.world.pos, &targetPoint); - if (sp30 > 100.0f) { - Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_1C0, 5, 0x3000, 0x100); + if (distToTarget > 100.0f) { + Math_SmoothStepToS(&this->actor.world.rot.y, this->yawTarget, 5, 0x3000, 0x100); this->actor.shape.rot.y = this->actor.world.rot.y; - Math_SmoothStepToS(&this->actor.shape.rot.x, this->unk_1BE, 5, 0x3000, 0x100); + Math_SmoothStepToS(&this->actor.shape.rot.x, this->pitchTarget, 5, 0x3000, 0x100); this->actor.world.rot.x = -this->actor.shape.rot.x; - } else if (this->unk_1CC < (this->unk_1CE - 1)) { - this->unk_1CC++; + } else if (this->currentPointIndex < (this->maxPointIndex - 1)) { + this->currentPointIndex++; } else { - this->unk_1C2 = 0; - syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); - func_809CA5D4(this); + this->isActive = false; + syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)); + EnSyatekiCrow_SetupWaitForSpawn(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); } } -void func_809CAAF8(EnSyatekiCrow* this) { +void EnSyatekiCrow_SetupDead(EnSyatekiCrow* this) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - syatekiMan->unk_280 += 60; - this->unk_1C2 = 0; + syatekiMan->score += 60; + this->isActive = false; 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; + this->actionFunc = EnSyatekiCrow_Dead; } -void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx) { +void EnSyatekiCrow_Dead(EnSyatekiCrow* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); @@ -243,81 +238,85 @@ void func_809CABC0(EnSyatekiCrow* this, GlobalContext* globalCtx) { this->actor.shape.rot.z += 0x1780; } - if (this->unk_1C4 > 20) { - func_800B3030(globalCtx, &this->actor.world.pos, &D_809CB050, &D_809CB050, this->actor.scale.x * 10000.0f, 0, - 0); - syatekiMan->unk_27A++; - syatekiMan->unk_274 &= ~(1 << EN_SYATEKI_CROW_GET_PARAM_FF00(&this->actor)); - func_809CA5D4(this); + if (this->deathTimer > 20) { + func_800B3030(play, &this->actor.world.pos, &sZeroVec, &sZeroVec, this->actor.scale.x * 10000.0f, 0, 0); + syatekiMan->guayHitCounter++; + syatekiMan->guayFlags &= ~(1 << EN_SYATEKI_CROW_GET_INDEX(&this->actor)); + EnSyatekiCrow_SetupWaitForSpawn(this); } - this->unk_1C4++; + this->deathTimer++; } -void func_809CACD0(EnSyatekiCrow* this, GlobalContext* globalCtx) { - if (this->actionFunc == func_809CA8E4) { - if (this->unk_23C.base.acFlags & AC_HIT) { +static Vec3f sVelocity = { 0.0f, 20.0f, 0.0f }; + +static Vec3f sAccel = { 0.0f, 0.0f, 0.0f }; + +void EnSyatekiCrow_UpdateDamage(EnSyatekiCrow* this, PlayState* play) { + if (this->actionFunc == EnSyatekiCrow_Fly) { + if (this->collider.base.acFlags & AC_HIT) { play_sound(NA_SE_SY_TRE_BOX_APPEAR); - this->unk_1C4 = 0; - this->unk_23C.base.acFlags &= ~AC_HIT; - EffectSsExtra_Spawn(globalCtx, &this->actor.world.pos, &D_809CB0C0, &D_809CB0CC, 5, 1); - func_809CAAF8(this); + this->deathTimer = 0; + this->collider.base.acFlags &= ~AC_HIT; + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 5, 1); + EnSyatekiCrow_SetupDead(this); } else { - this->unk_23C.elements->dim.worldSphere.center.x = this->actor.world.pos.x; - this->unk_23C.elements->dim.worldSphere.center.y = + this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements[0].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); + this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.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) { + if (this->actionFunc != EnSyatekiCrow_Dead) { Actor_MoveWithoutGravity(&this->actor); } else { Actor_MoveWithGravity(&this->actor); } - func_809CACD0(this, globalCtx); + EnSyatekiCrow_UpdateDamage(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) { - rot->y += (s16)(3072.0f * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); + rot->y += (s16)(0xC00 * sin_rad(this->skelAnime.curFrame * (M_PI / 4))); } else if (limbIndex == OBJECT_CROW_LIMB_TAIL) { - rot->y += (s16)(5120.0f * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); + rot->y += (s16)(0x1400 * sin_rad((this->skelAnime.curFrame + 2.5f) * (M_PI / 4))); } return false; } -void EnSyatekiCrow_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +static Vec3f sBodyOffset = { 2500.0f, 0.0f, 0.0f }; + +void EnSyatekiCrow_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnSyatekiCrow* this = THIS; - Vec3f* sp1C; + Vec3f* bodyPartPos; if (limbIndex == OBJECT_CROW_LIMB_BODY) { - Matrix_MultVec3f(&D_809CB0D8, &this->unk_144[0]); - this->unk_144[0].y -= 20.0f; + Matrix_MultVec3f(&sBodyOffset, &this->bodyPartsPos[0]); + this->bodyPartsPos[0].y -= 20.0f; } else if ((limbIndex == OBJECT_CROW_LIMB_RIGHT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_LEFT_WING_TIP) || (limbIndex == OBJECT_CROW_LIMB_TAIL)) { - sp1C = &this->unk_144[(limbIndex >> 1) - 1]; - Matrix_MultVec3f(&D_809CB050, sp1C); - sp1C->y -= 20.0f; + bodyPartPos = &this->bodyPartsPos[(limbIndex >> 1) - 1]; + Matrix_MultVec3f(&sZeroVec, bodyPartPos); + bodyPartPos->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..f244b0b60 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 @@ -2,34 +2,34 @@ #define Z_EN_SYATEKI_CROW_H #include "global.h" +#include "objects/object_crow/object_crow.h" -#define EN_SYATEKI_CROW_GET_PARAM_F(thisx) ((thisx)->params & 0xF) -#define EN_SYATEKI_CROW_GET_PARAM_F0(thisx) (((thisx)->params & 0xF0) >> 4) -#define EN_SYATEKI_CROW_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_CROW_GET_WAIT_MOD(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_CROW_GET_SPEED_MOD(thisx) (((thisx)->params & 0xF0) >> 4) +#define EN_SYATEKI_CROW_GET_INDEX(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_CROW_PARAMS(index, speedMod, waitMod) (((index << 8) & 0xFF00) | ((speedMod << 4) & 0xF0) | (waitMod & 0xF)) struct EnSyatekiCrow; -typedef void (*EnSyatekiCrowActionFunc)(struct EnSyatekiCrow*, GlobalContext*); +typedef void (*EnSyatekiCrowActionFunc)(struct EnSyatekiCrow*, PlayState*); typedef struct EnSyatekiCrow { /* 0x000 */ Actor actor; - /* 0x144 */ Vec3f unk_144[4]; + /* 0x144 */ Vec3f bodyPartsPos[4]; /* 0x174 */ SkelAnime skelAnime; /* 0x1B8 */ EnSyatekiCrowActionFunc actionFunc; - /* 0x1BC */ s16 unk_1BC; - /* 0x1BE */ s16 unk_1BE; - /* 0x1C0 */ s16 unk_1C0; - /* 0x1C2 */ s16 unk_1C2; - /* 0x1C4 */ s16 unk_1C4; - /* 0x1C8 */ Vec3s* unk_1C8; - /* 0x1CC */ s16 unk_1CC; - /* 0x1CE */ s16 unk_1CE; - /* 0x1D0 */ Vec3s jointTable[9]; - /* 0x206 */ Vec3s morphTable[9]; - /* 0x23C */ ColliderJntSph unk_23C; - /* 0x25C */ ColliderJntSphElement unk_25C; + /* 0x1BC */ s16 waitTimer; + /* 0x1BE */ s16 pitchTarget; + /* 0x1C0 */ s16 yawTarget; + /* 0x1C2 */ s16 isActive; + /* 0x1C4 */ s16 deathTimer; + /* 0x1C8 */ Vec3s* pathPoints; + /* 0x1CC */ s16 currentPointIndex; + /* 0x1CE */ s16 maxPointIndex; + /* 0x1D0 */ Vec3s jointTable[OBJECT_CROW_LIMB_MAX]; + /* 0x206 */ Vec3s morphTable[OBJECT_CROW_LIMB_MAX]; + /* 0x23C */ ColliderJntSph collider; + /* 0x25C */ ColliderJntSphElement colliderElements[1]; } EnSyatekiCrow; // size = 0x29C -extern const ActorInit En_Syateki_Crow_InitVars; - #endif // Z_EN_SYATEKI_CROW_H diff --git a/src/overlays/actors/ovl_En_Syateki_Dekunuts/overlay.cfg b/src/overlays/actors/ovl_En_Syateki_Dekunuts/overlay.cfg deleted file mode 100644 index 1165e9df0..000000000 --- a/src/overlays/actors/ovl_En_Syateki_Dekunuts/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Syateki_Dekunuts -z_en_syateki_dekunuts.c 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 bd5dece41..601095cfd 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 @@ -12,29 +12,34 @@ #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* play2); +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_80A2BFC4(EnSyatekiDekunuts* this); -void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C150(EnSyatekiDekunuts* this); -void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C1AC(EnSyatekiDekunuts* this); -void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C27C(EnSyatekiDekunuts* this); -void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C3AC(EnSyatekiDekunuts* this); -void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C478(EnSyatekiDekunuts* this); -void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx); -void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx); +void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_WaitForSpawn(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Spawn(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupWaitToEmerge(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_WaitToEmerge(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupEmerge(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Emerge(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupLookAround(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_LookAround(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_BonusLookAround(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupBurrow(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_Burrow(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_SetupGameEnd(EnSyatekiDekunuts* this); +void EnSyatekiDekunuts_GameEnd(EnSyatekiDekunuts* this, PlayState* play); +void EnSyatekiDekunuts_Dead(EnSyatekiDekunuts* this, PlayState* play); -const ActorInit En_Syateki_Dekunuts_InitVars = { +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_NORMAL, + /* 1 */ EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP, +} EnSyatekiDekunutsHeaddressType; + +ActorInit En_Syateki_Dekunuts_InitVars = { ACTOR_EN_SYATEKI_DEKUNUTS, ACTORCAT_ENEMY, FLAGS, @@ -66,9 +71,19 @@ static ColliderCylinderInit sCylinderInit = { { 48, 80, 0, { 0, 0, 0 } }, }; -static Cylinder16 D_80A2CADC[] = { { 24, 40, 0, { 0, 0, 0 } } }; +static Cylinder16 sBonusDekuScrubColliderDimensions[] = { { 24, 40, 0, { 0, 0, 0 } } }; -static AnimationInfo sAnimations[] = { +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_ANIM_UP, + /* 1 */ EN_SYATEKI_DEKUNUTS_ANIM_BURROW, + /* 2 */ EN_SYATEKI_DEKUNUTS_ANIM_IDLE, // unused + /* 3 */ EN_SYATEKI_DEKUNUTS_ANIM_LOOK_AROUND, + /* 4 */ EN_SYATEKI_DEKUNUTS_ANIM_DAMAGE, + /* 5 */ EN_SYATEKI_DEKUNUTS_ANIM_DIE, + /* 6 */ EN_SYATEKI_DEKUNUTS_ANIM_UNBURROW, // unused +} EnSyatekiDekunutsAnimation; + +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 }, @@ -79,73 +94,74 @@ static AnimationInfo sAnimations[] = { }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 77, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_MAD_SCRUB, ICHAIN_CONTINUE), ICHAIN_F32(gravity, 0, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2600, ICHAIN_STOP), }; -void EnSyatekiDekunuts_Init(Actor* thisx, GlobalContext* globalCtx2) { - static s32 D_80A2CB9C = 1; +void EnSyatekiDekunuts_Init(Actor* thisx, PlayState* play2) { + static s32 sDrawFlowers = true; // This makes it so only one EnSyatekiDekunuts draws all the flowers. EnSyatekiDekunuts* this = THIS; - GlobalContext* globalCtx = globalCtx2; - s32 phi_v0; + PlayState* play = play2; + s32 unkPathComparison; 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) { + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { Actor_SetScale(&this->actor, 0.01f); - this->collider.dim = D_80A2CADC[0]; - phi_v0 = 3; + this->collider.dim = sBonusDekuScrubColliderDimensions[0]; + unkPathComparison = 3; } else { Actor_SetScale(&this->actor, 0.02f); - phi_v0 = 1; + unkPathComparison = 1; } - while (path->unk2 != phi_v0) { - path = &globalCtx->setupPathList[path->unk1]; + while (path->unk2 != unkPathComparison) { + 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) { - this->unk_1EC = 1; - D_80A2CB9C = 0; + if (sDrawFlowers == true) { + this->shouldDrawFlowers = true; + sDrawFlowers = false; } else { - this->unk_1EC = 0; + this->shouldDrawFlowers = false; } Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); - SkelAnime_Init(globalCtx, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, - this->morphTable, DEKU_SCRUB_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &gDekuScrubSkel, &gDekuScrubBurrowAnim, this->jointTable, this->morphTable, + DEKU_SCRUB_LIMB_MAX); + if (path == NULL) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - this->unk_1E4 = Lib_SegmentedToVirtual(path->points); - this->unk_1E8 = EN_SYATEKI_DEKUNUTS_GET_PARAM_F0(&this->actor); - this->unk_1EA = path->count; - this->unk_1D8 = 0; + this->flowerPos = Lib_SegmentedToVirtual(path->points); + this->index = EN_SYATEKI_DEKUNUTS_GET_INDEX(&this->actor); + this->flowerCount = path->count; + this->timer = 0; this->unk_1DC = 0; - this->unk_1DA = 0; - func_80A2BE54(this); + this->waitTimer = 0; + EnSyatekiDekunuts_SetupWaitForSpawn(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) { +void EnSyatekiDekunuts_SetupWaitForSpawn(EnSyatekiDekunuts* this) { Animation_PlayOnceSetSpeed(&this->skelAnime, &gDekuScrubUpAnim, 0.0f); this->actor.speedXZ = 0.0f; @@ -153,239 +169,276 @@ void func_80A2BE54(EnSyatekiDekunuts* this) { this->actor.prevPos = this->actor.home.pos; this->actor.shape.rot = this->actor.world.rot; - this->unk_1D8 = 0; + this->timer = 0; this->unk_1DC = 0; - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { - this->unk_1E2 = 1; + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + this->isAlive = true; } - this->actionFunc = func_80A2BF18; + this->actionFunc = EnSyatekiDekunuts_WaitForSpawn; } -void func_80A2BF18(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +/** + * Waits until the shooting gallery man sets the appropriate Deku Scrub flag to spawn. + */ +void EnSyatekiDekunuts_WaitForSpawn(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)) { - func_80A2BFC4(this); - } else if (syatekiMan->unk_26A != 1) { - this->unk_1E2 = 1; + if ((syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) && (this->isAlive == true) && + (syatekiMan->dekuScrubFlags & (1 << this->index))) { + EnSyatekiDekunuts_SetupSpawn(this); + } else if (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING) { + this->isAlive = true; } - if ((syatekiMan->unk_272 == 0) && (syatekiMan->unk_274 == 0) && - (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1)) { - this->unk_1E2 = 1; + if (!syatekiMan->dekuScrubFlags && !syatekiMan->guayFlags && + (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS)) { + this->isAlive = true; } } -void func_80A2BFC4(EnSyatekiDekunuts* this) { - Vec3f sp14; +/** + * Positions the Deku Scrub to match up with its flower, then sets it up to start waiting. + */ +void EnSyatekiDekunuts_SetupSpawn(EnSyatekiDekunuts* this) { + Vec3f pos; EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - this->unk_1D8 = 0; - sp14.x = this->unk_1E4[this->unk_1E8].x; - sp14.y = this->unk_1E4[this->unk_1E8].y; - sp14.z = this->unk_1E4[this->unk_1E8].z; - this->actor.world.pos = this->actor.prevPos = sp14; + this->timer = 0; + pos.x = this->flowerPos[this->index].x; + pos.y = this->flowerPos[this->index].y; + pos.z = this->flowerPos[this->index].z; + this->actor.world.pos = this->actor.prevPos = pos; 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->timeToBurrow = 140 - (syatekiMan->currentWave * 20); - if ((syatekiMan->unk_27C & 1) != 0) { - this->unk_1F0 = 1; - this->unk_1F2 = 0; + if ((syatekiMan->currentWave % 2) != 0) { + this->headdressType = EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP; + this->headdressRotZ = 0; } else { - this->unk_1F0 = 0; + this->headdressType = EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_NORMAL; } - this->actionFunc = func_80A2C0F8; + this->actionFunc = EnSyatekiDekunuts_Spawn; } -void func_80A2C0F8(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +/** + * Waits 20 frames, then plays a sound and starts the process of making the Deku Scrubs emerge. + */ +void EnSyatekiDekunuts_Spawn(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan; - if (this->unk_1DA > 20) { + if (this->waitTimer > 20) { syatekiMan = (EnSyatekiMan*)this->actor.parent; Actor_PlaySfxAtPos(&syatekiMan->actor, NA_SE_EN_NUTS_DAMAGE); - this->unk_1DA = 0; - func_80A2C150(this); + this->waitTimer = 0; + EnSyatekiDekunuts_SetupWaitToEmerge(this); } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C150(EnSyatekiDekunuts* this) { - this->unk_1D8 = 0; - this->actionFunc = func_80A2C168; +void EnSyatekiDekunuts_SetupWaitToEmerge(EnSyatekiDekunuts* this) { + this->timer = 0; + this->actionFunc = EnSyatekiDekunuts_WaitToEmerge; } -void func_80A2C168(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { - if (this->unk_1DA > 20) { - func_80A2C1AC(this); - this->unk_1DA = 0; +/** + * Waits 20 frames, then makes the Deku Scrubs emerge from underground. + */ +void EnSyatekiDekunuts_WaitToEmerge(EnSyatekiDekunuts* this, PlayState* play) { + if (this->waitTimer > 20) { + EnSyatekiDekunuts_SetupEmerge(this); + this->waitTimer = 0; } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C1AC(EnSyatekiDekunuts* this) { +void EnSyatekiDekunuts_SetupEmerge(EnSyatekiDekunuts* this) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_UP); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_UP); this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - this->actionFunc = func_80A2C208; + this->actionFunc = EnSyatekiDekunuts_Emerge; } -void func_80A2C208(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +/** + * Waits until the animation for coming out of the ground is done playing, then makes the + * Deku Scrubs look around. If the headdress should be flipped up, then this will also + * adjust the headdress's rotation. + */ +void EnSyatekiDekunuts_Emerge(EnSyatekiDekunuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80A2C27C(this); + EnSyatekiDekunuts_SetupLookAround(this); } - if (this->unk_1F0 == 1) { - Math_SmoothStepToS(&this->unk_1F2, -0x8000, 5, 0x1000, 0x100); + if (this->headdressType == EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP) { + Math_SmoothStepToS(&this->headdressRotZ, -0x8000, 5, 0x1000, 0x100); } - this->unk_1D8++; + this->timer++; } -void func_80A2C27C(EnSyatekiDekunuts* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) != 1) { - this->actionFunc = func_80A2C2E0; +void EnSyatekiDekunuts_SetupLookAround(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_LOOK_AROUND); + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + this->actionFunc = EnSyatekiDekunuts_LookAround; } else { - this->actionFunc = func_80A2C33C; + this->actionFunc = EnSyatekiDekunuts_BonusLookAround; } } -void func_80A2C2E0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +/** + * Looks around back and forth until the timer reaches the time to burrow or until the game ends. + * No matter which occurs, the Deku Scrubs burrow underground afterwards. + */ +void EnSyatekiDekunuts_LookAround(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((this->unk_1EE < this->unk_1D8) || (syatekiMan->unk_26A != 1)) { - func_80A2C3AC(this); + if ((this->timeToBurrow < this->timer) || (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { + EnSyatekiDekunuts_SetupBurrow(this); } - this->unk_1D8++; + this->timer++; } -void func_80A2C33C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +/** + * Looks around back and forth until the game ends, then burrow underground afterwards. + */ +void EnSyatekiDekunuts_BonusLookAround(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if ((gSaveContext.unk_3DE0[1] <= 0) || (syatekiMan->unk_26A != 1)) { - func_80A2C3AC(this); + // There are some cases where the minigame timer can reach 0, but the shooting game state is + // still SG_GAME_STATE_RUNNING. This check just makes absolutely sure that once the game is + // over, these Deku Scrubs will burrow. + if ((gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] <= SECONDS_TO_TIMER(0)) || + (syatekiMan->shootingGameState != SG_GAME_STATE_RUNNING)) { + EnSyatekiDekunuts_SetupBurrow(this); } - if (this->unk_1D8 < 11) { - this->unk_1D8++; + if (this->timer <= 10) { + this->timer++; } } -void func_80A2C3AC(EnSyatekiDekunuts* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); - this->actionFunc = func_80A2C3F0; +void EnSyatekiDekunuts_SetupBurrow(EnSyatekiDekunuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_BURROW); + this->actionFunc = EnSyatekiDekunuts_Burrow; } -void func_80A2C3F0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { +/** + * Burrow underground. After 160 frames have passed since the Deku Scrub first emerged *and* + * after the burrowing animation is complete, this sets up the Deku Scrub to emerge again. + */ +void EnSyatekiDekunuts_Burrow(EnSyatekiDekunuts* this, PlayState* play) { EnSyatekiMan* syatekiMan = (EnSyatekiMan*)this->actor.parent; - if (syatekiMan->unk_26A == 1) { - if (this->unk_1D8 > 160 && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - this->unk_1D8 = 0; - func_80A2C150(this); + if (syatekiMan->shootingGameState == SG_GAME_STATE_RUNNING) { + if ((this->timer > 160) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->timer = 0; + EnSyatekiDekunuts_SetupWaitToEmerge(this); } else { - this->unk_1D8++; + this->timer++; } } else { - func_80A2C478(this); + EnSyatekiDekunuts_SetupGameEnd(this); } } -void func_80A2C478(EnSyatekiDekunuts* this) { - this->actionFunc = func_80A2C48C; +void EnSyatekiDekunuts_SetupGameEnd(EnSyatekiDekunuts* this) { + this->actionFunc = EnSyatekiDekunuts_GameEnd; } -void func_80A2C48C(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { - if (this->unk_1DA > 20) { - func_80A2BE54(this); - this->unk_1DA = 0; +/** + * Waits 20 frames, then resets the Deku Scrub back to its initial state. + */ +void EnSyatekiDekunuts_GameEnd(EnSyatekiDekunuts* this, PlayState* play) { + if (this->waitTimer > 20) { + EnSyatekiDekunuts_SetupWaitForSpawn(this); + this->waitTimer = 0; } else { - this->unk_1DA++; + this->waitTimer++; } } -void func_80A2C4D0(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { - static Vec3f D_80A2CBA0 = { 0.0f, 20.0f, 0.0f }; - static Vec3f D_80A2CBAC = { 0.0f, 0.0f, 0.0f }; +void EnSyatekiDekunuts_SetupDead(EnSyatekiDekunuts* this, PlayState* play) { + static Vec3f sVelocity = { 0.0f, 20.0f, 0.0f }; + static Vec3f sAccel = { 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++; + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + EffectSsExtra_Spawn(play, &this->actor.world.pos, &sVelocity, &sAccel, 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, &sVelocity, &sAccel, 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); - this->unk_1D8 = 160; - this->actionFunc = func_80A2C5DC; + this->isAlive = false; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_DAMAGE); + this->timer = 160; + this->actionFunc = EnSyatekiDekunuts_Dead; } -void func_80A2C5DC(EnSyatekiDekunuts* this, GlobalContext* globalCtx) { - static Color_RGBA8 D_80A2CBB8 = { 255, 255, 255, 255 }; - static Color_RGBA8 D_80A2CBBC = { 150, 150, 150, 0 }; +void EnSyatekiDekunuts_Dead(EnSyatekiDekunuts* this, PlayState* play) { + static Color_RGBA8 sPrimColor = { 255, 255, 255, 255 }; + static Color_RGBA8 sEnvColor = { 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); + if (this->timer == 160) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_SYATEKI_DEKUNUTS_ANIM_DIE); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_NUTS_DEAD); - this->unk_1D8--; - } else if (this->unk_1D8 < 160) { - Vec3f sp40; + this->timer--; + } else if (this->timer < 160) { + Vec3f pos; - sp40.x = this->actor.world.pos.x; - sp40.y = this->actor.world.pos.y + 18.0f; - sp40.z = this->actor.world.pos.z; - EffectSsDeadDb_Spawn(globalCtx, &sp40, &gZeroVec3f, &gZeroVec3f, &D_80A2CBB8, &D_80A2CBBC, 200, 0, 13); - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); - sp40.y = this->actor.world.pos.y + 10.0f; - EffectSsHahen_SpawnBurst(globalCtx, &sp40, 3.0f, 0, 12, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 18.0f; + pos.z = this->actor.world.pos.z; + EffectSsDeadDb_Spawn(play, &pos, &gZeroVec3f, &gZeroVec3f, &sPrimColor, &sEnvColor, 200, 0, 13); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 30, NA_SE_EN_EXTINCT); + pos.y = this->actor.world.pos.y + 10.0f; + EffectSsHahen_SpawnBurst(play, &pos, 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); + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) != EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + syatekiMan->dekuScrubFlags &= ~(1 << this->index); } - func_80A2BE54(this); + EnSyatekiDekunuts_SetupWaitForSpawn(this); } - } else if (this->unk_1D8 < 160) { - this->unk_1D8--; + } else if (this->timer < 160) { + this->timer--; } } -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)) { - if (EN_SYATEKI_DEKUNUTS_GET_PARAM_F(&this->actor) == 1) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); + if ((this->actionFunc != EnSyatekiDekunuts_WaitForSpawn) && (this->timer < this->timeToBurrow) && + (this->timer > 10)) { + if ((this->collider.base.acFlags & AC_HIT) && (this->isAlive == true)) { + if (EN_SYATEKI_DEKUNUTS_GET_TYPE(&this->actor) == EN_SYATEKI_DEKUNUTS_TYPE_BONUS) { + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); } else { play_sound(NA_SE_SY_TRE_BOX_APPEAR); } this->collider.base.acFlags &= ~AC_HIT; - func_80A2C4D0(this, globalCtx); + EnSyatekiDekunuts_SetupDead(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; } @@ -393,43 +446,43 @@ 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 == DEKU_SCRUB_LIMB_HEADDRESS) && (this->unk_1F0 == 1)) { - rot->z += this->unk_1F2; + if ((limbIndex == DEKU_SCRUB_LIMB_HEADDRESS) && + (this->headdressType == EN_SYATEKI_DEKUNUTS_HEADDRESS_TYPE_FLIPPED_UP)) { + rot->z += this->headdressRotZ; } return false; } -void EnSyatekiDekunuts_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiDekunuts_Draw(Actor* thisx, PlayState* play) { EnSyatekiDekunuts* this = THIS; - Vec3f temp_f20; + Vec3f flowerPos; s32 i; - if (this->actionFunc != func_80A2BF18) { - SkelAnime_DrawOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + if (this->actionFunc != EnSyatekiDekunuts_WaitForSpawn) { + SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSyatekiDekunuts_OverrideLimbDraw, NULL, &this->actor); } - if (this->unk_1EC == 1) { - for (i = 0; i < this->unk_1EA; i++) { - temp_f20.x = this->unk_1E4[i].x; - temp_f20.y = this->unk_1E4[i].y; - temp_f20.z = this->unk_1E4[i].z; + if (this->shouldDrawFlowers == true) { + for (i = 0; i < this->flowerCount; i++) { + flowerPos.x = this->flowerPos[i].x; + flowerPos.y = this->flowerPos[i].y; + flowerPos.z = this->flowerPos[i].z; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - Matrix_Translate(temp_f20.x, temp_f20.y, temp_f20.z, MTXMODE_NEW); + func_8012C28C(play->state.gfxCtx); + Matrix_Translate(flowerPos.x, flowerPos.y, flowerPos.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); + 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 50361894b..2ceb0b32d 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 @@ -4,36 +4,40 @@ #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_TYPE(thisx) ((thisx)->params & 0xF) +#define EN_SYATEKI_DEKUNUTS_GET_INDEX(thisx) (((thisx)->params & 0xF0) >> 4) #define EN_SYATEKI_DEKUNUTS_GET_PARAM_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_DEKUNUTS_PARAMS(unkFF00, index, type) (((unkFF00 << 8) & 0xFF00) | ((index << 4) & 0xF0) | (type & 0xF)) + +typedef enum { + /* 0 */ EN_SYATEKI_DEKUNUTS_TYPE_NORMAL, // Worth 30 points + /* 1 */ EN_SYATEKI_DEKUNUTS_TYPE_BONUS, // Worth 100 points +} EnSyatekiDekunutsType; struct EnSyatekiDekunuts; -typedef void (*EnSyatekiDekunutsActionFunc)(struct EnSyatekiDekunuts*, GlobalContext*); +typedef void (*EnSyatekiDekunutsActionFunc)(struct EnSyatekiDekunuts*, PlayState*); typedef struct EnSyatekiDekunuts { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnSyatekiDekunutsActionFunc actionFunc; /* 0x18C */ ColliderCylinder collider; - /* 0x1D8 */ s16 unk_1D8; - /* 0x1DA */ s16 unk_1DA; - /* 0x1CD */ s16 unk_1DC; + /* 0x1D8 */ s16 timer; + /* 0x1DA */ s16 waitTimer; + /* 0x1CD */ s16 unk_1DC; // Initialized, but never used /* 0x1DE */ UNK_TYPE1 unk_1DE[0x4]; - /* 0x1E2 */ s16 unk_1E2; - /* 0x1E4 */ Vec3s* unk_1E4; - /* 0x1E8 */ s16 unk_1E8; - /* 0x1EA */ s16 unk_1EA; - /* 0x1EC */ s16 unk_1EC; - /* 0x1EE */ s16 unk_1EE; - /* 0x1F0 */ s16 unk_1F0; - /* 0x1F2 */ s16 unk_1F2; + /* 0x1E2 */ s16 isAlive; + /* 0x1E4 */ Vec3s* flowerPos; + /* 0x1E8 */ s16 index; + /* 0x1EA */ s16 flowerCount; + /* 0x1EC */ s16 shouldDrawFlowers; + /* 0x1EE */ s16 timeToBurrow; + /* 0x1F0 */ s16 headdressType; + /* 0x1F2 */ s16 headdressRotZ; /* 0x1F4 */ Vec3s jointTable[DEKU_SCRUB_LIMB_MAX]; /* 0x230 */ Vec3s morphTable[DEKU_SCRUB_LIMB_MAX]; /* 0x26C */ UNK_TYPE1 unk_26C[0x4]; } EnSyatekiDekunuts; // size = 0x270 -extern const ActorInit En_Syateki_Dekunuts_InitVars; - #endif // Z_EN_SYATEKI_DEKUNUTS_H diff --git a/src/overlays/actors/ovl_En_Syateki_Man/overlay.cfg b/src/overlays/actors/ovl_En_Syateki_Man/overlay.cfg deleted file mode 100644 index 492b143b5..000000000 --- a/src/overlays/actors/ovl_En_Syateki_Man/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Syateki_Man -z_en_syateki_man.c 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 6ea613a6b..759e97206 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,39 +2,64 @@ * 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 "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); -const ActorInit En_Syateki_Man_InitVars = { +#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 + +ActorInit En_Syateki_Man_InitVars = { ACTOR_EN_SYATEKI_MAN, ACTORCAT_NPC, FLAGS, @@ -46,201 +71,244 @@ const ActorInit En_Syateki_Man_InitVars = { (ActorFunc)EnSyatekiMan_Draw, }; -static AnimationInfo sAnimations[] = { +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, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 2, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 3, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 4, EN_SYATEKI_DEKUNUTS_TYPE_NORMAL) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 0, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, + { 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, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, + { ACTOR_EN_SYATEKI_DEKUNUTS, -1000.0f, 200.0f, -700.0f, + EN_SYATEKI_DEKUNUTS_PARAMS(0, 1, EN_SYATEKI_DEKUNUTS_TYPE_BONUS) }, + { 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 sTownFierceDeityPlayerPos = { -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, &gBurlyGuySkel, &gSwampShootingGalleryManHeadScratchLoopAnim, + if (play->sceneId == SCENE_SYATEKI_MORI) { + SkelAnime_InitFlex(play, &this->skelAnime, &gBurlyGuySkel, &gSwampShootingGalleryManHeadScratchLoopAnim, this->jointTable, this->morphTable, BURLY_GUY_LIMB_MAX); } else { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gBurlyGuySkel, &gBurlyGuyHandsOnTableAnim, this->jointTable, + 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->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->sceneId == SCENE_SYATEKI_MORI) { + this->path = path; + EnSyatekiMan_Swamp_SpawnTargetActors(this, play, sSwampTargetActorLists[this->swampTargetActorListIndex], + actorListLength); } } -void EnSyatekiMan_Destroy(Actor* thisx, GlobalContext* globalCtx) { - gSaveContext.save.weekEventReg[63] &= (u8)~1; +void EnSyatekiMan_Destroy(Actor* thisx, PlayState* play) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); } -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->sceneId == SCENE_SYATEKI_MORI) { + this->actionFunc = EnSyatekiMan_Swamp_Idle; + } else if (play->sceneId == 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) { @@ -248,518 +316,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) { - gSaveContext.minigameState = 3; + + // 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.minigameStatus = MINIGAME_STATUS_END; } - this->unk_26A = 3; + + this->shootingGameState = SG_GAME_STATE_NOT_PLAYING; } else { func_8019F208(); - func_801159EC(-20); - gSaveContext.save.weekEventReg[63] |= 1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - globalCtx->msgCtx.msgMode = 0x43; - globalCtx->msgCtx.unk12023 = 4; - this->unk_26A = 7; - player->stateFlags1 |= 0x20; - this->actionFunc = func_809C7FFC; + Rupees_ChangeBy(-20); + SET_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + this->shootingGameState = SG_GAME_STATE_MOVING_PLAYER; + player->stateFlags1 |= PLAYER_STATE1_20; + 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) { - gSaveContext.minigameState = 3; + if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } - 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_801A2BB8(NA_BGM_MINI_GAME_2); + Interface_InitMinigame(play); + play->interfaceCtx.minigameAmmo = 80; + func_80123F2C(play, 80); + this->shootingGameState = SG_GAME_STATE_RUNNING; + this->actionFunc = EnSyatekiMan_Swamp_StartGame; + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); break; - case 0xA32: - if (gSaveContext.save.weekEventReg[63] & 2) { - func_801477B4(globalCtx); - player->stateFlags1 &= ~0x20; - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->actionFunc = func_809C6848; - gSaveContext.minigameState = 3; - this->unk_26A = 0; + case 0xA32: // You have to try harder! + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + func_801477B4(play); + player->stateFlags1 &= ~PLAYER_STATE1_20; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + this->actionFunc = EnSyatekiMan_Swamp_Idle; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; + 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); + gSaveContext.minigameStatus = MINIGAME_STATUS_END; + player->stateFlags1 |= PLAYER_STATE1_20; + 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; + if (player->stateFlags1 & PLAYER_STATE1_20) { + player->stateFlags1 |= PLAYER_STATE1_20; } - 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; - player->stateFlags1 &= ~0x20; - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->actionFunc = func_809C6848; - this->unk_26A = 0; + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + player->stateFlags1 &= ~PLAYER_STATE1_20; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + 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 == &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) { - player->stateFlags3 &= ~0x400; - gSaveContext.minigameState = 3; + if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { + player->stateFlags3 &= ~PLAYER_STATE3_400; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } - 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; + + SET_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); } } 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) { - player->stateFlags3 &= ~0x400; - gSaveContext.minigameState = 3; + if (this->shootingGameState == SG_GAME_STATE_ONE_MORE_GAME) { + player->stateFlags3 &= ~PLAYER_STATE3_400; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; } - 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; - player->stateFlags1 |= 0x20; - gSaveContext.save.weekEventReg[63] |= 1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->actionFunc = func_809C8710; + this->shootingGameState = SG_GAME_STATE_MOVING_PLAYER; + player->stateFlags1 |= PLAYER_STATE1_20; + SET_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + 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; - func_801A2BB8(NA_BGM_MINI_GAME_2); - this->actionFunc = func_809C8808; + this->flagsIndex = 0; + Interface_InitMinigame(play); + func_80123F2C(play, 0x63); + this->shootingGameState = SG_GAME_STATE_RUNNING; + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); + this->actionFunc = EnSyatekiMan_Town_StartGame; break; - case 0x401: - if (gSaveContext.save.weekEventReg[63] & 2) { - func_801477B4(globalCtx); - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->unk_26A = 0; - this->actionFunc = func_809C72D8; + case 0x401: // You got [score]? Oh, that's too bad... + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + func_801477B4(play); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + 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: - if (gSaveContext.save.weekEventReg[63] & 2) { - func_801477B4(globalCtx); - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->unk_26A = 0; - this->actionFunc = func_809C72D8; + case 0x403: // You got [score]? Too bad... + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + func_801477B4(play); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + 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); + gSaveContext.minigameStatus = MINIGAME_STATUS_END; + 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; + if (player->stateFlags1 & PLAYER_STATE1_20) { + player->stateFlags1 |= PLAYER_STATE1_20; } - 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)) { - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - player->stateFlags1 &= ~0x20; - this->actionFunc = func_809C72D8; - this->unk_26A = 0; + case TEXT_STATE_DONE: + if (Message_ShouldAdvance(play)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + player->stateFlags1 &= ~PLAYER_STATE1_20; + 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 (!(gSaveContext.save.weekEventReg[59] & 0x10)) { - gSaveContext.save.weekEventReg[59] |= 0x10; - } else if (!(gSaveContext.save.weekEventReg[32] & 2) && (this->unk_280 >= 0x884)) { - gSaveContext.save.weekEventReg[32] |= 2; + if (Actor_HasParent(&this->actor, play)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_59_10)) { + SET_WEEKEVENTREG(WEEKEVENTREG_59_10); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_32_02) && (this->score >= 2180)) { + SET_WEEKEVENTREG(WEEKEVENTREG_32_02); } + 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); - } else if (!(gSaveContext.save.weekEventReg[32] & 2)) { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_PIECE, 500.0f, 100.0f); + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_10)) { + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_32_02)) { + 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; @@ -769,55 +888,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; + + player->stateFlags1 &= ~PLAYER_STATE1_20; 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_IA_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 (!(gSaveContext.save.weekEventReg[59] & 0x20)) { - gSaveContext.save.weekEventReg[59] |= 0x20; + if (Actor_HasParent(&this->actor, play)) { + if (this->prevTextId == 0x407) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_59_20)) { + SET_WEEKEVENTREG(WEEKEVENTREG_59_20); } } - if ((this->unk_284 == 0x405) || (this->unk_284 == 0x406)) { - if (!(gSaveContext.save.weekEventReg[32] & 4)) { - gSaveContext.save.weekEventReg[32] |= 4; + if ((this->prevTextId == 0x405) || (this->prevTextId == 0x406)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_32_04)) { + SET_WEEKEVENTREG(WEEKEVENTREG_32_04); } } + this->actor.parent = NULL; - this->actionFunc = func_809C7EB4; + this->actionFunc = EnSyatekiMan_Town_GiveReward; } else { - if (this->unk_284 == 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); + if (this->prevTextId == 0x407) { + if ((CUR_UPG_VALUE(UPG_QUIVER) < 3) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_20)) { + 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); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_32_04)) { + 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; @@ -827,371 +950,472 @@ 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)) { - player->stateFlags1 &= ~0x20; - this->unk_280 = 0; - this->unk_26A = 0; - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->actionFunc = func_809C6810; + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + this->score = 0; + this->shootingGameState = SG_GAME_STATE_NONE; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + this->actionFunc = EnSyatekiMan_SetupIdle; } - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { - Message_StartTextbox(globalCtx, 0x408, &this->actor); - this->unk_284 = 0x408; - player->stateFlags1 &= ~0x20; + } 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 &= ~PLAYER_STATE1_20; 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_IA_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)) { - 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; + if (EnSyatekiMan_MovePlayerToPos(play, sSwampPlayerPos)) { + player->stateFlags1 |= PLAYER_STATE1_20; + 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); + sGameStartTimer--; } else { - D_809C9498 = 30; - this->unk_27E = 0; - this->unk_280 = 0; - player->stateFlags1 &= ~0x20; + sGameStartTimer = 30; + this->flagsIndex = 0; + this->score = 0; + player->stateFlags1 &= ~PLAYER_STATE1_20; 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; - func_8010E9F0(1, 100); + 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; + Interface_StartTimer(TIMER_ID_MINIGAME_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++; - if (gSaveContext.unk_3DE0[1] == 0) { - gSaveContext.unk_3DE0[1] = 0; - gSaveContext.unk_3DD0[1] = 5; + this->perGameVar1.guaySpawnTimer++; + + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; this->actor.draw = EnSyatekiMan_Draw; - this->unk_27E = 0; - this->unk_27C = 0; - player->stateFlags1 |= 0x20; - D_809C949C = 0; + this->flagsIndex = 0; + this->currentWave = 0; + player->stateFlags1 |= PLAYER_STATE1_20; + 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; - player->stateFlags1 |= 0x20; - D_809C949C = 0; + this->flagsIndex = 0; + this->currentWave = 0; + player->stateFlags1 |= PLAYER_STATE1_20; + sHasSpawnedGuaysForThisWave = false; func_801A2C20(); - this->unk_26A = 5; - if (this->unk_280 == 0x848) { - func_8011B4E0(globalCtx, 2); - gSaveContext.unk_3DD0[1] = 6; - this->actionFunc = func_809C8610; + this->shootingGameState = SG_GAME_STATE_GIVING_BONUS; + if (this->score == 2120) { + Interface_SetPerfectLetters(play, PERFECT_LETTERS_TYPE_2); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_6; + this->actionFunc = EnSyatekiMan_Swamp_AddBonusPoints; } else { - gSaveContext.unk_3DD0[1] = 5; - this->actionFunc = func_809C8488; + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; + 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) { - if (gSaveContext.save.weekEventReg[63] & 2) { - gSaveContext.save.weekEventReg[63] &= (u8)~1; - gSaveContext.save.weekEventReg[63] &= (u8)~2; - this->unk_26A = 0; - gSaveContext.minigameState = 3; - this->actionFunc = func_809C6848; + + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_63_02); + this->shootingGameState = SG_GAME_STATE_NONE; + gSaveContext.minigameStatus = MINIGAME_STATUS_END; + 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 (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) { - gSaveContext.unk_3E88[1] += 100; - globalCtx->interfaceCtx.unk_25C += 10; - this->unk_280 += 10; + player->stateFlags1 |= PLAYER_STATE1_20; + if (!play->interfaceCtx.perfectLettersOn) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; + this->flagsIndex = 0; + this->currentWave = 0; + this->actionFunc = EnSyatekiMan_Swamp_EndGame; + sBonusTimer = 0; + } else if (sBonusTimer > 10) { + gSaveContext.timerStopTimes[TIMER_ID_MINIGAME_1] += SECONDS_TO_TIMER(1); + play->interfaceCtx.minigamePoints += 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 = sTownFierceDeityPlayerPos; } 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 = sTownFierceDeityPlayerPos; } 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); - player->stateFlags1 |= 0x20; - D_809C94A4--; - } else if (D_809C94A4 > 0) { + play->unk_18790(play, -0x8000); + player->stateFlags1 |= PLAYER_STATE1_20; + 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) { - player->stateFlags1 &= ~0x20; - this->unk_280 = 0; - this->unk_27E = 0; - this->unk_26C = 70; - this->unk_26E = 0; - D_809C94A4 = 30; - func_8010E9F0(1, 75); + sGameStartTimer--; + } else if (sGameStartTimer == 0) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + this->score = 0; + this->flagsIndex = 0; + this->perGameVar1.octorokState = SG_OCTO_STATE_INITIAL; + this->perGameVar2.octorokHitType = SG_OCTO_HIT_TYPE_NONE; + sGameStartTimer = 30; + Interface_StartTimer(TIMER_ID_MINIGAME_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 = (((void)0, gSaveContext.unk_3DE0[1]) * 0.1f) + 1.0f; +/** + * 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), - if (sp30 < 0x2EF) { - s32 temp; + 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 (D_809C94A8 == 0) { - temp = ((void)0, gSaveContext.unk_3DE0[1]) % 500; + 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), + + 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.timerCurTimes[TIMER_ID_MINIGAME_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.timerCurTimes[TIMER_ID_MINIGAME_1]) % SECONDS_TO_TIMER(5); } else { - temp = (((void)0, gSaveContext.unk_3DE0[1]) + 250) % 500; + waveTimer = (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1]) + SECONDS_TO_TIMER_PRECISE(2, 50)) % + SECONDS_TO_TIMER(5); } - if (temp < 100) { - this->unk_26C = 80; + // Octoroks begin hiding four seconds after a wave begins. + if (waveTimer < 100) { + this->perGameVar1.octorokState = SG_OCTO_STATE_HIDING; } - if (this->unk_26E != 0) { - if (this->unk_26E == 2) { - gSaveContext.unk_3E18[1] -= 250; - D_809C94A8 = (D_809C94A8 + 25) % 50; + if (this->perGameVar2.octorokHitType != SG_OCTO_HIT_TYPE_NONE) { + if (this->perGameVar2.octorokHitType == SG_OCTO_HIT_TYPE_BLUE) { + gSaveContext.timerTimeLimits[TIMER_ID_MINIGAME_1] -= SECONDS_TO_TIMER_PRECISE(2, 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; - gSaveContext.unk_3DE0[1] = 0; - gSaveContext.unk_3DD0[1] = 5; - player->stateFlags1 |= 0x20; - D_809C94A8 = 0; + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] == SECONDS_TO_TIMER(0)) { + this->flagsIndex = 0; + this->perGameVar1.octorokState = SG_OCTO_STATE_HIDING; + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_1] = SECONDS_TO_TIMER(0); + gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; + player->stateFlags1 |= PLAYER_STATE1_20; + sModFromLosingTime = 0; this->actor.draw = EnSyatekiMan_Draw; func_801A2C20(); - this->actionFunc = func_809C8BF0; - if (this->unk_280 == 50) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); - func_8011B4E0(globalCtx, 1); + this->actionFunc = EnSyatekiMan_Town_EndGame; + if (this->score == 50) { + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); + Interface_SetPerfectLetters(play, PERFECT_LETTERS_TYPE_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) { - 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; +void EnSyatekiMan_Town_EndGame(EnSyatekiMan* this, PlayState* play) { + if (this->shootingGameState == SG_GAME_STATE_RUNNING) { + this->octorokFlags = 0; + if ((this->talkWaitTimer <= 0) && !play->interfaceCtx.perfectLettersOn) { + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_59_20)) { + // 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; } } @@ -1216,49 +1440,48 @@ void EnSyatekiMan_Blink(EnSyatekiMan* this) { this->blinkTimer++; } -void EnSyatekiMan_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiMan_Update(Actor* thisx, PlayState* play) { EnSyatekiMan* this = THIS; - this->actionFunc(this, globalCtx); + 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 == BURLY_GUY_LIMB_HEAD)) { + if ((play->sceneId == SCENE_SYATEKI_MIZU) && (limbIndex == BURLY_GUY_LIMB_HEAD)) { *dList = gTownShootingGalleryManHeadDL; } if (limbIndex == BURLY_GUY_LIMB_HEAD) { Matrix_Translate(3000.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_RotateZS(this->unk_258.x, MTXMODE_APPLY); - Matrix_RotateXS(this->unk_258.y, MTXMODE_APPLY); + Matrix_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->unk_25E.y, MTXMODE_APPLY); + 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 == BURLY_GUY_LIMB_HEAD) { - Matrix_MultVec3f(&sp18, &this->actor.focus.pos); + Matrix_MultVec3f(&sFocusOffset, &this->actor.focus.pos); } } -void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiMan_Draw(Actor* thisx, PlayState* play) { static TexturePtr sEyeTextures[] = { gSwampShootingGalleryManEyeOpenTex, gSwampShootingGalleryManEyeHalfTex, @@ -1267,7 +1490,7 @@ void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { EnSyatekiMan* this = THIS; s32 pad; - if (globalCtx->sceneNum == SCENE_SYATEKI_MIZU) { + if (play->sceneId == SCENE_SYATEKI_MIZU) { sEyeTextures[0] = gTownShootingGalleryManEyeOpenTex; sEyeTextures[1] = gTownShootingGalleryManEyeClosedTex; sEyeTextures[2] = gTownShootingGalleryManEyeClosedTex; @@ -1277,15 +1500,15 @@ void EnSyatekiMan_Draw(Actor* thisx, GlobalContext* globalCtx) { 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(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, + 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 16585ac84..0b637fecf 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 @@ -4,51 +4,70 @@ #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[BURLY_GUY_LIMB_MAX]; - /* 0x01F8 */ Vec3s morphTable[BURLY_GUY_LIMB_MAX]; - /* 0x0258 */ Vec3s unk_258; - /* 0x025E */ Vec3s unk_25E; - /* 0x0264 */ s16 eyeIndex; - /* 0x0266 */ s16 blinkTimer; - /* 0x0268 */ UNK_TYPE1 unk268[0x2]; - /* 0x026A */ s16 unk_26A; - /* 0x026C */ s16 unk_26C; - /* 0x026E */ s16 unk_26E; - /* 0x0270 */ s16 unk_270; - /* 0x0272 */ s16 unk_272; - /* 0x0274 */ s16 unk_274; - /* 0x0276 */ s16 unk_276; - /* 0x0278 */ s16 unk_278; - /* 0x027A */ s16 unk_27A; - /* 0x027C */ s16 unk_27C; - /* 0x027E */ s16 unk_27E; - /* 0x0280 */ s16 unk_280; - /* 0x0282 */ s16 unk_282; - /* 0x0284 */ s16 unk_284; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnSyatekiManActionFunc actionFunc; + /* 0x18C */ Path* path; + /* 0x190 */ s32 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; - #endif // Z_EN_SYATEKI_MAN_H diff --git a/src/overlays/actors/ovl_En_Syateki_Okuta/overlay.cfg b/src/overlays/actors/ovl_En_Syateki_Okuta/overlay.cfg deleted file mode 100644 index 5c4c2e7c5..000000000 --- a/src/overlays/actors/ovl_En_Syateki_Okuta/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Syateki_Okuta -z_en_syateki_okuta.c 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 34afad373..162a6d718 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,24 +11,24 @@ #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 = { +ActorInit En_Syateki_Okuta_InitVars = { ACTOR_EN_SYATEKI_OKUTA, ACTORCAT_ENEMY, FLAGS, @@ -60,7 +60,7 @@ static ColliderCylinderInit sCylinderInit = { { 20, 40, -30, { 0, 0, 0 } }, }; -static AnimationInfo sAnimations[] = { +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 }, @@ -72,7 +72,7 @@ static AnimationInfo sAnimations[] = { #include "assets/overlays/ovl_En_Syateki_Okuta/ovl_En_Syateki_Okuta.c" static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 66, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_OCTOROK, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 6500, ICHAIN_STOP), }; @@ -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,18 +94,18 @@ void EnSyatekiOkuta_Init(Actor* thisx, GlobalContext* globalCtx) { s32 bgId; Actor_ProcessInitChain(&this->actor, sInitChain); - SkelAnime_Init(globalCtx, &this->skelAnime, &gOctorokSkel, &gOctorokAppearAnim, this->jointTable, this->morphTable, + SkelAnime_Init(play, &this->skelAnime, &gOctorokSkel, &gOctorokAppearAnim, this->jointTable, this->morphTable, OCTOROK_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.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); + Actor_Kill(&this->actor); } else { this->actor.world.pos.y = this->actor.home.pos.y = ySurface; } @@ -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) { @@ -158,8 +158,8 @@ void func_80A36260(EnSyatekiOkuta* this) { 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) { @@ -179,22 +179,22 @@ void func_80A362F8(EnSyatekiOkuta* this) { 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,13 +279,13 @@ 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, - &D_80A37BA8, Rand_S16Offset(100, 50), 25, 0); + EffectSsDtBubble_SpawnCustomColor(play, &this->actor.world.pos, &sp84, &D_80A37B98, &D_80A37BA4, + &D_80A37BA8, Rand_S16Offset(100, 50), 25, false); } func_80A362F8(this); @@ -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.minigamePoints++; + 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; @@ -484,21 +484,21 @@ s32 EnSyatekiOkuta_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx 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, 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_Translate(this->actor.world.pos.x, this->actor.world.pos.y + 30.0f, this->actor.world.pos.z + 20.0f, MTXMODE_NEW); @@ -509,7 +509,7 @@ 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++, gShootingGalleryOctorokCrossDL); @@ -518,5 +518,5 @@ void EnSyatekiOkuta_Draw(Actor* thisx, GlobalContext* globalCtx) { } } - 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 17fafe94d..0527354d0 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; @@ -24,6 +24,4 @@ typedef struct EnSyatekiOkuta { /* 0x2AA */ s16 unk_2AA; } EnSyatekiOkuta; // size = 0x2AC -extern const ActorInit En_Syateki_Okuta_InitVars; - #endif // Z_EN_SYATEKI_OKUTA_H diff --git a/src/overlays/actors/ovl_En_Syateki_Wf/overlay.cfg b/src/overlays/actors/ovl_En_Syateki_Wf/overlay.cfg deleted file mode 100644 index 4a5373e73..000000000 --- a/src/overlays/actors/ovl_En_Syateki_Wf/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Syateki_Wf -z_en_syateki_wf.c 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 0a0b3f66c..20871efb2 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 @@ -11,24 +11,24 @@ #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* play2); +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] = { { @@ -73,7 +73,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -101,7 +101,7 @@ static Vec3f D_80A20EDC = { 0.0f, 20.0f, 0.0f }; static Vec3f D_80A20EE8 = { 0.0f, 0.0f, 0.0f }; -const ActorInit En_Syateki_Wf_InitVars = { +ActorInit En_Syateki_Wf_InitVars = { ACTOR_EN_SYATEKI_WF, ACTORCAT_ENEMY, FLAGS, @@ -113,7 +113,7 @@ const ActorInit En_Syateki_Wf_InitVars = { (ActorFunc)EnSyatekiWf_Draw, }; -static AnimationInfo sAnimations[] = { +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 }, @@ -139,7 +139,7 @@ static TexturePtr sEyeTextures[] = { gWolfosNormalEyeHalfTex, }; -void EnSyatekiWf_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnSyatekiWf_Init(Actor* thisx, PlayState* play) { s32 pad; EnSyatekiWf* this = THIS; Path* path; @@ -148,15 +148,15 @@ 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_INDEX(&this->actor); i++) { + path = &play->setupPathList[path->unk1]; } if (path == NULL) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -175,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, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + 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; + this->actor.hintId = TATL_HINT_ID_WOLFOS; 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) { @@ -224,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_INDEX(&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_INDEX(&this->actor))) { this->unk_298 = 1; } } @@ -246,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; @@ -257,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); } @@ -319,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); } } } @@ -328,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); } @@ -340,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); } @@ -354,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) { @@ -367,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)) { @@ -393,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) { @@ -407,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); @@ -424,25 +424,25 @@ void EnSyatekiWf_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_34C.base.acFlags &= ~AC_HIT; this->actor.colChkInfo.health -= 2; if (this->actor.colChkInfo.health == 0) { - func_801A3098(NA_BGM_GET_ITEM | 0x900); - func_80A20858(this, globalCtx); + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); + 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 { @@ -450,12 +450,11 @@ 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; @@ -468,15 +467,15 @@ void EnSyatekiWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } } -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 a43c76f77..56770952f 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 @@ -5,11 +5,12 @@ #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_INDEX(thisx) (((thisx)->params & 0xFF00) >> 8) +#define EN_SYATEKI_WF_PARAMS(index, unkF0, unused) (((index << 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; @@ -34,6 +35,4 @@ typedef struct EnSyatekiWf { /* 0x3AC */ UNK_TYPE1 unk_3AC[0x20]; } EnSyatekiWf; // size = 0x3CC -extern const ActorInit En_Syateki_Wf_InitVars; - #endif // Z_EN_SYATEKI_WF_H diff --git a/src/overlays/actors/ovl_En_Tab/overlay.cfg b/src/overlays/actors/ovl_En_Tab/overlay.cfg deleted file mode 100644 index 234201830..000000000 --- a/src/overlays/actors/ovl_En_Tab/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tab -z_en_tab.c 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 5745da0fd..abd7c100c 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -12,13 +12,13 @@ #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); static u8 D_80BE18D0[] = { /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x24 - 0x04), @@ -66,7 +66,7 @@ s32 D_80BE1A0C[] = { 0x0C103012, 0x14FFEC06, 0x00920000, 0x1300920C, 0x10300034, 0x0100050E, 0x2B100C10, 0x0E2B110C, 0x10000000, }; -const ActorInit En_Tab_InitVars = { +ActorInit En_Tab_InitVars = { ACTOR_EN_TAB, ACTORCAT_NPC, FLAGS, @@ -122,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; } @@ -164,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) { @@ -181,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; } @@ -198,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; } @@ -239,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; @@ -259,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_Translate(this->unk_308, 0.0f, 0.0f, MTXMODE_APPLY); - if ((&this->actor == player->targetActor) && - ((globalCtx->msgCtx.currentTextId < 0xFF) || (globalCtx->msgCtx.currentTextId > 0x200)) && (sp20 == 3) && - (this->unk_334 == 3)) { - if ((globalCtx->state.frames % 2) == 0) { + if ((&this->actor == player->talkActor) && + ((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 { @@ -281,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) { @@ -313,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, &gPlayerAnim_link_demo_bikkuri, 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; @@ -342,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; } @@ -353,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; @@ -366,9 +366,9 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { return NULL; } -s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, ScheduleResult* 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); @@ -385,7 +385,7 @@ s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } -s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BE0FC4(EnTab* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); @@ -399,18 +399,18 @@ s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return true; } -s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80BE1060(EnTab* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret; this->unk_2FC = 0; - switch (arg2->result) { + switch (scheduleOutput->result) { case 1: - ret = func_80BE0F04(this, 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: @@ -420,24 +420,23 @@ s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { 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 & PLAYER_STATE1_40) && !(play->msgCtx.currentTextId <= 0x2B00) && + (play->msgCtx.currentTextId < 0x2B08)) { this->actor.child = &this->unk_1E4->actor; this->unk_2FC |= 8; } else { dist = Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_1E4->actor.world.pos); - if ((gSaveContext.save.weekEventReg[75] & 1) || (this->unk_1E4->actor.draw == NULL) || - !(dist < 160.0f)) { - tempActor = &GET_PLAYER(globalCtx)->actor; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_01) || (this->unk_1E4->actor.draw == NULL) || !(dist < 160.0f)) { + tempActor = &GET_PLAYER(play)->actor; this->actor.child = tempActor; } else { tempActor = &this->unk_1E4->actor; @@ -453,7 +452,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; @@ -464,20 +463,20 @@ 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) { - ScheduleResult sp18; +void func_80BE127C(EnTab* this, PlayState* play) { + ScheduleOutput sp18; - this->unk_31A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->unk_31A = R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); - if (!Schedule_RunScript(globalCtx, D_80BE18D0, &sp18) || - ((this->unk_1D8 != sp18.result) && !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.result = 0; @@ -486,15 +485,15 @@ void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_1; } this->unk_1D8 = sp18.result; - func_80BE1224(this, globalCtx); + 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; @@ -508,15 +507,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); @@ -527,44 +525,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, EXCH_ITEM_NONE, this->unk_2FC & 7); + func_8013C964(&this->actor, play, radius, height, PLAYER_IA_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)) { @@ -573,7 +571,7 @@ 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) { @@ -582,7 +580,7 @@ void EnTab_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTab_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTab* this = THIS; s32 rotStep; s32 overrideStep; @@ -613,20 +611,20 @@ void EnTab_TransformDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) } } -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..6bb0503a7 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.h +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.h @@ -6,45 +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; - #endif // Z_EN_TAB_H diff --git a/src/overlays/actors/ovl_En_Tag_Obj/overlay.cfg b/src/overlays/actors/ovl_En_Tag_Obj/overlay.cfg deleted file mode 100644 index 0939c8b84..000000000 --- a/src/overlays/actors/ovl_En_Tag_Obj/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tag_Obj -z_en_tag_obj.c 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..2cc547e9a 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 @@ -1,7 +1,7 @@ /* * File: z_en_tag_obj.c * Overlay: ovl_En_Tag_Obj - * Description: + * Description: Unused Seahorse Spawner */ #include "z_en_tag_obj.h" @@ -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 = { { @@ -34,7 +34,7 @@ static ColliderCylinderInit sUnusedColliderInit = { { 20, 30, 0, { 0, 0, 0 } }, }; -const ActorInit En_Tag_Obj_InitVars = { +ActorInit En_Tag_Obj_InitVars = { ACTOR_EN_TAG_OBJ, ACTORCAT_PROP, FLAGS, @@ -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..25e7025d8 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,10 +7,8 @@ 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 -extern const ActorInit En_Tag_Obj_InitVars; - #endif // Z_EN_TAG_OBJ_H diff --git a/src/overlays/actors/ovl_En_Takaraya/overlay.cfg b/src/overlays/actors/ovl_En_Takaraya/overlay.cfg deleted file mode 100644 index 3fbedd25e..000000000 --- a/src/overlays/actors/ovl_En_Takaraya/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Takaraya -z_en_takaraya.c 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..9bc0cd1b9 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.c @@ -10,13 +10,13 @@ #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 = { +ActorInit En_Takaraya_InitVars = { ACTOR_EN_TAKARAYA, ACTORCAT_NPC, FLAGS, 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..cfa37125e 100644 --- a/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h +++ b/src/overlays/actors/ovl_En_Takaraya/z_en_takaraya.h @@ -5,15 +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; - #endif // Z_EN_TAKARAYA_H diff --git a/src/overlays/actors/ovl_En_Talk/overlay.cfg b/src/overlays/actors/ovl_En_Talk/overlay.cfg deleted file mode 100644 index 3fed504a4..000000000 --- a/src/overlays/actors/ovl_En_Talk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Talk -z_en_talk.c 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..4f9b2a53d 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.c +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.c @@ -10,13 +10,13 @@ #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 = { +ActorInit En_Talk_InitVars = { ACTOR_EN_TALK, ACTORCAT_ITEMACTION, FLAGS, @@ -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..ef2f67798 100644 --- a/src/overlays/actors/ovl_En_Talk/z_en_talk.h +++ b/src/overlays/actors/ovl_En_Talk/z_en_talk.h @@ -7,13 +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; - #endif // Z_EN_TALK_H diff --git a/src/overlays/actors/ovl_En_Talk_Gibud/overlay.cfg b/src/overlays/actors/ovl_En_Talk_Gibud/overlay.cfg deleted file mode 100644 index 9f776a093..000000000 --- a/src/overlays/actors/ovl_En_Talk_Gibud/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Talk_Gibud -z_en_talk_gibud.c 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 a52c9391d..a84059634 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,51 +5,52 @@ */ #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; - /* 0x4 */ s32 item; + /* 0x0 */ PlayerItemAction itemAction; + /* 0x4 */ ItemId item; /* 0x8 */ s32 amount; /* 0xC */ s16 isBottledItem; } EnTalkGibudRequestedItem; @@ -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, @@ -101,7 +102,7 @@ typedef enum { /* 2 */ EN_TALK_GIBUD_GRAB_RELEASE, } EnTalkGibudGrabState; -const ActorInit En_Talk_Gibud_InitVars = { +ActorInit En_Talk_Gibud_InitVars = { ACTOR_EN_TALK_GIBUD, ACTORCAT_ENEMY, FLAGS, @@ -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 }, @@ -199,16 +200,16 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; static EnTalkGibudRequestedItem sRequestedItemTable[] = { - { PLAYER_AP_BOTTLE_POTION_BLUE, ITEM_POTION_BLUE, 1, true }, - { PLAYER_AP_MAGIC_BEANS, ITEM_MAGIC_BEANS, 5, false }, - { PLAYER_AP_BOTTLE_SPRING_WATER, ITEM_SPRING_WATER, 1, true }, - { PLAYER_AP_BOTTLE_FISH, ITEM_FISH, 1, true }, - { PLAYER_AP_BOTTLE_BUG, ITEM_BUG, 1, true }, - { PLAYER_AP_NUT, ITEM_NUT, 10, false }, - { PLAYER_AP_BOMB, ITEM_BOMB, 10, false }, - { PLAYER_AP_BOTTLE_HOT_SPRING_WATER, ITEM_HOT_SPRING_WATER, 1, true }, - { PLAYER_AP_BOTTLE_BIG_POE, ITEM_BIG_POE, 1, true }, - { PLAYER_AP_BOTTLE_MILK, ITEM_MILK_BOTTLE, 1, true }, + { PLAYER_IA_BOTTLE_POTION_BLUE, ITEM_POTION_BLUE, 1, true }, + { PLAYER_IA_MAGIC_BEANS, ITEM_MAGIC_BEANS, 5, false }, + { PLAYER_IA_BOTTLE_SPRING_WATER, ITEM_SPRING_WATER, 1, true }, + { PLAYER_IA_BOTTLE_FISH, ITEM_FISH, 1, true }, + { PLAYER_IA_BOTTLE_BUG, ITEM_BUG, 1, true }, + { PLAYER_IA_NUT, ITEM_NUT, 10, false }, + { PLAYER_IA_BOMB, ITEM_BOMB, 10, false }, + { PLAYER_IA_BOTTLE_HOT_SPRING_WATER, ITEM_HOT_SPRING_WATER, 1, true }, + { PLAYER_IA_BOTTLE_BIG_POE, ITEM_BIG_POE, 1, true }, + { PLAYER_IA_BOTTLE_MILK, ITEM_MILK_BOTTLE, 1, true }, }; static InitChainEntry sInitChain[] = { @@ -221,27 +222,27 @@ 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; Actor_ProcessInitChain(&this->actor, sInitChain); this->actor.targetMode = 0; - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; 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; this->grabState = EN_TALK_GIBUD_GRAB_START; this->grabWaitTimer = 0; - this->itemActionParam = PLAYER_AP_NONE; + this->itemAction = PLAYER_IA_NONE; this->drawDmgEffTimer = 0; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; this->isTalking = false; @@ -267,21 +268,21 @@ void EnTalkGibud_Init(Actor* thisx, GlobalContext* globalCtx) { this->switchFlag = -1; } - if (this->switchFlag != -1 && Flags_GetSwitch(globalCtx, this->switchFlag)) { - Actor_MarkForDeath(&this->actor); + if (this->switchFlag != -1 && Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&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; @@ -406,10 +407,10 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { if (this->grabDamageTimer == 20) { s16 requiredScopeTemp; - damageSfxId = player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S; - globalCtx->damagePlayer(globalCtx, -8); + damageSfxId = player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S; + 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++; @@ -419,13 +420,13 @@ void EnTalkGibud_Grab(EnTalkGibud* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_REDEAD_ATTACK); } - if (!(player->stateFlags2 & 0x80) || (player->unk_B62 != 0)) { - if ((player->unk_B62 != 0) && (player->stateFlags2 & 0x80)) { - player->stateFlags2 &= ~0x80; + if (!(player->stateFlags2 & PLAYER_STATE2_80) || (player->unk_B62 != 0)) { + if ((player->unk_B62 != 0) && (player->stateFlags2 & PLAYER_STATE2_80)) { + player->stateFlags2 &= ~PLAYER_STATE2_80; 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; } @@ -565,15 +566,15 @@ void EnTalkGibud_Damage(EnTalkGibud* this, GlobalContext* globalCtx) { this->actor.world.rot.y = this->actor.shape.rot.y; if ((this->drawDmgEffTimer > 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) && (this->type == EN_TALK_GIBUD_TYPE_GIBDO)) { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; 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,17 +696,17 @@ 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, PlayerItemAction presentedItemAction) { EnTalkGibudRequestedItem* requestedItem = &sRequestedItemTable[this->requestedItemIndex]; - if (requestedItem->itemActionParam == presentedItemActionParam) { + if (requestedItem->itemAction == presentedItemAction) { if (!requestedItem->isBottledItem) { if (AMMO(requestedItem->item) >= requestedItem->amount) { return EN_TALK_GIBUD_REQUESTED_ITEM_MET; @@ -713,24 +714,25 @@ 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); - s32 itemActionParam; +void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, PlayState* play) { + Player* player = GET_PLAYER(play); + PlayerItemAction itemAction; - if (this->itemActionParam == PLAYER_AP_NONE) { - itemActionParam = func_80123810(globalCtx); - if (itemActionParam != PLAYER_AP_NONE) { - this->itemActionParam = itemActionParam; + if (this->itemAction == PLAYER_IA_NONE) { + itemAction = func_80123810(play); + + if (itemAction != PLAYER_IA_NONE) { + this->itemAction = itemAction; } - if (this->itemActionParam > PLAYER_AP_NONE) { - switch (EnTalkGibud_PresentedItemMatchesRequest(this, globalCtx, this->itemActionParam)) { + if (this->itemAction > PLAYER_IA_NONE) { + switch (EnTalkGibud_PresentedItemMatchesRequest(this, play, this->itemAction)) { case EN_TALK_GIBUD_REQUESTED_ITEM_MET: player->actor.textId = 0x138A; this->textId = 0x138A; @@ -749,9 +751,9 @@ void EnTalkGibud_CheckPresentedItem(EnTalkGibud* this, GlobalContext* globalCtx) default: break; } - func_801477B4(globalCtx); - } else if (this->itemActionParam < PLAYER_AP_NONE) { - Message_StartTextbox(globalCtx, 0x1389, &this->actor); + func_801477B4(play); + } else if (this->itemAction <= PLAYER_IA_MINUS1) { + Message_StartTextbox(play, 0x1389, &this->actor); this->textId = 0x1389; } } @@ -760,7 +762,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 +771,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); @@ -786,45 +788,45 @@ void EnTalkGibud_PassiveIdle(EnTalkGibud* this, GlobalContext* globalCtx) { } void EnTalkGibud_SetupTalk(EnTalkGibud* this) { - this->itemActionParam = PLAYER_AP_NONE; + this->itemAction = PLAYER_IA_NONE; 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); + Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE); } - player->stateFlags1 |= 0x20; - player->stateFlags1 |= 0x20000000; + player->stateFlags1 |= PLAYER_STATE1_20; + player->stateFlags1 |= PLAYER_STATE1_20000000; this->actor.flags |= ACTOR_FLAG_100000; EnTalkGibud_SetupDisappear(this); } else { @@ -833,22 +835,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,22 +866,22 @@ 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; + player->stateFlags1 |= PLAYER_STATE1_20000000; this->disappearanceTimer--; } else { if (this->switchFlag != -1) { - Flags_SetSwitch(globalCtx, this->switchFlag); + Flags_SetSwitch(play, this->switchFlag); } - player->stateFlags1 &= ~0x20; - player->stateFlags1 &= ~0x20000000; - Actor_MarkForDeath(&this->actor); + player->stateFlags1 &= ~PLAYER_STATE1_20; + player->stateFlags1 &= ~PLAYER_STATE1_20000000; + Actor_Kill(&this->actor); } } -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,12 +892,13 @@ 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)) && - !(player->stateFlags2 & (0x4000 | 0x80))) { + !(player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000 | + PLAYER_STATE1_80000 | PLAYER_STATE1_200000)) && + !(player->stateFlags2 & (PLAYER_STATE2_80 | PLAYER_STATE2_4000))) { return true; } @@ -907,8 +910,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,25 +920,25 @@ 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.hintId = TATL_HINT_ID_NONE; 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) { - this->actor.hintId = 0x2A; + this->actor.hintId = TATL_HINT_ID_REDEAD; } else { - this->actor.hintId = 0x2D; + this->actor.hintId = TATL_HINT_ID_GIBDO; } this->actor.textId = 0; EnTalkGibud_SetupWalkToHome(this); @@ -943,7 +946,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 +970,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 +995,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 +1080,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 +1106,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 +1120,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 +1133,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 +1164,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) && @@ -1178,36 +1180,36 @@ void EnTalkGibud_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } } -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..d887b1c0d 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; @@ -19,7 +19,7 @@ typedef struct EnTalkGibud { /* 0x1D8 */ Vec3f limbPos[15]; /* 0x28C */ s32 limbIndex; /* 0x290 */ s32 requestedItemIndex; - /* 0x294 */ s32 itemActionParam; + /* 0x294 */ PlayerItemAction itemAction; /* 0x298 */ s32 switchFlag; /* 0x29C */ f32 drawDmgEffAlpha; /* 0x2A0 */ f32 drawDmgEffScale; @@ -45,6 +45,4 @@ typedef struct EnTalkGibud { /* 0x3F7 */ s8 unk_3F7; // related to player->unk_ADD } EnTalkGibud; // size = 0x3F8 -extern const ActorInit En_Talk_Gibud_InitVars; - #endif // Z_EN_TALK_GIBUD_H diff --git a/src/overlays/actors/ovl_En_Tanron1/overlay.cfg b/src/overlays/actors/ovl_En_Tanron1/overlay.cfg deleted file mode 100644 index 5a6959a4e..000000000 --- a/src/overlays/actors/ovl_En_Tanron1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tanron1 -z_en_tanron1.c 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 0f8b56068..fec6a2d3b 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.c @@ -10,15 +10,15 @@ #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 = { +ActorInit En_Tanron1_InitVars = { ACTOR_EN_TANRON1, ACTORCAT_ENEMY, FLAGS, @@ -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; @@ -149,10 +149,10 @@ void EnTanron1_Update(Actor* thisx, GlobalContext* globalCtx) { break; } - if ((player->itemActionParam == 7) && (player->unk_B28 != 0)) { - this->unk_14C.x = player->swordInfo[0].tip.x; - this->unk_14C.y = player->swordInfo[0].tip.y; - this->unk_14C.z = player->swordInfo[0].tip.z; + if ((player->heldItemAction == PLAYER_IA_STICK) && (player->unk_B28 != 0)) { + 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,7 +258,7 @@ 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); } } @@ -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) { @@ -383,8 +382,7 @@ void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { 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); } } @@ -408,9 +406,11 @@ void func_80BB5AAC(EnTanron1* this, GlobalContext* globalCtx) { 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); + if (1) {} + + 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_Tanron1/z_en_tanron1.h b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h index d8e96537f..bff1b46bf 100644 --- a/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h +++ b/src/overlays/actors/ovl_En_Tanron1/z_en_tanron1.h @@ -39,6 +39,4 @@ typedef struct EnTanron1 { /* 0x3360 */ Vec3f unk_3360; } EnTanron1; // size = 0x336C -extern const ActorInit En_Tanron1_InitVars; - #endif // Z_EN_TANRON1_H diff --git a/src/overlays/actors/ovl_En_Tanron2/overlay.cfg b/src/overlays/actors/ovl_En_Tanron2/overlay.cfg deleted file mode 100644 index c585d560b..000000000 --- a/src/overlays/actors/ovl_En_Tanron2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tanron2 -z_en_tanron2.c 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 66ee6080e..332560403 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.c @@ -13,24 +13,24 @@ #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* play2); 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; EnTanron2* D_80BB8458[82]; -const ActorInit En_Tanron2_InitVars = { +ActorInit En_Tanron2_InitVars = { ACTOR_EN_TANRON2, ACTORCAT_BOSS, FLAGS, @@ -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,10 +140,10 @@ 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)) { + if ((KREG(64) != 0) || CHECK_EVENTINF(EVENTINF_60)) { func_80BB69C0(this); } else { func_80BB6F64(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; @@ -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,7 +352,7 @@ 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; @@ -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, - Rand_ZeroFloat(100.0f) + 200.0f, Rand_ZeroFloat(5.0f) + 15.0f, 0); + EffectSsDtBubble_SpawnCustomColor(play, &sp90, &spA8, &sp9C, &D_80BB81E8, &D_80BB81EC, + Rand_ZeroFloat(100.0f) + 200.0f, Rand_ZeroFloat(5.0f) + 15.0f, false); } } -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; @@ -394,8 +394,8 @@ void func_80BB7408(EnTanron2* this, GlobalContext* globalCtx) { if (this->actor.world.pos.y <= this->actor.floorHeight) { this->actor.world.pos.y = this->actor.floorHeight; if ((s8)this->actor.colChkInfo.health <= 0) { - Actor_MarkForDeath(&this->actor); - func_80BB71C8(this, globalCtx); + Actor_Kill(&this->actor); + 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; @@ -428,10 +428,10 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { func_80BB6B80(this); this->unk_158 = 1; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_IKURA_DAMAGE); - if ((player->unk_730 != 0) && (&this->actor != player->unk_730)) { - player->unk_730 = &this->actor; - globalCtx->actorCtx.targetContext.arrowPointedActor = &this->actor; - globalCtx->actorCtx.targetContext.targetedActor = &this->actor; + if ((player->targetedActor != NULL) && (&this->actor != player->targetedActor)) { + player->targetedActor = &this->actor; + play->actorCtx.targetContext.arrowPointedActor = &this->actor; + play->actorCtx.targetContext.targetedActor = &this->actor; } } else { this->unk_154 = 15; @@ -445,7 +445,7 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { 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); @@ -470,12 +470,12 @@ void func_80BB7578(EnTanron2* this, GlobalContext* globalCtx) { 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); + Actor_Kill(&this->actor); + 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); + Actor_Kill(&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; @@ -626,44 +626,42 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (D_80BB8458[i] != NULL) { Matrix_Translate(D_80BB8458[i]->actor.world.pos.x, D_80BB8458[i]->actor.world.pos.y, D_80BB8458[i]->actor.world.pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(D_80BB8458[i]->actor.scale.x, D_80BB8458[i]->actor.scale.y, 0.0f, MTXMODE_APPLY); Matrix_RotateZS(D_80BB8458[i]->unk_14A, MTXMODE_APPLY); Matrix_Scale(0.13f, 0.14299999f, 0.13f, MTXMODE_APPLY); Matrix_RotateZS(-D_80BB8458[i]->unk_14A, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_boss04_DL_0034C8); + 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_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)) { @@ -671,12 +669,11 @@ void EnTanron2_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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..3ae619a2d 100644 --- a/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h +++ b/src/overlays/actors/ovl_En_Tanron2/z_en_tanron2.h @@ -5,29 +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; - #endif // Z_EN_TANRON2_H diff --git a/src/overlays/actors/ovl_En_Tanron3/overlay.cfg b/src/overlays/actors/ovl_En_Tanron3/overlay.cfg deleted file mode 100644 index 1084615ef..000000000 --- a/src/overlays/actors/ovl_En_Tanron3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tanron3 -z_en_tanron3.c 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 5e6bd32ee..d991ab323 100644 --- a/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c +++ b/src/overlays/actors/ovl_En_Tanron3/z_en_tanron3.c @@ -18,20 +18,20 @@ #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 }; static Boss03* sGyorg = NULL; -const ActorInit En_Tanron3_InitVars = { +ActorInit En_Tanron3_InitVars = { ACTOR_EN_TANRON3, ACTORCAT_BOSS, FLAGS, @@ -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; @@ -141,12 +141,13 @@ void EnTanron3_SpawnBubbles(EnTanron3* this, GlobalContext* globalCtx) { 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, - &sEnvColor, Rand_ZeroFloat(30.0f) + 70.0f, Rand_ZeroFloat(5.0f) + 15.0f, 0); + EffectSsDtBubble_SpawnCustomColor(play, &this->actor.world.pos, &velocity, &acceleration, &sPrimColor, + &sEnvColor, Rand_ZeroFloat(30.0f) + 70.0f, Rand_ZeroFloat(5.0f) + 15.0f, + false); } } -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 +170,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) { @@ -210,7 +211,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { // If the player gets eaten by Gyorg, or if the attack timer ran out, // stop chasing the player for a little bit. - if (this->workTimer[WORK_TIMER_ATTACK] == 0 || (player->stateFlags2 & 0x80)) { + if (this->workTimer[WORK_TIMER_ATTACK] == 0 || (player->stateFlags2 & PLAYER_STATE2_80)) { this->workTimer[WORK_TIMER_WAIT] = 150; this->isNonHostile = true; } @@ -231,7 +232,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { // on attacking the player; in that case, this code will make it turn in the // 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); + atanTemp = Math_Atan2S_XY(this->targetPos.z, this->targetPos.x); Matrix_RotateYS(atanTemp, MTXMODE_NEW); Matrix_MultVecZ(700.0f, &this->targetPos); this->targetPos.y = 250.0f; @@ -258,9 +259,9 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { // Rotate the fish to look towards its target xzDistance = sqrtf(SQ(xDistance) + SQ(zDistance)); - atanTemp = Math_FAtan2F(xzDistance, -yDistance); + atanTemp = Math_Atan2S_XY(xzDistance, -yDistance); Math_ApproachS(&this->actor.world.rot.x, atanTemp, this->rotationScale, this->rotationStep); - atanTemp = Math_FAtan2F(zDistance, xDistance); + atanTemp = Math_Atan2S_XY(zDistance, xDistance); Math_SmoothStepToS(&this->actor.world.rot.y, atanTemp, this->rotationScale, this->rotationStep, 0); Math_ApproachS(&this->rotationStep, this->targetRotationStep, 1, 0x100); @@ -303,7 +304,7 @@ void EnTanron3_Live(EnTanron3* this, GlobalContext* globalCtx) { if (Rand_ZeroOne() < 0.5f) { this->targetShapeRotation.y = (s16)Rand_ZeroFloat(0x10000); } - this->actor.world.rot.y = Math_FAtan2F(this->actor.world.pos.z, this->actor.world.pos.x) + + this->actor.world.rot.y = Math_Atan2S_XY(this->actor.world.pos.z, this->actor.world.pos.x) + (s16)randPlusMinusPoint5Scaled(0xCE20); } @@ -316,7 +317,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,41 +333,41 @@ 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; yDistance = this->actor.world.pos.y - player->actor.world.pos.y + 30.0f; zDistance = this->actor.world.pos.z - player->actor.world.pos.z; - this->actor.world.rot.x = Math_FAtan2F(sqrtf(SQ(xDistance) + SQ(zDistance)), -yDistance); - this->actor.world.rot.y = Math_FAtan2F(zDistance, xDistance); + this->actor.world.rot.x = Math_Atan2S_XY(sqrtf(SQ(xDistance) + SQ(zDistance)), -yDistance); + this->actor.world.rot.y = Math_Atan2S_XY(zDistance, xDistance); this->workTimer[WORK_TIMER_DIE] = 6; this->actor.speedXZ = 10.0f; 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); - Actor_MarkForDeath(&this->actor); + EnTanron3_SpawnBubbles(this, play); + Actor_Kill(&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), + func_800B8D50(play, NULL, 3.0f, Math_Atan2S_XY(-player->actor.world.pos.z, -player->actor.world.pos.x), 5.0f, 0); } } @@ -375,13 +376,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 +403,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 +412,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 +447,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..8859de6a4 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 @@ -41,6 +41,4 @@ typedef struct EnTanron3 { /* 0x2F8 */ EnTanron3ActionFunc actionFunc; } EnTanron3; // size = 0x2FC -extern const ActorInit En_Tanron3_InitVars; - #endif // Z_EN_TANRON3_H diff --git a/src/overlays/actors/ovl_En_Tanron4/overlay.cfg b/src/overlays/actors/ovl_En_Tanron4/overlay.cfg deleted file mode 100644 index 734d70ac7..000000000 --- a/src/overlays/actors/ovl_En_Tanron4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tanron4 -z_en_tanron4.c 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 48eea6828..b53343931 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* play2); +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, @@ -31,7 +31,7 @@ typedef enum { /* 1 */ SEAGULL_TIMER_CHOOSE_TARGET, } SeagullTimers; -const ActorInit En_Tanron4_InitVars = { +ActorInit En_Tanron4_InitVars = { ACTOR_EN_TANRON4, ACTORCAT_ITEMACTION, FLAGS, @@ -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_RotateZS(this->roll, MTXMODE_APPLY); - 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); } } 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..36a48c91a 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; @@ -28,6 +28,4 @@ typedef struct EnTanron4 { #define SEAGULL_CLONE -1 #define SEAGULL_FOLLOW_ACTOR 100 -extern const ActorInit En_Tanron4_InitVars; - #endif // Z_EN_TANRON4_H diff --git a/src/overlays/actors/ovl_En_Tanron5/overlay.cfg b/src/overlays/actors/ovl_En_Tanron5/overlay.cfg deleted file mode 100644 index 4a522458e..000000000 --- a/src/overlays/actors/ovl_En_Tanron5/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tanron5 -z_en_tanron5.c 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 09da81cee..c052c3309 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.c @@ -13,17 +13,17 @@ #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* play2); +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* play2); +void func_80BE5C10(Actor* thisx, PlayState* play); s32 D_80BE5D80 = 0; -const ActorInit En_Tanron5_InitVars = { +ActorInit En_Tanron5_InitVars = { ACTOR_EN_TANRON5, ACTORCAT_BOSS, FLAGS, @@ -144,13 +144,13 @@ 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) { D_80BE5D80++; if (D_80BE5D80 > 60) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -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; @@ -198,17 +198,17 @@ void EnTanron5_Init(Actor* thisx, GlobalContext* globalCtx) { 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); + Actor_Kill(&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; @@ -230,7 +230,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { this->unk_1A0++; Actor_SetScale(&this->actor, 0.0f); if (this->unk_1A0 >= 40) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } return; } else { @@ -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; @@ -285,12 +285,12 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { 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; @@ -331,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); } } } @@ -350,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; @@ -361,7 +361,7 @@ 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); } } } @@ -372,7 +372,7 @@ void EnTanron5_Update(Actor* thisx, GlobalContext* globalCtx2) { } if ((this->unk_148 == gTwinmoldMajoraPillarDL) || (D_80BE5DD0 < 0.5f)) { - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + 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; @@ -392,32 +392,32 @@ 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++; this->actor.world.pos.y -= 2.0f * D_80BE5DD0; if (this->unk_1A0 == 40) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } return; } if (DECR(this->unk_144) == 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } 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) { @@ -431,11 +431,11 @@ 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 { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } } else { @@ -450,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; @@ -460,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); + Actor_Kill(&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); } } } @@ -477,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; @@ -504,13 +504,13 @@ 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; + texture = gDropArrows1Tex; } else { - texture = gameplay_keep_Tex_0617C0; + texture = gDropMagicLargeTex; } POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); @@ -520,9 +520,9 @@ void func_80BE5C10(Actor* thisx, GlobalContext* globalCtx) { Matrix_Translate(0.0f, 200.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateZS(this->unk_198, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); - 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..d40938bf8 100644 --- a/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h +++ b/src/overlays/actors/ovl_En_Tanron5/z_en_tanron5.h @@ -15,16 +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; - #endif // Z_EN_TANRON5_H diff --git a/src/overlays/actors/ovl_En_Tanron6/overlay.cfg b/src/overlays/actors/ovl_En_Tanron6/overlay.cfg deleted file mode 100644 index 2e81ae121..000000000 --- a/src/overlays/actors/ovl_En_Tanron6/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tanron6 -z_en_tanron6.c 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..4faa072f9 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.c @@ -1,7 +1,7 @@ /* * File: z_en_tanron6.c * Overlay: ovl_En_Tanron6 - * Description: Swarm of Giant Bees + * Description: Unused invisible enemy. Only draws a circle shadow. */ #include "z_en_tanron6.h" @@ -10,15 +10,15 @@ #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 = { +ActorInit En_Tanron6_InitVars = { ACTOR_EN_TANRON6, ACTORCAT_ENEMY, FLAGS, @@ -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..89d9a4aae 100644 --- a/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.h +++ b/src/overlays/actors/ovl_En_Tanron6/z_en_tanron6.h @@ -5,14 +5,12 @@ 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 -extern const ActorInit En_Tanron6_InitVars; - #endif // Z_EN_TANRON6_H diff --git a/src/overlays/actors/ovl_En_Test/overlay.cfg b/src/overlays/actors/ovl_En_Test/overlay.cfg deleted file mode 100644 index 3f264536a..000000000 --- a/src/overlays/actors/ovl_En_Test/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Test -z_en_test.c 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 e3e22939f..7f0a3e971 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -11,12 +11,12 @@ #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* play2); +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 = { +ActorInit En_Test_InitVars = { ACTOR_EN_TEST, ACTORCAT_ITEMACTION, FLAGS, @@ -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); @@ -149,16 +149,16 @@ void func_80863048(GlobalContext* globalCtx, EnTestStruct* arg1) { 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,11 +172,10 @@ 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); + Actor_Kill(thisx); return; } @@ -184,7 +183,7 @@ void EnTest_Init(Actor* thisx, GlobalContext* globalCtx2) { func_800C0094(thisx->floorPoly, thisx->world.pos.x, thisx->floorHeight, thisx->world.pos.z, &sp38); Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, true); thisx->world.rot = thisx->shape.rot; - this->unk_20A = func_800C9BB8(&globalCtx->colCtx, thisx->floorPoly, sp34); + 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; @@ -209,7 +208,7 @@ void EnTest_Update(Actor* thisx, GlobalContext* globalCtx) { if (func_80183DE0(&this->skeletonInfo) && (this->actor.parent == NULL) && (this->actor.params != -1)) { this->unk_209++; if (this->unk_209 > 20) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -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,14 +243,14 @@ 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; + Mtx* mtx; s32 sp2C = this->unk_208 - 1; if (sp2C >= 29) { @@ -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))); + mtx = GRAPH_ALLOC(play->state.gfxCtx, 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); + if (mtx != NULL) { + func_8012C2DC(play->state.gfxCtx); + func_8018450C(play, &this->skeletonInfo, mtx, 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..2b8d62993 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.h +++ b/src/overlays/actors/ovl_En_Test/z_en_test.h @@ -21,13 +21,11 @@ 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; /* 0x20C */ EnTestStruct unk_20C[20]; } EnTest; // size = 0x6BC -extern const ActorInit En_Test_InitVars; - #endif // Z_EN_TEST_H diff --git a/src/overlays/actors/ovl_En_Test2/overlay.cfg b/src/overlays/actors/ovl_En_Test2/overlay.cfg deleted file mode 100644 index 8a698679c..000000000 --- a/src/overlays/actors/ovl_En_Test2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Test2 -z_en_test2.c 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..257aea283 100644 --- a/src/overlays/actors/ovl_En_Test2/z_en_test2.c +++ b/src/overlays/actors/ovl_En_Test2/z_en_test2.c @@ -5,16 +5,29 @@ */ #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); -#if 0 -const ActorInit En_Test2_InitVars = { +typedef struct EnTest2ModelInfo { + /* 0x0 */ Gfx* dList1; + /* 0x4 */ Gfx* dList2; + /* 0x8 */ AnimatedMaterial* animMat; +} EnTest2ModelInfo; // size = 0xC + +ActorInit En_Test2_InitVars = { ACTOR_EN_TEST2, ACTORCAT_BG, FLAGS, @@ -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_Kill(&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.curRoom.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.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { + 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..3b03e0cc1 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,12 @@ struct EnTest2; typedef struct EnTest2 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ AnimatedMaterial* animMat; } EnTest2; // size = 0x148 -extern const ActorInit En_Test2_InitVars; +typedef enum { + /* 0xB */ EN_TEST2_PARAMS_B = 0xB, + /* 0xC */ EN_TEST2_PARAMS_C +} EnTest2_Params; #endif // Z_EN_TEST2_H diff --git a/src/overlays/actors/ovl_En_Test3/overlay.cfg b/src/overlays/actors/ovl_En_Test3/overlay.cfg deleted file mode 100644 index 25736e068..000000000 --- a/src/overlays/actors/ovl_En_Test3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Test3 -z_en_test3.c 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..dade95ee3 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -4,18 +4,172 @@ * Description: Kafei */ +#include "prevent_bss_reordering.h" #include "z_en_test3.h" +#include "objects/object_test3/object_test3.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "objects/object_mask_ki_tan/object_mask_ki_tan.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_4000000) #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); +typedef struct { + /* 0x0 */ s8 unk_0; + /* 0x1 */ s8 unk_1_0 : 4; + /* 0x1 */ s8 unk_1_4 : 4; +} struct_80A41828; // size = 0x2 -#if 0 -const ActorInit En_Test3_InitVars = { +typedef s32 (*EnTest3UnkFunc2)(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +typedef s32 (*EnTest3UnkFunc)(EnTest3* this, PlayState* play); + +typedef struct { + /* 0x0 */ EnTest3UnkFunc2 unk_0; + /* 0x4 */ EnTest3UnkFunc unk_4; +} struct_80A40678; // size = 0x8 + +typedef struct { + /* 0x0 */ EnTest3ActionFunc unk_0; // might not actually be an action function + /* 0x4 */ EnTest3ActionFunc actionFunc; +} struct_80A4168C; // size = 0x8 + +// Main functions +void EnTest3_Init(Actor* thisx, PlayState* play2); +void EnTest3_Destroy(Actor* thisx, PlayState* play2); +void EnTest3_Update(Actor* thisx, PlayState* play2); +void EnTest3_Draw(Actor* thisx, PlayState* play2); + +// Functions used in D_80A4169C and D_80A416C0. Purpose unclear, but related to Schedule +s32 func_80A3E870(EnTest3* this, PlayState* play); +s32 func_80A3E884(EnTest3* this, PlayState* play); +s32 func_80A3E898(EnTest3* this, PlayState* play); +s32 func_80A3E960(EnTest3* this, PlayState* play); +s32 func_80A3E97C(EnTest3* this, PlayState* play); +s32 func_80A3E9DC(EnTest3* this, PlayState* play); +s32 func_80A3EA30(EnTest3* this, PlayState* play); +s32 func_80A3EAC4(EnTest3* this, PlayState* play); +s32 func_80A3EAF8(EnTest3* this, PlayState* play); +s32 func_80A3EB8C(EnTest3* this, PlayState* play); +s32 func_80A3EBFC(EnTest3* this, PlayState* play); +s32 func_80A3EC30(EnTest3* this, PlayState* play); +s32 func_80A3EC44(EnTest3* this, PlayState* play); + +// Functions used in D_80A417E8. Purpose unclear, but related to Schedule +s32 func_80A3F080(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +s32 func_80A3F09C(EnTest3* this, PlayState* play); +s32 func_80A3F62C(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +s32 func_80A3F73C(EnTest3* this, PlayState* play); +s32 func_80A3F8D4(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +s32 func_80A3F9A4(EnTest3* this, PlayState* play); +s32 func_80A3F9E4(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +s32 func_80A3FA58(EnTest3* this, PlayState* play); +s32 func_80A3FBCC(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +s32 func_80A3FBE8(EnTest3* this, PlayState* play); +s32 func_80A3FDE4(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +s32 func_80A3FE20(EnTest3* this, PlayState* play); +s32 func_80A3FF10(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +s32 func_80A3FFD0(EnTest3* this, PlayState* play2); +s32 func_80A40098(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput); +s32 func_80A40230(EnTest3* this, PlayState* play); + +// Action functions +void func_80A40678(EnTest3* this, PlayState* play); +void func_80A40824(EnTest3* this, PlayState* play); +void func_80A4084C(EnTest3* this, PlayState* play); +void func_80A40908(EnTest3* this, PlayState* play); +void func_80A40A6C(EnTest3* this, PlayState* play); + +static u8 sScheduleScript[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x046 - 0x004), + /* 0x004 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ALLEY, 0x020 - 0x008), + /* 0x008 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 50, 7, 20, 0x01A - 0x00E), + /* 0x00E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(7, 30, 0x019 - 0x012), + /* 0x012 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_04, 0x017 - 0x016), + /* 0x016 */ SCHEDULE_CMD_RET_NONE(), + /* 0x017 */ SCHEDULE_CMD_RET_VAL_S(10), + /* 0x019 */ SCHEDULE_CMD_RET_NONE(), + /* 0x01A */ SCHEDULE_CMD_RET_TIME(6, 50, 7, 20, 15), + /* 0x020 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x045 - 0x024), + /* 0x024 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 6, 30, 0x03F - 0x02A), + /* 0x02A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 30, 6, 35, 0x03D - 0x030), + /* 0x030 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 35, 6, 50, 0x037 - 0x036), + /* 0x036 */ SCHEDULE_CMD_RET_NONE(), + /* 0x037 */ SCHEDULE_CMD_RET_TIME(6, 35, 6, 50, 14), + /* 0x03D */ SCHEDULE_CMD_RET_VAL_S(1), + /* 0x03F */ SCHEDULE_CMD_RET_TIME(6, 0, 6, 30, 13), + /* 0x045 */ SCHEDULE_CMD_RET_NONE(), + /* 0x046 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x09B - 0x04A), + /* 0x04A */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_02, 0x058 - 0x04E), + /* 0x04E */ SCHEDULE_CMD_BRANCH_S(0x0), + /* 0x050 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_04, 0x055 - 0x054), + /* 0x054 */ SCHEDULE_CMD_RET_NONE(), + /* 0x055 */ SCHEDULE_CMD_RET_VAL_L(10), + /* 0x058 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ALLEY, 0x081 - 0x05C), + /* 0x05C */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x050 - 0x060), + /* 0x060 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 25, 0x07B - 0x066), + /* 0x066 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 40, 0x079 - 0x06C), + /* 0x06C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 40, 16, 0, 0x073 - 0x072), + /* 0x072 */ SCHEDULE_CMD_RET_NONE(), + /* 0x073 */ SCHEDULE_CMD_RET_TIME(15, 40, 16, 0, 17), + /* 0x079 */ SCHEDULE_CMD_RET_VAL_S(1), + /* 0x07B */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 25, 16), + /* 0x081 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_AYASHIISHOP, 0x09A - 0x085), + /* 0x085 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 55, 16, 10, 0x094 - 0x08B), + /* 0x08B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 10, 22, 10, 0x092 - 0x091), + /* 0x091 */ SCHEDULE_CMD_RET_NONE(), + /* 0x092 */ SCHEDULE_CMD_RET_VAL_S(3), + /* 0x094 */ SCHEDULE_CMD_RET_TIME(15, 55, 16, 10, 12), + /* 0x09A */ SCHEDULE_CMD_RET_NONE(), + /* 0x09B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(3, 0x138 - 0x0A0), + /* 0x0A0 */ SCHEDULE_CMD_CHECK_FLAG_L(WEEKEVENTREG_33_08, 0x12C - 0x0A5), + /* 0x0A5 */ SCHEDULE_CMD_CHECK_FLAG_L(WEEKEVENTREG_79_40, 0x12C - 0x0AA), + /* 0x0AA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_SECOM, 0x0B0 - 0x0AE), + /* 0x0AE */ SCHEDULE_CMD_RET_VAL_S(7), + /* 0x0B0 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_20, 0x0DD - 0x0B4), + /* 0x0B4 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_IKANA, 0x0DC - 0x0B8), + /* 0x0B8 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_08, 0x0BE - 0x0BC), + /* 0x0BC */ SCHEDULE_CMD_RET_VAL_S(5), + /* 0x0BE */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_61_08, 0x0DA - 0x0C2), + /* 0x0C2 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_10, 0x0CD - 0x0C6), + /* 0x0C6 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(19, 0, 0x0CB - 0x0CA), + /* 0x0CA */ SCHEDULE_CMD_RET_NONE(), + /* 0x0CB */ SCHEDULE_CMD_RET_VAL_S(5), + /* 0x0CD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 0, 19, 10, 0x0D4 - 0x0D3), + /* 0x0D3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0D4 */ SCHEDULE_CMD_RET_TIME(19, 0, 19, 10, 20), + /* 0x0DA */ SCHEDULE_CMD_RET_VAL_S(5), + /* 0x0DC */ SCHEDULE_CMD_RET_NONE(), + /* 0x0DD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_IKANA, 0x0E8 - 0x0E1), + /* 0x0E1 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_90_02, 0x0E7 - 0x0E5), + /* 0x0E5 */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x0E7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0E8 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x0F9 - 0x0EC), + /* 0x0EC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(4, 0, 4, 10, 0x0F3 - 0x0F2), + /* 0x0F2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(4, 0, 4, 10, 11), + /* 0x0F9 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x12B - 0x0FD), + /* 0x0FD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(4, 10, 4, 30, 0x125 - 0x103), + /* 0x103 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_01, 0x11C - 0x107), + /* 0x107 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(4, 30, 4, 45, 0x116 - 0x10D), + /* 0x10D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(4, 45, 6, 0, 0x114 - 0x113), + /* 0x113 */ SCHEDULE_CMD_RET_NONE(), + /* 0x114 */ SCHEDULE_CMD_RET_VAL_S(6), + /* 0x116 */ SCHEDULE_CMD_RET_TIME(4, 30, 4, 45, 19), + /* 0x11C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(4, 30, 6, 0, 0x123 - 0x122), + /* 0x122 */ SCHEDULE_CMD_RET_NONE(), + /* 0x123 */ SCHEDULE_CMD_RET_VAL_S(8), + /* 0x125 */ SCHEDULE_CMD_RET_TIME(4, 10, 4, 30, 18), + /* 0x12B */ SCHEDULE_CMD_RET_NONE(), + /* 0x12C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_AYASHIISHOP, 0x137 - 0x130), + /* 0x130 */ SCHEDULE_CMD_CHECK_FLAG_S(WEEKEVENTREG_51_08, 0x135 - 0x134), + /* 0x134 */ SCHEDULE_CMD_RET_NONE(), + /* 0x135 */ SCHEDULE_CMD_RET_VAL_S(4), + /* 0x137 */ SCHEDULE_CMD_RET_NONE(), + /* 0x138 */ SCHEDULE_CMD_RET_NONE(), +}; + +ActorInit En_Test3_InitVars = { ACTOR_EN_TEST3, ACTORCAT_NPC, FLAGS, @@ -27,113 +181,1123 @@ const ActorInit En_Test3_InitVars = { (ActorFunc)NULL, }; -#endif +static struct_80A4168C D_80A4168C[] = { + { func_80A40A6C, NULL }, + { NULL, NULL }, +}; -extern UNK_TYPE D_0600EDD0; -extern UNK_TYPE D_0600F7EC; +static EnTest3UnkFunc D_80A4169C[] = { + func_80A3E898, func_80A3E898, func_80A3E884, func_80A3E898, func_80A3E898, + func_80A3EA30, func_80A3E898, func_80A3E960, func_80A3E870, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3E7E0.s") +static EnTest3UnkFunc D_80A416C0[] = { + func_80A3EAC4, func_80A3EAF8, func_80A3EBFC, func_80A3EC44, + func_80A3EC30, func_80A3E9DC, func_80A3EB8C, func_80A3E97C, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3E80C.s") +static PlayerAgeProperties sAgeProperties = { + 40.0f, + 60.0f, + 11.0f / 17.0f, + 71.0f, + 50.0f, + 49.0f, + 39.0f, + 27.0f, + 19.0f, + 22.0f, + 32.4f, + 32.0f, + 48.0f, + 11.0f / 17.0f * 70.0f, + 14.0f, + 12.0f, + 55.0f, + { 0xFFE8, 0x0DED, 0x036C }, + { { 0xFFE8, 0x0D92, 0x035E }, { 0xFFE8, 0x1371, 0x03A9 }, { 0x0008, 0x1256, 0x017C }, { 0x0009, 0x17EA, 0x0167 } }, + { { 0xFFE8, 0x1371, 0x03A9 }, { 0xFFE8, 0x195F, 0x03A9 }, { 0x0009, 0x17EA, 0x0167 }, { 0x0009, 0x1E0D, 0x017C } }, + { { 0x0008, 0x1256, 0x017C }, { 0x0009, 0x17EA, 0x0167 }, { 0xF9C8, 0x1256, 0x017C }, { 0xF9C9, 0x17EA, 0x0167 } }, + 0x0020, + 0x0000, + 22.0f, + 29.4343f, + &gPlayerAnim_clink_demo_Tbox_open, + &gPlayerAnim_clink_demo_goto_future, + &gPlayerAnim_clink_demo_return_to_future, + &gPlayerAnim_clink_normal_climb_startA, + &gPlayerAnim_clink_normal_climb_startB, + { &gPlayerAnim_clink_normal_climb_upL, &gPlayerAnim_clink_normal_climb_upR, &gPlayerAnim_link_normal_Fclimb_upL, + &gPlayerAnim_link_normal_Fclimb_upR }, + { &gPlayerAnim_link_normal_Fclimb_sideL, &gPlayerAnim_link_normal_Fclimb_sideR }, + { &gPlayerAnim_clink_normal_climb_endAL, &gPlayerAnim_clink_normal_climb_endAR }, + { &gPlayerAnim_clink_normal_climb_endBR, &gPlayerAnim_clink_normal_climb_endBL }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3E870.s") +static EffectBlureInit2 sBlureInit = { + 0, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 4, + 0, 2, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3E884.s") +static EffectTireMarkInit sTireMarkInit = { + 0, + 63, + { 0, 0, 15, 100 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3E898.s") +static struct_80A40678 D_80A417E8[] = { + { func_80A3F080, func_80A3F09C }, { func_80A40098, func_80A40230 }, { func_80A3F62C, func_80A3F73C }, + { func_80A3F8D4, func_80A3F9A4 }, { func_80A3F9E4, func_80A3FA58 }, { func_80A3FBCC, func_80A3FBE8 }, + { func_80A3FDE4, func_80A3FE20 }, { func_80A3FF10, func_80A3FFD0 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3E960.s") +static struct_80A41828 D_80A41828[] = { + { 0, 0, 0 }, { 3, -2, 0 }, { 2, -1, 0 }, { 2, -1, 1 }, { 2, -1, 2 }, { 2, 1, 3 }, { 2, -2, 4 }, { 5, 1, 0 }, + { 7, -1, 0 }, { 6, 2, 0 }, { 4, 4, 0 }, { 1, 1, 0 }, { 1, 1, 0 }, { 1, 2, 0 }, { 1, 1, 0 }, { 1, 1, 0 }, + { 1, 2, 0 }, { 1, 3, 0 }, { 1, 1, 0 }, { 1, 2, 0 }, { 1, 1, 0 }, { 0, 0, 0 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3E97C.s") +static EnTest3_struct_D78 D_80A41854[] = { + { 4, 0, 0x2B25 }, { 1, 0, 0x2969 }, { 3, 1, 0x296A }, { 1, 0, 0x296B }, { 5, 1, 0x0000 }, { 8, 0, 0x0000 }, + { 4, 0, 0x2976 }, { 6, 0, 0x2977 }, { 7, 10, 0x2978 }, { 4, 1, 0x0000 }, { 4, 0, 0x2968 }, { 4, 0, 0x297A }, + { 1, 0, 0x145D }, { 1, 0, 0x145E }, { 5, 1, 0x145F }, { 1, 0, 0x145F }, { 5, 0, 0x0000 }, { 4, 0, 0x1460 }, + { 4, 0, 0x145C }, { 4, 0, 0x2913 }, { 4, 0, 0x1465 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3E9DC.s") +s32 D_80A41D20; +s32 D_80A41D24; +Input sEnTest3_Input; +f32 D_80A41D40; +s16 D_80A41D44; +s32 D_80A41D48; +Vec3f D_80A41D50; +s32 D_80A41D5C; +s32 D_80A41D60; +s32 D_80A41D64; +s32 D_80A41D68; +Vec3f* D_80A41D6C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3EA30.s") +s32 func_80A3E7E0(EnTest3* this, EnTest3ActionFunc actionFunc) { + if (actionFunc == this->unk_D94) { + return false; + } else { + this->unk_D94 = actionFunc; + this->unk_D8A = 0; + this->unk_D88 = 0; + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3EAC4.s") +s32 func_80A3E80C(EnTest3* this, PlayState* play, s32 arg2) { + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3EAF8.s") + D_80A4168C[arg2].unk_0(this, play); + if (D_80A4168C[arg2].actionFunc == NULL) { + // D_80A4168C[arg2].actionFunc is always NULL + return false; + } else { + func_80A3E7E0(this, D_80A4168C[arg2].actionFunc); + return true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3EB8C.s") +s32 func_80A3E870(EnTest3* this, PlayState* play) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3EBFC.s") +s32 func_80A3E884(EnTest3* this, PlayState* play) { + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3EC30.s") +s32 func_80A3E898(EnTest3* this, PlayState* play) { + u16 textId = this->unk_D78->textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3EC44.s") + if ((this->unk_D78->unk_0 == 4) && CHECK_WEEKEVENTREG(WEEKEVENTREG_51_08)) { + func_80151BB4(play, 2); + } + if (textId == 0xFFFF) { + func_801477B4(play); + } else if (textId) { // != 0 + func_80151938(play, textId); + } + if (textId == 0x296B) { + LinkAnimation_PlayOnceSetSpeed(play, &this->player.skelAnime, &gPlayerAnim_al_yareyare, 2.0f / 3.0f); + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3ECEC.s") +s32 func_80A3E960(EnTest3* this, PlayState* play) { + this->unk_D8C = this->unk_D78->unk_1; + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3ED24.s") +s32 func_80A3E97C(EnTest3* this, PlayState* play) { + if (DECR(this->unk_D8C) == 0) { + Message_StartTextbox(play, this->unk_D78->textId, NULL); + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/EnTest3_Init.s") +s32 func_80A3E9DC(EnTest3* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->unk_D8D)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_D8D, &this->player.actor); + return true; + } else { + ActorCutscene_SetIntentToPlay(this->unk_D8D); + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/EnTest3_Destroy.s") +s32 func_80A3EA30(EnTest3* this, PlayState* play) { + if (this->unk_D78->textId == 0x145F) { + Actor* hideoutDoor = SubS_FindActor(play, NULL, ACTORCAT_BG, ACTOR_BG_IKNV_OBJ); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F080.s") + if (hideoutDoor != NULL) { + this->player.targetedActor = hideoutDoor; + } + } + if (this->unk_D78->unk_1 != 0) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->unk_D8D); + play->msgCtx.msgMode = 0x44; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F09C.s") +s32 func_80A3EAC4(EnTest3* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) { + return 1; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F0B0.s") +s32 func_80A3EAF8(EnTest3* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + if (this->unk_D78->textId == 0x145F) { + ActorCutscene_Stop(this->unk_D8D); + this->unk_D8D = 0x7C; + ActorCutscene_SetIntentToPlay(this->unk_D8D); + this->player.targetedActor = &GET_PLAYER(play)->actor; + } + return 1; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F114.s") +s32 func_80A3EB8C(EnTest3* this, PlayState* play) { + if (func_80A3EAF8(this, play)) { + Actor* hideoutObject = SubS_FindActor(play, NULL, ACTORCAT_ITEMACTION, ACTOR_OBJ_NOZOKI); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F15C.s") + if (hideoutObject != NULL) { + this->player.targetedActor = hideoutObject; + } + play->msgCtx.msgMode = 0x44; + return 1; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F2BC.s") +s32 func_80A3EBFC(EnTest3* this, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + return 1; + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F384.s") +s32 func_80A3EC30(EnTest3* this, PlayState* play) { + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F4A4.s") +s32 func_80A3EC44(EnTest3* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex != 0) { + func_8019F230(); + } else { + func_8019F208(); + } + if (play->msgCtx.choiceIndex != 0) { + return 1; + } else { + s32 ret = this->unk_D78->unk_1 + 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F534.s") + return ret; + } + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F5A4.s") +s32 func_80A3ECEC(EnTest3* this, PlayState* play) { + return D_80A4169C[this->unk_D78->unk_0](this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F62C.s") +s32 func_80A3ED24(EnTest3* this, PlayState* play) { + s32 temp = D_80A416C0[this->unk_D78->unk_0](this, play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F73C.s") + if (temp != 0) { + this->unk_D78 = &this->unk_D78[temp]; + return func_80A3ECEC(this, play); + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F8D4.s") +void EnTest3_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTest3* this = THIS; + Camera* subCam; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F9A4.s") + if (D_80A41D24) { + Actor_Kill(&this->player.actor); + return; + } + D_80A41D24 = true; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3F9E4.s") + this->player.actor.room = -1; + this->player.unk_A86 = -1; + this->player.transformation = PLAYER_FORM_HUMAN; + this->player.ageProperties = &sAgeProperties; + this->player.heldItemAction = PLAYER_IA_NONE; + this->player.heldItemId = ITEM_OCARINA; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3FA58.s") + Player_SetModelGroup(&this->player, 3); + play->playerInit(&this->player, play, &object_test3_Skel_00F7EC); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3FBCC.s") + Effect_Add(play, &this->player.meleeWeaponEffectIndex[0], EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(play, &this->player.meleeWeaponEffectIndex[1], EFFECT_BLURE2, 0, 0, &sBlureInit); + Effect_Add(play, &this->player.meleeWeaponEffectIndex[2], EFFECT_TIRE_MARK, 0, 0, &sTireMarkInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3FBE8.s") + this->player.maskObjectSegment = ZeldaArena_Malloc(0x3800); + play->func_18780(&this->player, play); + this->unk_D90 = GET_PLAYER(play); + this->player.giObjectSegment = this->unk_D90->giObjectSegment; + this->player.tatlActor = this->unk_D90->tatlActor; + if ((CURRENT_DAY != 3) || CHECK_WEEKEVENTREG(WEEKEVENTREG_33_08) || !CHECK_WEEKEVENTREG(WEEKEVENTREG_51_08)) { + this->player.currentMask = PLAYER_MASK_KEATON; + } + this->player.prevMask = this->player.currentMask; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3FDE4.s") + if (play->sceneId == SCENE_SECOM) { + this->subCamId = Play_CreateSubCamera(play); + subCam = Play_GetCamera(play, this->subCamId); + Camera_InitPlayerSettings(subCam, &this->player); + Camera_SetFlags(subCam, CAM_STATE_0 | CAM_STATE_6); + Play_ChangeCameraStatus(play, this->subCamId, CAM_STATUS_WAIT); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3FE20.s") + this->player.actor.colChkInfo.cylRadius = 20; + this->player.actor.colChkInfo.cylHeight = 60; + this->player.actor.colChkInfo.health = 255; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3FF10.s") + if (KAFEI_GET_PARAM_1E0(&this->player.actor) == 0) { + func_80A3E7E0(this, func_80A40824); + } else { + func_80A3E7E0(this, func_80A40678); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A3FFD0.s") +void EnTest3_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTest3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A40098.s") + Effect_Destroy(play, this->player.meleeWeaponEffectIndex[0]); + Effect_Destroy(play, this->player.meleeWeaponEffectIndex[1]); + Effect_Destroy(play, this->player.meleeWeaponEffectIndex[2]); + Collider_DestroyCylinder(play, &this->player.cylinder); + Collider_DestroyCylinder(play, &this->player.shieldCylinder); + Collider_DestroyQuad(play, &this->player.meleeWeaponQuads[0]); + Collider_DestroyQuad(play, &this->player.meleeWeaponQuads[1]); + Collider_DestroyQuad(play, &this->player.shieldQuad); + ZeldaArena_Free(this->player.maskObjectSegment); + Environment_StartTime(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A40230.s") +s32 func_80A3F080(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A40678.s") +s32 func_80A3F09C(EnTest3* this, PlayState* play) { + this->player.actor.draw = NULL; + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A40824.s") +void func_80A3F0B0(EnTest3* this, PlayState* play) { + func_800BC154(play, &play->actorCtx, &this->unk_D90->actor, 2); + func_800BC154(play, &play->actorCtx, &this->player.actor, 4); + this->unk_D90->stateFlags1 &= ~PLAYER_STATE1_20; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A4084C.s") +void func_80A3F114(EnTest3* this, PlayState* play) { + if (this->player.csMode != 0) { + play->startPlayerCutscene(play, &this->player, 6); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A40908.s") +s32 func_80A3F15C(EnTest3* this, PlayState* play, struct_80A41828* arg2) { + s32 pathIndex; + Path* path; + Vec3s* curPathPoint; + Vec3s* nextPathPoint; + Vec3f curPathPos; + Vec3f nextPathPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A409D4.s") + pathIndex = ABS_ALT(arg2->unk_1_0) - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A40A6C.s") + if (pathIndex >= 0) { + path = SubS_GetAdditionalPath(play, KAFEI_GET_PARAM_1F(&this->player.actor), pathIndex); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/EnTest3_Update.s") + curPathPoint = Lib_SegmentedToVirtual(path->points); + if (arg2->unk_1_0 > 0) { + nextPathPoint = curPathPoint + 1; + } else { + curPathPoint += path->count - 1; + nextPathPoint = curPathPoint - 1; + } + Math_Vec3s_ToVec3f(&curPathPos, curPathPoint); + Math_Vec3s_ToVec3f(&nextPathPos, nextPathPoint); + if (Math_Vec3f_DistXZ(&this->player.actor.world.pos, &curPathPos) > 10.0f) { + Math_Vec3f_Copy(&this->player.actor.world.pos, &curPathPos); + Math_Vec3f_Copy(&this->player.actor.home.pos, &curPathPos); + Math_Vec3f_Copy(&this->player.actor.prevPos, &curPathPos); + this->player.currentYaw = Math_Vec3f_Yaw(&this->player.actor.world.pos, &nextPathPos); + if (arg2->unk_1_0 < 0) { + this->player.currentYaw += 0x8000; + } + this->player.actor.shape.rot.y = this->player.currentYaw; + return true; + } + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A40CF0.s") +Actor* func_80A3F2BC(PlayState* play, EnTest3* this, s32 actorId, s32 category, f32 arg4, f32 arg5) { + Actor* actor = play->actorCtx.actorLists[category].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A40F34.s") + while (actor != NULL) { + if (actorId == actor->id) { + f32 dy = this->player.actor.world.pos.y - actor->world.pos.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Test3/func_80A4129C.s") + if ((fabsf(dy) < arg5) && (Actor_XZDistanceBetweenActors(&this->player.actor, actor) < arg4)) { + return actor; + } + } + actor = actor->next; + } + return NULL; +} + +s32 func_80A3F384(EnTest3* this, PlayState* play) { + Player* player = GET_PLAYER(play); + EnDoor* door = (EnDoor*)func_80A3F2BC(play, this, ACTOR_EN_DOOR, ACTORCAT_DOOR, 55.0f, 20.0f); + Vec3f offset; + + if ((door != NULL) && (door->unk_1A1 == 0) && + ((player->doorType == 0) || (&door->dyna.actor != player->doorActor)) && + Actor_ActorAIsFacingActorB(&this->player.actor, &door->dyna.actor, 0x3000)) { + Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &this->player.actor.world.pos); + this->player.doorType = 1; + this->player.doorDirection = (offset.z >= 0.0f) ? 1.0f : -1.0f; + this->player.doorActor = &door->dyna.actor; + this->player.unk_A86 = -1; + return true; + } + return false; +} + +s32 func_80A3F4A4(PlayState* play) { + return (Player_GetMask(play) == PLAYER_MASK_NONE) || (Player_GetMask(play) == PLAYER_MASK_BUNNY) || + (Player_GetMask(play) == PLAYER_MASK_POSTMAN) || (Player_GetMask(play) == PLAYER_MASK_KEATON) || + (Player_GetMask(play) == PLAYER_MASK_KAFEIS_MASK); +} + +void func_80A3F534(EnTest3* this, PlayState* play) { + if (!func_80A3F4A4(play)) { + this->unk_D78 = &D_80A41854[10]; + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_51_08)) { + this->unk_D78 = &D_80A41854[7]; + } else { + this->unk_D78 = &D_80A41854[1]; + } + this->unk_D8D = this->player.actor.cutscene; +} + +void func_80A3F5A4(EnTest3* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_51_08) || !func_80A3F4A4(play)) { + this->unk_D78 = &D_80A41854[18]; + D_80A41D5C = false; + } else if (D_80A41D5C) { + this->unk_D78 = &D_80A41854[17]; + } else { + this->unk_D78 = &D_80A41854[12]; + } + this->unk_D8D = this->player.actor.cutscene; +} + +s32 func_80A3F62C(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { + static EnTest3_struct_D78* D_80A418A8[] = { + &D_80A41854[0], &D_80A41854[1], &D_80A41854[11], &D_80A41854[12], &D_80A41854[19], + }; + + if (((func_80A3F15C(this, play, arg2) || (this->unk_D88 >= 8)) && ((arg2->unk_1_4 == 1) || (arg2->unk_1_4 == 2))) || + (arg2->unk_1_4 == 4)) { + if (arg2->unk_1_4 == 4) { + this->player.actor.home.rot.y = 0x7FFF; + } else { + this->player.actor.home.rot.y = this->player.actor.shape.rot.y + 0x8000; + } + this->player.stateFlags2 |= PLAYER_STATE2_40000; + play->startPlayerCutscene(play, &this->player, -1); + } + this->unk_D78 = D_80A418A8[arg2->unk_1_4]; + return true; +} + +s32 func_80A3F73C(EnTest3* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->player.actor, &play->state)) { + func_80A3E7E0(this, func_80A4084C); + this->player.targetedActor = &GET_PLAYER(play)->actor; + this->player.stateFlags2 &= ~PLAYER_STATE2_40000; + D_80A41D5C = true; + if ((this->unk_D78->unk_0 == 4) && CHECK_WEEKEVENTREG(WEEKEVENTREG_51_08)) { + func_80151BB4(play, 2); + } + } else { + if (play->actorCtx.flags & ACTORCTX_FLAG_4) { + play->actorCtx.flags &= ~ACTORCTX_FLAG_4; + this->player.stateFlags2 &= ~PLAYER_STATE2_40000; + this->unk_D90->stateFlags1 |= PLAYER_STATE1_20; + func_800BC154(play, &play->actorCtx, &this->unk_D90->actor, 4); + func_800BC154(play, &play->actorCtx, &this->player.actor, 2); + ActorCutscene_SetReturnCamera(this->subCamId); + play->startPlayerCutscene(play, &this->player, 7); + } + func_800B863C(&this->player.actor, play); + if (this->unk_D88 == 3) { + func_80A3F534(this, play); + } else if (this->unk_D88 == 5) { + func_80A3F5A4(this, play); + } + this->player.actor.textId = this->unk_D78->textId; + this->player.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } + return false; +} + +s32 func_80A3F8D4(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { + Actor* postActor; + + func_80A3F15C(this, play, arg2); + if (((postActor = func_80A3F2BC(play, this, ACTOR_EN_PST, ACTORCAT_PROP, 100.0f, 20.0f)) != NULL) || + ((postActor = func_80A3F2BC(play, this, ACTOR_EN_PM, ACTORCAT_NPC, 100.0f, 20.0f)) != NULL)) { + this->player.actor.home.rot.y = Actor_YawBetweenActors(&this->player.actor, postActor); + } + play->startPlayerCutscene(play, &this->player, 0x61); + return true; +} + +s32 func_80A3F9A4(EnTest3* this, PlayState* play) { + Math_ScaledStepToS(&this->player.actor.shape.rot.y, this->player.actor.home.rot.y, 0x320); + this->player.currentYaw = this->player.actor.shape.rot.y; + return false; +} + +s32 func_80A3F9E4(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { + scheduleOutput->time0 = SCHEDULE_TIME_NOW; + scheduleOutput->time1 = (u16)(scheduleOutput->time0 + 70); + func_80A40098(this, play, arg2, scheduleOutput); + if (this->player.actor.xzDistToPlayer < 300.0f) { + this->unk_D8A = -1; + } else { + this->unk_D8A = 120; + } + return true; +} + +s32 func_80A3FA58(EnTest3* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); + u32 cond; + struct_80A41828 sp40; + ScheduleOutput scheduleOutput; + + if (player->stateFlags1 & PLAYER_STATE1_40) { + return false; + } + cond = func_80A40230(this, play); + if (this->unk_D8A > 0) { + this->unk_D8A--; + cond = cond && (this->player.actor.xzDistToPlayer < 200.0f); + if (cond || this->unk_D8A <= 0) { + func_80A3F114(this, play); + sp40.unk_1_0 = 5; + scheduleOutput.time0 = SCHEDULE_TIME_NOW; + scheduleOutput.time1 = (u16)(scheduleOutput.time0 + (cond ? 80 : 140)); + + func_80A40098(this, play, &sp40, &scheduleOutput); + this->unk_D8A = -40; + return false; + } + if (this->unk_D8A == 90) { + play->startPlayerCutscene(play, &this->player, 0x15); + } + } else { + this->unk_D8A++; + if (this->unk_D8A == 0) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_51_04); + this->unk_D88 = 0; + } + } + return false; +} + +s32 func_80A3FBCC(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { + return true; +} + +s32 func_80A3FBE8(EnTest3* this, PlayState* play) { + if (D_80A41D20 == 0) { + if (!Play_InCsMode(play)) { + D_80A41D20 = 1; + this->unk_D78 = &D_80A41854[20]; + this->unk_D8D = this->player.actor.cutscene; + this->player.actor.textId = this->unk_D78->textId; + } + } else if (D_80A41D20 == 1) { + if (this->unk_D8D >= 0) { + if (func_80A3E9DC(this, play)) { + this->unk_D8D = -1; + Environment_StopTime(); + } + } else if ((play->actorCtx.flags & ACTORCTX_FLAG_6) || (play->actorCtx.flags & ACTORCTX_FLAG_5)) { + this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->player.actor.cutscene); + SET_WEEKEVENTREG(WEEKEVENTREG_90_02); + if (play->actorCtx.flags & ACTORCTX_FLAG_5) { + this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->unk_D8D); + } + Audio_QueueSeqCmd(NA_BGM_STOP | 0x10000); + D_80A41D20 = 2; + } else { + func_80A3F73C(this, play); + } + } else if ((D_80A41D20 == 2) && func_80A3E9DC(this, play)) { + ActorCutscene_SetReturnCamera(CAM_ID_MAIN); + Environment_StartTime(); + if (((void)0, gSaveContext.save.time) > CLOCK_TIME(6, 0)) { + func_800FE658(TIME_TO_MINUTES_ALT_F(fabsf((s16) - ((void)0, gSaveContext.save.time)))); + } + if (play->actorCtx.flags & ACTORCTX_FLAG_6) { + SET_WEEKEVENTREG(WEEKEVENTREG_51_20); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_90_02); + } + D_80A41D20 = 3; + } + return false; +} + +s32 func_80A3FDE4(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { + this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->player.actor.cutscene); + return true; +} + +s32 func_80A3FE20(EnTest3* this, PlayState* play) { + struct_80A41828 sp2C; + ScheduleOutput scheduleOutput; + + if (D_80A41D64 == 0) { + if (func_80A3E9DC(this, play)) { + sp2C.unk_1_0 = 2; + scheduleOutput.time0 = SCHEDULE_TIME_NOW; + scheduleOutput.time1 = (u16)(scheduleOutput.time0 + 1000); + func_80A40098(this, play, &sp2C, &scheduleOutput); + D_80A41D64 = 1; + return false; + } + } else if (D_80A41D64 == 1) { + func_80A40230(this, play); + } else if (D_80A41D64 == 2) { + ActorCutscene_Stop(this->unk_D8D); + SET_WEEKEVENTREG(WEEKEVENTREG_90_02); + D_80A41D64 = 3; + } + return false; +} + +s32 func_80A3FF10(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { + static Vec3f D_80A418BC = { -420.0f, 210.0f, -162.0f }; + + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_51_40)) { + D_80A41D68 = 2; + Math_Vec3f_Copy(&this->player.actor.world.pos, &D_80A418BC); + Math_Vec3f_Copy(&this->player.actor.home.pos, &D_80A418BC); + + this->player.actor.home.rot.y = -0x2AAB; + this->player.actor.shape.rot.y = -0x2AAB; + this->player.currentYaw = -0x2AAB; + if (1) {} // macro? + return true; + } else { + func_80A3F15C(this, play, arg2); + this->unk_D8D = this->player.actor.cutscene; + if (play->roomCtx.curRoom.num == 2) { + this->unk_D8D = ActorCutscene_GetAdditionalCutscene(this->unk_D8D); + } + return true; + } +} + +s32 func_80A3FFD0(EnTest3* this, PlayState* play2) { + PlayState* play = play2; + + if (D_80A41D68 == 0) { + if (!Play_InCsMode(play) && (play->roomCtx.curRoom.num == 2)) { + D_80A41D68 = 1; + } + } else if (D_80A41D68 == 1) { + if (func_80A3E9DC(this, play)) { + D_80A41D68 = 2; + } + } else { + SET_WEEKEVENTREG(WEEKEVENTREG_51_40); + play->startPlayerCutscene(play, &this->player, 0x6E); + } + return false; +} + +s32 func_80A40098(EnTest3* this, PlayState* play, struct_80A41828* arg2, ScheduleOutput* scheduleOutput) { + u16 now = SCHEDULE_TIME_NOW; + u16 startTime; + u16 numWaypoints; + + func_80A3F15C(this, play, arg2); + this->unk_D7C = SubS_GetAdditionalPath(play, KAFEI_GET_PARAM_1F(&this->player.actor), ABS_ALT(arg2->unk_1_0) - 1); + if ((this->unk_D88 < 7) && (this->unk_D88 != 0) && (this->unk_D80 >= 0)) { + startTime = now; + } else { + startTime = scheduleOutput->time0; + } + if (scheduleOutput->time1 < startTime) { + this->unk_DA8 = (startTime - scheduleOutput->time1) + (DAY_LENGTH - 1); + } else { + this->unk_DA8 = scheduleOutput->time1 - startTime; + } + this->unk_DB4 = now - startTime; + numWaypoints = startTime = this->unk_D7C->count - (SUBS_TIME_PATHING_ORDER - 1); + this->unk_DAC = this->unk_DA8 / numWaypoints; + this->unk_DB0 = (this->unk_DB4 / this->unk_DAC) + (SUBS_TIME_PATHING_ORDER - 1); + this->unk_D89 &= ~1; + this->unk_D84 = 1.0f; + return true; +} + +s32 func_80A40230(EnTest3* this, PlayState* play) { + f32 knots[265]; + Vec3f worldPos; + Vec3f sp7C; + Vec3f sp70; + s32 sp6C = 0; + s32 sp68 = 0; + s32 pad1; + f32 dx; + f32 dy; + s32 ret = false; + + SubS_TimePathing_FillKnots(knots, 3, this->unk_D7C->count + 3); + if (!(this->unk_D89 & 1)) { + sp70 = gZeroVec3f; + SubS_TimePathing_Update(this->unk_D7C, &this->unk_DA4, &this->unk_DB4, this->unk_DAC, this->unk_DA8, + &this->unk_DB0, knots, &sp70, this->unk_D80); + SubS_TimePathing_ComputeInitialY(play, this->unk_D7C, this->unk_DB0, &sp70); + Math_Vec3f_Copy(&this->player.actor.home.pos, &sp70); + Math_Vec3f_Copy(&this->player.actor.prevPos, &sp70); + this->player.actor.world.pos.y = sp70.y; + this->unk_D89 |= 1; + } else { + sp70 = this->unk_D98; + } + this->player.actor.world.pos.x = sp70.x; + this->player.actor.world.pos.z = sp70.z; + if (play->transitionMode != TRANS_MODE_OFF) { + sp6C = this->unk_DB4; + sp68 = this->unk_DB0; + sp70 = this->player.actor.world.pos; + } + this->unk_D98 = gZeroVec3f; + if (SubS_TimePathing_Update(this->unk_D7C, &this->unk_DA4, &this->unk_DB4, this->unk_DAC, this->unk_DA8, + &this->unk_DB0, knots, &this->unk_D98, this->unk_D80)) { + if (this->unk_D88 == 0x14) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_58_80); + this->player.actor.draw = NULL; + } else if (this->unk_D88 == 9) { + D_80A41D64 = 2; + } + ret = true; + } else { + worldPos = this->player.actor.world.pos; + sp7C = this->unk_D98; + this->player.actor.world.rot.y = Math_Vec3f_Yaw(&worldPos, &sp7C); + } + if (play->transitionMode != TRANS_MODE_OFF) { + this->unk_DB4 = sp6C; + this->unk_DB0 = sp68; + this->unk_D98 = sp70; + } + dx = this->player.actor.world.pos.x - this->player.actor.prevPos.x; + dy = this->player.actor.world.pos.z - this->player.actor.prevPos.z; + if (!Math_StepToF(&this->unk_D84, 1.0f, 0.1f)) { + this->player.actor.world.pos.x = this->player.actor.prevPos.x + (dx * this->unk_D84); + this->player.actor.world.pos.z = this->player.actor.prevPos.z + (dy * this->unk_D84); + } + Math_Vec3f_Copy(&D_80A41D50, &this->player.actor.world.pos); + dx = this->player.actor.world.pos.x - this->player.actor.prevPos.x; + dy = this->player.actor.world.pos.z - this->player.actor.prevPos.z; + this->player.linearVelocity = sqrtf(SQ(dx) + SQ(dy)); + this->player.linearVelocity *= 1.0f + (1.05f * fabsf(Math_SinS(this->player.unk_B6C))); + D_80A41D40 = (this->player.linearVelocity * 10.0f) + 20.0f; + D_80A41D40 = CLAMP_MAX(D_80A41D40, 60.0f); + D_80A41D44 = this->player.actor.world.rot.y; + this->player.actor.world.pos.x = this->player.actor.prevPos.x; + this->player.actor.world.pos.z = this->player.actor.prevPos.z; + if (!func_80A3F384(this, play)) { + D_80A41D48 = true; + } + return ret; +} + +void func_80A40678(EnTest3* this, PlayState* play) { + struct_80A41828* sp3C; + ScheduleOutput scheduleOutput; + + this->unk_D80 = ((this->unk_D88 == 20) || (this->unk_D88 == 10) || (this->unk_D88 == 9)) ? 3 + : Play_InCsMode(play) ? 0 + : R_TIME_SPEED + ((void)0, gSaveContext.save.timeSpeedOffset); + + if (Schedule_RunScript(play, sScheduleScript, &scheduleOutput)) { + if (this->unk_D88 != scheduleOutput.result) { + sp3C = &D_80A41828[scheduleOutput.result]; + func_80A3F114(this, play); + if (sp3C->unk_0 != 4) { + CLEAR_WEEKEVENTREG(WEEKEVENTREG_51_04); + } + if (!D_80A417E8[sp3C->unk_0].unk_0(this, play, sp3C, &scheduleOutput)) { + return; + } + if (scheduleOutput.result == 6) { + this->player.actor.home.rot.y = 0x7FFF; + this->player.stateFlags2 |= PLAYER_STATE2_40000; + play->startPlayerCutscene(play, &this->player, -1); + } + } + } else { + scheduleOutput.result = 0; + } + this->unk_D88 = scheduleOutput.result; + sp3C = &D_80A41828[this->unk_D88]; + D_80A417E8[sp3C->unk_0].unk_4(this, play); +} + +void func_80A40824(EnTest3* this, PlayState* play) { + this->unk_D78 = &D_80A41854[0]; + func_80A3F73C(this, play); +} + +void func_80A4084C(EnTest3* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->player.actor, play)) { + if ((this->unk_D78->unk_1 == 0) || !func_80A3E80C(this, play, this->unk_D78->unk_1 - 1)) { + if (KAFEI_GET_PARAM_1E0(&this->player.actor) == 0) { + func_80A3E7E0(this, func_80A40824); + } else { + func_80A3E7E0(this, func_80A40678); + } + this->player.targetedActor = NULL; + } + } else if (func_80A3ED24(this, play)) { + func_80A3E7E0(this, func_80A40908); + } +} + +void func_80A40908(EnTest3* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->player.actor, &play->state)) { + func_80A3E7E0(this, func_80A4084C); + this->player.targetedActor = &GET_PLAYER(play)->actor; + SET_WEEKEVENTREG(WEEKEVENTREG_51_08); + func_80151BB4(play, 0x19); + func_80151BB4(play, 2); + } else { + func_800B8500(&this->player.actor, play, 9999.9f, 9999.9f, PLAYER_IA_MINUS1); + this->unk_D78 = &D_80A41854[6]; + this->player.actor.textId = this->unk_D78->textId; + this->player.actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); + } +} + +void func_80A409D4(EnTest3* this, PlayState* play) { + if ((play->actorCtx.flags & ACTORCTX_FLAG_5) || (play->actorCtx.flags & ACTORCTX_FLAG_4)) { + play->actorCtx.flags &= ~ACTORCTX_FLAG_4; + func_80A3F0B0(this, play); + ActorCutscene_SetReturnCamera(CAM_ID_MAIN); + } else { + sEnTest3_Input = *CONTROLLER1(&play->state); + } +} + +void func_80A40A6C(EnTest3* this, PlayState* play) { + SET_WEEKEVENTREG(WEEKEVENTREG_64_20); +} + +void EnTest3_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTest3* this = THIS; + + sEnTest3_Input.rel.button = sEnTest3_Input.cur.button; + sEnTest3_Input.cur.button = 0; + sEnTest3_Input.rel.stick_x = 0; + sEnTest3_Input.rel.stick_y = 0; + + play->actorCtx.flags &= ~ACTORCTX_FLAG_7; + this->player.actor.draw = EnTest3_Draw; + D_80A41D48 = false; + this->player.actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); + if (Cutscene_CheckActorAction(play, 0x1FA) && + !((this->player.actor.category == ACTORCAT_PLAYER) && + ((play->actorCtx.flags & ACTORCTX_FLAG_5) || (play->actorCtx.flags & ACTORCTX_FLAG_4)))) { + if (this->player.csMode != 5) { + play->startPlayerCutscene(play, &this->player, 5); + } + play->actorCtx.flags &= ~ACTORCTX_FLAG_4; + } else if (this->player.actor.category == ACTORCAT_PLAYER) { + func_80A409D4(this, play); + } else if (play->startPlayerCutscene(play, &this->player, 0)) { + if (this->unk_D88 >= 7) { + Vec3f worldPos; + + Math_Vec3f_Copy(&worldPos, &this->player.actor.world.pos); + this->unk_D80 = 4; + func_80A40230(this, play); + Math_Vec3f_Copy(&this->player.actor.world.pos, &worldPos); + D_80A41D48 = false; + this->unk_D84 = 0.0f; + } + } else { + D_80A41D40 = 0.0f; + D_80A41D44 = this->player.actor.shape.rot.y; + this->unk_D94(this, play); + sEnTest3_Input.press.button = + (sEnTest3_Input.rel.button ^ sEnTest3_Input.cur.button) & sEnTest3_Input.cur.button; + func_800B6F20(play, &sEnTest3_Input, D_80A41D40, D_80A41D44); + } + play->playerUpdate(&this->player, play, &sEnTest3_Input); + if (D_80A41D48) { + this->player.actor.world.pos.x = D_80A41D50.x; + this->player.actor.world.pos.z = D_80A41D50.z; + this->player.linearVelocity = 0.0f; + } +} + +s32 D_80A418C8 = false; + +s32 EnTest3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnTest3* this = THIS; + + if (limbIndex == OBJECT_TEST3_LIMB_01) { + D_80A41D6C = &this->player.bodyPartsPos[-1]; + if (!(this->player.skelAnime.moveFlags & ANIM_FLAG_4) || (this->player.skelAnime.moveFlags & ANIM_FLAG_1)) { + pos->x *= this->player.ageProperties->unk_08; + pos->z *= this->player.ageProperties->unk_08; + } + if (!(this->player.skelAnime.moveFlags & ANIM_FLAG_4) || + (this->player.skelAnime.moveFlags & ANIM_FLAG_UPDATEY)) { + pos->y *= this->player.ageProperties->unk_08; + } + pos->y -= this->player.unk_AB8; + if (this->player.unk_AAA != 0) { + + Matrix_Translate(pos->x, ((Math_CosS(this->player.unk_AAA) - 1.0f) * 200.0f) + pos->y, pos->z, + MTXMODE_APPLY); + Matrix_RotateXS(this->player.unk_AAA, MTXMODE_APPLY); + Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); + func_80125318(pos, rot); + } + } else { + if (*dList != NULL) { + D_80A41D6C++; + } + if (D_80A418C8) { + *dList = NULL; + } + if (limbIndex == OBJECT_TEST3_LIMB_0B) { + rot->x += this->player.unk_AAC.z; + rot->y -= this->player.unk_AAC.y; + rot->z += this->player.unk_AAC.x; + } else if (limbIndex == OBJECT_TEST3_LIMB_0A) { + s32 requiredScopeTemp; + + if (this->player.unk_AA8 != 0) { + Matrix_RotateZS(0x44C, MTXMODE_APPLY); + Matrix_RotateYS(this->player.unk_AA8, MTXMODE_APPLY); + } + if (this->player.unk_AB2.y != 0) { + Matrix_RotateYS(this->player.unk_AB2.y, MTXMODE_APPLY); + } + Matrix_RotateXS(this->player.unk_AB2.x, MTXMODE_APPLY); + if (this->player.unk_AB2.z != 0) { + Matrix_RotateZS(this->player.unk_AB2.z, MTXMODE_APPLY); + } + } else { + func_80125500(play, &this->player, limbIndex, pos, rot); + } + } + return false; +} + +void EnTest3_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, Actor* thisx) { + s32 pad; + EnTest3* this = THIS; + + if (*dList2 != NULL) { + Matrix_MultZero(D_80A41D6C); + } + if (limbIndex == OBJECT_TEST3_LIMB_10) { + MtxF curMtxF; + Actor* leftHandActor; + + Math_Vec3f_Copy(&this->player.leftHandWorld.pos, D_80A41D6C); + if (*dList1 != NULL) { + func_80128640(play, &this->player, *dList1); + if (this->player.stateFlags3 & PLAYER_STATE3_20000000) { + OPEN_DISPS(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_test3_DL_00EDD0); + CLOSE_DISPS(play->state.gfxCtx); + } + } + leftHandActor = this->player.heldActor; + if ((leftHandActor != NULL) && (this->player.stateFlags1 & PLAYER_STATE1_800)) { + Vec3s curRot; + + Matrix_Get(&curMtxF); + Matrix_MtxFToYXZRot(&curMtxF, &curRot, false); + leftHandActor->world.rot.y = this->player.actor.shape.rot.y + this->player.leftHandWorld.rot.y; + leftHandActor->shape.rot.y = leftHandActor->world.rot.y; + } else { + Matrix_Get(&this->player.mf_CC4); + Matrix_MtxFToYXZRot(&this->player.mf_CC4, &this->player.leftHandWorld.rot, false); + func_80126B8C(play, &this->player); + } + + } else if (limbIndex == OBJECT_TEST3_LIMB_13) { + Actor* leftHandActor = this->player.heldActor; + + if (leftHandActor != NULL) { + leftHandActor->world.pos.x = (this->player.bodyPartsPos[15].x + this->player.leftHandWorld.pos.x) / 2.0f; + leftHandActor->world.pos.y = (this->player.bodyPartsPos[15].y + this->player.leftHandWorld.pos.y) / 2.0f; + leftHandActor->world.pos.z = (this->player.bodyPartsPos[15].z + this->player.leftHandWorld.pos.z) / 2.0f; + } + } else if (limbIndex == OBJECT_TEST3_LIMB_0B) { + Actor* actor730 = this->player.targetedActor; + + if ((*dList1 != NULL) && this->player.currentMask && !(this->player.stateFlags2 & PLAYER_STATE2_1000000)) { + // this->player.currentMask != PLAYER_MASK_NONE + if ((this->player.skelAnime.animation != &gPlayerAnim_cl_maskoff) && + ((this->player.skelAnime.animation != &gPlayerAnim_cl_setmask) || + (this->player.skelAnime.curFrame >= 12.0f))) { + if (func_80127438(play, &this->player, this->player.currentMask)) { + OPEN_DISPS(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_mask_ki_tan_DL_0004A0); + CLOSE_DISPS(play->state.gfxCtx); + } + } + } + if ((actor730 != NULL) && (actor730->id == ACTOR_BG_IKNV_OBJ)) { + Math_Vec3f_Copy(&this->player.actor.focus.pos, &actor730->focus.pos); + } else { + static Vec3f D_80A418CC = { 1100.0f, -700.0f, 0.0f }; + + Matrix_MultVec3f(&D_80A418CC, &this->player.actor.focus.pos); + } + } else if (limbIndex == OBJECT_TEST3_LIMB_15) { + if (D_80A41D60 || CHECK_WEEKEVENTREG(WEEKEVENTREG_50_80) || + (INV_CONTENT(ITEM_PENDANT_OF_MEMORIES) == ITEM_PENDANT_OF_MEMORIES) || + (this->player.getItemDrawId - 1 == GID_PENDANT_OF_MEMORIES)) { + D_80A41D60 = true; + } else { + OPEN_DISPS(play->state.gfxCtx); + gSPDisplayList(POLY_OPA_DISP++, object_test3_DL_00CB60); + CLOSE_DISPS(play->state.gfxCtx); + } + } else { + func_80128B74(play, &this->player, limbIndex); + } +} + +static TexturePtr sEyeTextures[] = { + object_test3_Tex_000DC0, object_test3_Tex_003680, object_test3_Tex_003E80, object_test3_Tex_004680, + object_test3_Tex_004E80, object_test3_Tex_005680, object_test3_Tex_005E80, object_test3_Tex_006680, +}; + +static TexturePtr sMouthTextures[] = { + object_test3_Tex_0009C0, + object_test3_Tex_006E80, + object_test3_Tex_007280, + object_test3_Tex_007680, +}; + +typedef struct { + /* 0x0 */ u8 eyeIndex; + /* 0x1 */ u8 mouthIndex; +} KafeiFace; // size = 0x2 + +static KafeiFace sFaceExpressions[] = { + { 0, 0 }, { 1, 0 }, { 2, 0 }, { 0, 0 }, { 1, 0 }, { 2, 0 }, { 4, 0 }, { 5, 1 }, { 7, 2 }, { 0, 2 }, + { 3, 0 }, { 4, 0 }, { 2, 2 }, { 1, 1 }, { 0, 2 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, +}; + +void EnTest3_Draw(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTest3* this = THIS; + s32 eyeTexIndex = (this->player.skelAnime.jointTable[OBJECT_TEST3_LIMB_MAX].x & 0xF) - 1; + s32 mouthTexIndex = ((this->player.skelAnime.jointTable[OBJECT_TEST3_LIMB_MAX].x >> 4) & 0xF) - 1; + Gfx* gfx; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C268(play); + if (this->player.invincibilityTimer > 0) { + s32 temp2; // Must exist for stack order. Could hold the result of CLAMP instead. + + this->player.unk_B5F += CLAMP(50 - this->player.invincibilityTimer, 8, 40); + temp2 = Math_CosS(this->player.unk_B5F * 0x100) * 2000.0f; + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 0, 0, 4000 - temp2); + } + func_800B8050(&this->player.actor, play, 0); + D_80A418C8 = false; + if (this->player.stateFlags1 & PLAYER_STATE1_100000) { + Vec3f sp4C; + + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &this->player.actor.focus.pos, &sp4C); + if (sp4C.z < -4.0f) { + D_80A418C8 = true; + } + } + + gfx = POLY_OPA_DISP; + + if (eyeTexIndex < 0) { + eyeTexIndex = sFaceExpressions[this->player.actor.shape.face].eyeIndex; + } + gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(sEyeTextures[eyeTexIndex])); + if (mouthTexIndex < 0) { + mouthTexIndex = sFaceExpressions[this->player.actor.shape.face].mouthIndex; + } + gSPSegment(&gfx[1], 0x09, Lib_SegmentedToVirtual(sMouthTextures[mouthTexIndex])); + + POLY_OPA_DISP = &gfx[2]; + + SkelAnime_DrawFlexLod(play, this->player.skelAnime.skeleton, this->player.skelAnime.jointTable, + this->player.skelAnime.dListCount, EnTest3_OverrideLimbDraw, EnTest3_PostLimbDraw, + &this->player.actor, 0); + if (this->player.invincibilityTimer > 0) { + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + } + if ((this->player.getItemDrawId - 1) != GID_NONE) { + Player_DrawGetItem(play, &this->player); + } + CLOSE_DISPS(play->state.gfxCtx); +} 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..a4f1ff659 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.h +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.h @@ -5,15 +5,37 @@ struct EnTest3; -typedef void (*EnTest3ActionFunc)(struct EnTest3*, GlobalContext*); +typedef void (*EnTest3ActionFunc)(struct EnTest3*, PlayState*); + +#define KAFEI_GET_PARAM_1F(thisx) ((thisx)->params & 0x1F) +#define KAFEI_GET_PARAM_1E0(thisx) (((thisx)->params >> 5) & 0xF) + +typedef struct { + /* 0x0 */ u8 unk_0; + /* 0x1 */ u8 unk_1; + /* 0x2 */ u16 textId; +} EnTest3_struct_D78; // size = 0x4 typedef struct EnTest3 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x628]; - /* 0x076C */ EnTest3ActionFunc actionFunc; - /* 0x0770 */ char unk_770[0x648]; + /* 0x000 */ Player player; + /* 0xD78 */ EnTest3_struct_D78* unk_D78; + /* 0xD7C */ Path* unk_D7C; + /* 0xD80 */ s32 unk_D80; + /* 0xD84 */ f32 unk_D84; + /* 0xD88 */ s8 unk_D88; + /* 0xD89 */ u8 unk_D89; + /* 0xD8A */ s16 unk_D8A; + /* 0xD8C */ u8 unk_D8C; + /* 0xD8D */ s8 unk_D8D; + /* 0xD8E */ s16 subCamId; + /* 0xD90 */ Player* unk_D90; + /* 0xD94 */ EnTest3ActionFunc unk_D94; + /* 0xD98 */ Vec3f unk_D98; + /* 0xDA4 */ f32 unk_DA4; + /* 0xDA8 */ s32 unk_DA8; + /* 0xDAC */ s32 unk_DAC; + /* 0xDB0 */ s32 unk_DB0; + /* 0xDB4 */ s32 unk_DB4; } EnTest3; // size = 0xDB8 -extern const ActorInit En_Test3_InitVars; - #endif // Z_EN_TEST3_H diff --git a/src/overlays/actors/ovl_En_Test4/overlay.cfg b/src/overlays/actors/ovl_En_Test4/overlay.cfg deleted file mode 100644 index 06bfe7839..000000000 --- a/src/overlays/actors/ovl_En_Test4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Test4 -z_en_test4.c 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..1dcb6ccb4 100644 --- a/src/overlays/actors/ovl_En_Test4/z_en_test4.c +++ b/src/overlays/actors/ovl_En_Test4/z_en_test4.c @@ -1,9 +1,10 @@ /* * File: z_en_test4.c * Overlay: ovl_En_Test4 - * Description: Three-Day Timer + * Description: Three-Day Events */ +#include "prevent_bss_reordering.h" #include "z_en_test4.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" #include "overlays/actors/ovl_En_Horse/z_en_horse.h" @@ -12,14 +13,14 @@ #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 = { +ActorInit En_Test4_InitVars = { ACTOR_EN_TEST4, ACTORCAT_SWITCH, FLAGS, @@ -45,32 +46,32 @@ 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.flags & ACTORCTX_FLAG_1)) { + if (play->actorCtx.flags & ACTORCTX_FLAG_1) { 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); + Interface_NewDay(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.flags & ACTORCTX_FLAG_1)) { this->actionFunc = func_80A42F20; sCurrentCs = sCutscenes[this->unk_144]; this->transitionCsTimer = 0; - gSaveContext.eventInf[1] |= 0x80; + SET_EVENTINF(EVENTINF_17); } else if (this->unk_144 == 0) { play_sound(NA_SE_EV_CHICKEN_CRY_M); } else { @@ -88,26 +89,26 @@ 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.flags & ACTORCTX_FLAG_1)) { Sram_IncrementDay(); gSaveContext.save.time = CLOCK_TIME(6, 0); - func_8010EE74(globalCtx, CURRENT_DAY); - func_80151A68(globalCtx, sDayMessages2[CURRENT_DAY - 1]); + Interface_NewDay(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.flags & ACTORCTX_FLAG_1)) { this->actionFunc = func_80A42F20; sCurrentCs = sCutscenes[this->unk_144]; this->transitionCsTimer = 0; - gSaveContext.eventInf[1] |= 0x80; + SET_EVENTINF(EVENTINF_17); } else if (this->unk_144 == 0) { play_sound(NA_SE_EV_CHICKEN_CRY_M); } else { @@ -239,7 +240,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 +278,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.flags & ACTORCTX_FLAG_1) || (CURRENT_DAY == 3) || (gSaveContext.save.time >= CLOCK_TIME(17, 0))) { gSaveContext.screenScale = 1000.0f; } @@ -287,25 +288,25 @@ 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; if (temp_v0 >= 0) { ActorCutscene* temp_v0_2 = ActorCutscene_GetCutscene(sCutscenes[0]); - gSaveContext.eventInf[5] |= 0x4; + SET_EVENTINF(EVENTINF_52); sCutscenes[1] = temp_v0_2->additionalCutscene; } else { - gSaveContext.eventInf[5] &= (u8)~0x4; + CLEAR_EVENTINF(EVENTINF_52); sCutscenes[1] = sCutscenes[0]; } - if (sIsLoaded || (gSaveContext.eventInf[2] & 0x80)) { - Actor_MarkForDeath(&this->actor); + if (sIsLoaded || (CHECK_EVENTINF(EVENTINF_27))) { + Actor_Kill(&this->actor); } else { sIsLoaded = true; this->actor.room = -1; @@ -315,15 +316,11 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { if (gSaveContext.save.time < CLOCK_TIME(6, 1)) { gSaveContext.save.time = CLOCK_TIME(6, 0); gSaveContext.gameMode = 0; - { - GameState* state = &globalCtx->state; - state->running = false; - } - SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext); - if (this && this && this) {} + STOP_GAMESTATE(&play->state); + SET_NEXT_GAMESTATE(&play->state, DayTelop_Init, sizeof(DayTelopState)); this->unk_144 = 1; gSaveContext.save.time = CLOCK_TIME(6, 0); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } else { gSaveContext.save.day = 1; dayTemp = gSaveContext.save.day; @@ -334,10 +331,10 @@ void EnTest4_Init(Actor* thisx, GlobalContext* globalCtx) { } } else if (gSaveContext.save.time == CLOCK_TIME(6, 0)) { this->unk_144 = 0; - func_80A41D70(this, globalCtx); + func_80A41D70(this, play); if ((gSaveContext.cutsceneTrigger == 0) && (sCutscenes[this->unk_144] >= 0) && - !(globalCtx->actorCtx.unk5 & 2)) { - player->stateFlags1 |= 0x200; + !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + player->stateFlags1 |= PLAYER_STATE1_200; } } else { if ((gSaveContext.save.time > CLOCK_TIME(18, 0)) || (gSaveContext.save.time < CLOCK_TIME(6, 0))) { @@ -353,24 +350,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.flags & ACTORCTX_FLAG_1)) { 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 +381,29 @@ 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.flags & ACTORCTX_FLAG_PICTO_BOX_ON) { + play->actorCtx.flags &= ~ACTORCTX_FLAG_PICTO_BOX_ON; } 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); - 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); + Interface_StartMoonCrash(play); + Actor_Kill(&this->actor); + SET_EVENTINF(EVENTINF_17); + } else if (((sCutscenes[this->unk_144] < 0) || (play->actorCtx.flags & ACTORCTX_FLAG_1)) && + (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); - if (player->stateFlags1 & 0x800000) { + Play_SetRespawnData(&play->state, RESPAWN_MODE_DOWN, Entrance_CreateFromSpawn(0), player->unk_3CE, + PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &player->unk_3C0, player->unk_3CC); + func_80169EFC(&play->state); + if (player->stateFlags1 & PLAYER_STATE1_800000) { 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 { @@ -415,13 +413,13 @@ void func_80A42AB8(EnTest4* this, GlobalContext* globalCtx) { } gSaveContext.respawnFlag = -4; - gSaveContext.eventInf[2] |= 0x80; - Actor_MarkForDeath(&this->actor); + SET_EVENTINF(EVENTINF_27); + Actor_Kill(&this->actor); } } - if ((sCutscenes[this->unk_144] >= 0) && ((globalCtx->actorCtx.unk5 & 2) == 0)) { - player->stateFlags1 |= 0x200; + if ((sCutscenes[this->unk_144] >= 0) && !(play->actorCtx.flags & ACTORCTX_FLAG_1)) { + player->stateFlags1 |= PLAYER_STATE1_200; this->unk_146 = gSaveContext.save.time; } else { if (this->unk_144 == 0) { @@ -439,38 +437,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->sceneId == SCENE_CLOCKTOWER))) { s32 playerParams; - u32 entranceIndex = gSaveContext.save.entranceIndex; + u32 entrance = gSaveContext.save.entrance; - if ((globalCtx->actorCtx.unk5 & 2)) { - playerParams = 0xCFF; + if ((play->actorCtx.flags & ACTORCTX_FLAG_1)) { + playerParams = PLAYER_PARAMS(0xFF, PLAYER_INITMODE_TELESCOPE); } else { - playerParams = 0xBFF; + playerParams = PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B); } - 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->sceneId == SCENE_TENMON_DAI) || (play->sceneId == 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; - player->stateFlags1 |= 0x200; - Actor_MarkForDeath(&this->actor); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + player->stateFlags1 |= PLAYER_STATE1_200; + Actor_Kill(&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,12 +490,12 @@ 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; - player->stateFlags1 &= ~0x200; + play->numSetupActors = -play->numSetupActors; + player->stateFlags1 &= ~PLAYER_STATE1_200; } } else { this->actionFunc = func_80A42AB8; @@ -510,51 +508,52 @@ void func_80A42F20(EnTest4* this, GlobalContext* globalCtx) { if (sCurrentCs >= 0) { ActorCutscene_Stop(sCurrentCs); } - gSaveContext.unk_3F22 = 0; - gSaveContext.eventInf[1] &= (u8)~0x80; - Interface_ChangeAlpha(50); + + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + CLEAR_EVENTINF(EVENTINF_17); + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); } } -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); + if (!(player->stateFlags1 & PLAYER_STATE1_2)) { + 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..0a372f245 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 { @@ -23,6 +23,4 @@ typedef enum { /* 1 */ TEST4_STATE_1 } EnTest4State; -extern const ActorInit En_Test4_InitVars; - #endif // Z_EN_TEST4_H diff --git a/src/overlays/actors/ovl_En_Test5/overlay.cfg b/src/overlays/actors/ovl_En_Test5/overlay.cfg deleted file mode 100644 index 9ad6cee31..000000000 --- a/src/overlays/actors/ovl_En_Test5/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Test5 -z_en_test5.c 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..83451fa02 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.c +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.c @@ -10,13 +10,13 @@ #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* play2); +void EnTest5_Destroy(Actor* thisx, PlayState* play); +void EnTest5_Update(Actor* thisx, PlayState* play2); +void EnTest5_HandleBottleAction(EnTest5* this, PlayState* play); void EnTest5_SetupAction(EnTest5* this, EnTest5ActionFunc actionFunc); -const ActorInit En_Test5_InitVars = { +ActorInit En_Test5_InitVars = { ACTOR_EN_TEST5, ACTORCAT_ITEMACTION, FLAGS, @@ -32,16 +32,16 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (!WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, + &water)) { + Actor_Kill(&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..8d0c47784 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.h +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.h @@ -7,16 +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; - #endif // Z_EN_TEST5_H diff --git a/src/overlays/actors/ovl_En_Test6/overlay.cfg b/src/overlays/actors/ovl_En_Test6/overlay.cfg deleted file mode 100644 index 35635730d..000000000 --- a/src/overlays/actors/ovl_En_Test6/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Test6 -z_en_test6.c 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 2efb3eb6b..c0915fce6 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -5,20 +5,21 @@ */ #include "z_en_test6.h" +#include "z64quake.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_200000 | ACTOR_FLAG_2000000) #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* play2); +void EnTest6_Destroy(Actor* thisx, PlayState* play2); +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,19 +30,19 @@ 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]; -const ActorInit En_Test6_InitVars = { +ActorInit En_Test6_InitVars = { ACTOR_EN_TEST6, ACTORCAT_ITEMACTION, FLAGS, @@ -80,13 +81,7 @@ u8 D_80A93E80[] = { }; TexturePtr D_80A9402C[] = { - NULL, - gameplay_keep_Tex_05B6F0, - gameplay_keep_Tex_05CEF0, - gameplay_keep_Tex_0607C0, - gameplay_keep_Tex_060FC0, - gameplay_keep_Tex_061FC0, - gameplay_keep_Tex_061FE0, + NULL, gDropArrows2Tex, gDropBombTex, gDropDekuNutTex, gDropDekuStickTex, gRupeeGreenTex, gRupeeBlueTex, }; Color_RGB8 D_80A94048 = { 230, 230, 220 }; @@ -96,7 +91,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 +100,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,20 +112,20 @@ 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; } phi_s0 = 0; phi_f24 = -900.0f; - if (gSaveContext.eventInf[7] & 1) { + if (CHECK_EVENTINF(EVENTINF_70)) { for (i = 0; i < 6; i++) { D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 5; } @@ -139,7 +134,7 @@ void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { phi_s0 |= 1; } - if (gSaveContext.eventInf[7] & 0x10) { + if (CHECK_EVENTINF(EVENTINF_74)) { D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 1; if (!(phi_s0 & 1)) { @@ -149,7 +144,7 @@ void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { phi_s0 |= 0x10; } - if (gSaveContext.eventInf[7] & 2) { + if (CHECK_EVENTINF(EVENTINF_71)) { D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 2; if (!(phi_s0 & 1)) { @@ -159,7 +154,7 @@ void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { phi_s0 |= 2; } - if (gSaveContext.eventInf[7] & 4) { + if (CHECK_EVENTINF(EVENTINF_72)) { D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 3; @@ -167,7 +162,7 @@ void func_80A90730(EnTest6* this, GlobalContext* globalCtx) { phi_s0 |= 4; } - if (gSaveContext.eventInf[7] & 8) { + if (CHECK_EVENTINF(EVENTINF_73)) { D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; if (!(phi_s0 & (0x10 | 0x2 | 0x1))) { D_80A94910[(s32)(Rand_ZeroOne() * ARRAY_COUNT(D_80A94910))].unk_00 = 4; @@ -196,43 +191,43 @@ 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_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); - gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); } Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(2.0f * ptr->unk_04, 2.0f * ptr->unk_04, 2.0f * ptr->unk_04, MTXMODE_APPLY); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZS(globalCtx->state.frames * 512, MTXMODE_APPLY); + Matrix_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); @@ -240,13 +235,13 @@ void func_80A90D34(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) 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* gfx2 = gfx; + Gfx* gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; Hilite* sp70; Vec3f sp64; @@ -254,37 +249,37 @@ 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); + if (gfxHead != NULL) { + 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); - gSPEndDisplayList(gfx); + gSPEndDisplayList(gfx++); - gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); + gSPSegment(POLY_OPA_DISP++, 0x07, gfxHead); Matrix_Translate(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + 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); + gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); } Matrix_Translate(ptr->unk_08 * ptr->unk_04, ptr->unk_0C, ptr->unk_10 * ptr->unk_04, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, ptr->unk_04 * 2.5f, MTXMODE_APPLY); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_RotateZS(globalCtx->state.frames * 256, MTXMODE_APPLY); + Matrix_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); @@ -292,84 +287,84 @@ void func_80A90FC0(EnTest6* this, GlobalContext* globalCtx, EnTest6Struct* ptr) 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)) { - Actor_MarkForDeath(&this->actor); + (play->playerActorCsIds[8] == -1)) { + Actor_Kill(&this->actor); return; } for (i = 0; i < ARRAY_COUNT(this->lights); i++) { Lights_PointNoGlowSetInfo(&this->lights[i].info, this->actor.world.pos.x, (s32)this->actor.world.pos.y - 20, this->actor.world.pos.z, 255, 255, 180, -1); - this->lights[i].node = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &this->lights[i].info); + this->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 +378,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 +389,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, PLAYER_CSMODE_6); func_80A90C34(); - Distortion_ClearType(0x20); - Actor_MarkForDeath(&this->actor); + Distortion_ClearType(DISTORTION_TYPE_5); + Actor_Kill(&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 +427,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 +454,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_SetType(DISTORTION_TYPE_5); Distortion_SetCountdown(80); - globalCtx->unk_18844 = 1; + play->unk_18844 = 1; this->unk_274 = 95; } break; @@ -484,10 +479,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; @@ -523,8 +518,8 @@ void func_80A91760(EnTest6* this, GlobalContext* globalCtx) { if (this->unk_27A == 10) { this->unk_14C = 0.1f; func_80A90C34(); - Distortion_ClearType(0x20); - globalCtx->unk_18844 = 0; + Distortion_ClearType(DISTORTION_TYPE_5); + play->unk_18844 = 0; if (this->unk_254 != NULL) { ZeldaArena_Free(this->unk_254); } @@ -534,57 +529,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, PLAYER_CSMODE_7); } else { if (this->unk_27A == 90) { - func_800B7298(globalCtx, NULL, 0x42); + func_800B7298(play, NULL, PLAYER_CSMODE_66); } if (this->unk_27A == 70) { - func_800B7298(globalCtx, NULL, 0x52); + func_800B7298(play, NULL, PLAYER_CSMODE_82); } if (this->unk_27A == 30) { - func_800B7298(globalCtx, NULL, 0x51); + func_800B7298(play, NULL, PLAYER_CSMODE_81); } if (this->unk_27A == 5) { - func_800B7298(globalCtx, NULL, 0x4A); + func_800B7298(play, NULL, PLAYER_CSMODE_74); } } 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 +588,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 +610,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, PLAYER_CSMODE_6); func_80A90C34(); - Distortion_ClearType(0x20); - Actor_MarkForDeath(&this->actor); + Distortion_ClearType(DISTORTION_TYPE_5); + Actor_Kill(&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); @@ -690,13 +685,13 @@ void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { case 115: func_80A90C08(0x14); - Distortion_SetType(0x20); + Distortion_SetType(DISTORTION_TYPE_5); Distortion_SetCountdown(90); this->unk_274 = 2; break; case 110: - func_801A3098(0x4A); + Audio_PlayFanfare(NA_BGM_SONG_OF_DOUBLE_TIME); break; case 38: @@ -721,38 +716,38 @@ void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { case 14: case 15: func_80A90C08(0x32); - Distortion_ClearType(0x20); + Distortion_ClearType(DISTORTION_TYPE_5); this->unk_274 = 0; break; case 1: func_80A90C34(); - if (gSaveContext.eventInf[5] & 4) { + if (CHECK_EVENTINF(EVENTINF_52)) { this->unk_274 = 9; } 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 +764,23 @@ void func_80A92188(EnTest6* this, GlobalContext* globalCtx) { break; case 98: - func_800B7298(globalCtx, NULL, 0x40); + func_800B7298(play, NULL, PLAYER_CSMODE_64); break; case 68: - func_800B7298(globalCtx, NULL, 0x41); + func_800B7298(play, NULL, PLAYER_CSMODE_65); break; case 52: - func_800B7298(globalCtx, NULL, 0x58); + func_800B7298(play, NULL, PLAYER_CSMODE_88); break; case 43: - func_800B7298(globalCtx, NULL, 0x72); + func_800B7298(play, NULL, PLAYER_CSMODE_114); break; case 38: - func_800B7298(globalCtx, NULL, 7); + func_800B7298(play, NULL, PLAYER_CSMODE_7); break; case 14: @@ -801,7 +796,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 +810,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 +841,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 +881,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 +922,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 +943,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 +952,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 +971,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, + PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &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; + SET_EVENTINF(EVENTINF_27); } else { gSaveContext.respawnFlag = 2; } - globalCtx->msgCtx.ocarinaMode = 4; + play->msgCtx.ocarinaMode = 4; return; } } else { @@ -1057,14 +1052,15 @@ 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), - player->unk_3CE, 0xBFF, &player->unk_3C0, player->unk_3CC); + Play_SetRespawnData(&play->state, 1, ((void)0, gSaveContext.save.entrance & 0xFFFF), + player->unk_3CE, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &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 +1088,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 +1097,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); @@ -1122,11 +1118,11 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); Matrix_RotateZS(phi_s2, MTXMODE_APPLY); - gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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); - gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); temp_s4 += 0x1000; cos = Math_CosS(temp_s4) * this->unk_150; @@ -1136,11 +1132,11 @@ void func_80A93298(EnTest6* this, GlobalContext* globalCtx) { Matrix_Scale(0.8f, 0.8f, 0.8f, MTXMODE_APPLY); Matrix_RotateZS(-phi_s2, MTXMODE_APPLY); - gSPMatrix(this->unk_148++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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); - gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); phi_f24 -= this->unk_14C; phi_s2 += this->unk_27E; @@ -1150,32 +1146,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) { @@ -1209,11 +1205,11 @@ void func_80A9369C(Actor* thisx, GlobalContext* globalCtx2) { 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); - gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); phi_s2 += 0x505; } @@ -1224,16 +1220,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: @@ -1252,12 +1248,12 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { 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); gDPSetRenderMode(this->unk_148++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); - gSPDisplayList(this->unk_148++, gameplay_keep_DL_07AFB0); + gSPDisplayList(this->unk_148++, gSongOfTimeClockDL); POLY_XLU_DISP = this->unk_148; } @@ -1271,13 +1267,13 @@ void func_80A939E8(EnTest6* this, GlobalContext* globalCtx2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 128, 128, 128, this->unk_282 >> 1); gDPSetEnvColor(POLY_XLU_DISP++, 230, 230, 180, this->unk_282); - func_8012C2DC(globalCtx->state.gfxCtx); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + 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); + gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } } Lights_PointSetPosition(&this->lights[0].info, player->actor.world.pos.x, player->actor.world.pos.y - 10.0f, @@ -1295,24 +1291,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..ec06afb91 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,37 +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; - #endif // Z_EN_TEST6_H diff --git a/src/overlays/actors/ovl_En_Test7/overlay.cfg b/src/overlays/actors/ovl_En_Test7/overlay.cfg deleted file mode 100644 index 5a898f7c0..000000000 --- a/src/overlays/actors/ovl_En_Test7/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Test7 -z_en_test7.c 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 8aacf408d..43facd831 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -11,30 +11,30 @@ #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* play2); +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 = { +ActorInit En_Test7_InitVars = { ACTOR_EN_TEST7, ACTORCAT_ITEMACTION, FLAGS, @@ -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,17 +320,17 @@ 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_Push(); @@ -362,7 +362,7 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { 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); @@ -373,7 +373,7 @@ void func_80AF14FC(GlobalContext* globalCtx2, EnTest7Struct2* arg1) { 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); @@ -409,54 +409,54 @@ void EnTest7_Init(Actor* thisx, GlobalContext* globalCtx2) { } else { func_80AF082C(this, func_80AF19A8); EnTest7_SetupAction(this, func_80AF2854); - func_801A2E54(NA_BGM_SONG_OF_SOARING); + Audio_PlayBgm_StorePrevBgm(NA_BGM_SONG_OF_SOARING); } - if (globalCtx->playerActorCsIds[8] == -1) { - Actor_MarkForDeath(&this->actor); + if (play->playerActorCsIds[8] == -1) { + Actor_Kill(&this->actor); return; } - ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[8]); - player2->stateFlags1 |= 0x20; + ActorCutscene_SetIntentToPlay(play->playerActorCsIds[8]); + player2->stateFlags1 |= PLAYER_STATE1_20; 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,63 +585,67 @@ 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; - MREG(65) = 255; - MREG(66) = 255; - MREG(67) = 255; - MREG(68) = 255; - globalCtx->unk_18844 = 0; + R_PLAY_FILL_SCREEN_ON = true; + R_PLAY_FILL_SCREEN_R = 255; + R_PLAY_FILL_SCREEN_G = 255; + R_PLAY_FILL_SCREEN_B = 255; + R_PLAY_FILL_SCREEN_ALPHA = 255; + 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 }; Color_RGB8 sp20 = { 220, 220, 255 }; - if (MREG(64) != 0) { + if (R_PLAY_FILL_SCREEN_ON) { Audio_PlaySfxAtPos(&this->actor.projectedPos, NA_SE_PL_WARP_WING_VANISH); - MREG(64) = 0; - MREG(65) = 0; - MREG(66) = 0; - MREG(67) = 0; - MREG(68) = 0; + R_PLAY_FILL_SCREEN_ON = false; + R_PLAY_FILL_SCREEN_R = 0; + R_PLAY_FILL_SCREEN_G = 0; + R_PLAY_FILL_SCREEN_B = 0; + R_PLAY_FILL_SCREEN_ALPHA = 0; } 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->sceneId == 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)) && CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + play->nextEntrance = ENTRANCE(SOUTHERN_SWAMP_CLEARED, 10); + } else if ((play->nextEntrance == ENTRANCE(MOUNTAIN_VILLAGE_WINTER, 8)) && + CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80)) { + play->nextEntrance = ENTRANCE(MOUNTAIN_VILLAGE_SPRING, 8); } } - globalCtx->sceneLoadFlag = 0x14; - globalCtx->unk_1887F = 2; - gSaveContext.seqIndex = 0xFF; - gSaveContext.nightSeqIndex = 0xFF; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_02; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } -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; + player->stateFlags2 |= PLAYER_STATE2_20000000; this->unk_144 |= 2; this->unk_148.unk_04 = 30.0f; - if (globalCtx->roomCtx.currRoom.unk3 != 1) { + if (play->roomCtx.curRoom.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); @@ -905,36 +911,36 @@ void func_80AF2F98(EnTest7* this, GlobalContext* globalCtx) { this->unk_148.unk_00 = this->unk_148.unk_04; this->unk_148.unk_08 = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; this->unk_148.unk_0C = ((this->unk_148.unk_04 * -0.29999998f) / 11.0f) + 0.7f; - player->stateFlags2 &= ~0x20000000; + player->stateFlags2 &= ~PLAYER_STATE2_20000000; } } -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; - player->stateFlags1 &= ~0x20000000; - Actor_MarkForDeath(&this->actor); + player->stateFlags1 &= ~PLAYER_STATE1_20; + player->stateFlags1 &= ~PLAYER_STATE1_20000000; + Actor_Kill(&this->actor); } } -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; @@ -945,16 +951,16 @@ s32 func_80AF31D0(GlobalContext* globalCtx, SkeletonInfo* skeletonInfo, s32 limb 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, this->unk_18CC.unk_18->unk_1 * sizeof(Mtx)); 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; } @@ -967,15 +973,14 @@ void EnTest7_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); + 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..30bf8e73c 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; @@ -62,6 +62,4 @@ typedef struct EnTest7 { /* 0x1E98 */ EnTest7UnkDrawFunc unk_1E98; } EnTest7; // size = 0x1E9C -extern const ActorInit En_Test7_InitVars; - #endif // Z_EN_TEST7_H diff --git a/src/overlays/actors/ovl_En_Tg/overlay.cfg b/src/overlays/actors/ovl_En_Tg/overlay.cfg deleted file mode 100644 index 99ad048ba..000000000 --- a/src/overlays/actors/ovl_En_Tg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tg -z_en_tg.c 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..947f97b62 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.c +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.c @@ -1,24 +1,27 @@ /* * File: z_en_tg.c * Overlay: ovl_En_Tg - * Description: Target Game (Honey & Darling) + * Description: Target Game (Honey & Darling) - End Credits Scene */ #include "z_en_tg.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) #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 EnTg_Idle(EnTg* this, PlayState* play); +void EnTg_UpdateHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects); +void EnTg_DrawHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects); +void EnTg_SpawnHeart(EnTg* this, EnTgHeartEffect* effect, Vec3f* heartStartPos, s32 numEffects); -#if 0 -const ActorInit En_Tg_InitVars = { +ActorInit En_Tg_InitVars = { ACTOR_EN_TG, ACTORCAT_NPC, FLAGS, @@ -30,18 +33,29 @@ const ActorInit En_Tg_InitVars = { (ActorFunc)EnTg_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809901C0 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT0, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 18, 64, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_809901EC = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -// static DamageTable sDamageTable = { -static DamageTable D_809901F8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(0, 0x0), /* Horse trample */ DMG_ENTRY(0, 0x0), @@ -76,37 +90,193 @@ static DamageTable D_809901F8 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -#endif +static AnimationInfoS sAnimationInfo[] = { + { &gHoneyAndDarlingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +}; -extern ColliderCylinderInit D_809901C0; -extern CollisionCheckInfoInit2 D_809901EC; -extern DamageTable D_809901F8; +void EnTg_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s16 animIndex) { + f32 endFrame; -extern UNK_TYPE D_0600B0E0; -extern UNK_TYPE D_0600B2B0; + animationInfo += animIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098F800.s") + if (animationInfo->frameCount < 0) { + endFrame = Animation_GetLastFrame(animationInfo->animation); + } else { + endFrame = animationInfo->frameCount; + } + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, endFrame, + animationInfo->mode, animationInfo->morphFrames); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098F8A8.s") +void EnTg_UpdateCollider(EnTg* 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(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098F928.s") +void EnTg_UpdateSkelAnime(EnTg* this, PlayState* play) { + SkelAnime_Update(&this->skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/EnTg_Init.s") +void EnTg_Init(Actor* thisx, PlayState* play) { + EnTg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/EnTg_Destroy.s") + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gHoneyAndDarlingSkel, NULL, this->jointTable, this->morphTable, + HONEY_AND_DARLING_LIMB_MAX); + EnTg_ChangeAnim(&this->skelAnime, sAnimationInfo, 0); + 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); + this->actionFunc = EnTg_Idle; + this->actor.gravity = -4.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FA70.s") +void EnTg_Destroy(Actor* thisx, PlayState* play) { + EnTg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/EnTg_Update.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FBB4.s") +/** + * The actor spins, and a heart is spawned above the actor every 12 frames. + */ +void EnTg_Idle(EnTg* this, PlayState* play) { + Vec3f heartStartPos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FBD0.s") + this->actor.shape.rot.y += sREG(0) + 0x258; + this->actor.world.rot = this->actor.shape.rot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/EnTg_Draw.s") + if (DECR(this->spawnHeartTimer) == 0) { + this->spawnHeartTimer = 12; + heartStartPos = this->actor.world.pos; + heartStartPos.y += 62.0f; + EnTg_SpawnHeart(this, this->effects, &heartStartPos, ARRAY_COUNT(this->effects)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FD50.s") +void EnTg_Update(Actor* thisx, PlayState* play) { + EnTg* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8098FEA8.s") + this->actionFunc(this, play); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + EnTg_UpdateSkelAnime(this, play); + EnTg_UpdateHearts(play, this->effects, ARRAY_COUNT(this->effects)); + EnTg_UpdateCollider(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tg/func_8099000C.s") +s32 EnTg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void EnTg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnTg* this = THIS; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == HONEY_AND_DARLING_LIMB_MAN_HEAD) { + Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); + } +} + +void EnTg_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnTg* this = THIS; + + Matrix_Push(); + EnTg_DrawHearts(play, this->effects, ARRAY_COUNT(this->effects)); + Matrix_Pop(); + + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + 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, + EnTg_OverrideLimbDraw, EnTg_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} + +/** + * Spawns a heart at the first effects array index that's not enabled. + * Because of the frame counts, only two hearts are ever spawned at a time. + */ +void EnTg_SpawnHeart(EnTg* this, EnTgHeartEffect* effect, Vec3f* heartStartPos, s32 numEffects) { + Vec3f heartVelocity = { 0.0f, 1.5f, 0.0f }; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s32 i; + + for (i = 0; i < numEffects && effect->isEnabled; i++, effect++) {} + + if (i < numEffects) { + effect->isEnabled = true; + effect->pos = *heartStartPos; + effect->velocity = heartVelocity; + effect->unusedZeroVec = zeroVec; + effect->scale = 0.01f; + effect->pos.x += 4.0f * Math_SinS(this->actor.shape.rot.y); + effect->pos.z += 4.0f * Math_CosS(this->actor.shape.rot.y); + effect->timer = 16; + } +} + +/** + * The heart path is curvy as it floats up because of the use of Math_SinS and Math_CosS. + */ +void EnTg_UpdateHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects) { + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; + s16 yaw = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); + s32 i; + + for (i = 0; i < numEffects; i++, effect++) { + if (effect->isEnabled == true) { + if (DECR(effect->timer) == 0) { + effect->isEnabled = false; + } + effect->pos.y += effect->velocity.y; + effect->pos.x += 2.0f * Math_SinS(effect->angle); + effect->pos.z += 2.0f * Math_CosS(effect->angle); + + Matrix_Push(); + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_RotateYS(yaw, MTXMODE_APPLY); + Matrix_MultVec3f(&zeroVec, &effect->pos); + Matrix_Pop(); + + effect->angle += 0x1770; + } + } +} + +void EnTg_DrawHearts(PlayState* play, EnTgHeartEffect* effect, s32 numEffects) { + s32 i; + s32 isMaterialApplied = false; + + OPEN_DISPS(play->state.gfxCtx); + + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + POLY_OPA_DISP = func_8012C724(POLY_OPA_DISP); + + for (i = 0; i < numEffects; i++, effect++) { + if (effect->isEnabled == true) { + if (!isMaterialApplied) { + gSPDisplayList(POLY_OPA_DISP++, gHoneyAndDarlingHeartMaterialDL); + isMaterialApplied = true; + } + Matrix_Translate(effect->pos.x, effect->pos.y, effect->pos.z, MTXMODE_NEW); + Matrix_ReplaceRotation(&play->billboardMtxF); + Matrix_Scale(effect->scale, effect->scale, effect->scale, MTXMODE_APPLY); + + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gDropRecoveryHeartTex)); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gHoneyAndDarlingHeartModelDL); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} 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..ca67624c1 100644 --- a/src/overlays/actors/ovl_En_Tg/z_en_tg.h +++ b/src/overlays/actors/ovl_En_Tg/z_en_tg.h @@ -2,17 +2,33 @@ #define Z_EN_TG_H #include "global.h" +#include "objects/object_mu/object_mu.h" struct EnTg; -typedef void (*EnTgActionFunc)(struct EnTg*, GlobalContext*); +typedef void (*EnTgActionFunc)(struct EnTg*, PlayState*); + +typedef struct EnTgHeartEffect { + /* 0x00 */ u8 isEnabled; + /* 0x01 */ u8 timer; + /* 0x04 */ f32 scale; + /* 0x08 */ UNK_TYPE1 unk8[0xC]; + /* 0x14 */ Vec3f pos; + /* 0x20 */ Vec3f unusedZeroVec; + /* 0x2C */ Vec3f velocity; + /* 0x38 */ s16 angle; +} EnTgHeartEffect; // size = 0x3C typedef struct EnTg { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnTgActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x400]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnTgActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x18C */ ColliderCylinder collider; + /* 0x1D8 */ UNK_TYPE1 unk1D8[0x18]; + /* 0x1F0 */ Vec3s jointTable[HONEY_AND_DARLING_LIMB_MAX]; + /* 0x26E */ Vec3s morphTable[HONEY_AND_DARLING_LIMB_MAX]; + /* 0x2EC */ s16 spawnHeartTimer; + /* 0x2F0 */ EnTgHeartEffect effects[10]; } EnTg; // size = 0x548 -extern const ActorInit En_Tg_InitVars; - #endif // Z_EN_TG_H diff --git a/src/overlays/actors/ovl_En_Thiefbird/overlay.cfg b/src/overlays/actors/ovl_En_Thiefbird/overlay.cfg deleted file mode 100644 index f469c156a..000000000 --- a/src/overlays/actors/ovl_En_Thiefbird/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Thiefbird -z_en_thiefbird.c 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 faeb3163e..58f44d468 100644 --- a/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c +++ b/src/overlays/actors/ovl_En_Thiefbird/z_en_thiefbird.c @@ -4,36 +4,36 @@ * Description: Takkuri */ +#include "prevent_bss_reordering.h" #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* play2); +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 = { +ActorInit En_Thiefbird_InitVars = { ACTOR_EN_THIEFBIRD, ACTORCAT_ENEMY, FLAGS, @@ -90,7 +90,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -131,28 +131,29 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static s16 D_80C13664[] = { ITEM00_ARROWS_10, ITEM00_BOMBS_B, ITEM00_RUPEE_GREEN, - ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_PURPLE }; +static s16 D_80C13664[] = { + ITEM00_ARROWS_10, ITEM00_BOMBS_B, ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_RUPEE_PURPLE, +}; static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 1000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 35, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_TAKKURI, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; -static Vec3f D_80C13920; -static s32 D_80C1392C; +Vec3f D_80C13920; +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; @@ -167,18 +168,22 @@ void EnThiefbird_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 1) { D_80C1392C = 1; Math_Vec3f_Copy(&D_80C13920, &this->actor.world.pos); - Actor_MarkForDeath(&this->actor); - } else if (STOLEN_ITEM_1 != STOLEN_ITEM_NONE) { - Actor_MarkForDeath(&this->actor); - } else { - func_80C11538(this); + Actor_Kill(&this->actor); + return; } + + if (STOLEN_ITEM_1 != STOLEN_ITEM_NONE) { + Actor_Kill(&this->actor); + return; + } + + func_80C11538(this); } -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 +201,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 +210,12 @@ 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 +232,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 +247,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 +264,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 +309,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 +399,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 +413,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 +427,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 +460,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); @@ -518,21 +527,22 @@ void func_80C11590(EnThiefbird* this, GlobalContext* globalCtx) { this->unk_18E--; } - if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x800000) && - (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && (this->actor.depthInWater < -40.0f)) { + if ((this->unk_18E == 0) && (this->actor.xzDistToPlayer < 300.0f) && + !(player->stateFlags1 & PLAYER_STATE1_800000) && (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,19 +572,19 @@ 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) || - (this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 1) || - (this->actor.depthInWater > -40.0f)) { + if ((this->unk_18E == 0) || (player->stateFlags1 & PLAYER_STATE1_800000) || + (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) { this->collider.base.atFlags &= ~AT_HIT; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_THIEFBIRD_VOICE); if (!(this->collider.base.atFlags & AT_BOUNCED)) { if ((D_80C1392C != 0) && CUR_UPG_VALUE(UPG_QUIVER) && ((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 +601,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 +614,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 +622,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 +645,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,24 +656,24 @@ 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]); } } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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 +702,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 +724,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 +757,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 +765,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 +786,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 +806,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,17 +837,17 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } 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 +856,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 +876,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 +922,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 +930,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 +947,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 +966,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 +1005,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 +1019,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 +1040,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,36 +1071,36 @@ 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_ReplaceRotation(&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); } } @@ -1108,49 +1117,49 @@ void EnThiefbird_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLi } } -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_Translate(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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..c40555299 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,30 +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; - #endif // Z_EN_THIEFBIRD_H diff --git a/src/overlays/actors/ovl_En_Time_Tag/overlay.cfg b/src/overlays/actors/ovl_En_Time_Tag/overlay.cfg deleted file mode 100644 index 9759bee86..000000000 --- a/src/overlays/actors/ovl_En_Time_Tag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Time_Tag -z_en_time_tag.c 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..4e09f01a9 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,32 +5,32 @@ */ #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 = { +ActorInit En_Time_Tag_InitVars = { ACTOR_EN_TIME_TAG, ACTORCAT_ITEMACTION, FLAGS, @@ -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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40) || (CURRENT_DAY != 3)) { + Actor_Kill(&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.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; + if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOLWA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) && + CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) { + SET_WEEKEVENTREG(WEEKEVENTREG_25_02); + } + } 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.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; + } + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_01) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + func_800B7298(play, &this->actor, PLAYER_CSMODE_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->sceneId != 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_01)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_63_02)) { + this->actionFunc = func_80ACA7C4; + } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y)) { + SET_WEEKEVENTREG(WEEKEVENTREG_63_02); + } + } else if ((temp_ft4 == this->actor.home.rot.x) && (temp_hi == this->actor.home.rot.y) && + !Play_InCsMode(play)) { + func_800B7298(play, &this->actor, PLAYER_CSMODE_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..ed6b611e4 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,13 +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; - #endif // Z_EN_TIME_TAG_H diff --git a/src/overlays/actors/ovl_En_Tite/overlay.cfg b/src/overlays/actors/ovl_En_Tite/overlay.cfg deleted file mode 100644 index 0d91c61fe..000000000 --- a/src/overlays/actors/ovl_En_Tite/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tite -z_en_tite.c 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 153bb8722..eb005b224 100644 --- a/src/overlays/actors/ovl_En_Tite/z_en_tite.c +++ b/src/overlays/actors/ovl_En_Tite/z_en_tite.c @@ -11,42 +11,42 @@ #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 = { +ActorInit En_Tite_InitVars = { ACTOR_EN_TITE, ACTORCAT_ENEMY, FLAGS, @@ -125,7 +125,7 @@ static Color_RGBA8 D_80896B40 = { 180, 180, 180, 255 }; static Vec3f D_80896B44 = { 0.0f, 0.45f, 0.0f }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 70, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_BLUE_TEKTITE, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_CONTINUE), ICHAIN_F32(terminalVelocity, -40, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), @@ -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,15 +665,16 @@ 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); - } - Actor_MarkForDeath(&this->actor); - } else { - for (i = 0; i < ARRAY_COUNT(this->unk_33C); i++) { - Math_Vec3f_Sum(&this->limbPos[i], &this->unk_33C[i], &this->limbPos[i]); - this->unk_33C[i].y += this->actor.gravity; + func_800B3030(play, &this->limbPos[i], &gZeroVec3f, &gZeroVec3f, 40, 7, 1); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->limbPos[i], 11, NA_SE_EN_EXTINCT); } + Actor_Kill(&this->actor); + return; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_33C); i++) { + Math_Vec3f_Sum(&this->limbPos[i], &this->unk_33C[i], &this->limbPos[i]); + this->unk_33C[i].y += this->actor.gravity; } } @@ -692,7 +693,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 +707,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 +730,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 +757,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 +780,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 +847,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 +868,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 +894,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 +912,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 +929,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 +943,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 +991,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 +1013,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 +1028,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 +1036,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 +1081,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 +1097,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 +1107,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, }; @@ -1135,7 +1135,7 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V this->unk_2BA = -1; } } else if (D_80896B8C[limbIndex] != -1) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); matrix = Matrix_GetCurrent(); matrix->xw = this->limbPos[D_80896B8C[limbIndex]].x; @@ -1143,18 +1143,18 @@ void EnTite_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V 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 +1171,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..4b87634a3 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,27 +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; - #endif // Z_EN_TITE_H diff --git a/src/overlays/actors/ovl_En_Tk/overlay.cfg b/src/overlays/actors/ovl_En_Tk/overlay.cfg deleted file mode 100644 index a7ca23e6e..000000000 --- a/src/overlays/actors/ovl_En_Tk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tk -z_en_tk.c 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 4f61ac43f..1bdc92b4a 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -13,52 +13,52 @@ #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, ScheduleResult* arg2); -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); -void func_80AED4F8(EnTk* this, GlobalContext* globalCtx); -void func_80AED610(EnTk* this, GlobalContext* globalCtx); -void func_80AED898(EnTk* this, GlobalContext* globalCtx); -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; @@ -69,7 +69,7 @@ static u8 D_80AEF800[] = { /* 0xE */ SCHEDULE_CMD_RET_NONE(), }; -const ActorInit En_Tk_InitVars = { +ActorInit En_Tk_InitVars = { ACTOR_EN_TK, ACTORCAT_NPC, FLAGS, @@ -199,21 +199,21 @@ 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); + Actor_Kill(&this->actor); return; } } else if (this->unk_2B0 == 2) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&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; @@ -253,53 +252,53 @@ void EnTk_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_2B0) { case 4: if (D_80AF0050 != 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } D_80AF0050 = 1; 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: - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } -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; - ScheduleResult sp34; + ScheduleOutput sp34; u8 temp4; 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); + if (R_TIME_SPEED != 0.0f) { + this->skelAnime.playSpeed = (f32)func_800FE620(play) / R_TIME_SPEED; } else { this->skelAnime.playSpeed = 0.0f; } @@ -338,17 +337,17 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { func_80AEC658(&this->skelAnime, this->unk_320, 1.0f, &sp48, &sp44); } - temp2 = REG(15) * sp44; + temp2 = R_TIME_SPEED * sp44; temp_f0 = temp2; - this->unk_2DC += (REG(15) * sp44) - temp2; + this->unk_2DC += (R_TIME_SPEED * sp44) - temp2; temp3 = this->unk_2DC; - this->unk_3D0 = temp2 + temp3; + this->timePathTimeSpeed = temp2 + temp3; this->unk_2DC -= temp3; - this->unk_2E0 += REG(15); + this->unk_2E0 += R_TIME_SPEED; - if (Schedule_RunScript(globalCtx, D_80AEF800, &sp34)) { - if ((this->unk_3CC != sp34.result) && !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.result; @@ -366,7 +365,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { } this->unk_3CC = sp34.result; - func_80AECE0C(this, globalCtx); + 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, EXCH_ITEM_NONE, 0x4000, 0x4000); + func_8013E8F8(&this->actor, play, 100.0f, 100.0f, PLAYER_IA_NONE, 0x4000, 0x4000); } return false; } -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { +s32 func_80AED354(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 phi_v1 = false; - if (arg2->result != 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, ScheduleResult* arg2) { +s32 func_80AED38C(EnTk* this, PlayState* play, ScheduleOutput* scheduleOutput) { u16 sp1E = SCHEDULE_TIME_NOW; u8 params = ENTK_GET_F800(&this->actor); u16 phi_a1; - s32 idx = arg2->result - 1; + s32 index = scheduleOutput->result - 1; + u16 tmp; - this->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->time0; + phi_a1 = scheduleOutput->time0; } - this->unk_3E4 = arg2->time1 - 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) { - if (!(gSaveContext.save.weekEventReg[31] & 0x10)) { - Message_StartTextbox(globalCtx, 0x13FE, &this->actor); - gSaveContext.save.weekEventReg[31] |= 0x10; +void func_80AED544(EnTk* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_31_10)) { + Message_StartTextbox(play, 0x13FE, &this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_31_10); } 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); - } else if (gSaveContext.save.weekEventReg[60] & 2) { - func_80AED544(this, globalCtx); + func_80AED544(this, play); + } else if (!Flags_GetSwitch(play, ENTK_GET_7F0(&this->actor))) { + Message_StartTextbox(play, 0x1403, &this->actor); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_60_02)) { + 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); - gSaveContext.save.weekEventReg[60] |= 2; - func_80151938(globalCtx, 0x13FF); + Rupees_ChangeBy(30); + SET_WEEKEVENTREG(WEEKEVENTREG_60_02); + 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; @@ -656,7 +657,7 @@ void func_80AED940(EnTk* this, GlobalContext* globalCtx) { } Math_Vec3f_Copy(&sp44, &player->actor.world.pos); - sp44.y = player->bodyPartsPos[7].y + 3.0f; + sp44.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; temp_v0 = Math_Vec3f_Pitch(&this->actor.focus.pos, &sp44); if (ABS(temp_v0) < 0x800) { Math_SmoothStepToS(&this->unk_31A, temp_v0, 3, 0x16C, 0); @@ -673,12 +674,12 @@ 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); Math_Vec3s_Copy(&this->unk_2F8, &actor->world.rot); - Actor_MarkForDeath(actor); + Actor_Kill(actor); this->unk_2CA |= 0x40; break; } @@ -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, EXCH_ITEM_NONE, 0x4000, 0x4000); + func_8013E8F8(&this->actor, play, 100.0f, 100.0f, PLAYER_IA_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_IA_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); - Actor_MarkForDeath(&this->actor); + func_801477B4(play); + Actor_Kill(&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; } @@ -757,7 +758,7 @@ void func_80AEDE10(EnTk* this, GlobalContext* globalCtx) { switch (this->unk_310) { case 0: this->unk_2CA &= ~0x1000; - if (!(gSaveContext.save.weekEventReg[52] & 0x80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_52_80)) { this->unk_2E6 = 0x1405; } else { this->unk_2E6 = 0x140B; @@ -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; + SET_WEEKEVENTREG(WEEKEVENTREG_52_80); 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,40 +920,41 @@ 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 { - this->unk_2CC = Actor_YawToPoint(&this->actor, &sp30.unk_00->world.pos); - this->actionFunc = func_80AEE414; + Actor_Kill(&this->actor); + return; } + + this->unk_2CC = Actor_YawToPoint(&this->actor, &sp30.unk_00->world.pos); + this->actionFunc = func_80AEE414; } -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 +965,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 +980,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 +992,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 +1030,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 +1040,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 +1082,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 +1125,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 +1143,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 +1155,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 +1168,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 +1191,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 +1219,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 +1267,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 +1292,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 +1307,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 +1329,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,7 +1347,7 @@ 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; @@ -1359,17 +1360,17 @@ void EnTk_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec case 14: 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 +1379,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_RotateYS(this->unk_318, 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, 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..42a8aa96a 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -5,64 +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; - #endif // Z_EN_TK_H diff --git a/src/overlays/actors/ovl_En_Torch/overlay.cfg b/src/overlays/actors/ovl_En_Torch/overlay.cfg deleted file mode 100644 index 081513543..000000000 --- a/src/overlays/actors/ovl_En_Torch/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Torch -z_en_torch.c 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..00335577b 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 = { +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)); - Actor_MarkForDeath(&this->actor); + ENBOX_PARAMS(ENBOX_TYPE_SMALL, sChestContents[(returnData >> 0x5) & 0x7], returnData)); + Actor_Kill(&this->actor); } diff --git a/src/overlays/actors/ovl_En_Torch/z_en_torch.h b/src/overlays/actors/ovl_En_Torch/z_en_torch.h index 87e1d6782..9ebfabb64 100644 --- a/src/overlays/actors/ovl_En_Torch/z_en_torch.h +++ b/src/overlays/actors/ovl_En_Torch/z_en_torch.h @@ -9,6 +9,4 @@ typedef struct EnTorch { /* 0x000 */ Actor actor; } EnTorch; // size = 0x144 -extern const ActorInit En_Torch_InitVars; - #endif // Z_EN_TORCH_H diff --git a/src/overlays/actors/ovl_En_Torch2/overlay.cfg b/src/overlays/actors/ovl_En_Torch2/overlay.cfg deleted file mode 100644 index 25ddefa7f..000000000 --- a/src/overlays/actors/ovl_En_Torch2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Torch2 -z_en_torch2.c 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..75f966a3c 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -11,15 +11,15 @@ #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* play2); -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 = { +ActorInit En_Torch2_InitVars = { ACTOR_EN_TORCH2, ACTORCAT_ITEMACTION, FLAGS, @@ -58,19 +58,15 @@ static InitChainEntry sInitChain[] = { // Shells for each of Link's different forms // (Playing elegy as Fierce Deity puts down a human shell) static Gfx* sShellDLists[] = { - gameplay_keep_DL_01C430, // Human - gameplay_keep_DL_048DF0, // Zora - gameplay_keep_DL_089070, // Deku - gameplay_keep_DL_057B10, // Goron - gameplay_keep_DL_01C430, // Human + gElegyShellHumanDL, gElegyShellGoronDL, gElegyShellZoraDL, gElegyShellDekuDL, gElegyShellHumanDL, }; -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 +79,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, - &this->actor.world.pos, this->actor.shape.rot.y); - globalCtx->actorCtx.unk254[this->actor.params] = 0; + Collider_DestroyCylinder(play, &this->collider); + Play_SetRespawnData(&play->state, this->actor.params + RESPAWN_MODE_GORON - 1, 0xFF, 0, + PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B), &this->actor.world.pos, this->actor.shape.rot.y); + play->actorCtx.elegyShells[this->actor.params] = NULL; } -void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnTorch2_Update(Actor* thisx, PlayState* play) { EnTorch2* this = THIS; u16 targetAlpha; u16 remainingFrames; @@ -105,7 +101,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 +127,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,32 +144,33 @@ 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 if (Math_StepToS(&this->alpha, 0, 8)) { - Actor_MarkForDeath(&this->actor); - } else { - this->actor.gravity = -1.0f; - Actor_MoveWithGravity(&this->actor); + Actor_Kill(&this->actor); + return; } + + this->actor.gravity = -1.0f; + Actor_MoveWithGravity(&this->actor); } -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]; + Gfx* gfx = sShellDLists[this->actor.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_Torch2/z_en_torch2.h b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h index 744a7975c..9033b9923 100644 --- a/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h +++ b/src/overlays/actors/ovl_En_Torch2/z_en_torch2.h @@ -29,6 +29,4 @@ typedef enum { /* 4 */ TORCH2_STATE_DYING, } EnTorch2State; -extern const ActorInit En_Torch2_InitVars; - #endif // Z_EN_TORCH2_H diff --git a/src/overlays/actors/ovl_En_Toto/overlay.cfg b/src/overlays/actors/ovl_En_Toto/overlay.cfg deleted file mode 100644 index 48534631e..000000000 --- a/src/overlays/actors/ovl_En_Toto/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Toto -z_en_toto.c 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..aefa6383f 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -11,46 +11,46 @@ #define THIS ((EnToto*)thisx) -#define ENTOTO_WEEK_EVENT_FLAGS (gSaveContext.save.weekEventReg[50] & 1 || gSaveContext.save.weekEventReg[51] & 0x80) +#define ENTOTO_WEEK_EVENT_FLAGS (CHECK_WEEKEVENTREG(WEEKEVENTREG_50_01) || CHECK_WEEKEVENTREG(WEEKEVENTREG_51_80)) -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 = { +ActorInit En_Toto_InitVars = { ACTOR_EN_TOTO, ACTORCAT_NPC, FLAGS, @@ -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 && - (gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < CLOCK_TIME(21, 30))) { - Actor_MarkForDeath(&this->actor); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && + (gSaveContext.save.time < CLOCK_TIME(21, 30))) { + Actor_Kill(&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->sceneId == 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->sceneId == 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->sceneId != 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 && - !(gSaveContext.save.time >= CLOCK_TIME(6, 0) && gSaveContext.save.time < 0xED02)) || - (globalCtx->sceneNum != SCENE_MILK_BAR && func_80BA397C(this, 0x2000))) { + if (((play->sceneId == SCENE_MILK_BAR) && + !((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < 0xED02))) || + ((play->sceneId != 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_IA_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->sceneId == 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->sceneId == 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.flags |= ACTORCTX_FLAG_5; 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); - if (player->stateFlags1 & 0x400 && player->unk_AE7 != 0) { - func_80151BB4(globalCtx, 48); - func_80151BB4(globalCtx, 9); - func_80151BB4(globalCtx, 10); + player = GET_PLAYER(play); + if ((player->stateFlags1 & PLAYER_STATE1_400) && player->unk_AE7 != 0) { + 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.flags &= ~ACTORCTX_FLAG_5; } -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, PLAYER_CSMODE_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, PLAYER_CSMODE_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, PLAYER_CSMODE_19); + 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, PLAYER_CSMODE_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,15 +502,15 @@ 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; func_80BA3C88(this); if (player->actor.world.pos.z > -270.0f) { if (this->spotlights != NULL) { - Actor_MarkForDeath(this->spotlights); + Actor_Kill(this->spotlights); } this->unk2B6 = 1; return this->text->unk1; @@ -521,16 +521,15 @@ 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++) { + for (i = 0; i < ARRAY_COUNT(D_80BA50DC); i++) { if (func_80BA44D4(&D_80BA50DC[i], player)) { 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[GET_PLAYER_FORM - 1].unk2, NULL); } } return 0; @@ -542,92 +541,92 @@ 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, PLAYER_CSMODE_68); + 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; + SET_WEEKEVENTREG(WEEKEVENTREG_56_10); } if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { - gSaveContext.save.weekEventReg[56] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_56_20); } if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - gSaveContext.save.weekEventReg[56] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_56_40); } if (gSaveContext.save.playerForm == PLAYER_FORM_GORON) { - gSaveContext.save.weekEventReg[56] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_56_80); } return 1; } return 0; } -s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { +s32 func_80BA47E0(EnToto* this, PlayState* play) { Vec3f spawnPos; s32 i; this->unk2B3 = 0; - if (gSaveContext.save.weekEventReg[56] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_56_10)) { this->unk2B3 += 1; } - if (gSaveContext.save.weekEventReg[56] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_56_20)) { this->unk2B3 += 2; } - if (gSaveContext.save.weekEventReg[56] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_56_40)) { this->unk2B3 += 4; } - if (gSaveContext.save.weekEventReg[56] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_56_80)) { this->unk2B3 += 8; } - for (i = 0; i < 4; i++) { + for (i = 0; i < ARRAY_COUNT(D_80BA50DC); 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, + PLAYER_PARAMS(0xFF, PLAYER_INITMODE_F) | 0xFFFFF000); } } - 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, PLAYER_CSMODE_68); 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); + Actor_Kill(actor); actor = actor->next; } if (this->spotlights != NULL) { - Actor_MarkForDeath(this->spotlights); + Actor_Kill(this->spotlights); } - func_800B7298(globalCtx, NULL, 0x45); + func_800B7298(play, NULL, PLAYER_CSMODE_69); if (this->unk2B3 == 0xF) { if (CURRENT_DAY == 1) { - gSaveContext.save.weekEventReg[50] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_50_01); } else { - gSaveContext.save.weekEventReg[51] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_51_80); } } 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..3c95a7dbb 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,11 +37,9 @@ 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 -extern const ActorInit En_Toto_InitVars; - #endif // Z_EN_TOTO_H diff --git a/src/overlays/actors/ovl_En_Trt/overlay.cfg b/src/overlays/actors/ovl_En_Trt/overlay.cfg deleted file mode 100644 index d0b1d075f..000000000 --- a/src/overlays/actors/ovl_En_Trt/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Trt -z_en_trt.c 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 470f4908a..caceb62bd 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_TrackPlayer(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,20 +64,33 @@ void EnTrt_Blink(EnTrt* this); void EnTrt_OpenEyes2(EnTrt* this); void EnTrt_NodOff(EnTrt* this); -static AnimationInfoS sAnimations[] = { - { &object_trt_Anim_00DE68, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_trt_Anim_00EE98, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_trt_Anim_00FD34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_0030EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_trt_Anim_003D78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_trt_Anim_00D52C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_000A44, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_001EF4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_002224, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_002CB0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +typedef enum { + /* 0 */ TRT_ANIM_IDLE, + /* 1 */ TRT_ANIM_HALF_AWAKE, + /* 2 */ TRT_ANIM_SLEEPING, + /* 3 */ TRT_ANIM_WAKE_UP, + /* 4 */ TRT_ANIM_SURPRISED, + /* 5 */ TRT_ANIM_HANDS_ON_COUNTER, + /* 6 */ TRT_ANIM_HOVER, + /* 7 */ TRT_ANIM_FLY_LOOK_AROUND, + /* 8 */ TRT_ANIM_FLY_DOWN, + /* 9 */ TRT_ANIM_FLY +} TrtAnimation; + +static AnimationInfoS sAnimationInfo[] = { + { &gKotakeIdleAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeHalfAwakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeSleepingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeWakeUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeHandsOnCounterAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyLookAroundAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; -const ActorInit En_Trt_InitVars = { +ActorInit En_Trt_InitVars = { ACTOR_EN_TRT, ACTORCAT_NPC, FLAGS, @@ -97,31 +110,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 +144,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->cursorIndex]->actor, &x, &y); this->cursorPos.x = x + xOffset; this->cursorPos.y = y + yOffset; this->cursorPos.z = 1.2f; @@ -178,41 +191,41 @@ void EnTrt_SetupGetMushroomCutscene(EnTrt* this) { } u16 EnTrt_GetItemTextId(EnTrt* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; - if (item->actor.params == SI_POTION_BLUE && !(this->flags & ENTRT_GIVEN_MUSHROOM)) { + if ((item->actor.params == SI_POTION_BLUE) && !(this->flags & ENTRT_GIVEN_MUSHROOM)) { return 0x880; } return item->actor.textId; } u16 EnTrt_GetItemChoiceTextId(EnTrt* this) { - EnGirlA* item = this->items[this->cursorIdx]; + EnGirlA* item = this->items[this->cursorIndex]; - if (item->actor.params == SI_POTION_BLUE && !(gSaveContext.save.weekEventReg[53] & 0x10)) { + if ((item->actor.params == SI_POTION_BLUE) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_53_10)) { this->textId = 0x881; return 0x881; } 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; - Interface_ChangeAlpha(50); + Actor_ProcessTalkRequest(&this->actor, &play->state); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); this->drawCursor = 0; this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = false; - player->stateFlags2 &= ~0x20000000; - globalCtx->interfaceCtx.unk_222 = 0; - globalCtx->interfaceCtx.unk_224 = 0; + player->stateFlags2 &= ~PLAYER_STATE2_20000000; + play->interfaceCtx.unk_222 = 0; + play->interfaceCtx.unk_224 = 0; this->textId = 0x834; this->timer = 80; this->flags |= ENTRT_FULLY_AWAKE; @@ -222,43 +235,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, DO_ACTION_NEXT); 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, DO_ACTION_DECIDE); 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 +314,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,149 +325,149 @@ 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) { EnTrt_SetupGetMushroomCutscene(this); if (this->cutsceneState == ENTRT_CUTSCENESTATE_PLAYING_SPECIAL) { - player->stateFlags2 &= ~0x20000000; + player->stateFlags2 &= ~PLAYER_STATE2_20000000; } - } 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); - gSaveContext.save.weekEventReg[53] |= 8; - func_80123D50(globalCtx, GET_PLAYER(globalCtx), ITEM_BOTTLE, PLAYER_AP_BOTTLE); + Message_StartTextbox(play, this->textId, &this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_53_08); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_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); + Player_UpdateBottleHeld(play, GET_PLAYER(play), ITEM_BOTTLE, PLAYER_IA_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_StartRedPotionConversation(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() || !CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { 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); + SET_WEEKEVENTREG(WEEKEVENTREG_85_08); + Message_StartTextbox(play, this->textId, &this->actor); this->actionFunc = EnTrt_EndConversation; } } else { - if (gSaveContext.save.weekEventReg[12] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_08)) { this->textId = 0x83D; - EnTrt_SetupStartShopping(globalCtx, this, 0); - } else if (gSaveContext.save.weekEventReg[84] & 0x40) { + EnTrt_SetupStartShopping(play, this, 0); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_40)) { 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; } - } else if (gSaveContext.save.weekEventReg[16] & 0x10) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { this->timer = 30; this->textId = 0x838; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING_SPECIAL; this->actionFunc = EnTrt_Surprised; return; - } else if (gSaveContext.save.weekEventReg[17] & 1) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_17_01)) { 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; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { + SET_WEEKEVENTREG(WEEKEVENTREG_12_10); } - gSaveContext.save.weekEventReg[84] |= 0x40; - player->stateFlags2 &= ~0x20000000; + SET_WEEKEVENTREG(WEEKEVENTREG_84_40); + player->stateFlags2 &= ~PLAYER_STATE2_20000000; this->actionFunc = EnTrt_GivenRedPotionForKoume; - } else if (gSaveContext.save.weekEventReg[12] & 0x10) { - Actor_PickUp(&this->actor, globalCtx, GI_POTION_RED, 300.0f, 300.0f); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { + 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); - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_20000000; //! @bug: EnTrt_ContinueShopping gets overwritten by EnTrt_ItemGiven this->actionFunc = EnTrt_ContinueShopping; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; @@ -466,42 +479,42 @@ 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_IA_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); - u8 cursorIdx; +void EnTrt_FaceShopkeeper(EnTrt* this, PlayState* play) { + u8 talkState = Message_GetState(&play->msgCtx); + u8 cursorIndex; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -518,16 +531,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, DO_ACTION_DECIDE); + 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; + cursorIndex = EnTrt_SetCursorIndexFromNeutral(this, 2); + if (cursorIndex != CURSOR_INVALID) { + this->cursorIndex = cursorIndex; this->actionFunc = EnTrt_LookToShelf; - func_8011552C(globalCtx, 6); + func_8011552C(play, DO_ACTION_DECIDE); this->stickRightPrompt.isEnabled = false; play_sound(NA_SE_SY_CURSOR); } @@ -536,7 +549,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,47 +565,47 @@ 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) { - u8 curTemp = this->cursorIdx; +void EnTrt_CursorLeftRight(PlayState* play, EnTrt* this) { + u8 curTemp = this->cursorIndex; 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; + this->cursorIndex = curTemp; } } else if (this->stickAccumX > 0) { if (curTemp != 0) { curTemp--; } if (this->items[curTemp] != NULL) { - this->cursorIdx = curTemp; + this->cursorIndex = curTemp; } } } -s32 EnTrt_HasPlayerSelectedItem(GlobalContext* globalCtx, EnTrt* this, Input* input) { - EnGirlA* item = this->items[this->cursorIdx]; +s32 EnTrt_HasPlayerSelectedItem(PlayState* play, EnTrt* this, Input* input) { + EnGirlA* item = this->items[this->cursorIndex]; - 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,11 +619,11 @@ 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; + u8 prevCursorIdx = this->cursorIndex; + u8 cursorIndex; if (!EnTrt_ReturnItemToShelf(this)) { this->delayTimer = 3; @@ -619,13 +632,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); - if (this->cursorIdx != prevCursorIdx) { - func_80151938(globalCtx, EnTrt_GetItemTextId(this)); + EnTrt_UpdateCursorPos(play, this); + if (talkState == TEXT_STATE_5) { + func_8011552C(play, DO_ACTION_DECIDE); + if (!EnTrt_HasPlayerSelectedItem(play, this, CONTROLLER1(&play->state))) { + EnTrt_CursorLeftRight(play, this); + if (this->cursorIndex != prevCursorIdx) { + func_80151938(play, EnTrt_GetItemTextId(this)); play_sound(NA_SE_SY_CURSOR); } } @@ -633,138 +646,146 @@ 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; - player->stateFlags2 &= ~0x20000000; - Interface_ChangeAlpha(50); + Actor_PickUp(&this->actor, play, this->items[this->cursorIndex]->getItemId, 300.0f, 300.0f); + play->msgCtx.msgMode = 0x43; + play->msgCtx.stateTimer = 4; + player->stateFlags2 &= ~PLAYER_STATE2_20000000; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); 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) { - EnGirlA* item = this->items[this->cursorIdx]; +void EnTrt_HandleCanBuyItem(PlayState* play, EnTrt* 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 == ENTRT_CUTSCENESTATE_PLAYING) { ActorCutscene_Stop(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_STOPPED; } func_8019F208(); - item2 = this->items[this->cursorIdx]; - item2->buyFanfareFunc(globalCtx, item2); - EnTrt_SetupBuyItemWithFanfare(globalCtx, this); + item2 = this->items[this->cursorIndex]; + 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; + + default: break; } } -void EnTrt_SelectItem(EnTrt* this, GlobalContext* globalCtx) { - EnGirlA* item = this->items[this->cursorIdx]; - u8 talkState = Message_GetState(&globalCtx->msgCtx); +void EnTrt_SelectItem(EnTrt* this, PlayState* play) { + EnGirlA* item = this->items[this->cursorIndex]; + 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, DO_ACTION_DECIDE); + 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); - gSaveContext.save.weekEventReg[53] |= 0x10; + item->boughtFunc(play, item); + SET_WEEKEVENTREG(WEEKEVENTREG_53_10); } } } } -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)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_85_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_84_40)) { this->textId = 0x88F; } else if (!(this->flags & ENTRT_MET)) { this->textId = 0x834; } else { this->textId = 0x83E; } - if (!(gSaveContext.save.weekEventReg[53] & 8)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_53_08)) { this->talkOptionTextId = 0x845; } else if (this->flags & ENTRT_GIVEN_MUSHROOM) { this->talkOptionTextId = 0x882; } 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) { + 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; } @@ -776,17 +797,17 @@ void EnTrt_IdleSleeping(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_20000000; 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); + } 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, 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, TRT_ANIM_HALF_AWAKE); + this->animIndex = TRT_ANIM_HALF_AWAKE; this->actionFunc = EnTrt_IdleAwake; this->blinkFunc = EnTrt_OpenThenCloseEyes; } @@ -795,20 +816,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->transformation == PLAYER_FORM_HUMAN) || (player->transformation == PLAYER_FORM_FIERCE_DEITY)) { + 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); @@ -817,22 +838,22 @@ void EnTrt_IdleAwake(EnTrt* this, GlobalContext* globalCtx) { ActorCutscene_SetIntentToPlay(this->cutscene); this->cutsceneState = ENTRT_CUTSCENESTATE_WAITING; } - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_20000000; if (player->transformation == PLAYER_FORM_HUMAN) { this->flags |= ENTRT_MET; } - EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 2); + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_SLEEPING); 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, TRT_ANIM_SLEEPING); + this->animIndex = TRT_ANIM_SLEEPING; this->sleepSoundTimer = 10; this->actor.textId = 0; this->actionFunc = EnTrt_IdleSleeping; @@ -840,9 +861,9 @@ 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; + s16 animLastFrame = Animation_GetLastFrame(&gKotakeWakeUpAnim) / (s16)this->skelAnime.playSpeed; if (this->cutsceneState == ENTRT_CUTSCENESTATE_WAITING) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { @@ -852,10 +873,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 != TRT_ANIM_HANDS_ON_COUNTER) { if (curFrame == animLastFrame) { - EnTrt_ChangeAnim(&this->skelAnime, sAnimations, 3); - this->animationIndex = 3; + EnTrt_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT_ANIM_WAKE_UP); + this->animIndex = TRT_ANIM_WAKE_UP; this->blinkFunc = EnTrt_OpenEyesThenSetToBlink; this->timer = 10; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; @@ -868,23 +889,23 @@ 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, TRT_ANIM_HANDS_ON_COUNTER); + Message_StartTextbox(play, this->textId, &this->actor); + this->animIndex = TRT_ANIM_HANDS_ON_COUNTER; 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); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_84_40) && + !CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_17_01)) { + func_8011552C(play, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actionFunc = EnTrt_Hello; } else { - this->actionFunc = EnTrt_SetupTryToGiveRedPotion; + this->actionFunc = EnTrt_StartRedPotionConversation; } break; case 0x83E: - func_8011552C(globalCtx, 6); + func_8011552C(play, DO_ACTION_DECIDE); this->stickLeftPrompt.isEnabled = false; this->stickRightPrompt.isEnabled = true; this->actionFunc = EnTrt_FaceShopkeeper; @@ -894,13 +915,13 @@ void EnTrt_BeginInteraction(EnTrt* this, GlobalContext* globalCtx) { this->actionFunc = EnTrt_SetupEndInteraction; break; case 0x88F: - this->actionFunc = EnTrt_SetupTryToGiveRedPotion; + this->actionFunc = EnTrt_StartRedPotionConversation; break; } } } -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 +931,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, TRT_ANIM_SURPRISED); + this->animIndex = TRT_ANIM_SURPRISED; this->blinkFunc = EnTrt_OpenEyes2; Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOTAKE_SURPRISED); this->timer = 30; @@ -919,66 +940,66 @@ 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, TRT_ANIM_HANDS_ON_COUNTER); + Message_StartTextbox(play, this->textId, &this->actor); + this->animIndex = TRT_ANIM_HANDS_ON_COUNTER; 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() || !CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { 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); + SET_WEEKEVENTREG(WEEKEVENTREG_85_08); + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_85_08); + 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)) { ActorCutscene_StartAndSetFlag(this->cutscene, &this->actor); - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_20000000; this->actionFunc = EnTrt_ContinueShopping; this->cutsceneState = ENTRT_CUTSCENESTATE_PLAYING; } else { @@ -989,7 +1010,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 +1029,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_IA_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 (gSaveContext.save.weekEventReg[20] & 2) { - globalCtx->nextEntranceIndex = 0xC50; + if ((talkState == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + 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 = this->items[this->cursorIndex]; + 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->cursorIndex]->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,52 +1104,52 @@ 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_IA_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, DO_ACTION_DECIDE); + 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 = this->items[this->cursorIndex]; + 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); + player->stateFlags2 |= PLAYER_STATE2_20000000; + Message_StartTextbox(play, this->textId, &this->actor); + EnTrt_SetupStartShopping(play, this, true); + func_800B85E0(&this->actor, play, 400.0f, PLAYER_IA_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 = this->items[this->cursorIndex]; + item->restockFunc(play, item); + EnTrt_EndInteraction(play, this); } } } void EnTrt_PositionSelectedItem(EnTrt* this) { static Vec3f sSelectedItemPosition = { 6.0f, 35.0f, -12.0f }; - u8 i = this->cursorIdx; + u8 i = this->cursorIndex; EnGirlA* item; ShopItem* shopItem = &sShop[i]; Vec3f worldPos; @@ -1189,7 +1210,7 @@ void EnTrt_UpdateItemSelectedProperty(EnTrt* this) { (this->drawCursor == 0)) { item->isSelected = false; } else { - item->isSelected = this->cursorIdx == i ? true : false; + item->isSelected = this->cursorIndex == i ? true : false; } } } @@ -1278,53 +1299,53 @@ void EnTrt_UpdateStickDirectionPromptAnim(EnTrt* this) { } void EnTrt_OpenEyes(EnTrt* this) { - if (this->eyeTextureIdx <= 0) { - this->eyeTextureIdx = 0; + if (this->eyeTexIndex <= 0) { + this->eyeTexIndex = 0; } else { - this->eyeTextureIdx--; + this->eyeTexIndex--; } } void EnTrt_CloseEyes(EnTrt* this) { - if (this->eyeTextureIdx >= 2) { - this->eyeTextureIdx = 2; + if (this->eyeTexIndex >= 2) { + this->eyeTexIndex = 2; } else { - this->eyeTextureIdx++; + this->eyeTexIndex++; } } void EnTrt_Blink(EnTrt* this) { s16 decr = this->blinkTimer - 1; - s16 eyeTextureIdxTemp; + s16 eyeTexIndex; if (decr != 0) { this->blinkTimer = decr; return; } - eyeTextureIdxTemp = this->eyeTextureIdx + 1; - if (eyeTextureIdxTemp > 2) { - this->eyeTextureIdx = 0; + eyeTexIndex = this->eyeTexIndex + 1; + if (eyeTexIndex > 2) { + this->eyeTexIndex = 0; this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; } else { - this->eyeTextureIdx = eyeTextureIdxTemp; + this->eyeTexIndex = eyeTexIndex; this->blinkTimer = 1; } } void EnTrt_NodOff(EnTrt* this) { s16 decr = this->blinkTimer - 1; - s16 eyeTextureIdxTemp; + s16 eyeTexIndex; if (decr != 0) { this->blinkTimer = decr; return; } - eyeTextureIdxTemp = this->eyeTextureIdx + 1; - if (eyeTextureIdxTemp > 2) { - this->eyeTextureIdx = 1; + eyeTexIndex = this->eyeTexIndex + 1; + if (eyeTexIndex > 2) { + this->eyeTexIndex = 1; this->blinkTimer = 20; } else { - this->eyeTextureIdx = eyeTextureIdxTemp; + this->eyeTexIndex = eyeTexIndex; this->blinkTimer = 3; } } @@ -1333,14 +1354,14 @@ void EnTrt_OpenThenCloseEyes(EnTrt* this) { if (this->skelAnime.curFrame >= 40.0f) { EnTrt_CloseEyes(this); } else if (this->skelAnime.curFrame >= 35.0f) { - this->eyeTextureIdx = 1; + this->eyeTexIndex = 1; } else if (this->skelAnime.curFrame >= 10.0f) { EnTrt_OpenEyes(this); } } void EnTrt_EyesClosed(EnTrt* this) { - this->eyeTextureIdx = 2; + this->eyeTexIndex = 2; } void EnTrt_OpenEyes2(EnTrt* this) { @@ -1350,36 +1371,36 @@ void EnTrt_OpenEyes2(EnTrt* this) { void EnTrt_OpenEyesThenSetToBlink(EnTrt* this) { if (this->skelAnime.curFrame >= 7.0f) { EnTrt_OpenEyes(this); - if (this->eyeTextureIdx == 0) { + if (this->eyeTexIndex == 0) { this->blinkFunc = EnTrt_Blink; } } } -void EnTrt_TalkToShopkeeper(EnTrt* this, GlobalContext* globalCtx) { - u8 talkState = talkState = Message_GetState(&globalCtx->msgCtx); - Player* player = GET_PLAYER(globalCtx); - s32 itemGiven; +void EnTrt_TalkToShopkeeper(EnTrt* this, PlayState* play) { + u8 talkState = talkState = Message_GetState(&play->msgCtx); + Player* player = GET_PLAYER(play); + PlayerItemAction itemAction; - if (talkState == 5) { - if (Message_ShouldAdvance(globalCtx)) { - if (this->talkOptionTextId == 0x845 || this->talkOptionTextId == 0x882) { - func_80151938(globalCtx, 0xFF); + if (talkState == TEXT_STATE_5) { + if (Message_ShouldAdvance(play)) { + if ((this->talkOptionTextId == 0x845) || (this->talkOptionTextId == 0x882)) { + 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) { - if (gSaveContext.save.weekEventReg[53] & 8) { + } else if (talkState == TEXT_STATE_16) { + itemAction = func_80123810(play); + if (itemAction > PLAYER_IA_NONE) { + if (itemAction == PLAYER_IA_BOTTLE_MUSHROOM) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_08)) { player->actor.textId = 0x888; } else { player->actor.textId = 0x883; } this->textId = player->actor.textId; - player->exchangeItemId = itemGiven; + player->exchangeItemId = itemAction; this->actionFunc = EnTrt_GetMushroom; } else { if (this->flags & ENTRT_GIVEN_MUSHROOM) { @@ -1390,34 +1411,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 (itemAction <= PLAYER_IA_MINUS1) { 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, DO_ACTION_DECIDE); 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,32 +1454,32 @@ 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); - if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && - gSaveContext.save.day >= 2) { +void EnTrt_InitShopkeeper(EnTrt* this, PlayState* play) { + SkelAnime_InitFlex(play, &this->skelAnime, &gKotakeSkel, &gKotakeSleepingAnim, NULL, NULL, 0); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_84_40) && + (gSaveContext.save.day >= 2)) { this->actor.draw = NULL; } else { this->actor.draw = EnTrt_Draw; } } -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); - if (!(gSaveContext.save.weekEventReg[12] & 8) && !(gSaveContext.save.weekEventReg[84] & 0x40) && + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_84_40) && gSaveContext.save.day >= 2) { this->textId = 0x84A; this->actionFunc = EnTrt_ShopkeeperGone; @@ -1472,7 +1493,7 @@ void EnTrt_InitShop(EnTrt* 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; @@ -1520,25 +1541,25 @@ 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->eyeTexIndex = 0; this->blinkFunc = EnTrt_EyesClosed; - if (gSaveContext.save.weekEventReg[53] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_08)) { this->flags |= ENTRT_GIVEN_MUSHROOM; } 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 +1568,10 @@ 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 +1584,11 @@ 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 +1601,8 @@ 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 +1619,32 @@ 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 +1653,57 @@ 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_TrackPlayer(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_TrackPlayer(EnTrt* this, PlayState* play) { + Player* player = GET_PLAYER(play); Vec3f playerPos; Vec3f pos; @@ -1685,13 +1711,13 @@ void EnTrt_UpdateHeadYawAndPitch(EnTrt* this, GlobalContext* globalCtx) { this->headYaw = CLAMP(this->headYaw, -0x38E0, 0x38E0); playerPos = player->actor.world.pos; - playerPos.y = player->bodyPartsPos[7].y + 3.0f; + playerPos.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; pos = this->actor.world.pos; Math_SmoothStepToS(&this->headPitch, Math_Vec3f_Pitch(&pos, &playerPos), 4, 0x1C70, 1); this->headPitch = CLAMP(this->headPitch, -0x1C70, 0x1C70); } -void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 isFullyAwake) { +void EnTrt_UpdateLimb(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 overrideRot) { Vec3f newPos; Vec3f zeroVec = gZeroVec3f; Vec3s newRot; @@ -1701,7 +1727,7 @@ void EnTrt_UpdateHeadPosAndRot(s16 pitch, s16 yaw, Vec3f* pos, Vec3s* rot, s32 i Matrix_Get(¤tState); Matrix_MtxFToYXZRot(¤tState, &newRot, false); *pos = newPos; - if (isFullyAwake) { + if (overrideRot) { newRot.x += pitch; newRot.y += yaw; Math_SmoothStepToS(&rot->x, newRot.x, 4, 0x1FFE, 1); @@ -1714,7 +1740,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; @@ -1724,22 +1750,22 @@ s32 EnTrt_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, this->items[i]->actor.scale.z = 0.2f; } - if (limbIndex == 14) { + if (limbIndex == KOTAKE_LIMB_BROOM) { *dList = NULL; } 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; + s32 overrideRot; - isFullyAwake = false; + overrideRot = false; if (this->flags & ENTRT_FULLY_AWAKE) { - isFullyAwake = true; + overrideRot = true; } - if (limbIndex == 21) { - EnTrt_UpdateHeadPosAndRot(this->headPitch, this->headYaw, &this->headPos, &this->headRot, isFullyAwake); + if (limbIndex == KOTAKE_LIMB_HEAD) { + EnTrt_UpdateLimb(this->headPitch, this->headYaw, &this->headPos, &this->headRot, overrideRot); 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_RotateYS(this->headRot.y, MTXMODE_APPLY); @@ -1748,10 +1774,10 @@ void EnTrt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -void EnTrt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTrt_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTrt* this = THIS; - if (limbIndex == 21) { + if (limbIndex == KOTAKE_LIMB_HEAD) { 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_RotateYS(this->headRot.y, MTXMODE_APPLY); @@ -1760,21 +1786,21 @@ void EnTrt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } } -void EnTrt_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr sEyeTextures[] = { object_trt_Tex_00B0B8, object_trt_Tex_00B8B8, object_trt_Tex_00C0B8 }; +void EnTrt_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sEyeTextures[] = { gKotakeEyeOpenTex, gKotakeEyeHalfTex, gKotakeEyeClosedTex }; EnTrt* this = THIS; s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_8012C28C(globalCtx->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, + func_8012C28C(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + 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..c81032af5 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]; @@ -22,7 +22,7 @@ typedef struct EnTrt { /* 0x338 */ s32 stickAccumX; /* 0x33C */ s32 stickAccumY; /* 0x340 */ EnGirlA* items[3]; - /* 0x34C */ u8 cursorIdx; + /* 0x34C */ u8 cursorIndex; /* 0x350 */ StickDirectionPrompt stickLeftPrompt; /* 0x388 */ StickDirectionPrompt stickRightPrompt; /* 0x3C0 */ f32 shopItemSelectedTween; @@ -33,7 +33,7 @@ typedef struct EnTrt { /* 0x3D4 */ u8 arrowAnimState; /* 0x3D5 */ u8 stickAnimState; /* 0x3D6 */ s16 blinkTimer; - /* 0x3D8 */ s16 eyeTextureIdx; + /* 0x3D8 */ s16 eyeTexIndex; /* 0x3DC */ EnTrtBlinkFunc blinkFunc; /* 0x3E0 */ s16 cutscene; /* 0x3E2 */ s16 tmpGetMushroomCutscene; @@ -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; @@ -64,6 +64,4 @@ typedef enum { /* 3 */ ENTRT_CUTSCENESTATE_PLAYING } EnTrtCutsceneState; -extern const ActorInit En_Trt_InitVars; - #endif // Z_EN_TRT_H diff --git a/src/overlays/actors/ovl_En_Trt2/overlay.cfg b/src/overlays/actors/ovl_En_Trt2/overlay.cfg deleted file mode 100644 index 60a280872..000000000 --- a/src/overlays/actors/ovl_En_Trt2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Trt2 -z_en_trt2.c 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 f2b8c9138..4018a5021 100644 --- a/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c +++ b/src/overlays/actors/ovl_En_Trt2/z_en_trt2.c @@ -11,35 +11,48 @@ #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[] = { - { &object_trt_Anim_00DE68, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_trt_Anim_00EE98, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_trt_Anim_00FD34, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_0030EC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_trt_Anim_003D78, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_trt_Anim_00D52C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_000A44, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_001EF4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_002224, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_trt_Anim_002CB0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +typedef enum { + /* 0 */ TRT2_ANIM_IDLE, + /* 1 */ TRT2_ANIM_HALF_AWAKE, + /* 2 */ TRT2_ANIM_SLEEPING, + /* 3 */ TRT2_ANIM_WAKE_UP, + /* 4 */ TRT2_ANIM_SURPRISED, + /* 5 */ TRT2_ANIM_HANDS_ON_COUNTER, + /* 6 */ TRT2_ANIM_HOVER, + /* 7 */ TRT2_ANIM_FLY_LOOK_AROUND, + /* 8 */ TRT2_ANIM_FLY_DOWN, + /* 9 */ TRT2_ANIM_FLY +} Trt2Animation; + +static AnimationInfoS sAnimationInfo[] = { + { &gKotakeIdleAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeHalfAwakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeSleepingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeWakeUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKotakeHandsOnCounterAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyLookAroundAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKotakeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; -const ActorInit En_Trt2_InitVars = { +ActorInit En_Trt2_InitVars = { ACTOR_EN_TRT2, ACTORCAT_NPC, FLAGS, @@ -108,43 +121,43 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -void func_80AD3380(SkelAnime* skelAnime, AnimationInfoS* animation, s32 arg2) { - f32 phi_f0; +void EnTrt2_ChangeAnim(SkelAnime* skelAnime, AnimationInfoS* animationInfo, s32 animIndex) { + f32 endFrame; - animation += arg2; + animationInfo += animIndex; - if (animation->frameCount < 0) { - phi_f0 = Animation_GetLastFrame(animation->animation); + if (animationInfo->frameCount < 0) { + endFrame = Animation_GetLastFrame(animationInfo->animation); } else { - phi_f0 = animation->frameCount; + endFrame = animationInfo->frameCount; } - Animation_Change(skelAnime, animation->animation, animation->playSpeed, animation->startFrame, phi_f0, - animation->mode, animation->morphFrames); + Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame, endFrame, + animationInfo->mode, animationInfo->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) { - if ((gSaveContext.save.weekEventReg[85] & 0x10) && !(gSaveContext.save.weekEventReg[84] & 0x40)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_85_10) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_84_40)) { this->unk_3A8 = 0x88F; } else if (this->unk_3A8 == 0) { this->unk_3A8 = 0x84B; - } else if (gSaveContext.save.weekEventReg[16] & 0x10) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { this->unk_3A8 = 0x838; - } else if (gSaveContext.save.weekEventReg[17] & 1) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_17_01)) { this->unk_3A8 = 0x84D; } else { this->unk_3A8 = 0x849; } } -void func_80AD3530(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD3530(EnTrt2* this, PlayState* play) { s16 phi_a1; f32 sp30; @@ -170,12 +183,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); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY_LOOK_AROUND); 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 +203,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 +216,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 +233,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; @@ -230,15 +243,15 @@ void func_80AD381C(EnTrt2* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_10; } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -void func_80AD38B8(EnTrt2* this, GlobalContext* globalCtx) { +void func_80AD38B8(EnTrt2* this, PlayState* play) { Vec3s sp30; if (this->unk_3D9 == 2) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } if (this->path != NULL) { @@ -271,39 +284,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); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); 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); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); 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); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY_DOWN); 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 +324,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); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY); 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; + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); 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,90 +371,90 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_85_10); 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)) || - !(gSaveContext.save.weekEventReg[12] & 0x10)) { + if (talkState == TEXT_STATE_DONE) { + if (Message_ShouldAdvance(play)) { + if ((Inventory_HasEmptyBottle() && !CHECK_WEEKEVENTREG(WEEKEVENTREG_84_40)) || + !CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { this->unk_3B2 = 12; } else { - gSaveContext.save.weekEventReg[85] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_85_10); 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)) { - if (!(gSaveContext.save.weekEventReg[12] & 0x10)) { - gSaveContext.save.weekEventReg[12] |= 0x10; +void func_80AD3FF4(EnTrt2* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { + SET_WEEKEVENTREG(WEEKEVENTREG_12_10); } - gSaveContext.save.weekEventReg[84] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_84_40); 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); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_10)) { + 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); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_HOVER); + 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,12 +463,12 @@ 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); - player->stateFlags1 |= 0x20; + player->stateFlags1 |= PLAYER_STATE1_20; this->unk_3B2 = 6; } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { @@ -465,14 +478,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); + player->stateFlags1 &= ~PLAYER_STATE1_20; + Actor_Kill(&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 +502,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 +518,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); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY_LOOK_AROUND); 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 +551,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, &gKotakeSkel, &gKotakeHoverAnim, NULL, NULL, 0); this->actor.draw = func_80AD56E8; } @@ -602,7 +615,7 @@ s16 func_80AD48F8(Path* path, s32 arg1, Vec3f* arg2, f32* arg3) { phi_f12 = 0.0f; } *arg3 = SQ(phi_f14) + SQ(phi_f12); - return RADF_TO_BINANG(Math_Acot2F(phi_f12, phi_f14)); + return RADF_TO_BINANG(Math_Atan2F_XY(phi_f12, phi_f14)); } f32 func_80AD49B8(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { @@ -623,20 +636,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 +657,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 +670,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 +678,7 @@ s32 func_80AD4B4C(EnTrt2* this, GlobalContext* globalCtx) { } else { this->unk_3A8 = 0x84F; this->unk_3D8 = true; - func_80AD3380(&this->skelAnime, sAnimations, 7); + EnTrt2_ChangeAnim(&this->skelAnime, sAnimationInfo, TRT2_ANIM_FLY_LOOK_AROUND); this->unk_3B2 = 7; } } @@ -683,9 +696,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 +709,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 +731,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; @@ -729,34 +742,34 @@ void func_80AD4DB4(EnTrt2* this, GlobalContext* globalCtx) { this->unk_3B8 = 0; this->unk_3BC = func_80AD4608; - if (gSaveContext.save.weekEventReg[12] & 8) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_08)) { + Actor_Kill(&this->actor); return; } - if (gSaveContext.save.weekEventReg[84] & 0x40) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_84_40)) { + Actor_Kill(&this->actor); return; } - if ((globalCtx->sceneNum == SCENE_20SICHITAI) || (globalCtx->sceneNum == SCENE_20SICHITAI2)) { + if ((play->sceneId == SCENE_20SICHITAI) || (play->sceneId == SCENE_20SICHITAI2)) { if (gSaveContext.save.day == 2) { - if (!(gSaveContext.save.weekEventReg[15] & 0x80)) { - gSaveContext.save.weekEventReg[15] |= 0x80; + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_15_80)) { + SET_WEEKEVENTREG(WEEKEVENTREG_15_80); this->unk_3B2 = 3; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } else if (gSaveContext.save.day == 2) { - if (gSaveContext.save.weekEventReg[15] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_15_80)) { this->unk_3B2 = 4; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } else if (gSaveContext.save.day == 3) { @@ -765,7 +778,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 +787,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->sceneId != SCENE_20SICHITAI) { + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 10.0f, 0.0f, 5); } Actor_SetFocus(&this->actor, 90.0f); @@ -790,44 +803,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; @@ -837,9 +850,9 @@ void func_80AD5234(EnTrt2* this, GlobalContext* globalCtx) { sp40 = player->actor.world.pos; if (this->unk_3B2 == 8) { - sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp40.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; } else { - sp40.y = player->bodyPartsPos[7].y + 45.0f; + sp40.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 45.0f; } sp34 = this->actor.world.pos; @@ -873,18 +886,18 @@ 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)) { + if ((limbIndex == KOTAKE_LIMB_TORSO_LIMB) || (limbIndex == KOTAKE_LIMB_LEFT_HAND) || + (limbIndex == KOTAKE_LIMB_RIGHT_HAND)) { rot->y += (s16)Math_SinS(this->unk_33C[limbIndex]) * 200; rot->z += (s16)Math_CosS(this->unk_372[limbIndex]) * 200; } 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; @@ -893,7 +906,7 @@ void EnTrt2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V phi_v0 = true; } - if (limbIndex == 21) { + if (limbIndex == KOTAKE_LIMB_HEAD) { func_80AD5394(this->unk_3D4, this->unk_3D6, &this->unk_3C8, &this->unk_3C2, phi_v0); 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); @@ -904,10 +917,10 @@ void EnTrt2_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, V } } -void EnTrt2_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thisx) { +void EnTrt2_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { EnTrt2* this = THIS; - if (limbIndex == 21) { + if (limbIndex == KOTAKE_LIMB_HEAD) { 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_RotateYS(this->unk_3C2.y, MTXMODE_APPLY); @@ -916,25 +929,25 @@ void EnTrt2_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* th } } -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, - object_trt_Tex_00C0B8, + gKotakeEyeOpenTex, + gKotakeEyeHalfTex, + gKotakeEyeClosedTex, }; 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..44c2565f7 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) @@ -41,6 +41,4 @@ typedef struct EnTrt2 { /* 0x3DA */ s16 unk_3DA; } EnTrt2; // size = 0x3DC -extern const ActorInit En_Trt2_InitVars; - #endif // Z_EN_TRT2_H diff --git a/src/overlays/actors/ovl_En_Tru/overlay.cfg b/src/overlays/actors/ovl_En_Tru/overlay.cfg deleted file mode 100644 index 49e1ffdd9..000000000 --- a/src/overlays/actors/ovl_En_Tru/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tru -z_en_tru.c 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 d428553f8..733ea0c57 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -5,24 +5,44 @@ */ #include "z_en_tru.h" -#include "objects/object_tru/object_tru.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_20) #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); + +typedef enum { + /* 0x00 */ KOUME_ANIM_INJURED_LYING_DOWN, + /* 0x01 */ KOUME_ANIM_INJURED_LYING_DOWN_MORPH, + /* 0x02 */ KOUME_ANIM_TRY_GET_UP, + /* 0x03 */ KOUME_ANIM_INJURED_RAISE_HEAD, + /* 0x04 */ KOUME_ANIM_INJURED_TALK, + /* 0x05 */ KOUME_ANIM_INJURED_HEAD_UP, + /* 0x06 */ KOUME_ANIM_INJURED_HEAD_UP_MORPH, + /* 0x07 */ KOUME_ANIM_TAKE, + /* 0x08 */ KOUME_ANIM_SHAKE, // Unused + /* 0x09 */ KOUME_ANIM_DRINK, + /* 0x0A */ KOUME_ANIM_FINISHED_DRINKING, + /* 0x0B */ KOUME_ANIM_HEALED, + /* 0x0C */ KOUME_ANIM_HOVER1, + /* 0x0D */ KOUME_ANIM_TAKE_OFF, + /* 0x0E */ KOUME_ANIM_FLY, + /* 0x0F */ KOUME_ANIM_HOVER2, + /* 0x10 */ KOUME_ANIM_MAX +} KoumeAnimation; static UNK_TYPE D_80A88910[] = { 0x0E08520C, @@ -56,7 +76,7 @@ static UNK_TYPE D_80A889A4[] = { 0x550C1000, }; -const ActorInit En_Tru_InitVars = { +ActorInit En_Tru_InitVars = { ACTOR_EN_TRU, ACTORCAT_NPC, FLAGS, @@ -69,7 +89,6 @@ const ActorInit En_Tru_InitVars = { }; #include "overlays/ovl_En_Tru/ovl_En_Tru.c" -#include "objects/gameplay_keep/gameplay_keep.h" static Vec3f D_80A8B250 = { 0.0f, 0.02f, 0.0f }; @@ -80,8 +99,8 @@ static Color_RGBA8 D_80A8B25C[] = { static f32 D_80A8B274[] = { 60.0f, 255.0f, 60.0f }; -static TexturePtr D_80A8B280[] = { - gDust8Tex, gDust7Tex, gDust6Tex, gDust5Tex, gDust4Tex, gDust3Tex, gDust2Tex, gDust1Tex, +static TexturePtr sDustTextures[] = { + gEffDust8Tex, gEffDust7Tex, gEffDust6Tex, gEffDust5Tex, gEffDust4Tex, gEffDust3Tex, gEffDust2Tex, gEffDust1Tex, }; static ColliderSphereInit sSphereInit = { @@ -106,23 +125,23 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 20, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS D_80A8B2D8[] = { - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +static AnimationInfoS sAnimationInfo[] = { + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTryGetUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredRaiseHeadAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeInjuredTalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeShakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeDrinkAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFinishedDrinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeHealedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeTakeOffAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; static Vec3f D_80A8B3D8 = { 0.0f, 24.0f, 16.0f }; @@ -148,13 +167,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 +193,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_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(arg0->unk_28, arg0->unk_28, 1.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 +226,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) { @@ -235,16 +253,15 @@ void func_80A85BCC(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, (u8)alpha); Matrix_Translate(arg0->unk_04.x, arg0->unk_04.y, arg0->unk_04.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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,22 +284,22 @@ 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; - s32 idx; + s32 index; if ((arg0->unk_00 == 3) || (arg0->unk_00 == 4) || (arg0->unk_00 == 5)) { if (!flag) { - POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, sizeof(Gfx) * 0); - gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_01A820); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gSPDisplayList(POLY_XLU_DISP++, gKoumeDustMaterialDL); flag = true; } @@ -305,22 +322,21 @@ void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx) { 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_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->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); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + index = ((f32)arg0->unk_02 / arg0->unk_01) * 8.0f; + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[index])); + gSPDisplayList(POLY_XLU_DISP++, gKoumeDustModelDL); Matrix_Pop(); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #else -void func_80A85F84(EnTruUnkStruct* arg0, GlobalContext* globalCtx); +void func_80A85F84(EnTruUnkStruct* arg0, PlayState* play); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Tru/func_80A85F84.s") #endif @@ -417,39 +433,39 @@ s32 func_80A86770(EnTru* this) { return false; } -void func_80A868F8(EnTru* this) { - this->skelAnime.playSpeed = this->unk_358; +void EnTru_UpdateSkelAnime(EnTru* this) { + this->skelAnime.playSpeed = this->playSpeed; SkelAnime_Update(&this->skelAnime); } -s32 func_80A86924(EnTru* this, s32 arg1) { - s32 ret = false; +s32 EnTru_ChangeAnim(EnTru* this, s32 animIndex) { + s32 didChange = false; - if (arg1 != this->unk_37C) { - this->unk_37C = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, D_80A8B2D8, arg1); - this->unk_358 = this->skelAnime.playSpeed; + if (animIndex != this->animIndex) { + this->animIndex = animIndex; + didChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->playSpeed = this->skelAnime.playSpeed; } - return ret; + return didChange; } -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; Math_ApproachS(&this->unk_368, this->actor.yawTowardsPlayer - this->actor.shape.rot.y, 4, 0x2AA8); this->unk_368 = CLAMP(this->unk_368, -0x1FFE, 0x1FFE); Math_Vec3f_Copy(&sp38, &player->actor.world.pos); - sp38.y = player->bodyPartsPos[7].y + 3.0f; + sp38.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; Math_Vec3f_Copy(&sp2C, &this->actor.focus.pos); sp2C.y -= 30.0f; Math_ApproachS(&this->unk_366, Math_Vec3f_Pitch(&sp2C, &sp38), 4, 0x2AA8); @@ -458,11 +474,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; @@ -476,12 +492,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_Push(); - func_8012C28C(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); switch (this->unk_390) { case 1: @@ -499,30 +515,30 @@ s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { Matrix_RotateXS(-0x4000, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0020C8); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gKoumePotionDL); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (this->unk_34E & 0x800) { Matrix_Push(); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); Matrix_RotateXS(-0x4000, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_tru_DL_001F90); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gKoumeBottleDL); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } return false; @@ -530,104 +546,105 @@ s32 func_80A86BAC(EnTru* this, GlobalContext* globalCtx) { s32 func_80A86DB8(EnTru* this) { if (this->unk_34E & 0x80) { - this->unk_36E = 2; + this->eyeTexIndex = 2; return false; } - switch (this->unk_37C) { - case 0: - case 1: - if (DECR(this->unk_36C) == 0) { + switch (this->animIndex) { + case KOUME_ANIM_INJURED_LYING_DOWN: + case KOUME_ANIM_INJURED_LYING_DOWN_MORPH: + if (DECR(this->blinkTimer) == 0) { s16 rand = Rand_S16Offset(40, 20); - if (this->unk_36E == 2) { - this->unk_36C = 8; + + if (this->eyeTexIndex == 2) { + this->blinkTimer = 8; } else { - this->unk_36C = rand; + this->blinkTimer = rand; } - if (this->unk_36E == 2) { - this->unk_36E = 1; + if (this->eyeTexIndex == 2) { + this->eyeTexIndex = 1; } else { - this->unk_36E = 2; + this->eyeTexIndex = 2; } } return false; - case 2: + case KOUME_ANIM_TRY_GET_UP: if (Animation_OnFrame(&this->skelAnime, 10.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if ((this->skelAnime.curFrame >= 11.0f) && (this->skelAnime.curFrame <= 32.0f)) { - this->unk_36E = 0; + this->eyeTexIndex = 0; } else { - this->unk_36E = 2; + this->eyeTexIndex = 2; } return false; - case 3: + case KOUME_ANIM_INJURED_RAISE_HEAD: if (Animation_OnFrame(&this->skelAnime, 31.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if (this->skelAnime.curFrame <= 32.0f) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 0; + this->eyeTexIndex = 0; } return false; - case 9: + case KOUME_ANIM_DRINK: if (Animation_OnFrame(&this->skelAnime, 57.0f)) { - this->unk_36C = 0; - this->unk_36E = 0; + this->blinkTimer = 0; + this->eyeTexIndex = 0; } if (this->skelAnime.curFrame < 57.0f) { - if (DECR(this->unk_36C) == 0) { - this->unk_36C = Rand_S16Offset(8, 8); - this->unk_36E = 2; + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(8, 8); + this->eyeTexIndex = 2; } else { - this->unk_36E = 1; + this->eyeTexIndex = 1; } - } else if (DECR(this->unk_36C) == 0) { - this->unk_36E++; - if (this->unk_36E >= 4) { - this->unk_36C = Rand_S16Offset(20, 10); - this->unk_36E = 0; + } else if (DECR(this->blinkTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 4) { + this->blinkTimer = Rand_S16Offset(20, 10); + this->eyeTexIndex = 0; } } return false; - case 10: - this->unk_36E = 0; + case KOUME_ANIM_FINISHED_DRINKING: + this->eyeTexIndex = 0; return false; - case 11: + case KOUME_ANIM_HEALED: if (Animation_OnFrame(&this->skelAnime, 19.0f) || Animation_OnFrame(&this->skelAnime, 45.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if ((this->skelAnime.curFrame >= 19.0f) && (this->skelAnime.curFrame <= 45.0f)) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 3; + this->eyeTexIndex = 3; } return false; - case 13: + case KOUME_ANIM_TAKE_OFF: if (Animation_OnFrame(&this->skelAnime, 19.0f)) { - this->unk_36E = 1; + this->eyeTexIndex = 1; } else if (this->skelAnime.curFrame >= 19.0f) { - this->unk_36E = 2; + this->eyeTexIndex = 2; } else { - this->unk_36E = 0; + this->eyeTexIndex = 0; } return false; default: - if (DECR(this->unk_36C) == 0) { - if ((this->unk_36E != 2) || !(this->unk_34E & 0x80)) { - this->unk_36E++; + if (DECR(this->blinkTimer) == 0) { + if ((this->eyeTexIndex != 2) || !(this->unk_34E & 0x80)) { + this->eyeTexIndex++; } - if (this->unk_36E >= 4) { - this->unk_36C = Rand_S16Offset(30, 30); - this->unk_36E = 0; + if (this->eyeTexIndex >= 4) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = 0; } } return false; @@ -636,7 +653,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; @@ -654,23 +671,23 @@ UNK_TYPE* func_80A871E0(EnTru* this, GlobalContext* globalCtx) { return D_80A88924; } - if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { + if (!(this->unk_34E & 0x40) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { return D_80A88918; } - if ((this->unk_34E & 0x1000) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x1000) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { return D_80A88910; } 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 +703,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 +725,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,13 +764,13 @@ 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; switch (this->unk_364) { case 0: - if ((this->unk_34E & 0x40) || (gSaveContext.save.weekEventReg[16] & 0x10)) { + if ((this->unk_34E & 0x40) || CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { this->unk_374 = this->actor.cutscene; this->unk_364++; } else { @@ -775,11 +792,12 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { break; case 2: - if ((this->unk_37C != 5) && (this->unk_37C != 6)) { - func_80A86924(this, 3); + if ((this->animIndex != KOUME_ANIM_INJURED_HEAD_UP) && + (this->animIndex != KOUME_ANIM_INJURED_HEAD_UP_MORPH)) { + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_RAISE_HEAD); this->unk_364++; } else { - func_80A86924(this, 4); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_TALK); ret = true; } break; @@ -787,7 +805,7 @@ s32 func_80A875AC(Actor* thisx, GlobalContext* globalCtx) { case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 4); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_TALK); ret = true; } break; @@ -806,41 +824,44 @@ 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); + PlayerItemAction itemAction; - 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: + itemAction = func_80123810(play); + + if ((itemAction == PLAYER_IA_BOTTLE_POTION_RED) || (itemAction == PLAYER_IA_BOTTLE_POTION_BLUE)) { + this->unk_34E |= 8; + if (itemAction == PLAYER_IA_BOTTLE_POTION_RED) { + this->unk_390 = 1; + } else { + this->unk_390 = 2; + } + this->unk_378 = func_80A87880; + this->unk_364 = 0; + ret = 1; + } else if (itemAction <= PLAYER_IA_MINUS1) { + ret = 3; + } else if (itemAction != PLAYER_IA_NONE) { + 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; @@ -867,32 +888,32 @@ s32 func_80A87880(Actor* thisx, GlobalContext* globalCtx) { this->unk_34E &= ~0x8; this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; - func_80A86924(this, 7); + EnTru_ChangeAnim(this, KOUME_ANIM_TAKE); this->unk_364++; break; case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 9); + EnTru_ChangeAnim(this, KOUME_ANIM_DRINK); this->actor.world.rot.y += 0x4000; } 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, PLAYER_MODELGROUP_DEFAULT); } break; case 4: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_364++; - func_80A86924(this, 10); + EnTru_ChangeAnim(this, KOUME_ANIM_FINISHED_DRINKING); ret = true; } else if (Animation_OnFrame(&this->skelAnime, 18.0f) || Animation_OnFrame(&this->skelAnime, 32.0f) || Animation_OnFrame(&this->skelAnime, 52.0f)) { if (Animation_OnFrame(&this->skelAnime, 52.0f)) { this->unk_34E &= ~0x400; - func_80123D50(globalCtx, player, 18, 21); + Player_UpdateBottleHeld(play, player, ITEM_BOTTLE, PLAYER_IA_BOTTLE); } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_KOUME_DRINK); } else if (Animation_OnFrame(&this->skelAnime, 90.0f)) { @@ -913,9 +934,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; @@ -924,18 +945,18 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { switch (this->unk_364) { case 0: - func_80A86924(this, 11); + EnTru_ChangeAnim(this, KOUME_ANIM_HEALED); this->unk_364++; break; 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); + Play_FillScreen(&play->state, true, 160, 160, 160, 0); this->unk_370 = 20; this->unk_372 = 10; this->unk_364++; @@ -947,7 +968,7 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { case 2: if (DECR(this->unk_370) != 0) { - MREG(68) = 255.0f - ((fabsf(10.0f - this->unk_370) / 10) * 255.0f); + R_PLAY_FILL_SCREEN_ALPHA = 255.0f - ((fabsf(10.0f - this->unk_370) / 10) * 255.0f); if (this->unk_370 == 9) { this->actor.shape.shadowDraw = NULL; this->unk_34E |= (0x200 | 0x8); @@ -955,10 +976,10 @@ s32 func_80A87B48(Actor* thisx, GlobalContext* globalCtx) { if (player->exchangeItemId != 0) { player->exchangeItemId = 0; } - func_80A86924(this, 12); + EnTru_ChangeAnim(this, KOUME_ANIM_HOVER1); } } else { - MREG(64) = 0; + R_PLAY_FILL_SCREEN_ON = false; ret = true; } break; @@ -972,7 +993,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,10 +1016,10 @@ 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); + EnTru_ChangeAnim(this, KOUME_ANIM_TAKE_OFF); this->skelAnime.baseTransl.y = 0; this->skelAnime.moveFlags = 2; this->unk_34E &= ~0x8; @@ -1008,19 +1029,19 @@ 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); + EnTru_ChangeAnim(this, KOUME_ANIM_FLY); this->actor.shape.rot.y = this->actor.world.rot.y; this->unk_362 = 20; this->unk_364++; } 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; + SET_WEEKEVENTREG(WEEKEVENTREG_12_08); } break; } @@ -1035,9 +1056,9 @@ 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 ((this->unk_34E & 0x80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { if (func_80A873B8(this)) { SubS_UpdateFlags(&this->unk_34E, 3, 7); } else { @@ -1050,16 +1071,17 @@ void func_80A87FD0(EnTru* this, GlobalContext* globalCtx) { SubS_UpdateFlags(&this->unk_34E, 0, 7); } - if ((this->unk_37C == 2) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->animIndex == KOUME_ANIM_TRY_GET_UP) && + Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->unk_362 = Rand_S16Offset(40, 20); - func_80A86924(this, 1); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN_MORPH); func_80A86460(this); - } else if (this->unk_37C != 2) { + } else if (this->animIndex != KOUME_ANIM_TRY_GET_UP) { if (DECR(this->unk_362) == 0) { - func_80A86924(this, 2); + EnTru_ChangeAnim(this, KOUME_ANIM_TRY_GET_UP); } } - } else if (!(gSaveContext.save.weekEventReg[16] & 0x10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10) && (fabsf(this->actor.playerHeightRel) < 10.0f) && (this->actor.xzDistToPlayer < 140.0f)) { SubS_UpdateFlags(&this->unk_34E, 4, 7); this->unk_34E |= 0x1040; @@ -1072,10 +1094,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; } @@ -1084,13 +1106,13 @@ void func_80A881E0(EnTru* this, GlobalContext* globalCtx) { ActorCutscene_Stop(ActorCutscene_GetCurrentIndex()); } - if (!(this->unk_34E & 0x40) && !(gSaveContext.save.weekEventReg[16] & 0x10)) { - func_80A86924(this, 0); + if (!(this->unk_34E & 0x40) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); } else if (this->unk_34E & 0x80) { - func_80A86924(this, 0); + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); func_80A86460(this); - } else if (gSaveContext.save.weekEventReg[16] & 0x10) { - func_80A86924(this, 6); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_HEAD_UP_MORPH); } SubS_UpdateFlags(&this->unk_34E, 0, 7); @@ -1103,22 +1125,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)) { - Actor_MarkForDeath(&this->actor); + if ((gSaveContext.save.entrance != ENTRANCE(WOODS_OF_MYSTERY, 0)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_12_08)) { + Actor_Kill(&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, &gKoumeSkel, NULL, this->jointTable, this->morphTable, KOUME_LIMB_MAX); + 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->animIndex = -1; + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_LYING_DOWN); + this->path = SubS_GetDayDependentPath(play, ENTRU_GET_PATH(&this->actor), 255, &this->unk_384); if (this->path != NULL) { this->unk_384 = 1; } @@ -1127,47 +1148,47 @@ void EnTru_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.008f); this->unk_34E = 0; - if (gSaveContext.save.weekEventReg[16] & 0x10) { - func_80A86924(this, 5); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_16_10)) { + EnTru_ChangeAnim(this, KOUME_ANIM_INJURED_HEAD_UP); } else { - this->unk_388 = EXCH_ITEM_NONE; + this->unk_388 = PLAYER_IA_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); + EnTru_UpdateSkelAnime(this); + func_80A86B0C(this, play); func_80A86DB8(this); radius = this->collider.dim.worldSphere.radius + 30; - this->unk_388 = !(this->unk_34E & 0x80) ? EXCH_ITEM_NONE : EXCH_ITEM_NONE; + this->unk_388 = !(this->unk_34E & 0x80) ? PLAYER_IA_NONE : PLAYER_IA_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) { + if (limbIndex == KOUME_LIMB_HEAD) { 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; @@ -1177,22 +1198,22 @@ s32 EnTru_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Matrix_MultVec3f(&D_80A8B3FC, &this->unk_1F8); } - if (!(this->unk_34E & 0x200) && (limbIndex == 14)) { + if (!(this->unk_34E & 0x200) && (limbIndex == KOUME_LIMB_BROOM)) { *dList = NULL; } 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); + if (limbIndex == KOUME_LIMB_RIGHT_HAND) { + 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 overrideRot; @@ -1214,7 +1235,7 @@ void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi overrideRot = false; } - if (limbIndex == 21) { + if (limbIndex == KOUME_LIMB_HEAD) { SubS_UpdateLimb(this->unk_366, this->unk_368 + this->actor.shape.rot.y, &this->unk_1EC, &this->unk_204, stepRot, overrideRot); Matrix_Pop(); @@ -1233,29 +1254,29 @@ void EnTru_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* thi } } -void EnTru_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_80A8B408[] = { - object_tru_Tex_018FA0, - object_tru_Tex_0197A0, - object_tru_Tex_019FA0, - object_tru_Tex_0197A0, +void EnTru_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sEyeTextures[] = { + gKoumeEyeOpenTex, + gKoumeEyeHalfTex, + gKoumeEyeClosedTex, + gKoumeEyeHalfTex, }; 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])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); - 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..48964b555 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.h +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.h @@ -2,11 +2,12 @@ #define Z_EN_TRU_H #include "global.h" +#include "objects/object_tru/object_tru.h" 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,43 +23,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[KOUME_LIMB_MAX]; + /* 0x2AC */ Vec3s morphTable[KOUME_LIMB_MAX]; + /* 0x34E */ u16 unk_34E; + /* 0x350 */ UNK_TYPE1 unk350[0x4]; + /* 0x354 */ s32* unk_354; + /* 0x358 */ f32 playSpeed; + /* 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 blinkTimer; + /* 0x36E */ s16 eyeTexIndex; + /* 0x370 */ s16 unk_370; + /* 0x372 */ s16 unk_372; + /* 0x374 */ s16 unk_374; + /* 0x378 */ EnTruUnkFunc unk_378; + /* 0x37C */ s32 animIndex; + /* 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; - #endif // Z_EN_TRU_H diff --git a/src/overlays/actors/ovl_En_Tru_Mt/overlay.cfg b/src/overlays/actors/ovl_En_Tru_Mt/overlay.cfg deleted file mode 100644 index 8c432043f..000000000 --- a/src/overlays/actors/ovl_En_Tru_Mt/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tru_Mt -z_en_tru_mt.c 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 3be859a99..e51af14ae 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,16 +11,36 @@ #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 = { +typedef enum { + /* 0x00 */ KOUME_MT_ANIM_INJURED_LYING_DOWN, + /* 0x01 */ KOUME_MT_ANIM_INJURED_LYING_DOWN_MORPH, + /* 0x02 */ KOUME_MT_ANIM_TRY_GET_UP, + /* 0x03 */ KOUME_MT_ANIM_INJURED_RAISE_HEAD, + /* 0x04 */ KOUME_MT_ANIM_INJURED_TALK, + /* 0x05 */ KOUME_MT_ANIM_INJURED_HEAD_UP, + /* 0x06 */ KOUME_MT_ANIM_INJURED_HEAD_UP_MORPH, + /* 0x07 */ KOUME_MT_ANIM_TAKE, + /* 0x08 */ KOUME_MT_ANIM_SHAKE, // Unused + /* 0x09 */ KOUME_MT_ANIM_DRINK, + /* 0x0A */ KOUME_MT_ANIM_FINISHED_DRINKING, + /* 0x0B */ KOUME_MT_ANIM_HEALED, + /* 0x0C */ KOUME_MT_ANIM_HOVER1, + /* 0x0D */ KOUME_MT_ANIM_TAKE_OFF, + /* 0x0E */ KOUME_MT_ANIM_FLY, + /* 0x0F */ KOUME_MT_ANIM_HOVER2, + /* 0x10 */ KOUME_MT_ANIM_MAX +} KoumeMtAnimation; + +ActorInit En_Tru_Mt_InitVars = { ACTOR_EN_TRU_MT, ACTORCAT_NPC, FLAGS, @@ -87,58 +107,58 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static AnimationInfoS D_80B7755C[] = { - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_00F9A0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_0108AC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_009348, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_00EEDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_015CA0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_014728, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_01B5C4, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_tru_Anim_007FA0, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_016B4C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_tru_Anim_011F88, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_003698, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_tru_Anim_002BD8, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_tru_Anim_00446C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +static AnimationInfoS sAnimationInfo[] = { + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredLyingDownAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTryGetUpAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredRaiseHeadAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeInjuredTalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeInjuredHeadUpAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeTakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeShakeAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, + { &gKoumeDrinkAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFinishedDrinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, + { &gKoumeHealedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeTakeOffAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, + { &gKoumeFlyAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, + { &gKoumeHoverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, }; Vec3f D_80B7765C = { 3000.0f, -800.0f, 0.0f }; Vec3f D_80B77668 = { 0.0f, 0.0f, -3000.0f }; -s32 func_80B76030(SkelAnime* skelAnime, s16 arg1) { +s32 EnTruMt_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { s16 endFrame; s16 startFrame; - s32 ret = false; + s32 didChange = false; - if ((arg1 >= 0) && (arg1 < ARRAY_COUNT(D_80B7755C))) { - endFrame = D_80B7755C[arg1].frameCount; + if ((animIndex >= KOUME_MT_ANIM_INJURED_LYING_DOWN) && (animIndex < KOUME_MT_ANIM_MAX)) { + endFrame = sAnimationInfo[animIndex].frameCount; if (endFrame < 0) { - endFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + endFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - startFrame = D_80B7755C[arg1].startFrame; + startFrame = sAnimationInfo[animIndex].startFrame; if (startFrame < 0) { - startFrame = Animation_GetLastFrame(D_80B7755C[arg1].animation); + startFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } - Animation_Change(skelAnime, D_80B7755C[arg1].animation, D_80B7755C[arg1].playSpeed, startFrame, endFrame, - D_80B7755C[arg1].mode, D_80B7755C[arg1].morphFrames); - ret = true; + Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, + startFrame, endFrame, sAnimationInfo[animIndex].mode, sAnimationInfo[animIndex].morphFrames); + didChange = true; } - return ret; + return didChange; } void func_80B76110(EnTruMt* this) { - if (DECR(this->unk_34E) == 0) { - this->unk_34C++; - if (this->unk_34C >= 3) { - this->unk_34E = Rand_S16Offset(30, 30); - this->unk_34C = 0; + if (DECR(this->blinkTimer) == 0) { + this->eyeTexIndex++; + if (this->eyeTexIndex >= 3) { + this->blinkTimer = Rand_S16Offset(30, 30); + this->eyeTexIndex = 0; } } } @@ -149,7 +169,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 +185,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.minigameHiddenPoints = 1; Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 25); return true; } @@ -177,13 +197,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 +217,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 +242,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 +309,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; @@ -298,7 +318,7 @@ void func_80B7679C(EnTruMt* this, GlobalContext* globalCtx) { this->unk_34A = CLAMP(this->unk_34A, -0x38E0, 0x38E0); sp40 = player->actor.world.pos; - sp40.y = player->bodyPartsPos[7].y + 3.0f; + sp40.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; sp34 = this->actor.world.pos; sp34.y += 30.0f; @@ -307,9 +327,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,34 +339,34 @@ 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); - gSaveContext.eventInf[3] |= 0x40; - gSaveContext.eventInf[4] |= 1; - player->stateFlags3 &= ~0x400; + if (gSaveContext.minigameHiddenScore >= 10) { + Message_StartTextbox(play, 0x87F, &this->actor); + SET_EVENTINF(EVENTINF_36); + SET_EVENTINF(EVENTINF_40); + player->stateFlags3 &= ~PLAYER_STATE3_400; this->actor.speedXZ = 0.0f; this->actionFunc = func_80B76BB8; - } else if (gSaveContext.eventInf[4] & 1) { + } else if (CHECK_EVENTINF(EVENTINF_40)) { u32 score = gSaveContext.minigameScore; if (((gSaveContext.save.unk_EE8 & 0xFFFF0000) >> 0x10) < score) { gSaveContext.save.unk_EE8 = ((gSaveContext.minigameScore & 0xFFFF) << 0x10) | (gSaveContext.save.unk_EE8 & 0xFFFF); - gSaveContext.eventInf[3] |= 0x80; + SET_EVENTINF(EVENTINF_37); } } } -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); - player->stateFlags3 |= 0x400; + func_80B76980(this, play); + player->stateFlags3 |= PLAYER_STATE3_400; if (this->path != NULL) { func_80B76540(this->path, this->unk_36C, &this->actor.world.pos, &sp34); @@ -366,84 +386,83 @@ 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); - player->stateFlags3 |= 0x400; + func_80B76980(this, play); + player->stateFlags3 |= PLAYER_STATE3_400; } -void EnTruMt_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnTruMt_Init(Actor* thisx, PlayState* play) { s32 pad; EnTruMt* this = THIS; - if (!(gSaveContext.eventInf[3] & 0x20)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_EVENTINF(EVENTINF_35)) { + Actor_Kill(&this->actor); return; } - if (func_80B763C4(this, globalCtx)) { - Actor_MarkForDeath(&this->actor); + if (func_80B763C4(this, play)) { + Actor_Kill(&this->actor); return; } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_tru_Skel_01AA60, NULL, this->jointTable, this->morphTable, - OBJECT_TRU_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gKoumeSkel, NULL, this->jointTable, this->morphTable, KOUME_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); - func_80B76030(&this->skelAnime, 14); + this->path = SubS_GetPathByIndex(play, ENTRUMT_GET_FC00(&this->actor), 0x3F); + EnTruMt_ChangeAnim(&this->skelAnime, KOUME_MT_ANIM_FLY); 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); + if (!CHECK_EVENTINF(EVENTINF_40)) { + func_80B761FC(this, play); } Actor_MoveWithoutGravity(&this->actor); @@ -474,27 +493,26 @@ 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) { + if (limbIndex == KOUME_LIMB_HEAD) { Matrix_MultVec3f(&gZeroVec3f, &this->unk_35C); } - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { 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; s32 phi_v0; - if (limbIndex == OBJECT_TRU_LIMB_15) { + if (limbIndex == KOUME_LIMB_HEAD) { if (this->unk_328 & 0x10) { phi_v0 = 1; } else { @@ -508,27 +526,27 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Matrix_RotateZS(this->unk_336.z, MTXMODE_APPLY); } - if (limbIndex == OBJECT_TRU_LIMB_0E) { - func_8012C28C(globalCtx->state.gfxCtx); + if (limbIndex == KOUME_LIMB_BROOM) { + func_8012C28C(play->state.gfxCtx); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_MultVec3f(&D_80B77668, &this->unk_370); Matrix_Translate(this->unk_370.x, this->unk_370.y, this->unk_370.z, MTXMODE_NEW); - Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), MTXMODE_APPLY); + Matrix_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); - gSPDisplayList(POLY_OPA_DISP++, object_tru_DL_0004C8); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gKoumeChainDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); sp54 = Matrix_GetCurrent(); if ((this->actor.child == NULL) || (this->actor.child->update == NULL)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_JC_MATO, sp54->xw, sp54->yw, - sp54->zw, this->unk_38E.x, BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))), + 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->xw; @@ -536,17 +554,17 @@ void EnTruMt_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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) { + if (limbIndex == KOUME_LIMB_HEAD) { Matrix_Translate(this->unk_33C.x, this->unk_33C.y, this->unk_33C.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_RotateYS(this->unk_336.y, MTXMODE_APPLY); @@ -555,24 +573,24 @@ void EnTruMt_TransformLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Actor* t } } -void EnTruMt_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnTruMt_Draw(Actor* thisx, PlayState* play) { EnTruMt* this = THIS; - TexturePtr sp48[] = { - object_tru_Tex_018FA0, - object_tru_Tex_0197A0, - object_tru_Tex_019FA0, + TexturePtr eyeTextures[] = { + gKoumeEyeOpenTex, + gKoumeEyeHalfTex, + gKoumeEyeClosedTex, }; - 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])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(eyeTextures[this->eyeTexIndex])); - 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..b114804d7 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,41 +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[KOUME_LIMB_MAX]; + /* 0x286 */ Vec3s morphTable[KOUME_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 eyeTexIndex; + /* 0x34E */ s16 blinkTimer; + /* 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; - #endif // Z_EN_TRU_MT_H diff --git a/src/overlays/actors/ovl_En_Tsn/overlay.cfg b/src/overlays/actors/ovl_En_Tsn/overlay.cfg deleted file mode 100644 index 7c9110389..000000000 --- a/src/overlays/actors/ovl_En_Tsn/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tsn -z_en_tsn.c 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 217d32540..a9631d96b 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.c @@ -5,30 +5,31 @@ */ #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 = { +ActorInit En_Tsn_InitVars = { ACTOR_EN_TSN, ACTORCAT_NPC, FLAGS, @@ -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; @@ -86,15 +87,15 @@ void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { switch (ENTSN_GET_F(&this->actor)) { case ENTSN_F_0: - if (gSaveContext.save.weekEventReg[26] & 8) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_26_08)) { + Actor_Kill(&this->actor); return; } this->actor.textId = 0x106E; break; case ENTSN_F_1: - if (gSaveContext.save.weekEventReg[26] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_26_04)) { this->actor.textId = 0x1091; } else { this->actor.textId = 0x108A; @@ -102,38 +103,38 @@ void func_80ADFCEC(EnTsn* this, GlobalContext* globalCtx) { break; } - if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { if ((ENTSN_GET_F(&this->actor)) == ENTSN_F_0) { this->actionFunc = func_80AE0D78; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } 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); + Actor_Kill(&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; @@ -143,39 +144,39 @@ void EnTsn_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.terminalVelocity = -9.0f; this->actor.gravity = -1.0f; - if (gSaveContext.save.weekEventReg[55] & 0x80) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&this->actor); } } -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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_26_08)) { textId = 0x107E; } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.save.weekEventReg[25] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_80)) { textId = 0x1083; } else { textId = 0x107F; } - } else if (gSaveContext.save.weekEventReg[26] & 1) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_26_01)) { textId = 0x1089; } else { 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); + SET_WEEKEVENTREG(WEEKEVENTREG_25_80); + func_801477B4(play); this->actionFunc = func_80AE0304; this->actor.textId = 0; break; case 0x1083: - gSaveContext.save.weekEventReg[25] |= 0x80; - func_801477B4(globalCtx); + SET_WEEKEVENTREG(WEEKEVENTREG_25_80); + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_26_01); + 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; + SET_WEEKEVENTREG(WEEKEVENTREG_26_01); 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,50 @@ 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); - Actor_MarkForDeath(&this->actor); +void func_80AE0418(EnTsn* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->actor, play)) { + Message_StartTextbox(play, 0x107D, NULL); + Actor_Kill(&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) { - s32 sp24; - Player* player = GET_PLAYER(globalCtx); +void func_80AE04FC(EnTsn* this, PlayState* play) { + PlayerItemAction itemAction; + Player* player = GET_PLAYER(play); - if (Message_GetState(&globalCtx->msgCtx) == 0x10) { - sp24 = func_80123810(globalCtx); - if (sp24 != 0) { - gSaveContext.save.weekEventReg[26] |= 2; + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemAction = func_80123810(play); + + if (itemAction != PLAYER_IA_NONE) { + SET_WEEKEVENTREG(WEEKEVENTREG_26_02); } - if (sp24 > 0) { - func_801477B4(globalCtx); + if (itemAction > PLAYER_IA_NONE) { + func_801477B4(play); this->actionFunc = func_80AE0704; - if (sp24 == 19) { - if (CHECK_QUEST_ITEM(QUEST_UNK_19)) { - if (func_8013A4C4(1 | 8)) { + if (itemAction == PLAYER_IA_PICTO_BOX) { + 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; } @@ -344,7 +346,7 @@ void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { return; } - if (sp24 == 13) { + if (itemAction == PLAYER_IA_HOOKSHOT) { player->actor.textId = 0x1075; return; } @@ -354,16 +356,16 @@ void func_80AE04FC(EnTsn* this, GlobalContext* globalCtx) { return; } - if (sp24 < 0) { - func_80151938(globalCtx, 0x1078); + if (itemAction <= PLAYER_IA_MINUS1) { + 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,30 +373,30 @@ 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_25_40)) { + func_80151938(play, 0x1074); } else { - func_80151938(globalCtx, 0x106F); + func_80151938(play, 0x106F); } this->unk_220 |= 2; - gSaveContext.save.weekEventReg[25] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_25_40); ENTSN_SET_Z(&this->unk_1D8->actor, true); this->unk_220 |= 4; break; @@ -403,51 +405,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()) { - gSaveContext.save.weekEventReg[26] |= 8; - func_801477B4(globalCtx); + if (Inventory_HasEmptyBottle()) { + SET_WEEKEVENTREG(WEEKEVENTREG_26_08); + 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,15 +457,15 @@ 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; case 0x108A: case 0x1091: - gSaveContext.save.weekEventReg[26] |= 4; - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + SET_WEEKEVENTREG(WEEKEVENTREG_26_04); + func_80151938(play, play->msgCtx.currentTextId + 1); this->unk_220 |= 2; this->actor.textId = 0x1091; break; @@ -473,34 +475,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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_26_08)) { + 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 +529,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 +590,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,7 +612,7 @@ 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; @@ -618,19 +621,19 @@ void EnTsn_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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..ff0b6bcbf 100644 --- a/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h +++ b/src/overlays/actors/ovl_En_Tsn/z_en_tsn.h @@ -5,30 +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; - #endif // Z_EN_TSN_H diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/overlay.cfg b/src/overlays/actors/ovl_En_Tubo_Trap/overlay.cfg deleted file mode 100644 index 364d4c7e9..000000000 --- a/src/overlays/actors/ovl_En_Tubo_Trap/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Tubo_Trap -z_en_tubo_trap.c 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..4f7b8b720 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 = { { @@ -39,7 +39,7 @@ static ColliderCylinderInit sCylinderInit = { { 11, 28, 0, { 0, 0, 0 } }, }; -const ActorInit En_Tubo_Trap_InitVars = { +ActorInit En_Tubo_Trap_InitVars = { ACTOR_EN_TUBO_TRAP, ACTORCAT_PROP, FLAGS, @@ -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,41 +164,40 @@ 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); - Actor_MarkForDeath(&this->actor); + EnTuboTrap_SpawnEffectsInWater(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_BOMB_DROP_WATER); + EnTuboTrap_DropCollectible(this, play); + Actor_Kill(&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); - Actor_MarkForDeath(&this->actor); + 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_Kill(&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); - Actor_MarkForDeath(&this->actor); + 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_Kill(&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); - Actor_MarkForDeath(&this->actor); + 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_Kill(&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); - Actor_MarkForDeath(&this->actor); + EnTuboTrap_SpawnEffectsOnLand(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(this, play); + Actor_Kill(&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..8df1aeb55 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,16 +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; - #endif // Z_EN_TUBO_TRAP_H diff --git a/src/overlays/actors/ovl_En_Twig/overlay.cfg b/src/overlays/actors/ovl_En_Twig/overlay.cfg deleted file mode 100644 index 29491912c..000000000 --- a/src/overlays/actors/ovl_En_Twig/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Twig -z_en_twig.c 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..5843357ee 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.c +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.c @@ -5,18 +5,27 @@ */ #include "z_en_twig.h" +#include "objects/object_twig/object_twig.h" #define FLAGS (ACTOR_FLAG_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* play2); +void EnTwig_Destroy(Actor* thisx, PlayState* play2); +void EnTwig_Update(Actor* thisx, PlayState* play2); +void EnTwig_Draw(Actor* thisx, PlayState* play); -#if 0 -const ActorInit En_Twig_InitVars = { +void func_80AC0A54(EnTwig* this, PlayState* play); +void func_80AC0A6C(EnTwig* this, PlayState* play); + +void func_80AC0A7C(EnTwig* this, PlayState* play); +void func_80AC0AC8(EnTwig* this, PlayState* play); + +void func_80AC0CC4(EnTwig* this, PlayState* play); +void func_80AC0D2C(EnTwig* this, PlayState* play); + +ActorInit En_Twig_InitVars = { ACTOR_EN_TWIG, ACTORCAT_MISC, FLAGS, @@ -28,36 +37,205 @@ const ActorInit En_Twig_InitVars = { (ActorFunc)EnTwig_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AC10C0[] = { +static s32 sCurrentRing; +static s16 sRingCount; +static s16 sRingNotCollected[25]; + +static CollisionHeader* sColHeaders[] = { + NULL, + &object_twig_Colheader_0020A0, + &object_twig_Colheader_0016C0, +}; + +static s16 sRingsHaveSpawned = false; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 40, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 40, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -#endif +void EnTwig_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; + s32 i; -extern InitChainEntry D_80AC10C0[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->unk_160 = RACERING_GET_PARAM_F(&this->dyna.actor); + DynaPolyActor_Init(&this->dyna, 1); + if (sColHeaders[this->unk_160] != NULL) { + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[this->unk_160]); + } + this->dyna.actor.bgCheckFlags |= 0x400; + switch (this->unk_160) { + case 0: + Actor_Kill(&this->dyna.actor); + break; + case 1: + if (!sRingsHaveSpawned) { + sRingCount = CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04) ? 25 : 20; + for (i = 0; i < sRingCount; i++) { + sRingNotCollected[i] = false; + } + sRingsHaveSpawned = true; + } + if (RACERING_GET_PARAM_1F0(&this->dyna.actor) != 0) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { + Actor_Kill(&this->dyna.actor); + return; + } + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_24_04)) { + Actor_Kill(&this->dyna.actor); + return; + } + Actor_SetScale(&this->dyna.actor, 4.2f); + this->dyna.actor.uncullZoneScale = this->dyna.actor.uncullZoneDownward = this->dyna.actor.scale.x * 60.0f; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + func_80AC0A7C(this, play); + break; + case 2: + Actor_SetScale(&this->dyna.actor, 1.0f); + this->dyna.actor.uncullZoneScale = this->dyna.actor.uncullZoneDownward = this->dyna.actor.scale.x * 880.0f; + func_80AC0A54(this, play); + break; + } +} -extern UNK_TYPE D_06001C38; +void EnTwig_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Init.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Destroy.s") +void func_80AC0A54(EnTwig* this, PlayState* play) { + this->actionFunc = func_80AC0A6C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A54.s") +void func_80AC0A6C(EnTwig* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A6C.s") +void func_80AC0A7C(EnTwig* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0A7C.s") + Math_Vec3f_Copy(&this->unk_180, &player->bodyPartsPos[0]); + this->unk_178 = 0; + this->unk_17A = 0; + this->actionFunc = func_80AC0AC8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0AC8.s") +void func_80AC0AC8(EnTwig* this, PlayState* play) { + static Vec3f D_80AC10D0 = { 0.0f, 0.0f, 1.0f }; + Player* player = GET_PLAYER(play); + Plane sp4C; + Vec3f sp40; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0CC4.s") + if (sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) { + if (this->unk_17A == 3) { + this->unk_17A = 0; + this->dyna.actor.shape.rot.z += 0x2000; + } else { + this->unk_17A++; + } + } + SubS_ConstructPlane(&this->dyna.actor.world.pos, &D_80AC10D0, &this->dyna.actor.shape.rot, &sp4C); + if ((sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) && + Math3D_LineSegVsPlane(sp4C.normal.x, sp4C.normal.y, sp4C.normal.z, sp4C.originDist, &this->unk_180, + &player->bodyPartsPos[0], &sp40, 0)) { + if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &sp40) <= SQ(this->dyna.actor.scale.x * 0.345f * 40.0f)) { + func_80AC0CC4(this, play); + return; + } + } else { + if (this->dyna.actor.xyzDistToPlayerSq <= SQ((this->dyna.actor.scale.x * 40.0f) + 40)) { + func_800C6314(play, &play->colCtx.dyna, this->dyna.bgId); + } else { + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + } + if (this->dyna.actor.xyzDistToPlayerSq >= (this->dyna.actor.scale.x * 10.0f * 40.0f * 40.0f)) { + this->dyna.actor.shape.rot.y = this->dyna.actor.yawTowardsPlayer; + this->dyna.actor.world.rot.y = this->dyna.actor.yawTowardsPlayer; + } + } + Math_Vec3f_Copy(&this->unk_180, &player->bodyPartsPos[0]); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/func_80AC0D2C.s") +void func_80AC0CC4(EnTwig* this, PlayState* play) { + this->unk_170 = 3458.0f; + this->unk_174 = 0.2f; + this->unk_16C |= 1; + func_800C62BC(play, &play->colCtx.dyna, this->dyna.bgId); + this->actionFunc = func_80AC0D2C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Update.s") +void func_80AC0D2C(EnTwig* this, PlayState* play) { + static Vec3f sKiraVel = { 0.0f, -0.05f, 0.0f }; + static Vec3f sKiraAccel = { 0.0f, -0.025f, 0.0f }; + static Color_RGBA8 sColorWhite = { 255, 255, 255, 130 }; + static Color_RGBA8 sColorYellow = { 255, 255, 0, 0 }; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Twig/EnTwig_Draw.s") + Math_SmoothStepToF(&this->dyna.actor.world.pos.x, player->bodyPartsPos[0].x, 0.5f, 100.0f, 0.01f); + Math_SmoothStepToF(&this->dyna.actor.world.pos.y, player->bodyPartsPos[0].y, 0.5f, 100.0f, 0.01f); + Math_SmoothStepToF(&this->dyna.actor.world.pos.z, player->bodyPartsPos[0].z, 0.5f, 100.0f, 0.01f); + this->dyna.actor.shape.rot.z += (s16)this->unk_170; + this->dyna.actor.scale.x -= this->unk_174; + if (this->dyna.actor.scale.x < 0.0f) { + Actor_SetScale(&this->dyna.actor, 0.0f); + } else { + Actor_SetScale(&this->dyna.actor, this->dyna.actor.scale.x); + } + if (this->dyna.actor.scale.x <= 0.0f) { + s32 j; + Vec3f sp6C; + + for (j = 0; j < 7; j++) { + sp6C.x = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.x; + sp6C.y = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.y; + sp6C.z = (Rand_Centered() * 10.0f) + this->dyna.actor.world.pos.z; + EffectSsKirakira_SpawnDispersed(play, &sp6C, &sKiraVel, &sKiraAccel, &sColorWhite, &sColorYellow, 1000, + (s32)(Rand_ZeroOne() * 10.0f) + 20); + } + play_sound(NA_SE_SY_GET_ITEM); + play->interfaceCtx.minigamePoints--; + sRingNotCollected[RACERING_GET_PARAM_FE0(&this->dyna.actor)] = true; + if (sCurrentRing == RACERING_GET_PARAM_FE0(&this->dyna.actor)) { + s32 i; + + for (i = 0; i < sRingCount; i++) { + if (!sRingNotCollected[i]) { + sCurrentRing = i; + break; + } + } + if (i == sRingCount) { + sCurrentRing = -1; + } + } + Actor_Kill(&this->dyna.actor); + return; + } + this->unk_170 += 180.0f / 0x10000; + this->unk_174 += 0.15f; +} + +void EnTwig_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + EnTwig* this = THIS; + + this->actionFunc(this, play); +} + +void EnTwig_Draw(Actor* thisx, PlayState* play) { + EnTwig* this = THIS; + + switch (this->unk_160) { + case 1: + Gfx_DrawDListOpa(play, object_twig_DL_001C38); + break; + case 2: + Gfx_DrawDListOpa(play, object_twig_DL_0014C8); + break; + } +} 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..3bdb62209 100644 --- a/src/overlays/actors/ovl_En_Twig/z_en_twig.h +++ b/src/overlays/actors/ovl_En_Twig/z_en_twig.h @@ -5,15 +5,24 @@ struct EnTwig; -typedef void (*EnTwigActionFunc)(struct EnTwig*, GlobalContext*); +typedef void (*EnTwigActionFunc)(struct EnTwig*, PlayState*); + +#define RACERING_GET_PARAM_F(thisx) ((thisx)->params & 0xF) +#define RACERING_GET_PARAM_1F0(thisx) (((thisx)->params >> 4) & 0x1F) +#define RACERING_GET_PARAM_FE0(thisx) (((thisx)->params >> 9) & 0x7F) typedef struct EnTwig { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ EnTwigActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x2C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ EnTwigActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x160 */ UNK_TYPE1 unk164[8]; + /* 0x16C */ s32 unk_16C; + /* 0x170 */ f32 unk_170; + /* 0x174 */ f32 unk_174; + /* 0x178 */ s16 unk_178; + /* 0x17A */ u16 unk_17A; + /* 0x17C */ UNK_TYPE1 unk17C[4]; + /* 0x180 */ Vec3f unk_180; } EnTwig; // size = 0x18C -extern const ActorInit En_Twig_InitVars; - #endif // Z_EN_TWIG_H diff --git a/src/overlays/actors/ovl_En_Viewer/overlay.cfg b/src/overlays/actors/ovl_En_Viewer/overlay.cfg deleted file mode 100644 index 3faa113d4..000000000 --- a/src/overlays/actors/ovl_En_Viewer/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Viewer -z_en_viewer.c 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..34551dac9 100644 --- a/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c +++ b/src/overlays/actors/ovl_En_Viewer/z_en_viewer.c @@ -10,19 +10,20 @@ #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; -#if 0 -const ActorInit En_Viewer_InitVars = { +static u8 D_8089F3E4 = 0; + +ActorInit En_Viewer_InitVars = { ACTOR_EN_VIEWER, ACTORCAT_ITEMACTION, FLAGS, @@ -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.curRoom.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.curRoom.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.curRoom.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..1532e7c70 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,28 @@ #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 -extern const ActorInit En_Viewer_InitVars; +typedef enum { + /* 0x0 */ ENVIEWER_PARAMS_0, + /* 0x1 */ ENVIEWER_PARAMS_1, + /* 0x2 */ ENVIEWER_PARAMS_2 +} EnViewerParams; #endif // Z_EN_VIEWER_H diff --git a/src/overlays/actors/ovl_En_Vm/overlay.cfg b/src/overlays/actors/ovl_En_Vm/overlay.cfg deleted file mode 100644 index 7c1774086..000000000 --- a/src/overlays/actors/ovl_En_Vm/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Vm -z_en_vm.c 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 77449c7a3..50109f887 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -13,23 +13,23 @@ #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 = { +ActorInit En_Vm_InitVars = { ACTOR_EN_VM, ACTORCAT_ENEMY, FLAGS, @@ -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, }; @@ -144,14 +144,14 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 2, 25, 100, MASS_IMMOVABLE }; TexturePtr D_808CD58C[] = { - gameplay_keep_Tex_03F300, gameplay_keep_Tex_03FB00, gameplay_keep_Tex_040300, gameplay_keep_Tex_040B00, - gameplay_keep_Tex_041300, gameplay_keep_Tex_041B00, gameplay_keep_Tex_042300, gameplay_keep_Tex_042B00, + gEffEnemyDeathFlame1Tex, gEffEnemyDeathFlame2Tex, gEffEnemyDeathFlame3Tex, gEffEnemyDeathFlame4Tex, + gEffEnemyDeathFlame5Tex, gEffEnemyDeathFlame6Tex, gEffEnemyDeathFlame7Tex, gEffEnemyDeathFlame8Tex, }; static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 14, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1000, ICHAIN_CONTINUE), - ICHAIN_S8(hintId, 57, ICHAIN_STOP), + ICHAIN_S8(hintId, TATL_HINT_ID_BEAMOS, ICHAIN_STOP), }; s32 D_808CD5B8 = false; @@ -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); - Actor_MarkForDeath(&this->actor); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0xB0); + Actor_Kill(&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; @@ -487,8 +486,8 @@ void EnVm_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec 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) { @@ -529,11 +528,11 @@ void EnVm_Draw(Actor* thisx, GlobalContext* globalCtx) { 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]); - gSPDisplayList(&gfx[6], gameplay_keep_DL_044300); + gSPSegment(&gfx[5], 0x08, D_808CD58C[play->gameplayFrames & 7]); + gSPDisplayList(&gfx[6], gEffEnemyDeathFlameDL); POLY_XLU_DISP = &gfx[7]; } @@ -541,17 +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_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..ca0678d90 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,27 +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; - #endif // Z_EN_VM_H diff --git a/src/overlays/actors/ovl_En_Wallmas/overlay.cfg b/src/overlays/actors/ovl_En_Wallmas/overlay.cfg deleted file mode 100644 index badbf57d0..000000000 --- a/src/overlays/actors/ovl_En_Wallmas/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Wallmas -z_en_wallmas.c 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 8ebb04c22..74bd4fec6 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -12,38 +12,38 @@ #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 = { +ActorInit En_Wallmas_InitVars = { ACTOR_EN_WALLMAS, ACTORCAT_ENEMY, FLAGS, @@ -123,7 +123,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit sColChkInfoInit = { 3, 30, 40, 150 }; static InitChainEntry sInitChain[] = { - ICHAIN_S8(hintId, 48, ICHAIN_CONTINUE), + ICHAIN_S8(hintId, TATL_HINT_ID_WALLMASTER, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), }; @@ -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,8 +170,8 @@ void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { } if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { - if (Flags_GetSwitch(globalCtx, this->switchFlag)) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&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; @@ -243,11 +243,12 @@ void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { this->timer--; } - if ((player->stateFlags1 & 0x08100000) || (player->stateFlags2 & 0x80) || (player->unk_B5E > 0) || - (player->actor.freezeTimer > 0) || !(player->actor.bgCheckFlags & 1) || + if ((player->stateFlags1 & (PLAYER_STATE1_100000 | PLAYER_STATE1_8000000)) || + (player->stateFlags2 & PLAYER_STATE2_80) || (player->unk_B5E > 0) || (player->actor.freezeTimer > 0) || + !(player->actor.bgCheckFlags & 1) || ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) && (Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos) > (120.f + this->detectionRadius)))) { - func_801A75E8(NA_SE_EN_FALL_AIM); + AudioSfx_StopById(NA_SE_EN_FALL_AIM); this->timer = 130; } @@ -256,12 +257,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 +277,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)) { + if ((player->stateFlags2 & PLAYER_STATE2_80) || (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 & PLAYER_STATE2_10) && (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 +313,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 +328,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 +347,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 +361,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) { @@ -376,13 +377,13 @@ void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { if (this->actor.playerHeightRel < -900.0f) { if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } if ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_TIMER_ONLY) || (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius)) { - EnWallmas_TimerInit(this, globalCtx); + EnWallmas_TimerInit(this, play); } else { EnWallmas_ProximityOrSwitchInit(this); } @@ -402,10 +403,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,46 +427,46 @@ 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); - Actor_MarkForDeath(&this->actor); + Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x90); + Actor_Kill(&this->actor); } this->actor.scale.z = this->actor.scale.x; this->actor.scale.y = this->actor.scale.x; } -void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx) { +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, PLAYER_CSMODE_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); + func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DAMAGE_S); Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_CATCH); } @@ -479,9 +480,9 @@ void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { this->actor.world.pos.y += 10.0f; } - player->actor.world.pos.y = this->actor.world.pos.y - sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)]; + player->actor.world.pos.y = this->actor.world.pos.y - sYOffsetPerForm[GET_PLAYER_FORM]; if (this->timer == -30) { - func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_TAKEN_AWAY); + func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_TAKEN_AWAY); } if (this->timer == 0) { @@ -490,8 +491,7 @@ void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { this->timer += 2; } else { - Math_StepToF(&this->actor.world.pos.y, - sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)] + player->actor.world.pos.y, 5.0f); + Math_StepToF(&this->actor.world.pos.y, sYOffsetPerForm[GET_PLAYER_FORM] + player->actor.world.pos.y, 5.0f); } Math_StepToF(&this->actor.world.pos.x, player->actor.world.pos.x, 3.0f); @@ -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; @@ -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,7 +703,7 @@ 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; @@ -716,7 +715,7 @@ void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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; @@ -726,33 +725,31 @@ void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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_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..ceb1d1823 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; @@ -52,6 +52,4 @@ typedef struct EnWallmas { /* 0x358 */ ColliderCylinder collider; } EnWallmas; // size = 0x3A4 -extern const ActorInit En_Wallmas_InitVars; - #endif // Z_EN_WALLMAS_H diff --git a/src/overlays/actors/ovl_En_Warp_Uzu/overlay.cfg b/src/overlays/actors/ovl_En_Warp_Uzu/overlay.cfg deleted file mode 100644 index 833f1a0b6..000000000 --- a/src/overlays/actors/ovl_En_Warp_Uzu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Warp_Uzu -z_en_warp_uzu.c 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 4065bdf39..32038c411 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,17 +11,17 @@ #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 = { +ActorInit En_Warp_Uzu_InitVars = { ACTOR_EN_WARP_UZU, ACTORCAT_PROP, FLAGS, @@ -60,23 +60,23 @@ 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; @@ -87,50 +87,50 @@ void func_80A66208(EnWarpUzu* this, GlobalContext* globalCtx) { 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..6b8bfb362 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; @@ -13,6 +13,4 @@ typedef struct EnWarpUzu { /* 0x148 */ ColliderCylinder collider; } EnWarpUzu; // size = 0x194 -extern const ActorInit En_Warp_Uzu_InitVars; - #endif // Z_EN_WARP_UZU_H diff --git a/src/overlays/actors/ovl_En_Warp_tag/overlay.cfg b/src/overlays/actors/ovl_En_Warp_tag/overlay.cfg deleted file mode 100644 index a70ec6a5c..000000000 --- a/src/overlays/actors/ovl_En_Warp_tag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Warp_tag -z_en_warp_tag.c 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..77b857c14 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,19 +12,19 @@ #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 = { +ActorInit En_Warp_tag_InitVars = { ACTOR_EN_WARP_TAG, ACTORCAT_ITEMACTION, FLAGS, @@ -45,21 +45,21 @@ 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) { - Actor_MarkForDeath(&this->dyna.actor); + if ((this->dangeonKeepObject = Object_GetIndex(&play->objectCtx, GAMEPLAY_DANGEON_KEEP)) < 0) { + Actor_Kill(&this->dyna.actor); } this->actionFunc = EnWarpTag_CheckDungeonKeepObject; @@ -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, &gWarpTagGoronTrialBaseCol); 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, PLAYER_CSMODE_81); this->actionFunc = EnWarpTag_GrottoReturn; } else { - func_800B7298(globalCtx, NULL, 0xF); + func_800B7298(play, NULL, PLAYER_CSMODE_15); 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, PLAYER_CSMODE_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); } @@ -176,11 +176,11 @@ void EnWarpTag_RespawnPlayer(EnWarptag* this, GlobalContext* globalCtx) { player->actor.world.pos.z = this->dyna.actor.world.pos.z + (diffZ * distance); if (Math_StepToS(&this->unkValue15E, 0x2710, 0xC8)) { - player->stateFlags3 |= 0x1; + player->stateFlags3 |= PLAYER_STATE3_1; 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,28 +192,28 @@ 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) { - playerParams = 0x9FF; + if (WARPTAG_GET_3C0_MAX(&this->dyna.actor) == WARPTAG_3C0_MAX) { + playerParams = PLAYER_PARAMS(0xFF, PLAYER_INITMODE_9); } else { // not used by any known variant - playerParams = 0x8FF; + playerParams = PLAYER_PARAMS(0xFF, PLAYER_INITMODE_8); } // 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,33 +241,33 @@ 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) {} - gSaveContext.seqIndex = 0xFF; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; } } -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..ac76ccb67 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; @@ -18,16 +18,14 @@ typedef struct EnWarptag { /* 0x160 */ EnWarptagActionFunc actionFunc; } EnWarptag; // size = 0x164 -extern const ActorInit En_Warp_tag_InitVars; - // Only two known Variants: // Goron Trial (MOON): 0x03C1 // Deku Playground: 0x83C0 -#define GET_WARPTAG_3C0_MAX(thisx) ((thisx)->params & 0x3C0) -#define GET_WARPTAG_3C0(thisx) (((thisx)->params >> 6) & 0xF) -#define GET_WARPTAG_EXIT_INDEX(thisx) ((thisx)->params & 0x3F) -#define GET_WARPTAG_INVISIBLE(thisx) ((thisx)->params < 0) // 0x8000 flag +#define WARPTAG_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/overlay.cfg b/src/overlays/actors/ovl_En_Water_Effect/overlay.cfg deleted file mode 100644 index 7aac8fdd8..000000000 --- a/src/overlays/actors/ovl_En_Water_Effect/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Water_Effect -z_en_water_effect.c 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 df347dc36..94890bd39 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 @@ -1,7 +1,15 @@ /* * File: z_en_water_effect.c * Overlay: ovl_En_Water_Effect - * Description: Water splashing effect (used for Gyorg) + * Description: Water/rock drop spawner and Gyorg water splashing effect + * + * This actor serves two purposes: + * - It can act as a "spawner" for either water drops or flaming rocks. This + * spawner can be placed in the ceiling to drop these repeatedly. + * - It is also used to control various water splashing effects for the Gyorg + * fight. Specifically, it handles the splashing that is caused when it + * enters or exits the water, and it handles the shockwave that is created + * when it rams the center platform. */ #include "z_en_water_effect.h" @@ -12,17 +20,17 @@ #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* play2); +void EnWaterEffect_Draw(Actor* thisx, PlayState* play2); -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 = { +ActorInit En_Water_Effect_InitVars = { ACTOR_EN_WATER_EFFECT, ACTORCAT_BOSS, FLAGS, @@ -78,34 +86,37 @@ 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; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_DC4 = Rand_ZeroFloat(100.0f); - if (this->actor.params == ENWATEREFFECT_1) { + if (this->actor.params == ENWATEREFFECT_TYPE_FALLING_ROCK_SPAWNER) { 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_TYPE_GYORG_RIPPLES) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SECONDARY_SPRAY) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE)) { 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_TYPE_GYORG_RIPPLES) { + 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, ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY); + 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, + ENWATEREFFECT_TYPE_GYORG_SECONDARY_SPRAY); + } else if (this->actor.params == ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY) { this->unk_DC4 = -3; - } else if (this->actor.params == ENWATEREFFECT_779) { + } else if (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SECONDARY_SPRAY) { this->unk_DC4 = -6; - } else if (this->actor.params == ENWATEREFFECT_780) { + } else if (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE) { this->unk_DC4 = 23; } @@ -127,13 +138,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 +154,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 +209,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,15 +223,15 @@ 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); } } @@ -249,7 +260,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 +277,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,14 +289,14 @@ 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)) { if (!phi_s4) { POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); phi_s4++; @@ -296,9 +307,9 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_00 == 1) { - Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx)), MTXMODE_APPLY); + Matrix_RotateYS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)), MTXMODE_APPLY); } else { - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); } Matrix_Scale(ptr->unk_2C.x, ptr->unk_2C.y, 1.0f, MTXMODE_APPLY); @@ -317,7 +328,7 @@ void EnWaterEffect_Draw(Actor* thisx, GlobalContext* globalCtx2) { if (!phi_s4) { func_8012C448(gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust1Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); phi_s4++; @@ -378,15 +389,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 +414,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,19 +477,19 @@ 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); } player->isBurning = true; - func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DEMO_DAMAGE); + func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_DEMO_DAMAGE); } } Math_Vec3f_Copy(&sp90, &ptr->unk_04); sp90.y += 30.0f; - temp_f0_2 = BgCheck_EntityRaycastFloor1(&globalCtx->colCtx, &sp88, &sp90); + temp_f0_2 = BgCheck_EntityRaycastFloor1(&play->colCtx, &sp88, &sp90); if (fabsf(temp_f0_2 - this->actor.floorHeight) > 200.0f) { phi_s5 = true; } @@ -493,7 +504,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 +514,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,15 +538,15 @@ 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_Translate(ptr->unk_04.x, ptr->unk_04.y, ptr->unk_04.z, MTXMODE_NEW); if (ptr->unk_2A >= 2) { - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); } else { - Matrix_RotateYS(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); @@ -544,8 +555,7 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { 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) { @@ -553,24 +563,24 @@ void func_80A5A184(Actor* thisx, GlobalContext* globalCtx2) { 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; if (this->unk_E38 < 1.0f) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } this->unk_DC4++; @@ -601,19 +611,19 @@ 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_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); @@ -621,14 +631,14 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Push(); Matrix_Push(); - if ((this->actor.params == ENWATEREFFECT_777) || (this->actor.params == ENWATEREFFECT_778)) { + if ((this->actor.params == ENWATEREFFECT_TYPE_GYORG_RIPPLES) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY)) { 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); } @@ -636,12 +646,11 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { 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); } @@ -651,37 +660,38 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { 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_TYPE_GYORG_SHOCKWAVE)) { + 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_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_TYPE_GYORG_RIPPLES) || + (this->actor.params == ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE)) { + 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_TYPE_GYORG_RIPPLES) { + 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)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust1Tex)); gDPSetEnvColor(POLY_XLU_DISP++, 250, 250, 255, 0); gSPDisplayList(POLY_XLU_DISP++, object_water_effect_DL_004260); phi_s4++; @@ -694,12 +704,12 @@ void func_80A5A6B8(Actor* thisx, GlobalContext* globalCtx2) { Matrix_Scale(ptr->unk_2C.x, 1.0f, ptr->unk_2C.x, 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..433ebac62 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 @@ -18,13 +18,14 @@ typedef struct { /* 0x3C */ s16 unk_3C; } EnWaterEffectStruct; // size = 0x40 -enum { - /* 0x 1 */ ENWATEREFFECT_1 = 1, - /* 0x309 */ ENWATEREFFECT_777 = 777, - /* 0x30A */ ENWATEREFFECT_778, - /* 0x30B */ ENWATEREFFECT_779, - /* 0x30C */ ENWATEREFFECT_780, -}; +typedef enum { + /* 0x001 */ ENWATEREFFECT_TYPE_FALLING_ROCK_SPAWNER = 1, // Spawner for falling flaming rocks, + /* 0x0FF */ ENWATEREFFECT_TYPE_FALLING_WATER_SPAWNER = 0xFF, // Spawner for water dripping from the ceiling + /* 0x309 */ ENWATEREFFECT_TYPE_GYORG_RIPPLES = 0x309, // Ripples on the surface when Gyrog enters/leaves the water + /* 0x30A */ ENWATEREFFECT_TYPE_GYORG_PRIMARY_SPRAY, // Large "funnel" of water that forms when Gyorg enters/leaves the water + /* 0x30B */ ENWATEREFFECT_TYPE_GYORG_SECONDARY_SPRAY, // Secondary "funnel" in the middle of the larger "funnel" + /* 0x30C */ ENWATEREFFECT_TYPE_GYORG_SHOCKWAVE, // Shockwave on the surface when Gyorg rams into the central platform +} EnWaterEffectType; typedef struct EnWaterEffect { /* 0x000 */ Actor actor; @@ -42,6 +43,4 @@ typedef struct EnWaterEffect { /* 0xE38 */ f32 unk_E38; } EnWaterEffect; // size = 0xE3C -extern const ActorInit En_Water_Effect_InitVars; - #endif // Z_EN_WATER_EFFECT_H diff --git a/src/overlays/actors/ovl_En_Wdhand/overlay.cfg b/src/overlays/actors/ovl_En_Wdhand/overlay.cfg deleted file mode 100644 index 501a7b6ed..000000000 --- a/src/overlays/actors/ovl_En_Wdhand/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Wdhand -z_en_wdhand.c 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..83cf47291 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.c @@ -10,13 +10,13 @@ #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 = { +ActorInit En_Wdhand_InitVars = { ACTOR_EN_WDHAND, ACTORCAT_ENEMY, FLAGS, @@ -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..5eb02fa1a 100644 --- a/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h +++ b/src/overlays/actors/ovl_En_Wdhand/z_en_wdhand.h @@ -5,15 +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; - #endif // Z_EN_WDHAND_H diff --git a/src/overlays/actors/ovl_En_Weather_Tag/overlay.cfg b/src/overlays/actors/ovl_En_Weather_Tag/overlay.cfg deleted file mode 100644 index 9b7593244..000000000 --- a/src/overlays/actors/ovl_En_Weather_Tag/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Weather_Tag -z_en_weather_tag.c 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 0f81d088d..7ddd539e7 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,32 +10,32 @@ #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 = { +ActorInit En_Weather_Tag_InitVars = { ACTOR_EN_WEATHER_TAG, ACTORCAT_PROP, FLAGS, @@ -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; @@ -77,8 +77,8 @@ void EnWeatherTag_Init(Actor* thisx, GlobalContext* globalCtx) { EnWeatherTag_SetupAction(this, func_80966A08); break; case WEATHERTAG_TYPE_UNK1: - if (gSaveContext.save.weekEventReg[52] & 0x20) { // if cleared STT - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + Actor_Kill(&this->actor); } EnWeatherTag_SetupAction(this, func_80966B08); break; @@ -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,55 +186,55 @@ 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; } if ((s16)this->unk154 < 0) { // cast req this->unk154 = 0; - // @BUG redudant code - Actor_MarkForDeath(&this->actor); + // redundant code + Actor_Kill(&this->actor); EnWeatherTag_SetupAction(this, EnWeatherTag_Die); } - func_8096689C(this, globalCtx); + func_8096689C(this, play); } -void EnWeatherTag_Die(EnWeatherTag* this, GlobalContext* globalCtx) { - Actor_MarkForDeath(&this->actor); +void EnWeatherTag_Die(EnWeatherTag* this, PlayState* play) { + Actor_Kill(&this->actor); } // WEATHERTAG_TYPE_UNK1 // 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,39 @@ 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->sceneId == SCENE_KAIZOKU) && (play->actorCtx.flags & ACTORCTX_FLAG_1)) { 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,109 +388,111 @@ 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; - 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.flags & ACTORCTX_FLAG_1) && (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) { - gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.daySpeed); + gSaveContext.save.time = ((void)0, gSaveContext.save.time) + (u16)R_TIME_SPEED; + if (R_TIME_SPEED != 0) { + gSaveContext.save.time = + ((void)0, gSaveContext.save.time) + (u16)((void)0, gSaveContext.save.timeSpeedOffset); } } } -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..b1e7f8f86 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 @@ -19,12 +19,10 @@ typedef struct EnWeatherTag { /* 0x158 */ u16 unk158; // increment/decrement amount for 154 } EnWeatherTag; // size = 0x15C -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/overlay.cfg b/src/overlays/actors/ovl_En_Wf/overlay.cfg deleted file mode 100644 index d24cd8a27..000000000 --- a/src/overlays/actors/ovl_En_Wf/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Wf -z_en_wf.c 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 89e765b98..bc505ee53 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -12,50 +12,50 @@ #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 = { +ActorInit En_Wf_InitVars = { ACTOR_EN_WF, ACTORCAT_PROP, FLAGS, @@ -123,7 +123,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 4, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -260,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; @@ -268,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) { @@ -293,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; @@ -308,8 +308,8 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { } } - if (Flags_GetClear(globalCtx, this->actor.room)) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetClear(play, this->actor.room)) { + Actor_Kill(&this->actor); return; } @@ -317,17 +317,17 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.0075f); if (this->actor.params == 0) { - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosNormalSkel, &gWolfosWaitingAnim, this->jointTable, this->morphTable, WOLFOS_NORMAL_LIMB_MAX); - this->actor.hintId = 0x4C; + this->actor.hintId = TATL_HINT_ID_WOLFOS; 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, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, + SkelAnime_InitFlex(play, &this->skelAnime, &gWolfosWhiteSkel, &gWolfosWaitingAnim, this->jointTable, this->morphTable, WOLFOS_WHITE_LIMB_MAX); - this->actor.hintId = 0x57; + this->actor.hintId = TATL_HINT_ID_WHITE_WOLFOS; CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable1, &sColChkInfoInit); } @@ -338,7 +338,7 @@ 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(sNormalEyeTextures); i++) { @@ -350,12 +350,12 @@ void EnWf_Init(Actor* thisx, GlobalContext* globalCtx) { 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) { @@ -370,13 +370,13 @@ 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; } } @@ -392,8 +392,8 @@ void EnWf_Blink(EnWf* this) { } } -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; @@ -410,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)) { @@ -424,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; } @@ -433,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; @@ -447,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; } @@ -465,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 }; @@ -476,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; @@ -491,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); } } @@ -530,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) { @@ -549,13 +549,13 @@ void func_80990F50(EnWf* this, GlobalContext* globalCtx) { } void func_80990FC8(EnWf* this) { - Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, 0.0f); this->unk_2A0 = 5; this->actor.flags |= ACTOR_FLAG_1; this->actionFunc = func_80991040; } -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); @@ -572,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, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, 3, -5.0f); + Animation_Change(&this->skelAnime, &gWolfosRearingUpFallingOverAnim, 0.5f, 0.0f, 7.0f, ANIMMODE_ONCE_INTERP, -5.0f); this->unk_2A0 = 5; this->actionFunc = func_80991174; } -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; @@ -598,8 +598,8 @@ void func_80991200(EnWf* this) { 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; @@ -613,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); @@ -648,16 +648,16 @@ void func_80991438(EnWf* this) { 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; @@ -665,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) { @@ -675,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); @@ -683,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); @@ -697,7 +697,7 @@ void func_8099149C(EnWf* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WOLFOS_CRY); } - func_80990E4C(this, globalCtx); + func_80990E4C(this, play); } } } @@ -707,13 +707,13 @@ void func_80991738(EnWf* this) { 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; @@ -767,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) { @@ -784,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); @@ -818,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; @@ -839,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); @@ -858,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); @@ -879,13 +879,14 @@ void func_80991FD8(EnWf* this) { if (this->skelAnime.curFrame > 15.0f) { phi_f0 = 15.0f; } - Animation_Change(&this->skelAnime, &gWolfosSlashingAnim, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, 3, 0.0f); + Animation_Change(&this->skelAnime, &gWolfosSlashingAnim, -0.5f, this->skelAnime.curFrame - 1.0f, phi_f0, + ANIMMODE_ONCE_INTERP, 0.0f); this->collider1.base.atFlags &= ~AT_ON; this->actionFunc = func_80992068; } -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; @@ -905,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); @@ -931,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); } @@ -955,17 +956,17 @@ 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); } } } @@ -982,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) { @@ -997,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,7 +1022,7 @@ void func_809924EC(EnWf* this, GlobalContext* globalCtx) { void func_809926D0(EnWf* this) { this->collider2.base.acFlags &= ~AC_ON; Animation_Change(&this->skelAnime, &gWolfosBackflippingAnim, -1.0f, - Animation_GetLastFrame(&gWolfosBackflippingAnim.common), 0.0f, 2, -3.0f); + Animation_GetLastFrame(&gWolfosBackflippingAnim.common), 0.0f, ANIMMODE_ONCE, -3.0f); this->unk_2A0 = 0; this->actor.speedXZ = 6.5f; this->actor.velocity.y = 15.0f; @@ -1030,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; @@ -1039,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,19 +1054,19 @@ void func_8099282C(EnWf* this) { this->unk_2A0 = 10; this->actor.speedXZ = 0.0f; Animation_Change(&this->skelAnime, &gWolfosBlockingAnim, -1.0f, Animation_GetLastFrame(&gWolfosBlockingAnim.common), - 0.0f, 2, -2.0f); + 0.0f, ANIMMODE_ONCE, -2.0f); this->actionFunc = func_809928CC; } -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); @@ -1073,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); @@ -1085,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, &gWolfosRunningAnim, -4.0f); - player = GET_PLAYER(globalCtx); + 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; @@ -1108,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) { @@ -1124,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)); @@ -1133,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); @@ -1142,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); @@ -1163,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) { @@ -1176,17 +1177,17 @@ 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); + Actor_Kill(&this->actor); } else { s32 i; 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); } @@ -1196,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); @@ -1208,7 +1209,7 @@ void func_80992FD4(EnWf* this) { 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)) { @@ -1236,13 +1237,13 @@ void func_80993148(EnWf* this) { 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); @@ -1281,13 +1282,13 @@ void func_80993350(EnWf* this) { 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); @@ -1322,11 +1323,11 @@ void func_80993524(EnWf* this) { 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); @@ -1368,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) || @@ -1380,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; @@ -1414,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; @@ -1448,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); } @@ -1464,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; @@ -1474,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) { 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); @@ -1493,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); } @@ -1531,7 +1532,7 @@ 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 == WOLFOS_NORMAL_LIMB_HEAD) || (limbIndex == WOLFOS_NORMAL_LIMB_EYES)) { @@ -1540,7 +1541,7 @@ s32 EnWf_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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, }; @@ -1561,13 +1562,13 @@ void EnWf_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec } } -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, sNormalEyeTextures[this->eyeIndex]); @@ -1575,18 +1576,17 @@ void EnWf_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 94cfb18e7..c8a0c7af8 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.h +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.h @@ -6,37 +6,35 @@ 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[WOLFOS_NORMAL_LIMB_MAX]; - /* 0x020C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; - /* 0x0290 */ EnWfActionFunc actionFunc; - /* 0x0294 */ u8 eyeIndex; - /* 0x0295 */ u8 unk_295; - /* 0x0296 */ u8 drawDmgEffType; - /* 0x0298 */ s16 unk_298; - /* 0x029A */ s16 unk_29A; - /* 0x029C */ s16 unk_29C; - /* 0x029E */ s16 unk_29E; - /* 0x02A0 */ s16 unk_2A0; - /* 0x02A2 */ u16 unk_2A2; - /* 0x02A4 */ f32 unk_2A4; - /* 0x02A8 */ f32 unk_2A8; - /* 0x02AC */ f32 drawDmgEffAlpha; - /* 0x02B0 */ f32 drawDmgEffScale; - /* 0x02B4 */ f32 drawDmgEffFrozenSteamScale; - /* 0x02B8 */ Vec3f limbPos[10]; - /* 0x0330 */ ColliderJntSph collider1; - /* 0x0350 */ ColliderJntSphElement collider1Elements[4]; - /* 0x0450 */ ColliderCylinder collider2; - /* 0x049C */ ColliderCylinder collider3; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x20C */ Vec3s morphTable[WOLFOS_NORMAL_LIMB_MAX]; + /* 0x290 */ EnWfActionFunc actionFunc; + /* 0x294 */ u8 eyeIndex; + /* 0x295 */ u8 unk_295; + /* 0x296 */ u8 drawDmgEffType; + /* 0x298 */ s16 unk_298; + /* 0x29A */ s16 unk_29A; + /* 0x29C */ s16 unk_29C; + /* 0x29E */ s16 unk_29E; + /* 0x2A0 */ s16 unk_2A0; + /* 0x2A2 */ u16 unk_2A2; + /* 0x2A4 */ f32 unk_2A4; + /* 0x2A8 */ f32 unk_2A8; + /* 0x2AC */ f32 drawDmgEffAlpha; + /* 0x2B0 */ f32 drawDmgEffScale; + /* 0x2B4 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2B8 */ Vec3f limbPos[10]; + /* 0x330 */ ColliderJntSph collider1; + /* 0x350 */ ColliderJntSphElement collider1Elements[4]; + /* 0x450 */ ColliderCylinder collider2; + /* 0x49C */ ColliderCylinder collider3; } EnWf; // size = 0x4E8 -extern const ActorInit En_Wf_InitVars; - #endif // Z_EN_WF_H diff --git a/src/overlays/actors/ovl_En_Wiz/overlay.cfg b/src/overlays/actors/ovl_En_Wiz/overlay.cfg deleted file mode 100644 index a52f236dc..000000000 --- a/src/overlays/actors/ovl_En_Wiz/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Wiz -z_en_wiz.c 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..ee2f3d158 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c @@ -1,10 +1,12 @@ /* * File: z_en_wiz.c * Overlay: ovl_En_Wiz - * Description: Wizzrobe + * Description: Wizrobe */ #include "z_en_wiz.h" +#include "objects/gameplay_keep/gameplay_keep.h" +#include "overlays/actors/ovl_En_Wiz_Brock/z_en_wiz_brock.h" #define FLAGS \ (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_1000 | ACTOR_FLAG_100000 | \ @@ -12,13 +14,73 @@ #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 = { +void EnWiz_StartIntroCutscene(EnWiz* this, PlayState* play); +void EnWiz_SetupAppear(EnWiz* this, PlayState* play); +void EnWiz_Appear(EnWiz* this, PlayState* play); +void EnWiz_SetupDance(EnWiz* this); +void EnWiz_Dance(EnWiz* this, PlayState* play); +void EnWiz_SetupSecondPhaseCutscene(EnWiz* this, PlayState* play); +void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play); +void EnWiz_SetupWindUp(EnWiz* this); +void EnWiz_WindUp(EnWiz* this, PlayState* play); +void EnWiz_SetupAttack(EnWiz* this); +void EnWiz_Attack(EnWiz* this, PlayState* play); +void EnWiz_SetupDisappear(EnWiz* this); +void EnWiz_Disappear(EnWiz* this, PlayState* play); +void EnWiz_Damaged(EnWiz* this, PlayState* play); +void EnWiz_SetupDead(EnWiz* this); +void EnWiz_Dead(EnWiz* this, PlayState* play); + +// This number is almost-entirely arbirary, with the only requirement being +// that cannot be a valid curPlatformIndex. Any negative number, or any number +// larger than 10, would work just as well. +#define INITIAL_PLATFORM_INDEX 777 + +typedef enum { + /* 1 */ EN_WIZ_ACTION_APPEAR = 1, + /* 2 */ EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS, + /* 3 */ EN_WIZ_ACTION_DISAPPEAR, + /* 4 */ EN_WIZ_ACTION_DAMAGED, + /* 5 */ EN_WIZ_ACTION_DEAD, + /* 6 */ EN_WIZ_ACTION_BURST_INTO_FLAMES, + /* 7 */ EN_WIZ_ACTION_RUN_IN_CIRCLES, + /* 8 */ EN_WIZ_ACTION_ATTACK, + /* 9 */ EN_WIZ_ACTION_DANCE, +} EnWizAction; + +typedef enum { + /* 0 */ EN_WIZ_INTRO_CS_NOT_STARTED, + /* 1 */ EN_WIZ_INTRO_CS_CAMERA_MOVE_TO_PLATFORM, + /* 2 */ EN_WIZ_INTRO_CS_APPEAR, + /* 3 */ EN_WIZ_INTRO_CS_CAMERA_SPIN_TO_FACE_WIZROBE, + /* 4 */ EN_WIZ_INTRO_CS_WAIT_BEFORE_RUN, + /* 5 */ EN_WIZ_INTRO_CS_RUN_IN_CIRCLES, + /* 6 */ EN_WIZ_INTRO_CS_DISAPPEAR, + /* 7 */ EN_WIZ_INTRO_CS_END +} EnWizIntroCutsceneState; + +typedef enum { + /* 0 */ EN_WIZ_FIGHT_STATE_FIRST_PHASE, + /* 1 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE, + /* 2 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE, + /* 3 */ EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND, +} EnWizFightState; + +typedef enum { + /* 0 */ EN_WIZ_ANIM_IDLE, + /* 1 */ EN_WIZ_ANIM_RUN, + /* 2 */ EN_WIZ_ANIM_DANCE, + /* 3 */ EN_WIZ_ANIM_WIND_UP, + /* 4 */ EN_WIZ_ANIM_ATTACK, + /* 5 */ EN_WIZ_ANIM_DAMAGE, +} EnWizAnimation; + +ActorInit En_Wiz_InitVars = { ACTOR_EN_WIZ, ACTORCAT_ENEMY, FLAGS, @@ -30,199 +92,1470 @@ const ActorInit En_Wiz_InitVars = { (ActorFunc)EnWiz_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[10] = { -static ColliderJntSphElementInit D_80A48B50[10] = { +static ColliderJntSphElementInit sJntSphElementsInit[10] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 1 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 1 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, - { 1, { { 0, 0, 0 }, 0 }, 0 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { WIZROBE_LIMB_PELVIS, { { 0, 0, 0 }, 0 }, 0 }, }, }; -// 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, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT2, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A48CC8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK1, { 0xF7CFFFFF, 0x08, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0xF7CFFFFF, 0x08, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 35, 130, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80A48CF4 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(3, 0xF), - /* Fire arrow */ DMG_ENTRY(1, 0x2), - /* Ice arrow */ DMG_ENTRY(2, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0xF), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(0, 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, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +typedef enum { + /* 0x0 */ EN_WIZ_DMGEFF_IMMUNE, // Deals no damage + /* 0x1 */ EN_WIZ_DMGEFF_UNK1, // Deals no damage. Was probably originally intended for destroying ghosts. + /* 0x2 */ EN_WIZ_DMGEFF_FIRE, // Damages and sets Ice Wizrobes on fire + /* 0x3 */ EN_WIZ_DMGEFF_FREEZE, // Damages and surrounds Fire Wizrobes with ice + /* 0x4 */ EN_WIZ_DMGEFF_LIGHT_ORB, // Damages and surrounds the Wizrobe with light orbs + /* 0xF */ EN_WIZ_DMGEFF_NONE = 0xF, // Deals regular damage and has no special effect +} EnWizDamageEffect; + +static DamageTable sFireWizrobeDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Deku Stick */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Explosives */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* UNK_DMG_D_06 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Hookshot */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(3, EN_WIZ_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Deku spin */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Zora barrier */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal shield */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), }; -// static DamageTable sDamageTable = { -static DamageTable D_80A48D14 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0xF), - /* Horse trample */ DMG_ENTRY(0, 0x0), - /* Explosives */ DMG_ENTRY(1, 0xF), - /* Zora boomerang */ DMG_ENTRY(1, 0xF), - /* Normal arrow */ DMG_ENTRY(1, 0xF), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0xF), - /* Sword */ DMG_ENTRY(1, 0xF), - /* Goron pound */ DMG_ENTRY(3, 0xF), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(0, 0x0), - /* Deku spin */ DMG_ENTRY(1, 0xF), - /* Deku bubble */ DMG_ENTRY(1, 0xF), - /* Deku launch */ DMG_ENTRY(0, 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, 0xF), - /* Zora punch */ DMG_ENTRY(1, 0xF), - /* Spin attack */ DMG_ENTRY(1, 0xF), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0xF), +static DamageTable sIceWizrobeDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Deku Stick */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Explosives */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* UNK_DMG_D_06 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Hookshot */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron punch */ DMG_ENTRY(2, EN_WIZ_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(3, EN_WIZ_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_FIRE), + /* Ice arrow */ DMG_ENTRY(1, EN_WIZ_DMGEFF_FREEZE), + /* Light arrow */ DMG_ENTRY(2, EN_WIZ_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Deku spin */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku bubble */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_WIZ_DMGEFF_UNK1), + /* Zora barrier */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal shield */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Light ray */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Thrown object */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Normal Roll */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Unblockable */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_WIZ_DMGEFF_IMMUNE), + /* Powder Keg */ DMG_ENTRY(1, EN_WIZ_DMGEFF_NONE), }; -#endif +void EnWiz_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; -extern ColliderJntSphElementInit D_80A48B50[10]; -extern ColliderJntSphInit D_80A48CB8; -extern ColliderCylinderInit D_80A48CC8; -extern DamageTable D_80A48CF4; -extern DamageTable D_80A48D14; + SkelAnime_InitFlex(play, &this->skelAnime, &gWizrobeSkel, &gWizrobeIdleAnim, this->jointTable, this->morphTable, + WIZROBE_LIMB_MAX); + SkelAnime_InitFlex(play, &this->ghostSkelAnime, &gWizrobeSkel, &gWizrobeIdleAnim, this->ghostBaseJointTable, + this->ghostMorphTable, WIZROBE_LIMB_MAX); + Actor_SetScale(&this->actor, 0.0f); + this->platformLightAlpha = 0; + this->alpha = 255; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + this->actor.targetMode = 3; + this->unk_450 = 1.0f; + this->actor.shape.yOffset = 700.0f; + Collider_InitAndSetJntSph(play, &this->ghostColliders, &this->actor, &sJntSphInit, this->ghostColliderElements); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->staffFlameScroll = Rand_S16Offset(0, 7); + this->switchFlag = EN_WIZ_GET_SWITCHFLAG(&this->actor); + this->type = EN_WIZ_GET_TYPE(&this->actor); -extern UNK_TYPE D_0600211C; -extern UNK_TYPE D_060025F0; -extern UNK_TYPE D_060066C0; + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Init.s") + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->actor.colChkInfo.damageTable = &sFireWizrobeDamageTable; + this->actor.colChkInfo.health = 8; + this->actor.flags &= ~ACTOR_FLAG_100000; + } else { + this->actor.colChkInfo.damageTable = &sIceWizrobeDamageTable; + this->actor.colChkInfo.health = 6; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Destroy.s") + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { + Actor_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A455C4.s") + this->actor.hintId = TATL_HINT_ID_WIZROBE; + this->curPlatformIndex = INITIAL_PLATFORM_INDEX; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A456A0.s") + // Setting the radius and scale to zero here effectively disables all of the ghost colliders. + this->ghostColliders.elements[0].dim.modelSphere.radius = 0; + this->ghostColliders.elements[0].dim.scale = 0.0f; + this->ghostColliders.elements[0].dim.modelSphere.center.x = 0; + this->ghostColliders.elements[0].dim.modelSphere.center.y = 0; + this->ghostColliders.elements[0].dim.modelSphere.center.z = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A45CD8.s") + this->actionFunc = EnWiz_StartIntroCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A460A4.s") +void EnWiz_Destroy(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46280.s") + Collider_DestroyCylinder(play, &this->collider); + Collider_DestroyJntSph(play, &this->ghostColliders); + if (this->type != EN_WIZ_TYPE_FIRE_NO_BGM) { + Audio_RestorePrevBgm(); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A462F8.s") +static AnimationHeader* sAnimations[] = { + &gWizrobeIdleAnim, // EN_WIZ_ANIM_IDLE + &gWizrobeRunAnim, // EN_WIZ_ANIM_RUN + &gWizrobeDanceAnim, // EN_WIZ_ANIM_DANCE + &gWizrobeWindUpAnim, // EN_WIZ_ANIM_WIND_UP + &gWizrobeAttackAnim, // EN_WIZ_ANIM_ATTACK + &gWizrobeDamageAnim, // EN_WIZ_ANIM_DAMAGE +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46414.s") +static u8 sAnimationModes[] = { + ANIMMODE_LOOP, // EN_WIZ_ANIM_IDLE + ANIMMODE_LOOP, // EN_WIZ_ANIM_RUN + ANIMMODE_LOOP, // EN_WIZ_ANIM_DANCE + ANIMMODE_LOOP, // EN_WIZ_ANIM_WIND_UP + ANIMMODE_LOOP, // EN_WIZ_ANIM_ATTACK + ANIMMODE_ONCE, // EN_WIZ_ANIM_DAMAGE +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A4668C.s") +void EnWiz_ChangeAnim(EnWiz* this, s32 animIndex, s32 updateGhostAnim) { + this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, sAnimationModes[animIndex], + -2.0f); + if (updateGhostAnim) { + Animation_Change(&this->ghostSkelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, + sAnimationModes[animIndex], -2.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46764.s") +/** + * Responsible for moving the camera around and making the Wizrobe run in circles during the intro cutscene. + */ +void EnWiz_HandleIntroCutscene(EnWiz* this, PlayState* play) { + Camera* subCam; + Vec3f eyeNext; + Vec3f atNext; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A468CC.s") + if (this->introCutsceneState < EN_WIZ_INTRO_CS_DISAPPEAR) { + subCam = Play_GetCamera(play, this->subCamId); + switch (this->introCutsceneState) { + case EN_WIZ_INTRO_CS_NOT_STARTED: + this->introCutsceneTimer = 100; + this->introCutsceneCameraAngle = this->actor.world.rot.y; + this->introCutsceneState++; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46990.s") + case EN_WIZ_INTRO_CS_CAMERA_MOVE_TO_PLATFORM: + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->introCutsceneCameraAngle) * 200.0f; + eyeNext.y += 100.0f; + eyeNext.z += Math_CosS(this->introCutsceneCameraAngle) * 200.0f; + atNext.y += 80.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + if ((fabsf(subCam->eye.x - eyeNext.x) < 2.0f) && (fabsf(subCam->eye.y - eyeNext.y) < 2.0f) && + (fabsf(subCam->eye.z - eyeNext.z) < 2.0f) && (fabsf(subCam->at.x - atNext.x) < 2.0f) && + (fabsf(subCam->at.y - atNext.y) < 2.0f) && (fabsf(subCam->at.z - atNext.z) < 2.0f)) { + Player* player = GET_PLAYER(play); + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46C88.s") + this->actor.world.rot.y = this->actor.shape.rot.y = + Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46CC4.s") + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y = Math_Vec3f_Yaw(&this->ghostPos[i], &player->actor.world.pos); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46DDC.s") + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, true); + this->shouldStartTimer = false; + this->targetPlatformLightAlpha = 255; + Math_Vec3f_Copy(&this->platformLightPos, &this->actor.world.pos); + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_UNARI); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A46E24.s") + this->introCutsceneTimer = 40; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47000.s") + case EN_WIZ_INTRO_CS_APPEAR: + if (this->introCutsceneTimer == 0) { + this->introCutsceneTimer = 20; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A470D8.s") + case EN_WIZ_INTRO_CS_CAMERA_SPIN_TO_FACE_WIZROBE: + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->actor.world.rot.y) * 160.0f; + eyeNext.y += 70.0f; + eyeNext.z += Math_CosS(this->actor.world.rot.y) * 140.0f; + atNext.x += -10.0f; + atNext.y += 100.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + if (this->introCutsceneTimer == 0) { + this->introCutsceneTimer = 10; + this->introCutsceneState++; + this->introCutsceneCameraAngle = this->actor.world.rot.y; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47298.s") + case EN_WIZ_INTRO_CS_WAIT_BEFORE_RUN: + if (this->introCutsceneTimer == 0) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_RUN, false); + this->rotationalVelocity = 0; + this->introCutsceneTimer = 34; + this->introCutsceneState++; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A473B8.s") + case EN_WIZ_INTRO_CS_RUN_IN_CIRCLES: + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + if (this->introCutsceneTimer == 0) { + this->animLoopCounter = this->introCutsceneCameraAngle = 0; + this->introCutsceneState = EN_WIZ_INTRO_CS_DISAPPEAR; + } else { + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + this->actor.world.rot.y += this->rotationalVelocity; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A4767C.s") + Math_Vec3f_Copy(&eyeNext, &this->actor.world.pos); + Math_Vec3f_Copy(&atNext, &this->actor.world.pos); + eyeNext.x += Math_SinS(this->introCutsceneCameraAngle) * 200.0f; + eyeNext.y += 100.0f; + eyeNext.z += Math_CosS(this->introCutsceneCameraAngle) * 200.0f; + atNext.y += 80.0f; + Math_ApproachF(&subCam->eye.x, eyeNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->eye.z, eyeNext.z, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.x, atNext.x, 0.3f, 30.0f); + Math_ApproachF(&subCam->at.z, atNext.z, 0.3f, 30.0f); + subCam->eye.y = eyeNext.y; + subCam->at.y = atNext.y; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A476C8.s") + default: + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A477E8.s") + if (this->musicStartTimer < 11) { + this->musicStartTimer++; + if ((this->type != EN_WIZ_TYPE_FIRE_NO_BGM) && (this->musicStartTimer == 11)) { + Audio_PlayBgm_StorePrevBgm(NA_BGM_MINI_BOSS); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Update.s") +/** + * Chooses which platform the Wizrobe should appear at, and updates its position accordingly. + * It also updates the position and alpha of all the ghosts. + */ +void EnWiz_SelectPlatform(EnWiz* this, PlayState* play) { + Actor* prop; + s32 i; + s32 j; + s16 ghostAlpha; + s16 type; + s16 curPlatformIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A47FCC.s") + for (i = 0; i < ARRAY_COUNT(this->platforms); i++) { + this->platforms[i] = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/func_80A48138.s") + prop = play->actorCtx.actorLists[ACTORCAT_PROP].first; + i = 0; + while (prop != NULL) { + if (prop->id != ACTOR_EN_WIZ_BROCK) { + prop = prop->next; + continue; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wiz/EnWiz_Draw.s") + this->platforms[i] = prop; + i++; + if (this->action != EN_WIZ_ACTION_BURST_INTO_FLAMES) { + type = this->type; + if (type == EN_WIZ_TYPE_FIRE_NO_BGM) { + type = EN_WIZ_TYPE_FIRE; + } + + prop->colChkInfo.health = type + EN_WIZ_BROCK_PLATFORM_TYPE_FIRE; + prop = prop->next; + } else { + prop->colChkInfo.health = EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE; + prop = prop->next; + } + } + + if (this->action != EN_WIZ_ACTION_DEAD) { + this->platformCount = i; + if (i < 0) { + i = 0; + } else if (this->platformCount > 10) { + this->platformCount = 10; + } + + curPlatformIndex = Rand_ZeroFloat(i); + while ((this->curPlatformIndex == curPlatformIndex) || ((s16)i == curPlatformIndex)) { + curPlatformIndex = Rand_ZeroFloat(i); + if (1) {} + } + + this->curPlatformIndex = curPlatformIndex; + switch (this->fightState) { + case EN_WIZ_FIGHT_STATE_FIRST_PHASE: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[curPlatformIndex]->world.pos); + break; + + case EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[0]->world.pos); + for (i = 0, ghostAlpha = 128; i < this->platformCount; i++, ghostAlpha -= 10) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->actor.world.pos); + this->ghostAlpha[i] = ghostAlpha; + } + break; + + default: + Math_Vec3f_Copy(&this->actor.world.pos, &this->platforms[curPlatformIndex]->world.pos); + for (i--; i >= 0; i--) { + if (curPlatformIndex != i) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->platforms[i]->world.pos); + this->ghostRot[i] = this->actor.world.rot; + this->ghostAlpha[i] = 100; + this->ghostNextPlatformIndex[i] = i; + for (j = 0; j < ARRAY_COUNT(this->jointTable); j++) { + this->ghostJointTables[i][j] = this->jointTable[j]; + } + } else { + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + } + break; + } + } +} + +/** + * Makes the ghosts run around the room from platform to platform. + */ +void EnWiz_MoveGhosts(EnWiz* this) { + s32 i; + s32 ghostNextPlatformIndex; + s32 playSfx = false; + + for (i = 0; i < this->platformCount; i++) { + if (this->ghostPos[i].x != 0.0f && this->ghostPos[i].z != 0.0f) { + f32 diffX; + f32 diffZ; + + ghostNextPlatformIndex = this->ghostNextPlatformIndex[i]; + diffX = this->platforms[ghostNextPlatformIndex]->world.pos.x - this->ghostPos[i].x; + diffZ = this->platforms[ghostNextPlatformIndex]->world.pos.z - this->ghostPos[i].z; + playSfx++; + + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 30.0f) { + this->ghostNextPlatformIndex[i]--; + if (this->ghostNextPlatformIndex[i] < 0) { + this->ghostNextPlatformIndex[i] = this->platformCount - 1; + } + } + + ghostNextPlatformIndex = this->ghostNextPlatformIndex[i]; + Math_ApproachF(&this->ghostPos[i].x, this->platforms[ghostNextPlatformIndex]->world.pos.x, 0.3f, 30.0f); + Math_ApproachF(&this->ghostPos[i].y, this->platforms[ghostNextPlatformIndex]->world.pos.y, 0.3f, 30.0f); + Math_ApproachF(&this->ghostPos[i].z, this->platforms[ghostNextPlatformIndex]->world.pos.z, 0.3f, 30.0f); + this->ghostRot[i].y = + Math_Vec3f_Yaw(&this->ghostPos[i], &this->platforms[ghostNextPlatformIndex]->world.pos); + } + } + + if (playSfx) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + } +} + +void EnWiz_StartIntroCutscene(EnWiz* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetFlag(this->actor.cutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(this->actor.cutscene); + this->actor.flags |= ACTOR_FLAG_100000; + EnWiz_SetupAppear(this, play); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void EnWiz_SetupAppear(EnWiz* this, PlayState* play) { + Player* player = GET_PLAYER(play); + s32 i; + s16 angle; + + this->action = EN_WIZ_ACTION_APPEAR; + + if (this->timer == 0) { + EnWiz_SelectPlatform(this, play); + + if (this->introCutsceneState != EN_WIZ_INTRO_CS_NOT_STARTED) { + angle = Math_Vec3f_Yaw(&this->actor.world.pos, &player->actor.world.pos); + this->actor.shape.rot.y = angle; + this->actor.world.rot.y = angle; + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y = Math_Vec3f_Yaw(&this->ghostPos[i], &player->actor.world.pos); + } + + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, true); + this->shouldStartTimer = false; + this->targetPlatformLightAlpha = 255; + Math_Vec3f_Copy(&this->platformLightPos, &this->actor.world.pos); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_UNARI); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } + } + + this->actionFunc = EnWiz_Appear; + } +} + +/** + * Makes the Wizrobe grow in scale and become more opaque. + * During the first phase, it also increases the alpha for the platform's light. + * If the player gets too close during the first phase, this will set up the Wizrobe to disappear. + */ +void EnWiz_Appear(EnWiz* this, PlayState* play) { + Vec3f staffTargetFlameScale = { 0.006f, 0.006f, 0.006f }; + Player* player = GET_PLAYER(play); + + EnWiz_HandleIntroCutscene(this, play); + + if (this->introCutsceneState >= EN_WIZ_INTRO_CS_APPEAR) { + SkelAnime_Update(&this->skelAnime); + + if ((this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) && + (this->introCutsceneState >= EN_WIZ_INTRO_CS_DISAPPEAR) && + ((this->actor.xzDistToPlayer < 200.0f) || + ((player->unk_D57 != 0) && + ((ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y)) < 0x7D0)) && + (ABS_ALT(BINANG_SUB(this->actor.yawTowardsPlayer, BINANG_ADD(player->actor.shape.rot.y, 0x8000))) < + 0x7D0)))) { + EnWiz_SetupDisappear(this); + } else { + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xBB8, 0); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 10, 10); + if (!this->shouldStartTimer) { + this->timer = 20; + this->shouldStartTimer = true; + } + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_VOICE - SFX_FLAG); + } + + if (this->timer == 0) { + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.01f); + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + } + + if (this->scale < 0.0138f) { + return; + } else { + this->action = EN_WIZ_ACTION_RUN_IN_CIRCLES; + this->actor.flags &= ~ACTOR_FLAG_8000000; + this->ghostColliders.elements[0].info.bumper.dmgFlags = 0x1013A22; + Math_Vec3f_Copy(&this->staffTargetFlameScale, &staffTargetFlameScale); + this->targetPlatformLightAlpha = 0; + + if (this->introCutsceneState == EN_WIZ_INTRO_CS_DISAPPEAR) { + this->timer = 0; + this->introCutsceneTimer = 20; + EnWiz_SetupDisappear(this); + } else if (this->introCutsceneState >= EN_WIZ_INTRO_CS_END) { + if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE) { + this->actionFunc = EnWiz_SetupSecondPhaseCutscene; + } else { + EnWiz_SetupDance(this); + } + } + } + } + } +} + +void EnWiz_SetupDance(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false); + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.001f); + this->rotationalVelocity = 0; + this->animLoopCounter = 0; + this->action = EN_WIZ_ACTION_DANCE; + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE) { + Animation_Change(&this->ghostSkelAnime, &gWizrobeRunAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gWizrobeRunAnim), + ANIMMODE_LOOP, 0.0f); + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND; + } + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + this->actionFunc = EnWiz_Dance; +} + +/** + * Makes the Wizrobe spin around and dance until there are no active projectiles + * and it completes at least three loops of its dancing animation. + */ +void EnWiz_Dance(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + Math_ApproachF(&this->scale, 0.015f, 0.05f, 0.001f); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + this->actor.world.rot.y += this->rotationalVelocity; + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } else { + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + } + + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 20, 50, 10); + if (this->endFrame <= curFrame) { + if (this->animLoopCounter < 10) { + this->animLoopCounter++; + } + } + + if ((this->animLoopCounter >= 3) && (!this->hasActiveProjectile)) { + this->targetPlatformLightAlpha = 0; + EnWiz_SetupWindUp(this); + } +} + +void EnWiz_SetupSecondPhaseCutscene(EnWiz* this, PlayState* play) { + s16 secondPhaseCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + + if (!ActorCutscene_GetCanPlayNext(secondPhaseCutscene)) { + ActorCutscene_SetIntentToPlay(secondPhaseCutscene); + } else { + ActorCutscene_StartAndSetFlag(secondPhaseCutscene, &this->actor); + this->subCamId = ActorCutscene_GetCurrentSubCamId(secondPhaseCutscene); + this->actor.flags |= ACTOR_FLAG_100000; + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false); + this->action = EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS; + this->nextPlatformIndex = 1; + this->hasRunToEveryPlatform = false; + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + this->actionFunc = EnWiz_SecondPhaseCutscene; + } +} + +/** + * Makes the Wizrobe run between every platform in the room once before returning to its + * original platform and disappearing. Ghosts trail behind the Wizrobe as it runs. + */ +void EnWiz_SecondPhaseCutscene(EnWiz* this, PlayState* play) { + Camera* subCam; + s32 i; + + Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0); + subCam = Play_GetCamera(play, this->subCamId); + Math_Vec3f_Copy(&subCam->at, &this->actor.focus.pos); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_RUN - SFX_FLAG); + if (this->platforms[this->nextPlatformIndex] != NULL) { + f32 diffX = this->actor.world.pos.x - this->platforms[this->nextPlatformIndex]->world.pos.x; + f32 diffZ = this->actor.world.pos.z - this->platforms[this->nextPlatformIndex]->world.pos.z; + s32 pad; + + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 30.0f) { + if (!this->hasRunToEveryPlatform) { + this->nextPlatformIndex++; + if (this->nextPlatformIndex >= this->platformCount) { + this->hasRunToEveryPlatform = true; + this->nextPlatformIndex = 0; + } + } else { + f32 diffX = this->actor.world.pos.x - this->ghostPos[this->platformCount].x; + f32 diffZ = this->actor.world.pos.z - this->ghostPos[this->platformCount].z; + s32 pad; + s32 i; + + this->actor.flags |= ACTOR_FLAG_8000000; + if (sqrtf(SQ(diffX) + SQ(diffZ)) < 20.0f) { + for (i = 0; i < this->platformCount; i++) { + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + + this->nextPlatformIndex = 0; + this->platformCount = 0; + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE; + this->timer = 0; + ActorCutscene_Stop(ActorCutscene_GetAdditionalCutscene(this->actor.cutscene)); + this->actor.flags &= ~ACTOR_FLAG_100000; + EnWiz_SetupDisappear(this); + return; + } + } + } + } + + Math_Vec3f_Copy(this->ghostPos, &this->actor.world.pos); + this->ghostRot[0].y = this->actor.world.rot.y; + Math_ApproachF(&this->actor.world.pos.x, this->platforms[this->nextPlatformIndex]->world.pos.x, 0.3f, 30.0f); + Math_ApproachF(&this->actor.world.pos.y, this->platforms[this->nextPlatformIndex]->world.pos.y, 0.3f, 30.0f); + Math_ApproachF(&this->actor.world.pos.z, this->platforms[this->nextPlatformIndex]->world.pos.z, 0.3f, 30.0f); + for (i = this->platformCount; i > 0; i--) { + Math_Vec3f_Copy(&this->ghostPos[i], &this->ghostPos[i - 1]); + this->ghostRot[i].y = this->ghostRot[i - 1].y; + } + + this->actor.world.rot.y = + Math_Vec3f_Yaw(&this->actor.world.pos, &this->platforms[this->nextPlatformIndex]->world.pos); +} + +void EnWiz_SetupWindUp(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_WIND_UP, false); + this->animLoopCounter = 0; + this->actionFunc = EnWiz_WindUp; +} + +/** + * Plays the wind up animation for at least two animation loops before attacking. + */ +void EnWiz_WindUp(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + s32 i; + + Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xC8, 0x1F40, 0x1388); + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } else { + for (i = 0; i < this->platformCount; i++) { + Math_SmoothStepToS(&this->ghostRot[i].y, this->actor.yawTowardsPlayer, 0xC8, 0x1F40, 0x1388); + } + } + + if (this->endFrame <= curFrame) { + this->animLoopCounter++; + if (this->animLoopCounter >= 2) { + EnWiz_SetupAttack(this); + } + } + + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 10, 10); +} + +void EnWiz_SetupAttack(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_ATTACK, false); + this->timer = 0; + this->shouldStartTimer = false; + this->action = EN_WIZ_ACTION_ATTACK; + this->actionFunc = EnWiz_Attack; +} + +/** + * Spawns an EnWizFire projectile that is pointed at the player, then disappears. + */ +void EnWiz_Attack(EnWiz* this, PlayState* play) { + f32 curFrame = this->skelAnime.curFrame; + + if (this->fightState >= EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + EnWiz_MoveGhosts(this); + } + + if (this->timer == 0) { + if ((Animation_OnFrame(&this->skelAnime, 6.0f)) && (!this->hasActiveProjectile)) { + Player* player = GET_PLAYER(play); + Vec3f pos; + s32 type = this->type; + + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += Math_SinS(this->actor.world.rot.y) * 40.0f; + pos.y += 60.0f; + pos.z += Math_CosS(this->actor.world.rot.y) * 40.0f; + if (type == EN_WIZ_TYPE_FIRE_NO_BGM) { + type = EN_WIZ_TYPE_FIRE; + } + + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_WIZ_FIRE, pos.x, pos.y, pos.z, + Math_Vec3f_Pitch(&pos, &player->actor.world.pos), + Math_Vec3f_Yaw(&pos, &player->actor.world.pos), 0, type * 4); + this->hasActiveProjectile = true; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_ATTACK); + Actor_PlaySfxAtPos(&this->actor, NA_SE_PL_MAGIC_FIRE); + } + + if ((curFrame >= 8.0f) && !this->shouldStartTimer) { + this->timer = 3; + this->shouldStartTimer = true; + } + + if (this->endFrame <= curFrame) { + EnWiz_SetupDisappear(this); + } + } +} + +void EnWiz_SetupDisappear(EnWiz* this) { + if (this->action != EN_WIZ_ACTION_DAMAGED) { + this->rotationalVelocity = 0x2710; + this->timer = 0; + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_IDLE, false); + this->action = EN_WIZ_ACTION_DISAPPEAR; + } else { + this->rotationalVelocity = 0x2710; + this->actor.world.rot.y += this->rotationalVelocity; + } + + this->targetPlatformLightAlpha = 0; + this->actor.flags |= ACTOR_FLAG_8000000; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DISAPPEAR); + Math_SmoothStepToS(&this->rotationalVelocity, 0x1388, 0x64, 0x3E8, 0x3E8); + this->actor.world.rot.y += this->rotationalVelocity; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = EnWiz_Disappear; +} + +/** + * Spin the Wizrobe around and shrink it so that it disappears into its platform. + * Afterwards, set it up to appear again. + */ +void EnWiz_Disappear(EnWiz* this, PlayState* play) { + s32 i; + + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + this->actor.world.rot.y += this->rotationalVelocity; + if ((this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) || (this->action == EN_WIZ_ACTION_DAMAGED)) { + Math_ApproachZeroF(&this->scale, 0.3f, 0.01f); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 5, 50, 0); + } else { + Math_ApproachZeroF(&this->scale, 0.3f, 0.001f); + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 10, 50, 0); + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + } + + Math_Vec3f_Copy(&this->staffTargetFlameScale, &gZeroVec3f); + if (this->scale < 0.001f) { + this->scale = 0.0f; + + if ((this->introCutsceneState == EN_WIZ_INTRO_CS_DISAPPEAR) && (this->introCutsceneTimer == 0)) { + this->introCutsceneState = EN_WIZ_INTRO_CS_END; + ActorCutscene_Stop(this->actor.cutscene); + this->actor.flags &= ~ACTOR_FLAG_100000; + } + + if (this->introCutsceneState != EN_WIZ_INTRO_CS_DISAPPEAR) { + this->alpha = 0; + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->ghostColliders.elements[0].info.bumper.dmgFlags = 0x1000202; + } + + this->actor.flags |= ACTOR_FLAG_1; + this->actionFunc = EnWiz_SetupAppear; + } + } +} + +void EnWiz_SetupDamaged(EnWiz* this, PlayState* play) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DAMAGE, false); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 8); + this->timer = 20; + + if ((this->fightState != EN_WIZ_FIGHT_STATE_FIRST_PHASE) && (this->actor.colChkInfo.health <= 0)) { + Enemy_StartFinishingBlow(play, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DEAD); + this->timer = 0; + this->actor.flags &= ~ACTOR_FLAG_1; + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_DAMAGE); + } + + this->scale = 0.015f; + this->platformCount = 0; + this->targetPlatformLightAlpha = 0; + if ((this->drawDmgEffTimer != 0) && + ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS))) { + this->timer = 0; + } + + this->rotationalVelocity = 0x4E20; + if ((this->drawDmgEffTimer != 0) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX)) { + this->rotationalVelocity = 0; + this->timer = 0; + } + + this->action = EN_WIZ_ACTION_DAMAGED; + this->actionFunc = EnWiz_Damaged; +} + +/** + * Spins the Wizrobe around quickly and makes it jump in the air if it was defeated or if + * it was damaged in a certain way. Afterwards, the Wizrobe either disappears or dies. + */ +void EnWiz_Damaged(EnWiz* this, PlayState* play) { + s32 i; + + if ((this->drawDmgEffTimer < 50) && (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_SFX)) { + Actor_SpawnIceEffects(play, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), 2, 1.0f, 0.7f); + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->rotationalVelocity = 0x4E20; + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + } + + if ((this->drawDmgEffTimer != 0) && (this->drawDmgEffTimer < 30) && + ((this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FIRE) || (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_LIGHT_ORBS))) { + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + this->drawDmgEffTimer = 0; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (!this->isDead && (this->fightState != EN_WIZ_FIGHT_STATE_FIRST_PHASE) && + (this->actor.colChkInfo.health <= 0)) { + this->actor.velocity.y = 30.0f; + this->actor.gravity = -3.0f; + this->isDead = true; + } + + this->actor.world.rot.y += this->rotationalVelocity; + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + for (i = 0; i < this->platformCount; i++) { + this->ghostRot[i].y += this->rotationalVelocity; + } + + if ((this->timer == 1) || + ((this->actor.velocity.y < 0.0f) && + (this->actor.world.pos.y < (this->platforms[this->curPlatformIndex]->world.pos.y + 11.0f)))) { + this->timer = 0; + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + this->drawDmgEffTimer = this->timer; + this->drawDmgEffType = this->timer; + + if (this->actor.colChkInfo.health <= 0) { + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE; + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->actor.colChkInfo.health = 8; + } else { + this->actor.colChkInfo.health = 6; + } + + EnWiz_SetupDisappear(this); + } else { + EnWiz_SetupDead(this); + } + } else { + EnWiz_SetupDisappear(this); + } + + this->actor.flags |= ACTOR_FLAG_8000000; + } + + Math_SmoothStepToS(&this->platformLightAlpha, this->targetPlatformLightAlpha, 20, 50, 10); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 35.0f, 40.0f, 40.0f, 0x1F); +} + +void EnWiz_SetupDead(EnWiz* this) { + EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DAMAGE, false); + this->rotationalVelocity = 0x2710; + this->action = EN_WIZ_ACTION_DEAD; + this->timer = 0; + this->actionFunc = EnWiz_Dead; +} + +/** + * Slows the Wizrobe's rotation to a stop, then makes it burst into flames. + * If the Wizrobe has a switch flag, it will set that switch flag when it dies. + */ +void EnWiz_Dead(EnWiz* this, PlayState* play) { + s32 i; + + this->actor.world.rot.y += this->rotationalVelocity; + Math_SmoothStepToS(&this->rotationalVelocity, 0, 0xA, 0xBB8, 0x14); + if (this->rotationalVelocity < 0x1E) { + Math_SmoothStepToS(&this->alpha, 0, 10, 30, 20); + for (i = 0; i < this->platformCount; i++) { + Math_SmoothStepToS(&this->ghostAlpha[i], 0, 10, 30, 20); + } + + this->action = EN_WIZ_ACTION_BURST_INTO_FLAMES; + } + + if (this->alpha < 30) { + EnWiz_SelectPlatform(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EN_EXTINCT); + Actor_Kill(&this->actor); + if (this->switchFlag >= 0) { + Flags_SetSwitch(play, this->switchFlag); + } + } +} + +static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 }; +static Color_RGBA8 sDustEnvTimer = { 180, 180, 180, 255 }; + +void EnWiz_UpdateDamage(EnWiz* this, PlayState* play) { + s32 i; + s32 attackDealsDamage = false; + + if (this->collider.base.acFlags & AC_HIT) { + this->ghostColliders.base.acFlags &= ~AC_HIT; + if (this->action < EN_WIZ_ACTION_RUN_IN_CIRCLES) { + return; + } + + switch (this->actor.colChkInfo.damageEffect) { + case EN_WIZ_DMGEFF_NONE: + attackDealsDamage = true; + break; + + case EN_WIZ_DMGEFF_FIRE: + if (this->type == EN_WIZ_TYPE_ICE) { + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } + + attackDealsDamage = true; + break; + + case EN_WIZ_DMGEFF_FREEZE: + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + this->drawDmgEffTimer = 80; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_SFX; + this->drawDmgEffScale = 0.0f; + this->drawDmgEffFrozenSteamScale = 1.5f; + } + + Actor_ApplyDamage(&this->actor); + EnWiz_SetupDamaged(this, play); + break; + + case EN_WIZ_DMGEFF_LIGHT_ORB: + if (((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); + this->drawDmgEffTimer = 40; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + attackDealsDamage = true; + } + break; + } + + this->alpha = 255; + if (attackDealsDamage) { + Actor_ApplyDamage(&this->actor); + EnWiz_SetupDamaged(this, play); + return; + } + } + + if ((this->platformCount != 0) && (this->fightState != EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE)) { + for (i = 0; i < this->platformCount; i++) { + Vec3f accel; + Vec3f velocity; + Vec3f pos; + f32 scaleStep; + s32 j; + + // If the player throws a Deku Nut or hits a ghost's collider (something that is impossible + // in the final game, since EnWiz_Init effectively disables them), then the below code will + // "destroy" the ghost by turning into a cloud of smoke. + if ((iREG(50) != 0) || (this->ghostColliders.elements[i + 1].info.bumperFlags & BUMP_HIT)) { + //! @bug: If a single ghost is destroyed, then changing the fight state here will cause + //! strange behavior; the ghosts will stand still and pretend to attack the player like + //! the real Wizrobe. Since Deku Nuts destroy all ghosts at once, and since the ghost + //! colliders are effectively disabled, this doesn't cause any problems in the final + //! game, but it becomes an issue if the ghost colliders are enabled. + this->fightState = EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_COPY_WIZROBE; + this->ghostColliders.base.acFlags &= ~BUMP_HIT; + if (this->ghostPos[i].x != .0f || this->ghostPos[i].z != .0f) { + for (j = 0; j < 9; j++) { + accel.x = 0.0f; + accel.y = 1.0f; + accel.z = 0.0f; + velocity.x = 0.0f; + velocity.y = 1.0f; + velocity.z = 0.0f; + scaleStep = Rand_S16Offset(20, 10); + Math_Vec3f_Copy(&pos, &this->ghostPos[i]); + pos.x += (f32)Rand_S16Offset(20, 20) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + pos.y += 70.0f + randPlusMinusPoint5Scaled(30.0f); + pos.z += (f32)Rand_S16Offset(20, 20) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1); + func_800B0DE0(play, &pos, &velocity, &accel, &sDustPrimColor, &sDustEnvTimer, + Rand_S16Offset(350, 100), scaleStep); + } + + SoundSource_PlaySfxAtFixedWorldPos(play, &this->ghostPos[i], 50, NA_SE_EN_WIZ_LAUGH); + Math_Vec3f_Copy(&this->ghostPos[i], &gZeroVec3f); + } + } + } + } +} + +void EnWiz_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; + s32 i; + s32 j; + + if (this->action != EN_WIZ_ACTION_APPEAR) { + SkelAnime_Update(&this->skelAnime); + SkelAnime_Update(&this->ghostSkelAnime); + } + + Actor_SetFocus(&this->actor, 60.0f); + Actor_SetScale(&this->actor, this->scale); + EnWiz_UpdateDamage(this, play); + this->actionFunc(this, play); + + this->actor.shape.rot.y = this->actor.world.rot.y; + + DECR(this->timer); + DECR(this->introCutsceneTimer); + DECR(this->drawDmgEffTimer); + + this->collider.dim.radius = 35; + this->collider.dim.height = 130; + this->collider.dim.yShift = 0; + if (this->action >= EN_WIZ_ACTION_RUN_IN_CIRCLES) { + CollisionCheck_SetAC(play, &play->colChkCtx, &this->ghostColliders.base); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + + Math_ApproachF(&this->staffFlameScale.x, this->staffTargetFlameScale.x, 0.3f, 0.002f); + Math_ApproachF(&this->staffFlameScale.y, this->staffTargetFlameScale.y, 0.3f, 0.002f); + Math_ApproachF(&this->staffFlameScale.z, this->staffTargetFlameScale.z, 0.3f, 0.002f); + + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + this->platformCount = 0; + } else if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_GHOSTS_RUN_AROUND) { + for (i = 0; i < this->platformCount; i++) { + for (j = 0; j < ARRAY_COUNT(this->ghostBaseJointTable); j++) { + this->ghostJointTables[i][j] = this->ghostBaseJointTable[j]; + } + } + } else { + for (i = 0; i < this->platformCount; i++) { + for (j = 0; j < ARRAY_COUNT(this->jointTable); j++) { + this->ghostJointTables[i][j] = this->jointTable[j]; + } + } + } +} + +void EnWiz_PostLimbDrawOpa(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + Vec3f staffFlamePos = { 0.0f, 0.0f, 0.0f }; + EnWiz* this = THIS; + + if (limbIndex == WIZROBE_LIMB_STAFF) { + staffFlamePos.x = 7300.0f; + staffFlamePos.y = -1500.0f; + if (this->action != EN_WIZ_ACTION_DANCE) { + staffFlamePos.y = 0.0f; + staffFlamePos.x = 5300.0f; + } + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &this->staffFlamePos); + } + + Collider_UpdateSpheres(limbIndex, &this->ghostColliders); + + if ((limbIndex == WIZROBE_LIMB_PELVIS) || (limbIndex == WIZROBE_LIMB_TORSO) || + (limbIndex == WIZROBE_LIMB_LEFT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_LEFT_FOREARM) || + (limbIndex == WIZROBE_LIMB_RIGHT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_RIGHT_FOREARM) || + (limbIndex == WIZROBE_LIMB_NECK) || (limbIndex == WIZROBE_LIMB_HEAD) || (limbIndex == WIZROBE_LIMB_JAW) || + (limbIndex == WIZROBE_LIMB_LEFT_SHIN) || (limbIndex == WIZROBE_LIMB_RIGHT_SHIN) || + (limbIndex == WIZROBE_LIMB_LOINCLOTH)) { + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } +} + +void EnWiz_PostLimbDrawXlu(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + Vec3f staffFlamePos = { 0.0f, 0.0f, 0.0f }; + s32 pad; + EnWiz* this = THIS; + + if (this->action != EN_WIZ_ACTION_BURST_INTO_FLAMES) { + if (limbIndex == WIZROBE_LIMB_STAFF) { + staffFlamePos.x = 7300.0f; + staffFlamePos.y = -1500.0f; + if (this->action != EN_WIZ_ACTION_DANCE) { + staffFlamePos.y = 0.0f; + staffFlamePos.x = 5300.0f; + } + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &this->staffFlamePos); + } + } else { + if (this->timer == 0) { + Vec3f flamePos; + + Matrix_Translate(0.0f, 0.0f, 0.0f, MTXMODE_APPLY); + Matrix_MultVec3f(&staffFlamePos, &flamePos); + flamePos.x += randPlusMinusPoint5Scaled(4.0f); + flamePos.y += randPlusMinusPoint5Scaled(7.0f); + flamePos.z += randPlusMinusPoint5Scaled(5.0f); + func_800B3030(play, &flamePos, &gZeroVec3f, &gZeroVec3f, ((Rand_ZeroFloat(1.0f) * 50.0f) + 70.0f), 10, 1); + SoundSource_PlaySfxAtFixedWorldPos(play, &flamePos, 10, NA_SE_EN_EXTINCT); + } + + if ((limbIndex >= WIZROBE_LIMB_RIGHT_FOOT) && (this->timer == 0)) { + this->timer = 4; + } + } + + if ((limbIndex == WIZROBE_LIMB_PELVIS) || (limbIndex == WIZROBE_LIMB_TORSO) || + (limbIndex == WIZROBE_LIMB_LEFT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_LEFT_FOREARM) || + (limbIndex == WIZROBE_LIMB_RIGHT_UPPER_ARM) || (limbIndex == WIZROBE_LIMB_RIGHT_FOREARM) || + (limbIndex == WIZROBE_LIMB_NECK) || (limbIndex == WIZROBE_LIMB_HEAD) || (limbIndex == WIZROBE_LIMB_JAW) || + (limbIndex == WIZROBE_LIMB_LEFT_SHIN) || (limbIndex == WIZROBE_LIMB_RIGHT_SHIN) || + (limbIndex == WIZROBE_LIMB_LOINCLOTH)) { + Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsPosIndex]); + this->bodyPartsPosIndex++; + if (this->bodyPartsPosIndex >= ARRAY_COUNT(this->bodyPartsPos)) { + this->bodyPartsPosIndex = 0; + } + } +} + +void EnWiz_Draw(Actor* thisx, PlayState* play) { + s32 pad; + EnWiz* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + if ((this->action == EN_WIZ_ACTION_BURST_INTO_FLAMES) || (this->alpha != 255)) { + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->alpha); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnWiz_PostLimbDrawXlu, &this->actor, POLY_XLU_DISP); + } else { + Scene_SetRenderModeXlu(play, 0, 1); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, this->alpha); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnWiz_PostLimbDrawOpa, &this->actor); + } + + if (this->drawDmgEffTimer != 0) { + f32 drawDmgEffAlpha = 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, drawDmgEffAlpha, + this->drawDmgEffType); + } + + if (this->platformCount > 0) { + s32 i; + s16 platformCount; + + Matrix_Push(); + + platformCount = this->platformCount; + if (this->fightState == EN_WIZ_FIGHT_STATE_SECOND_PHASE_CUTSCENE) { + platformCount = 10; + } + + for (i = 0; i < platformCount; i++) { + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + if ((this->ghostPos[i].x != 0.0f) && (this->ghostPos[i].z != 0.0f)) { + Matrix_Translate(this->ghostPos[i].x, this->ghostPos[i].y + 10.0f, this->ghostPos[i].z, MTXMODE_NEW); + Matrix_Scale(this->scale, this->scale, this->scale, MTXMODE_APPLY); + Matrix_RotateYS(this->ghostRot[i].y, MTXMODE_APPLY); + Matrix_RotateXS(this->ghostRot[i].x, MTXMODE_APPLY); + Matrix_RotateZS(this->ghostRot[i].z, MTXMODE_APPLY); + Scene_SetRenderModeXlu(play, 1, 2); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, this->ghostAlpha[i]); + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->ghostSkelAnime.skeleton, this->ghostJointTables[i], + this->ghostSkelAnime.dListCount, NULL, NULL, &this->actor, POLY_XLU_DISP); + this->ghostColliders.elements[i + 1].dim.worldSphere.center.x = this->ghostPos[i].x; + this->ghostColliders.elements[i + 1].dim.worldSphere.center.y = this->ghostPos[i].y + 50.0f; + this->ghostColliders.elements[i + 1].dim.worldSphere.center.z = this->ghostPos[i].z; + this->ghostColliders.elements[i + 1].dim.worldSphere.radius = + this->ghostColliders.elements[0].dim.modelSphere.radius; + this->ghostColliders.elements[i + 1].dim.scale = this->ghostColliders.elements[0].dim.scale; + } + } + + Matrix_Pop(); + } + + func_8012C2DC(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + + // Draw the light emanating from the Wizrobe's platform + if (this->fightState == EN_WIZ_FIGHT_STATE_FIRST_PHASE) { + Matrix_Push(); + + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWizrobePlatformLightTexAnim)); + Matrix_Translate(this->platformLightPos.x, this->platformLightPos.y, this->platformLightPos.z, MTXMODE_NEW); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 255, this->platformLightAlpha); + + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 100, 255); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 50, 0, 255, 255); + } + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWizrobePlatformLightDL); + + Matrix_Pop(); + } + + // Draw the flame at the tip of the Wizrobe's staff + Matrix_Translate(this->staffFlamePos.x, this->staffFlamePos.y, this->staffFlamePos.z, MTXMODE_NEW); + Matrix_Scale(this->staffFlameScale.x, this->staffFlameScale.y, this->staffFlameScale.z, MTXMODE_APPLY); + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, + ((this->staffFlameScroll * 10) - (play->state.frames * 20)) % 512, 32, 128)); + gDPPipeSync(POLY_XLU_DISP++); + + if ((this->type == EN_WIZ_TYPE_FIRE) || (this->type == EN_WIZ_TYPE_FIRE_NO_BGM)) { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 50, 0, 255); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 255, 255); + } + + 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++, gEffFire1DL); + + CLOSE_DISPS(play->state.gfxCtx); +} 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..4d35a0f68 100644 --- a/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h +++ b/src/overlays/actors/ovl_En_Wiz/z_en_wiz.h @@ -2,24 +2,79 @@ #define Z_EN_WIZ_H #include "global.h" +#include "objects/object_wiz/object_wiz.h" + +#define EN_WIZ_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) +#define EN_WIZ_GET_TYPE(thisx) (((thisx)->params >> 8) & 0xFF) + +typedef enum { + /* 0 */ EN_WIZ_TYPE_FIRE, + /* 1 */ EN_WIZ_TYPE_ICE, + /* 2 */ EN_WIZ_TYPE_FIRE_NO_BGM, // does not request the mini-boss BGM +} EnWizType; 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 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[WIZROBE_LIMB_MAX]; + /* 0x200 */ Vec3s morphTable[WIZROBE_LIMB_MAX]; + /* 0x278 */ SkelAnime ghostSkelAnime; + /* 0x2BC */ Vec3s ghostBaseJointTable[WIZROBE_LIMB_MAX]; + /* 0x334 */ Vec3s ghostMorphTable[WIZROBE_LIMB_MAX]; + /* 0x3AC */ EnWizActionFunc actionFunc; + /* 0x3B0 */ s16 action; + /* 0x3B2 */ s16 timer; + /* 0x3B4 */ s16 introCutsceneTimer; + /* 0x3B6 */ s16 fightState; + /* 0x3B8 */ s16 staffFlameScroll; + /* 0x3BA */ s16 hasActiveProjectile; + /* 0x3BC */ s16 hasRunToEveryPlatform; // used for the second phase cutscene to make sure the Wizrobe visits every platform + /* 0x3BE */ s16 unk_3BE; // unused, inferred from surrounding members + /* 0x3C0 */ s16 rotationalVelocity; + /* 0x3C2 */ s16 alpha; + /* 0x3C4 */ s16 platformLightAlpha; + /* 0x3C6 */ s16 targetPlatformLightAlpha; + /* 0x3C8 */ s16 introCutsceneCameraAngle; + /* 0x3CA */ u8 shouldStartTimer; + /* 0x3CB */ u8 introCutsceneState; + /* 0x3CC */ s32 musicStartTimer; + /* 0x3D0 */ f32 endFrame; + /* 0x3D4 */ f32 scale; + /* 0x3D8 */ Vec3f staffFlamePos; + /* 0x3E4 */ Vec3f staffFlameScale; + /* 0x3F0 */ Vec3f staffTargetFlameScale; + /* 0x3FC */ Vec3f unk_3FC; // unused, inferred from surrounding members + /* 0x408 */ Vec3f unk_408; // unused, inferred from surrounding members + /* 0x414 */ Vec3f platformLightPos; + /* 0x420 */ Actor* platforms[10]; + /* 0x448 */ Actor* freezard; + /* 0x44C */ s16 animLoopCounter; + /* 0x450 */ f32 unk_450; // set to 1.0f, but never used + /* 0x454 */ ColliderJntSph ghostColliders; + /* 0x474 */ ColliderJntSphElement ghostColliderElements[10]; + /* 0x6F4 */ ColliderCylinder collider; + /* 0x740 */ s32 platformCount; + /* 0x744 */ s32 nextPlatformIndex; // used for the second phase cutscene to dictate where the Wizrobe should run to next + /* 0x748 */ s16 curPlatformIndex; + /* 0x74A */ s16 type; + /* 0x74C */ s16 switchFlag; + /* 0x74E */ s16 subCamId; + /* 0x750 */ s16 isDead; + /* 0x752 */ s16 drawDmgEffTimer; + /* 0x754 */ s16 drawDmgEffType; + /* 0x758 */ f32 drawDmgEffScale; + /* 0x75C */ f32 drawDmgEffFrozenSteamScale; + /* 0x760 */ Vec3f bodyPartsPos[12]; + /* 0x7F0 */ s16 bodyPartsPosIndex; + /* 0x7F2 */ s16 ghostAlpha[10]; + /* 0x806 */ s16 ghostNextPlatformIndex[10]; + /* 0x81C */ Vec3f ghostPos[10]; + /* 0x894 */ Vec3s ghostRot[10]; + /* 0x8D0 */ Vec3s ghostJointTables[10][WIZROBE_LIMB_MAX]; } EnWiz; // size = 0xD80 -extern const ActorInit En_Wiz_InitVars; - #endif // Z_EN_WIZ_H diff --git a/src/overlays/actors/ovl_En_Wiz_Brock/overlay.cfg b/src/overlays/actors/ovl_En_Wiz_Brock/overlay.cfg deleted file mode 100644 index 8976343c8..000000000 --- a/src/overlays/actors/ovl_En_Wiz_Brock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Wiz_Brock -z_en_wiz_brock.c 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 ddfa6af47..f2d88759e 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 @@ -1,7 +1,7 @@ /* * File: z_en_wiz_brock.c * Overlay: ovl_En_Wiz_Brock - * Description: Wizzrobe Warp Platform + * Description: Wizrobe Warp Platform */ #include "z_en_wiz_brock.h" @@ -11,24 +11,17 @@ #define THIS ((EnWizBrock*)thisx) -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_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); +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, PlayState* play); +void EnWizBrock_UpdateStatus(EnWizBrock* this, PlayState* play); -void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); -void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx); +s16 sPlatformIndex = 0; -s16 platformCount = 0; - -const ActorInit En_Wiz_Brock_InitVars = { +ActorInit En_Wiz_Brock_InitVars = { ACTOR_EN_WIZ_BROCK, ACTORCAT_PROP, FLAGS, @@ -40,40 +33,40 @@ const ActorInit En_Wiz_Brock_InitVars = { (ActorFunc)EnWizBrock_Draw, }; -void EnWizBrock_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnWizBrock_Init(Actor* thisx, PlayState* play) { EnWizBrock* this = THIS; CollisionHeader* colHeader = NULL; DynaPolyActor_Init(&this->dyna, 0); - CollisionHeader_GetVirtual(&object_wiz_Colheader_001690, &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader); + CollisionHeader_GetVirtual(&gWizrobePlatformCol, &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->platformIndex = sPlatformIndex++; 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; } -void EnWizBrock_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnWizBrock_Destroy(Actor* thisx, PlayState* play) { EnWizBrock* this = THIS; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } -void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { +void EnWizBrock_SetupUpdateStatus(EnWizBrock* this, PlayState* play) { this->actionFunc = EnWizBrock_UpdateStatus; } /** - * @brief Checks the platform status, when the Wizzrobe is defeated, which triggers timer to + * @brief Checks the platform status, when the Wizrobe is defeated, which triggers timer to * count up to 30 at which point the platforms are despawned. */ -void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { - if (this->platformType == PLATFORM_TYPE_INACTIVE) { - if (this->dyna.actor.colChkInfo.health != PLATFORM_TYPE_MAX) { +void EnWizBrock_UpdateStatus(EnWizBrock* this, PlayState* play) { + if (this->platformType == EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE) { + if (this->dyna.actor.colChkInfo.health != EN_WIZ_BROCK_PLATFORM_TYPE_MAX) { this->platformType = this->dyna.actor.colChkInfo.health; } } @@ -87,59 +80,59 @@ void EnWizBrock_UpdateStatus(EnWizBrock* this, GlobalContext* globalCtx) { (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); + Actor_Kill(&this->dyna.actor); } } } } -void EnWizBrock_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnWizBrock_Update(Actor* thisx, PlayState* play) { EnWizBrock* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnWizBrock_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnWizBrock_Draw(Actor* thisx, PlayState* play) { s32 pad; EnWizBrock* this = THIS; - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - OPEN_DISPS(globalCtx->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(globalCtx, 0, 1); + Scene_SetRenderModeXlu(play, 0, 1); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); - Gfx_DrawDListOpa(globalCtx, gWizzrobePlatform); + Gfx_DrawDListOpa(play, gWizrobePlatformDL); } else { - Scene_SetRenderModeXlu(globalCtx, 1, 2); + Scene_SetRenderModeXlu(play, 1, 2); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, (s16)this->alpha); - Gfx_DrawDListXlu(globalCtx, gWizzrobePlatform); + Gfx_DrawDListXlu(play, gWizrobePlatformDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - if (this->platformType != PLATFORM_TYPE_INACTIVE) { - OPEN_DISPS(globalCtx->state.gfxCtx); - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&gWizzrobePlatformTexAnim)); + if (this->platformType != EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE) { + OPEN_DISPS(play->state.gfxCtx); + AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gWizrobePlatformCenterTexAnim)); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); - if (this->platformType == PLATFORM_TYPE_FIRE) { + if (this->platformType == EN_WIZ_BROCK_PLATFORM_TYPE_FIRE) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 00, 100, (s16)this->alpha); } else { gDPSetEnvColor(POLY_XLU_DISP++, 50, 00, 255, (s16)this->alpha); } - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, &gWizzrobePlatformCenter); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, &gWizrobePlatformCenterDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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 ac900777e..3df0362ed 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 @@ -3,21 +3,26 @@ #include "global.h" +typedef enum { + /* 0 */ EN_WIZ_BROCK_PLATFORM_TYPE_INACTIVE, + /* 1 */ EN_WIZ_BROCK_PLATFORM_TYPE_FIRE, + /* 2 */ EN_WIZ_BROCK_PLATFORM_TYPE_ICE, + /* 3 */ EN_WIZ_BROCK_PLATFORM_TYPE_MAX, +} EnWizBrockPlatformType; + struct EnWizBrock; -typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, GlobalContext*); +typedef void (*EnWizBrockActionFunc)(struct EnWizBrock*, PlayState*); typedef struct EnWizBrock { /* 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 + /* 0x1A6 */ s16 unk_1A6; // set to 0, but never used + /* 0x1A8 */ s16 platformIndex; // 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; - #endif // Z_EN_WIZ_BROCK_H diff --git a/src/overlays/actors/ovl_En_Wiz_Fire/overlay.cfg b/src/overlays/actors/ovl_En_Wiz_Fire/overlay.cfg deleted file mode 100644 index 47aa9022a..000000000 --- a/src/overlays/actors/ovl_En_Wiz_Fire/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Wiz_Fire -z_en_wiz_fire.c 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 53713bbb1..4ed3333fd 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 @@ -1,7 +1,7 @@ /* * File: z_en_wiz_fire.c * Overlay: ovl_En_Wiz_Fire - * Description: Wizzrobe Fire/Ice Attack + * Description: Wizrobe Fire/Ice Attack */ #include "z_en_wiz_fire.h" @@ -12,25 +12,32 @@ #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* play2); +void EnWizFire_Draw(Actor* thisx, PlayState* play2); -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_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2); -void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx); -void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx); +void EnWiz_SetupMoveMagicProjectile(EnWizFire* this, PlayState* play); +void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play); +void EnWiz_SetupSmallFlame(EnWizFire* this, PlayState* play); +void EnWiz_SmallFlame(EnWizFire* this, PlayState* play); +void EnWiz_Pool(EnWizFire* this, PlayState* play); +void EnWiz_KillMagicProjectile(EnWizFire* this, PlayState* play); +void EnWizFire_DrawSmallFlame(Actor* thisx, PlayState* play); +void EnWizFire_InitializeEffect(EnWizFire* this, Vec3f* pos, Vec3f* accel); +void EnWizFire_UpdateEffects(EnWizFire* this, PlayState* play); +void EnWizFire_DrawEffects(EnWizFire* this, PlayState* play); -static s32 D_80A4C1C0 = 0; +typedef enum { + /* 0 */ EN_WIZ_FIRE_ACTION_MOVE_MAGIC_PROJECTILE, + /* 1 */ EN_WIZ_FIRE_ACTION_SMALL_FLAME, + /* 2 */ EN_WIZ_FIRE_ACTION_POOL, + /* 3 */ EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE, +} EnWizFireAction; -const ActorInit En_Wiz_Fire_InitVars = { +static s32 sPoolHitByIceArrow = false; + +ActorInit En_Wiz_Fire_InitVars = { ACTOR_EN_WIZ_FIRE, ACTORCAT_ENEMY, FLAGS, @@ -62,314 +69,338 @@ 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); - this->unk_162 = this->actor.params; + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->type = EN_WIZ_FIRE_GET_TYPE(&this->actor); this->actor.targetMode = 3; - this->unk_172 = 10; - this->unk_1FC = 255.0f; + this->wallCheckTimer = 10; + this->alpha = 255.0f; this->actor.flags &= ~ACTOR_FLAG_1; - if (!func_8012405C(globalCtx)) { + if (!Player_HasMirrorShieldEquipped(play)) { this->collider.info.toucher.dmgFlags = 0x20000000; } - switch (this->unk_162) { - case 4: - this->unk_166 = 1; + switch (this->type) { + case EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE: + this->isIceType = true; this->collider.info.toucher.damage = 8; this->collider.info.toucher.effect = 2; this->collider.info.bumper.dmgFlags = (0x1000000 | 0x800 | 0x200 | 0x2); - this->unk_162 = 0; - - case 0: - if (this->unk_162 == 4) { - this->unk_162 = 0; + this->type = EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE; + // fallthrough + case EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE: + if (this->type == EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE) { + this->type = EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE; this->collider.info.toucher.damage = 8; } - - case 1: - case 3: - this->actionFunc = func_80A4984C; + // fallthrough + case EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE: + case EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE: + this->actionFunc = EnWiz_SetupMoveMagicProjectile; break; - case 2: - this->actor.draw = func_80A4BAB4; - this->unk_170 = Rand_S16Offset(0, 10000); - this->unk_160 = 1; + case EN_WIZ_FIRE_TYPE_SMALL_FLAME: + this->actor.draw = EnWizFire_DrawSmallFlame; + this->smallFlameScroll = Rand_S16Offset(0, 10000); + this->action = EN_WIZ_FIRE_ACTION_SMALL_FLAME; this->collider.info.toucher.damage = 2; - this->actionFunc = func_80A49F38; + this->actionFunc = EnWiz_SetupSmallFlame; + break; + + default: + break; } } -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]; + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + 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) { - Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; +void EnWiz_SetupMoveMagicProjectile(EnWizFire* this, PlayState* play) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; s32 i; - for (i = 0; i < ARRAY_COUNT(this->unk_178); i++) { - this->unk_178[i] = this->actor.world.pos; + for (i = 0; i < ARRAY_COUNT(this->magicProjectilePos); i++) { + this->magicProjectilePos[i] = this->actor.world.pos; } - this->unk_16E = 0; + this->lowestUsedIndex = 0; + 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; + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + velocity.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; } else { - sp44.z = 12.0f; + velocity.z = 12.0f; } - Matrix_MultVec3f(&sp44, &this->actor.velocity); + Matrix_MultVec3f(&velocity, &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) { + this->timer = 50; + + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { this->actor.velocity.y = 10.0f; this->actor.gravity = -1.0f; - this->unk_150 = 0.01f; + this->targetScale = 0.01f; } else { - this->unk_150 = 0.02f; - this->unk_168 = 100; + this->targetScale = 0.02f; + this->timer = 100; } - this->unk_160 = 0; - this->actionFunc = func_80A49A44; + + this->action = EN_WIZ_FIRE_ACTION_MOVE_MAGIC_PROJECTILE; + this->actionFunc = EnWiz_MoveMagicProjectile; } -void func_80A49A44(EnWizFire* this, GlobalContext* globalCtx) { - Vec3f sp54 = { 0.0f, 0.0f, 0.0f }; +/** + * Moves all types of magic projectiles around, including arcing ones created by the + * Fire Wizrobe's attack or ones reflected by the Mirror Shield. + */ +void EnWiz_MoveMagicProjectile(EnWizFire* this, PlayState* play) { + Vec3f velocity = { 0.0f, 0.0f, 0.0f }; this->actor.world.rot.z += 5000; - if (this->unk_162 != 0) { - this->unk_150 = 0.01f; + if (this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + this->targetScale = 0.01f; } else { - this->unk_150 = 0.02f; + this->targetScale = 0.02f; } - if ((this->unk_168 == 0) && (this->unk_14C < 0.001f)) { + if ((this->timer == 0) && (this->scale < 0.001f)) { Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_160 = 3; - this->unk_16A = 0; - this->actionFunc = func_80A4A608; + this->action = EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE; + this->increaseLowestUsedIndexTimer = 0; + this->actionFunc = EnWiz_KillMagicProjectile; return; } - if (this->unk_168 == 0) { - this->unk_150 = 0.0f; + if (this->timer == 0) { + this->targetScale = 0.0f; } - Math_ApproachF(&this->unk_14C, this->unk_150, 0.2f, 0.01f); + Math_ApproachF(&this->scale, this->targetScale, 0.2f, 0.01f); - if (this->unk_172 == 0) { - if ((this->actor.bgCheckFlags & 8) && (this->unk_162 == 0) && (this->unk_168 != 0) && + if (this->wallCheckTimer == 0) { + if ((this->actor.bgCheckFlags & 8) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->timer != 0) && (this->actor.bgCheckFlags & 8)) { - D_80A4C1C0 = 0; - this->unk_168 = 0; - this->unk_150 = 0.0f; + sPoolHitByIceArrow = false; + this->timer = 0; + this->targetScale = 0.0f; } } - if ((this->actor.bgCheckFlags & 1) && (this->unk_16A == 0)) { + if ((this->actor.bgCheckFlags & 1) && (this->poolTimer == 0)) { s32 i; - s16 phi_s0; - s32 temp; + s16 arcingProjectileRotY; + s32 pad; - if (this->unk_162 == 1) { - this->unk_16A = 10; + if (this->type == EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE) { + this->increaseLowestUsedIndexTimer = 10; Matrix_Push(); Matrix_RotateYS((s16)randPlusMinusPoint5Scaled(0x100) + this->actor.world.rot.y, MTXMODE_NEW); - sp54.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; - Matrix_MultVec3f(&sp54, &this->actor.velocity); + velocity.z = randPlusMinusPoint5Scaled(2.0f) + 8.0f; + Matrix_MultVec3f(&velocity, &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, - this->actor.world.pos.y - 10.0f, this->actor.world.pos.z, 0, 0, 0, 2); - this->unk_164 = 1; + if (!this->hasSpawnedSmallFlame) { + 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, + EN_WIZ_FIRE_TYPE_SMALL_FLAME); + this->hasSpawnedSmallFlame = true; } - this->unk_168 = 0; - this->unk_14C = 0.0f; + this->timer = 0; + this->scale = 0.0f; Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_160 = 3; - this->unk_16A = 0; - this->actionFunc = func_80A4A608; + this->action = EN_WIZ_FIRE_ACTION_KILL_MAGIC_PROJECTILE; + this->increaseLowestUsedIndexTimer = 0; + this->actionFunc = EnWiz_KillMagicProjectile; return; } - if ((this->unk_162 == 0) && (this->unk_168 != 0)) { + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->timer != 0)) { if (this->actor.floorBgId == BGCHECK_SCENE) { - this->unk_16A = 100; - if (this->unk_166 == 0) { - phi_s0 = 0; + this->poolTimer = 100; + if (!this->isIceType) { + arcingProjectileRotY = 0; for (i = 0; i < 5; i++) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, phi_s0, 0, 1); - phi_s0 += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_WIZ_FIRE, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, arcingProjectileRotY, 0, + EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE); + arcingProjectileRotY += BINANG_ADD((s32)randPlusMinusPoint5Scaled(0x1000), 0x3333); } Actor_PlaySfxAtPos(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - this->unk_16A = Rand_S16Offset(70, 30); - if (this->unk_16A != 0) { + this->poolTimer = Rand_S16Offset(70, 30); + if (this->poolTimer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_EXP - SFX_FLAG); } - } else if (this->unk_16A != 0) { + } else if (this->poolTimer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); } + Math_Vec3f_Copy(&this->actor.velocity, &gZeroVec3f); - this->unk_168 = 0; - this->unk_160 = 2; - this->unk_14C = 0.0f; - this->actionFunc = func_80A4A11C; + this->timer = 0; + this->action = EN_WIZ_FIRE_ACTION_POOL; + this->scale = 0.0f; + this->actionFunc = EnWiz_Pool; } + return; } } - if ((this->unk_162 != 3) && (this->unk_168 != 0)) { + if ((this->type != EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE) && (this->timer != 0)) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { - this->unk_168 = 0; - this->unk_148 = 1; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + this->timer = 0; + this->hitByIceArrow = true; + 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; this->collider.info.toucher.dmgFlags = 0x20; this->collider.info.toucher.damage = 2; - this->unk_168 = 100; - this->unk_162 = 3; + this->timer = 100; + this->type = EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE; this->actor.velocity.x *= -1.0f; this->actor.velocity.y *= -0.5f; this->actor.velocity.z *= -1.0f; if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL)) { - ((EnWiz*)this->actor.parent)->unk_3BA = 0; + ((EnWiz*)this->actor.parent)->hasActiveProjectile = false; } } } } -void func_80A49F38(EnWizFire* this, GlobalContext* globalCtx) { - this->unk_150 = 0.02f; - this->unk_168 = Rand_S16Offset(50, 50); - this->unk_154 = randPlusMinusPoint5Scaled(1.0f) * 0.007f; - this->unk_158 = randPlusMinusPoint5Scaled(1.0f) * 0.005f; - this->unk_15C = randPlusMinusPoint5Scaled(1.0f) * 0.007f; - this->actionFunc = func_80A49FD8; +void EnWiz_SetupSmallFlame(EnWizFire* this, PlayState* play) { + this->targetScale = 0.02f; + this->timer = Rand_S16Offset(50, 50); + this->scaleMod.x = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->scaleMod.y = randPlusMinusPoint5Scaled(1.0f) * 0.005f; + this->scaleMod.z = randPlusMinusPoint5Scaled(1.0f) * 0.007f; + this->actionFunc = EnWiz_SmallFlame; } -void func_80A49FD8(EnWizFire* this, GlobalContext* globalCtx) { - if (this->unk_168 > 10) { - Math_ApproachF(&this->unk_14C, this->unk_150, 0.3f, 0.01f); +/** + * Manages the small flame that is created when the arcing projectiles from the Fire Wizrobe's + * attack hit the floor. + */ +void EnWiz_SmallFlame(EnWizFire* this, PlayState* play) { + if (this->timer > 10) { + Math_ApproachF(&this->scale, this->targetScale, 0.3f, 0.01f); } else { - Math_ApproachF(&this->unk_14C, 2.0f * this->unk_150, 0.2f, 0.002f); - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 35.0f); - if ((this->unk_168 == 0) && (this->unk_1FC < 2.0f)) { - Actor_MarkForDeath(&this->actor); + Math_ApproachF(&this->scale, 2.0f * this->targetScale, 0.2f, 0.002f); + Math_ApproachZeroF(&this->alpha, 1.0f, 35.0f); + if ((this->timer == 0) && (this->alpha < 2.0f)) { + Actor_Kill(&this->actor); } return; } if (this->collider.base.acFlags & AC_HIT) { - if (this->unk_168 != 0) { + if (this->timer != 0) { this->collider.base.acFlags &= ~AC_HIT; - if (this->unk_168 > 10) { - this->unk_168 -= 10; + if (this->timer > 10) { + this->timer -= 10; } if (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000) { - this->unk_168 = 0; - this->unk_148 = 1; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + this->timer = 0; + this->hitByIceArrow = true; + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } } - if (this->unk_168 != 0) { + if (this->timer != 0) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_BURN_OUT - SFX_FLAG); } } -void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx) { +/** + * Manages the pool of fire or ice that is created when a magic projectile hits the floor. + */ +void EnWiz_Pool(EnWizFire* this, PlayState* play) { s32 pad; if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL) && (this->actor.parent->colChkInfo.health == 0)) { - this->unk_16A = 0; - this->unk_174 = 1; + this->poolTimer = 0; + this->playerHitByIceProjectile = true; } - this->unk_16E++; + this->lowestUsedIndex++; - if (this->unk_16E > 10) { - this->unk_16E = 10; + if (this->lowestUsedIndex > 10) { + this->lowestUsedIndex = 10; } - if (this->unk_16A != 0) { - Math_ApproachF(&this->unk_200, 60.0f, 0.5f, 10.0f); - if (this->unk_166 == 1) { - Vec3f sp40 = { 0.0f, 0.0f, 0.0f }; - Vec3f sp34; + if (this->poolTimer != 0) { + Math_ApproachF(&this->blendScale, 60.0f, 0.5f, 10.0f); + if (this->isIceType == true) { + Vec3f accel = { 0.0f, 0.0f, 0.0f }; + Vec3f pos; - sp40.x = randPlusMinusPoint5Scaled(3.0f) / 10.0f; - sp40.y = 0.23f; - sp40.z = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + accel.x = randPlusMinusPoint5Scaled(3.0f) / 10.0f; + accel.y = 0.23f; + accel.z = randPlusMinusPoint5Scaled(3.0f) / 10.0f; - Math_Vec3f_Copy(&sp34, &this->actor.world.pos); - sp34.x += randPlusMinusPoint5Scaled(150.0f); - sp34.z += randPlusMinusPoint5Scaled(150.0f); + Math_Vec3f_Copy(&pos, &this->actor.world.pos); + pos.x += randPlusMinusPoint5Scaled(150.0f); + pos.z += randPlusMinusPoint5Scaled(150.0f); - Math_ApproachF(&this->unk_1F0, 0.022f, 0.3f, 0.01f); - this->collider.dim.radius = this->unk_1F0 * 4300.0f; + Math_ApproachF(&this->poolScale, 0.022f, 0.3f, 0.01f); + this->collider.dim.radius = this->poolScale * 4300.0f; this->collider.dim.height = 30; this->collider.dim.yShift = 15; - func_80A4BC74(this, &sp34, &sp40); + EnWizFire_InitializeEffect(this, &pos, &accel); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); return; } - Math_ApproachF(&this->unk_1F0, 0.02f, 0.3f, 0.002f); - Math_ApproachF(&this->unk_1F8, 0.02f, 0.3f, 0.002f); - Math_ApproachF(&this->unk_1F4, 0.02f, 0.3f, 0.2f); - this->collider.dim.radius = this->unk_1F0 * 4000.0f; - this->collider.dim.height = this->unk_1F4 * 1850.0f; + Math_ApproachF(&this->poolScale, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->fireSmokeScale, 0.02f, 0.3f, 0.002f); + Math_ApproachF(&this->bigFlameScale, 0.02f, 0.3f, 0.2f); + this->collider.dim.radius = this->poolScale * 4000.0f; + this->collider.dim.height = this->bigFlameScale * 1850.0f; this->collider.dim.yShift = -15; if (this->collider.dim.height < 2) { @@ -378,359 +409,358 @@ void func_80A4A11C(EnWizFire* this, GlobalContext* globalCtx) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - if ((D_80A4C1C0 == 0) && (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000)) { - D_80A4C1C0 = 1; - this->unk_148 = 1; - this->unk_16A = 0; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); + if (!sPoolHitByIceArrow && (this->collider.info.acHitInfo->toucher.dmgFlags == 0x1000)) { + sPoolHitByIceArrow = true; + this->hitByIceArrow = true; + this->poolTimer = 0; + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 50, NA_SE_EV_ICE_MELT); } } + this->actor.world.pos.y = this->actor.floorHeight + 10.0f; Actor_SetFocus(&this->actor, 0.0f); return; } - Math_ApproachZeroF(&this->unk_200, 0.2f, 3.0f); + Math_ApproachZeroF(&this->blendScale, 0.2f, 3.0f); - if (this->unk_166 == 1) { - Math_ApproachZeroF(&this->unk_1F0, 0.046f, 0.001f); + if (this->isIceType == true) { + Math_ApproachZeroF(&this->poolScale, 0.046f, 0.001f); Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); - if (this->unk_164 == 0) { - if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->unk_1F0 < 0.05f)) { + if (!this->shouldPoolFadeOut) { + if ((this->actor.parent != NULL) && (this->actor.parent->id == ACTOR_EN_WIZ) && (this->poolScale < 0.05f)) { EnWiz* wiz = (EnWiz*)this->actor.parent; this->collider.dim.yShift = -15; - this->unk_164 = 1; - wiz->unk_3BA = 0; + this->shouldPoolFadeOut = true; + wiz->hasActiveProjectile = false; } } - if ((this->unk_164 != 0) && (this->unk_1F0 < 0.05f)) { - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 5.0f); + if (this->shouldPoolFadeOut && (this->poolScale < 0.05f)) { + Math_ApproachZeroF(&this->alpha, 1.0f, 5.0f); } - if ((this->unk_1F0 < 0.001f) && (this->unk_204 < 0.001f)) { - D_80A4C1C0 = 0; - Actor_MarkForDeath(&this->actor); + if ((this->poolScale < 0.001f) && (this->blendScaleFrac < 0.001f)) { + sPoolHitByIceArrow = false; + Actor_Kill(&this->actor); } + return; } - Math_ApproachZeroF(&this->unk_1F4, 0.1f, 0.01f); + Math_ApproachZeroF(&this->bigFlameScale, 0.1f, 0.01f); - if (this->unk_1F4 < 0.01f) { - Math_ApproachZeroF(&this->unk_1FC, 1.0f, 10.0f); - if ((this->unk_1FC < 10.0f) && (this->unk_204 < 0.001f)) { - D_80A4C1C0 = 0; - if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ) && - (this->actor.parent->update != NULL)) { + if (this->bigFlameScale < 0.01f) { + Math_ApproachZeroF(&this->alpha, 1.0f, 10.0f); + if ((this->alpha < 10.0f) && (this->blendScaleFrac < 0.001f)) { + sPoolHitByIceArrow = false; + if ((this->actor.parent != NULL) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && + (this->actor.parent->id == ACTOR_EN_WIZ) && (this->actor.parent->update != NULL)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - wiz->unk_3BA = 0; + wiz->hasActiveProjectile = false; } - Actor_MarkForDeath(&this->actor); + + Actor_Kill(&this->actor); } } } -void func_80A4A608(EnWizFire* this, GlobalContext* globalCtx) { - if (this->unk_16A == 0) { - this->unk_16A = 2; - this->unk_16E++; - if (this->unk_16E >= 6) { - if ((this->actor.parent != NULL) && (this->unk_162 == 0) && (this->actor.parent->id == ACTOR_EN_WIZ)) { +void EnWiz_KillMagicProjectile(EnWizFire* this, PlayState* play) { + if (this->increaseLowestUsedIndexTimer == 0) { + this->increaseLowestUsedIndexTimer = 2; + this->lowestUsedIndex++; + if (this->lowestUsedIndex >= 6) { + if ((this->actor.parent != NULL) && (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && + (this->actor.parent->id == ACTOR_EN_WIZ)) { EnWiz* wiz = (EnWiz*)this->actor.parent; - D_80A4C1C0 = 0; + sPoolHitByIceArrow = false; if (wiz->actor.update != NULL) { - wiz->unk_3BA = 0; + wiz->hasActiveProjectile = false; } } - Actor_MarkForDeath(&this->actor); + + Actor_Kill(&this->actor); } } } -void EnWizFire_Update(Actor* thisx, GlobalContext* globalCtx2) { - static Color_RGB8 D_80A4C234[] = { - { 100, 40, 40 }, { 180, 0x78, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, - { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, +void EnWizFire_Update(Actor* thisx, PlayState* play2) { + // These are AmbientColor, DiffuseColor1, DiffuseColor2, and fogColor + static Color_RGB8 lightSettingsColors[] = { + { 100, 40, 40 }, { 180, 120, 80 }, { 155, 80, 80 }, { 125, 20, 0 }, // Fire + { 0, 0, 0 }, { 200, 250, 250 }, { 100, 250, 250 }, { 225, 255, 235 }, // Ice }; - 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; + s16 randomScale; + s16 index; - Actor_SetScale(&this->actor, this->unk_14C); - func_80A4BDDC(this, globalCtx); - this->unk_204 = this->unk_200 / 60.0f; + Actor_SetScale(&this->actor, this->scale); + EnWizFire_UpdateEffects(this, play); + this->blendScaleFrac = this->blendScale / 60.0f; - if (this->unk_162 == 0) { + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { Actor* wiz = this->actor.parent; - if ((wiz != NULL) && (wiz->id == ACTOR_EN_WIZ) && (wiz->update != NULL) && (((EnWiz*)wiz)->unk_74A != 2)) { - f32 phi_f0; + if ((wiz != NULL) && (wiz->id == ACTOR_EN_WIZ) && (wiz->update != NULL) && + (((EnWiz*)wiz)->type != EN_WIZ_TYPE_FIRE_NO_BGM)) { + f32 fogNear; - idx = this->unk_166 * 4; - - phi_f0 = 970.0f; - if (this->unk_166 == 0) { - phi_f0 = 968.0f; + index = this->isIceType * 4; + fogNear = 970.0f; + if (!this->isIceType) { + fogNear = 968.0f; } - globalCtx->envCtx.lightSettings.fogNear = (phi_f0 - (s16)globalCtx->envCtx.unk_C4.fogNear) * this->unk_204; + play->envCtx.lightSettings.fogNear = (fogNear - (s16)play->envCtx.unk_C4.fogNear) * this->blendScaleFrac; - 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)lightSettingsColors[index].r - play->envCtx.unk_C4.ambientColor[0]) * this->blendScaleFrac; + play->envCtx.lightSettings.ambientColor[1] = + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.ambientColor[1]) * this->blendScaleFrac; + play->envCtx.lightSettings.ambientColor[2] = + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.ambientColor[2]) * this->blendScaleFrac; - 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; + index++; + play->envCtx.lightSettings.diffuseColor1[0] = + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.diffuseColor1[0]) * this->blendScaleFrac; + play->envCtx.lightSettings.diffuseColor1[1] = + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.diffuseColor1[1]) * this->blendScaleFrac; + play->envCtx.lightSettings.diffuseColor1[2] = + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.diffuseColor1[2]) * this->blendScaleFrac; - 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; + index++; + play->envCtx.lightSettings.diffuseColor2[0] = + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.diffuseColor[0]) * this->blendScaleFrac; + play->envCtx.lightSettings.diffuseColor2[1] = + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.diffuseColor[1]) * this->blendScaleFrac; + play->envCtx.lightSettings.diffuseColor2[2] = + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.diffuseColor[2]) * this->blendScaleFrac; - 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; + index++; + play->envCtx.lightSettings.fogColor[0] = + ((f32)lightSettingsColors[index].r - play->envCtx.unk_C4.fogColor[0]) * this->blendScaleFrac; + play->envCtx.lightSettings.fogColor[1] = + ((f32)lightSettingsColors[index].g - play->envCtx.unk_C4.fogColor[1]) * this->blendScaleFrac; + play->envCtx.lightSettings.fogColor[2] = + ((f32)lightSettingsColors[index].b - play->envCtx.unk_C4.fogColor[2]) * this->blendScaleFrac; } } - this->unk_170++; + this->smallFlameScroll++; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); this->actor.shape.yOffset = 10.0f; Actor_UpdatePos(&this->actor); - this->unk_178[0] = this->actor.world.pos; + this->magicProjectilePos[0] = this->actor.world.pos; - for (j = 8; j >= 0; j--) { - this->unk_178[j + 1] = this->unk_178[j]; + for (j = ARRAY_COUNT(this->magicProjectilePos) - 2; j >= 0; j--) { + this->magicProjectilePos[j + 1] = this->magicProjectilePos[j]; } this->actor.velocity.y += this->actor.gravity; - if (this->unk_172 != 0) { - this->unk_172--; - } + DECR(this->wallCheckTimer); + DECR(this->timer); + DECR(this->steamSpawnTimer); + DECR(this->poolTimer); - if (this->unk_168 != 0) { - this->unk_168--; - } + Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 5.0f, 10, 0x1D); - if (this->unk_16C != 0) { - this->unk_16C--; - } - - if (this->unk_16A != 0) { - this->unk_16A--; - } - - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 5.0f, 10, 0x1D); - - if (((this->unk_148 != 0) || (D_80A4C1C0 != 0)) && (this->unk_16C == 0)) { - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - f32 sp54; + if ((this->hitByIceArrow || sPoolHitByIceArrow) && (this->steamSpawnTimer == 0)) { + Vec3f accel; + Vec3f velocity; + Vec3f pos; + f32 scaleStep; s32 i; - sp70.x = 0.0f; - sp70.y = 1.0f; - sp70.z = 0.0f; - sp64.x = 0.0f; - sp64.y = 1.0f; - sp64.z = 0.0f; + accel.x = 0.0f; + accel.y = 1.0f; + accel.z = 0.0f; + velocity.x = 0.0f; + velocity.y = 1.0f; + velocity.z = 0.0f; - sp54 = Rand_S16Offset(20, 10); - if (this->unk_162 == 0) { - sp54 = Rand_S16Offset(40, 20); + scaleStep = Rand_S16Offset(20, 10); + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { + scaleStep = Rand_S16Offset(40, 20); } - this->unk_16C = Rand_S16Offset(2, 2); + this->steamSpawnTimer = Rand_S16Offset(2, 2); for (i = 0; i < 2; i++) { - temp_s0 = Rand_S16Offset(20, 20); - sp58.x = ((f32)((Rand_ZeroOne() < 0.5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.x; - sp58.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; - temp_s0 = Rand_S16Offset(20, 20); - sp58.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * temp_s0) + this->actor.world.pos.z; - func_800B0DE0(globalCtx, &sp58, &sp64, &sp70, &D_80A4C24C, &D_80A4C250, Rand_S16Offset(350, 100), sp54); + static Color_RGBA8 sSteamPrimColor = { 250, 250, 250, 255 }; + static Color_RGBA8 sSteamEnvColor = { 180, 180, 180, 255 }; + + randomScale = Rand_S16Offset(20, 20); + pos.x = ((f32)((Rand_ZeroOne() < 0.5f) ? -1 : 1) * randomScale) + this->actor.world.pos.x; + pos.y = (Rand_ZeroOne() * 20.0f) + this->actor.floorHeight; + randomScale = Rand_S16Offset(20, 20); + pos.z = ((f32)((Rand_ZeroOne() < .5f) ? -1 : 1) * randomScale) + this->actor.world.pos.z; + func_800B0DE0(play, &pos, &velocity, &accel, &sSteamPrimColor, &sSteamEnvColor, Rand_S16Offset(350, 100), + scaleStep); } } - if (this->unk_160 < 2) { - this->collider.dim.radius = (this->unk_14C * 15.0f) + 25.0f; - this->collider.dim.height = (this->unk_14C * 15.0f) + 25.0f; - this->collider.dim.yShift = (this->unk_14C * -0.75f) - 5.0f; + if (this->action < EN_WIZ_FIRE_ACTION_POOL) { + this->collider.dim.radius = (this->scale * 15.0f) + 25.0f; + this->collider.dim.height = (this->scale * 15.0f) + 25.0f; + this->collider.dim.yShift = (this->scale * -0.75f) - 5.0f; } - if (this->unk_162 == 2) { + if (this->type == EN_WIZ_FIRE_TYPE_SMALL_FLAME) { this->collider.dim.radius = 10; - this->collider.dim.height = this->unk_14C * 5000.0f; + this->collider.dim.height = this->scale * 5000.0f; this->collider.dim.yShift = 0; } if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; - if (this->unk_162 == 0) { + if (this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_WIZ_LAUGH2); if (player->invincibilityTimer > 0) { player->invincibilityTimer += 40; - if (this->unk_166 != 0) { + if (this->isIceType) { player->invincibilityTimer += 50; - this->unk_174 = 1; + this->playerHitByIceProjectile = true; } } } } - if ((player->stateFlags2 & 0x4000) && (player->unk_AE8 < 90)) { + if ((player->stateFlags2 & PLAYER_STATE2_4000) && (player->unk_AE8 < 90)) { player->unk_AE8 = 90; } - if ((this->unk_148 == 0) && (D_80A4C1C0 == 0) && ((this->unk_162 != 0) || (this->unk_1FC > 200.0f))) { + if (!this->hitByIceArrow && !sPoolHitByIceArrow && + ((this->type != EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) || (this->alpha > 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 EnWizFire_DrawIcePool(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); + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->action == EN_WIZ_FIRE_ACTION_POOL)) { + 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); + Matrix_Scale(this->poolScale, this->poolScale, this->poolScale, 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); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 0, 40, 30, 80); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005190); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->unk_1FC); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIcePoolDL); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 215, 215, 215, (s8)this->alpha); 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, 32, + 64, 1, play->state.frames & 0xFF, play->state.frames & 0xFF, 16, 16)); Matrix_RotateYS(0, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_005750); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIcePoolShineDL); } - func_80A4BF78(this, globalCtx); + EnWizFire_DrawEffects(this, play); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A4B33C(EnWizFire* this, GlobalContext* globalCtx2) { - GlobalContext* globalCtx = globalCtx2; +void EnWizFire_DrawFirePoolAndFlame(EnWizFire* this, PlayState* play2) { + PlayState* play = play2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + + if ((this->type == EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE) && (this->action == EN_WIZ_FIRE_ACTION_POOL)) { + func_8012C28C(play->state.gfxCtx); + func_8012C2DC(play->state.gfxCtx); - if ((this->unk_162 == 0) && (this->unk_160 == 2)) { - func_8012C28C(globalCtx->state.gfxCtx); - func_8012C2DC(globalCtx->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); + Matrix_Scale(this->poolScale, this->poolScale, this->poolScale, 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); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 100, 40, 0, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 255, 245, 255, 128); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003120); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeFirePoolDL); Matrix_Pop(); + Matrix_Push(); Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 80, 0, 0, (s8)this->unk_1FC); + 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->alpha); 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); + Matrix_Scale(this->fireSmokeScale, this->fireSmokeScale, this->fireSmokeScale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003640); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeFireSmokeDL); Matrix_Pop(); + Matrix_Translate(this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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); + Matrix_Scale(this->bigFlameScale, this->bigFlameScale, this->bigFlameScale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_003FC0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeBigFlameDL); } - 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); + 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); + for (i = ARRAY_COUNT(this->magicProjectilePos) - 1; i >= this->lowestUsedIndex; i--) { + f32 scale = this->actor.scale.x - (i * -0.0019f); - if (temp_f20 > 0.0f) { - if (this->unk_166 == 0) { + if (scale > 0.0f) { + if (!this->isIceType) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255 - (i * 25), 0, 255 - (i * 25)); gDPSetEnvColor(POLY_XLU_DISP++, 255 - (i * 25), 0, 0, 0); } else { @@ -738,136 +768,135 @@ void EnWizFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { gDPSetEnvColor(POLY_XLU_DISP++, 220, 255, 235, 0); } - 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_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_Translate(this->magicProjectilePos[i].x, this->magicProjectilePos[i].y + this->actor.shape.yOffset, + this->magicProjectilePos[i].z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, 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); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002B40); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeMagicProjectileDL); } } Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - if (this->unk_166 == 0) { - func_80A4B33C(this, globalCtx); + if (!this->isIceType) { + EnWizFire_DrawFirePoolAndFlame(this, play); } else { - func_80A4B0C8(this, globalCtx); + EnWizFire_DrawIcePool(this, play); } } -void func_80A4BAB4(Actor* thisx, GlobalContext* globalCtx) { +void EnWizFire_DrawSmallFlame(Actor* thisx, PlayState* play) { s32 pad; EnWizFire* this = THIS; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); 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, + Matrix_Scale(this->scale + this->scaleMod.x, this->scale + this->scaleMod.y, this->scale + this->scaleMod.z, MTXMODE_APPLY); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x20, 1, this->unk_170 & 0x7F, - (-this->unk_170 * 10) & 0x7F, 0x20, 0x20)); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->unk_1FC); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, this->smallFlameScroll & 0x7F, + (-this->smallFlameScroll * 10) & 0x7F, 32, 32)); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 100, 50, 0, (s8)this->alpha); gDPSetEnvColor(POLY_XLU_DISP++, 200, 235, 245, 255); - Matrix_Mult(&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); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_002630); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeSmallFlameDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80A4BC74(EnWizFire* this, Vec3f* arg1, Vec3f* arg2) { +void EnWizFire_InitializeEffect(EnWizFire* this, Vec3f* pos, Vec3f* accel) { s16 i; - EnWizFireStruct* ptr = this->unk_254; + EnWizFireEffect* effect = &this->effects[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { - if (ptr->unk_00 == 0) { - ptr->unk_00 = 1; - Math_Vec3f_Copy(&ptr->unk_1C, &gZeroVec3f); - ptr->unk_01 = Rand_ZeroFloat(100.0f); - ptr->unk_10 = *arg1; - ptr->unk_28 = *arg2; - ptr->unk_0C = (Rand_ZeroFloat(5.0f) + 20.0f) * 0.001f; - ptr->unk_08 = 0; - ptr->unk_06 = 0; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (!effect->isEnabled) { + effect->isEnabled = true; + Math_Vec3f_Copy(&effect->velocity, &gZeroVec3f); + effect->smokeScroll = Rand_ZeroFloat(100.0f); + effect->pos = *pos; + effect->accel = *accel; + effect->scale = (Rand_ZeroFloat(5.0f) + 20.0f) * 0.001f; + effect->shouldDecreaseAlpha = 0; + effect->alpha = 0; break; } } } -void func_80A4BDDC(EnWizFire* this, GlobalContext* globalCtx) { +void EnWizFire_UpdateEffects(EnWizFire* this, PlayState* play) { s32 i; - EnWizFireStruct* ptr = &this->unk_254[0]; + EnWizFireEffect* effect = &this->effects[0]; - for (i = 0; i < ARRAY_COUNT(this->unk_254); i++, ptr++) { - if (ptr->unk_00 != 0) { - ptr->unk_01++; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + effect->smokeScroll++; - ptr->unk_10.x += ptr->unk_1C.x; - ptr->unk_10.y += ptr->unk_1C.y; - ptr->unk_10.z += ptr->unk_1C.z; + effect->pos.x += effect->velocity.x; + effect->pos.y += effect->velocity.y; + effect->pos.z += effect->velocity.z; - ptr->unk_1C.x += ptr->unk_28.x; - ptr->unk_1C.y += ptr->unk_28.y; - ptr->unk_1C.z += ptr->unk_28.z; + effect->velocity.x += effect->accel.x; + effect->velocity.y += effect->accel.y; + effect->velocity.z += effect->accel.z; - if (ptr->unk_08 == 0) { - ptr->unk_06 += 10; - if (ptr->unk_06 >= 100) { - ptr->unk_08 = 1; + if (!effect->shouldDecreaseAlpha) { + effect->alpha += 10; + if (effect->alpha >= 100) { + effect->shouldDecreaseAlpha = true; } } else { - ptr->unk_06 -= 8; - if (ptr->unk_06 <= 0) { - ptr->unk_06 = 0; - ptr->unk_00 = 0; + effect->alpha -= 8; + if (effect->alpha <= 0) { + effect->alpha = 0; + effect->isEnabled = false; } } } } } -void func_80A4BF78(EnWizFire* this, GlobalContext* globalCtx) { +void EnWizFire_DrawEffects(EnWizFire* this, PlayState* play) { s16 i; - u8 flag; - EnWizFireStruct* ptr = &this->unk_254[0]; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + u8 materialFlag; + EnWizFireEffect* effect = &this->effects[0]; + 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++) { - if (ptr->unk_00 != 0) { - if (!flag) { - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000E70); - flag++; + materialFlag = false; + for (i = 0; i < ARRAY_COUNT(this->effects); i++, effect++) { + if (effect->isEnabled) { + if (!materialFlag) { + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIceSmokeMaterialDL); + materialFlag++; } - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, ptr->unk_06); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 195, 225, 235, effect->alpha); 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, (effect->smokeScroll * 3) & 0x7F, + (effect->smokeScroll * 0xF) & 0xFF, 32, 64, 1, 0, 0, 32, 32)); - Matrix_Translate(ptr->unk_10.x, ptr->unk_10.y, ptr->unk_10.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - Matrix_Scale(ptr->unk_0C, ptr->unk_0C, 1.0f, MTXMODE_APPLY); + 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); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BACK | G_FOG); - gSPDisplayList(POLY_XLU_DISP++, object_wiz_DL_000FD8); + gSPDisplayList(POLY_XLU_DISP++, gWizrobeIceSmokeModelDL); } } 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..90bf472dc 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 @@ -3,54 +3,65 @@ #include "global.h" +typedef enum { + /* 0 */ EN_WIZ_FIRE_TYPE_MAGIC_PROJECTILE, + /* 1 */ EN_WIZ_FIRE_TYPE_ARCING_MAGIC_PROJECTILE, + /* 2 */ EN_WIZ_FIRE_TYPE_SMALL_FLAME, + /* 3 */ EN_WIZ_FIRE_TYPE_REFLECTED_MAGIC_PROJECTILE, + /* 4 */ EN_WIZ_FIRE_TYPE_ICE_MAGIC_PROJECTILE +} EnWizFireType; + +#define EN_WIZ_FIRE_GET_TYPE(thisx) ((thisx)->params) + struct EnWizFire; -typedef void (*EnWizFireActionFunc)(struct EnWizFire*, GlobalContext*); +typedef void (*EnWizFireActionFunc)(struct EnWizFire*, PlayState*); typedef struct { - /* 0x00 */ u8 unk_00; - /* 0x01 */ u8 unk_01; + /* 0x00 */ u8 isEnabled; + /* 0x01 */ u8 smokeScroll; /* 0x02 */ UNK_TYPE1 unk02[0x4]; - /* 0x06 */ s16 unk_06; - /* 0x08 */ s16 unk_08; - /* 0x0A */ UNK_TYPE1 unk0A[0x2]; - /* 0x0C */ f32 unk_0C; - /* 0x10 */ Vec3f unk_10; - /* 0x1C */ Vec3f unk_1C; - /* 0x28 */ Vec3f unk_28; -} EnWizFireStruct; // size = 0x34 + /* 0x06 */ s16 alpha; + /* 0x08 */ s16 shouldDecreaseAlpha; + /* 0x0C */ f32 scale; + /* 0x10 */ Vec3f pos; + /* 0x1C */ Vec3f velocity; + /* 0x28 */ Vec3f accel; +} EnWizFireEffect; // size = 0x34 typedef struct EnWizFire { /* 0x0000 */ Actor actor; /* 0x0144 */ EnWizFireActionFunc actionFunc; - /* 0x0148 */ u8 unk_148; - /* 0x014C */ f32 unk_14C; - /* 0x0150 */ f32 unk_150; - /* 0x0154 */ f32 unk_154; - /* 0x0158 */ f32 unk_158; - /* 0x015C */ f32 unk_15C; - /* 0x0160 */ s16 unk_160; - /* 0x0162 */ s16 unk_162; - /* 0x0164 */ u8 unk_164; - /* 0x0166 */ s16 unk_166; - /* 0x0168 */ s16 unk_168; - /* 0x016A */ s16 unk_16A; - /* 0x016C */ s16 unk_16C; - /* 0x016E */ s16 unk_16E; - /* 0x0170 */ s16 unk_170; - /* 0x0172 */ s16 unk_172; - /* 0x0174 */ s8 unk_174; - /* 0x0178 */ Vec3f unk_178[10]; - /* 0x01F0 */ f32 unk_1F0; - /* 0x01F4 */ f32 unk_1F4; - /* 0x01F8 */ f32 unk_1F8; - /* 0x01FC */ f32 unk_1FC; - /* 0x0200 */ f32 unk_200; - /* 0x0204 */ f32 unk_204; + /* 0x0148 */ u8 hitByIceArrow; + /* 0x014C */ f32 scale; + /* 0x0150 */ f32 targetScale; + /* 0x0154 */ Vec3f scaleMod; + /* 0x0160 */ s16 action; + /* 0x0162 */ s16 type; + /* 0x0164 */ union { + u8 shouldPoolFadeOut; + u8 hasSpawnedSmallFlame; + }; + /* 0x0166 */ s16 isIceType; + /* 0x0168 */ s16 timer; + /* 0x016A */ union { + s16 poolTimer; + s16 increaseLowestUsedIndexTimer; + }; + /* 0x016C */ s16 steamSpawnTimer; + /* 0x016E */ s16 lowestUsedIndex; + /* 0x0170 */ s16 smallFlameScroll; + /* 0x0172 */ s16 wallCheckTimer; // The projectile won't check for impacts with walls until this is zero + /* 0x0174 */ s8 playerHitByIceProjectile; // Set, but never used + /* 0x0178 */ Vec3f magicProjectilePos[10]; + /* 0x01F0 */ f32 poolScale; + /* 0x01F4 */ f32 bigFlameScale; + /* 0x01F8 */ f32 fireSmokeScale; + /* 0x01FC */ f32 alpha; + /* 0x0200 */ f32 blendScale; + /* 0x0204 */ f32 blendScaleFrac; /* 0x0208 */ ColliderCylinder collider; - /* 0x0254 */ EnWizFireStruct unk_254[200]; + /* 0x0254 */ EnWizFireEffect effects[200]; } EnWizFire; // size = 0x2AF4 -extern const ActorInit En_Wiz_Fire_InitVars; - #endif // Z_EN_WIZ_FIRE_H diff --git a/src/overlays/actors/ovl_En_Wood02/overlay.cfg b/src/overlays/actors/ovl_En_Wood02/overlay.cfg deleted file mode 100644 index 52dbc67e4..000000000 --- a/src/overlays/actors/ovl_En_Wood02/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Wood02 -z_en_wood02.c 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..ba63b3021 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* play2); +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 @@ -38,7 +38,7 @@ typedef enum { static f32 sSpawnCos; static f32 sSpawnSin; -const ActorInit En_Wood02_InitVars = { +ActorInit En_Wood02_InitVars = { ACTOR_EN_WOOD02, ACTORCAT_PROP, FLAGS, @@ -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,12 +307,12 @@ 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; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } @@ -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,14 +357,14 @@ 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; // Despawn extra trees in a group if out of range if ((this->spawnType == WOOD_SPAWN_SPAWNED) && (thisx->parent != NULL)) { - if (!(thisx->flags & 0x40) && (this->unk_151 != 2)) { + if (!(thisx->flags & ACTOR_FLAG_40) && (this->unk_151 != 2)) { s32 index = this->unk_14A[0]; s32 phi_v0 = 0; @@ -375,12 +374,12 @@ void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { ((EnWood02*)thisx->parent)->unk_14A[index] = phi_v0; - Actor_MarkForDeath(thisx); + Actor_Kill(thisx); return; } 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); } @@ -450,7 +449,7 @@ void EnWood02_Update(Actor* thisx, GlobalContext* globalCtx2) { thisx->shape.rot.z = Math_SinS(this->unk_146 * 0xBB8) * 16384.0f; this->unk_14A[0]--; if (this->unk_14A[0] == 0) { - Actor_MarkForDeath(thisx); + Actor_Kill(thisx); } } @@ -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_Wood02/z_en_wood02.h b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h index 310d1e5de..128607414 100644 --- a/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h +++ b/src/overlays/actors/ovl_En_Wood02/z_en_wood02.h @@ -50,6 +50,4 @@ typedef enum { /* 0x1A */ WOOD_TREE_SPECIAL = 0x1A } WoodType; -extern const ActorInit En_Wood02_InitVars; - #endif // Z_EN_WOOD02_H diff --git a/src/overlays/actors/ovl_En_Yb/overlay.cfg b/src/overlays/actors/ovl_En_Yb/overlay.cfg deleted file mode 100644 index 5293ea603..000000000 --- a/src/overlays/actors/ovl_En_Yb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Yb -z_en_yb.c 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 b23282c31..2310a2eef 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -11,28 +11,28 @@ #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 = { +ActorInit En_Yb_InitVars = { ACTOR_EN_YB, ACTORCAT_NPC, FLAGS, @@ -68,7 +68,7 @@ static ColliderCylinderInit sCylinderInit = { // assumption: draw uses two different skeleton functions, might be incompatible static AnimationHeader* gYbUnusedAnimations[] = { &object_yb_Anim_000200 }; -static LinkAnimationHeader* gLinkAnimations[] = { &gameplay_keep_Linkanim_00DF28, &gameplay_keep_Linkanim_00CF98 }; +static LinkAnimationHeader* gLinkAnimations[] = { &gPlayerAnim_link_normal_wait_free, &gPlayerAnim_alink_dance_loop }; static Vec3f D_80BFB2E8 = { 0.0f, 0.5f, 0.0f }; @@ -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; @@ -84,20 +84,20 @@ void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_SetScale(&this->actor, 0.01f); 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); + // @bug this alignment is because of player animations, but should be using ALIGN16 + 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++) { @@ -120,40 +120,39 @@ void EnYb_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.flags &= ~ACTOR_FLAG_1; } - // check if already healed - if (gSaveContext.save.weekEventReg[82] & 4) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_82_04)) { + Actor_Kill(&this->actor); } } -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 +160,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 +187,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 +203,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,84 +232,84 @@ 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 { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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_IA_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_IA_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)) { - 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; + SET_WEEKEVENTREG(WEEKEVENTREG_82_04); 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 +317,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_IA_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,41 +340,41 @@ 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_IA_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) { - if (!(player->stateFlags2 & 0x8000000)) { + if (!(player->stateFlags2 & PLAYER_STATE2_8000000)) { this->playerOcarinaOut &= ~1; } - } else if ((player->stateFlags2 & 0x8000000) && this->actor.xzDistToPlayer < 180.0f && + } else if ((player->stateFlags2 & PLAYER_STATE2_8000000) && this->actor.xzDistToPlayer < 180.0f && fabsf(this->actor.playerHeightRel) < 50.0f) { this->playerOcarinaOut |= 1; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); @@ -384,9 +383,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 +396,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,7 +425,7 @@ 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) { @@ -437,7 +436,7 @@ void EnYb_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } -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) { @@ -448,35 +447,35 @@ void EnYb_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, } } -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/overlay.cfg b/src/overlays/actors/ovl_En_Zl1/overlay.cfg deleted file mode 100644 index 188c2f1d5..000000000 --- a/src/overlays/actors/ovl_En_Zl1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zl1 -z_en_zl1.c 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..e77aace23 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.c @@ -10,12 +10,12 @@ #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 = { +ActorInit En_Zl1_InitVars = { ACTOR_EN_ZL1, ACTORCAT_NPC, FLAGS, @@ -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_Zl1/z_en_zl1.h b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.h index e1b118191..4138558fb 100644 --- a/src/overlays/actors/ovl_En_Zl1/z_en_zl1.h +++ b/src/overlays/actors/ovl_En_Zl1/z_en_zl1.h @@ -10,6 +10,4 @@ typedef struct EnZl1 { /* 0x144 */ char unk_144[0xC0]; } EnZl1; // size = 0x204 -extern const ActorInit En_Zl1_InitVars; - #endif // Z_EN_ZL1_H diff --git a/src/overlays/actors/ovl_En_Zl4/overlay.cfg b/src/overlays/actors/ovl_En_Zl4/overlay.cfg deleted file mode 100644 index 91cec5610..000000000 --- a/src/overlays/actors/ovl_En_Zl4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zl4 -z_en_zl4.c 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..3dffe0a6f 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.c @@ -10,15 +10,15 @@ #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 = { +ActorInit En_Zl4_InitVars = { ACTOR_EN_ZL4, ACTORCAT_ITEMACTION, FLAGS, 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..326d2545e 100644 --- a/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h +++ b/src/overlays/actors/ovl_En_Zl4/z_en_zl4.h @@ -5,15 +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; - #endif // Z_EN_ZL4_H diff --git a/src/overlays/actors/ovl_En_Zo/overlay.cfg b/src/overlays/actors/ovl_En_Zo/overlay.cfg deleted file mode 100644 index eeedbff83..000000000 --- a/src/overlays/actors/ovl_En_Zo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zo -z_en_zo.c 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 2c5f76f2e..a16b828f9 100644 --- a/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -5,22 +5,21 @@ */ #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 = { +ActorInit En_Zo_InitVars = { ACTOR_EN_ZO, ACTORCAT_NPC, FLAGS, @@ -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 }, @@ -103,24 +102,24 @@ s8 sBodyParts[] = { -1, 1, 12, 13, 14, 9, 10, 11, 0, 6, 7, 8, 3, 4, 5, 2, -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,35 +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 TurnOptionsSet sTurnOptions = { +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(globalCtx); + Player* player = GET_PLAYER(play); Vec3f point; SkelAnime_Update(&this->skelAnime); if (SubS_AngleDiffLessEqual(this->actor.shape.rot.y, 0x2710, this->actor.yawTowardsPlayer)) { point.x = player->actor.world.pos.x; - point.y = player->bodyPartsPos[7].y + 3.0f; + point.y = player->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; point.z = player->actor.world.pos.z; - SubS_TurnToPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->turnTarget, &this->headRot, - &this->upperBodyRot, &sTurnOptions); + SubS_TrackPoint(&point, &this->actor.focus.pos, &this->actor.shape.rot, &this->trackTarget, &this->headRot, + &this->upperBodyRot, &sTrackOptions); } else { - Math_SmoothStepToS(&this->turnTarget.x, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->turnTarget.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); @@ -202,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; @@ -231,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)) { @@ -249,68 +248,69 @@ 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) { + 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) { + 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 }; @@ -318,13 +318,13 @@ void EnZo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (sBodyParts[limbIndex] >= 0) { Matrix_MultVec3f(&zeroVec, &this->bodyPartsPos[sBodyParts[limbIndex]]); } - if (limbIndex == 15) { + if (limbIndex == ZORA_LIMB_HEAD) { Matrix_MultVec3f(&sp30, &this->actor.focus.pos); } - if (limbIndex == 4) { + if (limbIndex == ZORA_LIMB_LEFT_FOOT) { Matrix_MultVec3f(&zeroVec, &this->leftFootPos); } - if (limbIndex == 7) { + if (limbIndex == ZORA_LIMB_RIGHT_FOOT) { Matrix_MultVec3f(&zeroVec, &this->rightFootPos); } } @@ -338,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, SUBS_SHADOW_TEX_SIZE); + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, SUBS_SHADOW_TEX_SIZE); u8* shadowTexIter; 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); @@ -355,7 +355,7 @@ 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_RotateXS(0, MTXMODE_NEW); @@ -368,6 +368,6 @@ void EnZo_Draw(Actor* thisx, GlobalContext* globalCtx) { ARRAY_COUNT(this->bodyPartsPos), sShadowSizes, sParentBodyParts); } - SubS_DrawShadowTex(&this->actor, &globalCtx->state, 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 b5faef776..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 turnTarget; - /* 0x02F4 */ Vec3s headRot; - /* 0x02FA */ Vec3s upperBodyRot; - /* 0x0300 */ UNK_TYPE1 unk_300[0x12]; - /* 0x0312 */ s16 limbRotY[20]; - /* 0x033A */ s16 limbRotZ[20]; - /* 0x0364 */ Vec3f bodyPartsPos[15]; - /* 0x041A */ UNK_TYPE1 unk_41A[0x6]; - /* 0x041E */ s16 eyeIndex; - /* 0x0420 */ s16 blinkTimer; + /* 0x000 */ Actor actor; + /* 0x144 */ EnZoActionFunc actionFunc; + /* 0x148 */ SkelAnime skelAnime; + /* 0x194 */ ColliderCylinder collider; + /* 0x1D8 */ UNK_TYPE1 unk_1D8[0x4]; + /* 0x1DC */ Path* path; + /* 0x1E0 */ s16 waypoint; + /* 0x1E4 */ Vec3f leftFootPos; + /* 0x1F0 */ Vec3f rightFootPos; + /* 0x1FC */ u8 isLeftFootGrounded; + /* 0x1FD */ u8 isRightFootGrounded; + /* 0x1FE */ Vec3s jointTable[ZORA_LIMB_MAX]; + /* 0x276 */ Vec3s morphTable[ZORA_LIMB_MAX]; + /* 0x2EE */ Vec3s trackTarget; + /* 0x2F4 */ Vec3s headRot; + /* 0x2FA */ Vec3s upperBodyRot; + /* 0x300 */ UNK_TYPE1 unk_300[0x12]; + /* 0x312 */ s16 limbRotY[20]; + /* 0x33A */ s16 limbRotZ[20]; + /* 0x364 */ Vec3f bodyPartsPos[15]; + /* 0x41A */ UNK_TYPE1 unk_41A[0x6]; + /* 0x41E */ s16 eyeIndex; + /* 0x420 */ s16 blinkTimer; } EnZo; // size = 0x424 #endif // Z_EN_ZO_H diff --git a/src/overlays/actors/ovl_En_Zob/overlay.cfg b/src/overlays/actors/ovl_En_Zob/overlay.cfg deleted file mode 100644 index e8a11666f..000000000 --- a/src/overlays/actors/ovl_En_Zob/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zob -z_en_zob.c 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 24b03ab5f..58dd246d8 100644 --- a/src/overlays/actors/ovl_En_Zob/z_en_zob.c +++ b/src/overlays/actors/ovl_En_Zob/z_en_zob.c @@ -11,33 +11,33 @@ #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 = { +ActorInit En_Zob_InitVars = { ACTOR_EN_ZOB, ACTORCAT_NPC, FLAGS, @@ -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; @@ -114,14 +114,14 @@ void EnZob_Init(Actor* thisx, GlobalContext* globalCtx) { switch (ENZOB_GET_F(&this->actor)) { case ENZOB_F_1: - if (gSaveContext.save.weekEventReg[78] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_01)) { this->actionFunc = func_80BA0BB4; } else { this->actionFunc = func_80BA0AD8; } - if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&this->actor); return; } break; @@ -130,23 +130,23 @@ 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; default: - if (gSaveContext.save.weekEventReg[55] & 0x80) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; break; } } -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,51 +205,51 @@ 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; if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { - if (gSaveContext.save.weekEventReg[30] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_30_02)) { textId = 0x11F9; } else { 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); - } else if (gSaveContext.save.weekEventReg[31] & 8) { + func_80B9F7E4(this, 5, ANIMMODE_ONCE); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_31_08)) { 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); - } else if (gSaveContext.save.weekEventReg[30] & 8) { + func_80B9F7E4(this, 2, ANIMMODE_ONCE); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_30_08)) { textId = 0x11FA; this->unk_304 = 1; - func_80B9F7E4(this, 2, 2); - } else if (!(gSaveContext.save.weekEventReg[30] & 4)) { - gSaveContext.save.weekEventReg[30] |= 4; + func_80B9F7E4(this, 2, ANIMMODE_ONCE); + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_30_04)) { + SET_WEEKEVENTREG(WEEKEVENTREG_30_04); 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; + SET_WEEKEVENTREG(WEEKEVENTREG_31_08); 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); + SET_WEEKEVENTREG(WEEKEVENTREG_30_02); + 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,19 +513,19 @@ 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; + player->stateFlags3 |= PLAYER_STATE3_20; break; } } @@ -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); - gSaveContext.save.weekEventReg[30] |= 8; + Message_StartTextbox(play, 0x1208, NULL); + SET_WEEKEVENTREG(WEEKEVENTREG_30_08); } 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_01)) { textId = 0x1257; this->unk_304 = 3; - func_80B9F7E4(this, 4, 2); - } else if (gSaveContext.save.weekEventReg[78] & 0x40) { + func_80B9F7E4(this, 4, ANIMMODE_ONCE); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_40)) { 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; + SET_WEEKEVENTREG(WEEKEVENTREG_78_40); 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_01)) { 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,7 +746,7 @@ 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) { @@ -753,23 +754,23 @@ void func_80BA0FAC(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -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..25ce14fdc 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,23 +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; - #endif // Z_EN_ZOB_H diff --git a/src/overlays/actors/ovl_En_Zod/overlay.cfg b/src/overlays/actors/ovl_En_Zod/overlay.cfg deleted file mode 100644 index 8acdefc35..000000000 --- a/src/overlays/actors/ovl_En_Zod/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zod -z_en_zod.c 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..9c7e7e6b5 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.c +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.c @@ -10,12 +10,41 @@ #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); + +void EnZod_ChangeAnim(EnZod* this, s16 nextAnimIndex, u8 mode); +void EnZod_PlayDrumsSequence(EnZod* this, PlayState* play); +void func_80BAFB84(EnZod* this, PlayState* play); +void func_80BAFDB4(EnZod* this, PlayState* play); +void func_80BAFF14(EnZod* this, PlayState* play); + +#define TIJO_STATE_1 (1 << 0) +#define TIJO_STATE_2 (1 << 1) + +typedef enum { + /* 0 */ ENZOD_ANIM_PLAYING_VIVACE, + /* 1 */ ENZOD_ANIM_READY_TO_PLAY, + /* 2 */ ENZOD_ANIM_ARMS_FOLDED, + /* 3 */ ENZOD_ANIM_PLAYING_LENTO, + /* 4 */ ENZOD_ANIM_PLAYING_ANDANTINO, + /* 5 */ ENZOD_ANIM_MAX, +} EnZodAnimation; + +typedef enum { + /* 1 */ ENZOD_INSTRUMENT_CYMBAL_1 = 1, + /* 2 */ ENZOD_INSTRUMENT_CYMBAL_2, + /* 3 */ ENZOD_INSTRUMENT_CYMBAL_3, + /* 4 */ ENZOD_INSTRUMENT_DRUM_1, + /* 5 */ ENZOD_INSTRUMENT_DRUM_2, + /* 6 */ ENZOD_INSTRUMENT_DRUM_3, + /* 7 */ ENZOD_INSTRUMENT_DRUM_4, + /* 8 */ ENZOD_INSTRUMENT_DRUM_5, + /* 9 */ ENZOD_INSTRUMENT_BASS_DRUM, +} EnZodInstrument; -#if 0 const ActorInit En_Zod_InitVars = { ACTOR_EN_ZOD, ACTORCAT_NPC, @@ -28,62 +57,596 @@ const ActorInit En_Zod_InitVars = { (ActorFunc)EnZod_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BB0540 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 60, 40, 0, { 0, 0, 0 } }, }; -#endif +static AnimationHeader* sAnimations[] = { + &gTijoPlayingVivaceAnim, &gTijoReadyToPlayAnim, &gTijoArmsFoldedAnim, + &gTijoPlayingLentoAnim, &gTijoPlayingAndantinoAnim, +}; -extern ColliderCylinderInit D_80BB0540; +static Vec3f D_80BB0580 = { 1300.0f, 1100.0f, 0.0f }; -extern UNK_TYPE D_06000D94; -extern UNK_TYPE D_06007650; +void EnZod_Init(Actor* thisx, PlayState* play) { + s32 i; + EnZod* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/EnZod_Init.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 60.0f); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitFlex(play, &this->skelAnime, &gTijoSkel, &gTijoPlayingLentoAnim, this->morphTable, this->jointTable, + TIJO_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gTijoPlayingLentoAnim); + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/EnZod_Destroy.s") + this->cymbalRots[0] = this->cymbalRots[1] = this->cymbalRots[2] = 0; + this->actor.gravity = this->actor.terminalVelocity = -4.0f; + this->cymbalRotVels[0] = this->cymbalRotVels[1] = this->cymbalRotVels[2] = 300; + this->stateFlags = 0; + this->nextAnimIndex = -1; + this->curAnimIndex = -1; + this->actor.textId = 0; + this->unk_298 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAF1EC.s") + for (i = 0; i < ARRAY_COUNT(this->drumScales); i++) { + this->drumScales[i] = 0.0f; + this->drumScaleVels[i] = 0.01; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAF2B4.s") + EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_LENTO, ANIMMODE_ONCE); + this->actionFunc = EnZod_PlayDrumsSequence; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAF338.s") + switch (ENZOD_GET_TYPE(thisx)) { + case ENZOD_TYPE_1: + if (gSaveContext.save.weekEventReg[78] & 1) { + this->actionFunc = func_80BAFDB4; + EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_VIVACE, ANIMMODE_ONCE); + this->actor.flags |= ACTOR_FLAG_10; + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAF3E0.s") + this->actionFunc = func_80BAFB84; + if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { + Actor_Kill(&this->actor); + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAF4D8.s") + case ENZOD_TYPE_2: + this->actionFunc = func_80BAFF14; + this->fogNear = -1; + this->stateFlags |= TIJO_STATE_2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAF7CC.s") + default: + if (gSaveContext.save.weekEventReg[55] & 0x80) { + Actor_Kill(&this->actor); + } + this->actor.flags |= ACTOR_FLAG_10; + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAF99C.s") +void EnZod_Destroy(Actor* thisx, PlayState* play) { + EnZod* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFA44.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFADC.s") +void EnZod_HandleRoomConversation(EnZod* this, PlayState* play) { + u16 textId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFB84.s") + if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { + textId = 0x1227; + if (gSaveContext.save.weekEventReg[32] & 8) { + textId = 0x1229; + } else { + gSaveContext.save.weekEventReg[32] |= 8; + } + } else if (this->stateFlags & TIJO_STATE_1) { + textId = 0x1225; + } else { + textId = 0x1219; + if (gSaveContext.save.weekEventReg[32] & 0x10) { + textId = 0x1226; + } else { + gSaveContext.save.weekEventReg[32] |= 0x10; + } + this->stateFlags |= TIJO_STATE_1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFC00.s") + EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_VIVACE, ANIMMODE_ONCE); + Message_StartTextbox(play, textId, &this->actor); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFC10.s") +s32 EnZod_PlayerIsFacingTijo(EnZod* this, PlayState* play) { + if ((this->actor.playerHeightRel < 30.0f) && (this->actor.xzDistToPlayer < 200.0f) && + Player_IsFacingActor(&this->actor, 0x3000, play) && Actor_IsFacingPlayer(&this->actor, 0x3000)) { + return true; + } else { + return false; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFD00.s") +void EnZod_ChangeAnim(EnZod* this, s16 nextAnimIndex, u8 mode) { + if ((nextAnimIndex < ENZOD_ANIM_PLAYING_VIVACE) || (nextAnimIndex >= ENZOD_ANIM_MAX)) { + nextAnimIndex = ENZOD_ANIM_PLAYING_LENTO; + } + Animation_Change(&this->skelAnime, sAnimations[nextAnimIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[nextAnimIndex]), mode, -5.0f); + this->curAnimIndex = nextAnimIndex; + this->nextAnimIndex = nextAnimIndex; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFDB4.s") +void EnZod_UpdateAnimation(EnZod* this) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->nextAnimIndex == this->curAnimIndex) { + EnZod_ChangeAnim(this, this->curAnimIndex, ANIMMODE_ONCE); + switch (this->curAnimIndex) { + case ENZOD_ANIM_PLAYING_LENTO: + if (Rand_ZeroFloat(1.0f) < 0.2f) { + this->nextAnimIndex = ENZOD_ANIM_PLAYING_ANDANTINO; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFE34.s") + case ENZOD_ANIM_PLAYING_ANDANTINO: + if (Rand_ZeroFloat(1.0f) < 0.8f) { + this->nextAnimIndex = ENZOD_ANIM_PLAYING_LENTO; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BAFF14.s") + } else { + EnZod_ChangeAnim(this, this->nextAnimIndex, ANIMMODE_ONCE); + } + SkelAnime_Update(&this->skelAnime); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/EnZod_Update.s") +void EnZod_UpdateInstruments(EnZod* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BB0128.s") + for (i = 0; i < ARRAY_COUNT(this->cymbalRots); i++) { + this->cymbalRots[i] += this->cymbalRotVels[i]; + this->cymbalRotVels[i] -= (s16)(this->cymbalRots[i] * 0.1f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BB0170.s") + if (ABS_ALT(this->cymbalRotVels[i]) > 100) { + this->cymbalRotVels[i] *= 0.9f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/func_80BB01B0.s") + switch (i) { + case 0: + if ((this->curAnimIndex == ENZOD_ANIM_PLAYING_ANDANTINO) && ((s32)this->skelAnime.curFrame == 7)) { + this->cymbalRotVels[i] = -1000; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Zod/EnZod_Draw.s") + case 1: + if ((this->curAnimIndex == ENZOD_ANIM_PLAYING_ANDANTINO) && ((s32)this->skelAnime.curFrame == 19)) { + this->cymbalRotVels[i] = -1000; + } + break; + + default: + break; + } + } + + for (i = 0; i < ARRAY_COUNT(this->drumScales); i++) { + this->drumScales[i] += this->drumScaleVels[i]; + this->drumScaleVels[i] -= (this->drumScales[i] * 0.8f); + + if (fabsf(this->drumScaleVels[i]) > 0.01f) { + this->drumScaleVels[i] *= 0.5f; + } + + switch (i) { + case 0: + if (((this->curAnimIndex == ENZOD_ANIM_PLAYING_LENTO) || + (this->curAnimIndex == ENZOD_ANIM_PLAYING_ANDANTINO)) && + ((s32)this->skelAnime.curFrame == 1)) { + this->drumScaleVels[i] = 0.1f; + } + break; + + case 2: + if (((this->curAnimIndex == ENZOD_ANIM_PLAYING_LENTO) && ((s32)this->skelAnime.curFrame == 19)) || + ((this->curAnimIndex == ENZOD_ANIM_PLAYING_ANDANTINO) && ((s32)this->skelAnime.curFrame == 8))) { + this->drumScaleVels[i] = 0.1f; + } + break; + + case 3: + switch (this->curAnimIndex) { + case 3: + switch ((s32)this->skelAnime.curFrame) { + case 1: + case 7: + case 12: + case 19: + this->drumScaleVels[i] = 0.03f; + break; + } + break; + + case 4: + if ((s32)this->skelAnime.curFrame == 1) { + this->drumScaleVels[i] = 0.1f; + } + break; + } + break; + + case 4: + if ((this->curAnimIndex == ENZOD_ANIM_PLAYING_ANDANTINO) && ((s32)this->skelAnime.curFrame == 19)) { + this->drumScaleVels[i] = 0.15f; + } + + break; + + default: + break; + } + } +} + +void func_80BAF7CC(EnZod* this, PlayState* play) { + EnZod_UpdateAnimation(this); + switch (Message_GetState(&play->msgCtx)) { + case TEXT_STATE_CHOICE: + if (Message_ShouldAdvance(play) && (play->msgCtx.currentTextId == 0x121F)) { + switch (play->msgCtx.choiceIndex) { + case 0: + func_8019F208(); + func_80151938(play, 0x1220); + break; + + case 1: + func_8019F230(); + func_80151938(play, 0x1223); + break; + } + } + break; + + case TEXT_STATE_5: + if (Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x121A: + case 0x121B: + case 0x121C: + case 0x1220: + case 0x1221: + case 0x1227: + func_80151938(play, play->msgCtx.currentTextId + 1); + break; + + case 0x1219: + func_80151938(play, play->msgCtx.currentTextId + 1); + this->nextAnimIndex = ENZOD_ANIM_ARMS_FOLDED; + break; + + case 0x121D: + func_80151938(play, play->msgCtx.currentTextId + 1); + this->nextAnimIndex = ENZOD_ANIM_READY_TO_PLAY; + break; + + case 0x1223: + func_80151938(play, play->msgCtx.currentTextId + 1); + this->nextAnimIndex = ENZOD_ANIM_PLAYING_VIVACE; + break; + + case 0x121E: + case 0x1226: + func_80151938(play, 0x121F); + this->nextAnimIndex = ENZOD_ANIM_READY_TO_PLAY; + break; + + default: + func_801477B4(play); + this->actionFunc = EnZod_PlayDrumsSequence; + EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_LENTO, ANIMMODE_ONCE); + break; + } + } + } +} + +void EnZod_PlayDrumsSequence(EnZod* this, PlayState* play) { + s32 pad; + Vec3f seqPos; + + EnZod_UpdateAnimation(this); + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + EnZod_HandleRoomConversation(this, play); + this->actionFunc = func_80BAF7CC; + } else if (EnZod_PlayerIsFacingTijo(this, play)) { + func_800B8614(&this->actor, play, 210.0f); + } + + seqPos.x = this->actor.projectedPos.x; + seqPos.y = this->actor.projectedPos.y; + seqPos.z = this->actor.projectedPos.z; + + func_801A1FB4(3, &seqPos, NA_BGM_DRUMS_PLAY, 700.0f); +} + +void func_80BAFA44(EnZod* this, PlayState* play) { + u16 textId; + + if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { + if (gSaveContext.save.weekEventReg[79] & 1) { + textId = 0x1253; + } else { + textId = 0x1251; + if (gSaveContext.save.weekEventReg[78] & 0x20) { + textId = 0x1252; + } else { + gSaveContext.save.weekEventReg[78] |= 0x20; + } + } + } else { + textId = 0x1250; + } + + EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_VIVACE, ANIMMODE_ONCE); + Message_StartTextbox(play, textId, &this->actor); +} + +void func_80BAFADC(EnZod* this, PlayState* play) { + u8 talkState; + + EnZod_UpdateAnimation(this); + talkState = Message_GetState(&play->msgCtx); + if (talkState != TEXT_STATE_CLOSING) { + if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = func_80BAFB84; + EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_LENTO, ANIMMODE_ONCE); + } + } else { + this->actionFunc = func_80BAFB84; + EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_LENTO, ANIMMODE_ONCE); + } +} + +void func_80BAFB84(EnZod* this, PlayState* play) { + EnZod_UpdateAnimation(this); + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + func_80BAFA44(this, play); + this->actionFunc = func_80BAFADC; + } else if (EnZod_PlayerIsFacingTijo(this, play)) { + func_800B8614(&this->actor, play, 210.0f); + } +} + +void EnZod_DoNothing(EnZod* this, PlayState* play) { +} + +void EnZod_Rehearse(EnZod* this, PlayState* play) { + EnZod_UpdateAnimation(this); + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + if (this->actor.cutscene == -1) { + this->actionFunc = EnZod_DoNothing; + play->nextEntrance = play->setupExitList[ENZOD_GET_ENTRANCE_INDEX(&this->actor)]; + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; + gSaveContext.save.weekEventReg[78] &= (u8)~1; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void EnZod_SetupRehearse(EnZod* this, PlayState* play) { + EnZod_UpdateAnimation(this); + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + EnZod_ChangeAnim(this, ENZOD_ANIM_PLAYING_LENTO, ANIMMODE_ONCE); + this->actionFunc = EnZod_Rehearse; + ActorCutscene_Stop(this->actor.cutscene); + this->actor.cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + gSaveContext.save.weekEventReg[79] |= 1; + Audio_QueueSeqCmd(NA_BGM_INDIGO_GO_SESSION | 0x8000); + } +} + +void func_80BAFDB4(EnZod* this, PlayState* play) { + EnZod_UpdateAnimation(this); + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + func_800B7298(play, NULL, 0x44); + Message_StartTextbox(play, 0x103A, &this->actor); + this->actionFunc = EnZod_SetupRehearse; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} + +void func_80BAFE34(EnZod* this, PlayState* play) { + EnZod_UpdateAnimation(this); + if (this->fogNear < 799) { + this->fogNear += 200; + } else { + this->fogNear += 30; + } + + if (this->fogNear > 999) { + this->fogNear = 999; + } + + if (Cutscene_CheckActorAction(play, 0x203)) { + if (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x203)]->action == 1) { + this->actionFunc = func_80BAFF14; + this->fogNear = -1; + } + } else { + this->actionFunc = func_80BAFF14; + this->fogNear = -1; + } +} + +void func_80BAFF14(EnZod* this, PlayState* play) { + EnZod_UpdateAnimation(this); + if (Cutscene_CheckActorAction(play, 0x203) && + (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x203)]->action == 4)) { + this->actionFunc = func_80BAFE34; + } +} + +void EnZod_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnZod* this = THIS; + Vec3s torsoRot; + + Actor_MoveWithGravity(&this->actor); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 10.0f, 10.0f, 4); + this->actionFunc(this, play); + EnZod_UpdateInstruments(this); + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + + this->eyeIndex = this->blinkTimer; + + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; + } + + torsoRot.z = 0; + torsoRot.y = 0; + torsoRot.x = 0; + + if (EnZod_PlayerIsFacingTijo(this, play)) { + Actor_TrackPlayer(play, &this->actor, &this->headRot, &torsoRot, this->actor.focus.pos); + if (this->headRot.x > 0xBB8) { + this->headRot.x = 0xBB8; + } else if (this->headRot.x < -0xBB8) { + this->headRot.x = -0xBB8; + } + } else { + Math_SmoothStepToS(&this->headRot.x, 0, 6, 0x1838, 0x64); + Math_SmoothStepToS(&this->headRot.y, 0, 6, 0x1838, 0x64); + } +} + +s32 EnZod_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnZod* this = THIS; + + if (limbIndex == TIJO_LIMB_HEAD) { + rot->x += this->headRot.y; + rot->z += this->headRot.x; + } + + return false; +} + +void EnZod_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + if (limbIndex == TIJO_LIMB_HEAD) { + Matrix_MultVec3f(&D_80BB0580, &thisx->focus.pos); + } +} + +void EnZod_DrawDrums(EnZod* this, PlayState* play) { + static Gfx* sTijoDrumsDLs[] = { + gTijoDrumFrameDL, gTijoRideCymbalDL, gTijoCrashCymbalDL, gTijoHiHatDL, gTijoDrum1DL, + gTijoDrum2DL, gTijoDrum3DL, gTijoDrum4DL, gTijoDrum5DL, gTijoBassDrumDL, + }; + s32 i; + f32 instrumentPosXs[] = { 0.0f, -2690.0f, 2310.0f, 3888.0f, -4160.0f, -2200.0f, -463.0f, 1397.0f, 3413.0f, 389.0f }; + f32 instrumentPosYs[] = { 0.0f, 6335.0f, 6703.0f, 5735.0f, 3098.0f, 3349.0f, 3748.0f, 3718.0f, 2980.0f, 1530.0f }; + f32 instrumentPosZs[] = { 0.0f, 4350.0f, 3200.0f, 1555.0f, 2874.0f, 3901.0f, 4722.0f, 4344.0f, 3200.0f, 3373.0f }; + f32 scale; + + OPEN_DISPS(play->state.gfxCtx); + + for (i = 0; i < ARRAY_COUNT(sTijoDrumsDLs); i++) { + Matrix_Push(); + Matrix_Translate(instrumentPosXs[i], instrumentPosYs[i], instrumentPosZs[i], MTXMODE_APPLY); + + switch (i) { + case ENZOD_INSTRUMENT_CYMBAL_1: + case ENZOD_INSTRUMENT_CYMBAL_2: + case ENZOD_INSTRUMENT_CYMBAL_3: + Matrix_RotateXS(this->cymbalRots[i - 1], MTXMODE_APPLY); + break; + + case ENZOD_INSTRUMENT_DRUM_1: + case ENZOD_INSTRUMENT_DRUM_2: + case ENZOD_INSTRUMENT_DRUM_3: + case ENZOD_INSTRUMENT_DRUM_4: + case ENZOD_INSTRUMENT_DRUM_5: + case ENZOD_INSTRUMENT_BASS_DRUM: + scale = this->drumScales[9 - i] + 1.0f; + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + break; + + default: + break; + } + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, sTijoDrumsDLs[i]); + Matrix_Pop(); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EnZod_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sTijoEyesTextures[] = { &gTijoEyesOpen, &gTijoEyesHalfOpen, &gTijoEyesClosed }; + EnZod* this = THIS; + Gfx* gfx; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + if (this->stateFlags & TIJO_STATE_2) { + POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 0, 0, 0, 0, this->fogNear, 1000); + } + + gfx = POLY_OPA_DISP; + + gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(sTijoEyesTextures[this->eyeIndex])); + gSPSegment(&gfx[1], 0x09, Lib_SegmentedToVirtual(&gTijoMouthClosedTex)); + + POLY_OPA_DISP = &gfx[2]; + + EnZod_DrawDrums(this, play); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnZod_OverrideLimbDraw, EnZod_PostLimbDraw, &this->actor); + if (this->stateFlags & TIJO_STATE_2) { + POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP); + } + + CLOSE_DISPS(play->state.gfxCtx); +} 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..9e6f3f4da 100644 --- a/src/overlays/actors/ovl_En_Zod/z_en_zod.h +++ b/src/overlays/actors/ovl_En_Zod/z_en_zod.h @@ -2,17 +2,40 @@ #define Z_EN_ZOD_H #include "global.h" +#include "assets/objects/object_zod/object_zod.h" + +#define ENZOD_GET_ENTRANCE_INDEX(thisx) (((thisx)->params & 0xFE00) >> 9) +#define ENZOD_GET_TYPE(thisx) ((thisx)->params & 0xF) 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 */ Vec3s morphTable[TIJO_LIMB_MAX]; + /* 0x180 */ Vec3s jointTable[TIJO_LIMB_MAX]; + /* 0x1BC */ SkelAnime skelAnime; + /* 0x200 */ ColliderCylinder collider; + /* 0x24C */ s16 eyeIndex; + /* 0x24E */ s16 blinkTimer; + /* 0x250 */ Vec3s headRot; + /* 0x256 */ u16 stateFlags; + /* 0x258 */ s16 curAnimIndex; + /* 0x25A */ s16 nextAnimIndex; + /* 0x25C */ s16 cymbalRots[3]; + /* 0x262 */ s16 cymbalRotVels[3]; + /* 0x268 */ f32 drumScales[6]; + /* 0x280 */ f32 drumScaleVels[6]; + /* 0x298 */ s16 unk_298; // Set but not used. + /* 0x29A */ s16 fogNear; + /* 0x29C */ EnZodActionFunc actionFunc; } EnZod; // size = 0x2A0 -extern const ActorInit En_Zod_InitVars; +typedef enum { + /* 1 */ ENZOD_TYPE_1 = 1, + /* 2 */ ENZOD_TYPE_2, + /* 0xF */ ENZOD_TYPE_0xF = 0xF, +} EnZodTypes; #endif // Z_EN_ZOD_H diff --git a/src/overlays/actors/ovl_En_Zog/overlay.cfg b/src/overlays/actors/ovl_En_Zog/overlay.cfg deleted file mode 100644 index fe913a71e..000000000 --- a/src/overlays/actors/ovl_En_Zog/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zog -z_en_zog.c 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 925eaeec0..a165d91fe 100644 --- a/src/overlays/actors/ovl_En_Zog/z_en_zog.c +++ b/src/overlays/actors/ovl_En_Zog/z_en_zog.c @@ -11,29 +11,29 @@ #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; -const ActorInit En_Zog_InitVars = { +ActorInit En_Zog_InitVars = { ACTOR_EN_ZOG, ACTORCAT_NPC, FLAGS, @@ -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,16 +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))) { - Actor_MarkForDeath(&this->actor); + ((play->csCtx.currentCsIndex != 2) || (gSaveContext.sceneLayer != 0) || (play->sceneId != SCENE_30GYOSON))) { + Actor_Kill(&this->actor); return; } @@ -235,7 +234,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,12 +259,12 @@ 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); } } - if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && (gSaveContext.save.weekEventReg[88] & 0x10)) { + if ((ENZOG_GET_F(&this->actor) != ENZOG_F_2) && CHECK_WEEKEVENTREG(WEEKEVENTREG_88_10)) { this->unk_302 = this->unk_300 = 0; this->unk_2FC = this->unk_2FE = 3; this->actor.flags |= ACTOR_FLAG_2000000; @@ -275,7 +274,7 @@ void EnZog_Init(Actor* thisx, GlobalContext* globalCtx) { Animation_PlayLoop(&this->skelAnime, D_80B958DC[0]); this->actor.textId = 0x1009; - if (gSaveContext.save.weekEventReg[91] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_91_02)) { this->actor.textId = 0x103C; this->actionFunc = func_80B9451C; } else { @@ -290,10 +289,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 +301,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 +345,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 +367,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 +379,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 +428,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 +458,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 +477,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 +502,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 +545,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,65 +586,66 @@ 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)) { + if (!(player->stateFlags2 & PLAYER_STATE2_8000000)) { this->unk_30A &= ~0x10; } - } else if ((player->stateFlags2 & 0x8000000) && (this->actor.xzDistToPlayer < 120.0f)) { + } else if ((player->stateFlags2 & PLAYER_STATE2_8000000) && (this->actor.xzDistToPlayer < 120.0f)) { this->unk_30A |= 0x10; Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); } } -void func_80B94470(EnZog* this, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == 5) { - if (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; - gSaveContext.save.weekEventReg[91] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_91_02); } if ((this->unk_304 == 11) && ((s32)this->skelAnime.curFrame >= 55)) { @@ -653,52 +653,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 +709,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,25 +734,25 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_29_20)) { this->actor.textId = 0x1009; } else { this->actor.textId = 0x1008; - gSaveContext.save.weekEventReg[29] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_29_20); } this->unk_300 = 2; this->unk_31C = 2; @@ -766,17 +767,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 +794,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 +813,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 +828,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 +848,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,29 +868,29 @@ 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)); } if ((player->actor.speedXZ > 3.0f) && (this->unk_324 == 0)) { this->unk_324 = 25; - func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_PUSH); + func_800B8E58(player, player->ageProperties->voiceSfxIdOffset + NA_SE_VO_LI_PUSH); } } this->actor.speedXZ *= 0.3f; } if (ABS_ALT(this->actor.yawTowardsPlayer - this->actor.world.rot.y) > 0x5000) { - Actor_PickUp(&this->actor, globalCtx, 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; @@ -904,21 +905,21 @@ void func_80B94E34(EnZog* this, GlobalContext* globalCtx) { this->unk_31C = 1; this->unk_31E = 0; func_80B93BA8(this, 0); - gSaveContext.save.weekEventReg[88] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_88_10); } 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; @@ -938,30 +939,30 @@ void func_80B95128(EnZog* this, GlobalContext* globalCtx) { } this->actor.flags &= ~ACTOR_FLAG_10000; - gSaveContext.save.weekEventReg[91] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_91_01); } 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 +976,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,7 +998,7 @@ 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; @@ -1012,15 +1013,15 @@ void EnZog_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } 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; @@ -1039,21 +1040,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 +1065,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 +1078,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..9971d77fa 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) @@ -40,6 +40,4 @@ typedef struct EnZog { /* 0x328 */ EnZogActionFunc actionFunc; } EnZog; // size = 0x32C -extern const ActorInit En_Zog_InitVars; - #endif // Z_EN_ZOG_H diff --git a/src/overlays/actors/ovl_En_Zoraegg/overlay.cfg b/src/overlays/actors/ovl_En_Zoraegg/overlay.cfg deleted file mode 100644 index f7f5fde0b..000000000 --- a/src/overlays/actors/ovl_En_Zoraegg/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zoraegg -z_en_zoraegg.c 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 b65da70e2..2f6f0e791 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.c @@ -12,33 +12,33 @@ #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 = { +ActorInit En_Zoraegg_InitVars = { ACTOR_EN_ZORAEGG, ACTORCAT_ITEMACTION, FLAGS, @@ -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,92 +96,92 @@ 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))) { - Actor_MarkForDeath(&this->actor); + case ENZORAEGG_1F_00: + if (Flags_GetSwitch(play, ENZORAEGG_GET_FE00(&this->actor))) { + Actor_Kill(&this->actor); return; } break; - case ENZORAEGG_1F_17: - if (func_80B319A8(globalCtx) >= 7) { - Actor_MarkForDeath(&this->actor); + case ENZORAEGG_1F_11: + if (func_80B319A8(play) >= 7) { + Actor_Kill(&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: - if (gSaveContext.save.weekEventReg[19] & 0x40) { - Actor_MarkForDeath(&this->actor); + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_19_40)) { + Actor_Kill(&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); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_19_40)) { + Actor_Kill(&this->actor); return; } break; } 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->sceneId].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->sceneId].unk_14 &= ~7; + gSaveContext.save.permanentSceneFlags[play->sceneId].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)); - Actor_MarkForDeath(&this->actor); - } else if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { +void func_80B320E0(EnZoraegg* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + Flags_SetSwitch(play, ENZORAEGG_GET_FE00(&this->actor)); + Actor_Kill(&this->actor); + } 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); + SET_EVENTINF(EVENTINF_33); + Actor_Kill(&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,35 +466,34 @@ 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; + SET_WEEKEVENTREG(WEEKEVENTREG_19_40); this->unk_1EC = 2; this->unk_1EE = 100; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ZORA_KIDS_SWIM_2); } - Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, - Cutscene_GetActorActionIndex(globalCtx, this->actorActionCmd)); + 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) { - if (gSaveContext.eventInf[3] & 8) { +void func_80B32B10(EnZoraegg* this, PlayState* play) { + if (CHECK_EVENTINF(EVENTINF_33)) { this->actionFunc = func_80B32A88; } } -void func_80B32B3C(EnZoraegg* this, GlobalContext* globalCtx) { - if (gSaveContext.eventInf[3] & 8) { +void func_80B32B3C(EnZoraegg* this, PlayState* play) { + if (CHECK_EVENTINF(EVENTINF_33)) { this->actionFunc = func_80B32A88; this->actor.draw = EnZoraegg_Draw; } } -void func_80B32B70(EnZoraegg* this, GlobalContext* globalCtx) { - func_80B31C40(this, globalCtx); - if (Cutscene_CheckActorAction(globalCtx, 0x1C9)) { - Actor_MarkForDeath(&this->actor); +void func_80B32B70(EnZoraegg* this, PlayState* play) { + func_80B31C40(this, play); + if (Cutscene_CheckActorAction(play, 0x1C9)) { + Actor_Kill(&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)) { - Actor_MarkForDeath(&this->actor); + if (Cutscene_CheckActorAction(play, 0x1C9)) { + Actor_Kill(&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; @@ -684,7 +675,7 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { 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); @@ -696,13 +687,13 @@ void func_80B32F04(Actor* thisx, GlobalContext* globalCtx) { 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), MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gfx = POLY_XLU_DISP; gfx = func_8012C868(gfx); @@ -711,35 +702,35 @@ 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_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_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); @@ -747,13 +738,12 @@ void func_80B331C8(Actor* thisx, GlobalContext* globalCtx) { 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) { +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_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; @@ -799,13 +789,13 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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: @@ -815,7 +805,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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; @@ -827,13 +817,13 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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,13 +831,13 @@ 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_Pop(); break; @@ -855,7 +845,7 @@ void EnZoraegg_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList 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..f36f77c2b 100644 --- a/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h +++ b/src/overlays/actors/ovl_En_Zoraegg/z_en_zoraegg.h @@ -5,60 +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; - #endif // Z_EN_ZORAEGG_H diff --git a/src/overlays/actors/ovl_En_Zos/overlay.cfg b/src/overlays/actors/ovl_En_Zos/overlay.cfg deleted file mode 100644 index a83ca1017..000000000 --- a/src/overlays/actors/ovl_En_Zos/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zos -z_en_zos.c 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 0f299f255..ba37c3ffe 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.c +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.c @@ -5,36 +5,52 @@ */ #include "z_en_zos.h" -#include "objects/object_zos/object_zos.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_2000000) #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 EnZos_ChangeAnim(EnZos* this, s16 animIndex, u8 animMode); +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 = { +typedef enum { + /* 0 */ EN_ZOS_ANIM_LEAN_ON_KEYBOARD, + /* 1 */ EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH, + /* 2 */ EN_ZOS_ANIM_HANDS_ON_HIPS, + /* 3 */ EN_ZOS_ANIM_TALK_FOOT_TAP, + /* 4 */ EN_ZOS_ANIM_TALK_LOOK_DOWN, + /* 5 */ EN_ZOS_ANIM_TALK_ARMS_OUT, + /* 6 */ EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, + /* 7 */ EN_ZOS_ANIM_PLAY_RIGHT, + /* 8 */ EN_ZOS_ANIM_PLAY_LEFT, + /* 9 */ EN_ZOS_ANIM_INSPIRED, + /* 10 */ EN_ZOS_ANIM_SLOW_PLAY, + /* 11 */ EN_ZOS_ANIM_PLAY_RIGHT_SHORTENED, + /* 12 */ EN_ZOS_ANIM_PLAY_LEFT_SHORTENED, + /* 13 */ EN_ZOS_ANIM_MAX +} EnZosAnimation; + +ActorInit En_Zos_InitVars = { ACTOR_EN_ZOS, ACTORCAT_NPC, FLAGS, @@ -66,81 +82,92 @@ 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, - this->morphTable, 18); - Animation_PlayLoop(&this->skelAnime, &object_zos_Anim_00A164); - Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + SkelAnime_InitFlex(play, &this->skelAnime, &gEvanSkel, &gEvanLeanOnKeyboardAnim, this->jointTable, this->morphTable, + EVAN_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gEvanLeanOnKeyboardAnim); + 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, ANIMMODE_ONCE); switch (ENZOS_GET_F(&this->actor)) { case ENZOS_F_1: - if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&this->actor); } - if (gSaveContext.save.weekEventReg[78] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_01)) { this->actionFunc = func_80BBC24C; } else { this->actionFunc = func_80BBC14C; } - func_80BBAE84(this, 0, 2); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, ANIMMODE_ONCE); break; case ENZOS_F_2: this->actionFunc = func_80BBC37C; - func_80BBAE84(this, 7, 2); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_RIGHT, ANIMMODE_ONCE); this->unk_2BC = -1; this->unk_2B6 |= 0x40; break; default: - if (gSaveContext.save.weekEventReg[55] & 0x80) { - Actor_MarkForDeath(&this->actor); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&this->actor); } this->actor.flags |= ACTOR_FLAG_10; break; } } -void EnZos_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnZos_Destroy(Actor* thisx, PlayState* play) { EnZos* this = THIS; - gSaveContext.save.weekEventReg[52] &= (u8)~0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_10); } -void func_80BBAE84(EnZos* this, s16 arg1, u8 arg2) { - static AnimationHeader* sAnimations[] = { - &object_zos_Anim_00A164, &object_zos_Anim_01621C, &object_zos_Anim_016980, &object_zos_Anim_007C40, - &object_zos_Anim_008630, &object_zos_Anim_0090CC, &object_zos_Anim_009830, &object_zos_Anim_005E04, - &object_zos_Anim_007334, &object_zos_Anim_0048D4, &object_zos_Anim_001CFC, &object_zos_Anim_005E04, - &object_zos_Anim_007334, - }; - f32 phi_f0; +static AnimationHeader* sAnimations[] = { + &gEvanLeanOnKeyboardAnim, // EN_ZOS_ANIM_LEAN_ON_KEYBOARD + &gEvanLeanOnKeyboardAndSighAnim, // EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH + &gEvanHandsOnHipsAnim, // EN_ZOS_ANIM_HANDS_ON_HIPS + &gEeanTalkFootTapAnim, // EN_ZOS_ANIM_TALK_FOOT_TAP + &gEvanTalkLookDownAnim, // EN_ZOS_ANIM_TALK_LOOK_DOWN + &gEvanTalkArmsOutAnim, // EN_ZOS_ANIM_TALK_ARMS_OUT + &gEvanTalkHandsOnHipsAnim, // EN_ZOS_ANIM_TALK_HANDS_ON_HIPS + &gEvanPlayRightAnim, // EN_ZOS_ANIM_PLAY_RIGHT + &gEvanPlayLeftAnim, // EN_ZOS_ANIM_PLAY_LEFT + &gEvanInspiredAnim, // EN_ZOS_ANIM_INSPIRED + &gEvanSlowPlayAnim, // EN_ZOS_ANIM_SLOW_PLAY + &gEvanPlayRightAnim, // EN_ZOS_ANIM_PLAY_RIGHT_SHORTENED + &gEvanPlayLeftAnim, // EN_ZOS_ANIM_PLAY_LEFT_SHORTENED +}; - if ((arg1 != this->unk_2B8) && (arg1 >= 0) && (arg1 < 13)) { - if (arg1 > 10) { - phi_f0 = 29.0f; +void EnZos_ChangeAnim(EnZos* this, s16 animIndex, u8 animMode) { + f32 endFrame; + + if ((animIndex != this->animIndex) && (animIndex >= EN_ZOS_ANIM_LEAN_ON_KEYBOARD) && + (animIndex < EN_ZOS_ANIM_MAX)) { + if (animIndex > EN_ZOS_ANIM_SLOW_PLAY) { + endFrame = 29.0f; } else { - phi_f0 = Animation_GetLastFrame(sAnimations[arg1]); + endFrame = Animation_GetLastFrame(sAnimations[animIndex]); } - Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, phi_f0, arg2, -5.0f); - this->unk_2B8 = arg1; + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, endFrame, animMode, -5.0f); + this->animIndex = animIndex; this->unk_2B6 &= ~0x80; } } -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 +176,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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_RIGHT, ANIMMODE_ONCE); break; case 1: - func_80BBAE84(this, 8, 2); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_LEFT, ANIMMODE_ONCE); break; case 2: - func_80BBAE84(this, 11, 2); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_RIGHT_SHORTENED, ANIMMODE_ONCE); break; default: - func_80BBAE84(this, 12, 2); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_LEFT_SHORTENED, ANIMMODE_ONCE); break; } return true; @@ -173,107 +200,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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, ANIMMODE_ONCE); } else { - func_80BBAE84(this, 1, 2); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH, 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 2; } else if (this->unk_2B6 & 4) { textId = 0x123E; - func_80BBAE84(this, 6, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 2; - } else if (gSaveContext.save.weekEventReg[40] & 0x20) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_40_20)) { textId = 0x1236; - func_80BBAE84(this, 6, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } else { textId = 0x1231; - func_80BBAE84(this, 6, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } } else { this->unk_2B6 &= ~2; - if (gSaveContext.save.weekEventReg[39] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_10)) { textId = 0x1243; - func_80BBAE84(this, 6, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 0x80; } else { textId = 0x1244; - gSaveContext.save.weekEventReg[39] |= 0x10; - func_80BBAE84(this, 4, 0); + SET_WEEKEVENTREG(WEEKEVENTREG_39_10); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_LOOK_DOWN, 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_IA_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; + SET_WEEKEVENTREG(WEEKEVENTREG_39_20); 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_IA_MINUS1); } else { - if (gSaveContext.save.weekEventReg[39] & 0x20) { - item = GI_RUPEE_PURPLE; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_20)) { + 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD_AND_SIGH, ANIMMODE_LOOP); break; case 2: - func_80BBAE84(this, 10, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_SLOW_PLAY, 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,83 +315,84 @@ 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; + if (this->animIndex == EN_ZOS_ANIM_INSPIRED) { + 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_SLOW_PLAY, ANIMMODE_LOOP); break; case 0x124D: this->unk_2B6 &= ~0x10; - func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, 0x124E); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, 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) { - s32 sp24; - Player* player = GET_PLAYER(globalCtx); +void func_80BBB718(EnZos* this, PlayState* play) { + PlayerItemAction itemAction; + Player* player = GET_PLAYER(play); SkelAnime_Update(&this->skelAnime); - if (Message_GetState(&globalCtx->msgCtx) == 0x10) { - sp24 = func_80123810(globalCtx); - if (sp24 > 0) { - func_801477B4(globalCtx); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemAction = func_80123810(play); - if (sp24 == 25) { + if (itemAction > PLAYER_IA_NONE) { + func_801477B4(play); + + if (itemAction == PLAYER_IA_BOTTLE_ZORA_EGG) { player->actor.textId = 0x1232; - func_80BBAE84(this, 5, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, ANIMMODE_LOOP); this->unk_2B6 |= 8; - gSaveContext.save.weekEventReg[40] |= 0x20; - } else if (gSaveContext.save.weekEventReg[39] & 8) { + SET_WEEKEVENTREG(WEEKEVENTREG_40_20); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_08)) { player->actor.textId = 0x1241; } else { player->actor.textId = 0x1237; - gSaveContext.save.weekEventReg[39] |= 8; - func_80BBAE84(this, 4, 0); + SET_WEEKEVENTREG(WEEKEVENTREG_39_08); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_LOOK_DOWN, ANIMMODE_LOOP); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; - } else if (sp24 < 0) { - if (gSaveContext.save.weekEventReg[39] & 8) { - func_80151938(globalCtx, 0x1241); + } else if (itemAction <= PLAYER_IA_MINUS1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_08)) { + func_80151938(play, 0x1241); } else { - func_80151938(globalCtx, 0x1237); - gSaveContext.save.weekEventReg[39] |= 8; - func_80BBAE84(this, 4, 0); + func_80151938(play, 0x1237); + SET_WEEKEVENTREG(WEEKEVENTREG_39_08); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_LOOK_DOWN, ANIMMODE_LOOP); this->unk_2B6 |= 4; } this->actionFunc = func_80BBB8AC; @@ -372,9 +400,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 +410,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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_FOOT_TAP, 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 +425,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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1232: @@ -412,30 +440,30 @@ void func_80BBB8AC(EnZos* this, GlobalContext* globalCtx) { case 0x1239: case 0x1246: - func_80BBAE84(this, 6, 0); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); + func_80151938(play, play->msgCtx.currentTextId + 1); break; case 0x1233: - func_80BBAE84(this, 5, 0); - func_80151938(globalCtx, globalCtx->msgCtx.currentTextId + 1); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_FOOT_TAP, 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, ANIMMODE_LOOP); + func_801477B4(play); this->actionFunc = func_80BBBDE0; this->unk_2B6 |= 1; break; @@ -443,23 +471,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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, 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 +495,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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); this->unk_2B6 |= 2; - } else if (gSaveContext.save.weekEventReg[41] & 0x10) { - Message_StartTextbox(globalCtx, 0x124A, &this->actor); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_41_10)) { + Message_StartTextbox(play, 0x124A, &this->actor); this->actionFunc = func_80BBB8AC; - func_80BBAE84(this, 6, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, ANIMMODE_LOOP); } else { - gSaveContext.save.weekEventReg[41] |= 0x10; - Message_StartTextbox(globalCtx, 0x124B, &this->actor); + SET_WEEKEVENTREG(WEEKEVENTREG_41_10); + Message_StartTextbox(play, 0x124B, &this->actor); this->actionFunc = func_80BBB574; - func_80BBAE84(this, 9, 2); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_INSPIRED, 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, 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_IA_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_IA_MINUS1); } } -void func_80BBBDE0(EnZos* this, GlobalContext* globalCtx) { +void func_80BBBDE0(EnZos* this, PlayState* play) { Actor* thisx = &this->actor; Vec3f sp28; @@ -519,34 +547,34 @@ 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, 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)) { - gSaveContext.save.weekEventReg[52] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_52_10); } else { - gSaveContext.save.weekEventReg[52] &= (u8)~0x10; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_10); } sp28.x = this->actor.projectedPos.x; @@ -555,85 +583,85 @@ 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) { - if (gSaveContext.save.weekEventReg[79] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_01)) { textId = 0x125B; - } else if (gSaveContext.save.weekEventReg[78] & 0x80) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_80)) { textId = 0x125A; } else { textId = 0x1259; - gSaveContext.save.weekEventReg[78] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_78_80); } - func_80BBAE84(this, 5, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_ARMS_OUT, ANIMMODE_LOOP); } else { textId = 0x1258; - func_80BBAE84(this, 6, 0); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_TALK_HANDS_ON_HIPS, 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)) { + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, 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: + EnZos_ChangeAnim(this, EN_ZOS_ANIM_HANDS_ON_HIPS, 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); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_LEAN_ON_KEYBOARD, 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); - if (gSaveContext.save.weekEventReg[79] & 1) { +void func_80BBC24C(EnZos* this, PlayState* play) { + func_80BBB0D4(this, play); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_01)) { this->actionFunc = func_80BBC22C; - func_80BBAE84(this, 7, 2); + EnZos_ChangeAnim(this, EN_ZOS_ANIM_PLAY_RIGHT, 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 +673,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,59 +684,59 @@ 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); + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); } - this->unk_2AC = this->unk_2AE; - if (this->unk_2AC >= 3) { - this->unk_2AC = 0; + this->eyeIndex = this->blinkTimer; + if (this->eyeIndex >= 3) { + this->eyeIndex = 0; } } -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) { + if (limbIndex == EVAN_LIMB_HEAD) { Matrix_MultVec3f(&D_80BBC750, &thisx->focus.pos); } } -void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { - static TexturePtr D_80BBC75C[] = { - object_zos_Tex_010918, - object_zos_Tex_011118, - object_zos_Tex_011918, +void EnZos_Draw(Actor* thisx, PlayState* play) { + static TexturePtr sEyeTextures[] = { + gEvanEyeOpenTex, + gEvanEyeHalfTex, + gEvanEyeClosedTex, }; 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); @@ -716,26 +744,26 @@ void EnZos_Draw(Actor* thisx, GlobalContext* globalCtx) { gfx = POLY_OPA_DISP; - gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(D_80BBC75C[this->unk_2AC])); + gSPSegment(&gfx[0], 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); Matrix_Push(); Matrix_RotateYS(this->actor.home.rot.y - this->actor.shape.rot.y, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -974.4f, MTXMODE_APPLY); - gSPMatrix(&gfx[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(&gfx[2], object_zos_DL_0136E0); - gSPDisplayList(&gfx[3], object_zos_DL_013088); + gSPMatrix(&gfx[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[2], gEvanUnknownWhiteTriangleDL); + gSPDisplayList(&gfx[3], gEvanKeyboardDL); POLY_OPA_DISP = &gfx[4]; 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..e3ede7b28 100644 --- a/src/overlays/actors/ovl_En_Zos/z_en_zos.h +++ b/src/overlays/actors/ovl_En_Zos/z_en_zos.h @@ -2,10 +2,11 @@ #define Z_EN_ZOS_H #include "global.h" +#include "objects/object_zos/object_zos.h" struct EnZos; -typedef void (*EnZosActionFunc)(struct EnZos*, GlobalContext*); +typedef void (*EnZosActionFunc)(struct EnZos*, PlayState*); #define ENZOS_GET_F(thisx) ((thisx)->params & 0xF) @@ -15,21 +16,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[EVAN_LIMB_MAX]; + /* 0x1B0 */ Vec3s morphTable[EVAN_LIMB_MAX]; + /* 0x21C */ SkelAnime skelAnime; + /* 0x260 */ ColliderCylinder collider; + /* 0x2AC */ s16 eyeIndex; + /* 0x2AE */ s16 blinkTimer; + /* 0x2B0 */ UNK_TYPE1 unk2B0[6]; + /* 0x2B6 */ u16 unk_2B6; + /* 0x2B8 */ s16 animIndex; + /* 0x2BA */ s16 unk_2BA; + /* 0x2BC */ s16 unk_2BC; + /* 0x2C0 */ EnZosActionFunc actionFunc; } EnZos; // size = 0x2C4 -extern const ActorInit En_Zos_InitVars; - #endif // Z_EN_ZOS_H diff --git a/src/overlays/actors/ovl_En_Zot/overlay.cfg b/src/overlays/actors/ovl_En_Zot/overlay.cfg deleted file mode 100644 index 0d4db225f..000000000 --- a/src/overlays/actors/ovl_En_Zot/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zot -z_en_zot.c 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 1cf8ad992..417a6388e 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -5,33 +5,34 @@ */ #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* play2); +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 = { +ActorInit En_Zot_InitVars = { ACTOR_EN_ZOT, ACTORCAT_NPC, FLAGS, @@ -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,37 +182,37 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&this->actor); } break; case 18: this->actionFunc = func_80B99384; - if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { - Actor_MarkForDeath(&this->actor); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&this->actor); } 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; } @@ -219,25 +220,25 @@ void EnZot_Init(Actor* thisx, GlobalContext* globalCtx2) { break; } - if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && (gSaveContext.save.weekEventReg[55] & 0x80)) { - Actor_MarkForDeath(&this->actor); + if ((ENZOT_GET_1F(thisx) >= 2) && (ENZOT_GET_1F(thisx) < 11) && CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&this->actor); } } -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; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_41_20); } } 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,137 +354,137 @@ 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) { textId = 0x125F; - if (gSaveContext.save.weekEventReg[28] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_28_80)) { textId = 0x1261; } else { - gSaveContext.save.weekEventReg[28] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_28_80); } } else { textId = 0x125C; - if (gSaveContext.save.weekEventReg[28] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_28_40)) { textId = 0x125E; } else { - gSaveContext.save.weekEventReg[28] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_28_40); } } - 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_29_10)) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x126A; - if (gSaveContext.save.weekEventReg[29] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_29_01)) { textId = 0x126D; } else { - gSaveContext.save.weekEventReg[29] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_29_01); } } else { textId = 0x1267; - if (gSaveContext.save.weekEventReg[29] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_29_02)) { textId = 0x1269; } else { - gSaveContext.save.weekEventReg[29] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_29_02); } } } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { textId = 0x1265; - if (gSaveContext.save.weekEventReg[29] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_29_04)) { textId = 0x1266; } else { - gSaveContext.save.weekEventReg[29] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_29_04); } } else { textId = 0x1262; - if (gSaveContext.save.weekEventReg[29] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_29_08)) { textId = 0x1264; } else { - gSaveContext.save.weekEventReg[29] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_29_08); } } - 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,56 +511,56 @@ 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_IA_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; } - if (!(player->stateFlags1 & 0x2000000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_2000000)) { phi_v1 = func_80B96CE4(this); } else { phi_v1 = 0; } if (phi_v1 != 0) { - gSaveContext.save.weekEventReg[29] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_29_10); this->actor.flags |= ACTOR_FLAG_10000; if (phi_v1 == 5) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { @@ -573,100 +574,100 @@ 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) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { switch (ENZOT_GET_1F(&this->actor)) { case 2: - if (gSaveContext.save.weekEventReg[37] & 0x40) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_37_40)) { textId = 0x127E; } else { textId = 0x127C; - gSaveContext.save.weekEventReg[37] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_37_40); } break; case 3: - if (gSaveContext.save.weekEventReg[38] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_38_01)) { textId = 0x1284; } else { textId = 0x1282; - gSaveContext.save.weekEventReg[38] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_38_01); } break; default: - if (gSaveContext.save.weekEventReg[38] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_38_04)) { textId = 0x128A; } else { textId = 0x1288; - gSaveContext.save.weekEventReg[38] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_38_04); } break; } } else { switch (ENZOT_GET_1F(&this->actor)) { case 2: - if (gSaveContext.save.weekEventReg[37] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_37_20)) { textId = 0x127B; } else { textId = 0x1279; - gSaveContext.save.weekEventReg[37] |= 0x20; + SET_WEEKEVENTREG(WEEKEVENTREG_37_20); } break; case 3: - if (gSaveContext.save.weekEventReg[37] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_37_80)) { textId = 0x1281; } else { textId = 0x127F; - gSaveContext.save.weekEventReg[37] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_37_80); } break; default: - if (gSaveContext.save.weekEventReg[38] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_38_02)) { textId = 0x1287; } else { textId = 0x1285; - gSaveContext.save.weekEventReg[38] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_38_02); } 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); - gSaveContext.save.weekEventReg[38] |= 8; + func_80B96BEC(this, 3, ANIMMODE_LOOP); + SET_WEEKEVENTREG(WEEKEVENTREG_38_08); 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); - } else if (gSaveContext.save.weekEventReg[38] & 8) { + func_80B97BF8(this, play); + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_38_08)) { 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; @@ -837,35 +837,35 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { if (CURRENT_DAY == 3) { textId = 0x129D; - } else if (gSaveContext.save.weekEventReg[39] & 1) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_01)) { textId = 0x129C; } else { textId = 0x129B; - gSaveContext.save.weekEventReg[39] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_39_01); } - } else if (gSaveContext.save.weekEventReg[38] & 0x80) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_38_80)) { textId = 0x1293; } else { textId = 0x1291; - gSaveContext.save.weekEventReg[38] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_38_80); } break; case 7: if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.save.weekEventReg[39] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_04)) { textId = 0x12AA; } else { textId = 0x12A6; - gSaveContext.save.weekEventReg[39] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_39_04); } - } 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) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_02)) { textId = 0x12A5; } else { textId = 0x12A2; - gSaveContext.save.weekEventReg[39] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_39_02); } break; @@ -877,7 +877,7 @@ void func_80B98178(EnZot* this, GlobalContext* globalCtx) { case 16: case 17: phi_v0 = (ENZOT_GET_1F(&this->actor) * 4) - 44; - if (gSaveContext.save.weekEventReg[79] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_01)) { phi_v0 += 2; } @@ -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,84 @@ 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_IA_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_IA_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) { - s32 itemActionParam; - Player* player = GET_PLAYER(globalCtx); +void func_80B985EC(EnZot* this, PlayState* play) { + PlayerItemAction itemAction; + Player* player = GET_PLAYER(play); - func_80B98348(this, globalCtx); - if (Message_GetState(&globalCtx->msgCtx) == 0x10) { - itemActionParam = func_80123810(globalCtx); - 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_80B98348(this, play); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_16) { + itemAction = func_80123810(play); + + if (itemAction > PLAYER_IA_NONE) { + func_801477B4(play); + if ((itemAction == PLAYER_IA_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); + } else if (itemAction <= PLAYER_IA_MINUS1) { + 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 +1015,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,271 +1062,271 @@ 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) { - if (gSaveContext.save.weekEventReg[39] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_80)) { textId = 0x12B6; } else { textId = 0x12B4; - gSaveContext.save.weekEventReg[39] |= 0x80; + SET_WEEKEVENTREG(WEEKEVENTREG_39_80); } - } else if (gSaveContext.save.weekEventReg[39] & 0x40) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_39_40)) { textId = 0x12B3; } else { textId = 0x12B1; - gSaveContext.save.weekEventReg[39] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_39_40); } - 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); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_41_20); + 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); + SET_WEEKEVENTREG(WEEKEVENTREG_41_20); + 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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_41_20)) { + 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); } } if (this->actor.xzDistToPlayer > 100.0f) { - gSaveContext.save.weekEventReg[41] &= (u8)~0x20; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_41_20); } } -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 (gSaveContext.save.weekEventReg[40] & 4) { + if (Flags_GetSwitch(play, this->actor.home.rot.z & 0x7F)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_40_04)) { textId = 0x12C5; } else { textId = 0x12C3; - gSaveContext.save.weekEventReg[40] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_40_04); } - } else if (gSaveContext.save.weekEventReg[40] & 2) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_40_02)) { textId = 0x12C2; } else { textId = 0x12C0; - gSaveContext.save.weekEventReg[40] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_40_02); } } 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 { textId = 0x12BE; this->unk_2F2 |= 0x10; } - } else if (gSaveContext.save.weekEventReg[40] & 1) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_40_01)) { textId = 0x12BC; } else { - gSaveContext.save.weekEventReg[40] |= 1; + SET_WEEKEVENTREG(WEEKEVENTREG_40_01); this->unk_2F2 |= 4; 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) { - if (gSaveContext.save.weekEventReg[40] & 0x10) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_40_10)) { textId = 0x12CD; } else { textId = 0x12CA; - gSaveContext.save.weekEventReg[40] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_40_10); } - } else if (gSaveContext.save.weekEventReg[40] & 8) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_40_08)) { textId = 0x12C9; } else { textId = 0x12C6; - gSaveContext.save.weekEventReg[40] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_40_08); } - 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); @@ -1344,14 +1346,15 @@ void EnZot_Update(Actor* thisx, GlobalContext* globalCtx) { } Gfx* func_80B99580(GraphicsContext* gfxCtx) { - Gfx* dList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + Gfx* gfx = gfxHead; - gSPEndDisplayList(dList); + gSPEndDisplayList(gfx++); - return dList; + return gfxHead; } -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; @@ -1369,13 +1372,13 @@ s32 EnZot_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, 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; @@ -1384,7 +1387,7 @@ void EnZot_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -void EnZot_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnZot_Draw(Actor* thisx, PlayState* play) { TexturePtr sp4C[] = { gZoraEyeOpenTex, gZoraEyeHalfTex, @@ -1392,16 +1395,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..1bab43ae3 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.h +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.h @@ -5,30 +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; - #endif // Z_EN_ZOT_H diff --git a/src/overlays/actors/ovl_En_Zov/overlay.cfg b/src/overlays/actors/ovl_En_Zov/overlay.cfg deleted file mode 100644 index 6e8d4a17a..000000000 --- a/src/overlays/actors/ovl_En_Zov/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zov -z_en_zov.c 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 4bb5f2a5a..851214b5d 100644 --- a/src/overlays/actors/ovl_En_Zov/z_en_zov.c +++ b/src/overlays/actors/ovl_En_Zov/z_en_zov.c @@ -12,23 +12,23 @@ #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 = { +ActorInit En_Zov_InitVars = { ACTOR_EN_ZOV, ACTORCAT_NPC, FLAGS, @@ -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); - if (!(gSaveContext.save.weekEventReg[55] & 0x80)) { - Actor_MarkForDeath(&this->actor); + func_80BD1570(this, 9, ANIMMODE_LOOP); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { + Actor_Kill(&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); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_53_20)) { + Actor_Kill(&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,46 +174,46 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_53_20)) { this->unk_320 &= ~2; if (gSaveContext.save.playerForm != PLAYER_FORM_ZORA) { textId = 0x1024; if ((this->unk_322 == 0) || (this->unk_322 == 4)) { - func_80BD1570(this, 4, 2); + 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,40 +358,40 @@ 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) { - if (gSaveContext.save.weekEventReg[79] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_79_01)) { textId = 0x1032; } else { textId = 0x1033; @@ -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; - gSaveContext.save.weekEventReg[78] |= 1; + play->nextEntrance = play->setupExitList[ENZOV_GET_FE00(&this->picto.actor)]; + play->transitionType = TRANS_TYPE_05; + play->transitionTrigger = TRANS_TRIGGER_START; + SET_WEEKEVENTREG(WEEKEVENTREG_78_01); 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,12 +534,12 @@ 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_MultVec3f(&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; } @@ -549,7 +552,7 @@ void EnZov_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Ve } } -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..a5e217ca3 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,28 +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; - #endif // Z_EN_ZOV_H diff --git a/src/overlays/actors/ovl_En_Zow/overlay.cfg b/src/overlays/actors/ovl_En_Zow/overlay.cfg deleted file mode 100644 index ba17bffc7..000000000 --- a/src/overlays/actors/ovl_En_Zow/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_En_Zow -z_en_zow.c 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 d29141499..7e3709162 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -11,18 +11,18 @@ #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 = { +ActorInit En_Zow_InitVars = { ACTOR_EN_ZOW, ACTORCAT_NPC, FLAGS, @@ -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; @@ -199,27 +199,26 @@ void func_80BDC830(EnZowStruct* ptr, GlobalContext* globalCtx) { 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); @@ -228,30 +227,29 @@ void func_80BDC9DC(EnZowStruct* ptr, GlobalContext* globalCtx) { } Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + 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) {} @@ -261,16 +259,15 @@ void func_80BDCB84(EnZowStruct* ptr, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 180, 180, 180, ptr->unk_0F); Matrix_Translate(ptr->unk_14.x, ptr->unk_14.y, ptr->unk_14.z, MTXMODE_NEW); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); + Matrix_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) { @@ -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,65 +345,65 @@ 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) { - if (gSaveContext.save.weekEventReg[55] & 0x80) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.save.weekEventReg[78] & 4) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_04)) { phi_a1 = 0x12FD; } else { phi_a1 = 0x12FA; - gSaveContext.save.weekEventReg[78] |= 4; + SET_WEEKEVENTREG(WEEKEVENTREG_78_04); } - } else if (gSaveContext.save.weekEventReg[78] & 0x10) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_10)) { phi_a1 = 0x1301; } else { - gSaveContext.save.weekEventReg[78] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_78_10); phi_a1 = 0x12FF; } } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.save.weekEventReg[78] & 8) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_08)) { phi_a1 = 0x12F8; } else { phi_a1 = 0x12F3; - gSaveContext.save.weekEventReg[78] |= 8; + SET_WEEKEVENTREG(WEEKEVENTREG_78_08); } - } else if (gSaveContext.save.weekEventReg[78] & 0x10) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_10)) { phi_a1 = 0x1301; } else { - gSaveContext.save.weekEventReg[78] |= 0x10; + SET_WEEKEVENTREG(WEEKEVENTREG_78_10); phi_a1 = 0x12FF; } - } else if (gSaveContext.save.weekEventReg[55] & 0x80) { + } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_55_80)) { if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { phi_a1 = 0x12EC; } else { phi_a1 = 0x12F1; } } else if (gSaveContext.save.playerForm == PLAYER_FORM_ZORA) { - if (gSaveContext.save.weekEventReg[78] & 2) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_78_02)) { phi_a1 = 0x12EB; } else { phi_a1 = 0x12E8; - gSaveContext.save.weekEventReg[78] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_78_02); } } 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; @@ -592,26 +589,27 @@ void EnZow_Update(Actor* thisx, GlobalContext* globalCtx) { } Gfx* func_80BDDA7C(GraphicsContext* gfxCtx) { - Gfx* gfx = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + Gfx* gfx = gfxHead; - gSPEndDisplayList(gfx); + gSPEndDisplayList(gfx++); - return gfx; + return gfxHead; } 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_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, @@ -621,30 +619,30 @@ void EnZow_Draw(Actor* thisx, GlobalContext* globalCtx) { 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_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..a9d915667 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,21 +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; - #endif // Z_EN_ZOW_H diff --git a/src/overlays/actors/ovl_Item_B_Heart/overlay.cfg b/src/overlays/actors/ovl_Item_B_Heart/overlay.cfg deleted file mode 100644 index 092976e2b..000000000 --- a/src/overlays/actors/ovl_Item_B_Heart/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Item_B_Heart -z_item_b_heart.c 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..c4d72a8f1 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,14 +11,14 @@ #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 = { +ActorInit Item_B_Heart_InitVars = { ACTOR_ITEM_B_HEART, ACTORCAT_BOSS, FLAGS, @@ -37,11 +37,11 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetCollectible(play, 0x1F)) { + Actor_Kill(&this->actor); return; } @@ -57,38 +57,39 @@ 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); - Actor_MarkForDeath(&this->actor); - } else { - Actor_PickUp(&this->actor, globalCtx, GI_HEART_CONTAINER, 30.0f, 80.0f); + if (Actor_HasParent(&this->actor, play)) { + Flags_SetCollectible(play, 0x1F); + Actor_Kill(&this->actor); + return; } + + 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 +100,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..f7ff62fa9 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,11 +7,9 @@ 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 -extern const ActorInit Item_B_Heart_InitVars; - #endif // Z_ITEM_B_HEART_H diff --git a/src/overlays/actors/ovl_Item_Etcetera/overlay.cfg b/src/overlays/actors/ovl_Item_Etcetera/overlay.cfg deleted file mode 100644 index bf610d3f6..000000000 --- a/src/overlays/actors/ovl_Item_Etcetera/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Item_Etcetera -z_item_etcetera.c 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..e327dc3f4 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -10,16 +10,17 @@ #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 = { +ActorInit Item_Etcetera_InitVars = { ACTOR_ITEM_ETCETERA, ACTORCAT_PROP, FLAGS, @@ -31,22 +32,109 @@ 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_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_80920164.s") + Actor_PickUp(&this->actor, play, this->getItemId, 30.0f, 50.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Item_Etcetera/func_809201BC.s") +void func_809200F8(ItemEtcetera* this, PlayState* play) { + if (Flags_GetTreasure(play, ITEMETCETERA_GET_TREASUREFLAG(&this->actor))) { + Actor_Kill(&this->actor); + } +} + +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.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { + 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..4ac893ba5 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.h @@ -5,14 +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; - #endif // Z_ITEM_ETCETERA_H diff --git a/src/overlays/actors/ovl_Item_Inbox/overlay.cfg b/src/overlays/actors/ovl_Item_Inbox/overlay.cfg deleted file mode 100644 index e6d4ee824..000000000 --- a/src/overlays/actors/ovl_Item_Inbox/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Item_Inbox -z_item_inbox.c 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..0599e117d 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.c @@ -1,7 +1,7 @@ /* * File: z_item_inbox.c * Overlay: ovl_Item_Inbox - * Description: + * Description: Unused, can draw GetItem models. Perhaps intended to draw items inside chests. */ #include "z_item_inbox.h" @@ -10,14 +10,14 @@ #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 = { +ActorInit Item_Inbox_InitVars = { ACTOR_ITEM_INBOX, ACTORCAT_NPC, FLAGS, @@ -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)) { - Actor_MarkForDeath(&this->actor); +void ItemInbox_Idle(ItemInbox* this, PlayState* play) { + if (Flags_GetTreasure(play, (this->actor.params >> 8) & 0x1F)) { + Actor_Kill(&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..e6b1adfd6 100644 --- a/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.h +++ b/src/overlays/actors/ovl_Item_Inbox/z_item_inbox.h @@ -5,13 +5,11 @@ struct ItemInbox; -typedef void (*ItemInboxActionFunc)(struct ItemInbox*, GlobalContext*); +typedef void (*ItemInboxActionFunc)(struct ItemInbox*, PlayState*); typedef struct ItemInbox { /* 0x000 */ Actor actor; /* 0x144 */ ItemInboxActionFunc actionFunc; } ItemInbox; // size = 0x148 -extern const ActorInit Item_Inbox_InitVars; - #endif // Z_ITEM_INBOX_H diff --git a/src/overlays/actors/ovl_Mir_Ray/overlay.cfg b/src/overlays/actors/ovl_Mir_Ray/overlay.cfg deleted file mode 100644 index 9010673e3..000000000 --- a/src/overlays/actors/ovl_Mir_Ray/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Mir_Ray -z_mir_ray.c 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 eee9de294..4880a326e 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); @@ -41,7 +41,7 @@ typedef struct { /* 0x1F */ u8 params; } MirRayDataEntry; // size = 0x20 -const ActorInit Mir_Ray_InitVars = { +ActorInit Mir_Ray_InitVars = { ACTOR_MIR_RAY, ACTORCAT_ITEMACTION, FLAGS, @@ -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)]; @@ -296,7 +296,7 @@ void MirRay_Init(Actor* thisx, GlobalContext* globalCtx) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); if (MIRRAY_LOCATION(&this->actor) >= MIRRAY_MAX) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } this->sourcePt.x = dataEntry->sourcePoint.x; @@ -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; @@ -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; @@ -455,7 +455,7 @@ void MirRay_SetupReflectionPolys(MirRay* this, GlobalContext* globalCtx, MirRayS 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; @@ -483,10 +483,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; @@ -498,8 +496,6 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe f32 spE8[3]; f32 normalVec[3]; MtxF* shieldMtx = &player->shieldMf; - Vec3f vecA; - Vec3f vecC; spE8[0] = -(shieldMtx->xz * this->reflectRange) * this->reflectIntensity * 400.0f; spE8[1] = -(shieldMtx->yz * this->reflectRange) * this->reflectIntensity * 400.0f; @@ -513,118 +509,119 @@ void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldRe vecD.y = spE8[1] + vecB.y; vecD.z = spE8[2] + vecB.z; - vecA.x = vecB.x + (shieldMtx->xx * 300.0f); - vecA.y = vecB.y + (shieldMtx->yx * 300.0f); - vecA.z = vecB.z + (shieldMtx->zx * 300.0f); + { + Vec3f vecA; + Vec3f vecC; - vecC.x = vecD.x + (shieldMtx->xx * 300.0f); - vecC.y = vecD.y + (shieldMtx->yx * 300.0f); - vecC.z = vecD.z + (shieldMtx->zx * 300.0f); + vecA.x = vecB.x + (shieldMtx->xx * 300.0f); + vecA.y = vecB.y + (shieldMtx->yx * 300.0f); + vecA.z = vecB.z + (shieldMtx->zx * 300.0f); - Collider_SetQuadVertices(&this->collider2, &vecA, &vecB, &vecC, &vecD); + vecC.x = vecD.x + (shieldMtx->xx * 300.0f); + vecC.y = vecD.y + (shieldMtx->yx * 300.0f); + vecC.z = vecD.z + (shieldMtx->zx * 300.0f); - for (i = 0; i < 6; i++) { - if (reflection[i].reflectionPoly != NULL) { - normalVec[0] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.x); - normalVec[1] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.y); - normalVec[2] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.z); + Collider_SetQuadVertices(&this->collider2, &vecA, &vecB, &vecC, &vecD); - if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, - &vecB, &vecD, &sp118, 1)) { + for (i = 0; i < 6; i++) { + if (reflection[i].reflectionPoly != NULL) { + normalVec[0] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.x); + normalVec[1] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.y); + normalVec[2] = COLPOLY_GET_NORMAL(reflection[i].reflectionPoly->normal.z); - reflection[i].pos.x = sp118.x; - reflection[i].pos.y = sp118.y; - reflection[i].pos.z = sp118.z; + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, + &vecB, &vecD, &sp118, 1)) { - temp_f0 = sqrtf(SQ(sp118.x - vecB.x) + SQ(sp118.y - vecB.y) + SQ(sp118.z - vecB.z)); + reflection[i].pos.x = sp118.x; + reflection[i].pos.y = sp118.y; + reflection[i].pos.z = sp118.z; - if (temp_f0 < (this->reflectIntensity * 600.0f)) { - reflection[i].opacity = 200; + temp_f0 = sqrtf(SQ(sp118.x - vecB.x) + SQ(sp118.y - vecB.y) + SQ(sp118.z - vecB.z)); + + if (temp_f0 < (this->reflectIntensity * 600.0f)) { + reflection[i].opacity = 200; + } else { + reflection[i].opacity = (s32)(800.0f - temp_f0); + } + + reflection[i].opacity = (s32)(reflection[i].opacity * 1.275f); + + sp10C.x = (shieldMtx->xx * 100.0f) + vecB.x; + sp10C.y = (shieldMtx->yx * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->zx * 100.0f) + vecB.z; + + sp100.x = (spE8[0] * 4.0f) + sp10C.x; + sp100.y = (spE8[1] * 4.0f) + sp10C.y; + sp100.z = (spE8[2] * 4.0f) + sp10C.z; + + reflection[i].mtx.xx = reflection[i].mtx.yy = reflection[i].mtx.zz = reflection[i].mtx.ww = 1.0f; + + reflection[i].mtx.yx = reflection[i].mtx.zx = reflection[i].mtx.wx = reflection[i].mtx.xy = + reflection[i].mtx.zy = reflection[i].mtx.wy = reflection[i].mtx.xz = reflection[i].mtx.yz = + reflection[i].mtx.wz = reflection[i].mtx.xw = reflection[i].mtx.yw = reflection[i].mtx.zw = + 0.0f; + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], + reflection[i].reflectionPoly->dist, &sp10C, &sp100, &intersection, 1)) { + reflection[i].mtx.xx = intersection.x - sp118.x; + reflection[i].mtx.yx = intersection.y - sp118.y; + reflection[i].mtx.zx = intersection.z - sp118.z; + } + + sp10C.x = (shieldMtx->xy * 100.0f) + vecB.x; + sp10C.y = (shieldMtx->yy * 100.0f) + vecB.y; + sp10C.z = (shieldMtx->zy * 100.0f) + vecB.z; + + sp100.x = (spE8[0] * 4.0f) + sp10C.x; + sp100.y = (spE8[1] * 4.0f) + sp10C.y; + sp100.z = (spE8[2] * 4.0f) + sp10C.z; + + if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], + reflection[i].reflectionPoly->dist, &sp10C, &sp100, &intersection, 1)) { + reflection[i].mtx.xy = intersection.x - sp118.x; + reflection[i].mtx.yy = intersection.y - sp118.y; + reflection[i].mtx.zy = intersection.z - sp118.z; + } } else { - reflection[i].opacity = (s32)(800.0f - temp_f0); + reflection[i].reflectionPoly = NULL; } - - reflection[i].opacity = (s32)(reflection[i].opacity * 1.275f); - - sp10C.x = (shieldMtx->xx * 100.0f) + vecB.x; - sp10C.y = (shieldMtx->yx * 100.0f) + vecB.y; - sp10C.z = (shieldMtx->zx * 100.0f) + vecB.z; - - sp100.x = (spE8[0] * 4.0f) + sp10C.x; - sp100.y = (spE8[1] * 4.0f) + sp10C.y; - sp100.z = (spE8[2] * 4.0f) + sp10C.z; - - reflection[i].mtx.xx = reflection[i].mtx.yy = reflection[i].mtx.zz = reflection[i].mtx.ww = 1.0f; - - reflection[i].mtx.yx = reflection[i].mtx.zx = reflection[i].mtx.wx = reflection[i].mtx.xy = - reflection[i].mtx.zy = reflection[i].mtx.wy = reflection[i].mtx.xz = reflection[i].mtx.yz = - reflection[i].mtx.wz = reflection[i].mtx.xw = reflection[i].mtx.yw = reflection[i].mtx.zw = - 0.0f; - - if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, - &sp10C, &sp100, &intersection, 1)) { - reflection[i].mtx.xx = intersection.x - sp118.x; - reflection[i].mtx.yx = intersection.y - sp118.y; - reflection[i].mtx.zx = intersection.z - sp118.z; - } - - sp10C.x = (shieldMtx->xy * 100.0f) + vecB.x; - sp10C.y = (shieldMtx->yy * 100.0f) + vecB.y; - sp10C.z = (shieldMtx->zy * 100.0f) + vecB.z; - - sp100.x = (spE8[0] * 4.0f) + sp10C.x; - sp100.y = (spE8[1] * 4.0f) + sp10C.y; - sp100.z = (spE8[2] * 4.0f) + sp10C.z; - - if (Math3D_LineSegVsPlane(normalVec[0], normalVec[1], normalVec[2], reflection[i].reflectionPoly->dist, - &sp10C, &sp100, &intersection, 1)) { - reflection[i].mtx.xy = intersection.x - sp118.x; - reflection[i].mtx.yy = intersection.y - sp118.y; - reflection[i].mtx.zy = intersection.z - sp118.z; - } - } else { - reflection[i].reflectionPoly = NULL; } } } } -#else -void MirRay_ReflectedBeam(MirRay* this, GlobalContext* globalCtx, MirRayShieldReflection* reflection); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray/MirRay_ReflectedBeam.s") -#endif -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)) { + if (!D_808E3BF0 && !this->unLit && Player_IsHoldingMirrorShield(play)) { Matrix_Mult(&player->shieldMf, MTXMODE_NEW); - MirRay_SetIntensity(this, globalCtx); + 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; @@ -644,7 +641,7 @@ void MirRay_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(0.01f, 0.01f, 0.01f, 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 +651,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..cd48cfed1 100644 --- a/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h +++ b/src/overlays/actors/ovl_Mir_Ray/z_mir_ray.h @@ -9,37 +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; - #endif // Z_MIR_RAY_H diff --git a/src/overlays/actors/ovl_Mir_Ray2/overlay.cfg b/src/overlays/actors/ovl_Mir_Ray2/overlay.cfg deleted file mode 100644 index 2a1947005..000000000 --- a/src/overlays/actors/ovl_Mir_Ray2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Mir_Ray2 -z_mir_ray2.c 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..a552e35ab 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.c @@ -10,13 +10,12 @@ #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 = { +ActorInit Mir_Ray2_InitVars = { ACTOR_MIR_RAY2, ACTORCAT_ITEMACTION, FLAGS, @@ -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..4bb40d40d 100644 --- a/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.h +++ b/src/overlays/actors/ovl_Mir_Ray2/z_mir_ray2.h @@ -5,11 +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; - #endif // Z_MIR_RAY2_H diff --git a/src/overlays/actors/ovl_Mir_Ray3/overlay.cfg b/src/overlays/actors/ovl_Mir_Ray3/overlay.cfg deleted file mode 100644 index b2553ef0f..000000000 --- a/src/overlays/actors/ovl_Mir_Ray3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Mir_Ray3 -z_mir_ray3.c 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 f5209c392..8f6fcbfe9 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Mir_Ray3_InitVars = { ACTOR_MIR_RAY3, ACTORCAT_ITEMACTION, FLAGS, @@ -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; @@ -213,9 +213,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; @@ -231,7 +230,6 @@ void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr) f32 temp_f2; Vec3f spD4; Vec3f spC8; - CollisionPoly* spC4; spF8[0] = -(shieldMf->mf[2][0] * this->unk_260) * this->unk_214 * 400.0f; spF8[1] = -(shieldMf->mf[2][1] * this->unk_260) * this->unk_214 * 400.0f; @@ -321,52 +319,52 @@ 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)) { - Math_Vec3f_Copy(&sp128, &sp134); + { + CollisionPoly* spC4; + + if (!BgCheck_AnyLineTest1(&play->colCtx, &sp140, &sp134, &sp128, &spC4, 1)) { + Math_Vec3f_Copy(&sp128, &sp134); + } + + sp128.x += spF8[0] * 5.0f; + sp128.y += spF8[1] * 5.0f; + sp128.z += spF8[2] * 5.0f; + + spD4.x = (shieldMf->mf[0][0] * 300.0f) + sp140.x; + spD4.y = (shieldMf->mf[0][1] * 300.0f) + sp140.y; + spD4.z = (shieldMf->mf[0][2] * 300.0f) + sp140.z; + + spC8.x = (shieldMf->mf[0][0] * 300.0f) + sp128.x; + spC8.y = (shieldMf->mf[0][1] * 300.0f) + sp128.y; + spC8.z = (shieldMf->mf[0][2] * 300.0f) + sp128.z; + + Collider_SetQuadVertices(&this->colliderQuad, &spD4, &sp140, &spC8, &sp128); } - - sp128.x += spF8[0] * 5.0f; - sp128.y += spF8[1] * 5.0f; - sp128.z += spF8[2] * 5.0f; - - spD4.x = (shieldMf->mf[0][0] * 300.0f) + sp140.x; - spD4.y = (shieldMf->mf[0][1] * 300.0f) + sp140.y; - spD4.z = (shieldMf->mf[0][2] * 300.0f) + sp140.z; - - spC8.x = (shieldMf->mf[0][0] * 300.0f) + sp128.x; - spC8.y = (shieldMf->mf[0][1] * 300.0f) + sp128.y; - spC8.z = (shieldMf->mf[0][2] * 300.0f) + sp128.z; - - Collider_SetQuadVertices(&this->colliderQuad, &spD4, &sp140, &spC8, &sp128); } -#else -void func_80B9E8D4(MirRay3* this, GlobalContext* globalCtx, MirRay3Struct* ptr); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Mir_Ray3/func_80B9E8D4.s") -#endif -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 time; - if (!(this->unk_210 & 1) && func_8012405C(globalCtx)) { + if (!(this->unk_210 & 1) && Player_HasMirrorShieldEquipped(play)) { Matrix_Mult(&player->shieldMf, MTXMODE_NEW); - func_80B9E544(this, globalCtx); + 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) { time = gSaveContext.save.time; @@ -384,13 +382,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; @@ -410,7 +408,7 @@ void MirRay3_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); Matrix_Mult(&sp8C[i].unk_0C, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + 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 +418,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_Mir_Ray3/z_mir_ray3.h b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h index 7aecd111f..3e285c050 100644 --- a/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h +++ b/src/overlays/actors/ovl_Mir_Ray3/z_mir_ray3.h @@ -19,6 +19,4 @@ typedef struct MirRay3 { /* 0x260 */ f32 unk_260; } MirRay3; // size = 0x264 -extern const ActorInit Mir_Ray3_InitVars; - #endif // Z_MIR_RAY3_H diff --git a/src/overlays/actors/ovl_Obj_Aqua/overlay.cfg b/src/overlays/actors/ovl_Obj_Aqua/overlay.cfg deleted file mode 100644 index fa2c65abc..000000000 --- a/src/overlays/actors/ovl_Obj_Aqua/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Aqua -z_obj_aqua.c 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 97865650d..acea3daf1 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.c @@ -11,20 +11,20 @@ #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); -const ActorInit Obj_Aqua_InitVars = { +ActorInit Obj_Aqua_InitVars = { ACTOR_OBJ_AQUA, ACTORCAT_ITEMACTION, FLAGS, @@ -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) { @@ -126,21 +126,21 @@ void func_80ACBA10(ObjAqua* this) { 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,20 +174,20 @@ 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); - Actor_MarkForDeath(&this->actor); + func_80ACB6A0(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 0x28, NA_SE_EV_BOMB_DROP_WATER); + Actor_Kill(&this->actor); } } else if (this->counter <= 0) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -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; @@ -208,7 +207,7 @@ void func_80ACBD48(ObjAqua* this, GlobalContext* globalCtx) { if (this->actor.shape.shadowAlpha > 2) { this->actor.shape.shadowAlpha -= 2; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -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,22 +228,22 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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,30 +254,30 @@ 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) { @@ -289,8 +288,10 @@ void ObjAqua_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateZS(rotation * -1, MTXMODE_APPLY); Matrix_Scale(10.0f / 13.0f, 1.0f, 1.0f, MTXMODE_APPLY); } + Matrix_RotateYS(yaw, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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..a47ea661a 100644 --- a/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h +++ b/src/overlays/actors/ovl_Obj_Aqua/z_obj_aqua.h @@ -8,17 +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; - #endif // Z_OBJ_AQUA_H diff --git a/src/overlays/actors/ovl_Obj_Armos/overlay.cfg b/src/overlays/actors/ovl_Obj_Armos/overlay.cfg deleted file mode 100644 index 1b54f7a3e..000000000 --- a/src/overlays/actors/ovl_Obj_Armos/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Armos -z_obj_armos.c 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 3e72b809e..565c99504 100644 --- a/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c +++ b/src/overlays/actors/ovl_Obj_Armos/z_obj_armos.c @@ -11,19 +11,19 @@ #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* play2); +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 = { +ActorInit Obj_Armos_InitVars = { ACTOR_OBJ_ARMOS, ACTORCAT_PROP, FLAGS, @@ -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 &= ~PLAYER_STATE2_10; 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,25 +271,25 @@ 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; } - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; if (!sp20) { @@ -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 &= ~PLAYER_STATE2_10; 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,15 +334,15 @@ 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); @@ -350,23 +350,23 @@ void func_809A5960(ObjArmos* this, GlobalContext* globalCtx) { (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); @@ -377,16 +377,16 @@ void func_809A5A3C(ObjArmos* this, GlobalContext* globalCtx) { 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..2e9453005 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,21 +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; - #endif // Z_OBJ_ARMOS_H diff --git a/src/overlays/actors/ovl_Obj_Bean/overlay.cfg b/src/overlays/actors/ovl_Obj_Bean/overlay.cfg deleted file mode 100644 index 24317cd06..000000000 --- a/src/overlays/actors/ovl_Obj_Bean/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Bean -z_obj_bean.c 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 3ee4be021..35f37d5d8 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,45 +22,45 @@ 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 = { +ActorInit Obj_Bean_InitVars = { ACTOR_OBJ_BEAN, ACTORCAT_BG, FLAGS, @@ -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; @@ -147,8 +147,8 @@ s32 func_80936D58(ObjBean* this, GlobalContext* globalCtx) { Math_Vec3f_Sum(&this->dyna.actor.world.pos, &spAC, &spA0); Math_Vec3f_Diff(&this->dyna.actor.world.pos, &spAC, &sp94); - if (BgCheck_EntityLineTest2(&globalCtx->colCtx, &spA0, &sp94, &sp88, &this->dyna.actor.floorPoly, 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; @@ -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,27 @@ 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)) { - Actor_MarkForDeath(&this->dyna.actor); - } else { - func_800BC154(globalCtx, &globalCtx->actorCtx, &this->dyna.actor, 7); - func_80937DD8(this); + if (!func_80936D58(this, play)) { + Actor_Kill(&this->dyna.actor); + return; } + + 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 +394,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 +488,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,13 +504,13 @@ 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))) { - Actor_MarkForDeath(&this->dyna.actor); + if (this->unk_1FF && Flags_GetSwitch(play, OBJBEAN_GET_3F80(&this->dyna.actor, 1))) { + Actor_Kill(&this->dyna.actor); return; } @@ -519,7 +520,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 +528,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 +542,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_IA_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 +564,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 +585,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, PLAYER_CSMODE_1); } this->unk_1E4 = 2; func_80938284(this); @@ -608,12 +609,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 +630,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 +644,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 +656,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 +678,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 +693,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,10 +713,13 @@ 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) { + Actor_Kill(&this->dyna.actor); + return; + } + + if (this->unk_1B2 <= 20) { this->dyna.actor.scale.x *= 0.89f; this->dyna.actor.scale.y *= 0.89f; this->dyna.actor.scale.z *= 0.89f; @@ -729,7 +733,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 +744,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, PLAYER_CSMODE_1); } this->unk_1B4 = 36; func_80937130(this); @@ -760,7 +764,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 +778,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 +796,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 +809,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 +826,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 +841,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 +851,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 +879,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 +893,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 +904,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 +918,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 +934,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); @@ -952,15 +956,15 @@ void func_80938E00(Actor* thisx, GlobalContext* globalCtx) { 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..7699b3427 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 { @@ -59,6 +59,4 @@ typedef struct ObjBean { /* 0x200 */ u8 unk_200; } ObjBean; // size = 0x204 -extern const ActorInit Obj_Bean_InitVars; - #endif // Z_OBJ_BEAN_H diff --git a/src/overlays/actors/ovl_Obj_Bell/overlay.cfg b/src/overlays/actors/ovl_Obj_Bell/overlay.cfg deleted file mode 100644 index 40a295642..000000000 --- a/src/overlays/actors/ovl_Obj_Bell/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Bell -z_obj_bell.c 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 602311116..f8534afea 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.c @@ -11,15 +11,15 @@ #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 = { +ActorInit Obj_Bell_InitVars = { ACTOR_OBJ_BELL, ACTORCAT_PROP, FLAGS, @@ -165,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; @@ -176,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; } @@ -203,16 +203,16 @@ 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) { +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_Translate(0.0f, 2600.0f, 0.0f, MTXMODE_APPLY); @@ -220,75 +220,75 @@ void func_80A359B4(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateXS(thisx->world.rot.x, MTXMODE_APPLY); Matrix_RotateYS(-thisx->world.rot.y, MTXMODE_APPLY); Matrix_Translate(0.0f, -2600.0f, 0.0f, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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) { +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_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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) { +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_MultVec3f(&sp30, &sp24); Math_Vec3f_ToVec3s(&this->collider1.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..a98f29680 100644 --- a/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.h +++ b/src/overlays/actors/ovl_Obj_Bell/z_obj_bell.h @@ -14,12 +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; - #endif // Z_OBJ_BELL_H diff --git a/src/overlays/actors/ovl_Obj_Bigicicle/overlay.cfg b/src/overlays/actors/ovl_Obj_Bigicicle/overlay.cfg deleted file mode 100644 index 7f70ff350..000000000 --- a/src/overlays/actors/ovl_Obj_Bigicicle/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Bigicicle -z_obj_bigicicle.c 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 8a1ae2df7..4b7e9f471 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.c @@ -6,24 +6,25 @@ #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 = { +ActorInit Obj_Bigicicle_InitVars = { ACTOR_OBJ_BIGICICLE, ACTORCAT_PROP, FLAGS, @@ -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,18 +115,18 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, this->actor.params)) { + Actor_Kill(&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); + Actor_Kill(&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..2eb5a00bd 100644 --- a/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h +++ b/src/overlays/actors/ovl_Obj_Bigicicle/z_obj_bigicicle.h @@ -5,20 +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; - #endif // Z_OBJ_BIGICICLE_H diff --git a/src/overlays/actors/ovl_Obj_Blockstop/overlay.cfg b/src/overlays/actors/ovl_Obj_Blockstop/overlay.cfg deleted file mode 100644 index 0c337eb0e..000000000 --- a/src/overlays/actors/ovl_Obj_Blockstop/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Blockstop -z_obj_blockstop.c 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 2d3a6f2d5..437f0c234 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.c @@ -11,13 +11,13 @@ #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 ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx); -void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx); +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, PlayState* play); +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, PlayState* play); -const ActorInit Obj_Blockstop_InitVars = { +ActorInit Obj_Blockstop_InitVars = { ACTOR_OBJ_BLOCKSTOP, ACTORCAT_PROP, FLAGS, @@ -29,17 +29,17 @@ const ActorInit Obj_Blockstop_InitVars = { (ActorFunc)NULL, }; -void ObjBlockstop_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjBlockstop_Init(Actor* thisx, PlayState* play) { ObjBlockstop* this = THIS; - if (Flags_GetSwitch(globalCtx, this->actor.params)) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, this->actor.params)) { + Actor_Kill(&this->actor); } this->actionFunc = ObjBlockstop_CheckForBlock; } -void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx) { - Actor* prop = globalCtx->actorCtx.actorLists[ACTORCAT_PROP].first; +void ObjBlockstop_CheckForBlock(ObjBlockstop* this, PlayState* play) { + Actor* prop = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (prop != NULL) { if ((prop->id == ACTOR_OBJ_OSHIHIKI) && (fabsf(prop->world.pos.x - this->actor.world.pos.x) < 20.0f) && @@ -56,20 +56,20 @@ void ObjBlockstop_CheckForBlock(ObjBlockstop* this, GlobalContext* globalCtx) { } } -void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, GlobalContext* globalCtx) { +void ObjBlockstop_TryPlayCutscene(ObjBlockstop* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { - Flags_SetSwitch(globalCtx, this->actor.params); + Flags_SetSwitch(play, this->actor.params); if (ActorCutscene_GetLength(this->actor.cutscene) != -1) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } ActorCutscene_SetIntentToPlay(this->actor.cutscene); } -void ObjBlockstop_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjBlockstop_Update(Actor* thisx, PlayState* play) { ObjBlockstop* this = THIS; - this->actionFunc(this, globalCtx); + 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..15d45a90b 100644 --- a/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h +++ b/src/overlays/actors/ovl_Obj_Blockstop/z_obj_blockstop.h @@ -5,13 +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; - #endif // Z_OBJ_BLOCKSTOP_H diff --git a/src/overlays/actors/ovl_Obj_Boat/overlay.cfg b/src/overlays/actors/ovl_Obj_Boat/overlay.cfg deleted file mode 100644 index 8617a8228..000000000 --- a/src/overlays/actors/ovl_Obj_Boat/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Boat -z_obj_boat.c 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..c48ff332c 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.c @@ -5,18 +5,20 @@ */ #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); -#if 0 -const ActorInit Obj_Boat_InitVars = { +void func_80B9B428(Actor* thisx, PlayState* play2); + +ActorInit Obj_Boat_InitVars = { ACTOR_OBJ_BOAT, ACTORCAT_BG, FLAGS, @@ -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 != PLAYER_CSMODE_26) { + 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..795c50689 100644 --- a/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h +++ b/src/overlays/actors/ovl_Obj_Boat/z_obj_boat.h @@ -3,13 +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; - #endif // Z_OBJ_BOAT_H diff --git a/src/overlays/actors/ovl_Obj_Bombiwa/overlay.cfg b/src/overlays/actors/ovl_Obj_Bombiwa/overlay.cfg deleted file mode 100644 index d18e4301f..000000000 --- a/src/overlays/actors/ovl_Obj_Bombiwa/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Bombiwa -z_obj_bombiwa.c 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 55304d195..84b2abc63 100644 --- a/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c +++ b/src/overlays/actors/ovl_Obj_Bombiwa/z_obj_bombiwa.c @@ -11,20 +11,20 @@ #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 = { +ActorInit Obj_Bombiwa_InitVars = { ACTOR_OBJ_BOMBIWA, ACTORCAT_PROP, FLAGS, @@ -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))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, OBJBOMBIWA_GET_7F(&this->actor))) { + Actor_Kill(&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); - Actor_MarkForDeath(&this->actor); + func_80939794(this, play); + Actor_Kill(&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,91 +429,88 @@ 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); } } this->unk_201--; if ((this->unk_200 >= 4) || (this->unk_201 <= 0)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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]; @@ -519,12 +519,12 @@ void func_8093A608(Actor* thisx, GlobalContext* globalCtx) { 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..b49a89323 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,16 +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; - #endif // Z_OBJ_BOMBIWA_H diff --git a/src/overlays/actors/ovl_Obj_Boyo/overlay.cfg b/src/overlays/actors/ovl_Obj_Boyo/overlay.cfg deleted file mode 100644 index c024ce5ed..000000000 --- a/src/overlays/actors/ovl_Obj_Boyo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Boyo -z_obj_boyo.c 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..cfecbdad0 100644 --- a/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c +++ b/src/overlays/actors/ovl_Obj_Boyo/z_obj_boyo.c @@ -13,12 +13,12 @@ #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 = { +ActorInit Obj_Boyo_InitVars = { ACTOR_OBJ_BOYO, ACTORCAT_PROP, FLAGS, @@ -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) { @@ -82,7 +82,7 @@ void ObjBoyo_UpdatePlayerBumpValues(ObjBoyo* this, Player* target) { void ObjBoyo_UpdatePirateBumpValues(ObjBoyo* src, EnKaizoku* target) { target->unk_2F0 = 30.0f; - target->unk_2F4 = Actor_YawBetweenActors(&src->actor, &target->actor); + target->unk_2F4 = Actor_YawBetweenActors(&src->actor, &target->picto.actor); } void ObjBoyo_UpdateBombBumpValues(ObjBoyo* src, EnBom* 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..dcff2a893 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; @@ -28,6 +28,4 @@ typedef struct ObjBoyo { /* 0x1AC */ s16 unk_1AC; } ObjBoyo; // size = 0x1B0 -extern const ActorInit Obj_Boyo_InitVars; - #endif // Z_OBJ_BOYO_H diff --git a/src/overlays/actors/ovl_Obj_Chan/overlay.cfg b/src/overlays/actors/ovl_Obj_Chan/overlay.cfg deleted file mode 100644 index 6480f28ff..000000000 --- a/src/overlays/actors/ovl_Obj_Chan/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Chan -z_obj_chan.c 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 c90e5d8f8..27f5cc273 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.c @@ -20,15 +20,15 @@ #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* this2, PlayState* play); +void ObjChan_PotAction(ObjChan* this, PlayState* play); -const ActorInit Obj_Chan_InitVars = { +ActorInit Obj_Chan_InitVars = { ACTOR_OBJ_CHAN, ACTORCAT_BG, FLAGS, @@ -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,39 +77,39 @@ 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; if (OBJCHAN_SUBTYPE(&this->actor) == OBJCHAN_SUBTYPE_CHANDELIER) { if (sObjChanLoaded) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } this->actor.room = -1; sObjChanLoaded = true; } Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sObjChanCylinderInit); + 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) { @@ -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,11 +165,11 @@ 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); + Actor_Kill(&this->actor); return; } @@ -177,18 +177,18 @@ 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; temp_v0->myPotIndex = i; temp_v0->actor.cutscene = this->actor.cutscene; } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } - 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; } @@ -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,11 +284,11 @@ 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; s32 phi_v1; @@ -305,23 +305,23 @@ 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) { - if (!(((void)0, gSaveContext.save.weekEventReg[0x25]) & 0x10)) { - gSaveContext.save.weekEventReg[0x25] = ((void)0, gSaveContext.save.weekEventReg[0x25]) | 0x10; - Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_MM, this->actor.world.pos.x, + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_37_10)) { + SET_WEEKEVENTREG(WEEKEVENTREG_37_10); + 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); } } - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -void ObjChan_CreateSmashParticles(ObjChan* this, GlobalContext* globalCtx) { +void ObjChan_CreateSmashEffects(ObjChan* this, PlayState* play) { s16 new_var = 0; s32 phi_s0; Vec3f spDC; @@ -352,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); + 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_Push(); if (this->stateFlags & OBJCHAN_STATE_ON_FIRE) { - ObjChan_DrawFire(this, globalCtx); + ObjChan_DrawFire(this, play); } 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_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - this->actor.shape.rot.y - this->rotation + 0x8000, + 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_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..f08f18adf 100644 --- a/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h +++ b/src/overlays/actors/ovl_Obj_Chan/z_obj_chan.h @@ -36,27 +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; - #endif // Z_OBJ_CHAN_H diff --git a/src/overlays/actors/ovl_Obj_Chikuwa/overlay.cfg b/src/overlays/actors/ovl_Obj_Chikuwa/overlay.cfg deleted file mode 100644 index d2599907a..000000000 --- a/src/overlays/actors/ovl_Obj_Chikuwa/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Chikuwa -z_obj_chikuwa.c 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..0c888a4ac 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.c @@ -5,18 +5,19 @@ */ #include "z_obj_chikuwa.h" +#include "z64quake.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 = { +ActorInit Obj_Chikuwa_InitVars = { ACTOR_OBJ_CHIKUWA, ACTORCAT_BG, FLAGS, @@ -28,31 +29,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 quakeVerticalMag; + s32 i; + s32 quakeIndex; + + 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)) { + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); + if (temp_fs0 < SQ(120.0f)) { + quakeVerticalMag = 4; + } else { + quakeVerticalMag = 3; + } + + Quake_SetSpeed(quakeIndex, 17232); + Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 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..ee5174246 100644 --- a/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h +++ b/src/overlays/actors/ovl_Obj_Chikuwa/z_obj_chikuwa.h @@ -5,11 +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; - #endif // Z_OBJ_CHIKUWA_H diff --git a/src/overlays/actors/ovl_Obj_Comb/overlay.cfg b/src/overlays/actors/ovl_Obj_Comb/overlay.cfg deleted file mode 100644 index 69f62abc4..000000000 --- a/src/overlays/actors/ovl_Obj_Comb/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Comb -z_obj_comb.c 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 737f9ef46..b03344708 100644 --- a/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c +++ b/src/overlays/actors/ovl_Obj_Comb/z_obj_comb.c @@ -11,18 +11,18 @@ #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 = { +ActorInit Obj_Comb_InitVars = { ACTOR_OBJ_COMB, ACTORCAT_PROP, FLAGS, @@ -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); + if ((sp2C == 1) && OBJCOMB_GET_10(&this->actor) && CHECK_WEEKEVENTREG(WEEKEVENTREG_83_02)) { + Actor_Kill(&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,9 +381,9 @@ 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); - Actor_MarkForDeath(&this->actor); + func_8098CEAC(this, play); + func_8098DA74(this, play); + Actor_Kill(&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,21 +486,21 @@ 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); + Actor_Kill(&this->actor); return; } if ((this->unk_1B4 == 10) && (this->unk_1B6 != 0) && (this->unk_1B5 == 2) && (this->actor.cutscene >= 0)) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { - func_800B7298(globalCtx, &this->actor, 4); + func_800B7298(play, &this->actor, PLAYER_CSMODE_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,12 +529,12 @@ 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, PLAYER_CSMODE_1); } if (((OBJCOMB_GET_8000(&this->actor) | OBJCOMB_GET_80(&this->actor)) == 1) && OBJCOMB_GET_10(&this->actor)) { - gSaveContext.save.weekEventReg[83] |= 2; + SET_WEEKEVENTREG(WEEKEVENTREG_83_02); } this->unk_1B5 = 2; @@ -542,18 +545,18 @@ void ObjComb_Update(Actor* thisx, GlobalContext* globalCtx) { } if (this->unk_1B7 != 0) { - globalCtx->actorCtx.unk5 |= 8; + play->actorCtx.flags |= ACTORCTX_FLAG_3; 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); + 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); @@ -562,10 +565,10 @@ void ObjComb_Draw(Actor* thisx, GlobalContext* globalCtx) { 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..0ee61baaf 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,24 +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; - #endif // Z_OBJ_COMB_H diff --git a/src/overlays/actors/ovl_Obj_Danpeilift/overlay.cfg b/src/overlays/actors/ovl_Obj_Danpeilift/overlay.cfg deleted file mode 100644 index d2836d012..000000000 --- a/src/overlays/actors/ovl_Obj_Danpeilift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Danpeilift -z_obj_danpeilift.c 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..9daa20bad 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.c @@ -10,13 +10,18 @@ #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); -#if 0 -const ActorInit Obj_Danpeilift_InitVars = { +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); + +ActorInit Obj_Danpeilift_InitVars = { ACTOR_OBJ_DANPEILIFT, ACTORCAT_BG, FLAGS, @@ -28,35 +33,172 @@ 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_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/func_80C1ADC0.s") + 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/ObjDanpeilift_Init.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_Destroy.s") +void ObjDanpeilift_DoNothing(ObjDanpeilift* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/func_80C1AF84.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_80C1AF94.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_80C1B210.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_80C1B26C.s") + if (isPosUpdated) { + ObjDanpeilift_UpdatePosition(this, this->curPoint); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Danpeilift/ObjDanpeilift_Update.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_Draw.s") +void ObjDanpeilift_Wait(ObjDanpeilift* this, PlayState* play) { + this->waitTimer--; + if (this->waitTimer <= 0) { + this->actionFunc = ObjDanpeilift_Move; + this->dyna.actor.speedXZ = 0.0f; + } +} + +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..392d5d4ca 100644 --- a/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h +++ b/src/overlays/actors/ovl_Obj_Danpeilift/z_obj_danpeilift.h @@ -2,18 +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; - #endif // Z_OBJ_DANPEILIFT_H diff --git a/src/overlays/actors/ovl_Obj_Demo/overlay.cfg b/src/overlays/actors/ovl_Obj_Demo/overlay.cfg deleted file mode 100644 index feba3b348..000000000 --- a/src/overlays/actors/ovl_Obj_Demo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Demo -z_obj_demo.c 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..060e793ca 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.c @@ -10,14 +10,14 @@ #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 = { +ActorInit Obj_Demo_InitVars = { ACTOR_OBJ_DEMO, ACTORCAT_PROP, FLAGS, @@ -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_Kill(&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->sceneId == SCENE_CASTLE) && (Audio_GetActiveSequence(SEQ_PLAYER_BGM_MAIN) == 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->sceneId == 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_Kill(&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_Kill(&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..065a21fe9 100644 --- a/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h +++ b/src/overlays/actors/ovl_Obj_Demo/z_obj_demo.h @@ -3,16 +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; - #endif // Z_OBJ_DEMO_H diff --git a/src/overlays/actors/ovl_Obj_Dhouse/overlay.cfg b/src/overlays/actors/ovl_Obj_Dhouse/overlay.cfg deleted file mode 100644 index 0e58d0666..000000000 --- a/src/overlays/actors/ovl_Obj_Dhouse/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Dhouse -z_obj_dhouse.c 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 c6eef8626..fce6d99ec 100644 --- a/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c +++ b/src/overlays/actors/ovl_Obj_Dhouse/z_obj_dhouse.c @@ -5,29 +5,30 @@ */ #include "z_obj_dhouse.h" +#include "z64quake.h" #include "objects/object_dhouse/object_dhouse.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_400000) #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* play2); 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 = { +ActorInit Obj_Dhouse_InitVars = { ACTOR_OBJ_DHOUSE, ACTORCAT_BG, FLAGS, @@ -123,27 +124,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 +167,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 +194,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 +209,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,7 +235,7 @@ 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; @@ -263,13 +264,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 +279,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 +308,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 +331,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 +357,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 +373,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 +407,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 +423,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,25 +453,25 @@ void func_80B139D8(ObjDhouse* this) { this->actionFunc = func_80B139F4; } -void func_80B139F4(ObjDhouse* this, GlobalContext* globalCtx) { - Camera* camera = GET_ACTIVE_CAM(globalCtx); - s16 quake; +void func_80B139F4(ObjDhouse* this, PlayState* play) { + Camera* camera = GET_ACTIVE_CAM(play); + s16 quakeIndex; if (this->unk_1370 == 117) { - quake = Quake_Add(camera, 3); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 8, 0, 0, 0); - Quake_SetCountdown(quake, 17); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 8, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 17); } else if (this->unk_1370 == 105) { - quake = Quake_Add(camera, 3); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 7, 0, 0, 0); - Quake_SetCountdown(quake, 20); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 7, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); } else if (this->unk_1370 == 90) { - quake = Quake_Add(camera, 3); - Quake_SetSpeed(quake, 20000); - Quake_SetQuakeValues(quake, 5, 0, 0, 0); - Quake_SetCountdown(quake, 62); + quakeIndex = Quake_Add(camera, QUAKE_TYPE_3); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 5, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 62); } this->unk_1370--; @@ -480,33 +481,33 @@ 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++) { @@ -516,8 +517,7 @@ void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { 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); } @@ -528,15 +528,14 @@ void func_80B13C08(Actor* thisx, GlobalContext* globalCtx) { 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..c03dbed7d 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) @@ -45,6 +45,4 @@ typedef struct ObjDhouse { /* 0x1370 */ s16 unk_1370; } ObjDhouse; // size = 0x1374 -extern const ActorInit Obj_Dhouse_InitVars; - #endif // Z_OBJ_DHOUSE_H diff --git a/src/overlays/actors/ovl_Obj_Dinner/overlay.cfg b/src/overlays/actors/ovl_Obj_Dinner/overlay.cfg deleted file mode 100644 index 3fc58dccd..000000000 --- a/src/overlays/actors/ovl_Obj_Dinner/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Dinner -z_obj_dinner.c 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..5a9ef2d05 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Obj_Dinner_InitVars = { ACTOR_OBJ_DINNER, ACTORCAT_PROP, FLAGS, @@ -28,27 +28,27 @@ 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)) { - Actor_MarkForDeath(&this->actor); + if ((gSaveContext.save.isNight != true) || ((CURRENT_DAY == 3) && CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01))) { + Actor_Kill(&this->actor); } 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_Dinner/z_obj_dinner.h b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.h index 8dc49ee48..a27dce28b 100644 --- a/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.h +++ b/src/overlays/actors/ovl_Obj_Dinner/z_obj_dinner.h @@ -10,6 +10,4 @@ typedef struct ObjDinner { /* 0x144 */ char unk_144[0x4]; } ObjDinner; // size = 0x148 -extern const ActorInit Obj_Dinner_InitVars; - #endif // Z_OBJ_DINNER_H diff --git a/src/overlays/actors/ovl_Obj_Dora/overlay.cfg b/src/overlays/actors/ovl_Obj_Dora/overlay.cfg deleted file mode 100644 index 1bb5f302a..000000000 --- a/src/overlays/actors/ovl_Obj_Dora/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Dora -z_obj_dora.c 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 163dd851d..9b6c81266 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.c @@ -11,17 +11,17 @@ #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, GlobalContext* globalCtx); +void ObjDora_Wait(ObjDora* this, PlayState* play); void ObjDora_SetupMoveGong(ObjDora* this); -void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx); +void ObjDora_MoveGong(ObjDora* this, PlayState* play); s32 ObjDora_IsHalfHour(u16 time); -void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx); +void ObjDora_UpdateCollision(ObjDora* this, PlayState* play); typedef enum { /* 0x0 */ DORA_HIT_NONE, @@ -35,7 +35,7 @@ typedef enum { /* 0xF */ DORA_DMGEFF_LIGHT } ObjDoraDamageEffect; -const ActorInit Obj_Dora_InitVars = { +ActorInit Obj_Dora_InitVars = { ACTOR_OBJ_DORA, ACTORCAT_NPC, FLAGS, @@ -125,7 +125,7 @@ static ColliderTrisInit sTrisInit = { OC2_TYPE_1, COLSHAPE_TRIS, }, - 6, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -166,7 +166,7 @@ static DamageTable sDamageTable = { static CollisionCheckInfoInit2 sColChkInfoInit = { 8, 0, 0, 0, MASS_HEAVY }; -void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjDora_Init(Actor* thisx, PlayState* play) { ObjDora* this = THIS; s32 i; s32 j; @@ -189,8 +189,8 @@ void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { this->gongForce.y = 0.0f; this->gongForce.z = 0.0f; - 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); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, @@ -206,17 +206,17 @@ void ObjDora_Init(Actor* thisx, GlobalContext* globalCtx) { ObjDora_SetupWait(this); } -void ObjDora_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjDora_Destroy(Actor* thisx, PlayState* play) { ObjDora* this = THIS; - Collider_DestroyTris(globalCtx, &this->colliderTris); + Collider_DestroyTris(play, &this->colliderTris); } void ObjDora_SetupWait(ObjDora* this) { this->actionFunc = ObjDora_Wait; } -void ObjDora_Wait(ObjDora* this, GlobalContext* globalCtx) { +void ObjDora_Wait(ObjDora* this, PlayState* play) { } void ObjDora_SetupMoveGong(ObjDora* this) { @@ -234,7 +234,7 @@ void ObjDora_SetupMoveGong(ObjDora* this) { this->actionFunc = ObjDora_MoveGong; } -void ObjDora_MoveGong(ObjDora* this, GlobalContext* globalCtx) { +void ObjDora_MoveGong(ObjDora* this, PlayState* play) { if ((this->gongForce.y < 182.0f) && (this->gongForce.z < 182.0f)) { this->lastGongHitType = DORA_HIT_LIGHT; @@ -261,7 +261,7 @@ s32 ObjDora_IsHalfHour(u16 time) { return false; } -void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx) { +void ObjDora_UpdateCollision(ObjDora* this, PlayState* play) { Actor* itemDrop; u16 time; @@ -281,12 +281,12 @@ void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx) { this->lastGongHitType = DORA_HIT_STRONG; } - func_800BC848(&this->actor, globalCtx, 5, 10); + 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(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_BLUE); + 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; @@ -304,49 +304,49 @@ void ObjDora_UpdateCollision(ObjDora* this, GlobalContext* globalCtx) { if (this->collisionCooldownTimer > 0) { this->collisionCooldownTimer--; } else { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->colliderTris.base); } } -void ObjDora_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjDora_Update(Actor* thisx, PlayState* play) { ObjDora* this = THIS; - this->actionFunc(this, globalCtx); - ObjDora_UpdateCollision(this, globalCtx); + this->actionFunc(this, play); + ObjDora_UpdateCollision(this, play); } -void ObjDora_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjDora_Draw(Actor* thisx, PlayState* play) { static Vec3f position = { 0.0f, -61.5f, 0.0f }; ObjDora* this = THIS; f32 gongForceX; - OPEN_DISPS(globalCtx->state.gfxCtx); - func_8012C28C(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); + func_8012C28C(play->state.gfxCtx); if (this->actionFunc == ObjDora_MoveGong) { gongForceX = this->gongForce.x; - if ((globalCtx->state.frames % 2) != 0) { + if ((play->state.frames % 2) != 0) { gongForceX *= -1.0f; } Matrix_Push(); Matrix_RotateXS(this->gongRotation.x, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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(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++, &gDoraChainDL); Matrix_Pop(); } 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++, &gDoraChainDL); gSPDisplayList(POLY_OPA_DISP++, &gDoraGongDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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 a2dbbea16..3c1b17f2a 100644 --- a/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h +++ b/src/overlays/actors/ovl_Obj_Dora/z_obj_dora.h @@ -5,22 +5,20 @@ struct ObjDora; -typedef void (*ObjDoraActionFunc)(struct ObjDora*, GlobalContext*); +typedef void (*ObjDoraActionFunc)(struct ObjDora*, PlayState*); typedef struct ObjDora { - /* 0x0000 */ Actor actor; - /* 0x0144 */ ColliderTris colliderTris; - /* 0x0164 */ ColliderTrisElement colliderTrisElements[6]; - /* 0x038C */ ObjDoraActionFunc actionFunc; - /* 0x0390 */ Vec3f gongForce; - /* 0x039C */ Vec2s gongAngle; - /* 0x03A0 */ s16 lastGongHitType; - /* 0x03A2 */ Vec2s gongRotation; // gongAngle * gongForce. Used in ObjDora_Draw. - /* 0x03A6 */ s16 rupeeDropTimer; - /* 0x03A8 */ s16 collisionCooldownTimer; - /* 0x03AA */ s16 unk3AA; // Set but not used + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderTris colliderTris; + /* 0x164 */ ColliderTrisElement colliderTrisElements[6]; + /* 0x38C */ ObjDoraActionFunc actionFunc; + /* 0x390 */ Vec3f gongForce; + /* 0x39C */ Vec2s gongAngle; + /* 0x3A0 */ s16 lastGongHitType; + /* 0x3A2 */ Vec2s gongRotation; // gongAngle * gongForce. Used in ObjDora_Draw. + /* 0x3A6 */ s16 rupeeDropTimer; + /* 0x3A8 */ s16 collisionCooldownTimer; + /* 0x3AA */ s16 unk3AA; // Set but not used } ObjDora; // size = 0x3AC -extern const ActorInit Obj_Dora_InitVars; - #endif // Z_OBJ_DORA_H diff --git a/src/overlays/actors/ovl_Obj_Dowsing/overlay.cfg b/src/overlays/actors/ovl_Obj_Dowsing/overlay.cfg deleted file mode 100644 index e8dbfc20a..000000000 --- a/src/overlays/actors/ovl_Obj_Dowsing/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Dowsing -z_obj_dowsing.c 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..01675c173 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.c @@ -1,7 +1,7 @@ /* * File: z_obj_dowsing.c * Overlay: ovl_Obj_Dowsing - * Description: + * Description: Rumbles controller if switch or collectible/chest flag is unset */ #include "z_obj_dowsing.h" @@ -10,14 +10,14 @@ #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 = { +ActorInit Obj_Dowsing_InitVars = { ACTOR_OBJ_DOWSING, ACTORCAT_ITEMACTION, FLAGS, @@ -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)) { - Actor_MarkForDeath(&this->actor); +s32 ObjDowsing_CheckValidSpawn(ObjDowsing* this, PlayState* play) { + if (ObjDowsing_GetFlag(this, play)) { + Actor_Kill(&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_Dowsing/z_obj_dowsing.h b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h index 7b1125a28..879c99d80 100644 --- a/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h +++ b/src/overlays/actors/ovl_Obj_Dowsing/z_obj_dowsing.h @@ -18,6 +18,4 @@ typedef struct ObjDowsing { /* 0x000 */ Actor actor; } ObjDowsing; // size = 0x144 -extern const ActorInit Obj_Dowsing_InitVars; - #endif // Z_OBJ_DOWSING_H diff --git a/src/overlays/actors/ovl_Obj_Driftice/overlay.cfg b/src/overlays/actors/ovl_Obj_Driftice/overlay.cfg deleted file mode 100644 index 1b85d29a1..000000000 --- a/src/overlays/actors/ovl_Obj_Driftice/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Driftice -z_obj_driftice.c 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 abc8d6c85..f0eaaf25a 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -11,21 +11,21 @@ #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 = { +ActorInit Obj_Driftice_InitVars = { ACTOR_OBJ_DRIFTICE, ACTORCAT_BG, FLAGS, @@ -264,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)]; @@ -302,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; @@ -320,24 +320,24 @@ 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; } -void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { +void func_80A671E0(ObjDriftice* this, PlayState* play) { f32 phi_f0; Vec3f sp40; f32 sp3C; @@ -389,7 +389,7 @@ void func_80A671E0(ObjDriftice* this, GlobalContext* globalCtx) { 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; } } @@ -405,10 +405,10 @@ 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); } } @@ -418,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; @@ -426,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)) { @@ -445,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..21e0f8f27 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,20 +42,20 @@ 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; +extern ActorInit Obj_Driftice_InitVars; #endif // Z_OBJ_DRIFTICE_H diff --git a/src/overlays/actors/ovl_Obj_Ending/overlay.cfg b/src/overlays/actors/ovl_Obj_Ending/overlay.cfg deleted file mode 100644 index 4930e5226..000000000 --- a/src/overlays/actors/ovl_Obj_Ending/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Ending -z_obj_ending.c 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..fd2bf4c02 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.c @@ -11,11 +11,11 @@ #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 = { +ActorInit Obj_Ending_InitVars = { ACTOR_OBJ_ENDING, ACTORCAT_BG, FLAGS, @@ -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_Ending/z_obj_ending.h b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.h index 163134f36..dfe6a83ea 100644 --- a/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.h +++ b/src/overlays/actors/ovl_Obj_Ending/z_obj_ending.h @@ -16,6 +16,4 @@ typedef struct ObjEnding { /* 0x148 */ AnimatedMaterial* animMat; } ObjEnding; // size = 0x14C -extern const ActorInit Obj_Ending_InitVars; - #endif // Z_OBJ_ENDING_H diff --git a/src/overlays/actors/ovl_Obj_Entotu/overlay.cfg b/src/overlays/actors/ovl_Obj_Entotu/overlay.cfg deleted file mode 100644 index 55d5ebe5f..000000000 --- a/src/overlays/actors/ovl_Obj_Entotu/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Entotu -z_obj_entotu.c 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 7d662432a..723dfcf3e 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Obj_Entotu_InitVars = { ACTOR_OBJ_ENTOTU, ACTORCAT_PROP, FLAGS, @@ -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) { +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(globalCtx))); + 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; @@ -130,25 +130,25 @@ void func_80A34B28(ObjEntotu* this, GlobalContext* globalCtx) { if (this->unk_1B8.x > 0.0f) { Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + 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)); @@ -156,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_Entotu/z_obj_entotu.h b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h index a00a7fcd4..ba667b6c7 100644 --- a/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h +++ b/src/overlays/actors/ovl_Obj_Entotu/z_obj_entotu.h @@ -14,6 +14,4 @@ typedef struct ObjEntotu { /* 0x1C6 */ s16 unk_1C6; } ObjEntotu; // size = 0x1C8 -extern const ActorInit Obj_Entotu_InitVars; - #endif // Z_OBJ_ENTOTU_H diff --git a/src/overlays/actors/ovl_Obj_Etcetera/overlay.cfg b/src/overlays/actors/ovl_Obj_Etcetera/overlay.cfg deleted file mode 100644 index d8a239068..000000000 --- a/src/overlays/actors/ovl_Obj_Etcetera/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Etcetera -z_obj_etcetera.c 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..ceedeb6c4 100644 --- a/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c +++ b/src/overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.c @@ -5,23 +5,22 @@ */ #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 = { +ActorInit Obj_Etcetera_InitVars = { ACTOR_OBJ_ETCETERA, ACTORCAT_BG, FLAGS, @@ -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)) { + if ((player->stateFlags3 & PLAYER_STATE3_200) && (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); @@ -145,7 +146,7 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { this->bounceOscillationScale = 0.003f; this->oscillationTimer = 30; this->burrowFlag &= ~1; - } else if ((player->stateFlags3 & 0x2000) && (this->dyna.actor.xzDistToPlayer < 30.0f) && + } else if ((player->stateFlags3 & PLAYER_STATE3_2000) && (this->dyna.actor.xzDistToPlayer < 30.0f) && (this->dyna.actor.playerHeightRel > 0.0f)) { // Player is hovering above the Deku Flower minOscillationTimer = 10 - (s32)(this->dyna.actor.playerHeightRel * 0.05f); @@ -158,11 +159,13 @@ void ObjEtcetera_Idle(ObjEtcetera* this, GlobalContext* globalCtx) { // Player is walking onto the Deku Flower, or falling on it from a height this->oscillationTimer = 10; ObjEtcetera_StartRustleAnimation(this); - } else if ((player->actor.speedXZ > 0.1f) || ((player->unk_ABC < 0.0f) && !(player->stateFlags3 & 0x100))) { + } else if ((player->actor.speedXZ > 0.1f) || + ((player->unk_ABC < 0.0f) && !(player->stateFlags3 & PLAYER_STATE3_100))) { // Player is walking on top of the Deku Flower, is at the very start of burrowing, or is at the very // start of launching this->oscillationTimer = 10; } + this->burrowFlag |= 1; } else { if (this->burrowFlag & 1) { @@ -170,27 +173,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 +206,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 +218,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 +232,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 +240,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 +257,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 +297,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 +314,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 +322,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 +335,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 +352,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..1805e151a 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; @@ -51,6 +33,4 @@ typedef struct ObjEtcetera { /* 0x280 */ ObjEtceteraActionFunc actionFunc; } ObjEtcetera; // size = 0x284 -extern const ActorInit Obj_Etcetera_InitVars; - #endif // Z_OBJ_ETCETERA_H diff --git a/src/overlays/actors/ovl_Obj_Fireshield/overlay.cfg b/src/overlays/actors/ovl_Obj_Fireshield/overlay.cfg deleted file mode 100644 index e5006379a..000000000 --- a/src/overlays/actors/ovl_Obj_Fireshield/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Fireshield -z_obj_fireshield.c 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..a4c4e21d2 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); @@ -22,7 +22,7 @@ void func_80A4CC54(ObjFireshield* this); void func_80A4CCBC(ObjFireshield* this); void func_80A4CD28(ObjFireshield* this); -const ActorInit Obj_Fireshield_InitVars = { +ActorInit Obj_Fireshield_InitVars = { ACTOR_OBJ_FIRESHIELD, ACTORCAT_PROP, FLAGS, @@ -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..ffe1d7a35 100644 --- a/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h +++ b/src/overlays/actors/ovl_Obj_Fireshield/z_obj_fireshield.h @@ -15,19 +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; - #endif // Z_OBJ_FIRESHIELD_H diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/overlay.cfg b/src/overlays/actors/ovl_Obj_Flowerpot/overlay.cfg deleted file mode 100644 index f6aa9dc16..000000000 --- a/src/overlays/actors/ovl_Obj_Flowerpot/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Flowerpot -z_obj_flowerpot.c 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 57964559d..49e8ac934 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -11,27 +11,27 @@ #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* play2); +void ObjFlowerpot_Update(Actor* thisx, PlayState* play2); +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 = { +ActorInit Obj_Flowerpot_InitVars = { ACTOR_OBJ_FLOWERPOT, ACTORCAT_PROP, FLAGS, @@ -77,19 +77,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 +145,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]; @@ -177,8 +177,8 @@ void func_80A1B3D0(void) { void func_80A1B840(MtxF* matrix) { MtxF* temp = Matrix_GetCurrent(); - f32* tmp = (f32*)&temp->mf[0]; - f32* tmp2 = (f32*)&matrix->mf[0]; + f32* tmp = &temp->xx; + f32* tmp2 = &matrix->xx; s32 i; for (i = 0; i < 16; i++) { @@ -186,25 +186,25 @@ 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) { @@ -213,7 +213,7 @@ void func_80A1BA04(ObjFlowerpot* this, Vec3f* arg1) { 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 +253,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 +296,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 +305,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 +336,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 +363,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,28 +382,28 @@ 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.curRoom.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); + 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); @@ -415,24 +415,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 +440,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 +457,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); - Actor_MarkForDeath(&this->actor); + func_80A1BD80(this, play); + func_80A1B994(this, play); + Actor_Kill(&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); - Actor_MarkForDeath(&this->actor); + func_80A1BA44(this, play); + func_80A1B994(this, play); + Actor_Kill(&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 +509,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 +530,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.curRoom.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 +554,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 +587,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,32 +599,32 @@ 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); - Actor_MarkForDeath(&this->actor); + func_80A1BA44(this, play); + func_80A1B994(this, play); + Actor_Kill(&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); - Actor_MarkForDeath(&this->actor); + func_80A1BD80(this, play); + func_80A1B994(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EV_DIVE_INTO_WATER_L); + Actor_Kill(&this->actor); return; } @@ -640,34 +640,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.curRoom.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 +678,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.curRoom.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 +690,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..ec1ec43bb 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.h @@ -5,22 +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; - #endif // Z_OBJ_FLOWERPOT_H diff --git a/src/overlays/actors/ovl_Obj_Funen/overlay.cfg b/src/overlays/actors/ovl_Obj_Funen/overlay.cfg deleted file mode 100644 index e67ba5e19..000000000 --- a/src/overlays/actors/ovl_Obj_Funen/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Funen -z_obj_funen.c 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 7bdaa8654..c3d4d1398 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.c @@ -11,10 +11,10 @@ #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 = { +ActorInit Obj_Funen_InitVars = { ACTOR_OBJ_FUNEN, ACTORCAT_PROP, FLAGS, OBJECT_FUNEN, sizeof(ObjFunen), (ActorFunc)ObjFunen_Init, (ActorFunc)Actor_Noop, (ActorFunc)Actor_Noop, (ActorFunc)ObjFunen_Draw, @@ -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_RotateYS((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_Funen/z_obj_funen.h b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.h index dfafc94cf..eb7ca5e2b 100644 --- a/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.h +++ b/src/overlays/actors/ovl_Obj_Funen/z_obj_funen.h @@ -9,6 +9,4 @@ typedef struct ObjFunen { /* 0x000 */ Actor actor; } ObjFunen; // size = 0x144 -extern const ActorInit Obj_Funen_InitVars; - #endif // Z_OBJ_FUNEN_H diff --git a/src/overlays/actors/ovl_Obj_Ghaka/overlay.cfg b/src/overlays/actors/ovl_Obj_Ghaka/overlay.cfg deleted file mode 100644 index c760e169f..000000000 --- a/src/overlays/actors/ovl_Obj_Ghaka/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Ghaka -z_obj_ghaka.c 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..0581706d5 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.c @@ -11,20 +11,20 @@ #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 = { +ActorInit Obj_Ghaka_InitVars = { ACTOR_OBJ_GHAKA, ACTORCAT_PROP, FLAGS, @@ -44,7 +44,7 @@ static InitChainEntry D_80B3C96C[] = { }; void func_80B3C260(ObjGhaka* this) { - if (gSaveContext.save.weekEventReg[20] & 0x20) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_20)) { this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + 100.0f; } this->actionFunc = func_80B3C39C; @@ -58,25 +58,25 @@ void func_80B3C2B0(ObjGhaka* this) { this->actionFunc = func_80B3C624; } -void func_80B3C2C4(ObjGhaka* this, GlobalContext* globalCtx) { - 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); +void func_80B3C2C4(ObjGhaka* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_20)) { + 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 { @@ -85,58 +85,61 @@ void func_80B3C39C(ObjGhaka* this, GlobalContext* globalCtx) { } } - if (this->dyna.pushForce < 0.0f && !(gSaveContext.save.weekEventReg[20] & 0x20) && + if (this->dyna.pushForce < 0.0f && !CHECK_WEEKEVENTREG(WEEKEVENTREG_20_20) && player->transformation == PLAYER_FORM_GORON) { func_80B3C2B0(this); } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } } -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; if (stepTemp) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; - func_80B3C2C4(this, globalCtx); - gSaveContext.save.weekEventReg[20] |= 0x20; + func_80B3C2C4(this, play); + SET_WEEKEVENTREG(WEEKEVENTREG_20_20); func_80B3C260(this); Audio_PlaySfxAtPos(&D_80B3C960, NA_SE_EV_BLOCK_BOUND); } else { @@ -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); + Actor_Kill(&this->dyna.actor); } - if (gSaveContext.save.weekEventReg[20] & 0x20) { - func_80B3C2C4(this, globalCtx); + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_20)) { + 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..5eb92f1e6 100644 --- a/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.h +++ b/src/overlays/actors/ovl_Obj_Ghaka/z_obj_ghaka.h @@ -5,15 +5,13 @@ 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 -extern const ActorInit Obj_Ghaka_InitVars; - #endif // Z_OBJ_GHAKA_H diff --git a/src/overlays/actors/ovl_Obj_Grass/overlay.cfg b/src/overlays/actors/ovl_Obj_Grass/overlay.cfg deleted file mode 100644 index 6aec3207d..000000000 --- a/src/overlays/actors/ovl_Obj_Grass/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Grass -z_obj_grass.c 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 51f2febc7..3414aaafa 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]; @@ -24,7 +26,7 @@ f32 D_809AAE10[20]; #include "overlays/ovl_Obj_Grass/ovl_Obj_Grass.c" -const ActorInit Obj_Grass_InitVars = { +ActorInit Obj_Grass_InitVars = { ACTOR_OBJ_GRASS, ACTORCAT_PROP, FLAGS, @@ -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; } } @@ -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,9 +450,9 @@ 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]; @@ -463,7 +465,7 @@ void func_809AA54C(Actor* thisx, GlobalContext* globalCtx2) { 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); @@ -500,7 +502,7 @@ void func_809AA798(Actor* thisx, GlobalContext* globalCtx) { 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..fffcdad4e 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 { @@ -44,6 +43,4 @@ typedef struct ObjGrass { /* 0x3298 */ struct ObjGrassCarry* unk_3298[2]; } ObjGrass; // size = 0x32A0 -extern const ActorInit Obj_Grass_InitVars; - #endif // Z_OBJ_GRASS_H diff --git a/src/overlays/actors/ovl_Obj_Grass_Carry/overlay.cfg b/src/overlays/actors/ovl_Obj_Grass_Carry/overlay.cfg deleted file mode 100644 index 41ae3cfcd..000000000 --- a/src/overlays/actors/ovl_Obj_Grass_Carry/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Grass_Carry -z_obj_grass_carry.c 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..9872fb0b7 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,23 +13,23 @@ #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 = { +ActorInit Obj_Grass_Carry_InitVars = { ACTOR_OBJ_GRASS_CARRY, ACTORCAT_PROP, FLAGS, @@ -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,26 +335,26 @@ 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) { if ((this->actionFunc != func_809AB610) && (this->actionFunc != func_809AB77C)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } - 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, gKusaBushType1DL); } 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..fa870305e 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,18 +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; - #endif // Z_OBJ_GRASS_CARRY_H diff --git a/src/overlays/actors/ovl_Obj_Grass_Unit/overlay.cfg b/src/overlays/actors/ovl_Obj_Grass_Unit/overlay.cfg deleted file mode 100644 index d67028b99..000000000 --- a/src/overlays/actors/ovl_Obj_Grass_Unit/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Grass_Unit -z_obj_grass_unit.c 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..c57ed608f 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,10 +10,10 @@ #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 = { +ActorInit Obj_Grass_Unit_InitVars = { ACTOR_OBJ_GRASS_UNIT, ACTORCAT_BG, FLAGS, diff --git a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h index 113132e5e..58a8a427a 100644 --- a/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h +++ b/src/overlays/actors/ovl_Obj_Grass_Unit/z_obj_grass_unit.h @@ -9,6 +9,4 @@ typedef struct ObjGrassUnit { /* 0x000 */ Actor actor; } ObjGrassUnit; // size = 0x144 -extern const ActorInit Obj_Grass_Unit_InitVars; - #endif // Z_OBJ_GRASS_UNIT_H diff --git a/src/overlays/actors/ovl_Obj_Hakaisi/overlay.cfg b/src/overlays/actors/ovl_Obj_Hakaisi/overlay.cfg deleted file mode 100644 index 5d1fb24ad..000000000 --- a/src/overlays/actors/ovl_Obj_Hakaisi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Hakaisi -z_obj_hakaisi.c 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 d3199e8d8..9c38849c9 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.c @@ -11,33 +11,33 @@ #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 = { +ActorInit Obj_Hakaisi_InitVars = { ACTOR_OBJ_HAKAISI, ACTORCAT_PROP, FLAGS, @@ -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,14 +119,14 @@ void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { this->switchFlag = -1; } - if ((this->switchFlag != -1) && Flags_GetSwitch(globalCtx, this->switchFlag)) { - Actor_MarkForDeath(&this->dyna.actor); + if ((this->switchFlag != -1) && Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&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); + Actor_Kill(&this->dyna.actor); } func_800C0094(this->dyna.actor.floorPoly, this->dyna.actor.world.pos.x, this->dyna.actor.floorHeight, @@ -149,11 +149,11 @@ void ObjHakaisi_Init(Actor* thisx, GlobalContext* globalCtx) { 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,7 +379,7 @@ 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) { @@ -389,14 +389,14 @@ void func_80B15264(ObjHakaisi* this) { 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,9 +404,9 @@ 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); - Actor_MarkForDeath(&this->dyna.actor); + func_80B14B6C(this, play, this->dyna.actor.world.pos, 40); + func_80B14CF8(play, this->dyna.actor.world.pos, 100, 30, 10); + Actor_Kill(&this->dyna.actor); } Matrix_RotateAxisS(this->unk_19C, &this->unk_184, MTXMODE_NEW); @@ -418,26 +418,26 @@ void func_80B15330(ObjHakaisi* this, GlobalContext* globalCtx) { 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..ed5341a82 100644 --- a/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h +++ b/src/overlays/actors/ovl_Obj_Hakaisi/z_obj_hakaisi.h @@ -5,25 +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; - #endif // Z_OBJ_HAKAISI_H diff --git a/src/overlays/actors/ovl_Obj_Hamishi/overlay.cfg b/src/overlays/actors/ovl_Obj_Hamishi/overlay.cfg deleted file mode 100644 index 902311cdc..000000000 --- a/src/overlays/actors/ovl_Obj_Hamishi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Hamishi -z_obj_hamishi.c 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..752b669cf 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Obj_Hamishi_InitVars = { ACTOR_OBJ_HAMISHI, ACTORCAT_PROP, FLAGS, @@ -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))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, OBJHAMISHI_GET_SWITCHFLAG(&this->actor))) { + Actor_Kill(&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,10 +230,10 @@ 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)); - Actor_MarkForDeath(&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_Kill(&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_Hamishi/z_obj_hamishi.h b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h index da838d480..962a59612 100644 --- a/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h +++ b/src/overlays/actors/ovl_Obj_Hamishi/z_obj_hamishi.h @@ -21,6 +21,4 @@ typedef struct ObjHamishi { /* 0x1A2 */ u8 unk_1A2; } ObjHamishi; // size = 0x1A4 -extern const ActorInit Obj_Hamishi_InitVars; - #endif // Z_OBJ_HAMISHI_H diff --git a/src/overlays/actors/ovl_Obj_Hana/overlay.cfg b/src/overlays/actors/ovl_Obj_Hana/overlay.cfg deleted file mode 100644 index 8d04d632c..000000000 --- a/src/overlays/actors/ovl_Obj_Hana/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Hana -z_obj_hana.c 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..97fbbec3d 100644 --- a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c +++ b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Obj_Hana_InitVars = { ACTOR_OBJ_HANA, ACTORCAT_PROP, FLAGS, @@ -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_Hana/z_obj_hana.h b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.h index f885850cd..dd8c4676c 100644 --- a/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.h +++ b/src/overlays/actors/ovl_Obj_Hana/z_obj_hana.h @@ -9,6 +9,4 @@ typedef struct ObjHana { /* 0x000 */ Actor actor; } ObjHana; // size = 0x144 -extern const ActorInit Obj_Hana_InitVars; - #endif // Z_OBJ_HANA_H diff --git a/src/overlays/actors/ovl_Obj_Hariko/overlay.cfg b/src/overlays/actors/ovl_Obj_Hariko/overlay.cfg deleted file mode 100644 index 98c352eb4..000000000 --- a/src/overlays/actors/ovl_Obj_Hariko/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Hariko -z_obj_hariko.c 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 840488810..1c33af7fe 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.c @@ -5,24 +5,25 @@ */ #include "z_obj_hariko.h" +#include "z64quake.h" #include "assets/objects/object_hariko/object_hariko.h" #define FLAGS (ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #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 = { +ActorInit Obj_Hariko_InitVars = { ACTOR_OBJ_HARIKO, ACTORCAT_PROP, FLAGS, @@ -34,7 +35,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 +47,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 +63,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 +79,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_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_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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..88a51a83f 100644 --- a/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h +++ b/src/overlays/actors/ovl_Obj_Hariko/z_obj_hariko.h @@ -5,17 +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; - #endif // Z_OBJ_HARIKO_H diff --git a/src/overlays/actors/ovl_Obj_Hgdoor/overlay.cfg b/src/overlays/actors/ovl_Obj_Hgdoor/overlay.cfg deleted file mode 100644 index 4bd3103fb..000000000 --- a/src/overlays/actors/ovl_Obj_Hgdoor/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Hgdoor -z_obj_hgdoor.c 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..e3972be18 100644 --- a/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c +++ b/src/overlays/actors/ovl_Obj_Hgdoor/z_obj_hgdoor.c @@ -11,22 +11,22 @@ #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 func_80BD42AC(ObjHgdoor* this); -void func_80BD42C0(ObjHgdoor* this, GlobalContext* globalCtx); -void func_80BD433C(ObjHgdoor* this); -void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx); -void func_80BD4460(ObjHgdoor* this); -void func_80BD4478(ObjHgdoor* this, GlobalContext* globalCtx); -s32 func_80BD44D0(ObjHgdoor* this, GlobalContext* globalCtx); +void ObjHgdoor_SetupIdle(ObjHgdoor* this); +void ObjHgdoor_Idle(ObjHgdoor* this, PlayState* play); +void ObjHgdoor_SetupCutscene(ObjHgdoor* this); +void ObjHgdoor_PlayCutscene(ObjHgdoor* this, PlayState* play); +void ObjHgdoor_SetupCsAction(ObjHgdoor* this); +void ObjHgdoor_HandleCsAction(ObjHgdoor* this, PlayState* play); +void ObjHgdoor_SetupStopCs(ObjHgdoor* this); +void ObjHgdoor_StopCs(ObjHgdoor* this, PlayState* play); +s32 ObjHgdoor_Rotate(ObjHgdoor* this, PlayState* play); -const ActorInit Obj_Hgdoor_InitVars = { +ActorInit Obj_Hgdoor_InitVars = { ACTOR_OBJ_HGDOOR, ACTORCAT_PROP, FLAGS, @@ -38,12 +38,10 @@ const ActorInit Obj_Hgdoor_InitVars = { (ActorFunc)ObjHgdoor_Draw, }; -static s16 D_80BD4690 = 0; -static s32 unused = 0; -static s32 unused2 = 0; +static s16 sOpenFlag = 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 +52,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 +64,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,42 +76,42 @@ 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); + ObjHgdoor_SetupIdle(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_SetupIdle(ObjHgdoor* this) { + this->actionFunc = ObjHgdoor_Idle; } -void ObjHgdoor_CheckShouldOpen(ObjHgdoor* this, GlobalContext* globalCtx) { - if (!(gSaveContext.save.weekEventReg[75] & 0x20) && !(gSaveContext.save.weekEventReg[52] & 0x20) && +void ObjHgdoor_Idle(ObjHgdoor* this, PlayState* play) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20) && (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); - func_80BD42AC(this); + ObjHgdoor_SetChild(this, play); + ObjHgdoor_SetParent(this, play); + ObjHgdoor_SetupCutscene(this); } } -void func_80BD42AC(ObjHgdoor* this) { - this->actionFunc = func_80BD42C0; +void ObjHgdoor_SetupCutscene(ObjHgdoor* this) { + this->actionFunc = ObjHgdoor_PlayCutscene; } -void func_80BD42C0(ObjHgdoor* this, GlobalContext* globalCtx) { +void ObjHgdoor_PlayCutscene(ObjHgdoor* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->dyna.actor); - func_80BD433C(this); - func_80BD433C((ObjHgdoor*)this->dyna.actor.child); + ObjHgdoor_SetupCsAction(this); + ObjHgdoor_SetupCsAction((ObjHgdoor*)this->dyna.actor.child); } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); @@ -122,50 +120,58 @@ void func_80BD42C0(ObjHgdoor* this, GlobalContext* globalCtx) { } } -void func_80BD433C(ObjHgdoor* this) { - this->unk166 = 0x63; - this->actionFunc = func_80BD4358; +void ObjHgdoor_SetupCsAction(ObjHgdoor* this) { + this->csAction = 0x63; + this->actionFunc = ObjHgdoor_HandleCsAction; } -void func_80BD4358(ObjHgdoor* this, GlobalContext* globalCtx) { +void ObjHgdoor_HandleCsAction(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->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = 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)) { this->dyna.actor.parent->colChkInfo.health = 1; } - D_80BD4690 = 1; + sOpenFlag = 1; break; + case 2: break; } } - if ((D_80BD4690 == 1) && (func_80BD44D0(this, globalCtx))) { - func_80BD4460(this); + if ((sOpenFlag == 1) && ObjHgdoor_Rotate(this, play)) { + ObjHgdoor_SetupStopCs(this); } } else { - this->unk166 = 0x63; + this->csAction = 0x63; } } -void func_80BD4460(ObjHgdoor* this) { +void ObjHgdoor_SetupStopCs(ObjHgdoor* this) { this->timer = 0; - this->actionFunc = func_80BD4478; + this->actionFunc = ObjHgdoor_StopCs; } -void func_80BD4478(ObjHgdoor* this, GlobalContext* globalCtx) { - if (this->timer++ > 80 && !ActorCutscene_GetCanPlayNext(this->cutscene)) { - ActorCutscene_Stop(this->cutscene); +void ObjHgdoor_StopCs(ObjHgdoor* this, PlayState* play) { + if (this->timer++ > 80) { + if (!ActorCutscene_GetCanPlayNext(this->cutscene)) { + ActorCutscene_Stop(this->cutscene); + } } } -s32 func_80BD44D0(ObjHgdoor* this, GlobalContext* globalCtx) { +/** + * @brief Function to increment the rotation angle of the door + * + * @return true when door is fully open, false otherwise + */ +s32 ObjHgdoor_Rotate(ObjHgdoor* this, PlayState* play) { if (this->rotation < 0x5555) { this->rotation += 0x1388; } else { @@ -175,7 +181,7 @@ s32 func_80BD44D0(ObjHgdoor* this, GlobalContext* globalCtx) { return false; } -void func_80BD4500(ObjHgdoor* this) { +void ObjHgdoor_Open(ObjHgdoor* this) { this->dyna.actor.shape.rot.y = this->dyna.actor.home.rot.y; if (OBJHGDOOR_IS_RIGHT_DOOR(&this->dyna.actor)) { this->dyna.actor.shape.rot.y += this->rotation; @@ -184,18 +190,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); - func_80BD4500(this); + this->actionFunc(this, play); + ObjHgdoor_Open(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 +210,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..7172952bb 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 @@ -16,9 +16,7 @@ typedef struct ObjHgdoor { /* 0x160 */ s16 cutscene; /* 0x162 */ s16 rotation; /* 0x164 */ s16 timer; - /* 0x166 */ u16 unk166; + /* 0x166 */ u16 csAction; } ObjHgdoor; // size = 0x168 -extern const ActorInit Obj_Hgdoor_InitVars; - #endif // Z_OBJ_HGDOOR_H diff --git a/src/overlays/actors/ovl_Obj_HsStump/overlay.cfg b/src/overlays/actors/ovl_Obj_HsStump/overlay.cfg deleted file mode 100644 index ddf618a65..000000000 --- a/src/overlays/actors/ovl_Obj_HsStump/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_HsStump -z_obj_hsstump.c 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..ae047f029 100644 --- a/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c +++ b/src/overlays/actors/ovl_Obj_HsStump/z_obj_hsstump.c @@ -11,17 +11,17 @@ #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 = { +ActorInit Obj_HsStump_InitVars = { ACTOR_OBJ_HSSTUMP, ACTORCAT_BG, FLAGS, @@ -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..0f06fdfaf 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; @@ -20,6 +20,4 @@ typedef struct ObjHsStump { /* 0x168 */ f32 rotFactor; } ObjHsStump; // size = 0x16C -extern const ActorInit Obj_HsStump_InitVars; - #endif // Z_OBJ_HSSTUMP_H diff --git a/src/overlays/actors/ovl_Obj_Hsblock/overlay.cfg b/src/overlays/actors/ovl_Obj_Hsblock/overlay.cfg deleted file mode 100644 index 19cd6470b..000000000 --- a/src/overlays/actors/ovl_Obj_Hsblock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Hsblock -z_obj_hsblock.c 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..26d89f00d 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c @@ -5,22 +5,25 @@ */ #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 = { +ActorInit Obj_Hsblock_InitVars = { ACTOR_OBJ_HSBLOCK, ACTORCAT_BG, FLAGS, @@ -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..f91926409 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h @@ -3,16 +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; - #endif // Z_OBJ_HSBLOCK_H diff --git a/src/overlays/actors/ovl_Obj_Hugebombiwa/overlay.cfg b/src/overlays/actors/ovl_Obj_Hugebombiwa/overlay.cfg deleted file mode 100644 index baf0417f6..000000000 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Hugebombiwa -z_obj_hugebombiwa.c 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 3fc7f84b1..cade13522 100644 --- a/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c +++ b/src/overlays/actors/ovl_Obj_Hugebombiwa/z_obj_hugebombiwa.c @@ -5,28 +5,30 @@ */ #include "z_obj_hugebombiwa.h" +#include "z64quake.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* play2); +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 = { +ActorInit Obj_Hugebombiwa_InitVars = { ACTOR_OBJ_HUGEBOMBIWA, ACTORCAT_PROP, FLAGS, @@ -60,7 +62,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 +107,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 +165,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 +174,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 +209,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 +224,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 +238,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 +280,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 +289,19 @@ 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 ObjHugebombiwa_AddQuake(ObjHugebombiwa* this, PlayState* play, s32 quakeVerticalMag) { s32 pad[2]; - s16 quake = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + s16 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_3); - Quake_SetSpeed(quake, 0x4E20); - Quake_SetQuakeValues(quake, arg2, 0, 0, 0); - Quake_SetCountdown(quake, 7); - func_8013ECE0(this->actor.xyzDistToPlayerSq, 255, 20, 150); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, quakeVerticalMag, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); + + Rumble_Request(this->actor.xyzDistToPlayerSq, 255, 20, 150); } s32 func_80A54A0C(ObjHugebombiwa* this) { @@ -330,19 +333,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))) { - Actor_MarkForDeath(&this->actor); + if (Flags_GetSwitch(play, ENHUGEBOMBIWA_GET_7F(&this->actor))) { + Actor_Kill(&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 +361,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 +396,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))) { - gSaveContext.save.weekEventReg[19] |= 2; + ((play->sceneId == SCENE_17SETUGEN) || (play->sceneId == SCENE_17SETUGEN2))) { + SET_WEEKEVENTREG(WEEKEVENTREG_19_02); } 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 { @@ -463,7 +466,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; @@ -475,7 +478,7 @@ void func_80A54E10(ObjHugebombiwa* this) { 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 +510,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) { + ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } @@ -521,7 +524,7 @@ void func_80A55064(ObjHugebombiwa* this, GlobalContext* globalCtx) { this->unk_4B2--; if ((this->unk_4B0 >= 20) || (this->unk_4B2 <= 0)) { ActorCutscene_Stop(this->actor.cutscene); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } @@ -558,7 +561,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); @@ -571,7 +574,7 @@ void func_80A55310(ObjHugebombiwa* this) { 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 +606,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) { + ObjHugebombiwa_AddQuake(this, play, (s32)(Rand_ZeroOne() * 5.5f) + 1); } } } @@ -617,46 +620,43 @@ void func_80A55564(ObjHugebombiwa* this, GlobalContext* globalCtx) { this->unk_4B2--; if ((this->unk_4B0 >= 20) || (this->unk_4B2 <= 0)) { ActorCutscene_Stop(this->actor.cutscene); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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); } @@ -674,7 +674,7 @@ void ObjHugebombiwa_Draw(Actor* thisx, GlobalContext* globalCtx) { 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 +682,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]); @@ -713,11 +713,11 @@ void func_80A55B34(Actor* thisx, GlobalContext* globalCtx) { Matrix_Scale(ptr->unk_00.x, ptr->unk_00.y, ptr->unk_00.z, 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..932a61c3d 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,15 +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; - #endif // Z_OBJ_HUGEBOMBIWA_H diff --git a/src/overlays/actors/ovl_Obj_Hunsui/overlay.cfg b/src/overlays/actors/ovl_Obj_Hunsui/overlay.cfg deleted file mode 100644 index 939fc3564..000000000 --- a/src/overlays/actors/ovl_Obj_Hunsui/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Hunsui -z_obj_hunsui.c 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..f35d270a0 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; @@ -47,7 +46,7 @@ ObjHansuiStruct D_80B9DC70[] = { { 3, 3 }, { 3, 5 }, { 3, 1 }, { 3, 6 }, { 3, 2 }, { 3, 4 }, { 3, 0 }, }; -const ActorInit Obj_Hunsui_InitVars = { +ActorInit Obj_Hunsui_InitVars = { ACTOR_OBJ_HUNSUI, ACTORCAT_BG, FLAGS, @@ -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) { @@ -240,7 +239,7 @@ void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = 0; this->dyna.actor.room = -1; } else { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } break; @@ -254,7 +253,7 @@ void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = 0; this->dyna.actor.room = -1; } else { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } break; @@ -270,7 +269,7 @@ void ObjHunsui_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.room = -1; this->actionFunc = func_80B9D714; // clang-format on } else { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } break; @@ -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.curRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + ((this->unk_16D != play->roomCtx.curRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num))) { switch (this->unk_160) { case OBJHUNSUI_F000_5: D_80B9DED8.unk_01 = 0; @@ -431,11 +431,11 @@ void func_80B9D120(ObjHunsui* this, GlobalContext* globalCtx) { D_80B9DED8.unk_02 = 0; break; } - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); 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.curRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + (this->unk_16D != play->roomCtx.curRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num)) { switch (this->unk_160) { case OBJHUNSUI_F000_5: D_80B9DED8.unk_01 = 0; @@ -536,16 +536,16 @@ void func_80B9D508(ObjHunsui* this, GlobalContext* globalCtx) { D_80B9DED8.unk_02 = 0; break; } - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); 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.curRoom.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)) { - Actor_MarkForDeath(&this->dyna.actor); + if ((this->unk_16C != play->roomCtx.curRoom.num) && (this->unk_16C != play->roomCtx.prevRoom.num) && + (this->unk_16D != play->roomCtx.curRoom.num) && (this->unk_16D != play->roomCtx.prevRoom.num)) { + Actor_Kill(&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..14a2eea62 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,37 +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; - #endif // Z_OBJ_HUNSUI_H diff --git a/src/overlays/actors/ovl_Obj_Ice_Poly/overlay.cfg b/src/overlays/actors/ovl_Obj_Ice_Poly/overlay.cfg deleted file mode 100644 index d77c80fcb..000000000 --- a/src/overlays/actors/ovl_Obj_Ice_Poly/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Ice_Poly -z_obj_ice_poly.c 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 bdffb1b52..13f49fd1f 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,17 +12,17 @@ #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 = { +ActorInit Obj_Ice_Poly_InitVars = { ACTOR_OBJ_ICE_POLY, ACTORCAT_ITEMACTION, FLAGS, @@ -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,26 +115,26 @@ 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))) { - Actor_MarkForDeath(thisx); + if (((this->unk_149 != OBJICEPOLY_FF_FF) && Flags_GetSwitch(play, this->unk_149)) || + ((play->sceneId == SCENE_KAJIYA) && CHECK_WEEKEVENTREG(WEEKEVENTREG_33_80))) { + Actor_Kill(thisx); return; } 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; @@ -178,7 +178,7 @@ void func_80931A38(ObjIcePoly* this, GlobalContext* globalCtx) { s32 pad3; f32 sp58; - if (!(player->stateFlags2 & 0x4000) && (this->unk_14A != 0)) { + if (!(player->stateFlags2 & PLAYER_STATE2_4000) && (this->unk_14A != 0)) { this->unk_14A--; } @@ -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->sceneId == 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,27 +260,28 @@ 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); - Actor_MarkForDeath(&this->actor); - } else { - this->unk_14A = 40; - Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_MELT); - this->actionFunc = func_80931EEC; + func_80931828(this, play); + Actor_Kill(&this->actor); + return; } + + this->unk_14A = 40; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ICE_MELT); + this->actionFunc = func_80931EEC; } else { ActorCutscene_SetIntentToPlay(this->actor.cutscene); } } -void func_80931EEC(ObjIcePoly* this, GlobalContext* globalCtx) { +void func_80931EEC(ObjIcePoly* this, PlayState* play) { Vec3f spAC; Vec3f spA0; Vec3f sp94; @@ -314,7 +315,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 +329,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); + Actor_Kill(&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..b081a7250 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,22 +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; - #endif // Z_OBJ_ICE_POLY_H diff --git a/src/overlays/actors/ovl_Obj_Iceblock/overlay.cfg b/src/overlays/actors/ovl_Obj_Iceblock/overlay.cfg deleted file mode 100644 index a72f4e3c8..000000000 --- a/src/overlays/actors/ovl_Obj_Iceblock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Iceblock -z_obj_iceblock.c 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 a4db0d04e..8c88c35ee 100644 --- a/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c +++ b/src/overlays/actors/ovl_Obj_Iceblock/z_obj_iceblock.c @@ -11,41 +11,41 @@ #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 = { +ActorInit Obj_Iceblock_InitVars = { ACTOR_OBJ_ICEBLOCK, ACTORCAT_BG, FLAGS, @@ -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,10 +846,10 @@ 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; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } @@ -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, &gIceBlockCol); + 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, PLAYER_CSMODE_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, PLAYER_CSMODE_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); + Actor_Kill(&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, PLAYER_CSMODE_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,28 +1505,28 @@ 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++) { @@ -1538,27 +1537,27 @@ void func_80A26BF8(ObjIceblock* this, GlobalContext* globalCtx) { 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)); + 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..466cd97b7 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,36 +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; - #endif // Z_OBJ_ICEBLOCK_H diff --git a/src/overlays/actors/ovl_Obj_Jg_Gakki/overlay.cfg b/src/overlays/actors/ovl_Obj_Jg_Gakki/overlay.cfg deleted file mode 100644 index f4ae147d7..000000000 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Jg_Gakki -z_obj_jg_gakki.c 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..0f4f83503 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,12 +11,12 @@ #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* play2); +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 = { +ActorInit Obj_Jg_Gakki_InitVars = { ACTOR_OBJ_JG_GAKKI, ACTORCAT_PROP, FLAGS, @@ -28,39 +28,39 @@ 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->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 7)) && (play->csCtx.currentCsIndex == 0)) { + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, frameCount, frameCount, ANIMMODE_ONCE, + 0.0f); + } else if ((play->sceneId == SCENE_17SETUGEN) || (play->sceneId == SCENE_10YUKIYAMANOMURA)) { + Animation_Change(&this->skelAnime, &gGoronElderDrumTakeOutAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, 0.0f); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&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_Jg_Gakki/z_obj_jg_gakki.h b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h index a3e8ae8eb..0da5151a4 100644 --- a/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h +++ b/src/overlays/actors/ovl_Obj_Jg_Gakki/z_obj_jg_gakki.h @@ -11,6 +11,4 @@ typedef struct ObjJgGakki { /* 0x188 */ ColliderCylinder collider; } ObjJgGakki; // size = 0x1D4 -extern const ActorInit Obj_Jg_Gakki_InitVars; - #endif // Z_OBJ_JG_GAKKI_H diff --git a/src/overlays/actors/ovl_Obj_Jgame_Light/overlay.cfg b/src/overlays/actors/ovl_Obj_Jgame_Light/overlay.cfg deleted file mode 100644 index 932e67c12..000000000 --- a/src/overlays/actors/ovl_Obj_Jgame_Light/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Jgame_Light -z_obj_jgame_light.c 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..af05f0ba3 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,18 +5,29 @@ */ #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; -#if 0 -const ActorInit Obj_Jgame_Light_InitVars = { +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); + +ActorInit Obj_Jgame_Light_InitVars = { ACTOR_OBJ_JGAME_LIGHT, ACTORCAT_PROP, FLAGS, @@ -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..0be39f7a6 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,12 +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; - #endif // Z_OBJ_JGAME_LIGHT_H diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/overlay.cfg b/src/overlays/actors/ovl_Obj_Kendo_Kanban/overlay.cfg deleted file mode 100644 index e1992b42b..000000000 --- a/src/overlays/actors/ovl_Obj_Kendo_Kanban/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Kendo_Kanban -z_obj_kendo_kanban.c 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 1ca1c4b58..3942fff76 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 @@ -1,7 +1,7 @@ /* * File: z_obj_kendo_kanban.c * Overlay: ovl_Obj_Kendo_Kanban - * Description: Swordsman's School - Cuttable Board + * Description: Swordsman's School - Cuttable Board at back of school */ #include "z_obj_kendo_kanban.h" @@ -9,22 +9,42 @@ #define FLAGS 0x00000000 +// Board Fragment Flags: Identify which of the 4 quadrants of the board are present. +#define OBJKENDOKANBAN_PART_FULL 0 +#define OBJKENDOKANBAN_PART_TOP_RIGHT (1 << 0) +#define OBJKENDOKANBAN_PART_TOP_LEFT (1 << 1) +#define OBJKENDOKANBAN_PART_BOTTOM_RIGHT (1 << 2) +#define OBJKENDOKANBAN_PART_BOTTOM_LEFT (1 << 3) +#define OBJKENDOKANBAN_RIGHT_HALF (OBJKENDOKANBAN_PART_TOP_RIGHT | OBJKENDOKANBAN_PART_BOTTOM_RIGHT) +#define OBJKENDOKANBAN_LEFT_HALF (OBJKENDOKANBAN_PART_TOP_LEFT | OBJKENDOKANBAN_PART_BOTTOM_LEFT) +#define OBJKENDOKANBAN_TOP_HALF (OBJKENDOKANBAN_PART_TOP_RIGHT | OBJKENDOKANBAN_PART_TOP_LEFT) +#define OBJKENDOKANBAN_BOTTOM_HALF (OBJKENDOKANBAN_PART_BOTTOM_RIGHT | OBJKENDOKANBAN_PART_BOTTOM_LEFT) + +// Number of bounces the board takes before settling. +#define MAX_BOUNCE_COUNT (7) + #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); +typedef enum { + /* -1 */ OBJKENDOKANBAN_DIR_DOWN = -1, + /* 0 */ OBJKENDOKANBAN_DIR_UNDETERMINED, + /* 1 */ OBJKENDOKANBAN_DIR_UP, +} ObjKendoKanbanDirection; -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 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); -const ActorInit Obj_Kendo_Kanban_InitVars = { +void ObjKendoKanban_SetupDoNothing(ObjKendoKanban* this); +void ObjKendoKanban_DoNothing(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_SetupTumble(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_Tumble(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_Settled(ObjKendoKanban* this, PlayState* play); +void ObjKendoKanban_HandlePhysics(ObjKendoKanban* this, PlayState* play); +s32 ObjKendoKanban_IsPlayerOnTop(ObjKendoKanban* this, PlayState* play); + +ActorInit Obj_Kendo_Kanban_InitVars = { ACTOR_OBJ_KENDO_KANBAN, ACTORCAT_NPC, FLAGS, @@ -36,29 +56,36 @@ const ActorInit Obj_Kendo_Kanban_InitVars = { (ActorFunc)ObjKendoKanban_Draw, }; -Vec3f D_80B66660 = { -1.5f, 10.0f, 0.5f }; -Vec3f D_80B6666C = { 1.5f, 10.0f, 0.5f }; -Vec3f D_80B66678 = { 0.0f, 4.0f, -1.0f }; -Vec3f D_80B66684 = { 1.0f, 7.0f, 4.0f }; -Vec3f D_80B66690 = { -150.0f, 425.0f, 40.0f }; -Vec3f D_80B6669C = { 150.0f, 425.0f, 40.0f }; -Vec3f D_80B666A8 = { 0.0f, 140.0f, 40.0f }; -Vec3f D_80B666B4 = { 0.0f, 565.0f, 40.0f }; +// Directly applied to the velocity of the actor upon object creation. +static Vec3f sVelocityLeftHalf = { -1.5f, 10.0f, 0.5f }; // Push Left/Up/Forward (Left side Breakaway) +static Vec3f sVelocityRightHalf = { 1.5f, 10.0f, 0.5f }; // Push Right/Up/Forward (Right side Breakaway) +static Vec3f sVelocityBottomHalf = { 0.0f, 4.0f, -1.0f }; // Push _/Up/Back (Bottom Breakaway) +static Vec3f sVelocityTopHalf = { 1.0f, 7.0f, 4.0f }; // Push Right/Up/Forward (Top Breakaway) -Gfx* D_80B666C0 = gKendoKanbanTopRightDL; -Gfx* D_80B666C4 = gKendoKanbanTopLeftDL; -Gfx* D_80B666C8 = gKendoKanbanBottomRightDL; -Gfx* D_80B666CC = gKendoKanbanBottomLeftDL; +// Centerpoint of the piece +static Vec3f sCenterPointLeftHalf = { -150.0f, 425.0f, 40.0f }; +static Vec3f sCenterPointRightHalf = { 150.0f, 425.0f, 40.0f }; +static Vec3f sCenterPointBottomHalf = { 0.0f, 140.0f, 40.0f }; +static Vec3f sCenterPointTopHalf = { 0.0f, 565.0f, 40.0f }; -Vec3f D_80B666D0 = { -300.0f, 850.0f, 40.0f }; -Vec3f D_80B666DC = { 10.0f, 850.0f, 40.0f }; -Vec3f D_80B666E8 = { 300.0f, 850.0f, 40.0f }; -Vec3f D_80B666F4 = { -300.0f, 310.0f, 40.0f }; -Vec3f D_80B66700 = { 0.0f, 280.0f, 40.0f }; -Vec3f D_80B6670C = { 300.0f, 250.0f, 40.0f }; -Vec3f D_80B66718 = { -300.0f, 10.0f, 40.0f }; -Vec3f D_80B66724 = { 0.0f, 10.0f, 40.0f }; -Vec3f D_80B66730 = { 300.0f, 10.0f, 40.0f }; +// Displaylists for the 4 pieces. +static Gfx* sDisplayLists[] = { + gKendoKanbanTopRightDL, + gKendoKanbanTopLeftDL, + gKendoKanbanBottomRightDL, + gKendoKanbanBottomLeftDL, +}; + +// Coordinates on the object face upon which the board can break +static Vec3f sPointTL = { -300.0f, 850.0f, 40.0f }; +static Vec3f sPointTC = { 10.0f, 850.0f, 40.0f }; +static Vec3f sPointTR = { 300.0f, 850.0f, 40.0f }; +static Vec3f sPointCL = { -300.0f, 310.0f, 40.0f }; +static Vec3f sPointCC = { 0.0f, 280.0f, 40.0f }; // Unused +static Vec3f sPointCR = { 300.0f, 250.0f, 40.0f }; +static Vec3f sPointBL = { -300.0f, 10.0f, 40.0f }; +static Vec3f sPointBC = { 0.0f, 10.0f, 40.0f }; +static Vec3f sPointBR = { 300.0f, 10.0f, 40.0f }; static ColliderTrisElementInit sTrisElementsInit[] = { { @@ -94,7 +121,7 @@ static ColliderTrisInit sTrisInit = { OC2_TYPE_1, COLSHAPE_TRIS, }, - 2, + ARRAY_COUNT(sTrisElementsInit), sTrisElementsInit, }; @@ -155,355 +182,346 @@ static DamageTable sDamageTable = { 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 }; +static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; +static Vec3f sUnitVecX = { 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]; + Vec3f vertices[3]; s32 i; s32 j; 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_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_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &sp70[j]); + for (j = 0; j < ARRAY_COUNT(vertices); j++) { + Matrix_MultVec3f(&sTrisElementsInit[i].dim.vtx[j], &vertices[j]); } - Collider_SetTrisVertices(&this->colliderTris, i, &sp70[0], &sp70[1], &sp70[2]); + Collider_SetTrisVertices(&this->colliderTris, i, &vertices[0], &vertices[1], &vertices[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->boardFragments = OBJKENDOKANBAN_GET_BOARD_FRAGMENTS(&this->actor); this->actor.gravity = -2.0f; - this->unk_2CC = D_80B6681C; - this->unk_2D8 = D_80B6681C; - this->unk_2E4 = D_80B6681C; - this->unk_2F0 = D_80B66828; - this->unk_302 = 0; - this->unk_304 = 0; - this->unk_2FC = -1; - this->unk_300 = 0; - this->unk_308 = 0; + this->centerPoint = sZeroVec; + this->centerPos = sZeroVec; + this->rootCornerPos = sZeroVec; + this->rotAxis = sUnitVecX; + this->rotAngle = 0; + this->rotVelocity = 0; + this->indexLastRootCornerPos = -1; + this->hasNewRootCornerPos = false; + this->numBounces = 0; - for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - this->unk_26C[i] = this->unk_29C[i] = D_80B6681C; + for (i = 0; i < ARRAY_COUNT(this->cornerPos); i++) { + this->cornerPos[i] = this->cornerPoints[i] = sZeroVec; } this->unk_30A = 0; - if (this->unk_30C == OBJKENDOKANBAN_F_0) { - func_80B65880(this); + if (this->boardFragments == OBJKENDOKANBAN_PART_FULL) { + ObjKendoKanban_SetupDoNothing(this); } else { - func_80B658A4(this, globalCtx); + ObjKendoKanban_SetupTumble(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 ObjKendoKanban_SetupDoNothing(ObjKendoKanban* this) { + this->actionFunc = ObjKendoKanban_DoNothing; } -void func_80B65894(ObjKendoKanban* this, GlobalContext* globalCtx) { +void ObjKendoKanban_DoNothing(ObjKendoKanban* this, PlayState* play) { } -void func_80B658A4(ObjKendoKanban* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void ObjKendoKanban_SetupTumble(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)) { - this->unk_30C = (OBJKENDOKANBAN_F_4 | OBJKENDOKANBAN_F_1); - this->unk_304 = 0x71C; - this->actor.velocity = D_80B6666C; - this->unk_2CC = D_80B6669C; + if (this->boardFragments == OBJKENDOKANBAN_PART_FULL) { + if ((player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_2H) || + (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH)) { - Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_KENDO_KANBAN, + // Vertical cuts initialize the right half, spawn the left half. + this->boardFragments = OBJKENDOKANBAN_RIGHT_HALF; + this->rotVelocity = 0x71C; // 10 degrees + this->actor.velocity = sVelocityRightHalf; + this->centerPoint = sCenterPointRightHalf; + + 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); + OBJKENDOKANBAN_LEFT_HALF); - this->unk_29C[0] = D_80B666DC; - this->unk_29C[1] = D_80B666E8; - this->unk_29C[2] = D_80B66730; - this->unk_29C[3] = D_80B66724; + this->cornerPoints[0] = sPointTC; + this->cornerPoints[1] = sPointTR; + this->cornerPoints[2] = sPointBR; + this->cornerPoints[3] = sPointBC; } else { - this->unk_30C = (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_4); - this->unk_304 = -0x71C; - this->actor.velocity = D_80B66678; - this->unk_2CC = D_80B666A8; + // Horizontal cuts initialize the bottom half, spawn the top half. + this->boardFragments = OBJKENDOKANBAN_BOTTOM_HALF; + this->rotVelocity = -0x71C; // -10 degrees + this->actor.velocity = sVelocityBottomHalf; + this->centerPoint = sCenterPointBottomHalf; - 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, OBJKENDOKANBAN_TOP_HALF); - this->unk_29C[0] = D_80B666F4; - this->unk_29C[1] = D_80B6670C; - this->unk_29C[2] = D_80B66730; - this->unk_29C[3] = D_80B66718; + this->cornerPoints[0] = sPointCL; + this->cornerPoints[1] = sPointCR; + this->cornerPoints[2] = sPointBR; + this->cornerPoints[3] = sPointBL; } - } else if (this->unk_30C == (OBJKENDOKANBAN_F_8 | OBJKENDOKANBAN_F_2)) { - this->unk_304 = 0x71C; - this->actor.velocity = D_80B66660; - this->unk_2CC = D_80B66690; + } else if (this->boardFragments == OBJKENDOKANBAN_LEFT_HALF) { + // Initialize the newly spawned left half + this->rotVelocity = 0x71C; // 10 degrees + this->actor.velocity = sVelocityLeftHalf; + this->centerPoint = sCenterPointLeftHalf; - this->unk_29C[0] = D_80B666D0; - this->unk_29C[1] = D_80B666DC; - this->unk_29C[2] = D_80B66724; - this->unk_29C[3] = D_80B66718; - } else if (this->unk_30C == (OBJKENDOKANBAN_F_2 | OBJKENDOKANBAN_F_1)) { - this->unk_304 = 0x71C; - this->actor.velocity = D_80B66684; - this->unk_2CC = D_80B666B4; + this->cornerPoints[0] = sPointTL; + this->cornerPoints[1] = sPointTC; + this->cornerPoints[2] = sPointBC; + this->cornerPoints[3] = sPointBL; + } else if (this->boardFragments == OBJKENDOKANBAN_TOP_HALF) { + // Initialize the newly spawned top half + this->rotVelocity = 0x71C; // 10 degrees + this->actor.velocity = sVelocityTopHalf; + this->centerPoint = sCenterPointTopHalf; - this->unk_29C[0] = D_80B666D0; - this->unk_29C[1] = D_80B666E8; - this->unk_29C[2] = D_80B6670C; - this->unk_29C[3] = D_80B666F4; + this->cornerPoints[0] = sPointTL; + this->cornerPoints[1] = sPointTR; + this->cornerPoints[2] = sPointCR; + this->cornerPoints[3] = sPointCL; } this->unk_30A = 0; - this->actionFunc = func_80B65CE0; + this->actionFunc = ObjKendoKanban_Tumble; } -void func_80B65CE0(ObjKendoKanban* this, GlobalContext* globalCtx) { +void ObjKendoKanban_Tumble(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); + this->rotAngle += this->rotVelocity; + ObjKendoKanban_HandlePhysics(this, play); if (this->actor.world.pos.y < -200.0f) { this->actor.world.pos.y = -200.0f; } } -void func_80B65D54(ObjKendoKanban* this) { - this->actionFunc = func_80B65D68; +void ObjKendoKanban_SetupSettled(ObjKendoKanban* this) { + this->actionFunc = ObjKendoKanban_Settled; } -void func_80B65D68(ObjKendoKanban* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void ObjKendoKanban_Settled(ObjKendoKanban* this, PlayState* play) { + Player* player = GET_PLAYER(play); - if (func_80B6618C(this, globalCtx) == 1) { + if (ObjKendoKanban_IsPlayerOnTop(this, play) == true) { player->unk_AC0 = 700.0f; } } -void func_80B65DA8(ObjKendoKanban* this, GlobalContext* globalCtx) { - Vec3f sp5C; +void ObjKendoKanban_HandlePhysics(ObjKendoKanban* this, PlayState* play) { + Vec3f rootCornerPos = this->cornerPos[0]; s32 pad[2]; - Vec3f sp48; + Vec3f vecCenterOut = this->actor.world.pos; s32 pad2; - s32 index = 0; + s32 indexRootCornerPos = 0; s32 i; - f32 sp38; + f32 verticalScalar; - sp5C = this->unk_26C[0]; - sp48 = this->actor.world.pos; - - sp48.x -= this->unk_2D8.x; - sp48.y -= this->unk_2D8.y; - sp48.z -= this->unk_2D8.z; - - sp38 = (this->unk_2F0.x * sp48.z) + (this->unk_2F0.z * -sp48.x); - - if (sp38 < 0.0f) { - this->unk_304 += 0x64; + // Calculate an affect on the rotation from gravity. + vecCenterOut.x -= this->centerPos.x; + vecCenterOut.y -= this->centerPos.y; + vecCenterOut.z -= this->centerPos.z; + verticalScalar = (this->rotAxis.x * vecCenterOut.z) + (this->rotAxis.z * -vecCenterOut.x); + if (verticalScalar < 0.0f) { + this->rotVelocity += 0x64; } else { - this->unk_304 -= 0x64; + this->rotVelocity -= 0x64; } - for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - if (this->unk_26C[i].y < sp5C.y) { - sp5C = this->unk_26C[i]; - index = i; + // Find the lowest point + for (i = 0; i < ARRAY_COUNT(this->cornerPos); i++) { + if (this->cornerPos[i].y < rootCornerPos.y) { + rootCornerPos = this->cornerPos[i]; + indexRootCornerPos = i; } } - if (index != this->unk_2FC) { - this->unk_300 = 1; - this->unk_2FC = index; - this->unk_2E4 = this->unk_29C[index]; + // When the lowest point changes, re-initialize the actor position to that point + if (indexRootCornerPos != this->indexLastRootCornerPos) { + this->hasNewRootCornerPos = true; + this->indexLastRootCornerPos = indexRootCornerPos; + this->rootCornerPos = this->cornerPoints[indexRootCornerPos]; Matrix_Push(); Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_MultVec3f(&this->unk_2E4, &this->actor.world.pos); - this->actor.world.pos = sp5C; + Matrix_MultVec3f(&this->rootCornerPos, &this->actor.world.pos); + this->actor.world.pos = rootCornerPos; this->actor.prevPos = this->actor.world.pos; 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) { + // When on the ground, apply some friction. this->actor.velocity.x *= 0.8f; this->actor.velocity.z *= 0.8f; } - if (this->unk_300 == 1) { - if (this->unk_308 >= 7) { - s16 temp_v0_3 = this->unk_302 & 0x3FFF; + if (this->hasNewRootCornerPos == true) { + if (this->numBounces >= MAX_BOUNCE_COUNT) { + s16 deltaRotAngle = this->rotAngle & 0x3FFF; - if (temp_v0_3 >= 0x2000) { - temp_v0_3 -= 0x4000; + if (deltaRotAngle >= 0x2000) { // 45 degrees + deltaRotAngle -= 0x4000; // 90 degrees } - this->unk_302 -= temp_v0_3; - this->unk_304 = 0; - func_80B65D54(this); + this->rotAngle -= deltaRotAngle; + this->rotVelocity = 0; + ObjKendoKanban_SetupSettled(this); return; } if (this->actor.bgCheckFlags & 2) { + // Upon touching the ground... Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); - this->unk_300 = 0; + this->hasNewRootCornerPos = false; this->actor.velocity.y *= 0.5f; } else if (this->actor.bgCheckFlags & 1) { - this->unk_308++; - this->unk_300 = 0; + // When on the ground... + this->numBounces++; + this->hasNewRootCornerPos = false; this->actor.velocity.x *= 0.3f; this->actor.velocity.z *= 0.3f; Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_WOODPLATE_BOUND); - if (sp38 > 0.0f) { - if (this->unk_304 > 0) { - this->unk_304 *= 1.2f; + // Adjust and (potentially) reverse rotation depending on the current + // facing of the board and the direction in which it is rotating. + if (verticalScalar > 0.0f) { + if (this->rotVelocity > 0) { + this->rotVelocity *= 1.2f; } else { - this->unk_304 *= -0.6f; + this->rotVelocity *= -0.6f; } - } else if (this->unk_304 < 0) { - this->unk_304 *= 1.2f; } else { - this->unk_304 *= -0.6f; + if (this->rotVelocity < 0) { + this->rotVelocity *= 1.2f; + } else { + this->rotVelocity *= -0.6f; + } } } } } -s32 func_80B6618C(ObjKendoKanban* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); - s32 phi_v0; - s32 phi_v1 = 0; +s32 ObjKendoKanban_IsPlayerOnTop(ObjKendoKanban* this, PlayState* play) { + Player* player = GET_PLAYER(play); s32 i; - f32 x; - f32 z; - f32 x2; - f32 z2; + s32 j; + Vec2f playerToCornerA; + Vec2f playerToCornerB; + s32 priorDir = OBJKENDOKANBAN_DIR_UNDETERMINED; - for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - if (i != 3) { - phi_v0 = i + 1; - } else { - phi_v0 = 0; - } + for (i = 0; i < ARRAY_COUNT(this->cornerPos); i++) { + j = (i != 3) ? (i + 1) : 0; - z = this->unk_26C[i].z - player->actor.world.pos.z; - x = this->unk_26C[i].x - player->actor.world.pos.x; - - z2 = (this->unk_26C[phi_v0].z - player->actor.world.pos.z); - x2 = (this->unk_26C[phi_v0].x - player->actor.world.pos.x); - - if ((x * z2) < (z * x2)) { - if (phi_v1 == 0) { - phi_v1 = 1; - } else if (phi_v1 != 1) { + // For each pair of points (moving clockwise around the shape), verify that the normal + // vector's magnitute is in the same direction. This condition being true means + // the player is within the bounds of the four cornerPoints. + playerToCornerA.z = this->cornerPos[i].z - player->actor.world.pos.z; + playerToCornerA.x = this->cornerPos[i].x - player->actor.world.pos.x; + playerToCornerB.z = this->cornerPos[j].z - player->actor.world.pos.z; + playerToCornerB.x = this->cornerPos[j].x - player->actor.world.pos.x; + if ((playerToCornerA.x * playerToCornerB.z) < (playerToCornerA.z * playerToCornerB.x)) { + if (priorDir == OBJKENDOKANBAN_DIR_UNDETERMINED) { + priorDir = OBJKENDOKANBAN_DIR_UP; + } else if (priorDir != OBJKENDOKANBAN_DIR_UP) { + return false; + } + } else { + if (priorDir == OBJKENDOKANBAN_DIR_UNDETERMINED) { + priorDir = OBJKENDOKANBAN_DIR_DOWN; + } else if (priorDir != OBJKENDOKANBAN_DIR_DOWN) { return false; } - } else if (phi_v1 == 0) { - phi_v1 = -1; - } else if (phi_v1 != -1) { - return false; } } return true; } -void func_80B66304(ObjKendoKanban* this, GlobalContext* globalCtx) { - if ((this->actionFunc != func_80B65CE0) && (this->actionFunc != func_80B65D68)) { +void ObjKendoKanban_UpdateCollision(ObjKendoKanban* this, PlayState* play) { + if ((this->actionFunc != ObjKendoKanban_Tumble) && (this->actionFunc != ObjKendoKanban_Settled)) { if (this->colliderTris.base.acFlags & AC_HIT) { this->colliderTris.base.acFlags &= ~AC_HIT; - func_80B658A4(this, globalCtx); + ObjKendoKanban_SetupTumble(this, play); } Collider_UpdateCylinder(&this->actor, &this->colliderCylinder); this->colliderCylinder.dim.pos.z -= (s16)(20.0f * Math_CosS(this->actor.shape.rot.y)); this->colliderCylinder.dim.pos.x -= (s16)(20.0f * Math_SinS(this->actor.shape.rot.y)); - if (this->actionFunc == func_80B65894) { - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderTris.base); + if (this->actionFunc == ObjKendoKanban_DoNothing) { + 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); - - func_80B66304(this, globalCtx); + this->actionFunc(this, play); + ObjKendoKanban_UpdateCollision(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); + if (this->boardFragments == OBJKENDOKANBAN_PART_FULL) { + 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_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); + Matrix_RotateAxisS(this->rotAngle, &this->rotAxis, MTXMODE_APPLY); + Matrix_Translate(-this->rootCornerPos.x, -this->rootCornerPos.y, -this->rootCornerPos.z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - if (this->unk_30C & OBJKENDOKANBAN_F_1) { - gSPDisplayList(POLY_OPA_DISP++, D_80B666C0); - } - - if (this->unk_30C & OBJKENDOKANBAN_F_2) { - gSPDisplayList(POLY_OPA_DISP++, D_80B666C4); - } - - if (this->unk_30C & OBJKENDOKANBAN_F_4) { - gSPDisplayList(POLY_OPA_DISP++, D_80B666C8); - } - - if (this->unk_30C & OBJKENDOKANBAN_F_8) { - gSPDisplayList(POLY_OPA_DISP++, D_80B666CC); + // Display only the fragments of the board which are present + for (i = 0; i < ARRAY_COUNT(sDisplayLists); i++) { + if ((1 << i) & this->boardFragments) { + gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[i]); + } } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - for (i = 0; i < ARRAY_COUNT(this->unk_26C); i++) { - Matrix_MultVec3f(&this->unk_29C[i], &this->unk_26C[i]); + // Update the alternate position trackers (Corners and Center of the board) + for (i = 0; i < ARRAY_COUNT(this->cornerPos); i++) { + Matrix_MultVec3f(&this->cornerPoints[i], &this->cornerPos[i]); } - - Matrix_MultVec3f(&this->unk_2CC, &this->unk_2D8); + Matrix_MultVec3f(&this->centerPoint, &this->centerPos); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Kendo_Kanban/ObjKendoKanban_Draw.s") -#endif diff --git a/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h b/src/overlays/actors/ovl_Obj_Kendo_Kanban/z_obj_kendo_kanban.h index a8c4f8d7c..72bf6e71e 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,38 +5,30 @@ struct ObjKendoKanban; -typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, GlobalContext*); +typedef void (*ObjKendoKanbanActionFunc)(struct ObjKendoKanban*, PlayState*); -#define OBJKENDOKANBAN_GET_F(thisx) ((thisx)->params & 0xF) - -#define OBJKENDOKANBAN_F_0 0 -#define OBJKENDOKANBAN_F_1 (1 << 0) -#define OBJKENDOKANBAN_F_2 (1 << 1) -#define OBJKENDOKANBAN_F_4 (1 << 2) -#define OBJKENDOKANBAN_F_8 (1 << 3) +#define OBJKENDOKANBAN_GET_BOARD_FRAGMENTS(thisx) ((thisx)->params & 0xF) 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 cornerPos[4]; + /* 0x29C */ Vec3f cornerPoints[4]; + /* 0x2CC */ Vec3f centerPoint; + /* 0x2D8 */ Vec3f centerPos; + /* 0x2E4 */ Vec3f rootCornerPos; + /* 0x2F0 */ Vec3f rotAxis; + /* 0x2FC */ s32 indexLastRootCornerPos; + /* 0x300 */ s16 hasNewRootCornerPos; + /* 0x302 */ s16 rotAngle; + /* 0x304 */ s16 rotVelocity; + /* 0x306 */ UNK_TYPE1 pad306[2]; + /* 0x308 */ s16 numBounces; + /* 0x30A */ s16 unk_30A; + /* 0x30C */ u8 boardFragments; } ObjKendoKanban; // size = 0x310 -extern const ActorInit Obj_Kendo_Kanban_InitVars; - #endif // Z_OBJ_KENDO_KANBAN_H diff --git a/src/overlays/actors/ovl_Obj_Kepn_Koya/overlay.cfg b/src/overlays/actors/ovl_Obj_Kepn_Koya/overlay.cfg deleted file mode 100644 index 8a6c7b560..000000000 --- a/src/overlays/actors/ovl_Obj_Kepn_Koya/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Kepn_Koya -z_obj_kepn_koya.c 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..abd9b2577 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,12 +11,12 @@ #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 = { +ActorInit Obj_Kepn_Koya_InitVars = { ACTOR_OBJ_KEPN_KOYA, ACTORCAT_PROP, FLAGS, @@ -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); + Actor_Kill(&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_Kepn_Koya/z_obj_kepn_koya.h b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.h index ce33c0112..58b4f69a1 100644 --- a/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.h +++ b/src/overlays/actors/ovl_Obj_Kepn_Koya/z_obj_kepn_koya.h @@ -10,6 +10,4 @@ typedef struct ObjKepnKoya { /* 0x15C */ UNK_TYPE1 unk15C[0x4]; } ObjKepnKoya; // size = 0x160 -extern const ActorInit Obj_Kepn_Koya_InitVars; - #endif // Z_OBJ_KEPN_KOYA_H diff --git a/src/overlays/actors/ovl_Obj_Kibako/overlay.cfg b/src/overlays/actors/ovl_Obj_Kibako/overlay.cfg deleted file mode 100644 index d0a8b240a..000000000 --- a/src/overlays/actors/ovl_Obj_Kibako/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Kibako -z_obj_kibako.c 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..36927b262 100644 --- a/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c +++ b/src/overlays/actors/ovl_Obj_Kibako/z_obj_kibako.c @@ -12,31 +12,31 @@ #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* play2); +void ObjKibako_Destroy(Actor* thisx, PlayState* play2); +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; static s16 D_80927388 = 0; static s16 D_8092738C = 0; -const ActorInit Obj_Kibako_InitVars = { +ActorInit Obj_Kibako_InitVars = { ACTOR_OBJ_KIBAKO, ACTORCAT_PROP, FLAGS, @@ -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.curRoom.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,27 +145,27 @@ 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); + Actor_Kill(&this->actor); return; } this->unk199 = this->actor.room; 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); - Actor_MarkForDeath(&this->actor); + 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_Kill(&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); - Actor_MarkForDeath(&this->actor); + ObjKibako_AirBreak(this, play); + ObjKibako_SpawnCollectible(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + Actor_Kill(&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.curRoom.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,22 +380,22 @@ 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); - Actor_MarkForDeath(&this->actor); + ObjKibako_AirBreak(this, play); + ObjKibako_SpawnCollectible(this, play); + SoundSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 20, NA_SE_EV_WOODBOX_BREAK); + Actor_Kill(&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); - Actor_MarkForDeath(&this->actor); + 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_Kill(&this->actor); } else { if (this->actor.velocity.y < -0.05f) { this->actor.gravity = -2.3f; @@ -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..102dd1e1b 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; @@ -22,6 +22,4 @@ typedef struct ObjKibako { /* 0x199 */ s8 unk199; /* room? */ } ObjKibako; // size = 0x19C -extern const ActorInit Obj_Kibako_InitVars; - #endif // Z_OBJ_KIBAKO_H diff --git a/src/overlays/actors/ovl_Obj_Kibako2/overlay.cfg b/src/overlays/actors/ovl_Obj_Kibako2/overlay.cfg deleted file mode 100644 index 436504fc8..000000000 --- a/src/overlays/actors/ovl_Obj_Kibako2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Kibako2 -z_obj_kibako2.c 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..06af2a8e3 100644 --- a/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c +++ b/src/overlays/actors/ovl_Obj_Kibako2/z_obj_kibako2.c @@ -12,14 +12,14 @@ #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 = { +ActorInit Obj_Kibako2_InitVars = { ACTOR_OBJ_KIBAKO2, ACTORCAT_BG, FLAGS, @@ -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); - Actor_MarkForDeath(&this->dyna.actor); +void ObjKibako2_Kill(ObjKibako2* this, PlayState* play) { + ObjKibako2_SpawnContents(this, play); + Actor_Kill(&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.flags |= ACTORCTX_FLAG_3; } 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..47c8649d9 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; @@ -25,6 +25,4 @@ typedef struct ObjKibako2 { /* 0x1AD */ s8 skulltulaNoiseTimer; } ObjKibako2; // size = 0x1B0 -extern const ActorInit Obj_Kibako2_InitVars; - #endif // Z_OBJ_KIBAKO2_H diff --git a/src/overlays/actors/ovl_Obj_Kinoko/overlay.cfg b/src/overlays/actors/ovl_Obj_Kinoko/overlay.cfg deleted file mode 100644 index 071ad6a34..000000000 --- a/src/overlays/actors/ovl_Obj_Kinoko/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Kinoko -z_obj_kinoko.c 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 33cadc8f6..9c9215b24 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Obj_Kinoko_InitVars = { ACTOR_OBJ_KINOKO, ACTORCAT_ITEMACTION, FLAGS, @@ -28,31 +28,31 @@ 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) { thisx->draw = NULL; - thisx->hintId = 0xFF; + thisx->hintId = TATL_HINT_ID_NONE; thisx->flags &= ~ACTOR_FLAG_1; } else { thisx->draw = ObjKinoko_Draw; - thisx->hintId = 0x64; + thisx->hintId = TATL_HINT_ID_MUSHROOM; thisx->flags |= ACTOR_FLAG_1; - if (Actor_HasParent(thisx, globalCtx)) { - Flags_SetCollectible(globalCtx, OBJ_KINOKO_GET_FLAG(thisx)); - Actor_MarkForDeath(thisx); + if (Actor_HasParent(thisx, play)) { + Flags_SetCollectible(play, OBJ_KINOKO_GET_FLAG(thisx)); + Actor_Kill(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_RotateXS(-0x4000, MTXMODE_APPLY); - gSPMatrix(&gfx[5], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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_Kinoko/z_obj_kinoko.h b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h index 9073e3e14..335f33a02 100644 --- a/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h +++ b/src/overlays/actors/ovl_Obj_Kinoko/z_obj_kinoko.h @@ -9,8 +9,6 @@ typedef struct ObjKinoko { /* 0x000 */ Actor actor; } ObjKinoko; // size = 0x144 -extern const ActorInit Obj_Kinoko_InitVars; - #define OBJ_KINOKO_GET_FLAG(thisx) ((thisx)->params & 0x7F) #endif // Z_OBJ_KINOKO_H diff --git a/src/overlays/actors/ovl_Obj_Kzsaku/overlay.cfg b/src/overlays/actors/ovl_Obj_Kzsaku/overlay.cfg deleted file mode 100644 index c2a20d705..000000000 --- a/src/overlays/actors/ovl_Obj_Kzsaku/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Kzsaku -z_obj_kzsaku.c 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..9ceff660e 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.c @@ -11,19 +11,19 @@ #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 = { +ActorInit Obj_Kzsaku_InitVars = { ACTOR_OBJ_KZSAKU, ACTORCAT_PROP, FLAGS, @@ -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..0a6f00187 100644 --- a/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h +++ b/src/overlays/actors/ovl_Obj_Kzsaku/z_obj_kzsaku.h @@ -7,16 +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; - #endif // Z_OBJ_KZSAKU_H diff --git a/src/overlays/actors/ovl_Obj_Lift/overlay.cfg b/src/overlays/actors/ovl_Obj_Lift/overlay.cfg deleted file mode 100644 index fca482174..000000000 --- a/src/overlays/actors/ovl_Obj_Lift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Lift -z_obj_lift.c 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..aff88964b 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.c @@ -5,18 +5,29 @@ */ #include "z_obj_lift.h" +#include "z64quake.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); -#if 0 -const ActorInit Obj_Lift_InitVars = { +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); + +ActorInit Obj_Lift_InitVars = { ACTOR_OBJ_LIFT, ACTORCAT_BG, FLAGS, @@ -28,46 +39,209 @@ 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_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093D8B4.s") + 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_8093D9C0.s") +void ObjLift_Destroy(Actor* thisx, PlayState* play) { + ObjLift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DA48.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DB70.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_8093DB90.s") +void func_8093D7A0(ObjLift* this, PlayState* play) { + s32 pad; + s16 quakeIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Update.s") + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + if (this->timer <= 0) { + if (OBJLIFT_GET_7(&this->dyna.actor) == 7) { + func_8093D9C0(this); + } else { + quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_1); + Quake_SetSpeed(quakeIndex, 10000); + Quake_SetQuakeValues(quakeIndex, 2, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 20); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/ObjLift_Draw.s") + func_8093D88C(this); + } + } + } else { + this->timer = D_8093DD50[OBJLIFT_GET_7(&this->dyna.actor)]; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lift/func_8093DC90.s") +void func_8093D88C(ObjLift* this) { + this->timer = 20; + this->actionFunc = func_8093D8B4; + this->dyna.actor.draw = func_8093DC90; +} + +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); + } +} + +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_Kill(&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..b7f2af050 100644 --- a/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h +++ b/src/overlays/actors/ovl_Obj_Lift/z_obj_lift.h @@ -3,17 +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; - #endif // Z_OBJ_LIFT_H diff --git a/src/overlays/actors/ovl_Obj_Lightblock/overlay.cfg b/src/overlays/actors/ovl_Obj_Lightblock/overlay.cfg deleted file mode 100644 index ecf5da6fa..000000000 --- a/src/overlays/actors/ovl_Obj_Lightblock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Lightblock -z_obj_lightblock.c 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..16a628fa2 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.c @@ -11,18 +11,18 @@ #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 = { +ActorInit Obj_Lightblock_InitVars = { ACTOR_OBJ_LIGHTBLOCK, ACTORCAT_BG, FLAGS, @@ -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,33 +91,34 @@ 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))) { - Actor_MarkForDeath(&this->dyna.actor); - } else { - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_lightblock_Colheader_000B80); - Collider_SetCylinder(globalCtx, &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; - this->collider.dim.yShift = typeVars->yShift; - this->alpha = 255; - func_80AF3AC8(this); + Collider_InitCylinder(play, &this->collider); + if (Flags_GetSwitch(play, LIGHTBLOCK_DESTROYED(&this->dyna.actor))) { + Actor_Kill(&this->dyna.actor); + return; } + + 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; + this->collider.dim.yShift = typeVars->yShift; + this->alpha = 255; + func_80AF3AC8(this); } -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 +137,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 +145,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,47 +161,50 @@ 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--; if (this->timer <= 0) { temp_a0 = this->dyna.actor.cutscene; ActorCutscene_Stop(temp_a0); - Actor_MarkForDeath(&this->dyna.actor); - } else if (this->timer <= 60) { + Actor_Kill(&this->dyna.actor); + return; + } + + if (this->timer <= 60) { if (this->alpha > 40) { this->alpha -= 40; } 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..63a106dac 100644 --- a/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h +++ b/src/overlays/actors/ovl_Obj_Lightblock/z_obj_lightblock.h @@ -8,17 +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; - #endif // Z_OBJ_LIGHTBLOCK_H diff --git a/src/overlays/actors/ovl_Obj_Lightswitch/overlay.cfg b/src/overlays/actors/ovl_Obj_Lightswitch/overlay.cfg deleted file mode 100644 index cafaebb11..000000000 --- a/src/overlays/actors/ovl_Obj_Lightswitch/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Lightswitch -z_obj_lightswitch.c 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 b1d54899b..f2946d536 100644 --- a/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c +++ b/src/overlays/actors/ovl_Obj_Lightswitch/z_obj_lightswitch.c @@ -11,23 +11,23 @@ #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 = { +ActorInit Obj_Lightswitch_InitVars = { ACTOR_OBJ_LIGHTSWITCH, ACTORCAT_SWITCH, FLAGS, @@ -62,7 +62,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -83,11 +83,11 @@ 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_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y + (this->actor.shape.yOffset * this->actor.scale.y), @@ -96,17 +96,17 @@ void ObjLightswitch_InitCollider(ObjLightswitch* this, GlobalContext* globalCtx) 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,21 +165,21 @@ 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; } if (isTriggered) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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,17 +311,18 @@ 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 { - func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); // "burn into ashes" + Actor_Kill(&this->actor); + return; } + + func_800B9010(&this->actor, NA_SE_EN_COMMON_EXTINCT_LEV - SFX_FLAG); // "burn into ashes" } -void ObjLightswitch_Update(Actor* thisx, GlobalContext* globalCtx) { +void ObjLightswitch_Update(Actor* thisx, PlayState* play) { ObjLightswitch* this = THIS; s32 pad; @@ -329,7 +330,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 +355,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,7 +378,7 @@ 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); @@ -386,26 +387,26 @@ void ObjLightSwitch_DrawOpa(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.z = this->actor.shape.rot.z + this->edgeRot; 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_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,7 +414,7 @@ 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); @@ -422,25 +423,25 @@ void ObjLightSwitch_DrawXlu(ObjLightswitch* this, GlobalContext* globalCtx) { tempRot.z = this->actor.shape.rot.z + this->edgeRot; 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_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..c26dab262 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 { @@ -29,8 +29,6 @@ typedef struct ObjLightswitch { } ObjLightswitch; // size = 0x1C0 -extern const ActorInit Obj_Lightswitch_InitVars; - #define LIGHTSWITCH_FACE_ASLEEP 0 #define LIGHTSWITCH_FACE_WAKING 1 #define LIGHTSWITCH_FACE_FULLAWAKE 2 @@ -40,8 +38,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/overlay.cfg b/src/overlays/actors/ovl_Obj_Lupygamelift/overlay.cfg deleted file mode 100644 index ad6243891..000000000 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Lupygamelift -z_obj_lupygamelift.c 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..6620c5116 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -5,18 +5,23 @@ */ #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); -#if 0 -const ActorInit Obj_Lupygamelift_InitVars = { +void func_80AF04BC(ObjLupygamelift* this); +void func_80AF04D8(ObjLupygamelift* this, PlayState* play); +void func_80AF0514(ObjLupygamelift* this); +void func_80AF0530(ObjLupygamelift* this, PlayState* play); + +ActorInit Obj_Lupygamelift_InitVars = { ACTOR_OBJ_LUPYGAMELIFT, ACTORCAT_BG, FLAGS, @@ -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..e25f9cd6d 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h @@ -3,17 +3,22 @@ #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 - -extern const ActorInit Obj_Lupygamelift_InitVars; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjLupygameliftActionFunc actionFunc; + /* 0x160 */ f32 targetSpeedXZ; + /* 0x164 */ s32 count; + /* 0x168 */ s32 pointIndex; + /* 0x16C */ Vec3s* points; + /* 0x170 */ s16 timer; +} ObjLupygamelift; /* size = 0x174 */ #endif // Z_OBJ_LUPYGAMELIFT_H diff --git a/src/overlays/actors/ovl_Obj_Makekinsuta/overlay.cfg b/src/overlays/actors/ovl_Obj_Makekinsuta/overlay.cfg deleted file mode 100644 index d63602969..000000000 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Makekinsuta -z_obj_makekinsuta.c 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..c46821ac1 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.c @@ -10,12 +10,15 @@ #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); -#if 0 -const ActorInit Obj_Makekinsuta_InitVars = { +s32 func_8099FA40(ObjMakekinsuta* this, PlayState* play); +void func_8099FB64(Actor* thisx, PlayState* play); +void func_8099FD7C(Actor* thisx, PlayState* play); + +ActorInit Obj_Makekinsuta_InitVars = { ACTOR_OBJ_MAKEKINSUTA, ACTORCAT_ITEMACTION, FLAGS, @@ -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_Kill(&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_Atan2S_XY(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, PLAYER_CSMODE_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..17c9220e2 100644 --- a/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h +++ b/src/overlays/actors/ovl_Obj_Makekinsuta/z_obj_makekinsuta.h @@ -5,11 +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; - #endif // Z_OBJ_MAKEKINSUTA_H diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/overlay.cfg b/src/overlays/actors/ovl_Obj_Makeoshihiki/overlay.cfg deleted file mode 100644 index 7d4fbe22d..000000000 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Makeoshihiki -z_obj_makeoshihiki.c 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..bb7d30f69 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -10,10 +10,10 @@ #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 = { +ActorInit Obj_Makeoshihiki_InitVars = { ACTOR_OBJ_MAKEOSHIHIKI, ACTORCAT_PROP, FLAGS, @@ -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) { - Actor_MarkForDeath(&this->actor); + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_OBJ_OSHIHIKI, childPoint->x, childPoint->y, + childPoint->z, 0, 0, 0, 0xFFF1) == NULL) { + Actor_Kill(&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..47fbe831b 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; @@ -15,6 +15,4 @@ typedef struct ObjMakeoshihiki { /* 0x148 */ s32 pathCount; } ObjMakeoshihiki; // size = 0x14C -extern const ActorInit Obj_Makeoshihiki_InitVars; - #endif // Z_OBJ_MAKEOSHIHIKI_H diff --git a/src/overlays/actors/ovl_Obj_Milk_Bin/overlay.cfg b/src/overlays/actors/ovl_Obj_Milk_Bin/overlay.cfg deleted file mode 100644 index a5f995b32..000000000 --- a/src/overlays/actors/ovl_Obj_Milk_Bin/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Milk_Bin -z_obj_milk_bin.c 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..8ff6e8455 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,12 +11,12 @@ #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* play2); +void ObjMilkBin_Draw(Actor* thisx, PlayState* play); -const ActorInit Obj_Milk_Bin_InitVars = { +ActorInit Obj_Milk_Bin_InitVars = { ACTOR_OBJ_MILK_BIN, ACTORCAT_PROP, FLAGS, @@ -48,40 +48,40 @@ 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; this->disableDraw = 0; this->type = thisx->params; - if ((this->type == OBJ_MILK_BIN_TYPE_2) && !(gSaveContext.save.weekEventReg[52] & 1)) { + if ((this->type == OBJ_MILK_BIN_TYPE_2) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01)) { this->disableDraw |= 1; } } -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) { - if (gSaveContext.save.weekEventReg[22] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { if (((gSaveContext.save.day == 2) && (gSaveContext.save.isNight == 1)) || (gSaveContext.save.day >= 3)) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } } } else if (this->type == OBJ_MILK_BIN_TYPE_2) { - if (gSaveContext.save.weekEventReg[52] & 1) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01)) { this->disableDraw &= ~1; } else { this->disableDraw |= 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..9eb0d298d 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,14 +7,12 @@ 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; } ObjMilkBin; // size = 0x19C -extern const ActorInit Obj_Milk_Bin_InitVars; - typedef enum { /* 0 */ OBJ_MILK_BIN_TYPE_DEFAULT, /* 1 */ OBJ_MILK_BIN_TYPE_1, // This actor will kill itself if the player has obtained the milk bottle and the current time is the night of the second day onwards. diff --git a/src/overlays/actors/ovl_Obj_Mine/overlay.cfg b/src/overlays/actors/ovl_Obj_Mine/overlay.cfg deleted file mode 100644 index 7d0fb28e9..000000000 --- a/src/overlays/actors/ovl_Obj_Mine/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Mine -z_obj_mine.c 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 5b5e80d39..556f72b67 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -10,13 +10,13 @@ #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); #if 0 -const ActorInit Obj_Mine_InitVars = { +ActorInit Obj_Mine_InitVars = { ACTOR_OBJ_MINE, ACTORCAT_PROP, FLAGS, @@ -39,7 +39,7 @@ static ColliderJntSphElementInit D_80A84570[1] = { // static ColliderJntSphInit sJntSphInit = { static ColliderJntSphInit D_80A84594 = { { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_PLAYER | OC1_TYPE_1, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 1, D_80A84570, // sJntSphElementsInit, + ARRAY_COUNT(sJntSphElementsInit), D_80A84570, // sJntSphElementsInit, }; // static InitChainEntry sInitChain[] = { diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 4b7f8ee3d..257a6ff3a 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*); typedef struct ObjMine { /* 0x0000 */ Actor actor; @@ -14,6 +14,4 @@ typedef struct ObjMine { /* 0x01A8 */ char unk_1A8[0x120C]; } ObjMine; // size = 0x13B4 -extern const ActorInit Obj_Mine_InitVars; - #endif // Z_OBJ_MINE_H diff --git a/src/overlays/actors/ovl_Obj_Moon_Stone/overlay.cfg b/src/overlays/actors/ovl_Obj_Moon_Stone/overlay.cfg deleted file mode 100644 index 0b388c672..000000000 --- a/src/overlays/actors/ovl_Obj_Moon_Stone/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Moon_Stone -z_obj_moon_stone.c 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 d6d780a04..18c36f87e 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,21 +11,21 @@ #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 = { +ActorInit Obj_Moon_Stone_InitVars = { ACTOR_OBJ_MOON_STONE, ACTORCAT_PROP, FLAGS, @@ -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); @@ -49,38 +49,38 @@ void ObjMoonStone_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.colChkInfo.health = 0; this->actor.flags |= (ACTOR_FLAG_1 | ACTOR_FLAG_8); 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, + } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_74_40)) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_74_80)) { + 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; func_80C0673C(this); } else { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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,35 +89,35 @@ 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); } } void func_80C0673C(ObjMoonStone* this) { - if (!(gSaveContext.save.weekEventReg[74] & 0x80)) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_74_80)) { this->actor.draw = NULL; } this->actionFunc = func_80C06768; } -void func_80C06768(ObjMoonStone* this, GlobalContext* globalCtx) { - if ((gSaveContext.save.weekEventReg[74] & 0x80)) { +void func_80C06768(ObjMoonStone* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_74_80)) { 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)) { - gSaveContext.save.weekEventReg[74] |= 0x40; - Actor_MarkForDeath(&this->actor); +void func_80C06870(ObjMoonStone* this, PlayState* play) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { + SET_WEEKEVENTREG(WEEKEVENTREG_74_40); + Actor_Kill(&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); + if (!(player->stateFlags1 & (PLAYER_STATE1_2 | PLAYER_STATE1_80 | PLAYER_STATE1_200 | PLAYER_STATE1_10000000))) { + 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_ReplaceRotation(&globalCtx->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, object_gi_reserve00_DL_000C80); - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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..dfb9835a6 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,15 +5,13 @@ 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 -extern const ActorInit Obj_Moon_Stone_InitVars; - #endif // Z_OBJ_MOON_STONE_H diff --git a/src/overlays/actors/ovl_Obj_Mu_Pict/overlay.cfg b/src/overlays/actors/ovl_Obj_Mu_Pict/overlay.cfg deleted file mode 100644 index 77c10a6df..000000000 --- a/src/overlays/actors/ovl_Obj_Mu_Pict/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Mu_Pict -z_obj_mu_pict.c 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..e2750e639 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,22 +10,22 @@ #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 = { +ActorInit Obj_Mu_Pict_InitVars = { ACTOR_OBJ_MU_PICT, ACTORCAT_PROP, FLAGS, @@ -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); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_52_20)) { + Actor_Kill(&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..98902bfb7 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; @@ -17,6 +17,4 @@ typedef struct ObjMuPict { /* 0x14C */ u16 textId; } ObjMuPict; // size = 0x150 -extern const ActorInit Obj_Mu_Pict_InitVars; - #endif // Z_OBJ_MU_PICT_H diff --git a/src/overlays/actors/ovl_Obj_Mure/overlay.cfg b/src/overlays/actors/ovl_Obj_Mure/overlay.cfg deleted file mode 100644 index 99c755b9a..000000000 --- a/src/overlays/actors/ovl_Obj_Mure/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Mure -z_obj_mure.c 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..815c15af8 100644 --- a/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c +++ b/src/overlays/actors/ovl_Obj_Mure/z_obj_mure.c @@ -10,17 +10,17 @@ #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 = { +ActorInit Obj_Mure_InitVars = { ACTOR_OBJ_MURE, ACTORCAT_ITEMACTION, FLAGS, @@ -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,36 +81,36 @@ 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); + Actor_Kill(&this->actor); return; } if (this->type >= OBJMURE_TYPE_MAX) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } - if (!func_808D7928(this, globalCtx)) { - Actor_MarkForDeath(&this->actor); + if (!func_808D7928(this, play)) { + Actor_Kill(&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; @@ -207,16 +207,16 @@ void ObjMure_KillActorsImpl(ObjMure* this, GlobalContext* globalCtx) { break; case OBJMURE_CHILD_STATE_2: if (this->children[i] != NULL) { - Actor_MarkForDeath(this->children[i]); + Actor_Kill(this->children[i]); this->children[i] = NULL; } 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]); + Actor_Kill(this->children[i]); this->children[i] = NULL; } } @@ -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..7bf2d40b7 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,33 @@ 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/overlay.cfg b/src/overlays/actors/ovl_Obj_Mure2/overlay.cfg deleted file mode 100644 index dcb1eb3ac..000000000 --- a/src/overlays/actors/ovl_Obj_Mure2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Mure2 -z_obj_mure2.c 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..bda4dc258 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c @@ -10,15 +10,15 @@ #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 = { +ActorInit Obj_Mure2_InitVars = { ACTOR_OBJ_MURE2, ACTORCAT_PROP, FLAGS, 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..f70d45f1e 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h @@ -5,14 +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; - #endif // Z_OBJ_MURE2_H diff --git a/src/overlays/actors/ovl_Obj_Mure3/overlay.cfg b/src/overlays/actors/ovl_Obj_Mure3/overlay.cfg deleted file mode 100644 index 7774442db..000000000 --- a/src/overlays/actors/ovl_Obj_Mure3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Mure3 -z_obj_mure3.c 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..c8f657c13 100644 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.c @@ -10,16 +10,18 @@ #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 = { +ActorInit Obj_Mure3_InitVars = { ACTOR_OBJ_MURE3, ACTORCAT_BG, FLAGS, @@ -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, PlayState* 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_Kill(&(*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_Kill(&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..8715e4308 100644 --- a/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h +++ b/src/overlays/actors/ovl_Obj_Mure3/z_obj_mure3.h @@ -3,16 +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; - #endif // Z_OBJ_MURE3_H diff --git a/src/overlays/actors/ovl_Obj_Nozoki/overlay.cfg b/src/overlays/actors/ovl_Obj_Nozoki/overlay.cfg deleted file mode 100644 index 9173a8055..000000000 --- a/src/overlays/actors/ovl_Obj_Nozoki/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Nozoki -z_obj_nozoki.c 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 2ff0e093e..933ea06d2 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -6,34 +6,33 @@ #include "z_obj_nozoki.h" #include "objects/object_secom_obj/object_secom_obj.h" -#include "prevent_bss_reordering.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 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, GlobalContext* globalCtx); -void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA2BA4(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx); -void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx); -void ObjNozoki_Draw(Actor* thisx, GlobalContext* globalCtx); +void 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; -const ActorInit Obj_Nozoki_InitVars = { +ActorInit Obj_Nozoki_InitVars = { ACTOR_OBJ_NOZOKI, ACTORCAT_ITEMACTION, FLAGS, @@ -64,7 +63,7 @@ void ObjNozoki_SetupAction(ObjNozoki* this, ObjNozokiActionFunc actionFunc) { this->actionFunc = actionFunc; } -void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjNozoki_Init(Actor* thisx, PlayState* play) { ObjNozoki* this = THIS; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -72,7 +71,7 @@ void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx) { this->dyna.actor.shape.rot.z = 0; this->unk_15F = this->dyna.actor.cutscene; - if (globalCtx->sceneNum == SCENE_AYASHIISHOP) { + if (play->sceneId == SCENE_AYASHIISHOP) { this->unk_15C = 4; ObjNozoki_SetupAction(this, func_80BA3230); this->dyna.actor.colChkInfo.cylRadius = -40; @@ -85,29 +84,29 @@ void ObjNozoki_Init(Actor* thisx, GlobalContext* globalCtx) { } } -void ObjNozoki_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void ObjNozoki_Destroy(Actor* thisx, PlayState* play) { ObjNozoki* this = THIS; if (this->unk_15C == 0) { - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); } } -void func_80BA2514(ObjNozoki* this, GlobalContext* globalCtx) { - s32 sp24 = Object_GetIndex(&globalCtx->objectCtx, D_80BA34B8[this->unk_15C]); +void func_80BA2514(ObjNozoki* this, PlayState* play) { + s32 sp24 = Object_GetIndex(&play->objectCtx, D_80BA34B8[this->unk_15C]); if (sp24 < 0) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } - if (Object_IsLoaded(&globalCtx->objectCtx, sp24)) { + if (Object_IsLoaded(&play->objectCtx, sp24)) { this->dyna.actor.objBankIndex = sp24; this->dyna.actor.draw = ObjNozoki_Draw; if (this->unk_15C == 0) { - Actor_SetObjectDependency(globalCtx, &this->dyna.actor); - DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_secom_obj_Colheader_0001C0); + 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; } @@ -143,8 +142,8 @@ s32 func_80BA26A8(ObjNozoki* this) { return false; } -s32 func_80BA2708(ObjNozoki* this, GlobalContext* globalCtx) { - Actor* enemy = globalCtx->actorCtx.actorLists[ACTORCAT_ENEMY].first; +s32 func_80BA2708(ObjNozoki* this, PlayState* play) { + Actor* enemy = play->actorCtx.actorLists[ACTORCAT_ENEMY].first; Vec3f sp30; while (enemy != NULL) { @@ -164,18 +163,18 @@ void func_80BA2790(ObjNozoki* this) { this->unk_15E = 0; } -void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx) { - if (!(globalCtx->actorCtx.unk5 & 0x20)) { +void func_80BA27C4(ObjNozoki* this, PlayState* play) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_5)) { if (OBJNOZOKI_GET_200(&this->dyna.actor)) { - if (!func_80BA2708(this, globalCtx)) { + if (!func_80BA2708(this, play)) { return; } } else { if (D_80BA36B0 != 0) { - globalCtx->actorCtx.unk5 |= 0x80; + play->actorCtx.flags |= ACTORCTX_FLAG_7; } - if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + if (!Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { return; } } @@ -190,14 +189,14 @@ void func_80BA27C4(ObjNozoki* this, GlobalContext* globalCtx) { if (this->unk_15E < 0) { this->unk_15E = 50; } - globalCtx->actorCtx.unk5 |= 0x10; + play->actorCtx.flags |= ACTORCTX_FLAG_4; } } - GET_PLAYER(globalCtx)->linearVelocity = 0.0f; + GET_PLAYER(play)->linearVelocity = 0.0f; } } -void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx) { +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); @@ -205,22 +204,22 @@ void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx) { return; } - if (!(globalCtx->actorCtx.unk5 & 0x20)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_5)) { Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 200.0f, this->dyna.actor.velocity.y); if (OBJNOZOKI_GET_200(&this->dyna.actor)) { - if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + if (!Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { return; } - } else if (Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + } 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(globalCtx)->actor.world.pos); + 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); } @@ -243,7 +242,7 @@ void func_80BA28DC(ObjNozoki* this, GlobalContext* globalCtx) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); } -void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx) { +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)) { @@ -251,22 +250,22 @@ void func_80BA2AB4(ObjNozoki* this, GlobalContext* globalCtx) { D_80BA36B0 = 1; } - if (!(globalCtx->actorCtx.unk5 & 0x20)) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_5)) { if (!(OBJNOZOKI_GET_200(&this->dyna.actor)) && - Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { func_80BA2790(this); } } } -void func_80BA2B64(ObjNozoki* this, GlobalContext* globalCtx, s32 arg2, s32 arg3) { +void func_80BA2B64(ObjNozoki* this, PlayState* play, s32 arg2, s32 arg3) { this->unk_15D = arg2; this->unk_15E = 80; - Flags_UnsetSwitch(globalCtx, arg3); + Flags_UnsetSwitch(play, arg3); } -void func_80BA2BA4(ObjNozoki* this, GlobalContext* globalCtx) { - if (!Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { +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) { @@ -288,7 +287,7 @@ s32 func_80BA2C28(ObjNozoki* this) { return -1; } -void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx) { +void func_80BA2C94(ObjNozoki* this, PlayState* play) { s32 temp_v0 = func_80BA2C28(this); f32 sp38; f32 sp34; @@ -298,26 +297,26 @@ void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx) { D_80BA36B4 = temp_v0; } - if ((temp_v0 < 0) && Play_InCsMode(globalCtx)) { + 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(globalCtx, this->dyna.actor.world.rot.z)) { - func_80BA2B64(this, globalCtx, 1, this->dyna.actor.world.rot.x); - } else if ((this->unk_15D != 2) && Flags_GetSwitch(globalCtx, this->dyna.actor.world.rot.x)) { - func_80BA2B64(this, globalCtx, 2, this->dyna.actor.world.rot.z); + 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(globalCtx, this->dyna.actor.world.rot.z); - Flags_UnsetSwitch(globalCtx, this->dyna.actor.world.rot.x); + 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 ((globalCtx->actorCtx.unk5 & 0x40) || (globalCtx->actorCtx.unk5 & 0x20)) { + if ((play->actorCtx.flags & ACTORCTX_FLAG_6) || (play->actorCtx.flags & ACTORCTX_FLAG_5)) { temp_f0 = 0.5f; } else { temp_f0 = this->dyna.actor.speedXZ; @@ -327,20 +326,20 @@ void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx) { D_80BA36B8 += this->dyna.actor.speedXZ; - if (globalCtx->actorCtx.unk5 & 0x40) { + if (play->actorCtx.flags & ACTORCTX_FLAG_6) { if (sp34 <= 5.0f) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } - } else if (!(globalCtx->actorCtx.unk5 & 0x20) && (GET_PLAYER(globalCtx)->actor.id == ACTOR_PLAYER) && - Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG2(&this->dyna.actor)) && (sp38 < 20.0f)) { + } else if (!(play->actorCtx.flags & ACTORCTX_FLAG_5) && (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 }; - globalCtx->actorCtx.unk5 |= 0x40; + play->actorCtx.flags |= ACTORCTX_FLAG_6; Lib_Vec3f_TranslateAndRotateY(&this->dyna.actor.home.pos, this->dyna.actor.shape.rot.y, &D_80BA34F0, &this->dyna.actor.world.pos); this->dyna.actor.shape.rot.x = -0x1F40; } else if (sp34 < 50.0f) { - globalCtx->actorCtx.unk5 |= 0x20; + play->actorCtx.flags |= ACTORCTX_FLAG_5; if (sp34 < 20.0f) { this->dyna.actor.velocity.y -= 0.4f; @@ -348,7 +347,7 @@ void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx) { sp38 = this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y; if (sp38 >= 100.0f) { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); } this->dyna.actor.shape.rot.x = -0x1F40 - (s16)(sp38 * 400.0f); @@ -361,21 +360,21 @@ void func_80BA2C94(ObjNozoki* this, GlobalContext* globalCtx) { this->dyna.actor.velocity.x -= 0x10000; } - globalCtx->roomCtx.unk7A[0] = this->dyna.actor.velocity.x; + play->roomCtx.unk7A[0] = this->dyna.actor.velocity.x; - func_8019FAD8(&D_801DB4A4, NA_SE_EV_SECOM_CONVEYOR - SFX_FLAG, this->dyna.actor.speedXZ); + func_8019FAD8(&gSfxDefaultPos, NA_SE_EV_SECOM_CONVEYOR - SFX_FLAG, this->dyna.actor.speedXZ); } -void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx) { +void func_80BA3044(ObjNozoki* this, PlayState* play) { Vec3f* sp1C = &this->dyna.actor.focus.pos; if (this->unk_15D == 0) { - if (globalCtx->actorCtx.unk5 & 0x40) { + if (play->actorCtx.flags & ACTORCTX_FLAG_6) { this->unk_15D = 1; this->unk_15E = 20; Math_Vec3f_Copy(&this->dyna.actor.world.pos, sp1C); - } else if (!(globalCtx->actorCtx.unk5 & 0x20) && - Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + } else if (!(play->actorCtx.flags & ACTORCTX_FLAG_5) && + Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { sp1C = &this->dyna.actor.home.pos; } } else if (DECR(this->unk_15E) == 0) { @@ -385,9 +384,9 @@ void func_80BA3044(ObjNozoki* this, GlobalContext* globalCtx) { Math_Vec3f_StepToXZ(&this->dyna.actor.world.pos, sp1C, 8.0f); } -void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx) { +void func_80BA311C(ObjNozoki* this, PlayState* play) { if (this->unk_15D == 0) { - if (Flags_GetSwitch(globalCtx, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { + if (Flags_GetSwitch(play, OBJNOZOKI_GET_SWITCHFLAG1(&this->dyna.actor))) { this->unk_15D = 1; this->unk_15E = 70; } @@ -407,50 +406,50 @@ void func_80BA311C(ObjNozoki* this, GlobalContext* globalCtx) { } } -void func_80BA3230(ObjNozoki* this, GlobalContext* globalCtx) { - if (gSaveContext.save.weekEventReg[64] & 0x20) { - Actor* npc = globalCtx->actorCtx.actorLists[ACTORCAT_NPC].first; - Actor* test3 = SubS_FindActor(globalCtx, npc, ACTORCAT_NPC, ACTOR_EN_TEST3); +void func_80BA3230(ObjNozoki* this, PlayState* play) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_64_20)) { + 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 ((globalCtx->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { + if ((play->curSpawn == 3) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_64_40)) { 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_64_40)) { this->dyna.actor.textId = 0; } else { this->dyna.actor.textId = 0x2979; } } - if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state)) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state)) { ObjNozoki_SetupAction(this, func_80BA3344); } else { - func_800B8614(&this->dyna.actor, globalCtx, 50.0f); + func_800B8614(&this->dyna.actor, play, 50.0f); } } } } -void func_80BA3344(ObjNozoki* this, GlobalContext* globalCtx) { - if ((globalCtx->curSpawn == 3) && !(gSaveContext.save.weekEventReg[64] & 0x40)) { - if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { - gSaveContext.save.weekEventReg[64] |= 0x40; +void func_80BA3344(ObjNozoki* this, PlayState* play) { + if ((play->curSpawn == 3) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_64_40)) { + if (Actor_TextboxIsClosing(&this->dyna.actor, play)) { + SET_WEEKEVENTREG(WEEKEVENTREG_64_40); this->dyna.actor.flags &= ~ACTOR_FLAG_10000; ObjNozoki_SetupAction(this, func_80BA3230); } - } else if ((this->dyna.actor.textId == 0) || Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { - globalCtx->nextEntranceIndex = 0xE20; - globalCtx->sceneLoadFlag = 0x14; + } 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, GlobalContext* globalCtx) { +void ObjNozoki_Update(Actor* thisx, PlayState* play) { ObjNozoki* this = THIS; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } Gfx* D_80BA34FC[] = { @@ -461,12 +460,12 @@ Gfx* D_80BA34FC[] = { object_secom_obj_DL_001300, }; -void ObjNozoki_Draw(Actor* thisx, GlobalContext* globalCtx) { +void ObjNozoki_Draw(Actor* thisx, PlayState* play) { ObjNozoki* this = THIS; if (this->unk_15C == 1) { - GetItem_Draw(globalCtx, GID_39); + GetItem_Draw(play, GID_MASK_SUN); } else { - Gfx_DrawDListOpa(globalCtx, D_80BA34FC[this->unk_15C]); + 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 08af2bc02..4c4b74916 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.h @@ -5,7 +5,7 @@ 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) @@ -16,14 +16,12 @@ typedef void (*ObjNozokiActionFunc)(struct ObjNozoki*, GlobalContext*); #define OBJNOZOKI_400 0x400 typedef struct ObjNozoki { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ u8 unk_15C; - /* 0x015D */ u8 unk_15D; - /* 0x015E */ s8 unk_15E; - /* 0x015F */ s8 unk_15F; - /* 0x0160 */ ObjNozokiActionFunc actionFunc; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ u8 unk_15C; + /* 0x15D */ u8 unk_15D; + /* 0x15E */ s8 unk_15E; + /* 0x15F */ s8 unk_15F; + /* 0x160 */ ObjNozokiActionFunc actionFunc; } ObjNozoki; // size = 0x164 -extern const ActorInit Obj_Nozoki_InitVars; - #endif // Z_OBJ_NOZOKI_H diff --git a/src/overlays/actors/ovl_Obj_Ocarinalift/overlay.cfg b/src/overlays/actors/ovl_Obj_Ocarinalift/overlay.cfg deleted file mode 100644 index 3d9eef7c4..000000000 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Ocarinalift -z_obj_ocarinalift.c 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..3a25ef402 100644 --- a/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c +++ b/src/overlays/actors/ovl_Obj_Ocarinalift/z_obj_ocarinalift.c @@ -5,18 +5,33 @@ */ #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); -#if 0 -const ActorInit Obj_Ocarinalift_InitVars = { +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); + +ActorInit Obj_Ocarinalift_InitVars = { ACTOR_OBJ_OCARINALIFT, ACTORCAT_BG, FLAGS, @@ -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..3789383c2 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,30 @@ #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 -extern const ActorInit Obj_Ocarinalift_InitVars; +typedef enum ObjOcarinaliftParams { + /* 0x0 */ OBJOCARINALIFT_PARAMSC_0, + /* 0x1 */ OBJOCARINALIFT_PARAMSC_1 +} ObjOcarinaliftParams; #endif // Z_OBJ_OCARINALIFT_H diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/overlay.cfg b/src/overlays/actors/ovl_Obj_Oshihiki/overlay.cfg deleted file mode 100644 index 48cf4049f..000000000 --- a/src/overlays/actors/ovl_Obj_Oshihiki/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Oshihiki -z_obj_oshihiki.c 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 fac52301a..1d7762c44 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -12,20 +12,20 @@ #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 = { +ActorInit Obj_Oshihiki_InitVars = { ACTOR_OBJ_OSHIHIKI, ACTORCAT_PROP, FLAGS, @@ -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,19 +193,19 @@ 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: case OBJOSHIHIKI_F_2: - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } } else { @@ -213,30 +213,30 @@ void ObjOshihiki_Init(Actor* thisx, GlobalContext* globalCtx) { case OBJOSHIHIKI_F_3: case OBJOSHIHIKI_F_4: case OBJOSHIHIKI_F_5: - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } } } - 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,9 +291,9 @@ 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); + Actor_Kill(&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,31 +391,31 @@ 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; } } - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } } else if (fabsf(this->dyna.pushForce) > 0.001f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } } -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,63 +424,63 @@ 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); } } if (!sp20 && (fabsf(this->dyna.pushForce) > 0.001f)) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } } -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,77 +491,76 @@ 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; + player->stateFlags2 &= ~PLAYER_STATE2_10; 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); } 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; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; this->pushDist = 0.0f; this->pushSpeed = 0.0f; 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; if (fabsf(this->dyna.pushForce) > 0.001f) { this->dyna.pushForce = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; } 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)) { + 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..d2f61e2cf 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,28 +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; - #endif // Z_OBJ_OSHIHIKI_H diff --git a/src/overlays/actors/ovl_Obj_Purify/overlay.cfg b/src/overlays/actors/ovl_Obj_Purify/overlay.cfg deleted file mode 100644 index 966356722..000000000 --- a/src/overlays/actors/ovl_Obj_Purify/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Purify -z_obj_purify.c 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..ee26937da 100644 --- a/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c +++ b/src/overlays/actors/ovl_Obj_Purify/z_obj_purify.c @@ -5,17 +5,43 @@ */ #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); -#if 0 -const ActorInit Obj_Purify_InitVars = { +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 + +ActorInit Obj_Purify_InitVars = { ACTOR_OBJ_PURIFY, ACTORCAT_BG, FLAGS, @@ -27,42 +53,245 @@ 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) { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_12_01)) { + return true; + } + } else { + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_02)) { + 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_Kill(&this->dyna.actor); + } else if (sp20 == 0) { + func_80A84EAC(this); + } else if (ObjPurify_IsPurified(this)) { + Actor_Kill(&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_Kill(&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..2651bf049 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,18 @@ 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/overlay.cfg b/src/overlays/actors/ovl_Obj_Pzlblock/overlay.cfg deleted file mode 100644 index d2b05c1ff..000000000 --- a/src/overlays/actors/ovl_Obj_Pzlblock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Pzlblock -z_obj_pzlblock.c 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..3aca23bca 100644 --- a/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c +++ b/src/overlays/actors/ovl_Obj_Pzlblock/z_obj_pzlblock.c @@ -12,20 +12,20 @@ #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 = { +ActorInit Obj_Pzlblock_InitVars = { ACTOR_OBJ_PZLBLOCK, ACTORCAT_PROP, FLAGS, @@ -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 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; } } @@ -278,28 +278,28 @@ 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; } - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_10; this->dyna.pushForce = 0.0f; if (sp20 == 0) { func_809A3A48(this); @@ -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 &= ~PLAYER_STATE2_10; 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..27a038860 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) @@ -25,6 +25,4 @@ typedef struct ObjPzlblock { /* 0x17A */ s8 unk_17A; } ObjPzlblock; // size = 0x17C -extern const ActorInit Obj_Pzlblock_InitVars; - #endif // Z_OBJ_PZLBLOCK_H diff --git a/src/overlays/actors/ovl_Obj_Raillift/overlay.cfg b/src/overlays/actors/ovl_Obj_Raillift/overlay.cfg deleted file mode 100644 index 69c3fc70c..000000000 --- a/src/overlays/actors/ovl_Obj_Raillift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Raillift -z_obj_raillift.c 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..d0a705cf2 100644 --- a/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c +++ b/src/overlays/actors/ovl_Obj_Raillift/z_obj_raillift.c @@ -6,28 +6,29 @@ #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_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_DoNothing(ObjRaillift* this, PlayState* play); +void ObjRaillift_Idle(ObjRaillift* this, PlayState* play); +void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 index); +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 = { +ActorInit Obj_Raillift_InitVars = { ACTOR_OBJ_RAILLIFT, ACTORCAT_BG, FLAGS, @@ -48,11 +49,11 @@ static InitChainEntry sInitChain[] = { static CollisionHeader* sColHeaders[] = { &object_raillift_Colheader_004FF8, &object_raillift_Colheader_0048D0 }; -void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 idx) { - Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->points[idx]); +void ObjRaillift_UpdatePosition(ObjRaillift* this, s32 index) { + Math_Vec3s_ToVec3f(&this->dyna.actor.world.pos, &this->points[index]); } -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..41b7a821e 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) @@ -38,6 +38,4 @@ typedef struct ObjRaillift { /* 0x188 */ s16 cutsceneTimer; } ObjRaillift; // size = 0x18C -extern const ActorInit Obj_Raillift_InitVars; - #endif // Z_OBJ_RAILLIFT_H diff --git a/src/overlays/actors/ovl_Obj_Roomtimer/overlay.cfg b/src/overlays/actors/ovl_Obj_Roomtimer/overlay.cfg deleted file mode 100644 index b4eef8427..000000000 --- a/src/overlays/actors/ovl_Obj_Roomtimer/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Roomtimer -z_obj_roomtimer.c 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..154f662f8 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.c @@ -10,15 +10,15 @@ #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 = { +ActorInit Obj_Roomtimer_InitVars = { ACTOR_OBJ_ROOMTIMER, ACTORCAT_ENEMY, FLAGS, @@ -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,52 +42,53 @@ 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) { - gSaveContext.unk_3DD0[4] = 5; + if ((this->actor.params != 0x1FF) && (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] >= TIMER_STATE_START)) { + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } } -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); + Interface_StartTimer(TIMER_ID_MINIGAME_2, 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; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_STOP; } ActorCutscene_SetIntentToPlay(this->actor.cutscene); this->actionFunc = func_80973DE0; - } else if (this->actor.params != 0x1FF && gSaveContext.unk_3DD0[4] == 0) { + } else if ((this->actor.params != 0x1FF) && (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] == TIMER_STATE_OFF)) { play_sound(NA_SE_OC_ABYSS); - func_80169EFC(&globalCtx->state); - Actor_MarkForDeath(&this->actor); + func_80169EFC(&play->state); + Actor_Kill(&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); } - Actor_MarkForDeath(&this->actor); - } else { - ActorCutscene_SetIntentToPlay(this->actor.cutscene); + Actor_Kill(&this->actor); + return; } + + ActorCutscene_SetIntentToPlay(this->actor.cutscene); } -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..5ce7d13d4 100644 --- a/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h +++ b/src/overlays/actors/ovl_Obj_Roomtimer/z_obj_roomtimer.h @@ -7,14 +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; - #endif // Z_OBJ_ROOMTIMER_H diff --git a/src/overlays/actors/ovl_Obj_Rotlift/overlay.cfg b/src/overlays/actors/ovl_Obj_Rotlift/overlay.cfg deleted file mode 100644 index 7c2884ce4..000000000 --- a/src/overlays/actors/ovl_Obj_Rotlift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Rotlift -z_obj_rotlift.c 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..ce18a68b0 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.c @@ -5,18 +5,27 @@ */ #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); -#if 0 -const ActorInit Obj_Rotlift_InitVars = { +void ObjRotlift_MoveDekuFlowers(ObjRotlift* this); + +typedef struct ObjRotliftModelInfo { + /* 0x0 */ Gfx* dList; + /* 0x4 */ AnimatedMaterial* animMat; + /* 0x8 */ CollisionHeader* colHeader; +} ObjRotliftModelInfo; // size = 0xC + +ActorInit Obj_Rotlift_InitVars = { ACTOR_OBJ_ROTLIFT, ACTORCAT_BG, FLAGS, @@ -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..df3fe1dee 100644 --- a/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h +++ b/src/overlays/actors/ovl_Obj_Rotlift/z_obj_rotlift.h @@ -3,13 +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; - #endif // Z_OBJ_ROTLIFT_H diff --git a/src/overlays/actors/ovl_Obj_Shutter/overlay.cfg b/src/overlays/actors/ovl_Obj_Shutter/overlay.cfg deleted file mode 100644 index 9b5210eb4..000000000 --- a/src/overlays/actors/ovl_Obj_Shutter/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Shutter -z_obj_shutter.c 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..6f93935b2 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.c @@ -5,18 +5,18 @@ */ #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 = { +ActorInit Obj_Shutter_InitVars = { ACTOR_OBJ_SHUTTER, ACTORCAT_PROP, FLAGS, @@ -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..3f23b3dfe 100644 --- a/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h +++ b/src/overlays/actors/ovl_Obj_Shutter/z_obj_shutter.h @@ -7,9 +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; - #endif // Z_OBJ_SHUTTER_H diff --git a/src/overlays/actors/ovl_Obj_Skateblock/overlay.cfg b/src/overlays/actors/ovl_Obj_Skateblock/overlay.cfg deleted file mode 100644 index bb4e2fec8..000000000 --- a/src/overlays/actors/ovl_Obj_Skateblock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Skateblock -z_obj_skateblock.c 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..6a469eea0 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -11,23 +11,23 @@ #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 = { +ActorInit Obj_Skateblock_InitVars = { ACTOR_OBJ_SKATEBLOCK, ACTORCAT_BG, FLAGS, @@ -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,10 +366,10 @@ 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; + player->stateFlags2 &= ~PLAYER_STATE2_10; 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, PLAYER_CSMODE_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, PLAYER_CSMODE_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..ab4f37240 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h @@ -5,33 +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; - #endif // Z_OBJ_SKATEBLOCK_H diff --git a/src/overlays/actors/ovl_Obj_Smork/overlay.cfg b/src/overlays/actors/ovl_Obj_Smork/overlay.cfg deleted file mode 100644 index 35a105b7d..000000000 --- a/src/overlays/actors/ovl_Obj_Smork/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Smork -z_obj_smork.c 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 83e286e97..dd02f6c1b 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.c @@ -11,12 +11,12 @@ #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 = { +ActorInit Obj_Smork_InitVars = { ACTOR_OBJ_SMORK, ACTORCAT_PROP, FLAGS, @@ -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; @@ -109,25 +109,25 @@ void func_80A3D9C4(ObjSmork* this, GlobalContext* globalCtx) { if (this->unk_1B8 > 0.0f) { Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); - this->actor.shape.rot.y = BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx))); + 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)); @@ -135,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_Smork/z_obj_smork.h b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h index 5ab3e405c..a1b21d442 100644 --- a/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h +++ b/src/overlays/actors/ovl_Obj_Smork/z_obj_smork.h @@ -16,6 +16,4 @@ typedef struct ObjSmork { /* 0x1C6 */ s16 unk_1C6; } ObjSmork; // size = 0x1C8 -extern const ActorInit Obj_Smork_InitVars; - #endif // Z_OBJ_SMORK_H diff --git a/src/overlays/actors/ovl_Obj_Snowball/overlay.cfg b/src/overlays/actors/ovl_Obj_Snowball/overlay.cfg deleted file mode 100644 index 45a8a39bd..000000000 --- a/src/overlays/actors/ovl_Obj_Snowball/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Snowball -z_obj_snowball.c 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 3979479f6..068be3ea0 100644 --- a/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c +++ b/src/overlays/actors/ovl_Obj_Snowball/z_obj_snowball.c @@ -12,28 +12,28 @@ #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 = { +ActorInit Obj_Snowball_InitVars = { ACTOR_OBJ_SNOWBALL, ACTORCAT_PROP, FLAGS, @@ -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))) { - Actor_MarkForDeath(&this->actor); + if ((sp40 == 5) && Flags_GetSwitch(play, OBJSNOWBALL_GET_3F(&this->actor))) { + Actor_Kill(&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); + Actor_Kill(&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,7 +683,7 @@ 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_RotateZYX(ptr->unk_1C.x, ptr->unk_1C.y, ptr->unk_1C.z, MTXMODE_NEW); @@ -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,9 +723,9 @@ 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); + Actor_Kill(&this->actor); } } else { for (i = 0; i < ARRAY_COUNT(this->unk_1A8); i++) { @@ -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; @@ -814,12 +813,12 @@ void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { 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); @@ -829,11 +828,11 @@ void func_80B04D34(Actor* thisx, GlobalContext* globalCtx) { 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..804c2596c 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) @@ -40,6 +40,4 @@ typedef struct ObjSnowball { /* 0x211 */ s8 unk_211; } ObjSnowball; // size = 0x214 -extern const ActorInit Obj_Snowball_InitVars; - #endif // Z_OBJ_SNOWBALL_H diff --git a/src/overlays/actors/ovl_Obj_Snowball2/overlay.cfg b/src/overlays/actors/ovl_Obj_Snowball2/overlay.cfg deleted file mode 100644 index 5d740b086..000000000 --- a/src/overlays/actors/ovl_Obj_Snowball2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Snowball2 -z_obj_snowball2.c 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 5356e2e88..d62002e73 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.c @@ -11,22 +11,22 @@ #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 = { +ActorInit Obj_Snowball2_InitVars = { ACTOR_OBJ_SNOWBALL2, ACTORCAT_PROP, FLAGS, @@ -61,7 +61,7 @@ static ColliderJntSphInit sJntSphInit = { OC2_TYPE_2, COLSHAPE_JNTSPH, }, - 1, + ARRAY_COUNT(sJntSphElementsInit), sJntSphElementsInit, }; @@ -86,20 +86,19 @@ void func_80B38E20(ObjSnowball2* this) { 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.curRoom.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); - Actor_MarkForDeath(&this->actor); + func_80B38E88(this, play); + func_80B39108(this, play); + func_80B39B5C(this, play); + Actor_Kill(&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.curRoom.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,13 +458,13 @@ 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); - Actor_MarkForDeath(&this->actor); + func_80B38E88(this, play); + func_80B39108(this, play); + func_80B39B5C(this, play); + Actor_Kill(&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,12 +565,12 @@ 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) { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); return; } @@ -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..19bd173fb 100644 --- a/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h +++ b/src/overlays/actors/ovl_Obj_Snowball2/z_obj_snowball2.h @@ -5,25 +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; - #endif // Z_OBJ_SNOWBALL2_H diff --git a/src/overlays/actors/ovl_Obj_Sound/overlay.cfg b/src/overlays/actors/ovl_Obj_Sound/overlay.cfg deleted file mode 100644 index d1863878b..000000000 --- a/src/overlays/actors/ovl_Obj_Sound/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Sound -z_obj_sound.c 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..42c2bcc95 100644 --- a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c +++ b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.c @@ -10,12 +10,12 @@ #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 = { +ActorInit Obj_Sound_InitVars = { ACTOR_OBJ_SOUND, ACTORCAT_ITEMACTION, FLAGS, diff --git a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.h b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.h index 8f3c80257..a83aa840b 100644 --- a/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.h +++ b/src/overlays/actors/ovl_Obj_Sound/z_obj_sound.h @@ -10,6 +10,4 @@ typedef struct ObjSound { /* 0x144 */ char unk_144[0x4]; } ObjSound; // size = 0x148 -extern const ActorInit Obj_Sound_InitVars; - #endif // Z_OBJ_SOUND_H diff --git a/src/overlays/actors/ovl_Obj_Spidertent/overlay.cfg b/src/overlays/actors/ovl_Obj_Spidertent/overlay.cfg deleted file mode 100644 index f5f13b8ad..000000000 --- a/src/overlays/actors/ovl_Obj_Spidertent/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Spidertent -z_obj_spidertent.c 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 37ceb7268..4708062da 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.c @@ -11,19 +11,19 @@ #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 = { +ActorInit Obj_Spidertent_InitVars = { ACTOR_OBJ_SPIDERTENT, ACTORCAT_BG, FLAGS, @@ -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; @@ -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,26 +522,26 @@ 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; f32 sp54; - if (player->itemActionParam == 7) { + if (player->heldItemAction == PLAYER_IA_STICK) { if (player->unk_B28 > 0) { for (i = 0; i < ARRAY_COUNT(this->colliderElements); i++) { triNorm = &this->collider.elements[i].dim; - if (func_80B2FB94(&player->swordInfo[0].tip, 6.0f, triNorm, &sp58, &sp54) && + 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); @@ -562,15 +562,15 @@ void ObjSpidertent_Init(Actor* thisx, GlobalContext* globalCtx) { 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))) { - Actor_MarkForDeath(&this->dyna.actor); + if (Flags_GetSwitch(play, OBJSPIDERTENT_GET_7F00(&this->dyna.actor))) { + Actor_Kill(&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); + 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); @@ -596,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) { @@ -611,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)]; @@ -625,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; @@ -658,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; } @@ -666,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); } } @@ -675,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, PLAYER_CSMODE_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); @@ -695,15 +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; s32 j; s32 pad; - Vec3f sp60; - f32 sp5C; this->unk_3C6++; @@ -759,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); } @@ -781,45 +777,46 @@ 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); } } } } else if (this->unk_3C1 <= 0) { ActorCutscene_Stop(this->dyna.actor.cutscene); - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&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..881a816a7 100644 --- a/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h +++ b/src/overlays/actors/ovl_Obj_Spidertent/z_obj_spidertent.h @@ -5,28 +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; - #endif // Z_OBJ_SPIDERTENT_H diff --git a/src/overlays/actors/ovl_Obj_Spinyroll/overlay.cfg b/src/overlays/actors/ovl_Obj_Spinyroll/overlay.cfg deleted file mode 100644 index 38ea69b6d..000000000 --- a/src/overlays/actors/ovl_Obj_Spinyroll/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Spinyroll -z_obj_spinyroll.c 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 2b15ef0b6..83959e168 100644 --- a/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c +++ b/src/overlays/actors/ovl_Obj_Spinyroll/z_obj_spinyroll.c @@ -11,24 +11,24 @@ #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* play2); +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 = { +ActorInit Obj_Spinyroll_InitVars = { ACTOR_OBJ_SPINYROLL, ACTORCAT_PROP, FLAGS, @@ -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]; @@ -510,7 +500,7 @@ void ObjSpinyroll_Init(Actor* thisx, GlobalContext* globalCtx) { ((sp34->x == sp30->x) && (sp34->y == sp30->y) && (sp34->z != sp30->z))) { this->unk_49C = false; } else { - Actor_MarkForDeath(&this->dyna.actor); + Actor_Kill(&this->dyna.actor); return; } @@ -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; @@ -697,12 +687,12 @@ void ObjSpinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { 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..36d8e644a 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,44 +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; - #endif // Z_OBJ_SPINYROLL_H diff --git a/src/overlays/actors/ovl_Obj_Switch/overlay.cfg b/src/overlays/actors/ovl_Obj_Switch/overlay.cfg deleted file mode 100644 index 683d4ae00..000000000 --- a/src/overlays/actors/ovl_Obj_Switch/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Switch -z_obj_switch.c 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 8b61f265b..ada5eadd3 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 }, @@ -70,7 +71,7 @@ static TexturePtr sEyeSwitchTextures[][4] = { static s32 sIsSegmentTableInit = false; -const ActorInit Obj_Switch_InitVars = { +ActorInit Obj_Switch_InitVars = { ACTOR_OBJ_SWITCH, ACTORCAT_SWITCH, FLAGS, @@ -203,11 +204,11 @@ 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); + 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), @@ -216,14 +217,14 @@ void ObjSwitch_InitJntSphCollider(ObjSwitch* this, GlobalContext* globalCtx, Col 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); + 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 + @@ -240,22 +241,22 @@ void ObjSwitch_InitTrisCollider(ObjSwitch* this, GlobalContext* globalCtx, Colli Matrix_Pop(); } -Actor* ObjSwitch_SpawnIce(ObjSwitch* this, GlobalContext* globalCtx) { - return Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_OBJ_ICE_POLY, +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.flags & ACTORCTX_FLAG_7) { + 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->sceneId == 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->sceneId == 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; @@ -410,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); @@ -457,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; } @@ -503,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; @@ -560,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); } @@ -576,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->sceneId == SCENE_SECOM) && DynaPolyActor_IsInSwitchPressedState(&this->dyna)) { + ObjSwitch_SetSwitchFlagState(this, play, true); } else { ObjSwitch_FloorSwitchRiseUpInit(this); } @@ -595,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->sceneId == 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->sceneId == SCENE_SECOM) { this->floorSwitchReleaseTimer = 2; } else { this->floorSwitchReleaseTimer = 6; @@ -621,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); @@ -661,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); @@ -674,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); } } @@ -685,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); @@ -699,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); } @@ -710,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; } @@ -720,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); @@ -736,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); @@ -746,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; @@ -771,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); @@ -793,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); @@ -803,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); @@ -820,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) { @@ -837,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); } } @@ -861,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); } @@ -877,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 { @@ -904,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); @@ -913,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) { @@ -922,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; } @@ -941,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--; } @@ -956,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..764c724a0 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,35 +33,33 @@ 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; - #define OBJ_SWITCH_GET_TYPE(thisx) ((thisx)->params&7) #define OBJ_SWITCH_GET_SUBTYPE(thisx) ((thisx)->params >> 4 & 7) #define OBJ_SWITCH_GET_SWITCH_FLAG(thisx) ((thisx)->params >> 8 & 0x7F) diff --git a/src/overlays/actors/ovl_Obj_Swprize/overlay.cfg b/src/overlays/actors/ovl_Obj_Swprize/overlay.cfg deleted file mode 100644 index 4b73ca304..000000000 --- a/src/overlays/actors/ovl_Obj_Swprize/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Swprize -z_obj_swprize.c 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..578244237 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.c @@ -10,17 +10,20 @@ #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 ObjSwprize_DoNothing(ObjSwprize* this, PlayState* play); +void func_80C25654(ObjSwprize* this, PlayState* play); +void func_80C25640(ObjSwprize* this); +void func_80C25698(ObjSwprize* this); +void func_80C256AC(ObjSwprize* this, PlayState* play); +void func_80C25710(ObjSwprize* this); +void func_80C2572C(ObjSwprize* this, PlayState* play); +void ObjSwprize_SetupDoNothing(ObjSwprize* this); -#if 0 -const ActorInit Obj_Swprize_InitVars = { +ActorInit Obj_Swprize_InitVars = { ACTOR_OBJ_SWPRIZE, ACTORCAT_PROP, FLAGS, @@ -32,30 +35,113 @@ const ActorInit Obj_Swprize_InitVars = { (ActorFunc)NULL, }; -#endif +s16 D_80C257F0[] = { 2, 0x14, 1, 8 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25360.s") +s16 D_80C257F8[] = { -0x888, 0, 0x888 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C253D0.s") +void func_80C25360(ObjSwprize* this, Vec3f* vec) { + 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, vec); + Matrix_Pop(); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/ObjSwprize_Init.s") +void func_80C253D0(ObjSwprize* this, PlayState* play) { + Actor* thisx = &this->actor; + s32 i; + Actor* collectible; + Vec3f sp78; + s32 type = OBJ_SWPRIZE_GET_TYPE(thisx); + s32 temp_s0 = D_80C257F0[type]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/ObjSwprize_Destroy.s") + func_80C25360(this, &sp78); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25640.s") + if (type == 2) { + for (i = 0; i < 3; i++) { + collectible = Item_DropCollectible(play, &thisx->world.pos, temp_s0); + if (collectible != NULL) { + if (sp78.y < 0.98f) { + collectible->velocity.y = (sp78.y + 1.0f) * 4.0f; + collectible->speedXZ = (2.0f * (1.0f - fabsf(sp78.y))) + 2.0f; + collectible->world.rot.y = Math_Atan2S_XY(sp78.z, sp78.x) + D_80C257F8[i]; + } else { + collectible->world.rot.y = i * (0x10000 / 3); + } + } + } + } else { + collectible = Item_DropCollectible(play, &thisx->world.pos, temp_s0); + if ((collectible != NULL) && (sp78.y < 0.98f)) { + collectible->velocity.y = (sp78.y + 1.0f) * 4.0f; + collectible->speedXZ = (2.0f * (1.0f - fabsf(sp78.y))) + 2.0f; + collectible->world.rot.y = Math_Atan2S_XY(sp78.z, sp78.x); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25654.s") +void ObjSwprize_Init(Actor* thisx, PlayState* play) { + ObjSwprize* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25698.s") + if (Flags_GetSwitch(play, OBJ_SWPRIZE_GET_SWITCH_FLAG(&this->actor))) { + ObjSwprize_SetupDoNothing(this); + } else { + func_80C25640(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C256AC.s") +void ObjSwprize_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25710.s") +void func_80C25640(ObjSwprize* this) { + this->actionFunc = func_80C25654; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C2572C.s") +void func_80C25654(ObjSwprize* this, PlayState* play) { + if (Flags_GetSwitch(play, OBJ_SWPRIZE_GET_SWITCH_FLAG(&this->actor))) { + func_80C25698(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25780.s") +void func_80C25698(ObjSwprize* this) { + this->actionFunc = func_80C256AC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/func_80C25794.s") +void func_80C256AC(ObjSwprize* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); + func_80C253D0(this, play); + func_80C25710(this); + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Swprize/ObjSwprize_Update.s") +void func_80C25710(ObjSwprize* this) { + this->timer = 40; + this->actionFunc = func_80C2572C; +} + +void func_80C2572C(ObjSwprize* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + if (this->timer == 0) { + ActorCutscene_Stop(this->actor.cutscene); + ObjSwprize_SetupDoNothing(this); + } + } +} + +void ObjSwprize_SetupDoNothing(ObjSwprize* this) { + this->actionFunc = ObjSwprize_DoNothing; +} + +void ObjSwprize_DoNothing(ObjSwprize* this, PlayState* play) { +} + +void ObjSwprize_Update(Actor* thisx, PlayState* play) { + ObjSwprize* this = THIS; + + this->actionFunc(this, play); +} 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..efba85a87 100644 --- a/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h +++ b/src/overlays/actors/ovl_Obj_Swprize/z_obj_swprize.h @@ -3,16 +3,17 @@ #include "global.h" +#define OBJ_SWPRIZE_GET_SWITCH_FLAG(thisx) ((thisx)->params & 0x7F) +#define OBJ_SWPRIZE_GET_TYPE(thisx) (((thisx)->params >> 8) & 3) + 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 */ s16 timer; } ObjSwprize; // size = 0x14C -extern const ActorInit Obj_Swprize_InitVars; - #endif // Z_OBJ_SWPRIZE_H diff --git a/src/overlays/actors/ovl_Obj_Syokudai/overlay.cfg b/src/overlays/actors/ovl_Obj_Syokudai/overlay.cfg deleted file mode 100644 index e03e132b7..000000000 --- a/src/overlays/actors/ovl_Obj_Syokudai/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Syokudai -z_obj_syokudai.c 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 9001ea27a..96716d107 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -13,12 +13,12 @@ #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* play2); +void ObjSyokudai_Draw(Actor* thisx, PlayState* play); -const ActorInit Obj_Syokudai_InitVars = { +ActorInit Obj_Syokudai_InitVars = { ACTOR_OBJ_SYOKUDAI, ACTORCAT_PROP, FLAGS, @@ -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; @@ -196,10 +196,10 @@ void ObjSyokudai_Update(Actor* thisx, GlobalContext* globalCtx2) { if (this->flameCollider.info.acHitInfo->toucher.dmgFlags & 0x820) { interaction = OBJ_SYOKUDAI_INTERACTION_ARROW_FA; } - } else if (player->itemActionParam == PLAYER_AP_STICK) { + } else if (player->heldItemAction == PLAYER_IA_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_Translate(0.0f, OBJ_SYOKUDAI_FLAME_HEIGHT, 0.0f, MTXMODE_APPLY); - Matrix_RotateYS(BINANG_ROT180(Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) - thisx->shape.rot.y), - MTXMODE_APPLY); + Matrix_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..d49f38289 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h @@ -16,8 +16,6 @@ typedef struct ObjSyokudai { /* 0x1E4 */ LightInfo lightInfo; } ObjSyokudai; // size = 0x1F4 -extern const ActorInit Obj_Syokudai_InitVars; - typedef enum { /* 0 */ OBJ_SYOKUDAI_TYPE_SWITCH_CAUSES_FLAME, /* 1 */ OBJ_SYOKUDAI_TYPE_FLAME_CAUSES_SWITCH, @@ -50,10 +48,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/overlay.cfg b/src/overlays/actors/ovl_Obj_Takaraya_Wall/overlay.cfg deleted file mode 100644 index 71b838a3a..000000000 --- a/src/overlays/actors/ovl_Obj_Takaraya_Wall/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Takaraya_Wall -z_obj_takaraya_wall.c 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..b8ab34df0 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,15 +10,15 @@ #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 = { +ActorInit Obj_Takaraya_Wall_InitVars = { ACTOR_OBJ_TAKARAYA_WALL, ACTORCAT_BG, FLAGS, 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..225e26512 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,14 +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; - #endif // Z_OBJ_TAKARAYA_WALL_H diff --git a/src/overlays/actors/ovl_Obj_Taru/overlay.cfg b/src/overlays/actors/ovl_Obj_Taru/overlay.cfg deleted file mode 100644 index 70ba0b5b3..000000000 --- a/src/overlays/actors/ovl_Obj_Taru/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Taru -z_obj_taru.c 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..791564b57 100644 --- a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c +++ b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.c @@ -1,22 +1,30 @@ /* * 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); -#if 0 -const ActorInit Obj_Taru_InitVars = { +void func_80B9C07C(ObjTaru* this, PlayState* play); +void func_80B9C174(ObjTaru* this, PlayState* play); +void func_80B9C1A0(ObjTaru* this, PlayState* play); + +ActorInit Obj_Taru_InitVars = { ACTOR_OBJ_TARU, ACTORCAT_BG, FLAGS, @@ -28,55 +36,310 @@ 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_Kill(&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_Kill(&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_Kill(&this->dyna.actor); + return; + } + + 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.flags |= ACTORCTX_FLAG_3; + } + 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..629bc57a5 100644 --- a/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h +++ b/src/overlays/actors/ovl_Obj_Taru/z_obj_taru.h @@ -3,17 +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; - #endif // Z_OBJ_TARU_H diff --git a/src/overlays/actors/ovl_Obj_Toge/overlay.cfg b/src/overlays/actors/ovl_Obj_Toge/overlay.cfg deleted file mode 100644 index 0a249ec38..000000000 --- a/src/overlays/actors/ovl_Obj_Toge/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Toge -z_obj_toge.c 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..306ca7029 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.c @@ -5,22 +5,25 @@ */ #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* play2); +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 = { +ActorInit Obj_Toge_InitVars = { ACTOR_OBJ_TOGE, ACTORCAT_PROP, FLAGS, @@ -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_Kill(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_Kill(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..8259e62c8 100644 --- a/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h +++ b/src/overlays/actors/ovl_Obj_Toge/z_obj_toge.h @@ -5,15 +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; - #endif // Z_OBJ_TOGE_H diff --git a/src/overlays/actors/ovl_Obj_Tokei_Step/overlay.cfg b/src/overlays/actors/ovl_Obj_Tokei_Step/overlay.cfg deleted file mode 100644 index 1f100873c..000000000 --- a/src/overlays/actors/ovl_Obj_Tokei_Step/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Tokei_Step -z_obj_tokei_step.c 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 1567e90cc..694a5ac59 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,28 +5,30 @@ */ #include "z_obj_tokei_step.h" +#include "z64quake.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 = { +ActorInit Obj_Tokei_Step_InitVars = { ACTOR_OBJ_TOKEI_STEP, ACTORCAT_BG, FLAGS, @@ -59,17 +61,18 @@ void ObjTokeiStep_SetSysMatrix(ObjTokeiStepPanel* panel) { 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 quakeIndex = Quake_Add(GET_ACTIVE_CAM(play), QUAKE_TYPE_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); + Quake_SetSpeed(quakeIndex, 20000); + Quake_SetQuakeValues(quakeIndex, 1, 0, 0, 0); + Quake_SetCountdown(quakeIndex, 7); + + 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; @@ -85,7 +88,7 @@ void ObjTokeiStep_SpawnDust(ObjTokeiStep* this, ObjTokeiStepPanel* panel, Global 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)); } } @@ -136,7 +139,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 +179,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 +190,13 @@ 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->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 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 +204,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 +237,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 +245,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 +257,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..ddb1517de 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,10 +19,8 @@ typedef struct ObjTokeiStepPanel { typedef struct ObjTokeiStep { /* 0x000 */ DynaPolyActor dyna; - /* 0x15c */ ObjTokeiStepFunc actionFunc; + /* 0x15C */ ObjTokeiStepFunc actionFunc; /* 0x160 */ ObjTokeiStepPanel panels[7]; } ObjTokeiStep; // size = 0x1EC -extern const ActorInit Obj_Tokei_Step_InitVars; - #endif // Z_OBJ_TOKEI_STEP_H diff --git a/src/overlays/actors/ovl_Obj_Tokei_Tobira/overlay.cfg b/src/overlays/actors/ovl_Obj_Tokei_Tobira/overlay.cfg deleted file mode 100644 index 3182fc3f4..000000000 --- a/src/overlays/actors/ovl_Obj_Tokei_Tobira/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Tokei_Tobira -z_obj_tokei_tobira.c 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..0c81ec028 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,13 +10,13 @@ #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 = { +ActorInit Obj_Tokei_Tobira_InitVars = { ACTOR_OBJ_TOKEI_TOBIRA, ACTORCAT_BG, FLAGS, 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..8f9983995 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,15 +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; - #endif // Z_OBJ_TOKEI_TOBIRA_H diff --git a/src/overlays/actors/ovl_Obj_Tokei_Turret/overlay.cfg b/src/overlays/actors/ovl_Obj_Tokei_Turret/overlay.cfg deleted file mode 100644 index 57bac89fa..000000000 --- a/src/overlays/actors/ovl_Obj_Tokei_Turret/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Tokei_Turret -z_obj_tokei_turret.c 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..3dc8b3297 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,18 +5,18 @@ */ #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 = { +ActorInit Obj_Tokei_Turret_InitVars = { ACTOR_OBJ_TOKEI_TURRET, ACTORCAT_BG, FLAGS, @@ -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..620228f53 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,13 +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; - #endif // Z_OBJ_TOKEI_TURRET_H diff --git a/src/overlays/actors/ovl_Obj_Tokeidai/overlay.cfg b/src/overlays/actors/ovl_Obj_Tokeidai/overlay.cfg deleted file mode 100644 index 4458dfd69..000000000 --- a/src/overlays/actors/ovl_Obj_Tokeidai/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Tokeidai -z_obj_tokeidai.c 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 546e29a8e..704bc58c3 100644 --- a/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c +++ b/src/overlays/actors/ovl_Obj_Tokeidai/z_obj_tokeidai.c @@ -42,27 +42,27 @@ #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 = { +ActorInit Obj_Tokeidai_InitVars = { ACTOR_OBJ_TOKEIDAI, ACTORCAT_PROP, FLAGS, @@ -116,34 +116,30 @@ 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->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 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; this->actor.world.pos.y += this->actor.scale.y * 1900.0f; this->actor.shape.yOffset = 1500.0f; - gSaveContext.save.weekEventReg[8] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_08_40); } else { this->actionFunc = ObjTokeidai_ExteriorGear_Idle; } } -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->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 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 +159,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 +171,8 @@ 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->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 2) && (play->csCtx.currentCsIndex == 0))) { this->spotlightIntensity = 0; ObjTokeidai_SetupTowerOpening(this); @@ -186,9 +180,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 +204,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 +220,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 +239,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 +262,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 +277,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 +317,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 +343,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 +360,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 +396,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 +414,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 +425,46 @@ 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) { - 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))) { +void ObjTokeidai_TowerOpening_EndCutscene(ObjTokeidai* this, PlayState* play) { + if (Cutscene_CheckActorAction(play, 132) != 0 && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 5) { + SET_WEEKEVENTREG(WEEKEVENTREG_08_40); + if (((play->sceneId == SCENE_CLOCKTOWER) && (gSaveContext.sceneLayer == 2) && + (play->csCtx.currentCsIndex == 0)) || + ((play->sceneId == SCENE_00KEIKOKU) && (gSaveContext.sceneLayer == 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 == + PLAYER_PARAMS(0xFF, PLAYER_INITMODE_TELESCOPE)) { + 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 +475,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 +485,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 +494,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 +534,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 +563,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,10 +586,10 @@ 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) || - (gSaveContext.save.weekEventReg[8] & 0x40)) { +void ObjTokeidai_TowerOpening_Start(ObjTokeidai* this, PlayState* play) { + if ((Cutscene_CheckActorAction(play, 132) && + play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 132)]->action == 4) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40)) { this->actionFunc = ObjTokeidai_TowerOpening_RaiseTower; } } @@ -613,19 +607,19 @@ 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) { - if (((CURRENT_DAY == 3 && gSaveContext.save.time < CLOCK_TIME(6, 0)) || CURRENT_DAY >= 4) || - (gSaveContext.save.weekEventReg[8] & 0x40)) { +void ObjTokeidai_StaircaseToRooftop_Idle(ObjTokeidai* this, PlayState* play) { + if ((((CURRENT_DAY == 3) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) || CURRENT_DAY >= 4) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_08_40)) { this->actor.draw = ObjTokeidai_Draw; } else { this->actor.draw = NULL; } } -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 +630,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,20 +683,20 @@ 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); - gSaveContext.save.weekEventReg[8] |= 0x40; + SET_WEEKEVENTREG(WEEKEVENTREG_08_40); 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.flags & ACTORCTX_FLAG_1) && OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_TOWER_CLOCK_TERMINA_FIELD && ActorCutscene_GetCurrentIndex() == -1) { this->actor.draw = NULL; @@ -717,27 +711,27 @@ 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 && - OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_TERMINA_FIELD && - ActorCutscene_GetCurrentIndex() == -1) { + if (!(play->actorCtx.flags & ACTORCTX_FLAG_1) && + (OBJ_TOKEIDAI_TYPE(&this->actor) == OBJ_TOKEIDAI_TYPE_EXTERIOR_GEAR_TERMINA_FIELD) && + (ActorCutscene_GetCurrentIndex() == -1)) { this->actor.draw = NULL; } this->clockTime = gSaveContext.save.time; @@ -750,19 +744,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,40 +778,40 @@ 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); + 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); @@ -826,16 +819,16 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Push(); Matrix_RotateZS(-this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerMinuteRingDL); Matrix_Pop(); Matrix_Translate(0.0f, 0.0f, this->clockFaceZTranslation, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gClockTowerClockCenterAndHandDL); Matrix_RotateZS(-this->clockFaceRotation * 2, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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); @@ -845,15 +838,15 @@ void ObjTokeidai_Clock_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_Translate(0.0f, -1112.0f, -19.6f, MTXMODE_APPLY); Matrix_RotateYS(this->sunMoonPanelRotation, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + 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_RotateYS(-this->actor.shape.rot.y, MTXMODE_APPLY); @@ -863,30 +856,30 @@ void ObjTokeidai_Counterweight_Draw(Actor* thisx, GlobalContext* globalCtx) { 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_Translate(0.0f, this->yTranslation, 0.0f, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -1791.0f, MTXMODE_APPLY); @@ -895,9 +888,9 @@ void ObjTokeidai_ExteriorGear_Draw(Actor* thisx, GlobalContext* globalCtx) { Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, 1791.0f, MTXMODE_APPLY); Matrix_RotateZS(this->minuteRingOrExteriorGearRotation, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - func_8012C28C(globalCtx->state.gfxCtx); + 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..e670d19e0 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; @@ -62,6 +62,4 @@ typedef struct ObjTokeidai { /* 0x174 */ ObjTokeidaiActionFunc actionFunc; } ObjTokeidai; // size = 0x178 -extern const ActorInit Obj_Tokeidai_InitVars; - #endif // Z_OBJ_TOKEIDAI_H diff --git a/src/overlays/actors/ovl_Obj_Toudai/overlay.cfg b/src/overlays/actors/ovl_Obj_Toudai/overlay.cfg deleted file mode 100644 index fec5d2975..000000000 --- a/src/overlays/actors/ovl_Obj_Toudai/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Toudai -z_obj_toudai.c 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..07561b8cd 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.c @@ -5,18 +5,18 @@ */ #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 = { +ActorInit Obj_Toudai_InitVars = { ACTOR_OBJ_TOUDAI, ACTORCAT_PROP, FLAGS, @@ -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..60f0b9796 100644 --- a/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h +++ b/src/overlays/actors/ovl_Obj_Toudai/z_obj_toudai.h @@ -7,9 +7,15 @@ struct ObjToudai; typedef struct ObjToudai { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xFC]; -} ObjToudai; // size = 0x240 - -extern const ActorInit Obj_Toudai_InitVars; + /* 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 #endif // Z_OBJ_TOUDAI_H diff --git a/src/overlays/actors/ovl_Obj_Tree/overlay.cfg b/src/overlays/actors/ovl_Obj_Tree/overlay.cfg deleted file mode 100644 index c3a0007c9..000000000 --- a/src/overlays/actors/ovl_Obj_Tree/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Tree -z_obj_tree.c 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 223ebad74..4dcfd4f74 100644 --- a/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c +++ b/src/overlays/actors/ovl_Obj_Tree/z_obj_tree.c @@ -11,16 +11,16 @@ #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 = { +ActorInit Obj_Tree_InitVars = { ACTOR_OBJ_TREE, ACTORCAT_PROP, FLAGS, @@ -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_RotateZYX(xRot, 0, zRot, 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_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..8d40c57f1 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) @@ -19,6 +19,4 @@ typedef struct ObjTree { /* 0x1B4 */ s16 timer; } ObjTree; // size = 0x1B8 -extern const ActorInit Obj_Tree_InitVars; - #endif // Z_OBJ_TREE_H diff --git a/src/overlays/actors/ovl_Obj_Tsubo/overlay.cfg b/src/overlays/actors/ovl_Obj_Tsubo/overlay.cfg deleted file mode 100644 index 00f17aeb5..000000000 --- a/src/overlays/actors/ovl_Obj_Tsubo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Tsubo -z_obj_tsubo.c 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..33b493237 100644 --- a/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c +++ b/src/overlays/actors/ovl_Obj_Tsubo/z_obj_tsubo.c @@ -5,23 +5,43 @@ */ #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* play2); +void ObjTsubo_Update(Actor* thisx, PlayState* play); +void ObjTsubo_Draw(Actor* thisx, PlayState* play2); -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); -#if 0 -const ActorInit Obj_Tsubo_InitVars = { +s16 D_80929500 = 0; +s16 D_80929504 = 0; +s16 D_80929508 = 0; +s16 D_8092950C = 0; + +ActorInit Obj_Tsubo_InitVars = { ACTOR_OBJ_TSUBO, ACTORCAT_PROP, FLAGS, @@ -33,79 +53,641 @@ 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->sceneId != SCENE_HAKUGIN_BS) && (play->sceneId != 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.curRoom.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_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80927FCC.s") + 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_809282F0.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_8092860C.s") + Collider_DestroyCylinder(play, &this->cylinderCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928904.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_80928914.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_80928928.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_809289B4.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_809289E4.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_80928D6C.s") + pos.y = worldPos->y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_80928D80.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_80928E74.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_80928F18.s") + pos.y = this->actor.world.pos.y + this->actor.depthInWater; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Tsubo/func_809291DC.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_8092926C.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/ObjTsubo_Update.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/func_809294B0.s") +void ObjTsubo_RacePotBreak3(ObjTsubo* this, PlayState* play2) { +} + +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_Kill(&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.curRoom.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_Kill(&this->actor); + return; + } + + 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_Kill(&this->actor); + return; + } + + 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.flags |= ACTORCTX_FLAG_3; + 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..2b3d1537f 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,37 @@ 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/overlay.cfg b/src/overlays/actors/ovl_Obj_Um/overlay.cfg deleted file mode 100644 index a8eb50a9b..000000000 --- a/src/overlays/actors/ovl_Obj_Um/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Um -z_obj_um.c 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..2a819b791 100644 --- a/src/overlays/actors/ovl_Obj_Um/z_obj_um.c +++ b/src/overlays/actors/ovl_Obj_Um/z_obj_um.c @@ -1,40 +1,67 @@ /* * 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: + * - WEEKEVENTREG_22_01: Aliens defeated + * If false: The actor doesn't spawn + * - WEEKEVENTREG_31_40 + * If true: Cremia doesn't explain again she'll deliever milk to town + * - WEEKEVENTREG_31_80 + * If true: Triggers cutscene on Romani's Ranch + * - WEEKEVENTREG_34_80 + * If true: Doesn't spawn on Romani's Ranch + * - WEEKEVENTREG_52_01 + * If true: Doesn't spawn on Romani's Ranch or Milk Road + * - WEEKEVENTREG_52_02 + * If true: Doesn't spawn on Romani's Ranch or Milk Road + * - WEEKEVENTREG_59_02 + * If true: Doesn't spawn again on Milk Road + * + * weekEventReg flags set by this actor: + * - WEEKEVENTREG_31_40: Cremia offered a ride + * Cremia offered a ride accross the Milk Road to Player + * - WEEKEVENTREG_31_80: Player is in Milk Run + * Player accepts the ride and is with Cremia during the Milk Run + * - WEEKEVENTREG_34_80: Cremia does Milk Run alone + * Player didn't interact or didn't accept the ride + * - WEEKEVENTREG_52_01: Won Milk Run minigame + * At least one pot is safe. Turns off the "Lose Milk Run minigame" + * - WEEKEVENTREG_52_02: Lose Milk Run minigame + * Every pot was broken by bandits. Turns off the "Win Milk Run minigame" + * - WEEKEVENTREG_59_02: ? + * Passed through Milk Road after winning the Milk Run + * + * weekEventReg flags unset by this actor: + * - WEEKEVENTREG_31_80 + * Turned off when the Milk Run finishes + * - WEEKEVENTREG_52_01 + * Turned off if Player lose the Milk Run + * - WEEKEVENTREG_52_02 + * 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 animIndex); void ObjUm_SetupAction(ObjUm* this, ObjUmActionFunc actionFunc); -#if 0 -const ActorInit Obj_Um_InitVars = { +ActorInit Obj_Um_InitVars = { ACTOR_OBJ_UM, ACTORCAT_NPC, FLAGS, @@ -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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + Actor_Kill(&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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_31_80)) { + // 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); + Environment_StopTime(); + } else { + // Waiting for player -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/ObjUm_SetupAction.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_34_80) || (gSaveContext.save.time >= CLOCK_TIME(19, 0)) || + (gSaveContext.save.time <= CLOCK_TIME(6, 0)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01) || + CHECK_WEEKEVENTREG(WEEKEVENTREG_52_02)) { + Actor_Kill(&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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_31_80) || CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01)) { + Actor_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78E88.s") + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_52_02)) { + this->pathIndex = this->initialPathIndex; + sp54 = false; + Environment_StopTime(); + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_31_80)) { + Actor_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78EBC.s") + this->pathIndex = this->initialPathIndex; + sp54 = false; + Environment_StopTime(); + 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 (!CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01) || CHECK_WEEKEVENTREG(WEEKEVENTREG_59_02)) { + Actor_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Um/func_80B78EFC.s") + this->pathIndex = this->initialPathIndex; + sp54 = false; + Environment_StopTime(); + ObjUm_SetupAction(this, ObjUm_PostMilkRunStartCs); + this->unk_354 = 0; + ObjUm_RotatePlayer(this, play, 0); + Audio_PlayFanfare(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_Kill(&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_Kill(&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_KillMyDonkeyAndMyself, ObjUm_TerminateMe, ObjUmn't, ObjUm_Asinucide +void func_80B79524(ObjUm* this) { + Actor_Kill(&this->dyna.actor); + if (this->donkey != NULL) { + Actor_Kill(&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: + SET_WEEKEVENTREG(WEEKEVENTREG_31_40); + if (play->msgCtx.choiceIndex == 0) { + player = GET_PLAYER(play); + func_8019F208(); + SET_WEEKEVENTREG(WEEKEVENTREG_31_80); + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_31_40)) { + // "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))) { + SET_WEEKEVENTREG(WEEKEVENTREG_34_80); + 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 (CHECK_WEEKEVENTREG(WEEKEVENTREG_31_80)) { + 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.seqId = (u8)NA_BGM_DISABLED; + CLEAR_WEEKEVENTREG(WEEKEVENTREG_31_80); + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; + + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_52_01) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_52_02)) { + if (!this->areAllPotsBroken) { + play->nextEntrance = ENTRANCE(MILK_ROAD, 6); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; + SET_WEEKEVENTREG(WEEKEVENTREG_52_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_02); + } else { + play->nextEntrance = ENTRANCE(ROMANI_RANCH, 8); + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_03; + play->transitionTrigger = TRANS_TRIGGER_START; + SET_WEEKEVENTREG(WEEKEVENTREG_52_02); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_52_01); + } + } + 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) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_02)) { + ActorCutscene_Stop(this->dyna.actor.cutscene); + Audio_SetCutsceneFlag(false); + SET_WEEKEVENTREG(WEEKEVENTREG_59_02); + 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[PLAYER_BODYPART_HEAD].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..0c6a7178e 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,91 @@ #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/overlay.cfg b/src/overlays/actors/ovl_Obj_Usiyane/overlay.cfg deleted file mode 100644 index 82fd486bb..000000000 --- a/src/overlays/actors/ovl_Obj_Usiyane/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Usiyane -z_obj_usiyane.c 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..24e816644 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -5,18 +5,18 @@ */ #include "z_obj_usiyane.h" +#include "objects/object_obj_usiyane/object_obj_usiyane.h" #define FLAGS (ACTOR_FLAG_20) #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 = { +ActorInit Obj_Usiyane_InitVars = { ACTOR_OBJ_USIYANE, ACTORCAT_PROP, FLAGS, @@ -28,40 +28,245 @@ const ActorInit Obj_Usiyane_InitVars = { (ActorFunc)ObjUsiyane_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C086B0[] = { +PosRot D_80C08660[] = { + { { 800.0f, -940.0f, 2000.0f }, { 0, 0, 0x2AF8 } }, + { { 560.0f, -790.0f, -2000.0f }, { 0, 0, 0x2EE0 } }, + { { -480.0f, -780.0f, -1990.0f }, { 0, 0, -0x2710 } }, + { { -470.0f, -850.0f, 2000.0f }, { 0, 0, -0x2710 } }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 900, ICHAIN_STOP), }; -#endif +s32 func_80C07C80(s32 arg0) { + s32 var_v1; -extern InitChainEntry D_80C086B0[]; + if (!(arg0 & 1)) { + var_v1 = gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF; + } else { + var_v1 = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; + } + return var_v1 + CLOCK_TIME(2, 30); +} -extern UNK_TYPE D_06000838; -extern UNK_TYPE D_060022AC; +s32 func_80C07CD0(void) { + if (CURRENT_DAY <= 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07C80.s") + if (CURRENT_DAY == 1) { + s32 time = gSaveContext.save.time; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07CD0.s") + if ((time < CLOCK_TIME(2, 30)) || (time >= CLOCK_TIME(6, 0))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07DC4.s") + if (time < CLOCK_TIME(5, 15)) { + s32 var_s1 = CLOCK_TIME(5, 15); + s32 temp_v0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07DFC.s") + for (i = 0; i < 8; i++) { + temp_v0_2 = func_80C07C80(i); + var_s1 = CLAMP_MAX(var_s1, temp_v0_2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07F30.s") + if (time < (var_s1 + 0xE11)) { + return false; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C081C8.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_22_01)) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C082CC.s") +void func_80C07DC4(ObjUsiyane* this, PlayState* play) { + if (func_80C07CD0()) { + Actor_Kill(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C082E0.s") +void func_80C07DFC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5, Vec3f* arg6, Vec3s* arg7) { + f32 temp_fv0 = (f32)arg4 / arg5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Init.s") + // VEC3F_LERPIMPDST + arg6->x = ((arg2->x - arg0->x) * temp_fv0) + arg0->x; + arg6->y = ((arg2->y - arg0->y) * temp_fv0) + arg0->y; + arg6->z = ((arg2->z - arg0->z) * temp_fv0) + arg0->z; + arg7->x = (((f32)arg3->x - (f32)arg1->x) * temp_fv0) + arg1->x; + arg7->y = (((f32)arg3->y - (f32)arg1->y) * temp_fv0) + arg1->y; + arg7->z = (((f32)arg3->z - (f32)arg1->z) * temp_fv0) + arg1->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Destroy.s") +void func_80C07F30(ObjUsiyane* this, PlayState* play) { + s32 i; + s32 j; + Vec3f sp94; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Update.s") + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + if (i != ARRAY_COUNT(this->unk_168[0]) - 1) { + func_80C07DFC(&this->unk_710[i], &D_80C08660[i].rot, &this->unk_710[i + 1], &D_80C08660[i + 1].rot, j, + 10, &this->unk_168[j][i].unk_00, &this->unk_168[j][i].unk_18); + } else { + func_80C07DFC(&this->unk_710[i], &D_80C08660[i].rot, &this->unk_710[0], &D_80C08660[0].rot, j, 10, + &this->unk_168[j][i].unk_00, &this->unk_168[j][i].unk_18); + } + func_800B12F0(play, &this->unk_168[j][i].unk_00, &gZeroVec3f, &gZeroVec3f, 100, 30, 7); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Draw.s") + this->unk_168[j][i].unk_18.y = (s32)Rand_Next() >> 0x10; + + sp94.x = this->unk_168[j][i].unk_00.x - this->unk_708; + sp94.y = 0.0f; + sp94.z = this->unk_168[j][i].unk_00.z - this->unk_70C; + Math3D_Normalize(&sp94); + + sp94.x *= 5.0f; + sp94.y = 19.0f; + sp94.z *= 5.0f; + + this->unk_168[j][i].unk_0C = sp94; + + this->unk_168[j][i].unk_1E.x = Rand_Centered() * 4000.0f; + this->unk_168[j][i].unk_1E.y = Rand_Centered() * 4000.0f; + this->unk_168[j][i].unk_1E.z = Rand_Centered() * 4000.0f; + } + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_HOUSE_BROKEN); + this->unk_740 = 0; + this->unk_744 |= 4; +} + +void func_80C081C8(ObjUsiyane* this, PlayState* play) { + s32 i; + s32 j; + + this->unk_744 |= 1; + + if (this->unk_740 <= 70) { + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + this->unk_168[j][i].unk_0C.y += -0.8f; + + this->unk_168[j][i].unk_00.x += this->unk_168[j][i].unk_0C.x; + this->unk_168[j][i].unk_00.y += this->unk_168[j][i].unk_0C.y; + this->unk_168[j][i].unk_00.z += this->unk_168[j][i].unk_0C.z; + + this->unk_168[j][i].unk_18.x += this->unk_168[j][i].unk_1E.x; + this->unk_168[j][i].unk_18.y += this->unk_168[j][i].unk_1E.y; + this->unk_168[j][i].unk_18.z += this->unk_168[j][i].unk_1E.z; + } + } + + } else if (this->unk_740 >= 70) { + Actor_Kill(&this->dyna.actor); + } + this->unk_740++; +} + +void func_80C082CC(ObjUsiyane* this, PlayState* play) { + this->unk_164 = -1; +} + +void func_80C082E0(ObjUsiyane* this, PlayState* play) { + CsCmdActorAction* csAction; + + if (Cutscene_CheckActorAction(play, 0x228)) { + this->unk_160 = Cutscene_GetActorActionIndex(play, 0x228); + csAction = play->csCtx.actorActions[this->unk_160]; + if (this->unk_164 != csAction->action) { + this->unk_164 = csAction->action; + if (this->unk_164 == 2) { + func_80C07F30(this, play); + this->actionFunc = func_80C081C8; + } + } + } +} + +void ObjUsiyane_Init(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 0.1f); + + this->unk_744 = 0; + + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_obj_usiyane_Colheader_0022AC); + + switch (OBJUSIYANE_GET_F(&this->dyna.actor)) { + case OBJUSIYANE_F_0: + this->actionFunc = func_80C07DC4; + break; + + case OBJUSIYANE_F_1: + func_80C082CC(this, play); + this->actionFunc = func_80C082E0; + break; + + default: + Actor_Kill(&this->dyna.actor); + break; + } +} + +void ObjUsiyane_Destroy(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void ObjUsiyane_Update(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + this->actionFunc(this, play); +} + +void ObjUsiyane_Draw(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + MtxF mf; + + if (!(this->unk_744 & 1)) { + Gfx_DrawDListOpa(play, object_obj_usiyane_DL_000838); + } + + if (!(this->unk_744 & 2)) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_80C08660); i++) { + Vec3f sp74; + + Matrix_MultVec3f(&D_80C08660[i].pos, &this->unk_710[i]); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + this->unk_708 = sp74.x; + this->unk_70C = sp74.z; + } + this->unk_744 |= 2; + } + + if ((this->unk_744 & 4) && !(this->unk_744 & 8)) { + s32 i; + s32 j; + + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + Matrix_Push(); + SkinMatrix_SetScaleRotateRPYTranslate(&mf, 0.1f, 0.1f, 0.1f, this->unk_168[j][i].unk_18.x, + this->unk_168[j][i].unk_18.y, this->unk_168[j][i].unk_18.z, + this->unk_168[j][i].unk_00.x, this->unk_168[j][i].unk_00.y, + this->unk_168[j][i].unk_00.z); + Matrix_Put(&mf); + Gfx_DrawDListOpa(play, object_obj_usiyane_DL_000098); + Matrix_Pop(); + } + } + } +} 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..2abc2a38b 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h @@ -5,15 +5,33 @@ struct ObjUsiyane; -typedef void (*ObjUsiyaneActionFunc)(struct ObjUsiyane*, GlobalContext*); +typedef void (*ObjUsiyaneActionFunc)(struct ObjUsiyane*, PlayState*); + +#define OBJUSIYANE_GET_F(thisx) ((thisx)->params & 0xF) + +enum { + /* 0 */ OBJUSIYANE_F_0, + /* 1 */ OBJUSIYANE_F_1, +}; + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3s unk_18; + /* 0x1E */ Vec3s unk_1E; +} ObjUsiyaneStruct; // size = 0x24 typedef struct ObjUsiyane { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjUsiyaneActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x5E8]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjUsiyaneActionFunc actionFunc; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ ObjUsiyaneStruct unk_168[10][4]; + /* 0x708 */ f32 unk_708; + /* 0x70C */ f32 unk_70C; + /* 0x710 */ Vec3f unk_710[4]; + /* 0x740 */ s32 unk_740; + /* 0x744 */ s32 unk_744; } ObjUsiyane; // size = 0x748 -extern const ActorInit Obj_Usiyane_InitVars; - #endif // Z_OBJ_USIYANE_H diff --git a/src/overlays/actors/ovl_Obj_Visiblock/overlay.cfg b/src/overlays/actors/ovl_Obj_Visiblock/overlay.cfg deleted file mode 100644 index 9436fe9e3..000000000 --- a/src/overlays/actors/ovl_Obj_Visiblock/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Visiblock -z_obj_visiblock.c 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..4b0a797f6 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.c @@ -11,11 +11,11 @@ #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 = { +ActorInit Obj_Visiblock_InitVars = { ACTOR_OBJ_VISIBLOCK, ACTORCAT_BG, FLAGS, @@ -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_Visiblock/z_obj_visiblock.h b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.h index 946685a5c..5fa08ab86 100644 --- a/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.h +++ b/src/overlays/actors/ovl_Obj_Visiblock/z_obj_visiblock.h @@ -10,6 +10,4 @@ typedef struct ObjVisiblock { /* 0x15C */ UNK_TYPE1 unk15C[0x4]; } ObjVisiblock; // size = 0x160 -extern const ActorInit Obj_Visiblock_InitVars; - #endif // Z_OBJ_VISIBLOCK_H diff --git a/src/overlays/actors/ovl_Obj_Vspinyroll/overlay.cfg b/src/overlays/actors/ovl_Obj_Vspinyroll/overlay.cfg deleted file mode 100644 index 0b324c966..000000000 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Vspinyroll -z_obj_vspinyroll.c 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 067bd58ec..b7a1e59be 100644 --- a/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c +++ b/src/overlays/actors/ovl_Obj_Vspinyroll/z_obj_vspinyroll.c @@ -11,23 +11,23 @@ #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* play2); +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 = { +ActorInit Obj_Vspinyroll_InitVars = { ACTOR_OBJ_VSPINYROLL, ACTORCAT_PROP, FLAGS, @@ -159,7 +159,7 @@ void func_80A3C7E8(ObjVspinyroll* this) { } } -s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s32 arg3) { +s32 func_80A3C8D8(ObjVspinyroll* this, PlayState* play, Vec3f* arg2, s32 arg3) { s32 pad; ObjVspinyrollStruct3* unk_1A8 = &this->unk_1A8; ObjVspinyrollStruct2* ptr; @@ -194,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, &unk_1A8->unk_000[i].collisionPoly, true, - false, false, true, &unk_1A8->unk_000[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; @@ -207,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); } @@ -224,10 +224,10 @@ s32 func_80A3C8D8(ObjVspinyroll* this, GlobalContext* globalCtx, Vec3f* arg2, s3 return sp9C; } -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; @@ -235,15 +235,15 @@ s32 func_80A3CB94(ObjVspinyroll* this, GlobalContext* globalCtx, s32 arg2) { return false; } -DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, GlobalContext* globalCtx) { +DynaPolyActor* func_80A3CBF0(ObjVspinyroll* this, PlayState* play) { if (this->unk_1A8.unk_1E0 != NULL) { - return DynaPoly_GetActor(&globalCtx->colCtx, this->unk_1A8.unk_1E0->bgId); + 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; @@ -257,7 +257,7 @@ void func_80A3CC84(f32 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); @@ -280,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; @@ -299,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]; @@ -314,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) { @@ -326,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; @@ -339,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) { @@ -354,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); } @@ -364,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); @@ -386,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; } @@ -400,20 +400,20 @@ 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_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y + 60.0f, this->dyna.actor.world.pos.z, @@ -422,20 +422,20 @@ void ObjVspinyroll_Draw(Actor* thisx, GlobalContext* globalCtx) { 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); + 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); @@ -443,13 +443,13 @@ void func_80A3D2C0(Actor* thisx, GlobalContext* globalCtx) { 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 15879f86e..09a91b437 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) @@ -28,21 +28,19 @@ typedef struct { } ObjVspinyrollStruct3; // size = 0x1E8 typedef struct ObjVspinyroll { - /* 0x0000 */ DynaPolyActor dyna; - /* 0x015C */ ColliderCylinder collider; - /* 0x01A8 */ ObjVspinyrollStruct3 unk_1A8; - /* 0x0390 */ ObjVspinyrollActionFunc actionFunc; - /* 0x0394 */ f32 unk_394; - /* 0x0398 */ s32 unk_398; - /* 0x039C */ Vec3f unk_39C[2]; - /* 0x03B4 */ Vec3f unk_3B4; - /* 0x03C0 */ s16 unk_3C0; - /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; - /* 0x03C6 */ s16 unk_3C6; - /* 0x03C8 */ s16 unk_3C8; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ColliderCylinder collider; + /* 0x1A8 */ ObjVspinyrollStruct3 unk_1A8; + /* 0x390 */ ObjVspinyrollActionFunc actionFunc; + /* 0x394 */ f32 unk_394; + /* 0x398 */ s32 unk_398; + /* 0x39C */ Vec3f unk_39C[2]; + /* 0x3B4 */ Vec3f unk_3B4; + /* 0x3C0 */ s16 unk_3C0; + /* 0x3C2 */ s16 unk_3C2; + /* 0x3C4 */ s16 unk_3C4; + /* 0x3C6 */ s16 unk_3C6; + /* 0x3C8 */ s16 unk_3C8; } ObjVspinyroll; // size = 0x3CC -extern const ActorInit Obj_Vspinyroll_InitVars; - #endif // Z_OBJ_VSPINYROLL_H diff --git a/src/overlays/actors/ovl_Obj_Warpstone/overlay.cfg b/src/overlays/actors/ovl_Obj_Warpstone/overlay.cfg deleted file mode 100644 index 2f3fe66ea..000000000 --- a/src/overlays/actors/ovl_Obj_Warpstone/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Warpstone -z_obj_warpstone.c 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 c676b4960..3fa3260fd 100644 --- a/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c +++ b/src/overlays/actors/ovl_Obj_Warpstone/z_obj_warpstone.c @@ -12,17 +12,17 @@ #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* play2); 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 = { +ActorInit Obj_Warpstone_InitVars = { ACTOR_OBJ_WARPSTONE, ACTORCAT_ITEMACTION, FLAGS, @@ -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,53 +125,53 @@ 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); + 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(&globalCtx->billboardMtxF, MTXMODE_APPLY); + 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); @@ -179,13 +179,13 @@ void ObjWarpstone_Draw(Actor* thisx, GlobalContext* globalCtx2) { 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_RotateZF((((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); + Matrix_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++, gEffFlash1DL); Matrix_Pop(); - Matrix_RotateZF((~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI) / 0x8000, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, gOwlStatueWhiteFlashDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + 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++, gEffFlash1DL); + 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..a2db609d6 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, @@ -26,9 +26,7 @@ typedef struct ObjWarpstone { /* 0x1AC */ ObjWarpstoneActionFunc actionFunc; } ObjWarpstone; // size = 0x1B0 -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/overlay.cfg b/src/overlays/actors/ovl_Obj_Wind/overlay.cfg deleted file mode 100644 index 7f65da5cf..000000000 --- a/src/overlays/actors/ovl_Obj_Wind/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Wind -z_obj_wind.c 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..5f53030f3 100644 --- a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c +++ b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.c @@ -10,13 +10,13 @@ #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 = { +ActorInit Obj_Wind_InitVars = { ACTOR_OBJ_WIND, ACTORCAT_ITEMACTION, FLAGS, diff --git a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.h b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.h index 23296ff09..08db8914a 100644 --- a/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.h +++ b/src/overlays/actors/ovl_Obj_Wind/z_obj_wind.h @@ -10,6 +10,4 @@ typedef struct ObjWind { /* 0x144 */ char unk_144[0x4]; } ObjWind; // size = 0x148 -extern const ActorInit Obj_Wind_InitVars; - #endif // Z_OBJ_WIND_H diff --git a/src/overlays/actors/ovl_Obj_Wturn/overlay.cfg b/src/overlays/actors/ovl_Obj_Wturn/overlay.cfg deleted file mode 100644 index 07e4b563d..000000000 --- a/src/overlays/actors/ovl_Obj_Wturn/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Wturn -z_obj_wturn.c 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..184fed3d6 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.c @@ -10,25 +10,25 @@ #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 = { +ActorInit Obj_Wturn_InitVars = { ACTOR_OBJ_WTURN, ACTORCAT_ITEMACTION, FLAGS, GAMEPLAY_KEEP, sizeof(ObjWturn), (ActorFunc)ObjWturn_Init, (ActorFunc)Actor_Noop, (ActorFunc)ObjWturn_Update, (ActorFunc)NULL, }; -void ObjWturn_Init(Actor* thisx, GlobalContext* globalCtx) { +void ObjWturn_Init(Actor* thisx, PlayState* play) { ObjWturn* this = THIS; func_808A7954(this); @@ -38,12 +38,15 @@ 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); - 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))) { +void func_808A7968(ObjWturn* this, PlayState* play) { + if (play->msgCtx.ocarinaMode >= 28 && play->msgCtx.ocarinaMode < 39) { + Flags_UnsetSwitch(play, this->actor.params); + Actor_Kill(&this->actor); + return; + } + + if ((Flags_GetSwitch(play, this->actor.params) && (play->sceneId == SCENE_F40)) || + (!Flags_GetSwitch(play, this->actor.params) && (play->sceneId == SCENE_F41))) { func_808A7A24(this); } } @@ -53,76 +56,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, PLAYER_CSMODE_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, PLAYER_CSMODE_84); 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->sceneId == 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..2e2963d0e 100644 --- a/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h +++ b/src/overlays/actors/ovl_Obj_Wturn/z_obj_wturn.h @@ -5,15 +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; - #endif // Z_OBJ_WTURN_H diff --git a/src/overlays/actors/ovl_Obj_Y2lift/overlay.cfg b/src/overlays/actors/ovl_Obj_Y2lift/overlay.cfg deleted file mode 100644 index 432bb3e7f..000000000 --- a/src/overlays/actors/ovl_Obj_Y2lift/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Y2lift -z_obj_y2lift.c 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..9399940d8 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.c @@ -5,18 +5,18 @@ */ #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 = { +ActorInit Obj_Y2lift_InitVars = { ACTOR_OBJ_Y2LIFT, ACTORCAT_BG, FLAGS, @@ -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..cacb0fa7b 100644 --- a/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h +++ b/src/overlays/actors/ovl_Obj_Y2lift/z_obj_y2lift.h @@ -6,10 +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; - #endif // Z_OBJ_Y2LIFT_H diff --git a/src/overlays/actors/ovl_Obj_Y2shutter/overlay.cfg b/src/overlays/actors/ovl_Obj_Y2shutter/overlay.cfg deleted file mode 100644 index 913e42405..000000000 --- a/src/overlays/actors/ovl_Obj_Y2shutter/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Y2shutter -z_obj_y2shutter.c 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..9d35288c5 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.c @@ -1,22 +1,35 @@ /* * File: z_obj_y2shutter.c * Overlay: ovl_Obj_Y2shutter - * Description: Pirates' Fortress sliding grate + * Description: Pirates' Fortress sliding grated/barred shutters */ #include "z_obj_y2shutter.h" +#include "objects/object_kaizoku_obj/object_kaizoku_obj.h" #define FLAGS (ACTOR_FLAG_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 = { +typedef struct ShutterInfo { + /* 0x00 */ Gfx* dList; + /* 0x04 */ CollisionHeader* colHeader; + /* 0x08 */ f32 openedOffsetY; + /* 0x0C */ f32 openVelocity; + /* 0x10 */ f32 openAccel; + /* 0x14 */ f32 closeVelocity; + /* 0x18 */ f32 closeAccel; + /* 0x1C */ u8 openStartSettleTimer; + /* 0x1D */ u8 openEndAndCloseSettleTimer; + /* 0x1E */ u8 openTimer; +} ShutterInfo; // size = 0x20 + +ActorInit Obj_Y2shutter_InitVars = { ACTOR_OBJ_Y2SHUTTER, ACTORCAT_BG, FLAGS, @@ -28,24 +41,136 @@ const ActorInit Obj_Y2shutter_InitVars = { (ActorFunc)ObjY2shutter_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B9AEB0[] = { +ShutterInfo sShutterInfo[] = { + { gPirateBarredShutterDL, &gPirateBarredShutterCol, 120.0f, 20.0f, 3.0f, -20.0f, 3.0f, 4, 8, 160 }, + { gPirateGratedShutterDL, &gPirateGratedShutterCol, 150.0f, 1.0f, 0.04f, -1.0f, 0.04f, 6, 12, 160 }, +}; + +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 ObjY2shutter_Init(Actor* thisx, PlayState* play) { + s32 pad[2]; + ShutterInfo* info = &sShutterInfo[OBJY2SHUTTER_GET_TYPE(thisx)]; + ObjY2shutter* this = THIS; -extern InitChainEntry D_80B9AEB0[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, info->colHeader); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2shutter/ObjY2shutter_Init.s") +void ObjY2shutter_Destroy(Actor* thisx, PlayState* play) { + ObjY2shutter* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2shutter/ObjY2shutter_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2shutter/func_80B9AA20.s") +void ObjY2shutter_SetupOpen(ObjY2shutter* this, ShutterInfo* info, ShutterType shutterType) { + this->openTimer = info->openTimer; + this->settleTimer = info->openStartSettleTimer; + if (shutterType == SHUTTER_BARRED) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALDOOR_OPEN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2shutter/ObjY2shutter_Update.s") +void ObjY2shutter_Update(Actor* thisx, PlayState* play) { + s32 pad; + ObjY2shutter* this = THIS; + ShutterType shutterType = OBJY2SHUTTER_GET_TYPE(&this->dyna.actor); + ShutterInfo* info = &sShutterInfo[shutterType]; + f32 targetPosY = this->dyna.actor.world.pos.y; + f32 targetVelocityY = 0.0f; + f32 accelY = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Y2shutter/ObjY2shutter_Draw.s") + sShutterInfo[0].openTimer = DREG(84) + 160; + sShutterInfo[1].openTimer = DREG(85) + 160; + + if (((shutterType == SHUTTER_BARRED) && (DREG(86) != 0)) || ((shutterType != SHUTTER_BARRED) && (DREG(87) != 0))) { + if (shutterType == SHUTTER_BARRED) { + DREG(86) = 0; + } else { + DREG(87) = 0; + } + + if (Flags_GetSwitch(play, OBJY2SHUTTER_GET_SWITCHFLAG(&this->dyna.actor))) { + Flags_UnsetSwitch(play, OBJY2SHUTTER_GET_SWITCHFLAG(&this->dyna.actor)); + } else { + Flags_SetSwitch(play, OBJY2SHUTTER_GET_SWITCHFLAG(&this->dyna.actor)); + } + } + + if (this->settleTimer == 0) { + if (Flags_GetSwitch(play, OBJY2SHUTTER_GET_SWITCHFLAG(&this->dyna.actor))) { + s16 cutscene = this->dyna.actor.cutscene; + + if (this->openTimer == 0) { + if ((cutscene >= 0) && !ActorCutscene_GetCanPlayNext(cutscene)) { + ActorCutscene_SetIntentToPlay(cutscene); + } else if (cutscene >= 0) { + ActorCutscene_StartAndSetUnkLinkFields(cutscene, &this->dyna.actor); + this->openTimer = -1; + } else { + ObjY2shutter_SetupOpen(this, info, shutterType); + } + } else if (this->openTimer < 0) { + if (func_800F22C4(cutscene, &this->dyna.actor)) { + ObjY2shutter_SetupOpen(this, info, shutterType); + } + } else { + targetPosY = this->dyna.actor.home.pos.y + info->openedOffsetY; + targetVelocityY = info->openVelocity; + accelY = info->openAccel; + if (this->openTimer < 2) { + Flags_UnsetSwitch(play, OBJY2SHUTTER_GET_SWITCHFLAG(&this->dyna.actor)); + } else { + this->openTimer--; + } + } + } else if (this->openTimer != 0) { + this->openTimer = 0; + this->settleTimer = info->openStartSettleTimer; + if (shutterType == SHUTTER_BARRED) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALDOOR_CLOSE); + } + } else { + targetPosY = this->dyna.actor.home.pos.y; + targetVelocityY = info->closeVelocity; + accelY = info->closeAccel; + } + } + + Math_StepToF(&this->dyna.actor.velocity.y, targetVelocityY, accelY); + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; + + if (((this->dyna.actor.world.pos.y - targetPosY) * targetVelocityY) >= 0.0f) { + this->dyna.actor.world.pos.y = targetPosY; + this->dyna.actor.velocity.y = 0.0f; + if (!this->isStationary) { + this->isStationary = true; + this->settleTimer = info->openEndAndCloseSettleTimer; + if (shutterType != SHUTTER_BARRED) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALDOOR_STOP); + } + } + } else { + this->isStationary = false; + if (shutterType != SHUTTER_BARRED) { + func_800B9010(&this->dyna.actor, NA_SE_EV_METALDOOR_SLIDE - SFX_FLAG); + } + } + + if (DECR(this->settleTimer)) { + this->dyna.actor.shape.yOffset = 2.0f * (this->settleTimer & 1) * this->settleTimer; + } +} + +void ObjY2shutter_Draw(Actor* thisx, PlayState* play) { + ObjY2shutter* this = THIS; + ShutterInfo* info = &sShutterInfo[(OBJY2SHUTTER_GET_TYPE(&this->dyna.actor))]; + + Gfx_DrawDListOpa(play, info->dList); +} diff --git a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.h b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.h index 217bcee6c..bccdce645 100644 --- a/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.h +++ b/src/overlays/actors/ovl_Obj_Y2shutter/z_obj_y2shutter.h @@ -6,10 +6,18 @@ struct ObjY2shutter; typedef struct ObjY2shutter { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 openTimer; + /* 0x15E */ u8 isStationary; // true if the door is neither opening nor closing + /* 0x15F */ u8 settleTimer; } ObjY2shutter; // size = 0x160 -extern const ActorInit Obj_Y2shutter_InitVars; +typedef enum { + /* 0x0 */ SHUTTER_BARRED, + /* 0x1 */ SHUTTER_GRATED, +} ShutterType; + +#define OBJY2SHUTTER_GET_TYPE(thisx) (((thisx)->params >> 7) & 1) +#define OBJY2SHUTTER_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F) #endif // Z_OBJ_Y2SHUTTER_H diff --git a/src/overlays/actors/ovl_Obj_Yado/overlay.cfg b/src/overlays/actors/ovl_Obj_Yado/overlay.cfg deleted file mode 100644 index 091dbfce7..000000000 --- a/src/overlays/actors/ovl_Obj_Yado/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Yado -z_obj_yado.c 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..b4a78851a 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.c @@ -4,6 +4,7 @@ * Description: Stockpot Inn - 2nd Floor Window */ +#include "prevent_bss_reordering.h" #include "z_obj_yado.h" #include "objects/object_yado_obj/object_yado_obj.h" @@ -11,12 +12,12 @@ #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 = { +ActorInit Obj_Yado_InitVars = { ACTOR_OBJ_YADO, ACTORCAT_BG, FLAGS, @@ -34,7 +35,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 +43,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_Yado/z_obj_yado.h b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.h index 28ffd63dc..52ef8693e 100644 --- a/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.h +++ b/src/overlays/actors/ovl_Obj_Yado/z_obj_yado.h @@ -10,6 +10,4 @@ typedef struct ObjYado { /* 0x144 */ u8 isNight; } ObjYado; // size = 0x148 -extern const ActorInit Obj_Yado_InitVars; - #endif // Z_OBJ_YADO_H diff --git a/src/overlays/actors/ovl_Obj_Yasi/overlay.cfg b/src/overlays/actors/ovl_Obj_Yasi/overlay.cfg deleted file mode 100644 index e1d3b9f4e..000000000 --- a/src/overlays/actors/ovl_Obj_Yasi/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Obj_Yasi -z_obj_yasi.c 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 3dfea0818..5af34152a 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.c @@ -13,12 +13,12 @@ #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 = { +ActorInit Obj_Yasi_InitVars = { ACTOR_OBJ_YASI, ACTORCAT_PROP, FLAGS, @@ -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,7 +82,7 @@ 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_Translate(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, @@ -97,5 +97,5 @@ void ObjYasi_Draw(Actor* thisx, GlobalContext* globalCtx) { } 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..fc2b777d8 100644 --- a/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h +++ b/src/overlays/actors/ovl_Obj_Yasi/z_obj_yasi.h @@ -9,8 +9,6 @@ typedef struct ObjYasi { /* 0x000 */ DynaPolyActor dyna; } ObjYasi; // size = 0x15C -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/overlay.cfg b/src/overlays/actors/ovl_Object_Kankyo/overlay.cfg deleted file mode 100644 index 9c4704cae..000000000 --- a/src/overlays/actors/ovl_Object_Kankyo/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Object_Kankyo -z_object_kankyo.c 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 2f976f2cc..db78f579b 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -11,23 +11,23 @@ #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; -const ActorInit Object_Kankyo_InitVars = { +ActorInit Object_Kankyo_InitVars = { ACTOR_OBJECT_KANKYO, ACTORCAT_ITEMACTION, FLAGS, @@ -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); + Actor_Kill(&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_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,24 +409,24 @@ 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); @@ -436,12 +434,12 @@ void func_808DCDB4(ObjectKankyo* this, GlobalContext* globalCtx) { 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; @@ -554,47 +554,46 @@ void func_808DD3C8(Actor* thisx, GlobalContext* globalCtx2) { gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust5Tex)); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffDust5Tex)); } - Matrix_Translate(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_Mult(&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); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffDustDL); } } - 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->sceneId == 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,45 +601,46 @@ 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_Translate(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_Mult(&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); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gDust5Tex)); + 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(gEffDust5Tex)); gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG); - gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_023130); + gSPDisplayList(POLY_XLU_DISP++, gEffDustDL); } } - 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); @@ -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); @@ -719,13 +718,12 @@ void func_808DDE9C(Actor* thisx, GlobalContext* globalCtx2) { 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..8dc8d4d85 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; @@ -28,6 +28,4 @@ typedef struct ObjectKankyo { /* 0x1150 */ ObjectKankyoActionFunc actionFunc; } ObjectKankyo; // size = 0x1154 -extern const ActorInit Object_Kankyo_InitVars; - #endif // Z_OBJECT_KANKYO_H diff --git a/src/overlays/actors/ovl_Oceff_Spot/overlay.cfg b/src/overlays/actors/ovl_Oceff_Spot/overlay.cfg deleted file mode 100644 index e302cce9a..000000000 --- a/src/overlays/actors/ovl_Oceff_Spot/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Spot -z_oceff_spot.c 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..731fe6b77 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -10,18 +10,18 @@ #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* play2); +void OceffSpot_Destroy(Actor* thisx, PlayState* play2); +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 OceffSpot_Wait(OceffSpot* this, PlayState* play); +void OceffSpot_GrowCylinder(OceffSpot* this, PlayState* play); +void OceffSpot_End(OceffSpot* this, PlayState* play); void OceffSpot_SetupAction(OceffSpot* this, OceffSpotActionFunc actionFunc); -#if 0 -const ActorInit Oceff_Spot_InitVars = { +ActorInit Oceff_Spot_InitVars = { ACTOR_OCEFF_SPOT, ACTORCAT_ITEMACTION, FLAGS, @@ -33,28 +33,140 @@ const ActorInit Oceff_Spot_InitVars = { (ActorFunc)OceffSpot_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80973478[] = { +#include "assets/overlays/ovl_Oceff_Spot/ovl_Oceff_Spot.c" + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 0, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 1500, ICHAIN_STOP), }; -#endif +void OceffSpot_SetupAction(OceffSpot* this, OceffSpotActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern InitChainEntry D_80973478[]; +void OceffSpot_Init(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + OceffSpot* this = THIS; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_SetupAction.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + OceffSpot_SetupAction(this, OceffSpot_GrowCylinder); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_Init.s") + Lights_PointNoGlowSetInfo(&this->lightInfo1, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + this->lightNode1 = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo1); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_Destroy.s") + Lights_PointNoGlowSetInfo(&this->lightInfo2, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + this->lightNode2 = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo2); + this->actor.scale.y = 0.3f; + this->unk16C = 0.0f; + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.world.pos.x = player->bodyPartsPos[0].x; + this->actor.world.pos.z = player->bodyPartsPos[0].z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/func_80972844.s") +void OceffSpot_Destroy(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + OceffSpot* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/func_809728F8.s") + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode1); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode2); + Magic_Reset(play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/func_80972934.s") +void OceffSpot_End(OceffSpot* this, PlayState* play) { + if (this->unk16C > 0.0f) { + this->unk16C -= 0.05f; + } else { + Actor_Kill(&this->actor); + if ((R_TIME_SPEED != 400) && (play->msgCtx.unk12046 == 0)) { + if ((play->msgCtx.ocarinaAction != 0x39) || (play->msgCtx.ocarinaMode != 0xA)) { + gSaveContext.sunsSongState = SUNSSONG_START; + } + } else { + play->msgCtx.ocarinaMode = 4; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_Update.s") +void OceffSpot_Wait(OceffSpot* this, PlayState* play) { + if (this->timer > 0) { + this->timer--; + } else { + OceffSpot_SetupAction(this, OceffSpot_End); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Spot/OceffSpot_Draw.s") +void OceffSpot_GrowCylinder(OceffSpot* this, PlayState* play) { + if (this->unk16C < 1.0f) { + this->unk16C += 0.05f; + } else { + OceffSpot_SetupAction(this, OceffSpot_Wait); + this->timer = 60; + } +} + +void OceffSpot_Update(Actor* thisx, PlayState* play) { + f32 scale; + s32 pad; + Player* player = GET_PLAYER(play); + f32 temp; + OceffSpot* this = THIS; + + temp = (1.0f - cosf(this->unk16C * M_PI)) * 0.5f; + this->actionFunc(this, play); + + switch (gSaveContext.save.playerForm) { + default: + scale = 1.0f; + break; + + case PLAYER_FORM_DEKU: + scale = 1.3f; + break; + + case PLAYER_FORM_ZORA: + scale = 1.2f; + break; + + case PLAYER_FORM_GORON: + scale = 2.0f; + break; + } + + this->actor.scale.z = (scale * 0.42f) * temp; + this->actor.scale.x = (scale * 0.42f) * temp; + + this->actor.world.pos = player->actor.world.pos; + this->actor.world.pos.y = this->actor.world.pos.y + 5.0f; + + temp = (2.0f - this->unk16C) * this->unk16C; + + func_800FD2B4(play, temp * 0.5f, 880.0f, 0.2f, 0.9f); + + Lights_PointNoGlowSetInfo(&this->lightInfo1, this->actor.world.pos.x, this->actor.world.pos.y + 55.0f, + this->actor.world.pos.z, (s32)(255.0f * temp), (s32)(255.0f * temp), (s32)(200.0f * temp), + 100.0f * temp); + Lights_PointNoGlowSetInfo( + &this->lightInfo2, this->actor.world.pos.x + (Math_SinS(player->actor.shape.rot.y) * 20.0f), + this->actor.world.pos.y + 20.0f, this->actor.world.pos.z + (Math_CosS(player->actor.shape.rot.y) * 20.0f), + (s32)(255.0f * temp), (s32)(255.0f * temp), (s32)(200.0f * temp), 100.0f * temp); +} + +void OceffSpot_Draw(Actor* thisx, PlayState* play) { + OceffSpot* this = THIS; + u32 scroll = play->state.frames & 0xFFFF; + + 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++, &sSunSongEffectCylinderMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, 0, scroll * 2, scroll * -2, 0x20, 0x20, 1, 0, + scroll * -8, 0x20, 0x20)); + gSPDisplayList(POLY_XLU_DISP++, &sSunSongEffectCylinderModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} 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..2e4e2a29a 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.h @@ -5,14 +5,17 @@ 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 */ LightNode* lightNode1; + /* 0x148 */ LightInfo lightInfo1; + /* 0x158 */ LightNode* lightNode2; + /* 0x15C */ LightInfo lightInfo2; + /* 0x16C */ f32 unk16C; + /* 0x170 */ u16 timer; + /* 0x174 */ OceffSpotActionFunc actionFunc; } OceffSpot; // size = 0x178 -extern const ActorInit Oceff_Spot_InitVars; - #endif // Z_OCEFF_SPOT_H diff --git a/src/overlays/actors/ovl_Oceff_Storm/overlay.cfg b/src/overlays/actors/ovl_Oceff_Storm/overlay.cfg deleted file mode 100644 index 6845a1117..000000000 --- a/src/overlays/actors/ovl_Oceff_Storm/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Storm -z_oceff_storm.c 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..96d76f807 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -10,18 +10,16 @@ #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 OceffStorm_DefaultAction(OceffStorm* this, PlayState* play); +void func_80981B48(OceffStorm* this, PlayState* play); +void OceffStorm_Draw2(Actor* thisx, PlayState* play); -void OceffStorm_SetupAction(OceffStorm* this, OceffStormActionFunc actionFunc); - -#if 0 -const ActorInit Oceff_Storm_InitVars = { +ActorInit Oceff_Storm_InitVars = { ACTOR_OCEFF_STORM, ACTORCAT_ITEMACTION, FLAGS, @@ -33,22 +31,194 @@ const ActorInit Oceff_Storm_InitVars = { (ActorFunc)OceffStorm_Draw, }; -#endif +void OceffStorm_SetupAction(OceffStorm* this, OceffStormActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_SetupAction.s") +s32 func_8098176C(PlayState* play) { + s32 ret = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/func_8098176C.s") + switch (play->sceneId) { + case SCENE_13HUBUKINOMITI: + case SCENE_11GORONNOSATO: + case SCENE_10YUKIYAMANOMURA: + case SCENE_14YUKIDAMANOMITI: + case SCENE_12HAKUGINMAE: + case SCENE_17SETUGEN: + case SCENE_GORONRACE: + if (gSaveContext.sceneLayer == 0) { + ret = true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_Init.s") + case SCENE_10YUKIYAMANOMURA2: + if (gSaveContext.sceneLayer == 1) { + ret = true; + } + break; + } + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_Destroy.s") +void OceffStorm_Init(Actor* thisx, PlayState* play) { + s32 pad[2]; + Player* player = GET_PLAYER(play); + OceffStorm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/func_80981928.s") + OceffStorm_SetupAction(this, OceffStorm_DefaultAction); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/func_80981B48.s") + this->posYOffAdd = 0; + this->counter = 0; + this->primColorAlpha = 0; + this->vtxAlpha = 0; + this->actor.scale.y = 0.0f; + this->actor.scale.z = 0.0f; + this->actor.scale.x = 0.0f; + this->posYOff = this->posYOffAdd; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_Update.s") + if (this->actor.params == OCEFF_STORM_ACTION_PARAM_1) { + OceffStorm_SetupAction(this, func_80981B48); + this->actor.draw = OceffStorm_Draw2; + } else { + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.world.pos.x = player->bodyPartsPos[0].x; + this->actor.world.pos.z = player->bodyPartsPos[0].z; + gSaveContext.jinxTimer = 0; + if ((play->interfaceCtx.restrictions.songOfStorms == 0) && !func_8098176C(play)) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_OKARINA_EFFECT, this->actor.world.pos.x, + this->actor.world.pos.y - 30.0f, this->actor.world.pos.z, 0, 0, 0, 1); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/func_80981BB8.s") +void OceffStorm_Destroy(Actor* thisx, PlayState* play) { + OceffStorm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Storm/OceffStorm_Draw.s") + Magic_Reset(play); +} + +void OceffStorm_DefaultAction(OceffStorm* this, PlayState* play) { + f32 cylinderScale; + + switch (gSaveContext.save.playerForm) { + default: + cylinderScale = 1.0f; + break; + + case PLAYER_FORM_DEKU: + cylinderScale = 1.3f; + break; + + case PLAYER_FORM_ZORA: + cylinderScale = 1.2f; + break; + + case PLAYER_FORM_GORON: + cylinderScale = 2.0f; + break; + } + + if (this->counter < 10) { + this->primColorAlpha = (s8)(this->counter * 10.0f); + } else if (this->counter > 60) { + this->primColorAlpha = (s8)((70 - this->counter) * 10.0f); + } else { + this->primColorAlpha = 100; + } + + if ((this->counter < 10) || (this->counter >= 60)) { + this->vtxAlpha = 0; + } else if (this->counter <= 40) { + if (this->vtxAlpha <= 200) { + this->vtxAlpha += 10; + } + this->actor.scale.x = this->actor.scale.z = 0.4f * cylinderScale; + this->actor.scale.y = 0.3f; + } else if (this->counter > 40) { + this->vtxAlpha = (60 - this->counter) * 10; + } else { + this->actor.scale.x = this->actor.scale.z = 0.4f * cylinderScale; + this->vtxAlpha = -1; + } + + if (this->counter > 40) { + this->actor.world.pos.y += this->posYOff * 0.01f; + this->posYOff += this->posYOffAdd; + this->posYOffAdd += 10; + } + + if (this->counter < 70) { + this->counter++; + } else { + Actor_Kill(&this->actor); + } +} + +void func_80981B48(OceffStorm* this, PlayState* play) { + if (this->primColorAlpha < 100) { + this->primColorAlpha += 5; + } + //! @bug Actor_Kill is never called so the actor will stay alive forever +} + +void OceffStorm_Update(Actor* thisx, PlayState* play) { + OceffStorm* this = THIS; + + this->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)); + this->actionFunc(this, play); +} + +#include "assets/overlays/ovl_Oceff_Storm/ovl_Oceff_Storm.c" + +void OceffStorm_Draw2(Actor* thisx, PlayState* play) { + s32 scroll = play->state.frames & 0xFFF; + OceffStorm* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + gDPPipeSync(POLY_XLU_DISP++); + + POLY_XLU_DISP = func_8012C3A4(POLY_XLU_DISP); + + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 200, 200, 150, this->primColorAlpha); + + gSPDisplayList(POLY_XLU_DISP++, &sSongOfStormsMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 8, scroll * 4, 64, + 64, 1, scroll * 4, scroll * 4, 64, 64)); + gSPTextureRectangle(POLY_XLU_DISP++, 0, 0, SCREEN_WIDTH << 2, SCREEN_HEIGHT << 2, G_TX_RENDERTILE, 0, 0, + (s32)(0.13671875 * (1 << 10)), (s32)(-0.13671875 * (1 << 10))); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void OceffStorm_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFFF; + OceffStorm* this = (OceffStorm*)thisx; + Vtx* vtxPtr = sSongOfStormsCylinderVtx; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 200, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 150, 150, 0, 128); + gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); + gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); + + vtxPtr[0].v.cn[3] = vtxPtr[6].v.cn[3] = vtxPtr[16].v.cn[3] = vtxPtr[25].v.cn[3] = this->vtxAlpha >> 1; + vtxPtr[10].v.cn[3] = vtxPtr[22].v.cn[3] = this->vtxAlpha; + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, &sSongOfStormsCylinderMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 4, (0 - scroll) * 8, + 32, 32, 1, scroll * 8, (0 - scroll) * 12, 32, 32)); + gSPDisplayList(POLY_XLU_DISP++, &sSongOfStormsCylinderModelDL); + + CLOSE_DISPS(play->state.gfxCtx); + + OceffStorm_Draw2(&this->actor, play); +} 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..87a67191c 100644 --- a/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h +++ b/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.h @@ -5,14 +5,20 @@ 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 */ u16 counter; + /* 0x146 */ u8 primColorAlpha; + /* 0x147 */ u8 vtxAlpha; + /* 0x148 */ s16 posYOff; + /* 0x14A */ s16 posYOffAdd; + /* 0x14C */ OceffStormActionFunc actionFunc; } OceffStorm; // size = 0x150 -extern const ActorInit Oceff_Storm_InitVars; +typedef enum { + /* 1 */ OCEFF_STORM_ACTION_PARAM_1 = 1 +} OceffStormActionParams; #endif // Z_OCEFF_STORM_H diff --git a/src/overlays/actors/ovl_Oceff_Wipe/overlay.cfg b/src/overlays/actors/ovl_Oceff_Wipe/overlay.cfg deleted file mode 100644 index c10e855cf..000000000 --- a/src/overlays/actors/ovl_Oceff_Wipe/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Wipe -z_oceff_wipe.c 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..42bf6c703 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -10,13 +10,12 @@ #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 = { +ActorInit Oceff_Wipe_InitVars = { ACTOR_OCEFF_WIPE, ACTORCAT_ITEMACTION, FLAGS, @@ -28,12 +27,100 @@ const ActorInit Oceff_Wipe_InitVars = { (ActorFunc)OceffWipe_Draw, }; -#endif +UNK_TYPE4 D_80977200; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Init.s") +void OceffWipe_Init(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Destroy.s") + Actor_SetScale(&this->actor, 0.1f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Update.s") +void OceffWipe_Destroy(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe/OceffWipe_Draw.s") + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe_Update(Actor* thisx, PlayState* play) { + OceffWipe* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_Kill(&this->actor); + } +} + +#include "assets/overlays/ovl_Oceff_Wipe/ovl_Oceff_Wipe.c" + +static u8 sAlphaIndices[] = { + 0x01, 0x10, 0x22, 0x01, 0x20, 0x12, 0x01, 0x20, 0x12, 0x01, + 0x10, 0x22, 0x01, 0x20, 0x12, 0x01, 0x12, 0x21, 0x01, 0x02, +}; + +void OceffWipe_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFF; + OceffWipe* this = THIS; + f32 z; + s32 pad; + u8 alphaTable[3]; + s32 i; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + OPEN_DISPS(play->state.gfxCtx); + + if (this->counter < 32) { + z = Math_SinS(this->counter << 9) * 1360.0f; + } else { + z = 1360.0f; + } + + if (this->counter >= 80) { + alphaTable[0] = 0; + alphaTable[1] = (100 - this->counter) * 8; + alphaTable[2] = (100 - this->counter) * 12; + } else { + alphaTable[0] = 0; + alphaTable[1] = 160; + alphaTable[2] = 255; + } + + for (i = 0; i < 20; i++) { + vtxPtr = sSongOfTimeFrustumVtx; + vtxPtr[i * 2 + 0].v.cn[3] = alphaTable[(sAlphaIndices[i] & 0xF0) >> 4]; + vtxPtr[i * 2 + 1].v.cn[3] = alphaTable[sAlphaIndices[i] & 0xF]; + } + + func_8012C2DC(play->state.gfxCtx); + + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.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); + + if (this->actor.params != OCEFF_WIPE_ZL) { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 170, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 150, 255, 128); + } else { + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 200, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 0, 255, 128); + } + + gSPDisplayList(POLY_XLU_DISP++, sSongOfTimeFrustumMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0 - scroll, scroll * -2, 32, + 32, 1, 0 - scroll, scroll * -2, 32, 32)); + gSPDisplayList(POLY_XLU_DISP++, sSongOfTimeFrustumModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h index 5b7e34837..0ee4314d0 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h +++ b/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.h @@ -3,13 +3,16 @@ #include "global.h" +typedef enum { + /* 0x0 */ OCEFF_WIPE_ZL, + /* 0x1 */ OCEFF_WIPE_SOT +} OceffWipeType; + struct OceffWipe; typedef struct OceffWipe { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe; // size = 0x148 -extern const ActorInit Oceff_Wipe_InitVars; - #endif // Z_OCEFF_WIPE_H diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/overlay.cfg b/src/overlays/actors/ovl_Oceff_Wipe2/overlay.cfg deleted file mode 100644 index a8d56b9bb..000000000 --- a/src/overlays/actors/ovl_Oceff_Wipe2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Wipe2 -z_oceff_wipe2.c 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..3d8004c5c 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -10,13 +10,12 @@ #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 = { +ActorInit Oceff_Wipe2_InitVars = { ACTOR_OCEFF_WIPE2, ACTORCAT_ITEMACTION, FLAGS, @@ -28,12 +27,83 @@ const ActorInit Oceff_Wipe2_InitVars = { (ActorFunc)OceffWipe2_Draw, }; -#endif +#include "assets/overlays/ovl_Oceff_Wipe2/ovl_Oceff_Wipe2.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe2/OceffWipe2_Init.s") +s32 D_809879D0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe2/OceffWipe2_Destroy.s") +void OceffWipe2_Init(Actor* thisx, PlayState* play) { + OceffWipe2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe2/OceffWipe2_Update.s") + Actor_SetScale(&this->actor, 0.1f); + this->timer = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe2/OceffWipe2_Draw.s") +void OceffWipe2_Destroy(Actor* thisx, PlayState* play) { + OceffWipe2* this = THIS; + + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe2_Update(Actor* thisx, PlayState* play) { + OceffWipe2* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->timer < 100) { + this->timer++; + } else { + Actor_Kill(&this->actor); + } +} + +void OceffWipe2_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFF; + OceffWipe2* this = THIS; + f32 z; + u8 alpha; + s32 pad[2]; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + vtxPtr = sEponaSongFrustumVtx; + + if (this->timer < 32) { + z = Math_SinS(this->timer << 9) * 1220.0f; + } else { + z = 1220.0f; + } + + if (this->timer >= 80) { + alpha = 12 * (100 - this->timer); + } else { + alpha = 255; + } + + vtxPtr[1].v.cn[3] = vtxPtr[3].v.cn[3] = vtxPtr[5].v.cn[3] = vtxPtr[7].v.cn[3] = vtxPtr[9].v.cn[3] = + vtxPtr[11].v.cn[3] = vtxPtr[13].v.cn[3] = vtxPtr[15].v.cn[3] = vtxPtr[16].v.cn[3] = vtxPtr[18].v.cn[3] = + vtxPtr[20].v.cn[3] = alpha; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.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); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128); + gSPDisplayList(POLY_XLU_DISP++, sEponaSongFrustumMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 6, scroll * -6, 64, + 64, 1, scroll * -6, 0, 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, sEponaSongFrustumModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h index 79d366525..ee2fb2968 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h +++ b/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.h @@ -7,9 +7,7 @@ struct OceffWipe2; typedef struct OceffWipe2 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 timer; } OceffWipe2; // size = 0x148 -extern const ActorInit Oceff_Wipe2_InitVars; - #endif // Z_OCEFF_WIPE2_H diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/overlay.cfg b/src/overlays/actors/ovl_Oceff_Wipe3/overlay.cfg deleted file mode 100644 index 5aca74d99..000000000 --- a/src/overlays/actors/ovl_Oceff_Wipe3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Wipe3 -z_oceff_wipe3.c 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 f91385daa..52031ce00 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -11,13 +11,12 @@ #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 = { +ActorInit Oceff_Wipe3_InitVars = { ACTOR_OCEFF_WIPE3, ACTORCAT_ITEMACTION, FLAGS, @@ -29,12 +28,82 @@ const ActorInit Oceff_Wipe3_InitVars = { (ActorFunc)OceffWipe3_Draw, }; -#endif +#include "assets/overlays/ovl_Oceff_Wipe3/ovl_Oceff_Wipe3.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe3/OceffWipe3_Init.s") +s32 D_80989130; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe3/OceffWipe3_Destroy.s") +void OceffWipe3_Init(Actor* thisx, PlayState* play) { + OceffWipe3* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe3/OceffWipe3_Update.s") + Actor_SetScale(&this->actor, 0.1f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe3/OceffWipe3_Draw.s") +void OceffWipe3_Destroy(Actor* thisx, PlayState* play) { + OceffWipe3* this = THIS; + + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe3_Update(Actor* thisx, PlayState* play) { + OceffWipe3* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_Kill(&this->actor); + } +} + +void OceffWipe3_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFFF; + OceffWipe3* this = THIS; + f32 z; + u8 alpha; + s32 pad[2]; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + vtxPtr = sSariaSongFrustumVtx; + + if (this->counter < 32) { + z = Math_SinS(this->counter * 512) * 1220.0f; + } else { + z = 1220.0f; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + + vtxPtr[1].v.cn[3] = vtxPtr[3].v.cn[3] = vtxPtr[5].v.cn[3] = vtxPtr[7].v.cn[3] = vtxPtr[9].v.cn[3] = + vtxPtr[11].v.cn[3] = vtxPtr[13].v.cn[3] = vtxPtr[15].v.cn[3] = vtxPtr[17].v.cn[3] = vtxPtr[19].v.cn[3] = + vtxPtr[21].v.cn[3] = alpha; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.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); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 170, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 128); + gSPDisplayList(POLY_XLU_DISP++, &sSariaSongFrustrumMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, 0, scroll * 12, scroll * -12, 64, 64, 1, + scroll * 8, scroll * -8, 64, 64)); + gSPDisplayList(POLY_XLU_DISP++, &sSariaSongFrustumModelDL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h index b9f41bb09..a604aae34 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.h @@ -7,9 +7,7 @@ struct OceffWipe3; typedef struct OceffWipe3 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe3; // size = 0x148 -extern const ActorInit Oceff_Wipe3_InitVars; - #endif // Z_OCEFF_WIPE3_H diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/overlay.cfg b/src/overlays/actors/ovl_Oceff_Wipe4/overlay.cfg deleted file mode 100644 index 64cd25b04..000000000 --- a/src/overlays/actors/ovl_Oceff_Wipe4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Wipe4 -z_oceff_wipe4.c 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..3554bc78a 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -10,13 +10,12 @@ #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 = { +ActorInit Oceff_Wipe4_InitVars = { ACTOR_OCEFF_WIPE4, ACTORCAT_ITEMACTION, FLAGS, @@ -28,12 +27,87 @@ const ActorInit Oceff_Wipe4_InitVars = { (ActorFunc)OceffWipe4_Draw, }; -#endif +#include "assets/overlays/ovl_Oceff_Wipe4/ovl_Oceff_Wipe4.c" -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe4/OceffWipe4_Init.s") +s32 D_8099E780; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe4/OceffWipe4_Destroy.s") +void OceffWipe4_Init(Actor* thisx, PlayState* play) { + OceffWipe4* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe4/OceffWipe4_Update.s") + Actor_SetScale(&this->actor, 0.1f); + this->counter = 0; + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe4/OceffWipe4_Draw.s") +void OceffWipe4_Destroy(Actor* thisx, PlayState* play) { + OceffWipe4* this = THIS; + + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe4_Update(Actor* thisx, PlayState* play) { + OceffWipe4* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 50) { + this->counter++; + } else { + Actor_Kill(&this->actor); + } +} + +void OceffWipe4_Draw(Actor* thisx, PlayState* play) { + u32 scroll = play->state.frames & 0xFFF; + OceffWipe4* this = THIS; + f32 z; + u8 alpha; + s32 pad[2]; + Vec3f eye = GET_ACTIVE_CAM(play)->eye; + Vtx* vtxPtr; + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(play)); + + if (this->counter < 16) { + z = Math_SinS(this->counter * 0x400) * 1220.0f; + } else { + z = 1220.0f; + } + + vtxPtr = sScarecrowSongFrustumVtx; + if (this->counter >= 30) { + alpha = 12 * (50 - this->counter); + } else { + alpha = 255; + } + + vtxPtr[1].v.cn[3] = vtxPtr[3].v.cn[3] = vtxPtr[5].v.cn[3] = vtxPtr[7].v.cn[3] = vtxPtr[9].v.cn[3] = + vtxPtr[11].v.cn[3] = vtxPtr[13].v.cn[3] = vtxPtr[15].v.cn[3] = vtxPtr[17].v.cn[3] = vtxPtr[19].v.cn[3] = + vtxPtr[21].v.cn[3] = alpha; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C2DC(play->state.gfxCtx); + + Matrix_Translate(eye.x + quakeOffset.x, eye.y + quakeOffset.y, eye.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); + + if (this->actor.params == OCEFF_WIPE4_UNUSED) { + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongUnusedMaterialDL); + } else { + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongMaterialDL); + } + + gSPDisplayList(POLY_XLU_DISP++, sScarecrowSongModelDL); + gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, scroll * 2, scroll * -2, 32, + 64, 1, scroll * -1, scroll, 32, 32)); + gSPDisplayList(POLY_XLU_DISP++, &sScarecrowSongModelDL[11]); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h index 76debbeed..e65bf575b 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h +++ b/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.h @@ -3,13 +3,16 @@ #include "global.h" +typedef enum { + /* 0 */ OCEFF_WIPE4_SCARECROWS, + /* 1 */ OCEFF_WIPE4_UNUSED +} OceffWipe4Type; + struct OceffWipe4; typedef struct OceffWipe4 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe4; // size = 0x148 -extern const ActorInit Oceff_Wipe4_InitVars; - #endif // Z_OCEFF_WIPE4_H diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/overlay.cfg b/src/overlays/actors/ovl_Oceff_Wipe5/overlay.cfg deleted file mode 100644 index 274c53c0f..000000000 --- a/src/overlays/actors/ovl_Oceff_Wipe5/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Wipe5 -z_oceff_wipe5.c 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..0d0db6385 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.c @@ -10,13 +10,12 @@ #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 = { +ActorInit Oceff_Wipe5_InitVars = { ACTOR_OCEFF_WIPE5, ACTORCAT_ITEMACTION, FLAGS, @@ -28,12 +27,104 @@ const ActorInit Oceff_Wipe5_InitVars = { (ActorFunc)OceffWipe5_Draw, }; -#endif +UNK_TYPE4 D_80BC9260; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Init.s") +void OceffWipe5_Init(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Destroy.s") + Actor_SetScale(&this->actor, 1.0f); + this->counter = 0; + this->actor.world.pos = play->cameraPtrs[play->activeCamId]->eye; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Update.s") +void OceffWipe5_Destroy(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Oceff_Wipe5/OceffWipe5_Draw.s") + Magic_Reset(play); + play->msgCtx.unk120B0 = 0; +} + +void OceffWipe5_Update(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; + + this->actor.world.pos = GET_ACTIVE_CAM(play)->eye; + if (this->counter < 100) { + this->counter++; + } else { + Actor_Kill(&this->actor); + } +} + +#include "assets/overlays/ovl_Oceff_Wipe5/ovl_Oceff_Wipe5.c" + +static u8 sPrimColors[] = { + 255, 255, 200, 255, 255, 200, 200, 255, 255, 255, 255, 200, 255, 200, 255, +}; + +static u8 sEnvColors[] = { + 50, 200, 0, 255, 50, 0, 0, 100, 255, 255, 150, 0, 255, 0, 200, +}; + +void OceffWipe5_Draw(Actor* thisx, PlayState* play) { + OceffWipe5* this = THIS; + f32 z; + s32 pad; + s32 i; + s32 pad2; + Vec3f activeCamEye = GET_ACTIVE_CAM(play)->eye; + Camera* cam = GET_ACTIVE_CAM(play); + Vec3f quakeOffset; + u8 alpha; + s32 colorIndex = OCEFF_WIPE5_GET_SONG_TYPE(thisx) * 3; + f32 phi_fv1 = 1220.0f; + + if ((((OCEFF_WIPE5_GET_SONG_TYPE(thisx) == 2) && (play->sceneId == SCENE_LABO)) && + ((play->csCtx.currentCsIndex == 0) || (play->csCtx.currentCsIndex == 1))) && + (play->csCtx.state != 0)) { + phi_fv1 = 1150.0f; + } + + if (colorIndex >= 13) { + colorIndex = 0; + } + + Camera_GetQuakeOffset(&quakeOffset, cam); + + if (this->counter < 32) { + z = Math_SinS(this->counter << 9) * phi_fv1; + } else { + z = phi_fv1; + } + + if (this->counter >= 80) { + alpha = 12 * (100 - this->counter); + } else { + alpha = 255; + } + for (i = 1; i < ARRAY_COUNT(gOceff5Vtx); i += 2) { + gOceff5Vtx[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); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, sPrimColors[colorIndex], sPrimColors[colorIndex + 1], + sPrimColors[colorIndex + 2], 255); + gDPSetEnvColor(POLY_XLU_DISP++, sEnvColors[colorIndex], sEnvColors[colorIndex + 1], sEnvColors[colorIndex + 2], + 255); + + AnimatedMat_Draw(play, gOceff5TexAnim); + + gSPDisplayList(POLY_XLU_DISP++, &gOceff5DL); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h index 063d0386b..21e1f2383 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h +++ b/src/overlays/actors/ovl_Oceff_Wipe5/z_oceff_wipe5.h @@ -3,13 +3,13 @@ #include "global.h" +#define OCEFF_WIPE5_GET_SONG_TYPE(thisx) ((thisx)->params & 0xF) + struct OceffWipe5; typedef struct OceffWipe5 { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ s16 counter; } OceffWipe5; // size = 0x148 -extern const ActorInit Oceff_Wipe5_InitVars; - #endif // Z_OCEFF_WIPE5_H diff --git a/src/overlays/actors/ovl_Oceff_Wipe6/overlay.cfg b/src/overlays/actors/ovl_Oceff_Wipe6/overlay.cfg deleted file mode 100644 index 722d51979..000000000 --- a/src/overlays/actors/ovl_Oceff_Wipe6/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Wipe6 -z_oceff_wipe6.c 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 a54ca583c..87dbe2752 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.c @@ -10,12 +10,12 @@ #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 = { +ActorInit Oceff_Wipe6_InitVars = { ACTOR_OCEFF_WIPE6, ACTORCAT_ITEMACTION, FLAGS, @@ -29,31 +29,31 @@ 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) { + Magic_Reset(play); + 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 { - Actor_MarkForDeath(&this->actor); + Actor_Kill(&this->actor); } } -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); + 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(&globalCtx->billboardMtxF); + Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_RotateXS(0x708, MTXMODE_APPLY); Matrix_Translate(0.0f, 0.0f, -z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - AnimatedMat_Draw(globalCtx, ovl_Oceff_Wipe6_Matanimheader_000338); + 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_Wipe6/z_oceff_wipe6.h b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h index c37e3f9d4..2afd8f24f 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h +++ b/src/overlays/actors/ovl_Oceff_Wipe6/z_oceff_wipe6.h @@ -10,6 +10,4 @@ typedef struct OceffWipe6 { /* 0x144 */ s16 counter; } OceffWipe6; // size = 0x148 -extern const ActorInit Oceff_Wipe6_InitVars; - #endif // Z_OCEFF_WIPE6_H diff --git a/src/overlays/actors/ovl_Oceff_Wipe7/overlay.cfg b/src/overlays/actors/ovl_Oceff_Wipe7/overlay.cfg deleted file mode 100644 index 0956cdd61..000000000 --- a/src/overlays/actors/ovl_Oceff_Wipe7/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Oceff_Wipe7 -z_oceff_wipe7.c 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..f269a89a5 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.c @@ -10,13 +10,12 @@ #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 = { +ActorInit Oceff_Wipe7_InitVars = { ACTOR_OCEFF_WIPE7, ACTORCAT_ITEMACTION, FLAGS, @@ -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; + + Magic_Reset(play); + 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_Kill(&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..7cb7019a7 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.h +++ b/src/overlays/actors/ovl_Oceff_Wipe7/z_oceff_wipe7.h @@ -7,9 +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; - #endif // Z_OCEFF_WIPE7_H diff --git a/src/overlays/actors/ovl_Shot_Sun/overlay.cfg b/src/overlays/actors/ovl_Shot_Sun/overlay.cfg deleted file mode 100644 index bd210022d..000000000 --- a/src/overlays/actors/ovl_Shot_Sun/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Shot_Sun -z_shot_sun.c 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..74e711cfa 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -1,26 +1,25 @@ /* * 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* play); -#if 0 -const ActorInit Shot_Sun_InitVars = { +ActorInit Shot_Sun_InitVars = { ACTOR_SHOT_SUN, ACTORCAT_PROP, FLAGS, @@ -32,27 +31,160 @@ 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_Kill(&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_Kill(&this->actor); + return; + } + + 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[PLAYER_BODYPART_HEAD].x + (play->envCtx.sunPos.x * (1.0f / 6.0f)); + cylinderPos.y = + (player->bodyPartsPos[PLAYER_BODYPART_HEAD].y - 30.0f) + (play->envCtx.sunPos.y * (1.0f / 6.0f)); + cylinderPos.z = player->bodyPartsPos[PLAYER_BODYPART_HEAD].z + (play->envCtx.sunPos.z * (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..3ba7f35d9 100644 --- a/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h +++ b/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.h @@ -3,17 +3,21 @@ #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]; + /* 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; - #endif // Z_SHOT_SUN_H diff --git a/src/overlays/actors/ovl_TG_Sw/overlay.cfg b/src/overlays/actors/ovl_TG_Sw/overlay.cfg deleted file mode 100644 index d0341bf09..000000000 --- a/src/overlays/actors/ovl_TG_Sw/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_TG_Sw -z_tg_sw.c 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..8c1e98bed 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -11,14 +11,14 @@ #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 = { +ActorInit TG_Sw_InitVars = { ACTOR_TG_SW, ACTORCAT_PROP, FLAGS, @@ -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; @@ -84,25 +84,26 @@ void TGSw_ActionExecuteOneShot(TGSw* this, GlobalContext* globalCtx) { actor = actor->next; } while (actor != NULL); - Actor_MarkForDeath(&this->actor); + Actor_Kill(&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..cbcb66431 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h @@ -4,13 +4,11 @@ #include "global.h" struct TGSw; -typedef void (*TGSwActionFunc)(struct TGSw*, GlobalContext*); +typedef void (*TGSwActionFunc)(struct TGSw*, PlayState*); typedef struct TGSw { /* 0x000 */ Actor actor; /* 0x144 */ TGSwActionFunc actionFunc; } TGSw; // size = 0x148 -extern const ActorInit TG_Sw_InitVars; - #endif // Z_TG_SW_H diff --git a/src/overlays/actors/ovl_player_actor/overlay.cfg b/src/overlays/actors/ovl_player_actor/overlay.cfg deleted file mode 100644 index 2d4849235..000000000 --- a/src/overlays/actors/ovl_player_actor/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_player_actor -z_player.c diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index bc3e3c1e8..1f92e8825 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -5,6 +5,9 @@ */ #include "global.h" +#include "z64quake.h" +#include "z64rumble.h" +#include "z64shrink_window.h" #define THIS ((Player*)thisx) @@ -12,10 +15,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/overlay.cfg b/src/overlays/effects/ovl_Effect_En_Ice_Block/overlay.cfg deleted file mode 100644 index 3035ab72e..000000000 --- a/src/overlays/effects/ovl_Effect_En_Ice_Block/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_En_Ice_Block -z_eff_en_ice_block.c 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 a2449af92..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,27 +48,27 @@ 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); + 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_Mult(&globalCtx->billboardMtxF, 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Blast/overlay.cfg deleted file mode 100644 index 2bb72beac..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Blast -z_eff_ss_blast.c 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..93353f28c 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 @@ -1,27 +1,90 @@ /* * File: z_eff_ss_blast.c * Overlay: ovl_Effect_Ss_Blast - * Description: + * Description: Shockwave Effect */ #include "z_eff_ss_blast.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 rAlphaStep regs[8] +#define rScale regs[9] +#define rScaleStep regs[10] +#define rScaleStepDecay regs[11] #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); +u32 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 = { EFFECT_SS_BLAST, EffectSsBlast_Init, }; -#endif +u32 EffectSsBlast_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsBlastInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Blast/EffectSsBlast_Init.s") + this->pos = initParams->pos; + this->pos.y += 5.0f; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->gfx = gEffShockwaveDL; + this->life = initParams->life; + this->draw = EffectSsBlast_Draw; + this->update = EffectSsBlast_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->rAlphaStep = initParams->primColor.a / initParams->life; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->rScaleStepDecay = initParams->scaleStepDecay; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Blast/EffectSsBlast_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Blast/EffectSsBlast_Update.s") +void EffectSsBlast_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mf; + s32 pad; + f32 radius; + + OPEN_DISPS(gfxCtx); + + radius = this->rScale * 0.0025f; + + func_8012C2DC(play->state.gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, this->rEnvColorA); + func_801691F0(play, &mf, &this->pos); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, this->rPrimColorA); + Matrix_Put(&mf); + Matrix_Scale(radius, radius, radius, 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 EffectSsBlast_Update(PlayState* play, u32 index, EffectSs* this) { + Math_StepToS(&this->rPrimColorA, 0, this->rAlphaStep); + this->rScale += this->rScaleStep; + + if (this->rScaleStep != 0) { + this->rScaleStep -= this->rScaleStepDecay; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h index 2a13227c3..72a264c03 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h +++ b/src/overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h @@ -11,7 +11,7 @@ typedef struct { /* 0x28 */ Color_RGBA8 envColor; /* 0x2C */ s16 scale; /* 0x2E */ s16 scaleStep; - /* 0x30 */ s16 sclaeStepDecay; + /* 0x30 */ s16 scaleStepDecay; /* 0x32 */ s16 life; } EffectSsBlastInitParams; // size = 0x34 diff --git a/src/overlays/effects/ovl_Effect_Ss_Bomb2/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Bomb2/overlay.cfg deleted file mode 100644 index f964deb72..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Bomb2/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Bomb2 -z_eff_ss_bomb2.c 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..d15151d49 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 @@ -1,30 +1,195 @@ /* * File: z_eff_ss_bomb2.c * Overlay: ovl_Effect_Ss_Bomb2 - * Description: + * Description: Bomb Blast */ #include "z_eff_ss_bomb2.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rTexIndex 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 rScaleStep regs[9] +#define rDepth regs[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); +u32 EffectSsBomb2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsBomb2_DrawFade(PlayState* play, u32 index, EffectSs* this); +void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this); +void EffectSsBomb2_Update(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Bomb2_InitVars = { EFFECT_SS_BOMB2, EffectSsBomb2_Init, }; -#endif +static EffectSsDrawFunc sDrawFuncs[] = { + EffectSsBomb2_DrawFade, + EffectSsBomb2_DrawLayered, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bomb2/EffectSsBomb2_Init.s") +static TexturePtr sTextures[] = { + gEffBombExplosion1Tex, gEffBombExplosion2Tex, gEffBombExplosion3Tex, gEffBombExplosion4Tex, + gEffBombExplosion5Tex, gEffBombExplosion6Tex, gEffBombExplosion7Tex, gEffBombExplosion8Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bomb2/func_80978138.s") +static TexturePtr sLayeredTextures[] = { + gEffBombExplosion1Tex, gEffBombExplosion2Tex, gEffBombExplosion3Tex, gEffBombExplosion4Tex, + gEffBombExplosion5Tex, gEffBombExplosion6Tex, gEffBombExplosion7Tex, gEffBombExplosion8Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bomb2/func_80978304.s") +u32 EffectSsBomb2_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsBomb2InitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Bomb2/EffectSsBomb2_Update.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gEffBombExplosion1DL; + this->life = 24; + this->update = EffectSsBomb2_Update; + this->draw = sDrawFuncs[initParams->drawMode]; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->rPrimColorR = 255; + this->rPrimColorG = 255; + this->rPrimColorB = 255; + this->rPrimColorA = 255; + this->rEnvColorR = 0; + this->rEnvColorG = 0; + this->rEnvColorB = 200; + + return 1; +} + +// unused in the original game. looks like EffectSsBomb but with color +void EffectSsBomb2_DrawFade(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + Mtx* mtx; + s32 pad; + 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, 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); + 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, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sTextures[this->rTexIndex])); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBomb2_DrawLayered(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + MtxF mtx2F; + Mtx* mtx2; + Mtx* mtx; + s32 pad[3]; + f32 scale; + f32 depth; + f32 layer2Scale = 0.925f; + s32 i; + + OPEN_DISPS(gfxCtx); + + depth = this->rDepth; + scale = this->rScale * 0.01f; + 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); + + mtx2 = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult); + + if (mtx2 != NULL) { + 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, 0); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sLayeredTextures[this->rTexIndex])); + gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion2DL); + gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion3DL); + + Matrix_MtxToMtxF(mtx2, &mtx2F); + Matrix_Put(&mtx2F); + + for (i = 1; i >= 0; i--) { + Matrix_Translate(0.0f, 0.0f, depth, MTXMODE_APPLY); + Matrix_RotateZF((this->life * 0.02f) + 180.0f, MTXMODE_APPLY); + Matrix_Scale(layer2Scale, layer2Scale, layer2Scale, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gEffBombExplosion3DL); + layer2Scale -= 0.15f; + } + } + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsBomb2_Update(PlayState* play, u32 index, EffectSs* this) { + s32 divisor; + + this->rTexIndex = (23 - this->life) / 3; + this->rScale += this->rScaleStep; + + if (this->rScaleStep == 30) { + this->rDepth += 4; + } else { + this->rDepth += 2; + } + + if ((this->life < 23) && (this->life > 13)) { + divisor = this->life - 13; + this->rPrimColorR = func_800B096C(this->rPrimColorR, 255, divisor); + this->rPrimColorG = func_800B096C(this->rPrimColorG, 255, divisor); + this->rPrimColorB = func_800B096C(this->rPrimColorB, 150, divisor); + this->rPrimColorA = func_800B096C(this->rPrimColorA, 255, divisor); + this->rEnvColorR = func_800B096C(this->rEnvColorR, 150, divisor); + this->rEnvColorG = func_800B096C(this->rEnvColorG, 0, divisor); + this->rEnvColorB = func_800B096C(this->rEnvColorB, 0, divisor); + } else if ((this->life < 14) && (this->life > -1)) { + divisor = this->life + 1; + this->rPrimColorR = func_800B096C(this->rPrimColorR, 50, divisor); + this->rPrimColorG = func_800B096C(this->rPrimColorG, 50, divisor); + this->rPrimColorB = func_800B096C(this->rPrimColorB, 50, divisor); + this->rPrimColorA = func_800B096C(this->rPrimColorA, 150, divisor); + this->rEnvColorR = func_800B096C(this->rEnvColorR, 10, divisor); + this->rEnvColorG = func_800B096C(this->rEnvColorG, 10, divisor); + this->rEnvColorB = func_800B096C(this->rEnvColorB, 10, divisor); + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Bubble/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Bubble/overlay.cfg deleted file mode 100644 index bdf4b4069..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Bubble/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Bubble -z_eff_ss_bubble.c 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 6627e1c87..3298b2ab3 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 @@ -1,7 +1,7 @@ /* * File: z_eff_ss_bubble.c * Overlay: ovl_Effect_Ss_Bubble - * Description: + * Description: Water Bubbles */ #include "z_eff_ss_bubble.h" @@ -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* play2, 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,8 +45,8 @@ 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); @@ -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_IsFloorConveyor(&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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_D_Fire/overlay.cfg deleted file mode 100644 index 2c439ec55..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_D_Fire -z_eff_ss_d_fire.c 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..9d8eecfbc 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 @@ -1,31 +1,115 @@ /* * File: z_eff_ss_d_fire.c * Overlay: ovl_Effect_Ss_D_Fire - * Description: + * Description: Dodongo Fire */ #include "z_eff_ss_d_fire.h" +#include "objects/object_dodongo/object_dodongo.h" + +#define rScale regs[0] +#define rTexIndex regs[1] +#define rAlpha regs[5] +#define rAlphaStep regs[6] +#define rFadeDelay regs[7] +#define rScaleStep regs[8] +#define rObjectIndex regs[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); +u32 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 = { EFFECT_SS_D_FIRE, EffectSsDFire_Init, }; -#endif +static TexturePtr sFireTextures[] = { gDodongoFire0Tex, gDodongoFire1Tex, gDodongoFire2Tex, gDodongoFire3Tex }; -extern UNK_TYPE D_060098A0; +s32 EffectSsDFire_CheckForObject(EffectSs* this, PlayState* play) { + if (((this->rObjectIndex = Object_GetIndex(&play->objectCtx, OBJECT_DODONGO)) < 0) || + !Object_IsLoaded(&play->objectCtx, this->rObjectIndex)) { + this->life = -1; + this->draw = NULL; + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_D_Fire/func_809791B0.s") +u32 EffectSsDFire_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDFireInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_D_Fire/EffectSsDFire_Init.s") + if (EffectSsDFire_CheckForObject(this, play)) { + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gDodongoFireDL; + this->life = initParams->life; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->draw = EffectSsDFire_Draw; + this->update = EffectSsDFire_Update; + this->rTexIndex = (play->state.frames & 3) ^ 3; // The xor reverses order, i.e 3 -> 2 -> 1 -> 0 -> 3 + this->rAlpha = initParams->alpha; + this->rFadeDelay = this->life - initParams->fadeDelay; + this->rAlphaStep = initParams->alphaStep; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_D_Fire/EffectSsDFire_Draw.s") + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_D_Fire/EffectSsDFire_Update.s") + return 0; +} + +void EffectSsDFire_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + s32 pad; + void* object; + f32 scale; + + if (EffectSsDFire_CheckForObject(this, play)) { + object = play->objectCtx.status[this->rObjectIndex].segment; + + OPEN_DISPS(gfxCtx); + + gSegments[6] = VIRTUAL_TO_PHYSICAL(object); + gSPSegment(POLY_XLU_DISP++, 0x06, object); + + scale = this->rScale / 100.0f; + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C974(gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 50, this->rAlpha); + + { + TexturePtr* tex = sFireTextures[this->rTexIndex]; + + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(tex)); + } + + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); + } +} + +void EffectSsDFire_Update(PlayState* play, u32 index, EffectSs* this) { + this->rTexIndex++; + this->rTexIndex &= 3; + this->rScale += this->rScaleStep; + if (this->life < this->rFadeDelay) { + this->rAlpha -= this->rAlphaStep; + if (this->rAlpha < 0) { + this->rAlpha = 0; + this->life = -1; + } + } + + EffectSsDFire_CheckForObject(this, play); +} diff --git a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h index 09298249d..2d657bc43 100644 --- a/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h +++ b/src/overlays/effects/ovl_Effect_Ss_D_Fire/z_eff_ss_d_fire.h @@ -10,8 +10,8 @@ typedef struct { /* 0x24 */ s16 scale; /* 0x26 */ s16 scaleStep; /* 0x28 */ s16 alpha; - /* 0x2A */ s16 fadeDelay; - /* 0x2C */ s16 unk_2C; + /* 0x2A */ s16 alphaStep; + /* 0x2C */ s16 fadeDelay; /* 0x30 */ s32 life; } EffectSsDFireInitParams; // size = 0x34 diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/overlay.cfg deleted file mode 100644 index 61ff41312..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Dead_Db -z_eff_ss_dead_db.c 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..54963eb3b 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 @@ -1,27 +1,129 @@ /* * File: z_eff_ss_dead_db.c * Overlay: ovl_Effect_Ss_Dead_Db - * Description: + * Description: Enemy Death Flames */ #include "z_eff_ss_dead_db.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rTexIndex 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 rScaleStep regs[9] +#define rTotalLife regs[11] #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); +u32 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 = { EFFECT_SS_DEAD_DB, EffectSsDeadDb_Init, }; -#endif +static TexturePtr sTextures[] = { + gEffEnemyDeathFlame1Tex, gEffEnemyDeathFlame2Tex, gEffEnemyDeathFlame3Tex, gEffEnemyDeathFlame4Tex, + gEffEnemyDeathFlame5Tex, gEffEnemyDeathFlame6Tex, gEffEnemyDeathFlame7Tex, gEffEnemyDeathFlame8Tex, + gEffEnemyDeathFlame9Tex, gEffEnemyDeathFlame10Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_Init.s") +u32 EffectSsDeadDb_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDeadDbInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_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 = gEffEnemyDeathFlameDL; + this->life = initParams->life; + this->flags = 4; + this->rScaleStep = initParams->scaleStep; + this->rTotalLife = initParams->life; + this->draw = EffectSsDeadDb_Draw; + this->update = EffectSsDeadDb_Update; + this->rScale = initParams->scale; + this->rTexIndex = 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; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Db/EffectSsDeadDb_Update.s") + return 1; +} + +void EffectSsDeadDb_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) { + gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C974(gfxCtx); + gDPSetEnvColor(POLY_XLU_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, 0); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + this->rPrimColorA); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sTextures[this->rTexIndex])); + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + } + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsDeadDb_Update(PlayState* play, u32 index, EffectSs* this) { + this->rTexIndex = (f32)((this->rTotalLife - this->life) * 9) / this->rTotalLife; + this->rScale += this->rScaleStep; + + this->rPrimColorR -= 10; + if (this->rPrimColorR < 0) { + this->rPrimColorR = 0; + } + + this->rPrimColorG -= 10; + if (this->rPrimColorG < 0) { + this->rPrimColorG = 0; + } + + this->rPrimColorB -= 10; + if (this->rPrimColorB < 0) { + this->rPrimColorB = 0; + } + + this->rEnvColorR -= 10; + if (this->rEnvColorR < 0) { + this->rEnvColorR = 0; + } + + this->rEnvColorG -= 10; + if (this->rEnvColorG < 0) { + this->rEnvColorG = 0; + } + + this->rEnvColorB -= 10; + if (this->rEnvColorB < 0) { + this->rEnvColorB = 0; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h index bbdf3c290..a1ac62167 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dead_Db/z_eff_ss_dead_db.h @@ -11,8 +11,8 @@ typedef struct { /* 0x26 */ s16 scaleStep; /* 0x28 */ Color_RGBA8 primColor; /* 0x2C */ Color_RGBA8 envColor; - /* 0x30 */ s32 unk_30; -} EffectSsDeadDbInitParams; // size = 0x30 + /* 0x30 */ s32 life; +} EffectSsDeadDbInitParams; // size = 0x34 extern const EffectSsInit Effect_Ss_Dead_Db_InitVars; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/overlay.cfg deleted file mode 100644 index 86355de67..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Dd/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Dead_Dd -z_eff_ss_dead_dd.c 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..5e8a1e451 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,140 @@ */ #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++, gLensFlareCircleDL); + } + + 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/overlay.cfg deleted file mode 100644 index 40a9f45d1..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Dead_Ds/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Dead_Ds -z_eff_ss_dead_ds.c 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..7bf60c2a1 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 @@ -1,27 +1,124 @@ /* * File: z_eff_ss_dead_ds.c * Overlay: ovl_Effect_Ss_Dead_Ds - * Description: + * Description: Burn mark on the floor */ #include "z_eff_ss_dead_ds.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rScale regs[0] +#define rTimer regs[1] +#define rRoll regs[2] +#define rPitch regs[3] +#define rYaw regs[4] +#define rAlpha regs[5] +#define rScaleStep regs[9] +#define rAlphaStep regs[10] +#define rHalfOfLife regs[11] #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); +u32 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 = { EFFECT_SS_DEAD_DS, EffectSsDeadDs_Init, }; -#endif +u32 EffectSsDeadDs_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDeadDsInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Ds/EffectSsDeadDs_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->life = initParams->life; + this->rScaleStep = initParams->scaleStep; + this->rHalfOfLife = initParams->life / 2; + this->rAlphaStep = initParams->alpha / this->rHalfOfLife; + this->draw = EffectSsDeadDs_Draw; + this->update = EffectSsDeadDs_Update; + this->rScale = initParams->scale; + this->rAlpha = initParams->alpha; + this->rTimer = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Ds/EffectSsDeadDs_Draw.s") + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dead_Ds/EffectSsDeadDs_Update.s") +void EffectSsDeadDs_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + f32 scale; + s32 pad2[2]; + MtxF mf; + f32 yIntersect; + Vec3f pos; + CollisionPoly* floorPoly; + + OPEN_DISPS(play->state.gfxCtx); + + scale = this->rScale * 0.01f; + func_8012C974(play->state.gfxCtx); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0, 0, 0, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 0); + pos = this->pos; + + if (this->rTimer == 0) { + Vec3s rot; + Vec3f prevPos; + + prevPos.x = pos.x - this->velocity.x; + prevPos.y = pos.y - this->velocity.y; + prevPos.z = pos.z - this->velocity.z; + + if (BgCheck_EntitySphVsWall1(&play->colCtx, &this->pos, &pos, &prevPos, 1.5f, &floorPoly, 1.0f)) { + func_800C0094(floorPoly, this->pos.x, this->pos.y, this->pos.z, &mf); + Matrix_Put(&mf); + } else { + pos.y++; + yIntersect = BgCheck_EntityRaycastFloor1(&play->colCtx, &floorPoly, &pos); + + if (floorPoly != NULL) { + func_800C0094(floorPoly, this->pos.x, yIntersect + 1.5f, this->pos.z, &mf); + Matrix_Put(&mf); + } else { + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Get(&mf); + } + } + + Matrix_MtxFToZYXRot(&mf, &rot, false); + this->rRoll = rot.x; + this->rPitch = rot.y; + this->rYaw = rot.z; + this->pos.y = mf.yw; + this->rTimer++; + } + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_RotateZYX(this->rRoll, this->rPitch, this->rYaw, MTXMODE_APPLY); + Matrix_RotateXFApply(1.57f); // (M_PI / 2) + 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); + gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + gSPDisplayList(POLY_XLU_DISP++, gLensFlareCircleDL); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void EffectSsDeadDs_Update(PlayState* play, u32 index, EffectSs* this) { + if (this->life < this->rHalfOfLife) { + + this->rScale += this->rScaleStep; + if (this->rScale < 0) { + this->rScale = 0; + } + + this->rAlpha -= this->rAlphaStep; + if (this->rAlpha < 0) { + this->rAlpha = 0; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/overlay.cfg deleted file mode 100644 index f3b368b9e..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Dt_Bubble -z_eff_ss_dt_bubble.c 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..4d009c00a 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 @@ -1,27 +1,116 @@ /* * File: z_eff_ss_dt_bubble.c * Overlay: ovl_Effect_Ss_Dt_Bubble - * Description: + * Description: Non-Water Bubbles (a random mix of translucent and opaque) */ #include "z_eff_ss_dt_bubble.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 rRandXZ regs[8] +#define rScale regs[9] +#define rLifespan regs[10] #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); +u32 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); + +static Color_RGBA8 sPrimColors[] = { + { 255, 255, 100, 255 }, + { 150, 255, 255, 255 }, + { 100, 255, 255, 255 }, + { 255, 255, 255, 255 }, +}; + +static Color_RGBA8 sEnvColors[] = { + { 170, 0, 0, 255 }, + { 0, 100, 0, 255 }, + { 0, 0, 255, 255 }, + { 150, 150, 150, 0 }, +}; -#if 0 const EffectSsInit Effect_Ss_Dt_Bubble_InitVars = { EFFECT_SS_DT_BUBBLE, EffectSsDtBubble_Init, }; -#endif +u32 EffectSsDtBubble_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDtBubbleInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dt_Bubble/EffectSsDtBubble_Init.s") + { + TexturePtr tex = (Rand_ZeroOne() < 0.5f) ? gEffBubble1Tex : gEffBubble2Tex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dt_Bubble/EffectSsDtBubble_Draw.s") + this->gfx = VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(tex)); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dt_Bubble/EffectSsDtBubble_Update.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->life = initParams->life; + + if (!initParams->customColor) { + this->rPrimColorR = sPrimColors[initParams->colorProfile].r; + this->rPrimColorG = sPrimColors[initParams->colorProfile].g; + this->rPrimColorB = sPrimColors[initParams->colorProfile].b; + this->rPrimColorA = sPrimColors[initParams->colorProfile].a; + this->rEnvColorR = sEnvColors[initParams->colorProfile].r; + this->rEnvColorG = sEnvColors[initParams->colorProfile].g; + this->rEnvColorB = sEnvColors[initParams->colorProfile].b; + this->rEnvColorA = sEnvColors[initParams->colorProfile].a; + } else { + 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->rRandXZ = initParams->randXZ; + this->rScale = initParams->scale; + this->rLifespan = initParams->life; + this->draw = EffectSsDtBubble_Draw; + this->update = EffectSsDtBubble_Update; + + return 1; +} + +void EffectSsDtBubble_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + f32 scale; + + OPEN_DISPS(gfxCtx); + + scale = this->rScale * 0.004f; + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + func_8012C28C(gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, this->rPrimColorR, this->rPrimColorG, this->rPrimColorB, + (this->rPrimColorA * this->life) / this->rLifespan); + gDPSetEnvColor(POLY_OPA_DISP++, this->rEnvColorR, this->rEnvColorG, this->rEnvColorB, + (this->rEnvColorA * this->life) / this->rLifespan); + gSPSegment(POLY_OPA_DISP++, 0x08, this->gfx); + gSPDisplayList(POLY_OPA_DISP++, gEffBubbleDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsDtBubble_Update(PlayState* play, u32 index, EffectSs* this) { + if (this->rRandXZ == true) { + this->pos.x += (Rand_ZeroOne() * 2.0f) - 1.0f; + this->pos.z += (Rand_ZeroOne() * 2.0f) - 1.0f; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h index 75847c0c4..e572f4a2c 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dt_Bubble/z_eff_ss_dt_bubble.h @@ -3,6 +3,13 @@ #include "global.h" +typedef enum { + /* 0 */ DTBUBBLE_COLOR_PROFILE_RED, + /* 1 */ DTBUBBLE_COLOR_PROFILE_GREEN, + /* 2 */ DTBUBBLE_COLOR_PROFILE_BLUE, + /* 3 */ DTBUBBLE_COLOR_PROFILE_CLEAR +} DtBubbleColorProfile; + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Dust/overlay.cfg deleted file mode 100644 index fa47efe59..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Dust -z_eff_ss_dust.c 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..7a2274a5d 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 @@ -1,30 +1,192 @@ /* * File: z_eff_ss_dust.c * Overlay: ovl_Effect_Ss_Dust - * Description: + * Description: Dust Particle Effect */ #include "z_eff_ss_dust.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] // this reg is also used to set specific colors in the fire update function +#define rScale regs[9] +#define rScaleStep regs[10] +#define rDrawFlags regs[11] +#define rLifespan regs[12] #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); +u32 EffectSsDust_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +void EffectSsDust_Update(PlayState* play, u32 index, EffectSs* this); +void EffectSsDust_UpdateFire(PlayState* play, u32 index, EffectSs* this); +void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Dust_InitVars = { EFFECT_SS_DUST, EffectSsDust_Init, }; -#endif +static EffectSsUpdateFunc sUpdateFuncs[] = { + EffectSsDust_Update, + EffectSsDust_UpdateFire, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dust/EffectSsDust_Init.s") +static TexturePtr sDustTextures[] = { + gEffDust1Tex, gEffDust2Tex, gEffDust3Tex, gEffDust4Tex, gEffDust5Tex, gEffDust6Tex, gEffDust7Tex, gEffDust8Tex, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dust/EffectSsDust_Draw.s") +u32 EffectSsDust_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsDustInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dust/func_809776BC.s") + Math_Vec3f_Copy(&this->pos, &initParams->pos); + Math_Vec3f_Copy(&this->velocity, &initParams->velocity); + Math_Vec3f_Copy(&this->accel, &initParams->accel); + this->gfx = gEffDustDL; + this->life = initParams->life; + this->update = sUpdateFuncs[initParams->updateMode]; + this->draw = EffectSsDust_Draw; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Dust/func_809777B4.s") + if (initParams->drawFlags & DUST_DRAWFLAG_RAND_COLOR_OFFSET) { + s32 randColorOffset = Rand_ZeroOne() * 20.0f - 10.0f; + + this->rPrimColorR = initParams->primColor.r + randColorOffset; + this->rPrimColorG = initParams->primColor.g + randColorOffset; + this->rPrimColorB = initParams->primColor.b + randColorOffset; + this->rEnvColorR = initParams->envColor.r + randColorOffset; + this->rEnvColorG = initParams->envColor.g + randColorOffset; + this->rEnvColorB = initParams->envColor.b + randColorOffset; + } else { + 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->rPrimColorA = initParams->primColor.a; + this->rEnvColorA = initParams->envColor.a; + this->rTexIndex = 0; + this->rScale = initParams->scale; + this->rScaleStep = initParams->scaleStep; + this->rLifespan = initParams->life; + this->rDrawFlags = initParams->drawFlags; + + return 1; +} + +void EffectSsDust_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; + MtxF mfTrans; + MtxF mfScale; + MtxF mfResult; + MtxF mfTransBillboard; + s32 pad; + Mtx* mtx; + f32 scale; + + 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); + 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); + gDPPipeSync(POLY_XLU_DISP++); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sDustTextures[this->rTexIndex])); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0); + gDPPipeSync(POLY_XLU_DISP++); + + if (this->rDrawFlags & DUST_DRAWFLAG1) { + gDPSetCombineLERP(POLY_XLU_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, 0, TEXEL0, 0, + COMBINED, 0, SHADE, 0, 0, 0, 0, COMBINED); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_FOG_SHADE_A, G_RM_ZB_CLD_SURF2); + gSPSetGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } else if (this->rDrawFlags & DUST_DRAWFLAG2) { + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); + } else { // DUST_DRAWFLAG0 + gSPClearGeometryMode(POLY_XLU_DISP++, G_LIGHTING); + } + + gDPPipeSync(POLY_XLU_DISP++); + 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 EffectSsDust_Update(PlayState* play, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + + if ((this->life <= this->rLifespan) && (this->life >= (this->rLifespan - 7))) { + if (this->rLifespan >= 5) { + this->rTexIndex = this->rLifespan - this->life; + } else { + this->rTexIndex = ((this->rLifespan - this->life) * (ARRAY_COUNT(sDustTextures) / this->rLifespan)); + } + } else { + this->rTexIndex = ARRAY_COUNT(sDustTextures) - 1; + } + + this->rScale += this->rScaleStep; +} + +// this update mode is unused in the original game +void EffectSsDust_UpdateFire(PlayState* play, u32 index, EffectSs* this) { + this->accel.x = (Rand_ZeroOne() * 0.4f) - 0.2f; + this->accel.z = (Rand_ZeroOne() * 0.4f) - 0.2f; + + switch (this->rTexIndex) { + case 0: + this->rPrimColorR = 255; + this->rPrimColorG = 150; + this->rPrimColorB = 0; + this->rEnvColorR = 150; + this->rEnvColorG = 50; + this->rEnvColorB = 0; + break; + case 1: + this->rPrimColorR = 200; + this->rPrimColorG = 50; + this->rPrimColorB = 0; + this->rEnvColorR = 100; + this->rEnvColorG = 0; + this->rEnvColorB = 0; + break; + case 2: + this->rPrimColorR = 50; + this->rPrimColorG = 0; + this->rPrimColorB = 0; + this->rEnvColorR = 0; + this->rEnvColorG = 0; + this->rEnvColorB = 0; + break; + case 3: + this->rPrimColorR = 50; + this->rEnvColorR = this->rPrimColorG = this->rEnvColorG = this->rPrimColorB = this->rEnvColorB = 0; + break; + } + + if (this->rTexIndex < (ARRAY_COUNT(sDustTextures) - 1)) { + this->rTexIndex++; + } + + this->rScale += this->rScaleStep; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h index 7e8bfbfb8..410a14352 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h +++ b/src/overlays/effects/ovl_Effect_Ss_Dust/z_eff_ss_dust.h @@ -3,6 +3,16 @@ #include "global.h" +#define DUST_DRAWFLAG0 (0) +#define DUST_DRAWFLAG1 (1 << 0) +#define DUST_DRAWFLAG2 (1 << 1) +#define DUST_DRAWFLAG_RAND_COLOR_OFFSET (1 << 2) + +typedef enum { + /* 0 */ DUST_UPDATE_NORMAL, + /* 1 */ DUST_UPDATE_FIRE +} DustUpdateMode; + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; diff --git a/src/overlays/effects/ovl_Effect_Ss_En_Fire/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_En_Fire/overlay.cfg deleted file mode 100644 index 0652dd235..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_En_Fire/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_En_Fire -z_eff_ss_en_fire.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_En_Ice/overlay.cfg deleted file mode 100644 index a761dda6e..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_En_Ice/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_En_Ice -z_eff_ss_en_ice.c 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..1108e61ce 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_Atan2S_XY(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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Extra/overlay.cfg deleted file mode 100644 index b83dab7ec..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Extra/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Extra -z_eff_ss_extra.c 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..bf21a8741 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] = VIRTUAL_TO_PHYSICAL(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] = VIRTUAL_TO_PHYSICAL(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.minigamePoints = sScores[this->rScoreIndex]; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/overlay.cfg deleted file mode 100644 index 3b701b737..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Fhg_Flash -z_eff_ss_fhg_flash.c 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..b81ccf594 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(PLAYER_BODYPART_MAX - 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/overlay.cfg deleted file mode 100644 index 233962db3..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Fire_Tail/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Fire_Tail -z_eff_ss_fire_tail.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_G_Fire/overlay.cfg deleted file mode 100644 index 0041d4fac..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_G_Fire/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_G_Fire -z_eff_ss_g_fire.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_G_Ripple/overlay.cfg deleted file mode 100644 index f5997e908..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_G_Ripple/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_G_Ripple -z_eff_ss_g_ripple.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_G_Spk/overlay.cfg deleted file mode 100644 index d49c555de..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_G_Spk/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_G_Spk -z_eff_ss_g_spk.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_G_Splash/overlay.cfg deleted file mode 100644 index 6f49625f8..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_G_Splash -z_eff_ss_g_splash.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Hahen/overlay.cfg deleted file mode 100644 index fd5cb9c8f..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Hahen/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Hahen -z_eff_ss_hahen.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Hitmark/overlay.cfg deleted file mode 100644 index 3623bfcfc..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Hitmark/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Hitmark -z_eff_ss_hitmark.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/overlay.cfg deleted file mode 100644 index 643644dd7..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Piece/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Ice_Piece -z_eff_ss_ice_piece.c 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..52561fea2 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_Atan2S_XY(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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/overlay.cfg deleted file mode 100644 index 854b90889..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Ice_Smoke/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Ice_Smoke -z_eff_ss_ice_smoke.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_K_Fire/overlay.cfg deleted file mode 100644 index 0d9080c15..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_K_Fire/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_K_Fire -z_eff_ss_k_fire.c 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Kakera/overlay.cfg deleted file mode 100644 index 4a7f62d11..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Kakera/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Kakera -z_eff_ss_kakera.c 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 a345f0b5c..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,9 +94,9 @@ 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); } } @@ -107,7 +107,7 @@ void EffectSsKakera_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Kirakira/overlay.cfg deleted file mode 100644 index 02edf776c..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Kirakira/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Kirakira -z_eff_ss_kirakira.c 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 4c7c01ca3..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 @@ -23,18 +23,18 @@ #define PARAMS ((EffectSsKirakiraInitParams*)initParamsx) -u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this); -void func_80977F28(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +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); const EffectSsInit Effect_Ss_Kirakira_InitVars = { EFFECT_SS_KIRAKIRA, EffectSsKirakira_Init, }; -u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsKirakira_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsKirakiraInitParams* initParams = PARAMS; this->pos = initParams->pos; @@ -80,7 +80,7 @@ u32 EffectSsKirakira_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, v return 1; } -void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsKirakira_Draw(PlayState* play, u32 index, EffectSs* this) { GraphicsContext* gfxCtx; f32 scale = this->rScale / 10000.0f; s32 pad; @@ -92,14 +92,14 @@ void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) MtxF mfResult; Mtx* mtx; - gfxCtx = globalCtx->state.gfxCtx; + 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, &globalCtx->billboardMtxF, &mfTransBillboard); + 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); @@ -120,7 +120,7 @@ void EffectSsKirakira_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) CLOSE_DISPS(gfxCtx); } -void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this) { +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; @@ -136,7 +136,7 @@ void func_80977DB4(GlobalContext* globalCtx, u32 index, EffectSs* this) { this->rYaw += this->rRotSpeed; } -void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this) { +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); @@ -154,6 +154,6 @@ void func_80977E6C(GlobalContext* globalCtx, u32 index, EffectSs* this) { this->rYaw += this->rRotSpeed; } -void func_80977F28(GlobalContext* globalCtx, u32 index, EffectSs* this) { +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_Lightning/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Lightning/overlay.cfg deleted file mode 100644 index b698e915f..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Lightning/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Lightning -z_eff_ss_lightning.c 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 15fdcfc50..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 @@ -22,9 +22,9 @@ #define PARAMS ((EffectSsLightningInitParams*)initParamsx) -u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +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, @@ -38,7 +38,7 @@ const EffectSsInit Effect_Ss_Lightning_InitVars = { static s32 sIsDesegmented = false; -u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsLightning_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsLightningInitParams* initParams = PARAMS; s32 i; @@ -70,7 +70,7 @@ u32 EffectSsLightning_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, return 1; } -void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s32 yaw, EffectSs* this) { +void EffectSsLightning_NewLightning(PlayState* play, Vec3f* pos, s32 yaw, EffectSs* this) { EffectSs newLightning; EffectSS_Delete(&newLightning); @@ -80,11 +80,11 @@ void EffectSsLightning_NewLightning(GlobalContext* globalCtx, Vec3f* pos, s32 ya newLightning.rYaw = yaw; newLightning.life = newLightning.rLifespan; - EffectSS_Copy(globalCtx, &newLightning); + EffectSS_Copy(play, &newLightning); } -void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSsLightning_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; MtxF mfResult; MtxF mfTrans; MtxF mfScale; @@ -109,7 +109,7 @@ void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) xzScale = yScale * 0.6f; SkinMatrix_SetScale(&mfScale, xzScale, yScale, xzScale); SkinMatrix_SetRotateRPY(&mfRot, this->vec.x, this->vec.y, this->rYaw); - SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTransBillboard); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard); SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfRot, &mfTransBillboardRot); SkinMatrix_MtxFMtxFMult(&mfTransBillboardRot, &mfScale, &mfResult); @@ -130,7 +130,7 @@ void EffectSsLightning_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) CLOSE_DISPS(gfxCtx); } -void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsLightning_Update(PlayState* play, u32 index, EffectSs* this) { s32 pad; Vec3f pos; s32 yaw; @@ -145,13 +145,13 @@ void EffectSsLightning_Update(GlobalContext* globalCtx, u32 index, EffectSs* thi pos.y = this->pos.y + (Math_SinS(this->rYaw - 0x4000) * scale); scale = Math_CosS(this->rYaw - 0x4000) * scale; - pos.x = this->pos.x - (Math_CosS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); - pos.z = this->pos.z + (Math_SinS(Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx))) * scale); + 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(globalCtx, &pos, yaw, this); + EffectSsLightning_NewLightning(play, &pos, yaw, this); if (Rand_ZeroOne() < 0.1f) { - EffectSsLightning_NewLightning(globalCtx, &pos, (this->rYaw * 2) - yaw, this); + EffectSsLightning_NewLightning(play, &pos, (this->rYaw * 2) - yaw, this); } } } diff --git a/src/overlays/effects/ovl_Effect_Ss_Sbn/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Sbn/overlay.cfg deleted file mode 100644 index c958b3df5..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Sbn/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Sbn -z_eff_ss_sbn.c 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 2e8646a54..c5c058cc3 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 @@ -22,10 +22,10 @@ #define PARAMS ((EffectSsSbnInitParams*)initParamsx) -u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsSbn_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsSbn_Draw(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); const EffectSsInit Effect_Ss_Sbn_InitVars = { EFFECT_SS_SBN, @@ -44,7 +44,7 @@ static TexturePtr sTextures[] = { gEffPoppedDekuBubble4Tex, gEffPoppedDekuBubble5Tex, }; -u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsSbn_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsSbnInitParams* initParams = PARAMS; CollisionPoly* colPoly; MtxF mtx; @@ -111,17 +111,17 @@ u32 EffectSsSbn_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* 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); + this->rRotAngle = Math_Atan2S_XY(angle, opposite); } else { - this->rRotAngle = -Math_FAtan2F(angle, opposite); + this->rRotAngle = -Math_Atan2S_XY(angle, opposite); } } return 1; } -void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSsSbn_DrawSliding(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; MtxF mtx; f32 scale = this->rScale * 0.001f; s32 pad; @@ -149,20 +149,20 @@ void EffectSsSbn_DrawSliding(GlobalContext* globalCtx, u32 index, EffectSs* this this->rScroll += this->rScrollStep; } else { gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gEffPoppedDekuBubbleSliding12Tex)); - if ((this->rScrollStep >= 2) && ((globalCtx->state.frames % 2) == 0)) { + if ((this->rScrollStep >= 2) && ((play->state.frames % 2) == 0)) { this->rScrollStep--; } this->rScroll += this->rScrollStep; } gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 0x20, 0x40, 1, 0, this->rScroll, 0x20, 0x20)); + 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(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSsSbn_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; MtxF mtx; f32 scale = this->rScale * 0.001f; @@ -194,7 +194,7 @@ void EffectSsSbn_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -void EffectSsSbn_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsSbn_Update(PlayState* play, u32 index, EffectSs* this) { if (this->life < 10) { this->rAlpha -= 20; } else if (this->life >= 45) { diff --git a/src/overlays/effects/ovl_Effect_Ss_Sibuki/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Sibuki/overlay.cfg deleted file mode 100644 index 66dfae07c..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Sibuki/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Sibuki -z_eff_ss_sibuki.c 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 5d30ecf04..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,8 +61,8 @@ 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); @@ -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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/overlay.cfg deleted file mode 100644 index 82cde4368..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Solder_Srch_Ball -z_eff_ss_solder_srch_ball.c 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..01224dd32 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 @@ -1,27 +1,93 @@ /* * File: z_eff_ss_solder_srch_ball.c * Overlay: ovl_Effect_Ss_Solder_Srch_Ball - * Description: + * Description: Vision sphere */ #include "z_eff_ss_solder_srch_ball.h" +#include "objects/gameplay_keep/gameplay_keep.h" + +#define rFlags regs[0] #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); +u32 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 = { EFFECT_SS_SOLDER_SRCH_BALL, EffectSsSolderSrchBall_Init, }; -#endif +u32 EffectSsSolderSrchBall_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + EffectSsSolderSrchBallInitParams* initParams = PARAMS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Init.s") + this->pos = initParams->pos; + this->velocity = initParams->velocity; + this->accel = initParams->accel; + this->update = EffectSsSolderSrchBall_Update; + if (!(initParams->flags & SOLDERSRCHBALL_INVISIBLE)) { + this->draw = EffectSsSolderSrchBall_Draw; + } + this->life = 10; + this->rgScale = initParams->scale; + this->rFlags = initParams->flags; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Draw.s") + //! @bug actor field used to store an s16* + // This bug is purely cosmetic. Nothing external will ever read this as an Actor, so there are no unintended + // side-effects. + this->actor = (Actor*)initParams->playerDetected; + return 1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Solder_Srch_Ball/EffectSsSolderSrchBall_Update.s") +void EffectSsSolderSrchBall_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = play->state.gfxCtx; + f32 scale = this->rgScale / 100.0f; + + func_8012C28C(gfxCtx); + func_8012C2DC(play->state.gfxCtx); + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(gSun1Tex)); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleMaterialDL); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, 255); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_RotateZF(DEGF_TO_RADF(20.0f * play->state.frames), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, gSunSparkleModelDL); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsSolderSrchBall_Update(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + f32 diffX; + f32 diffY; + f32 diffZ; + s16* playerDetected = (s16*)this->actor; + Player* player = GET_PLAYER(play); + + diffX = player->actor.world.pos.x - this->pos.x; + diffY = player->actor.world.pos.y - this->pos.y; + diffZ = player->actor.world.pos.z - this->pos.z; + + if (this->rFlags >= SOLDERSRCHBALL_SMALL_DETECT_RADIUS) { + if ((sqrtf(SQ(diffX) + SQ(diffZ)) < 10.0f) && (sqrtf(SQ(diffY)) < 10.0f)) { + *playerDetected = true; + } + } else if (!BgCheck_SphVsFirstWall(&play->colCtx, &this->pos, 30.0f)) { + if ((sqrtf(SQ(diffX) + SQ(diffZ)) < 40.0f) && (sqrtf(SQ(diffY)) < 80.0f)) { + *playerDetected = true; + } + } else if (this->life > 1) { + this->life = 1; + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h index 24b9f47fc..fb4fb4159 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h +++ b/src/overlays/effects/ovl_Effect_Ss_Solder_Srch_Ball/z_eff_ss_solder_srch_ball.h @@ -3,13 +3,16 @@ #include "global.h" +#define SOLDERSRCHBALL_INVISIBLE (1 << 0) +#define SOLDERSRCHBALL_SMALL_DETECT_RADIUS (1 << 1) + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; - /* 0x24 */ s16 unused; - /* 0x28 */ s16* linkDetected; - /* 0x2C */ s16 drawFlag; + /* 0x24 */ s16 scale; + /* 0x28 */ s16* playerDetected; + /* 0x2C */ s16 flags; } EffectSsSolderSrchBallInitParams; // size = 0x30 extern const EffectSsInit Effect_Ss_Solder_Srch_Ball_InitVars; diff --git a/src/overlays/effects/ovl_Effect_Ss_Stick/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Stick/overlay.cfg deleted file mode 100644 index 5f691232a..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Stick/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Stick -z_eff_ss_stick.c 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 adca90668..1c6d53e7f 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,9 +40,9 @@ 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); @@ -51,12 +51,12 @@ void EffectSsStick_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { 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++, 0x0C, D_801C0850); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[this->rObjBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x0C, gCullBackDList); 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/overlay.cfg b/src/overlays/effects/ovl_Effect_Ss_Stone1/overlay.cfg deleted file mode 100644 index a6706c014..000000000 --- a/src/overlays/effects/ovl_Effect_Ss_Stone1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_Effect_Ss_Stone1 -z_eff_ss_stone1.c 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 abcd52393..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 @@ -11,9 +11,9 @@ #define rReg0 regs[0] -u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx); -void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this); -void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this); +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); const EffectSsInit Effect_Ss_Stone1_InitVars = { EFFECT_SS_STONE1, @@ -37,7 +37,7 @@ static EffStoneDrawInfo sDrawInfo[] = { { gEffStone1Tex, { 255, 255, 255, 255 }, { 0, 255, 255, 255 } }, }; -u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, void* initParamsx) { +u32 EffectSsStone1_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { EffectSsStone1InitParams* initParams = PARAMS; Vec3f pos = initParams->pos; @@ -51,8 +51,8 @@ u32 EffectSsStone1_Init(GlobalContext* globalCtx, u32 index, EffectSs* this, voi return 1; } -void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSsStone1_Draw(PlayState* play, u32 index, EffectSs* this) { + GraphicsContext* gfxCtx = play->state.gfxCtx; EffStoneDrawInfo* drawParams = &sDrawInfo[this->life]; Vec3f mfVec; f32 mfW; @@ -60,7 +60,7 @@ void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { OPEN_DISPS(gfxCtx); - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &this->pos, &mfVec, &mfW); + 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); @@ -75,7 +75,7 @@ void EffectSsStone1_Draw(GlobalContext* globalCtx, u32 index, EffectSs* this) { CLOSE_DISPS(gfxCtx); } -void EffectSsStone1_Update(GlobalContext* globalCtx, u32 index, EffectSs* this) { +void EffectSsStone1_Update(PlayState* play, u32 index, EffectSs* this) { if ((this->life == 6) && (this->rReg0 != 0)) { iREG(50) = 0; } diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/overlay.cfg b/src/overlays/fbdemos/ovl_fbdemo_triforce/overlay.cfg deleted file mode 100644 index d5f678c11..000000000 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_fbdemo_triforce -z_fbdemo_triforce.c diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c index 268f8e1a6..00e7cfabd 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.c @@ -5,6 +5,7 @@ */ #include "z_fbdemo_triforce.h" +#include "assets/objects/object_fbdemo_triforce/ovl_fbdemo_triforce.c" void* TransitionTriforce_Init(void* thisx); void TransitionTriforce_Destroy(void* thisx); @@ -15,35 +16,132 @@ void TransitionTriforce_SetType(void* thisx, s32 type); void TransitionTriforce_SetColor(void* thisx, u32 color); s32 TransitionTriforce_IsDone(void* thisx); -#if 0 -const TransitionInit TransitionTriforce_InitVars = { - TransitionTriforce_Init, - TransitionTriforce_Destroy, - TransitionTriforce_Update, - TransitionTriforce_Draw, - TransitionTriforce_Start, - TransitionTriforce_SetType, - TransitionTriforce_SetColor, - NULL, +TransitionInit TransitionTriforce_InitVars = { + TransitionTriforce_Init, TransitionTriforce_Destroy, TransitionTriforce_Update, TransitionTriforce_Draw, + TransitionTriforce_Start, TransitionTriforce_SetType, TransitionTriforce_SetColor, NULL, TransitionTriforce_IsDone, }; -#endif +void TransitionTriforce_Start(void* thisx) { + TransitionTriforce* this = (TransitionTriforce*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Start.s") + switch (this->state) { + case STATE_SPIRAL_IN_SLOW: + case STATE_SPIRAL_IN_FAST: + this->transPos = 1.0f; + return; + } + this->transPos = 0.03f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Init.s") +void* TransitionTriforce_Init(void* thisx) { + TransitionTriforce* this = (TransitionTriforce*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Destroy.s") + bzero(this, sizeof(TransitionTriforce)); + guOrtho(&this->projection, -SCREEN_WIDTH / 2, SCREEN_WIDTH / 2, -SCREEN_HEIGHT / 2, SCREEN_HEIGHT / 2, -1000.0f, + 1000.0f, 1.0f); + this->transPos = 1.0f; + this->state = STATE_SPIRAL_IN_FAST; + this->step = 0.015f; + this->fadeType = TYPE_TRANSPARENT_TRIFORCE; + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Update.s") +void TransitionTriforce_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_SetColor.s") +void TransitionTriforce_Update(void* thisx, s32 updateRate) { + TransitionTriforce* this = (TransitionTriforce*)thisx; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_SetType.s") + for (i = updateRate; i > 0; i--) { + if (this->state == STATE_SPIRAL_IN_SLOW) { + this->transPos = CLAMP_MIN(this->transPos * (1.0f - this->step), 0.03f); + } else if (this->state == STATE_SPIRAL_IN_FAST) { + this->transPos = CLAMP_MIN(this->transPos - this->step, 0.03f); + } else if (this->state == STATE_SPIRAL_OUT_SLOW) { + this->transPos = CLAMP_MAX(this->transPos / (1.0f - this->step), 1.0f); + } else if (this->state == STATE_SPIRAL_OUT_FAST) { + this->transPos = CLAMP_MAX(this->transPos + this->step, 1.0f); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/func_80AC5280.s") +void TransitionTriforce_SetColor(void* thisx, u32 color) { + TransitionTriforce* this = (TransitionTriforce*)thisx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_Draw.s") + this->color.rgba = color; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_triforce/TransitionTriforce_IsDone.s") +void TransitionTriforce_SetType(void* thisx, s32 type) { + TransitionTriforce* this = (TransitionTriforce*)thisx; + + this->fadeType = type; +} + +void TransitionTriforce_SetState(void* thisx, s32 state) { + TransitionTriforce* this = (TransitionTriforce*)thisx; + + this->state = state; +} + +void TransitionTriforce_Draw(void* thisx, Gfx** gfxP) { + Gfx* gfx = *gfxP; + Mtx* modelView; + s32 pad[2]; + TransitionTriforce* this = (TransitionTriforce*)thisx; + f32 rotation = this->transPos * 360.0f; + + modelView = this->modelView[this->frame]; + this->frame ^= 1; + guScale(&modelView[0], this->transPos * 0.625f, this->transPos * 0.625f, 1.0f); + guRotate(&modelView[1], rotation, 0.0f, 0.0f, 1.0f); + guTranslate(&modelView[2], 0.0f, 0.0f, 0.0f); + gDPPipeSync(gfx++); + gSPDisplayList(gfx++, sTriforceWipeDL); + gDPSetColor(gfx++, G_SETPRIMCOLOR, this->color.rgba); + gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gSPMatrix(gfx++, &this->projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gfx++, &modelView[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, &modelView[1], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPMatrix(gfx++, &modelView[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPVertex(gfx++, &sTriforceWipeVtx, ARRAY_COUNT(sTriforceWipeVtx), 0); + if (!TransitionTriforce_IsDone(this)) { + switch (this->fadeType) { + case TYPE_TRANSPARENT_TRIFORCE: + gSP2Triangles(gfx++, 0, 4, 5, 0, 4, 1, 3, 0); + gSP1Triangle(gfx++, 5, 3, 2, 0); + break; + + case TYPE_FILLED_TRIFORCE: + gSP2Triangles(gfx++, 3, 4, 5, 0, 0, 2, 6, 0); + gSP2Triangles(gfx++, 0, 6, 7, 0, 1, 0, 7, 0); + gSP2Triangles(gfx++, 1, 7, 8, 0, 1, 8, 9, 0); + gSP2Triangles(gfx++, 1, 9, 2, 0, 2, 9, 6, 0); + break; + } + + } else { + switch (this->fadeType) { + case TYPE_TRANSPARENT_TRIFORCE: + break; + + case TYPE_FILLED_TRIFORCE: + gSP1Quadrangle(gfx++, 6, 7, 8, 9, 0); + break; + } + } + gDPPipeSync(gfx++); + *gfxP = gfx; +} + +s32 TransitionTriforce_IsDone(void* thisx) { + TransitionTriforce* this = (TransitionTriforce*)thisx; + + if ((this->state == STATE_SPIRAL_IN_SLOW) || (this->state == STATE_SPIRAL_IN_FAST)) { + return this->transPos <= 0.03f; + } else if ((this->state == STATE_SPIRAL_OUT_SLOW) || (this->state == STATE_SPIRAL_OUT_FAST)) { + return (this->transPos >= 1.0f); + } + return false; +} diff --git a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h index 7d7dcae56..06d807a08 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h +++ b/src/overlays/fbdemos/ovl_fbdemo_triforce/z_fbdemo_triforce.h @@ -3,10 +3,29 @@ #include "global.h" +typedef enum { + /* 0 */ STATE_NONE, + /* 1 */ STATE_SPIRAL_IN_SLOW, + /* 2 */ STATE_SPIRAL_IN_FAST, + /* 3 */ STATE_SPIRAL_OUT_SLOW, + /* 4 */ STATE_SPIRAL_OUT_FAST +} FbTriforceState; + +typedef enum { + /* 0 */ TYPE_NONE, + /* 1 */ TYPE_TRANSPARENT_TRIFORCE, + /* 2 */ TYPE_FILLED_TRIFORCE +} TriforceFadeType; + typedef struct { - /* 0x0000 */ char unk_0[0x1E0]; + /* 0x000 */ Color_RGBA8_u32 color; + /* 0x004 */ f32 transPos; + /* 0x008 */ f32 step; + /* 0x00C */ s32 state; + /* 0x010 */ s32 fadeType; + /* 0x018 */ Mtx projection; + /* 0x058 */ s32 frame; + /* 0x060 */ Mtx modelView[2][3]; } TransitionTriforce; // size = 0x1E0 -extern const TransitionInit TransitionTriforce_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/overlay.cfg b/src/overlays/fbdemos/ovl_fbdemo_wipe1/overlay.cfg deleted file mode 100644 index 5b3efc6ad..000000000 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_fbdemo_wipe1 -z_fbdemo_wipe1.c diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c index 560d341f2..ed12d400e 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.c @@ -17,7 +17,7 @@ void TransitionWipe1_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe1_IsDone(void* thisx); #if 0 -const TransitionInit TransitionWipe1_InitVars = { +TransitionInit TransitionWipe1_InitVars = { TransitionWipe1_Init, TransitionWipe1_Destroy, TransitionWipe1_Update, diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h index fe70e724b..971940bb2 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe1/z_fbdemo_wipe1.h @@ -7,6 +7,4 @@ typedef struct { /* 0x0000 */ char unk_0[0x218]; } TransitionWipe1; // size = 0x218 -extern const TransitionInit TransitionWipe1_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe3/overlay.cfg b/src/overlays/fbdemos/ovl_fbdemo_wipe3/overlay.cfg deleted file mode 100644 index 73258114b..000000000 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe3/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_fbdemo_wipe3 -z_fbdemo_wipe3.c diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c index bbd488642..c33f3c8c7 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.c @@ -17,7 +17,7 @@ void TransitionWipe3_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe3_IsDone(void* thisx); #if 0 -const TransitionInit TransitionWipe3_InitVars = { +TransitionInit TransitionWipe3_InitVars = { TransitionWipe3_Init, TransitionWipe3_Destroy, TransitionWipe3_Update, diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h index f74f86a61..8fed0dcfe 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe3/z_fbdemo_wipe3.h @@ -7,6 +7,4 @@ typedef struct { /* 0x0000 */ char unk_0[0x120]; } TransitionWipe3; // size = 0x120 -extern const TransitionInit TransitionWipe3_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe4/overlay.cfg b/src/overlays/fbdemos/ovl_fbdemo_wipe4/overlay.cfg deleted file mode 100644 index e18ed9858..000000000 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe4/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_fbdemo_wipe4 -z_fbdemo_wipe4.c diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c index 49dd027c8..e91d8ab5e 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.c @@ -17,7 +17,7 @@ void TransitionWipe4_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe4_IsDone(void* thisx); #if 0 -const TransitionInit TransitionWipe4_InitVars = { +TransitionInit TransitionWipe4_InitVars = { TransitionWipe4_Init, TransitionWipe4_Destroy, TransitionWipe4_Update, diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h index 60296230e..8a677c2a4 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe4/z_fbdemo_wipe4.h @@ -7,6 +7,4 @@ typedef struct { /* 0x0000 */ char unk_0[0x28]; } TransitionWipe4; // size = 0x28 -extern const TransitionInit TransitionWipe4_InitVars; - #endif diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/overlay.cfg b/src/overlays/fbdemos/ovl_fbdemo_wipe5/overlay.cfg deleted file mode 100644 index 297aa770c..000000000 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_fbdemo_wipe5 -z_fbdemo_wipe5.c 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..a4b0cfa74 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c @@ -6,6 +6,8 @@ #include "z_fbdemo_wipe5.h" +#define THIS ((TransitionWipe5*)thisx) + void* TransitionWipe5_Init(void* thisx); void TransitionWipe5_Destroy(void* thisx); void TransitionWipe5_Update(void* thisx, s32 updateRate); @@ -16,37 +18,129 @@ void TransitionWipe5_SetColor(void* thisx, u32 color); void TransitionWipe5_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe5_IsDone(void* thisx); -#if 0 -const TransitionInit TransitionWipe5_InitVars = { - TransitionWipe5_Init, - TransitionWipe5_Destroy, - TransitionWipe5_Update, - TransitionWipe5_Draw, - TransitionWipe5_Start, - TransitionWipe5_SetType, - TransitionWipe5_SetColor, - TransitionWipe5_SetEnvColor, - TransitionWipe5_IsDone, +TransitionInit TransitionWipe5_InitVars = { + TransitionWipe5_Init, TransitionWipe5_Destroy, TransitionWipe5_Update, + TransitionWipe5_Draw, TransitionWipe5_Start, TransitionWipe5_SetType, + TransitionWipe5_SetColor, TransitionWipe5_SetEnvColor, TransitionWipe5_IsDone, }; -#endif +void TransitionWipe5_Start(void* thisx) { + TransitionWipe5* this = THIS; -extern UNK_TYPE D_0F000000; + this->isDone = false; + switch (this->unk_12) { + case 0: + this->unk_08 = 0.02f; + break; + case 1: + this->unk_08 = 0.05f; + break; + default: + this->unk_08 = 0.2f; + break; + } + switch (this->unk_11) { + case 0: + this->primColor.rgba = RGBA8(0, 0, 0, 255); + break; + case 1: + this->primColor.rgba = RGBA8(160, 160, 160, 255); + break; + default: + this->primColor.rgba = RGBA8(160, 160, 160, 255); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Start.s") +void* TransitionWipe5_Init(void* thisx) { + TransitionWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Init.s") + bzero(this, sizeof(TransitionWipe5)); + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Destroy.s") +void TransitionWipe5_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Update.s") +void TransitionWipe5_Update(void* thisx, s32 updateRate) { + TransitionWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Draw.s") + if (this->unk_10 == 0) { + this->isDone = true; + } else { + this->unk_0C += (this->unk_08 * 3.0f) / updateRate; + if (this->unk_0C >= 1.0f) { + this->unk_0C = 1.0f; + this->isDone = true; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_IsDone.s") +void TransitionWipe5_Draw(void* thisx, Gfx** gfxP) { + Gfx* gfx = *gfxP; + s32 width = gScreenWidth; + s32 height = gScreenHeight; + void* sp50 = D_801FBB90; + TransitionWipe5* this = THIS; + s32 alpha = (1.0f - this->unk_0C) * 255.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_SetType.s") + gDPPipeSync(gfx++); + gSPLoadUcodeL(gfx++, gspS2DEX2_fifo); + if (this->unk_10 == 0) { + gDPSetOtherMode(gfx++, + G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); + func_8014116C(&gfx, D_0F000000, sp50, width, height, 1); + } else { + if (alpha == 255) { + gDPSetOtherMode(gfx++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | G_RM_OPA_SURF | G_RM_OPA_SURF2); + } else { + gDPSetOtherMode(gfx++, + G_AD_NOISE | G_CD_NOISE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); + } + gDPSetEnvColor(gfx++, 255, 255, 255, alpha); + gDPSetCombineLERP(gfx++, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, + ENVIRONMENT); + func_8014116C(&gfx, sp50, D_0F000000, width, height, 0); + } + gDPPipeSync(gfx++); + gSPLoadUcode(gfx++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); + *gfxP = gfx; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_SetColor.s") +s32 TransitionWipe5_IsDone(void* thisx) { + TransitionWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_SetEnvColor.s") + return this->isDone; +} + +void TransitionWipe5_SetType(void* thisx, s32 type) { + TransitionWipe5* this = THIS; + + if (type & 0x80) { + this->unk_11 = 0; + this->unk_12 = type & 1; + } else if (type == 1) { + this->unk_10 = 1; + } else { + this->unk_10 = 0; + } +} + +void TransitionWipe5_SetColor(void* thisx, u32 color) { + TransitionWipe5* this = THIS; + + this->primColor.rgba = color; +} + +void TransitionWipe5_SetEnvColor(void* thisx, u32 color) { + TransitionWipe5* this = THIS; + + this->envColor.rgba = color; +} diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h index d8ffe0616..d5cd9137d 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h @@ -4,9 +4,14 @@ #include "global.h" typedef struct { - /* 0x0000 */ char unk_0[0x14]; + /* 0x00 */ Color_RGBA8_u32 primColor; + /* 0x04 */ Color_RGBA8_u32 envColor; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ u8 unk_10; + /* 0x11 */ u8 unk_11; + /* 0x12 */ u8 unk_12; + /* 0x13 */ u8 isDone; } TransitionWipe5; // size = 0x14 -extern const TransitionInit TransitionWipe5_InitVars; - #endif diff --git a/src/overlays/gamestates/ovl_daytelop/overlay.cfg b/src/overlays/gamestates/ovl_daytelop/overlay.cfg deleted file mode 100644 index 3766a9b41..000000000 --- a/src/overlays/gamestates/ovl_daytelop/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_daytelop -z_daytelop.c diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c index df16aae5b..201030862 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.c +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.c @@ -5,6 +5,8 @@ */ #include "z_daytelop.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "misc/daytelop_static/daytelop_static.h" #include "interface/icon_item_gameover_static/icon_item_gameover_static.h" @@ -63,7 +65,7 @@ UNK_TYPE D_808158E0[] = { 0x00000001, 0x00000000, }; -void Daytelop_Update(DaytelopContext* this, GameState* gameState) { +void DayTelop_Update(DayTelopState* this, GameState* thisx) { static u8 D_80815FF0 = 0; s16 new_var; u8 temp_v0_2; @@ -77,12 +79,9 @@ void Daytelop_Update(DaytelopContext* this, GameState* gameState) { gSaveContext.save.day = 1; } - { - GameState* state = &this->state; - state->running = 0; - } + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); - SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); gSaveContext.save.time = CLOCK_TIME(6, 0); D_801BDBC8 = 0xFE; } else if (this->transitionCountdown == 90) { @@ -126,7 +125,7 @@ TexturePtr sHoursLeftTextures[] = { gDaytelop24HoursNESTex, }; -void Daytelop_Draw(DaytelopContext* this) { +void DayTelop_Draw(DayTelopState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; OPEN_DISPS(gfxCtx); @@ -187,11 +186,11 @@ void Daytelop_Draw(DaytelopContext* this) { 0x0400, 0x0400); } - CLOSE_DISPS(this->state.gfxCtx); + CLOSE_DISPS(gfxCtx); } -void Daytelop_Main(GameState* thisx) { - DaytelopContext* this = (DaytelopContext*)thisx; +void DayTelop_Main(GameState* thisx) { + DayTelopState* this = (DayTelopState*)thisx; func_8012CF0C(this->state.gfxCtx, true, true, 0, 0, 0); @@ -200,18 +199,18 @@ void Daytelop_Main(GameState* thisx) { gSPSegment(POLY_OPA_DISP++, 0x0C, this->gameoverStaticFile); CLOSE_DISPS(this->state.gfxCtx); - Daytelop_Draw(this); - Daytelop_Update(this, &this->state); + DayTelop_Draw(this); + DayTelop_Update(this, &this->state); } -void Daytelop_Destroy(GameState* thisx) { +void DayTelop_Destroy(GameState* thisx) { ShrinkWindow_Destroy(); } -void Daytelop_nop80815770(DaytelopContext* this) { +void DayTelop_Noop(DayTelopState* this) { } -void Daytelop_LoadGraphics(DaytelopContext* this) { +void DayTelop_LoadGraphics(DayTelopState* this) { size_t segmentSize = SEGMENT_ROM_SIZE(daytelop_static); this->daytelopStaticFile = THA_AllocEndAlign16(&this->state.heap, segmentSize); @@ -222,15 +221,15 @@ void Daytelop_LoadGraphics(DaytelopContext* this) { DmaMgr_SendRequest0(this->gameoverStaticFile, SEGMENT_ROM_START(icon_item_gameover_static), segmentSize); } -void Daytelop_Init(GameState* thisx) { - DaytelopContext* this = (DaytelopContext*)thisx; +void DayTelop_Init(GameState* thisx) { + DayTelopState* this = (DayTelopState*)thisx; - Game_SetFramerateDivisor(thisx, 1); - Matrix_Init(thisx); + Game_SetFramerateDivisor(&this->state, 1); + Matrix_Init(&this->state); ShrinkWindow_Destroy(); - View_Init(&this->view, thisx->gfxCtx); - thisx->main = Daytelop_Main; - thisx->destroy = Daytelop_Destroy; + View_Init(&this->view, this->state.gfxCtx); + this->state.main = DayTelop_Main; + this->state.destroy = DayTelop_Destroy; this->transitionCountdown = 140; this->fadeInState = DAYTELOP_HOURSTEXT_OFF; @@ -241,7 +240,7 @@ void Daytelop_Init(GameState* thisx) { Sram_IncrementDay(); } - Daytelop_nop80815770(this); - Daytelop_LoadGraphics(this); + DayTelop_Noop(this); + DayTelop_LoadGraphics(this); play_sound(NA_SE_OC_TELOP_IMPACT); } diff --git a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h index d77a5f334..a7350e898 100644 --- a/src/overlays/gamestates/ovl_daytelop/z_daytelop.h +++ b/src/overlays/gamestates/ovl_daytelop/z_daytelop.h @@ -3,8 +3,8 @@ #include "global.h" -void Daytelop_Init(GameState* thisx); -void Daytelop_Destroy(GameState* thisx); +void DayTelop_Init(GameState* thisx); +void DayTelop_Destroy(GameState* thisx); typedef struct { /* 0x000 */ GameState state; @@ -16,12 +16,12 @@ typedef struct { /* 0x240 */ s16 transitionCountdown; /* 0x242 */ s16 fadeInState; /* 0x244 */ s16 alpha; -} DaytelopContext; // size = 0x248 +} DayTelopState; // size = 0x248 typedef enum { /* 0 */ DAYTELOP_HOURSTEXT_OFF, /* 1 */ DAYTELOP_HOURSTEXT_FADEIN, /* 2 */ DAYTELOP_HOURSTEXT_ON -} Daytelop_FadeState; +} DaytelopFadeState; #endif diff --git a/src/overlays/gamestates/ovl_file_choose/overlay.cfg b/src/overlays/gamestates/ovl_file_choose/overlay.cfg deleted file mode 100644 index b18724161..000000000 --- a/src/overlays/gamestates/ovl_file_choose/overlay.cfg +++ /dev/null @@ -1,4 +0,0 @@ -ovl_file_choose -z_file_nameset_NES.c -z_file_choose_80807940.c -z_file_choose_NES.c 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..f3231ec56 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.h +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.h @@ -3,10 +3,10 @@ #include "global.h" -void FileChoose_Init(GameState* thisx); -void FileChoose_Destroy(GameState* thisx); +void FileSelect_Init(GameState* thisx); +void FileSelect_Destroy(GameState* thisx); -typedef struct FileChooseContext { +typedef struct FileSelectState { /* 0x00000 */ GameState state; /* 0x000A4 */ Vtx* unk_A4; /* 0x000A8 */ u8* staticSegment; @@ -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; @@ -111,15 +110,6 @@ typedef struct FileChooseContext { /* 0x2454C */ s16 unk_2454C; /* 0x2454E */ s16 unk_2454E; /* 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; +} FileSelectState; // size = 0x24558 #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..da9144e7c 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,9 @@ */ #include "z_file_choose.h" +#include "z64rumble.h" +#include "z64shrink_window.h" +#include "z64view.h" extern UNK_TYPE D_01002800; extern UNK_TYPE D_01007980; @@ -18,15 +21,15 @@ extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BC20.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_nop8080bc44.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_nop8080bc44.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_nop8080BC4C.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_nop8080BC4C.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BC58.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BDAC.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_RenderView.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_RenderView.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_8080BE60.s") @@ -84,13 +87,13 @@ extern GfxMasterList D_0E000000; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_80812ED0.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_UpdateAndDrawSkybox.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_UpdateAndDrawSkybox.s") -void FileChoose_Main(GameState* thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_Main.s") +void FileSelect_Main(GameState* thisx); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_Main.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/func_80813908.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_Destroy.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_Destroy.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileChoose_Init.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_file_choose/FileSelect_Init.s") 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/overlay.cfg b/src/overlays/gamestates/ovl_opening/overlay.cfg deleted file mode 100644 index 6366c3afd..000000000 --- a/src/overlays/gamestates/ovl_opening/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_opening -z_opening.c diff --git a/src/overlays/gamestates/ovl_opening/z_opening.c b/src/overlays/gamestates/ovl_opening/z_opening.c index c705cb708..c56cc4bbb 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.c +++ b/src/overlays/gamestates/ovl_opening/z_opening.c @@ -5,60 +5,60 @@ */ #include "z_opening.h" +#include "z64shrink_window.h" +#include "z64view.h" -void Opening_SetupForTitleCutscene(OpeningContext* this) { - static s32 openingEntrances[] = { 0x1C00, 0x1C10 }; - static s32 openingCutscenes[] = { 0xFFFA, 0xFFFA }; +void TitleSetup_SetupTitleScreen(TitleSetupState* this) { + static s32 sOpeningEntrances[] = { ENTRANCE(CUTSCENE, 0), ENTRANCE(CUTSCENE, 1) }; + static s32 sOpeningCutscenes[] = { 0xFFFA, 0xFFFA }; - gSaveContext.eventInf[1] &= (u8)~0x80; + CLEAR_EVENTINF(EVENTINF_17); gSaveContext.gameMode = 1; Sram_InitNewSave(); - gSaveContext.save.entranceIndex = openingEntrances[D_801BB12C]; - gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = openingCutscenes[D_801BB12C]; - gSaveContext.sceneSetupIndex = 0; + gSaveContext.save.entrance = sOpeningEntrances[D_801BB12C]; + gSaveContext.nextCutsceneIndex = gSaveContext.save.cutscene = sOpeningCutscenes[D_801BB12C]; + gSaveContext.sceneLayer = 0; gSaveContext.save.time = CLOCK_TIME(8, 0); gSaveContext.save.day = 1; - { - GameState* thisx = &this->gameState; - thisx->running = false; - } - SET_NEXT_GAMESTATE(&this->gameState, Play_Init, GlobalContext); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(PlayState)); + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; } -void func_80803EA0(OpeningContext* this) { +void func_80803EA0(TitleSetupState* this) { SREG(33) |= 1; } -void Opening_Main(GameState* thisx) { - OpeningContext* this = (OpeningContext*)thisx; +void TitleSetup_Main(GameState* thisx) { + TitleSetupState* this = (TitleSetupState*)thisx; - func_8012CF0C(this->gameState.gfxCtx, false, true, 0, 0, 0); - Opening_SetupForTitleCutscene(this); + func_8012CF0C(this->state.gfxCtx, false, true, 0, 0, 0); + TitleSetup_SetupTitleScreen(this); func_80803EA0(this); } -void Opening_Destroy(GameState* thisx) { +void TitleSetup_Destroy(GameState* thisx) { ShrinkWindow_Destroy(); } -void Opening_Init(GameState* thisx) { - OpeningContext* this = (OpeningContext*)thisx; +void TitleSetup_Init(GameState* thisx) { + TitleSetupState* this = (TitleSetupState*)thisx; - Game_SetFramerateDivisor(&this->gameState, 1); - Matrix_Init(&this->gameState); + Game_SetFramerateDivisor(&this->state, 1); + Matrix_Init(&this->state); ShrinkWindow_Init(); - View_Init(&this->view, this->gameState.gfxCtx); - this->gameState.main = Opening_Main; - this->gameState.destroy = Opening_Destroy; + View_Init(&this->view, this->state.gfxCtx); + this->state.main = TitleSetup_Main; + this->state.destroy = TitleSetup_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_opening/z_opening.h b/src/overlays/gamestates/ovl_opening/z_opening.h index 809767fe4..36a01ffe9 100644 --- a/src/overlays/gamestates/ovl_opening/z_opening.h +++ b/src/overlays/gamestates/ovl_opening/z_opening.h @@ -3,13 +3,13 @@ #include "global.h" -void Opening_Init(GameState* thisx); -void Opening_Destroy(GameState* thisx); +void TitleSetup_Init(GameState* thisx); +void TitleSetup_Destroy(GameState* thisx); typedef struct { - /* 0x000 */ GameState gameState; + /* 0x000 */ GameState state; /* 0x0A4 */ UNK_TYPE1 unk_A4[0x4]; /* 0x0A8 */ View view; -} OpeningContext; // size = 0x210 +} TitleSetupState; // size = 0x210 #endif diff --git a/src/overlays/gamestates/ovl_select/overlay.cfg b/src/overlays/gamestates/ovl_select/overlay.cfg deleted file mode 100644 index 5250bd7fb..000000000 --- a/src/overlays/gamestates/ovl_select/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_select -z_select.c diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 53dbc266f..461192d48 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -1,363 +1,507 @@ /* * File: z_select.c * Overlay: ovl_select - * Description: Debug map select + * Description: Debug Map Select Menu */ #include "z_select.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "libc/alloca.h" #include "overlays/gamestates/ovl_title/z_title.h" -void Select_LoadTitle(SelectContext* this) { - { - GameState* gameState = &this->state; - gameState->running = false; - } - - SET_NEXT_GAMESTATE(&this->state, Title_Init, TitleContext); +void MapSelect_LoadConsoleLogo(MapSelectState* this) { + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, ConsoleLogo_Init, sizeof(ConsoleLogoState)); } -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.unk_3F1E = 0; - gSaveContext.unk_3F20 = 0; - gSaveContext.unk_3F22 = 0; - gSaveContext.unk_3F24 = 0; + 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.hudVisibilityForceButtonAlphasByStatus = false; + gSaveContext.nextHudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + gSaveContext.hudVisibilityTimer = 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.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = 0xFFFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; 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); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, Play_Init, sizeof(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_LoadConsoleLogo, 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; @@ -365,19 +509,18 @@ void Select_UpdateMenu(SelectContext* this) { if (this->verticalInputAccumulator == 0) { if (CHECK_BTN_ALL(controller1->press.button, BTN_A) || CHECK_BTN_ALL(controller1->press.button, BTN_START)) { - for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3EC0); i++) { - gSaveContext.unk_3DD0[i] = 0; - gSaveContext.unk_3DE0[i] = 0; - gSaveContext.unk_3E18[i] = 0; - gSaveContext.unk_3E50[i] = 0; - gSaveContext.unk_3E88[i] = 0; - gSaveContext.unk_3EC0[i] = 0; + for (i = 0; i < TIMER_ID_MAX; i++) { + gSaveContext.timerStates[i] = TIMER_STATE_OFF; + gSaveContext.timerCurTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerTimeLimits[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerStartOsTimes[i] = 0; + gSaveContext.timerStopTimes[i] = SECONDS_TO_TIMER(0); + gSaveContext.timerPausedOsTimes[i] = 0; } - gSaveContext.minigameState = 0; + gSaveContext.minigameStatus = MINIGAME_STATUS_INACTIVE; 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 +687,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 +696,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 +704,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 +721,7 @@ void Select_UpdateMenu(SelectContext* this) { if (this->timerUp != 0) { this->timerUp--; } + if (this->timerUp == 0) { this->lockUp = false; } @@ -583,19 +729,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 +767,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 +849,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 +866,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 +889,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 +944,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 +953,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 +993,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, GET_PLAYER_FORM); + MapSelect_PrintCutsceneSetting(this, printer, ((void)0, gSaveContext.save.cutscene)); POLY_OPA_DISP = GfxPrint_Close(printer); GfxPrint_Destroy(printer); @@ -846,7 +1003,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 +1014,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,36 +1022,36 @@ 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); SET_FULLSCREEN_VIEWPORT(&this->view); - View_RenderView(&this->view, 0xF); + View_Apply(&this->view, VIEW_ALL); 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..69312e986 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 (*SelectLoadFunc)(struct MapSelectState*, u32, s32); typedef struct { /* 0x00 */ char* name; - /* 0x04 */ Select_LoadFunc loadFunc; - /* 0x08 */ s32 entranceIndex; + /* 0x04 */ SelectLoadFunc loadFunc; + /* 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/overlay.cfg b/src/overlays/gamestates/ovl_title/overlay.cfg deleted file mode 100644 index 11343031f..000000000 --- a/src/overlays/gamestates/ovl_title/overlay.cfg +++ /dev/null @@ -1,2 +0,0 @@ -ovl_title -z_title.c diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index 1c32f6490..2b23bf565 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -5,10 +5,12 @@ */ #include "z_title.h" +#include "z64shrink_window.h" +#include "z64view.h" #include "overlays/gamestates/ovl_opening/z_opening.h" #include "misc/nintendo_rogo_static/nintendo_rogo_static.h" -void Title_UpdateCounters(TitleContext* this) { +void ConsoleLogo_UpdateCounters(ConsoleLogoState* this) { if ((this->coverAlpha == 0) && (this->visibleDuration != 0)) { this->timer--; this->visibleDuration--; @@ -32,7 +34,7 @@ void Title_UpdateCounters(TitleContext* this) { this->ult++; } -void Title_RenderView(TitleContext* this, f32 x, f32 y, f32 z) { +void ConsoleLogo_RenderView(ConsoleLogoState* this, f32 x, f32 y, f32 z) { View* view = &this->view; Vec3f eye; Vec3f at; @@ -44,15 +46,15 @@ void Title_RenderView(TitleContext* this, f32 x, f32 y, f32 z) { up.x = up.z = 0.0f; at.x = at.y = at.z = 0.0f; up.y = 1.0f; - func_8013F0D0(view, 30.0f, 10.0f, 12800.0f); - View_SetViewOrientation(view, &eye, &at, &up); - View_RenderView(view, 0xF); + View_SetPerspective(view, 30.0f, 10.0f, 12800.0f); + View_LookAt(view, &eye, &at, &up); + View_Apply(view, VIEW_ALL); } -void Title_Draw(GameState* thisx) { - static s16 titleRotation = 0; +void ConsoleLogo_Draw(GameState* thisx) { + static s16 sTitleRotation = 0; static Lights1 sTitleLights = gdSPDefLights1(100, 100, 100, 255, 255, 255, 69, 69, 69); - TitleContext* this = (TitleContext*)thisx; + ConsoleLogoState* this = (ConsoleLogoState*)thisx; u16 y; u16 idx; Vec3f lightDir; @@ -60,7 +62,7 @@ void Title_Draw(GameState* thisx) { Vec3f eye; s32 pad[2]; - OPEN_DISPS(this->gameState.gfxCtx); + OPEN_DISPS(this->state.gfxCtx); lightDir.x = 69.0f; lightDir.y = 69.0f; @@ -74,24 +76,24 @@ void Title_Draw(GameState* thisx) { eye.y = 4002.5417f; eye.z = 1119.0837f; - Hilite_DrawOpa(&object, &eye, &lightDir, this->gameState.gfxCtx); + Hilite_DrawOpa(&object, &eye, &lightDir, this->state.gfxCtx); gSPSetLights1(POLY_OPA_DISP++, sTitleLights); - Title_RenderView(this, 0.0f, 150.0f, 300.0f); - func_8012C28C(this->gameState.gfxCtx); + ConsoleLogo_RenderView(this, 0.0f, 150.0f, 300.0f); + func_8012C28C(this->state.gfxCtx); Matrix_Translate(-53.0f, -5.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - Matrix_RotateZYX(0, titleRotation, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, sTitleRotation, 0, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->gameState.gfxCtx), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(this->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gNintendo64LogoNDL); - func_8012C628(this->gameState.gfxCtx); + func_8012C628(this->state.gfxCtx); 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); @@ -109,62 +111,58 @@ void Title_Draw(GameState* thisx) { 1 << 10, 1 << 10); } - func_800FC444(this->gameState.gfxCtx, 0, 0, 0, this->coverAlpha, 2); + func_800FC444(this->state.gfxCtx, 0, 0, 0, this->coverAlpha, 2); - titleRotation += 300; + sTitleRotation += 300; - CLOSE_DISPS(this->gameState.gfxCtx); + CLOSE_DISPS(this->state.gfxCtx); } -void Title_Main(GameState* thisx) { - TitleContext* this = (TitleContext*)thisx; +void ConsoleLogo_Main(GameState* thisx) { + ConsoleLogoState* this = (ConsoleLogoState*)thisx; - func_8012CF0C(this->gameState.gfxCtx, true, true, 0, 0, 0); + func_8012CF0C(this->state.gfxCtx, true, true, 0, 0, 0); - OPEN_DISPS(this->gameState.gfxCtx); + OPEN_DISPS(this->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x01, this->staticSegment); - Title_UpdateCounters(this); - Title_Draw(&this->gameState); + ConsoleLogo_UpdateCounters(this); + ConsoleLogo_Draw(&this->state); if (this->exit) { - gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; - gSaveContext.nightSeqIndex = 0xFF; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; gSaveContext.gameMode = 1; - { - GameState* gameState = &this->gameState; - gameState->running = false; - } - SET_NEXT_GAMESTATE(&this->gameState, Opening_Init, OpeningContext); + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, TitleSetup_Init, sizeof(TitleSetupState)); } - CLOSE_DISPS(this->gameState.gfxCtx); + CLOSE_DISPS(this->state.gfxCtx); } -void Title_Destroy(GameState* thisx) { - TitleContext* this = (TitleContext*)thisx; +void ConsoleLogo_Destroy(GameState* thisx) { + ConsoleLogoState* this = (ConsoleLogoState*)thisx; - Sram_InitSram(&this->gameState, &this->sramCtx); + Sram_InitSram(&this->state, &this->sramCtx); ShrinkWindow_Destroy(); CIC6105_Nop80081828(); } -void Title_Init(GameState* thisx) { - TitleContext* this = (TitleContext*)thisx; - uintptr_t segmentSize = - (uintptr_t)_nintendo_rogo_staticSegmentRomEnd - (uintptr_t)_nintendo_rogo_staticSegmentRomStart; +void ConsoleLogo_Init(GameState* thisx) { + ConsoleLogoState* this = (ConsoleLogoState*)thisx; + uintptr_t segmentSize = SEGMENT_ROM_SIZE(nintendo_rogo_static); - this->staticSegment = THA_AllocEndAlign16(&this->gameState.heap, segmentSize); - DmaMgr_SendRequest0(this->staticSegment, (uintptr_t)_nintendo_rogo_staticSegmentRomStart, segmentSize); + this->staticSegment = THA_AllocEndAlign16(&this->state.heap, segmentSize); + DmaMgr_SendRequest0(this->staticSegment, SEGMENT_ROM_START(nintendo_rogo_static), segmentSize); - Game_SetFramerateDivisor(thisx, 1); - Matrix_Init(thisx); + Game_SetFramerateDivisor(&this->state, 1); + Matrix_Init(&this->state); ShrinkWindow_Init(); - View_Init(&this->view, thisx->gfxCtx); + View_Init(&this->view, this->state.gfxCtx); - thisx->main = Title_Main; - thisx->destroy = Title_Destroy; + this->state.main = ConsoleLogo_Main; + this->state.destroy = ConsoleLogo_Destroy; this->exit = false; if (!(Padmgr_GetControllerBitmask() & 1)) { diff --git a/src/overlays/gamestates/ovl_title/z_title.h b/src/overlays/gamestates/ovl_title/z_title.h index 7f2f34425..0cb19da1a 100644 --- a/src/overlays/gamestates/ovl_title/z_title.h +++ b/src/overlays/gamestates/ovl_title/z_title.h @@ -3,11 +3,11 @@ #include "global.h" -void Title_Init(GameState* thisx); -void Title_Destroy(GameState* thisx); +void ConsoleLogo_Init(GameState* thisx); +void ConsoleLogo_Destroy(GameState* thisx); typedef struct { - /* 0x000 */ GameState gameState; + /* 0x000 */ GameState state; /* 0x0A4 */ u8* staticSegment; /* 0x0A8 */ View view; /* 0x210 */ SramContext sramCtx; @@ -18,6 +18,6 @@ typedef struct { /* 0x240 */ s16 ult; /* 0x242 */ s16 uls; /* 0x244 */ u8 exit; -} TitleContext; // size = 0x248 +} ConsoleLogoState; // size = 0x248 #endif diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/overlay.cfg b/src/overlays/kaleido_scope/ovl_kaleido_scope/overlay.cfg deleted file mode 100644 index c35d94518..000000000 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/overlay.cfg +++ /dev/null @@ -1,7 +0,0 @@ -ovl_kaleido_scope -z_kaleido_collect.c -z_kaleido_debug.c -z_kaleido_item.c -z_kaleido_map.c -z_kaleido_mask.c -z_kaleido_scope_NES.c 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..fe72ee840 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 @@ -1,23 +1,1009 @@ /* * File: z_kaleido_collect.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu - Quest Status Page */ #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; +s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s16 point); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808160A0.s") +extern TexturePtr D_08061000; // gBombersNotebookIconTex +extern TexturePtr D_08062000; // gSongNoteIconTex -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80817B5C.s") +s16 sQuestRemainsColorTimerInit[] = { 120, 60, 2, 80 }; +s16 sQuestHpColorTimerInit[] = { 20, 4, 20, 10 }; +s16 sQuestSongPlayedOcarinaButtonsNum = 0; +u8 sQuestSongPlayedOcarinaButtons[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +s16 sQuestSongPlayedOcarinaButtonsAlpha[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +s16 sQuestHpPrimColorTargets[][4] = { + { 255, 0, 0, 255 }, + { 255, 70, 0, 150 }, + { 255, 70, 0, 150 }, + { 255, 0, 0, 255 }, +}; +s16 sQuestRemainsEnvTargets[][3] = { + { 0, 0, 0 }, // QUEST_REMAINS_ODOLWA Target 1 + { 0, 0, 0 }, // QUEST_REMAINS_GOHT Target 1 + { 0, 0, 0 }, // QUEST_REMAINS_GYORG Target 1 + { 0, 0, 0 }, // QUEST_REMAINS_TWINMOLD Target 1 + { 0, 0, 0 }, // Unused + { 0, 0, 0 }, // Unused + { 0, 60, 0 }, // QUEST_REMAINS_ODOLWA Target 2 + { 90, 0, 0 }, // QUEST_REMAINS_GOHT Target 2 + { 0, 40, 110 }, // QUEST_REMAINS_GYORG Target 2 + { 80, 40, 0 }, // QUEST_REMAINS_TWINMOLD Target 2 + { 70, 0, 90 }, // Unused + { 90, 90, 0 }, // Unused +}; +s16 sQuestRemainsEnvRed[] = { + 255, // QUEST_REMAINS_ODOLWA + 255, // QUEST_REMAINS_GOHT + 255, // QUEST_REMAINS_GYORG + 255, // QUEST_REMAINS_TWINMOLD + 255, // Unused + 255, // Unused +}; +s16 sQuestRemainsEnvGreen[] = { + 255, // QUEST_REMAINS_ODOLWA + 255, // QUEST_REMAINS_GOHT + 255, // QUEST_REMAINS_GYORG + 255, // QUEST_REMAINS_TWINMOLD + 255, // Unused + 255, // Unused +}; +s16 sQuestRemainsEnvBlue[] = { + 150, // QUEST_REMAINS_ODOLWA + 150, // QUEST_REMAINS_GOHT + 150, // QUEST_REMAINS_GYORG + 150, // QUEST_REMAINS_TWINMOLD + 150, // Unused + 150, // Unused +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80818904.s") +#ifdef NON_EQUIVALENT +// TODO: is actually NON_MATCHING, update once `z_kaleido_scope_NES.c` is decompiled +// A single small regalloc at the first `Gfx_DrawTexQuadIA8` for the heart piece count (see `gItemIcons`) +void KaleidoScope_DrawQuestStatus(PlayState* play) { + static s16 sQuestRemainsColorTimer = 20; + static s16 sQuestRemainsColorTimerIndex = 0; + static s16 sQuestHpPrimRed = 0; + static s16 sQuestHpPrimGreen = 0; + static s16 sQuestHpPrimBlue = 0; + static s16 sQuestHpPrimAlpha = 0; + static s16 sQuestHpColorTimer = 20; + static s16 sQuestHpPrimColorTargetIndex = 0; + static TexturePtr sOcarinaButtonTextures[] = { + gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, + }; + static s16 sQuestSongsPrimRed[] = { + 150, // QUEST_SONG_SONATA + 255, // QUEST_SONG_LULLABY + 100, // QUEST_SONG_BOSSA_NOVA + 255, // QUEST_SONG_ELEGY + 255, // QUEST_SONG_OATH + 255, // QUEST_SONG_SARIA + 255, // QUEST_SONG_TIME + 255, // QUEST_SONG_HEALING + 255, // QUEST_SONG_EPONA + 255, // QUEST_SONG_SOARING + 255, // QUEST_SONG_STORMS + 255, // QUEST_SONG_SUN + }; + static s16 sQuestSongsPrimGreen[] = { + 255, // QUEST_SONG_SONATA + 80, // QUEST_SONG_LULLABY + 150, // QUEST_SONG_BOSSA_NOVA + 160, // QUEST_SONG_ELEGY + 100, // QUEST_SONG_OATH + 240, // QUEST_SONG_SARIA + 255, // QUEST_SONG_TIME + 255, // QUEST_SONG_HEALING + 255, // QUEST_SONG_EPONA + 255, // QUEST_SONG_SOARING + 255, // QUEST_SONG_STORMS + 255, // QUEST_SONG_SUN + }; + static s16 sQuestSongsPrimBlue[] = { + 100, // QUEST_SONG_SONATA + 40, // QUEST_SONG_LULLABY + 255, // QUEST_SONG_BOSSA_NOVA + 0, // QUEST_SONG_ELEGY + 255, // QUEST_SONG_OATH + 100, // QUEST_SONG_SARIA + 255, // QUEST_SONG_TIME + 255, // QUEST_SONG_HEALING + 255, // QUEST_SONG_EPONA + 255, // QUEST_SONG_SOARING + 255, // QUEST_SONG_STORMS + 255, // QUEST_SONG_SUN + }; + static TexturePtr sQuestUpgradeTextures[][3] = { + { 0x08053000, 0x08054000, 0x08055000 }, // UPG_QUIVER + { 0x08056000, 0x08057000, 0x08058000 }, // UPG_BOMB_BAG + }; + static u8 sQuestUpgrades[] = { UPG_QUIVER, UPG_BOMB_BAG }; + PauseContext* pauseCtx = &play->pauseCtx; + s16 sp1CA; // colorSetR and numOcarinaButtons + s16 sp1C8; // colorSetG and ocarinaButtonIndex + s16 sp1C6; + s16 sp1C4; + s16 var_v1; + s16 i; + s16 j; + s16 k; + s16 skullTokenDigits[3]; + u16 isDigitDrawn; + + OPEN_DISPS(play->state.gfxCtx); + + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_QUEST] * 4, pauseCtx->questVtx); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + // Draw the Boss Remains icons + sQuestRemainsColorTimer--; + for (i = 0, j = 0; i < 4; i++, j += 4) { + if ((sQuestRemainsColorTimerIndex != 1) && (sQuestRemainsColorTimerIndex != 3)) { + var_v1 = (sQuestRemainsColorTimerIndex != 0) ? (i + 6) : i; + + if (sQuestRemainsColorTimer != 0) { + sp1CA = ABS_ALT(sQuestRemainsEnvRed[i] - sQuestRemainsEnvTargets[var_v1][0]) / sQuestRemainsColorTimer; + sp1C8 = + ABS_ALT(sQuestRemainsEnvGreen[i] - sQuestRemainsEnvTargets[var_v1][1]) / sQuestRemainsColorTimer; + sp1C6 = ABS_ALT(sQuestRemainsEnvBlue[i] - sQuestRemainsEnvTargets[var_v1][2]) / sQuestRemainsColorTimer; + + if (sQuestRemainsEnvRed[i] >= sQuestRemainsEnvTargets[var_v1][0]) { + sQuestRemainsEnvRed[i] -= sp1CA; + } else { + sQuestRemainsEnvRed[i] += sp1CA; + } + if (sQuestRemainsEnvGreen[i] >= sQuestRemainsEnvTargets[var_v1][1]) { + sQuestRemainsEnvGreen[i] -= sp1C8; + } else { + sQuestRemainsEnvGreen[i] += sp1C8; + } + if (sQuestRemainsEnvBlue[i] >= sQuestRemainsEnvTargets[var_v1][2]) { + sQuestRemainsEnvBlue[i] -= sp1C6; + } else { + sQuestRemainsEnvBlue[i] += sp1C6; + } + } else { + sQuestRemainsEnvRed[i] = sQuestRemainsEnvTargets[var_v1][0]; + sQuestRemainsEnvGreen[i] = sQuestRemainsEnvTargets[var_v1][1]; + sQuestRemainsEnvBlue[i] = sQuestRemainsEnvTargets[var_v1][2]; + } + } + + if (CHECK_QUEST_ITEM(i)) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, sQuestRemainsEnvRed[i], sQuestRemainsEnvGreen[i], sQuestRemainsEnvBlue[i], + 0); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, gItemIcons[ITEM_REMAINS_ODOLWA + i], 32, 32, 0); + } + } + + if (sQuestRemainsColorTimer == 0) { + sQuestRemainsColorTimer = sQuestRemainsColorTimerInit[sQuestRemainsColorTimerIndex]; + if (++sQuestRemainsColorTimerIndex > 3) { + sQuestRemainsColorTimerIndex = 0; + } + } + + // Draw shield + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, gItemIcons[(ITEM_SHIELD_HERO - 1) + GET_CUR_EQUIP_VALUE(1)], + 32, 32, 0); + } + + j += 4; + + // Draw Sword + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_NONE) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, gItemIcons[(ITEM_SWORD_KOKIRI - 1) + GET_CUR_EQUIP_VALUE(0)], + 32, 32, 0); + } + + j += 4; + + // Draw Songs + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + gDPLoadTextureBlock(POLY_OPA_DISP++, &D_08062000, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 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); + + for (i = 0; i < 12; i++, j += 4) { + if (CHECK_QUEST_ITEM(i + QUEST_SONG_SONATA) || + ((i == (QUEST_SONG_LULLABY - QUEST_SONG_SONATA)) && !CHECK_QUEST_ITEM(i + QUEST_SONG_SONATA) && + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) { + if ((i + QUEST_SONG_SONATA) == pauseCtx->cursorSlot[PAUSE_QUEST]) { + pauseCtx->questVtx[j + 0].v.ob[0] = pauseCtx->questVtx[j + 2].v.ob[0] = + pauseCtx->questVtx[j + 0].v.ob[0] - 2; + + pauseCtx->questVtx[j + 1].v.ob[0] = pauseCtx->questVtx[j + 3].v.ob[0] = + pauseCtx->questVtx[j + 1].v.ob[0] + 4; + + pauseCtx->questVtx[j + 0].v.ob[1] = pauseCtx->questVtx[j + 1].v.ob[1] = + pauseCtx->questVtx[j + 0].v.ob[1] + 2; + + pauseCtx->questVtx[j + 2].v.ob[1] = pauseCtx->questVtx[j + 3].v.ob[1] = + pauseCtx->questVtx[j + 2].v.ob[1] - 4; + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sQuestSongsPrimRed[i], sQuestSongsPrimGreen[i], + sQuestSongsPrimBlue[i], pauseCtx->alpha); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + } + + // Draw Bombers Notebook + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, &D_08061000, 32, 32, 0); + } + + j += 4; + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + // Loop over quest item upgrades + for (i = 0; i < 2; i++, j += 4) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (GET_CUR_UPG_VALUE(sQuestUpgrades[i]) != 0) { + KaleidoScope_DrawTexQuadRGBA32( + play->state.gfxCtx, sQuestUpgradeTextures[i][GET_CUR_UPG_VALUE(sQuestUpgrades[i]) - 1], 32, 32, 0); + } + } + + // Skip over &pauseCtx->questVtx[84], which should be `QUEST_SKULL_TOKEN` + j += 4; + + sp1CA = ABS_ALT(sQuestHpPrimRed - sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][0]) / sQuestHpColorTimer; + sp1C8 = ABS_ALT(sQuestHpPrimGreen - sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][1]) / sQuestHpColorTimer; + sp1C6 = ABS_ALT(sQuestHpPrimBlue - sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][2]) / sQuestHpColorTimer; + sp1C4 = ABS_ALT(sQuestHpPrimAlpha - sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][3]) / sQuestHpColorTimer; + + if (sQuestHpPrimRed >= sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][0]) { + sQuestHpPrimRed -= sp1CA; + } else { + sQuestHpPrimRed += sp1CA; + } + + if (sQuestHpPrimGreen >= sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][1]) { + sQuestHpPrimGreen -= sp1C8; + } else { + sQuestHpPrimGreen += sp1C8; + } + + if (sQuestHpPrimBlue >= sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][2]) { + sQuestHpPrimBlue -= sp1C6; + } else { + sQuestHpPrimBlue += sp1C6; + } + + if (sQuestHpPrimAlpha >= sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][3]) { + sQuestHpPrimAlpha -= sp1C4; + } else { + sQuestHpPrimAlpha += sp1C4; + } + + sQuestHpColorTimer--; + if (sQuestHpColorTimer == 0) { + sQuestHpPrimRed = sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][0]; + sQuestHpPrimGreen = sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][1]; + sQuestHpPrimBlue = sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][2]; + sQuestHpPrimAlpha = sQuestHpPrimColorTargets[sQuestHpPrimColorTargetIndex][3]; + sQuestHpColorTimer = sQuestHpColorTimerInit[sQuestHpPrimColorTargetIndex]; + if (++sQuestHpPrimColorTargetIndex > 3) { + sQuestHpPrimColorTargetIndex = 0; + } + } + + if ((GET_SAVE_INVENTORY_QUEST_ITEMS >> QUEST_HEART_PIECE_COUNT) != 0) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + if ((pauseCtx->state == PAUSE_STATE_OPENING_3) || (pauseCtx->state == PAUSE_STATE_UNPAUSE_SETUP)) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sQuestHpPrimColorTargets[0][0], sQuestHpPrimColorTargets[0][1], + sQuestHpPrimColorTargets[0][2], pauseCtx->alpha); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sQuestHpPrimRed, sQuestHpPrimGreen, sQuestHpPrimBlue, + sQuestHpPrimAlpha); + } + + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255); + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + + POLY_OPA_DISP = Gfx_DrawTexQuadIA8( + POLY_OPA_DISP, + gItemIcons[(0x7A + ((GET_SAVE_INVENTORY_QUEST_ITEMS & 0xF0000000) >> QUEST_HEART_PIECE_COUNT))], 48, 48, 0); + } + + j += 4; + + if (pauseCtx->state == PAUSE_STATE_MAIN) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PLAYBACK) { + // Draw ocarina buttons as they are played back + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + + if (pauseCtx->ocarinaStaff->pos != 0) { + if (sQuestSongPlayedOcarinaButtonsNum == (pauseCtx->ocarinaStaff->pos - 1)) { + sQuestSongPlayedOcarinaButtonsNum++; + sQuestSongPlayedOcarinaButtons[pauseCtx->ocarinaStaff->pos - 1] = + pauseCtx->ocarinaStaff->buttonIndex; + } + + for (i = 0, k = 0; i < 8; i++, k += 4, j += 4) { + if (sQuestSongPlayedOcarinaButtons[i] == OCARINA_BTN_INVALID) { + break; + } + + if (sQuestSongPlayedOcarinaButtonsAlpha[i] != 255) { + sQuestSongPlayedOcarinaButtonsAlpha[i] += 50; + if (sQuestSongPlayedOcarinaButtonsAlpha[i] >= 255) { + sQuestSongPlayedOcarinaButtonsAlpha[i] = 255; + } + } + + pauseCtx->questVtx[j + 0].v.ob[1] = pauseCtx->questVtx[j + 1].v.ob[1] = + pauseCtx->ocarinaButtonsY[sQuestSongPlayedOcarinaButtons[i]]; + + pauseCtx->questVtx[j + 2].v.ob[1] = pauseCtx->questVtx[j + 3].v.ob[1] = + pauseCtx->questVtx[j + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (sQuestSongPlayedOcarinaButtons[i] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 150, 255, sQuestSongPlayedOcarinaButtonsAlpha[i]); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, sQuestSongPlayedOcarinaButtonsAlpha[i]); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + + POLY_OPA_DISP = Gfx_DrawTexQuadIA8( + POLY_OPA_DISP, sOcarinaButtonTextures[sQuestSongPlayedOcarinaButtons[i]], 16, 16, 0); + } + } + } else if (IS_PAUSE_MAIN_STATE_SAVE_PROMPT || (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG)) { + // Draw the buttons for playing a song + sp1C8 = pauseCtx->ocarinaSongIndex; + sp1CA = gOcarinaSongButtons[sp1C8].numButtons; + + i = j; + + for (k = 0; k < sp1CA; k++, j += 4) { + pauseCtx->questVtx[j + 0].v.ob[1] = pauseCtx->questVtx[j + 1].v.ob[1] = + pauseCtx->ocarinaButtonsY[gOcarinaSongButtons[sp1C8].buttonIndex[k]]; + + pauseCtx->questVtx[j + 2].v.ob[1] = pauseCtx->questVtx[j + 3].v.ob[1] = + pauseCtx->questVtx[j + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG) { + // Draw ocarina buttons colored + if (gOcarinaSongButtons[sp1C8].buttonIndex[k] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 150, 255, 200); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, 200); + } + } else { + // Gray out buttons while reading ocarina song inputs + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 150, 150, 150, 150); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + + POLY_OPA_DISP = Gfx_DrawTexQuadIA8( + POLY_OPA_DISP, sOcarinaButtonTextures[gOcarinaSongButtons[sp1C8].buttonIndex[k]], 16, 16, 0); + } + + if (pauseCtx->mainState != PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG) { + pauseCtx->ocarinaStaff = AudioOcarina_GetPlayingStaff(); + + // Update ocarina song inputs + if (pauseCtx->ocarinaStaff->pos != 0) { + if (sQuestSongPlayedOcarinaButtonsNum == (pauseCtx->ocarinaStaff->pos - 1)) { + if (pauseCtx->ocarinaStaff->buttonIndex <= OCARINA_BTN_C_UP) { + sQuestSongPlayedOcarinaButtons[pauseCtx->ocarinaStaff->pos - 1] = + pauseCtx->ocarinaStaff->buttonIndex; + sQuestSongPlayedOcarinaButtons[pauseCtx->ocarinaStaff->pos] = OCARINA_BTN_INVALID; + sQuestSongPlayedOcarinaButtonsNum++; + } + } + } + + // Draw the buttons colored as the ocarina song inputs are read from + j = i + 32; + k = 0; + for (; k < 8; k++, j += 4) { + if (sQuestSongPlayedOcarinaButtons[k] == OCARINA_BTN_INVALID) { + continue; + } + + if (sQuestSongPlayedOcarinaButtonsAlpha[k] != 255) { + sQuestSongPlayedOcarinaButtonsAlpha[k] += 50; + if (sQuestSongPlayedOcarinaButtonsAlpha[k] >= 255) { + sQuestSongPlayedOcarinaButtonsAlpha[k] = 255; + } + } + + pauseCtx->questVtx[j + 0].v.ob[1] = pauseCtx->questVtx[j + 1].v.ob[1] = + pauseCtx->ocarinaButtonsY[sQuestSongPlayedOcarinaButtons[k]]; + + pauseCtx->questVtx[j + 2].v.ob[1] = pauseCtx->questVtx[j + 3].v.ob[1] = + pauseCtx->questVtx[j + 0].v.ob[1] - 12; + + gDPPipeSync(POLY_OPA_DISP++); + + if (sQuestSongPlayedOcarinaButtons[k] == OCARINA_BTN_A) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 80, 150, 255, sQuestSongPlayedOcarinaButtonsAlpha[k]); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 50, sQuestSongPlayedOcarinaButtonsAlpha[k]); + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[j], 4, 0); + + POLY_OPA_DISP = Gfx_DrawTexQuadIA8( + POLY_OPA_DISP, sOcarinaButtonTextures[sQuestSongPlayedOcarinaButtons[k]], 16, 16, 0); + } + + if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT_INIT) { + for (k = 0; k < 8; k++) { + sQuestSongPlayedOcarinaButtons[k] = OCARINA_BTN_INVALID; + sQuestSongPlayedOcarinaButtonsAlpha[k] = 0; + } + + sQuestSongPlayedOcarinaButtonsNum = 0; + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_StartDefault((1 << pauseCtx->ocarinaSongIndex) | 0x80000000); + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + pauseCtx->ocarinaStaff->pos = 0; + pauseCtx->ocarinaStaff->state = 0xFE; + pauseCtx->mainState = PAUSE_MAIN_STATE_SONG_PROMPT; + } + } + } + } + + // Draw Skull Token Count + // QUEST_SKULL_TOKEN never properly set, see Item_Give(), + // Vertices not well placed, digits are not aligned and placed in unintended positions + if (CHECK_QUEST_ITEM(QUEST_SKULL_TOKEN) && ((play->sceneId == SCENE_KINSTA1) || (play->sceneId == SCENE_KINDAN2))) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + + skullTokenDigits[0] = skullTokenDigits[1] = 0; + skullTokenDigits[2] = Inventory_GetSkullTokenCount(play->sceneId); + + while (skullTokenDigits[2] >= 100) { + skullTokenDigits[0]++; + skullTokenDigits[2] -= 100; + } + + while (skullTokenDigits[2] >= 10) { + skullTokenDigits[1]++; + skullTokenDigits[2] -= 10; + } + + //! @bug: &pauseCtx->questVtx[84] is the questVtx for skull tokens + gSPVertex(POLY_OPA_DISP++, &pauseCtx->questVtx[152], 24, 0); + + // Loop over two sets of digits, the first is shadowed, the second is colored + for (k = 0, i = 0; k < 2; k++) { + if (k == 0) { + // shadow + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, pauseCtx->alpha); + } else { + if (Inventory_GetSkullTokenCount(play->sceneId) == 100) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 50, 50, pauseCtx->alpha); + } else { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + } + } + + isDigitDrawn = false; + for (j = 0; j < 3; j++, i += 4) { + if ((j >= 2) || (skullTokenDigits[j] != 0) || isDigitDrawn) { + gDPLoadTextureBlock(POLY_OPA_DISP++, ((u8*)gCounterDigit0Tex + (8 * 16 * skullTokenDigits[j])), + G_IM_FMT_I, G_IM_SIZ_8b, 8, 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); + + gSP1Quadrangle(POLY_OPA_DISP++, i, i + 2, i + 3, i + 1, 0); + + isDigitDrawn = true; + } + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} +#else +s16 sQuestRemainsColorTimer = 20; +s16 sQuestRemainsColorTimerIndex = 0; +s16 sQuestHpPrimRed = 0; +s16 sQuestHpPrimGreen = 0; +s16 sQuestHpPrimBlue = 0; +s16 sQuestHpPrimAlpha = 0; +s16 sQuestHpColorTimer = 20; +s16 sQuestHpPrimColorTargetIndex = 0; +TexturePtr sOcarinaButtonTextures[] = { + gOcarinaATex, gOcarinaCDownTex, gOcarinaCRightTex, gOcarinaCLeftTex, gOcarinaCUpTex, +}; +s16 sQuestSongsPrimRed[] = { + 150, 255, 100, 255, 255, 255, 255, 255, 255, 255, 255, 255, +}; +s16 sQuestSongsPrimGreen[] = { + 255, 80, 150, 160, 100, 240, 255, 255, 255, 255, 255, 255, +}; +s16 sQuestSongsPrimBlue[] = { + 100, 40, 255, 0, 255, 100, 255, 255, 255, 255, 255, 255, +}; +TexturePtr sQuestUpgradeTextures[][3] = { + { 0x08053000, 0x08054000, 0x08055000 }, + { 0x08056000, 0x08057000, 0x08058000 }, +}; +u8 sQuestUpgrades[] = { UPG_QUIVER, UPG_BOMB_BAG }; +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawQuestStatus.s") +#endif + +typedef enum { + /* -3 */ CURSOR_TO_LEFT = -3, // Cursor on the "scroll to left page" position + /* -2 */ CURSOR_TO_RIGHT, // Cursor on the "scroll to right page" position + /* -1 */ CURSOR_NONE // No position in that direction, cursor stays where it is +} CursorPointNext; + +typedef struct { + /* 0x0 */ s16 up; + /* 0x2 */ s16 down; + /* 0x4 */ s16 left; + /* 0x6 */ s16 right; +} CursorPointDirection; + +void KaleidoScope_UpdateQuestCursor(PlayState* play) { + static s16 sQuestSongPlaybackDelayTimer = 0; + static CursorPointDirection sCursorPointLinks[] = { + { CURSOR_NONE, QUEST_REMAINS_TWINMOLD, QUEST_REMAINS_GYORG, QUEST_REMAINS_GOHT }, // QUEST_REMAINS_ODOLWA + { QUEST_REMAINS_ODOLWA, QUEST_SHIELD, QUEST_REMAINS_TWINMOLD, CURSOR_TO_RIGHT }, // QUEST_REMAINS_GOHT + { QUEST_REMAINS_ODOLWA, QUEST_SWORD, QUEST_HEART_PIECE, QUEST_REMAINS_TWINMOLD }, // QUEST_REMAINS_GYORG + { QUEST_REMAINS_ODOLWA, QUEST_SHIELD, QUEST_REMAINS_GYORG, QUEST_REMAINS_GOHT }, // QUEST_REMAINS_TWINMOLD + { QUEST_REMAINS_GOHT, QUEST_BOMB_BAG, QUEST_SWORD, CURSOR_TO_RIGHT }, // QUEST_SHIELD + { QUEST_REMAINS_GYORG, QUEST_QUIVER, QUEST_SONG_STORMS, QUEST_SHIELD }, // QUEST_SWORD + { QUEST_SONG_TIME, CURSOR_NONE, CURSOR_TO_LEFT, QUEST_SONG_LULLABY }, // QUEST_SONG_SONATA + { QUEST_SONG_HEALING, CURSOR_NONE, QUEST_SONG_SONATA, QUEST_SONG_BOSSA_NOVA }, // QUEST_SONG_LULLABY + { QUEST_SONG_EPONA, CURSOR_NONE, QUEST_SONG_LULLABY, QUEST_SONG_ELEGY }, // QUEST_SONG_BOSSA_NOVA + { QUEST_SONG_SOARING, CURSOR_NONE, QUEST_SONG_BOSSA_NOVA, QUEST_SONG_OATH }, // QUEST_SONG_ELEGY + { QUEST_SONG_STORMS, CURSOR_NONE, QUEST_SONG_ELEGY, QUEST_QUIVER }, // QUEST_SONG_OATH + { QUEST_SONG_SUN, CURSOR_NONE, QUEST_SONG_OATH, QUEST_SWORD }, // QUEST_SONG_SARIA + { QUEST_BOMBERS_NOTEBOOK, QUEST_SONG_SONATA, CURSOR_TO_LEFT, QUEST_SONG_HEALING }, // QUEST_SONG_TIME + { QUEST_BOMBERS_NOTEBOOK, QUEST_SONG_LULLABY, QUEST_SONG_TIME, QUEST_SONG_EPONA }, // QUEST_SONG_HEALING + { QUEST_HEART_PIECE, QUEST_SONG_BOSSA_NOVA, QUEST_SONG_HEALING, QUEST_SONG_SOARING }, // QUEST_SONG_EPONA + { QUEST_HEART_PIECE, QUEST_SONG_ELEGY, QUEST_SONG_EPONA, QUEST_SONG_STORMS }, // QUEST_SONG_SOARING + { QUEST_HEART_PIECE, QUEST_SONG_OATH, QUEST_SONG_SOARING, QUEST_SWORD }, // QUEST_SONG_STORMS + { QUEST_HEART_PIECE, QUEST_SONG_SARIA, QUEST_SONG_STORMS, QUEST_SWORD }, // QUEST_SONG_SUN + { CURSOR_NONE, QUEST_SONG_TIME, CURSOR_TO_LEFT, QUEST_HEART_PIECE }, // QUEST_BOMBERS_NOTEBOOK + { QUEST_SWORD, CURSOR_NONE, QUEST_SONG_OATH, QUEST_BOMB_BAG }, // QUEST_QUIVER + { QUEST_SHIELD, CURSOR_NONE, QUEST_QUIVER, CURSOR_TO_RIGHT }, // QUEST_BOMB_BAG + { QUEST_QUIVER, QUEST_SONG_TIME, CURSOR_TO_LEFT, QUEST_HEART_PIECE }, // QUEST_SKULL_TOKEN + { CURSOR_NONE, QUEST_SONG_STORMS, QUEST_BOMBERS_NOTEBOOK, QUEST_REMAINS_GYORG }, // QUEST_HEART_PIECE + }; + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + s32 pad; + s16 nextCursorPoint; + s16 oldCursorPoint; + s16 i; + u16 cursor; + u16 cursorItem; + + pauseCtx->nameColorSet = PAUSE_NAME_COLOR_SET_WHITE; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + + // != PAUSE_MAIN_STATE_IDLE + if ((pauseCtx->state == PAUSE_STATE_MAIN) && + (!pauseCtx->mainState || (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG)) && + (pauseCtx->pageIndex == PAUSE_QUEST) && !pauseCtx->itemDescriptionOn) { + if (pauseCtx->cursorSpecialPos == 0) { + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_QUEST]; + + if (pauseCtx->stickAdjX < -30) { + // Move cursor left + if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + pauseCtx->unk_298 = 4.0f; + + nextCursorPoint = sCursorPointLinks[oldCursorPoint].left; + if (nextCursorPoint == CURSOR_TO_LEFT) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + if (interfaceCtx->unk_212 == 6) { + func_8011552C(play, DO_ACTION_INFO); + } + return; + } else { + while (nextCursorPoint > CURSOR_NONE) { + if (KaleidoScope_UpdateQuestStatusPoint(pauseCtx, nextCursorPoint)) { + break; + } + nextCursorPoint = sCursorPointLinks[nextCursorPoint].left; + } + } + } else if (pauseCtx->stickAdjX > 30) { + // Move cursor right + if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + pauseCtx->unk_298 = 4.0f; + nextCursorPoint = sCursorPointLinks[oldCursorPoint].right; + + if (nextCursorPoint == CURSOR_TO_RIGHT) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + return; + } + + while (nextCursorPoint > CURSOR_NONE) { + if (KaleidoScope_UpdateQuestStatusPoint(pauseCtx, nextCursorPoint)) { + break; + } + nextCursorPoint = sCursorPointLinks[nextCursorPoint].right; + } + } + + if (pauseCtx->stickAdjY < -30) { + // Move cursor down + if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + nextCursorPoint = sCursorPointLinks[oldCursorPoint].down; + + while (nextCursorPoint > CURSOR_NONE) { + pauseCtx->unk_298 = 4.0f; + if (KaleidoScope_UpdateQuestStatusPoint(pauseCtx, nextCursorPoint)) { + break; + } + nextCursorPoint = sCursorPointLinks[nextCursorPoint].down; + } + } else if (pauseCtx->stickAdjY > 30) { + // Move cursor up + if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + nextCursorPoint = sCursorPointLinks[oldCursorPoint].up; + while (nextCursorPoint > CURSOR_NONE) { + pauseCtx->unk_298 = 4.0f; + if (KaleidoScope_UpdateQuestStatusPoint(pauseCtx, nextCursorPoint)) { + break; + } + nextCursorPoint = sCursorPointLinks[nextCursorPoint].up; + } + } + + // if the cursor point changed + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_QUEST]) { + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + play_sound(NA_SE_SY_CURSOR); + } + + // Update cursor item and slot + if (pauseCtx->cursorPoint[PAUSE_QUEST] != QUEST_HEART_PIECE) { + if (pauseCtx->cursorPoint[PAUSE_QUEST] <= QUEST_REMAINS_TWINMOLD) { + // Boss Remains + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursorItem = ITEM_REMAINS_ODOLWA + pauseCtx->cursorPoint[PAUSE_QUEST]; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_BOMBERS_NOTEBOOK) { + // Bombers Notebook + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursorItem = ITEM_BOMBERS_NOTEBOOK; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_SHIELD) { + // Shield + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD) != EQUIP_VALUE_SHIELD_NONE) { + cursorItem = (ITEM_SHIELD_HERO - EQUIP_TYPE_SHIELD) + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD); + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_SWORD) { + // Sword + if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) != EQUIP_VALUE_SWORD_NONE) { + cursorItem = + (ITEM_SWORD_KOKIRI - EQUIP_VALUE_SWORD_KOKIRI) + GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD); + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] <= QUEST_SONG_SUN) { + // Songs + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursorItem = ITEM_WALLET_GIANT + pauseCtx->cursorPoint[PAUSE_QUEST]; + } else if ((pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_SONG_LULLABY) && + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO)) { + cursorItem = ITEM_SONG_LULLABY_INTRO; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_QUIVER) { + // Quiver Upgrade + if (GET_CUR_UPG_VALUE(UPG_QUIVER) != 0) { + cursorItem = (ITEM_QUIVER_30 - 1) + GET_CUR_UPG_VALUE(UPG_QUIVER); + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_BOMB_BAG) { + // Bomb Bag Upgrade + if (GET_CUR_UPG_VALUE(UPG_BOMB_BAG) != 0) { + cursorItem = (ITEM_BOMB_BAG_20 - 1) + GET_CUR_UPG_VALUE(UPG_BOMB_BAG); + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } else { + // Heart Piece Count + if ((GET_SAVE_INVENTORY_QUEST_ITEMS >> QUEST_HEART_PIECE_COUNT) != 0) { + cursorItem = ITEM_HEART_CONTAINER; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + } + + cursor = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = cursor; + + if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (pauseCtx->state == PAUSE_STATE_MAIN) && + (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && (pauseCtx->cursorSpecialPos == 0)) { + if ((cursor >= QUEST_SONG_SONATA) && (cursor <= QUEST_SONG_SUN)) { + // Handle part of the ocarina songs playback + if ((CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST]) || + ((cursor == QUEST_SONG_LULLABY) && !CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST]) && + CHECK_QUEST_ITEM(QUEST_SONG_LULLABY_INTRO))) && + (msgCtx->msgLength == 0)) { + // The cursor is on a learned song + // Set some things up for song playback + + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursor = pauseCtx->cursorSlot[PAUSE_QUEST]; + } else { + cursor = QUEST_BOMB_BAG; + } + + pauseCtx->ocarinaSongIndex = gOcarinaSongItemMap[cursor - QUEST_SONG_SONATA]; + sQuestSongPlaybackDelayTimer = 10; + + for (i = 0; i < 8; i++) { + sQuestSongPlayedOcarinaButtons[i] = OCARINA_BTN_INVALID; + sQuestSongPlayedOcarinaButtonsAlpha[i] = 0; + } + + sQuestSongPlayedOcarinaButtonsNum = 0; + + // Setup the song to receive user input, immediately cancelled below + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_StartDefault((1 << pauseCtx->ocarinaSongIndex) | 0x80000000); + + // Clear the playback staff + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + pauseCtx->ocarinaStaff->pos = 0; + pauseCtx->ocarinaStaff->state = 0xFF; + + pauseCtx->ocarinaButtonsY[OCARINA_BTN_A] = -62; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_DOWN] = -56; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_RIGHT] = -49; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_LEFT] = -46; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_UP] = -41; + + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG; + + if (interfaceCtx->unk_212 != 6) { + func_8011552C(play, DO_ACTION_DECIDE); + } + + // Stop receiving input to play a song as mentioned above + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } else { + if (interfaceCtx->unk_212 != 6) { + func_8011552C(play, DO_ACTION_DECIDE); + } + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } + } else { + if ((cursor == QUEST_BOMBERS_NOTEBOOK) && (pauseCtx->cursorItem[PAUSE_QUEST] != PAUSE_ITEM_NONE)) { + if (interfaceCtx->unk_212 != 6) { + func_8011552C(play, DO_ACTION_DECIDE); + } + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_BLUE; + } else if (interfaceCtx->unk_212 == 6) { + func_8011552C(play, DO_ACTION_INFO); + } + + if ((pauseCtx->cursorItem[PAUSE_QUEST] != PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && (msgCtx->msgLength == 0)) { + if (pauseCtx->cursorPoint[PAUSE_QUEST] == QUEST_BOMBERS_NOTEBOOK) { + play->pauseCtx.bombersNotebookOpen = true; + pauseCtx->mainState = PAUSE_MAIN_STATE_BOMBERS_NOTEBOOK_OPEN; + play_sound(NA_SE_SY_DECIDE); + } else { + pauseCtx->itemDescriptionOn = true; + if (pauseCtx->cursorYIndex[PAUSE_QUEST] < 2) { + if (pauseCtx->cursorItem[PAUSE_QUEST] < ITEM_REMAINS_ODOLWA) { + func_801514B0(play, 0x1737 + pauseCtx->cursorItem[PAUSE_QUEST], 1); + } else { + func_801514B0(play, 0x173B + pauseCtx->cursorItem[PAUSE_QUEST], 3); + } + } else { + if (pauseCtx->cursorItem[PAUSE_QUEST] < ITEM_REMAINS_ODOLWA) { + func_801514B0(play, 0x1737 + pauseCtx->cursorItem[PAUSE_QUEST], 1); + } else { + func_801514B0(play, 0x173B + pauseCtx->cursorItem[PAUSE_QUEST], 1); + } + } + } + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } + } else if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) { + // Abort reading ocarina song input if the stick is moved + if ((pauseCtx->stickAdjX != 0) || (pauseCtx->stickAdjY != 0)) { + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + } else if ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG) && + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && (msgCtx->msgLength == 0) && + (cursor >= QUEST_SONG_SONATA) && (cursor <= QUEST_SONG_SUN)) { + pauseCtx->mainState = PAUSE_MAIN_STATE_SONG_PLAYBACK_INIT; + sQuestSongPlaybackDelayTimer = 10; + } + + if (pauseCtx->cursorSpecialPos == 0) { + if ((pauseCtx->cursorSlot[PAUSE_QUEST] >= 6) && (pauseCtx->cursorSlot[PAUSE_QUEST] < 0x12) && + ((pauseCtx->mainState <= PAUSE_MAIN_STATE_SONG_PLAYBACK) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG)) && + (pauseCtx->cursorItem[pauseCtx->pageIndex] != PAUSE_ITEM_NONE)) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_BLUE; + if ((pauseCtx->mainState >= PAUSE_MAIN_STATE_SONG_PLAYBACK) && + (pauseCtx->mainState <= PAUSE_MAIN_STATE_SONG_PROMPT_DONE)) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + } + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickAdjX > 30) { + if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + + func_80821A04(play); + + pauseCtx->cursorPoint[PAUSE_QUEST] = QUEST_BOMBERS_NOTEBOOK; + if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) { + cursorItem = ITEM_BOMBERS_NOTEBOOK; + } else { + cursorItem = PAUSE_ITEM_NONE; + } + + cursor = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = cursor; + } + } else if (pauseCtx->stickAdjX < -30) { + if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PROMPT) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + + func_80821A04(play); + + pauseCtx->cursorPoint[PAUSE_QUEST] = QUEST_REMAINS_GOHT; + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursorItem = (ITEM_REMAINS_GOHT - 1) + pauseCtx->cursorPoint[PAUSE_QUEST]; + if (pauseCtx->cursorPoint[PAUSE_QUEST] != QUEST_REMAINS_ODOLWA) { + // This condition is always true as `cursorPoint` is set three lines above + cursorItem = ITEM_MASK_GIANT; + } + } else { + cursorItem = PAUSE_ITEM_NONE; + } + + cursor = pauseCtx->cursorPoint[PAUSE_QUEST]; + pauseCtx->cursorItem[pauseCtx->pageIndex] = cursorItem; + pauseCtx->cursorSlot[pauseCtx->pageIndex] = cursor; + } + } else if (pauseCtx->mainState == PAUSE_MAIN_STATE_SONG_PLAYBACK_INIT) { + // After a short delay, start the playback of the selected song + + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_BLUE; + sQuestSongPlaybackDelayTimer--; + if (sQuestSongPlaybackDelayTimer == 0) { + for (i = 0; i < 8; i++) { + sQuestSongPlayedOcarinaButtons[i] = OCARINA_BTN_INVALID; + sQuestSongPlayedOcarinaButtonsAlpha[i] = 0; + } + sQuestSongPlayedOcarinaButtonsNum = 0; + + pauseCtx->ocarinaButtonsY[OCARINA_BTN_A] = -62; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_DOWN] = -56; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_RIGHT] = -49; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_LEFT] = -46; + pauseCtx->ocarinaButtonsY[OCARINA_BTN_C_UP] = -41; + + if (CHECK_QUEST_ITEM(pauseCtx->cursorPoint[PAUSE_QUEST])) { + cursor = pauseCtx->cursorSlot[PAUSE_QUEST]; + } else { + cursor = QUEST_BOMB_BAG; + } + + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); + pauseCtx->ocarinaSongIndex = gOcarinaSongItemMap[cursor - QUEST_SONG_SONATA]; + AudioOcarina_SetPlaybackSong(pauseCtx->ocarinaSongIndex + 1, 1); + pauseCtx->mainState = PAUSE_MAIN_STATE_SONG_PLAYBACK; + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + pauseCtx->ocarinaStaff->pos = 0; + } + } +} + +s32 KaleidoScope_UpdateQuestStatusPoint(PauseContext* pauseCtx, s16 point) { + pauseCtx->cursorPoint[PAUSE_QUEST] = point; + + return true; +} 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..b8858b7ca 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 { + /* 0x0 */ s16 screenX; + /* 0x2 */ s16 screenY; + /* 0x4 */ s16 width; +} SectionPosition; // size = 0x6; -#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_ODOLWA + 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->stickAdjX = input->rel.stick_x; + pauseCtx->stickAdjY = 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) { + CUR_FORM_EQUIP(EQUIP_SLOT_B) = value + (ITEM_SWORD_KOKIRI - 1); + gSaveContext.save.playerData.swordHealth = 100; + } else { + CUR_FORM_EQUIP(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); + + CUR_FORM_EQUIP(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..d1a358e75 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 @@ -1,27 +1,1001 @@ /* * File: z_kaleido_item.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu - Item Page */ #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 sEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B240.s") +// Timer to hold magic arrow icon over magic arrow slot before moving when equipping. +s16 sEquipMagicArrowSlotHoldTimer = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B6BC.s") +// Number of frames to move icon from slot to target position when equipping. +s16 sEquipAnimTimer = 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081B6EC.s") +u8 gPlayerFormSlotRestrictions[PLAYER_FORM_MAX][NUM_ITEM_SLOTS] = { + // Fierce Deity + { + false, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + false, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + false, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + false, // SLOT_PICTO_BOX + false, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + false, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 + }, + // Goron + { + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + true, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 + }, + // Zora + { + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + false, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 + }, + // Deku + { + true, // SLOT_OCARINA + false, // SLOT_BOW + false, // SLOT_ARROW_FIRE + false, // SLOT_ARROW_ICE + false, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + false, // SLOT_BOMB + false, // SLOT_BOMBCHU + false, // SLOT_STICK + true, // SLOT_NUT + false, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + false, // SLOT_HOOKSHOT + false, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 + }, + // Human + { + true, // SLOT_OCARINA + true, // SLOT_BOW + true, // SLOT_ARROW_FIRE + true, // SLOT_ARROW_ICE + true, // SLOT_ARROW_LIGHT + true, // SLOT_TRADE_DEED + true, // SLOT_BOMB + true, // SLOT_BOMBCHU + true, // SLOT_STICK + true, // SLOT_NUT + true, // SLOT_MAGIC_BEANS + true, // SLOT_TRADE_KEY_MAMA + false, // SLOT_POWDER_KEG + true, // SLOT_PICTO_BOX + true, // SLOT_LENS + true, // SLOT_HOOKSHOT + true, // SLOT_SWORD_GREAT_FAIRY + true, // SLOT_TRADE_COUPLE + true, // SLOT_BOTTLE_1 + true, // SLOT_BOTTLE_2 + true, // SLOT_BOTTLE_3 + true, // SLOT_BOTTLE_4 + true, // SLOT_BOTTLE_5 + true, // SLOT_BOTTLE_6 + }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081BCA8.s") +s16 sAmmoRectLeft[] = { + 95, // SLOT_BOW + 62, // SLOT_BOMB + 95, // SLOT_BOMBCHU + 128, // SLOT_STICK + 161, // SLOT_NUT + 194, // SLOT_MAGIC_BEANS + 62, // SLOT_POWDER_KEG + 95, // SLOT_PICTO_BOX +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081C684.s") +s16 sAmmoRectHeight[] = { + 85, // SLOT_BOW + 117, // SLOT_BOMB + 117, // SLOT_BOMBCHU + 117, // SLOT_STICK + 117, // SLOT_NUT + 117, // SLOT_MAGIC_BEANS + 150, // SLOT_POWDER_KEG + 150, // SLOT_PICTO_BOX +}; + +void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item, u16 ammoIndex) { + s16 ammoUpperDigit; + s16 ammo; + + OPEN_DISPS(gfxCtx); + + if (item == ITEM_PICTO_BOX) { + if (!CHECK_QUEST_ITEM(QUEST_PICTOGRAPH)) { + ammo = 0; + } else { + ammo = 1; + } + } else { + ammo = AMMO(item); + } + + gDPPipeSync(POLY_OPA_DISP++); + + if (!gPlayerFormSlotRestrictions[((void)0, gSaveContext.save.playerForm)][SLOT(item)]) { + // Ammo item is restricted + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 100, 100, 100, pauseCtx->alpha); + } else { + // Default ammo + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + if (ammo == 0) { + // Out of ammo + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 130, 130, 130, pauseCtx->alpha); + } else if (((item == ITEM_BOMB) && (AMMO(item) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((item == ITEM_BOW) && (AMMO(item) == CUR_CAPACITY(UPG_QUIVER))) || + ((item == ITEM_STICK) && (AMMO(item) == CUR_CAPACITY(UPG_STICKS))) || + ((item == ITEM_NUT) && (AMMO(item) == CUR_CAPACITY(UPG_NUTS))) || + ((item == ITEM_BOMBCHU) && (AMMO(item) == CUR_CAPACITY(UPG_BOMB_BAG))) || + ((item == ITEM_POWDER_KEG) && (ammo == 1)) || ((item == ITEM_PICTO_BOX) && (ammo == 1)) || + ((item == ITEM_MAGIC_BEANS) && (ammo == 20))) { + // Ammo at capacity + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 120, 255, 0, pauseCtx->alpha); + } + } + + // Separate ammo into upper and lower digits + for (ammoUpperDigit = 0; ammo >= 10; ammoUpperDigit++) { + ammo -= 10; + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw upper digit + if (ammoUpperDigit != 0) { + POLY_OPA_DISP = + Gfx_DrawTexRectIA8(POLY_OPA_DISP, ((u8*)gAmmoDigit0Tex + (8 * 8 * ammoUpperDigit)), 8, 8, + sAmmoRectLeft[ammoIndex], sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); + } + + // Draw lower digit + POLY_OPA_DISP = + Gfx_DrawTexRectIA8(POLY_OPA_DISP, ((u8*)gAmmoDigit0Tex + (8 * 8 * ammo)), 8, 8, sAmmoRectLeft[ammoIndex] + 6, + sAmmoRectHeight[ammoIndex], 8, 8, 1 << 10, 1 << 10); + + CLOSE_DISPS(gfxCtx); +} + +void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx) { + pauseCtx->cursorVtx[0].v.ob[0] = vtx[index].v.ob[0]; + pauseCtx->cursorVtx[0].v.ob[1] = vtx[index].v.ob[1]; +} + +s16 sMagicArrowEffectsR[] = { 255, 100, 255 }; +s16 sMagicArrowEffectsG[] = { 0, 100, 255 }; +s16 sMagicArrowEffectsB[] = { 0, 255, 100 }; + +void KaleidoScope_DrawItemSelect(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; + u16 i; + u16 j; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C8AC(play->state.gfxCtx); + + // Draw a white box around the items that are equipped on the C buttons + // Loop over c-buttons (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + for (i = 0, j = NUM_ITEM_SLOTS * 4; i < 3; i++, j += 4) { + if (GET_CUR_FORM_BTN_ITEM(i + 1) != ITEM_NONE) { + if (GET_CUR_FORM_BTN_SLOT(i + 1) < NUM_ITEM_SLOTS) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j], 4, 0); + POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, gEquippedItemOutlineTex, 32, 32, 0); + } + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw the item icons + // Loop over slots (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + for (j = 0, i = 0; i < NUM_ITEM_SLOTS; i++, j += 4) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (((void)0, gSaveContext.save.inventory.items[i]) != ITEM_NONE) { + if ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && (pauseCtx->pageIndex == PAUSE_ITEM) && + (pauseCtx->cursorSpecialPos == 0) && + gPlayerFormSlotRestrictions[(void)0, gSaveContext.save.playerForm][i]) { + if ((sEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) && (i == SLOT_ARROW_ICE)) { + // Possible bug: + // Supposed to be `SLOT_BOW`, unchanged from OoT, instead increase size of ice arrow icon + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sMagicArrowEffectsR[pauseCtx->equipTargetItem - 0xB5], + sMagicArrowEffectsG[pauseCtx->equipTargetItem - 0xB5], + sMagicArrowEffectsB[pauseCtx->equipTargetItem - 0xB5], pauseCtx->alpha); + + pauseCtx->itemVtx[j + 0].v.ob[0] = pauseCtx->itemVtx[j + 2].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] - 2; + pauseCtx->itemVtx[j + 1].v.ob[0] = pauseCtx->itemVtx[j + 3].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] + 32; + pauseCtx->itemVtx[j + 0].v.ob[1] = pauseCtx->itemVtx[j + 1].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] + 2; + pauseCtx->itemVtx[j + 2].v.ob[1] = pauseCtx->itemVtx[j + 3].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] - 32; + + } else if (i == pauseCtx->cursorSlot[PAUSE_ITEM]) { + // Increase the size of the selected item + pauseCtx->itemVtx[j + 0].v.ob[0] = pauseCtx->itemVtx[j + 2].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] - 2; + pauseCtx->itemVtx[j + 1].v.ob[0] = pauseCtx->itemVtx[j + 3].v.ob[0] = + pauseCtx->itemVtx[j + 0].v.ob[0] + 32; + pauseCtx->itemVtx[j + 0].v.ob[1] = pauseCtx->itemVtx[j + 1].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] + 2; + pauseCtx->itemVtx[j + 2].v.ob[1] = pauseCtx->itemVtx[j + 3].v.ob[1] = + pauseCtx->itemVtx[j + 0].v.ob[1] - 32; + } + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->itemVtx[j + 0], 4, 0); + KaleidoScope_DrawTexQuadRGBA32(play->state.gfxCtx, + gItemIcons[((void)0, gSaveContext.save.inventory.items[i])], 32, 32, 0); + } + } + + // Draw the ammo digits + if (pauseCtx->pageIndex == PAUSE_ITEM) { + if ((pauseCtx->state == PAUSE_STATE_MAIN) && + ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) || (pauseCtx->mainState == PAUSE_MAIN_STATE_EQUIP_ITEM)) && + (pauseCtx->state != PAUSE_STATE_SAVEPROMPT) && !IS_PAUSE_STATE_GAMEOVER) { + func_8012C628(play->state.gfxCtx); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + // Loop over slots (i) and ammoIndex (j) + for (j = 0, i = 0; i < NUM_ITEM_SLOTS; i++) { + if (gAmmoItems[i] != ITEM_NONE) { + if (((void)0, gSaveContext.save.inventory.items[i]) != ITEM_NONE) { + KaleidoScope_DrawAmmoCount(pauseCtx, play->state.gfxCtx, + ((void)0, gSaveContext.save.inventory.items[i]), j); + } + j++; + } + } + func_8012C8AC(play->state.gfxCtx); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +u8 sPlayerFormItems[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_NONE, +}; + +void KaleidoScope_UpdateItemCursor(PlayState* play) { + s32 pad1; + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + u16 vtxIndex; + u16 cursorItem; + u16 cursorSlot; + u8 magicArrowIndex; + s16 cursorPoint; + s16 cursorXIndex; + s16 cursorYIndex; + s16 oldCursorPoint; + s16 moveCursorResult; + s16 pad2; + + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + pauseCtx->nameColorSet = PAUSE_NAME_COLOR_SET_WHITE; + + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (pauseCtx->pageIndex == PAUSE_ITEM) && !pauseCtx->itemDescriptionOn) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + + cursorItem = pauseCtx->cursorItem[PAUSE_ITEM]; + + // Move cursor left/right + if (pauseCtx->cursorSpecialPos == 0) { + // cursor is currently on a slot + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; + + if (ABS_ALT(pauseCtx->stickAdjX) > 30) { + cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + cursorXIndex = pauseCtx->cursorXIndex[PAUSE_ITEM]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_ITEM]; + + // Search for slot to move to + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjX < -30) { + // move cursor left + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorXIndex[PAUSE_ITEM] != 0) { + pauseCtx->cursorXIndex[PAUSE_ITEM]--; + pauseCtx->cursorPoint[PAUSE_ITEM]--; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM]++; + + if (pauseCtx->cursorYIndex[PAUSE_ITEM] >= 4) { + pauseCtx->cursorYIndex[PAUSE_ITEM] = 0; + } + + pauseCtx->cursorPoint[PAUSE_ITEM] = + pauseCtx->cursorXIndex[PAUSE_ITEM] + (pauseCtx->cursorYIndex[PAUSE_ITEM] * 6); + + if (pauseCtx->cursorPoint[PAUSE_ITEM] >= NUM_ITEM_SLOTS) { + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM]; + } + + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_ITEM]) { + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + } + } + } else if (pauseCtx->stickAdjX > 30) { + // move cursor right + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorXIndex[PAUSE_ITEM] <= 4) { + pauseCtx->cursorXIndex[PAUSE_ITEM]++; + pauseCtx->cursorPoint[PAUSE_ITEM]++; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM]++; + + if (pauseCtx->cursorYIndex[PAUSE_ITEM] >= 4) { + pauseCtx->cursorYIndex[PAUSE_ITEM] = 0; + } + + pauseCtx->cursorPoint[PAUSE_ITEM] = + pauseCtx->cursorXIndex[PAUSE_ITEM] + (pauseCtx->cursorYIndex[PAUSE_ITEM] * 6); + + if (pauseCtx->cursorPoint[PAUSE_ITEM] >= NUM_ITEM_SLOTS) { + pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorXIndex[PAUSE_ITEM]; + } + + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_ITEM]) { + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + } + } + } + } + + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickAdjX > 30) { + func_80821A04(play); + cursorYIndex = 0; + cursorXIndex = 0; + cursorPoint = 0; // top row, left column (SLOT_OCARINA) + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + break; + } + + // move 1 row down and retry + cursorYIndex++; + cursorPoint += 6; + if (cursorYIndex < 4) { + continue; + } + + // move 1 column right and retry + cursorYIndex = 0; + cursorPoint = cursorXIndex + 1; + cursorXIndex = cursorPoint; + if (cursorXIndex < 6) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } + } else { // PAUSE_CURSOR_PAGE_RIGHT + if (pauseCtx->stickAdjX < -30) { + func_80821A04(play); + cursorXIndex = 5; + cursorPoint = 5; // top row, right columne (SLOT_TRADE_DEED) + cursorYIndex = 0; + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if (gSaveContext.save.inventory.items[cursorPoint] != ITEM_NONE) { + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + pauseCtx->cursorXIndex[PAUSE_ITEM] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + break; + } + + // move 1 row down and retry + cursorYIndex++; + cursorPoint += 6; + if (cursorYIndex < 4) { + continue; + } + + // move 1 column left and retry + cursorYIndex = 0; + cursorPoint = cursorXIndex - 1; + cursorXIndex = cursorPoint; + if (cursorXIndex >= 0) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + // move cursor up/down + if (ABS_ALT(pauseCtx->stickAdjY) > 30) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; + + cursorPoint = pauseCtx->cursorPoint[PAUSE_ITEM]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_ITEM]; + + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjY > 30) { + // move cursor up + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] != 0) { + pauseCtx->cursorYIndex[PAUSE_ITEM]--; + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + } + } else if (pauseCtx->stickAdjY < -30) { + // move cursor down + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] < 3) { + pauseCtx->cursorYIndex[PAUSE_ITEM]++; + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorPoint[PAUSE_ITEM] += 6; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_ITEM] = cursorYIndex; + pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; + } + } + } + } + + cursorSlot = pauseCtx->cursorPoint[PAUSE_ITEM]; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; + + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } else if (moveCursorResult != PAUSE_CURSOR_RESULT_SPECIAL_POS) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]]; + } + + if (cursorItem == ITEM_NONE) { + cursorItem = PAUSE_ITEM_NONE; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + } + + if ((cursorItem != (u32)PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + + pauseCtx->cursorItem[PAUSE_ITEM] = cursorItem; + pauseCtx->cursorSlot[PAUSE_ITEM] = cursorSlot; + if (cursorItem != PAUSE_ITEM_NONE) { + // Equip item to the C buttons + if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && !pauseCtx->itemDescriptionOn && + (pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + CHECK_BTN_ANY(CONTROLLER1(&play->state)->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { + + // Ensure that a transformation mask can not be unequipped while being used + if (gSaveContext.save.playerForm != PLAYER_FORM_HUMAN) { + if (1) {} + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CLEFT)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CDOWN)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CRIGHT)) { + if (sPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + play_sound(NA_SE_SY_ERROR); + return; + } + } + } + + // Ensure that a non-transformation mask can not be unequipped while being used + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CLEFT)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_LEFT; + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CDOWN)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_DOWN; + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_CRIGHT)) { + if ((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT))) { + play_sound(NA_SE_SY_ERROR); + return; + } + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_RIGHT; + } + + // Equip item to the C buttons + pauseCtx->equipTargetItem = cursorItem; + pauseCtx->equipTargetSlot = cursorSlot; + pauseCtx->mainState = PAUSE_MAIN_STATE_EQUIP_ITEM; + vtxIndex = cursorSlot * 4; + pauseCtx->equipAnimX = pauseCtx->itemVtx[vtxIndex].v.ob[0] * 10; + pauseCtx->equipAnimY = pauseCtx->itemVtx[vtxIndex].v.ob[1] * 10; + pauseCtx->equipAnimAlpha = 255; + sEquipMagicArrowSlotHoldTimer = 0; + sEquipState = EQUIP_STATE_MOVE_TO_C_BTN; + sEquipAnimTimer = 10; + + if ((pauseCtx->equipTargetItem == ITEM_ARROW_FIRE) || + (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) || + (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT)) { + magicArrowIndex = 0; + if (pauseCtx->equipTargetItem == ITEM_ARROW_ICE) { + magicArrowIndex = 1; + } + if (pauseCtx->equipTargetItem == ITEM_ARROW_LIGHT) { + magicArrowIndex = 2; + } + play_sound(NA_SE_SY_SET_FIRE_ARROW + magicArrowIndex); + pauseCtx->equipTargetItem = 0xB5 + magicArrowIndex; + pauseCtx->equipAnimAlpha = sEquipState = 0; // EQUIP_STATE_MAGIC_ARROW_GROW_ORB + sEquipAnimTimer = 6; + } else { + play_sound(NA_SE_SY_DECIDE); + } + } else if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (pauseCtx->state == PAUSE_STATE_MAIN) && + (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && (msgCtx->msgLength == 0)) { + // Give description on item through a message box + pauseCtx->itemDescriptionOn = true; + if (pauseCtx->cursorYIndex[PAUSE_ITEM] < 2) { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 3); + } else { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_ITEM], 1); + } + } + } + } else { + pauseCtx->cursorItem[PAUSE_ITEM] = PAUSE_ITEM_NONE; + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_ITEM]) { + play_sound(NA_SE_SY_CURSOR); + } + } else if ((pauseCtx->mainState == PAUSE_MAIN_STATE_EQUIP_ITEM) && (pauseCtx->pageIndex == PAUSE_ITEM)) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; + } +} + +s16 sCButtonPosX[] = { 660, 900, 1140 }; +s16 sCButtonPosY[] = { 1100, 920, 1100 }; + +void KaleidoScope_UpdateItemEquip(PlayState* play) { + static s16 sEquipMagicArrowBowSlotHoldTimer = 0; + PauseContext* pauseCtx = &play->pauseCtx; + Vtx* bowItemVtx; + u16 offsetX; + u16 offsetY; + + // Grow glowing orb when equipping magic arrows + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_GROW_ORB) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + sEquipState++; + } + // Hover over magic arrow slot when the next state is reached + sEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) { + sEquipMagicArrowBowSlotHoldTimer--; + + if (sEquipMagicArrowBowSlotHoldTimer == 0) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + sEquipAnimTimer = 6; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + sEquipState++; + play_sound(NA_SE_SY_SYNTH_MAGIC_ARROW); + } + return; + } + + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + bowItemVtx = &pauseCtx->itemVtx[4]; + offsetX = ABS_ALT(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sEquipAnimTimer; + } else { + offsetX = ABS_ALT(pauseCtx->equipAnimX - sCButtonPosX[pauseCtx->equipTargetCBtn]) / sEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - sCButtonPosY[pauseCtx->equipTargetCBtn]) / sEquipAnimTimer; + } + + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipAnimAlpha < 254)) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + } + sEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimScale -= pauseCtx->equipAnimShrinkRate / sEquipAnimTimer; + pauseCtx->equipAnimShrinkRate -= pauseCtx->equipAnimShrinkRate / sEquipAnimTimer; + + // Update coordinates of item icon while being equipped + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + // target is the bow slot + if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[4].v.ob[0] * 10)) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[4].v.ob[1] * 10)) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } else { + // target is the c button + if (pauseCtx->equipAnimX >= sCButtonPosX[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= sCButtonPosY[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } + + sEquipAnimTimer--; + if (sEquipAnimTimer == 0) { + if (sEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + sEquipState++; + sEquipMagicArrowBowSlotHoldTimer = 4; + return; + } + + // Equip item onto c buttons + if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_LEFT) { + // Swap if item is already equipped on CDown or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } + + // Equip item on CLeft + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + } else if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_DOWN) { + // Swap if item is already equipped on CLeft or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } + } + + // Equip item on CDown + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + } else { // (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_RIGHT) + // Swap if item is already equipped on CLeft or CDown. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8) && + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) == ITEM_BOW) || + (((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) >= ITEM_BOW_ARROW_FIRE) && + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) <= ITEM_BOW_ARROW_LIGHT)))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } + + // Special case for magic arrows + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipTargetItem < 0xB8)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) == ITEM_BOW) || + ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) <= ITEM_BOW_ARROW_LIGHT))) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + } + } else if (pauseCtx->equipTargetItem == ITEM_BOW) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) >= ITEM_BOW_ARROW_FIRE) && + (BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) <= ITEM_BOW_ARROW_LIGHT)) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } + } + + // Equip item on CRight + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + } + + // Reset params + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + sEquipAnimTimer = 10; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + } + } else { + sEquipMagicArrowSlotHoldTimer--; + if (sEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimAlpha = 255; + } + } +} 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..87acfaa6c 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 @@ -1,27 +1,977 @@ /* * File: z_kaleido_map.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu: Map Page */ #include "z_kaleido_scope.h" +#include "interface/parameter_static/parameter_static.h" +#include "interface/icon_item_field_static/icon_item_field_static.h" +#include "interface/icon_item_dungeon_static/icon_item_dungeon_static.h" +#include "interface/icon_item_jpn_static/icon_item_jpn_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; +extern s16 D_8082B7F0[]; +extern s16 D_8082B838[]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081D240.s") +extern TexturePtr D_09007500; // gPlayerFaceIcon -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081D6DC.s") +#define WORLD_MAP_IMAGE_TEX_WIDTH 216 +#define WORLD_MAP_IMAGE_TEX_HEIGHT 128 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081E118.s") +void KaleidoScope_DrawDungeonStrayFairyCount(PlayState* play) { + s16 counterDigits[2]; + s16 rectLeft; + s16 digitIndex; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081E7D8.s") + OPEN_DISPS(play->state.gfxCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081FB1C.s") + // Get digits for max number of stray fairies + counterDigits[1] = 15; + counterDigits[0] = counterDigits[1] / 10; + counterDigits[1] -= (s16)(counterDigits[0] * 10); + + // Draw max number of stray fairies + for (rectLeft = 116, digitIndex = 0; digitIndex < 2; digitIndex++, rectLeft += 8) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 255); + + POLY_OPA_DISP = Gfx_DrawTexRectI8(POLY_OPA_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[digitIndex]), + 8, 16, rectLeft + 1, 146, 8, 16, 1 << 10, 1 << 10); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + gSPTextureRectangle(POLY_OPA_DISP++, rectLeft * 4, 145 << 2, (rectLeft + 8) * 4, 161 << 2, G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + } + + // Draw Counter slash + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 255); + + POLY_OPA_DISP = + Gfx_DrawTexRectI8(POLY_OPA_DISP, gStrayFairyMapCounterSlashTex, 8, 16, 107, 146, 8, 16, 1 << 10, 1 << 10); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + gSPTextureRectangle(POLY_OPA_DISP++, 106 << 2, 145 << 2, 114 << 2, 161 << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); + + // Get digits for current number of stray fairies collected + counterDigits[1] = gSaveContext.save.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex]; + counterDigits[0] = counterDigits[1] / 10; + counterDigits[1] -= (s16)(counterDigits[0] * 10); + + // Draw digits for current number of stray fairies collected + for (rectLeft = 88, digitIndex = 0; digitIndex < 2; digitIndex++, rectLeft += 8) { + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, 255); + + POLY_OPA_DISP = Gfx_DrawTexRectI8(POLY_OPA_DISP, (u8*)gCounterDigit0Tex + (8 * 16 * counterDigits[digitIndex]), + 8, 16, rectLeft + 1, 146, 8, 16, 1 << 10, 1 << 10); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + + gSPTextureRectangle(POLY_OPA_DISP++, rectLeft * 4, 145 << 2, (rectLeft + 8) * 4, 161 << 2, G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +TexturePtr sDungeonItemTextures[] = { + 0x09003600, // `gBossKeyIconTex`: DUNGEON_BOSS_KEY + 0x09003F00, // `gCompassIconTex`: DUNGEON_COMPASS + 0x09004800, // `gDungeonMapIconTex`: DUNGEON_MAP +}; + +TexturePtr sDungeonTitleTextures[] = { + gPauseWoodfallTitleENGTex, // DUNGEON_INDEX_WOODFALL_TEMPLE + gPauseSnowheadTitleENGTex, // DUNGEON_INDEX_SNOWHEAD_TEMPLE + gPauseGreatBayTitleENGTex, // DUNGEON_INDEX_GREAT_BAY_TEMPLE + gPauseStoneTowerTitleENGTex, // DUNGEON_INDEX_STONE_TOWER_TEMPLE +}; + +s16 sDungeonMapFloorIconPosY[] = { 67, 81, 95, 109, 123 }; + +void KaleidoScope_DrawDungeonMap(PlayState* play) { + static s16 sStrayFairyIconTimer = 30; + static s16 sStrayFairyIconIndex = 0; + static s16 sStrayFairyIconAlphaScaleTimer = 15; + static s16 sStrayFairyIconAlphaScaleState = 0; + static s16 sStrayFairyIconAlpha = 255; + static f32 sStrayFairyIconScale = 100.0f; + static TexturePtr sStrayFairyIconTextures[][4] = { + // DUNGEON_INDEX_WOODFALL_TEMPLE + { gStrayFairyWoodfallIconTex, gDungeonStrayFairyWoodfallIconTex, gStrayFairyWoodfallIconTex, + gDungeonStrayFairyWoodfallIconTex }, + // DUNGEON_INDEX_SNOWHEAD_TEMPLE + { gStrayFairySnowheadIconTex, gDungeonStrayFairySnowheadIconTex, gStrayFairySnowheadIconTex, + gDungeonStrayFairySnowheadIconTex }, + // DUNGEON_INDEX_GREAT_BAY_TEMPLE + { gStrayFairyGreatBayIconTex, gDungeonStrayFairyGreatBayIconTex, gStrayFairyGreatBayIconTex, + gDungeonStrayFairyGreatBayIconTex }, + // DUNGEON_INDEX_STONE_TOWER_TEMPLE + { gStrayFairyStoneTowerIconTex, gDungeonStrayFairyStoneTowerIconTex, gStrayFairyStoneTowerIconTex, + gDungeonStrayFairyStoneTowerIconTex }, + }; + static u8 sStrayFairyIconPrimColors[][3] = { + { 255, 110, 160 }, // DUNGEON_INDEX_WOODFALL_TEMPLE + { 90, 255, 100 }, // DUNGEON_INDEX_SNOWHEAD_TEMPLE + { 120, 255, 255 }, // DUNGEON_INDEX_GREAT_BAY_TEMPLE + { 245, 245, 90 }, // DUNGEON_INDEX_STONE_TOWER_TEMPLE + }; + static u8 sStrayFairyIconEnvColors[][3] = { + { 255, 255, 255 }, // DUNGEON_INDEX_WOODFALL_TEMPLE + { 255, 255, 255 }, // DUNGEON_INDEX_SNOWHEAD_TEMPLE + { 255, 255, 255 }, // DUNGEON_INDEX_GREAT_BAY_TEMPLE + { 225, 170, 0 }, // DUNGEON_INDEX_STONE_TOWER_TEMPLE + }; + static s32 sStrayFairyIconRectS[] = { + 1 << 10, // mirror texture horizontally + 0, // default + 0, // default + 0 // default + }; + PauseContext* pauseCtx = &play->pauseCtx; + s16 i; + s16 j; + f32 scale; + + OPEN_DISPS(play->state.gfxCtx); + + j = 72 + (pauseCtx->cursorSlot[PAUSE_MAP] * 4); + KaleidoScope_SetCursorVtx(pauseCtx, j, pauseCtx->mapPageVtx); + + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + if (pauseCtx->cursorSpecialPos == 0) { + if (pauseCtx->cursorPoint[PAUSE_MAP] <= DUNGEON_STRAY_FAIRIES) { + pauseCtx->cursorItem[PAUSE_MAP] = ITEM_KEY_BOSS + pauseCtx->cursorPoint[PAUSE_MAP]; + } + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP]; + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[60], 16, 0); + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA, G_CC_MODULATEIA); + + POLY_OPA_DISP = + Gfx_DrawTexQuadIA8(POLY_OPA_DISP, sDungeonTitleTextures[((void)0, gSaveContext.dungeonIndex)], 128, 16, 0); + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + // Loop over dungeonItems (i) and vtxIndex (j) + for (i = DUNGEON_BOSS_KEY, j = 4; i <= DUNGEON_STRAY_FAIRIES; i++, j += 4) { + if (i == DUNGEON_STRAY_FAIRIES) { + if ((pauseCtx->pageIndex == PAUSE_MAP) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { + // If (pauseCtx->state == PAUSE_STATE_MAIN), then the other conditions are redundant and + // always return true + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->state != PAUSE_STATE_SAVEPROMPT) && + !IS_PAUSE_STATE_GAMEOVER) { + KaleidoScope_SetView(pauseCtx, 0.0f, 0.0f, 64.0f); + + if (!sStrayFairyIconAlphaScaleState) { + sStrayFairyIconAlpha -= 6; + sStrayFairyIconScale -= 1.0f; + } else { + sStrayFairyIconAlpha += 6; + sStrayFairyIconScale += 1.0f; + } + + sStrayFairyIconAlphaScaleTimer--; + if (sStrayFairyIconAlphaScaleTimer == 0) { + sStrayFairyIconAlphaScaleState ^= 1; + sStrayFairyIconAlphaScaleTimer = 15; + } + + func_8012C8AC(play->state.gfxCtx); + + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, + PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, + 0); + + gDPSetPrimColor( + POLY_OPA_DISP++, 0, 0, sStrayFairyIconPrimColors[((void)0, gSaveContext.dungeonIndex)][0], + sStrayFairyIconPrimColors[((void)0, gSaveContext.dungeonIndex)][1], + sStrayFairyIconPrimColors[((void)0, gSaveContext.dungeonIndex)][2], sStrayFairyIconAlpha); + gDPSetEnvColor(POLY_OPA_DISP++, sStrayFairyIconEnvColors[((void)0, gSaveContext.dungeonIndex)][0], + sStrayFairyIconEnvColors[((void)0, gSaveContext.dungeonIndex)][1], + sStrayFairyIconEnvColors[((void)0, gSaveContext.dungeonIndex)][2], 0); + + scale = sStrayFairyIconScale / 100.0f; + + Matrix_Translate(-83.0f, -29.0f, -128.0f, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + pauseCtx->mapPageVtx[76].v.ob[0] = pauseCtx->mapPageVtx[78].v.ob[0] = -16; + + pauseCtx->mapPageVtx[77].v.ob[0] = pauseCtx->mapPageVtx[79].v.ob[0] = + pauseCtx->mapPageVtx[76].v.ob[0] + 32; + + pauseCtx->mapPageVtx[76].v.ob[1] = pauseCtx->mapPageVtx[77].v.ob[1] = 12; + + pauseCtx->mapPageVtx[78].v.ob[1] = pauseCtx->mapPageVtx[79].v.ob[1] = + pauseCtx->mapPageVtx[76].v.ob[1] - 24; + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[76], 4, 0); + + POLY_OPA_DISP = + Gfx_DrawTexQuad4b(POLY_OPA_DISP, gStrayFairyGlowingCircleIconTex, G_IM_FMT_I, 32, 24, 0); + KaleidoScope_SetView(pauseCtx, pauseCtx->eye.x, pauseCtx->eye.y, pauseCtx->eye.z); + func_8012C628(play->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, sStrayFairyIconAlpha); + + sStrayFairyIconTimer--; + + if (sStrayFairyIconTimer == 0) { + sStrayFairyIconIndex = (sStrayFairyIconIndex + 1) & 3; + sStrayFairyIconTimer = 34; + } + + gDPLoadTextureBlock( + POLY_OPA_DISP++, + sStrayFairyIconTextures[((void)0, gSaveContext.dungeonIndex)][sStrayFairyIconIndex], + G_IM_FMT_RGBA, G_IM_SIZ_32b, 32, 24, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 5, + G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + gSPTextureRectangle(POLY_OPA_DISP++, 54 << 2, 140 << 2, 86 << 2, 164 << 2, G_TX_RENDERTILE, + sStrayFairyIconRectS[sStrayFairyIconIndex], 0, 1 << 10, 1 << 10); + + KaleidoScope_DrawDungeonStrayFairyCount(play); + func_8012C8AC(play->state.gfxCtx); + } + } + } else if (CHECK_DUNGEON_ITEM(i, gSaveContext.dungeonIndex)) { + gDPLoadTextureBlock(POLY_OPA_DISP++, sDungeonItemTextures[i], G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 24, 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); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + } + } + + func_80108AF8(play); + + if ((pauseCtx->pageIndex == PAUSE_MAP) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE)) { + // If (pauseCtx->state == PAUSE_STATE_MAIN), then the other conditions are redundant and always return + // true + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->state != PAUSE_STATE_SAVEPROMPT) && + !IS_PAUSE_STATE_GAMEOVER) { + + func_8012C628(play->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + // Draw Player's face next to the dungeon floor icon currently in. + POLY_OPA_DISP = + Gfx_DrawTexRectRGBA16(POLY_OPA_DISP, &D_09007500, 16, 16, 62, + sDungeonMapFloorIconPosY[R_REVERSE_FLOOR_INDEX], 16, 16, 1 << 10, 1 << 10); + + if (CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, gSaveContext.dungeonIndex)) { + POLY_OPA_DISP = Gfx_DrawTexRectRGBA16(POLY_OPA_DISP, gDungeonMapSkullTex, 16, 16, 108, + sDungeonMapFloorIconPosY[FLOOR_INDEX_MAX - func_80105318()], 16, + 16, 1 << 10, 1 << 10); + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + func_8012C8AC(play->state.gfxCtx); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void KaleidoScope_UpdateDungeonCursor(PlayState* play) { + s32 pad; + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + s16 i; + s16 oldCursorPoint; + + if (pauseCtx->state == PAUSE_STATE_MAIN) { + if ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && (pauseCtx->pageIndex == PAUSE_MAP)) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MAP]; + if (pauseCtx->stickAdjX > 30) { + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + func_80821A04(play); + pauseCtx->cursorXIndex[PAUSE_MAP] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->unk_256; + pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->unk_256; + } else if (pauseCtx->cursorSpecialPos == 0) { + if (pauseCtx->cursorXIndex[PAUSE_MAP] == 0) { + pauseCtx->cursorXIndex[PAUSE_MAP] = 1; + pauseCtx->cursorPoint[PAUSE_MAP] = DUNGEON_STRAY_FAIRIES; + } else { + if (pauseCtx->cursorPoint[PAUSE_MAP] == DUNGEON_STRAY_FAIRIES) { + pauseCtx->cursorPoint[PAUSE_MAP] = DUNGEON_NONE; + } + + while (true) { + pauseCtx->cursorPoint[PAUSE_MAP]++; + if (pauseCtx->cursorPoint[PAUSE_MAP] == DUNGEON_STRAY_FAIRIES) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + if (CHECK_DUNGEON_ITEM(pauseCtx->cursorPoint[PAUSE_MAP], gSaveContext.dungeonIndex)) { + break; + } + } + } + } + } else if (pauseCtx->stickAdjX < -30) { + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT) { + func_80821A04(play); + pauseCtx->cursorXIndex[PAUSE_MAP] = 1; + pauseCtx->cursorPoint[PAUSE_MAP] = DUNGEON_MAP; + if (!CHECK_DUNGEON_ITEM(DUNGEON_MAP, gSaveContext.dungeonIndex)) { + pauseCtx->cursorPoint[PAUSE_MAP]--; // DUNGEON_COMPASS + if (!CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, gSaveContext.dungeonIndex)) { + pauseCtx->cursorPoint[PAUSE_MAP]--; // DUNGEON_BOSS_KEY + if (!CHECK_DUNGEON_ITEM(DUNGEON_BOSS_KEY, gSaveContext.dungeonIndex)) { + pauseCtx->cursorSlot[PAUSE_MAP] = DUNGEON_STRAY_FAIRIES; + pauseCtx->cursorPoint[PAUSE_MAP] = DUNGEON_STRAY_FAIRIES; + } + } + } else { + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_MAP]; + } + } else if (pauseCtx->cursorSpecialPos == 0) { + if (pauseCtx->cursorXIndex[PAUSE_MAP] == 0) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + } else if (pauseCtx->cursorPoint[PAUSE_MAP] == DUNGEON_STRAY_FAIRIES) { + pauseCtx->cursorXIndex[PAUSE_MAP] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->unk_256; + pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->unk_256; + } else { + while (true) { + pauseCtx->cursorPoint[PAUSE_MAP]--; + if (pauseCtx->cursorPoint[PAUSE_MAP] <= DUNGEON_NONE) { + pauseCtx->cursorSlot[PAUSE_MAP] = DUNGEON_STRAY_FAIRIES; + pauseCtx->cursorPoint[PAUSE_MAP] = DUNGEON_STRAY_FAIRIES; + break; + } + if (CHECK_DUNGEON_ITEM(pauseCtx->cursorPoint[PAUSE_MAP], gSaveContext.dungeonIndex)) { + break; + } + } + } + } + } else if ((pauseCtx->cursorSpecialPos == 0) && (pauseCtx->stickAdjY > 30)) { + if (pauseCtx->cursorPoint[PAUSE_MAP] >= DUNGEON_FLOOR_INDEX_4) { + for (i = pauseCtx->cursorPoint[PAUSE_MAP] - (DUNGEON_FLOOR_INDEX_4 + 1); i >= 0; i--) { + if ((gSaveContext.save.permanentSceneFlags[(void)0, gSaveContext.dungeonIndex].unk_14 & + gBitFlags[i]) || + func_801090B0(FLOOR_INDEX_MAX - i)) { + pauseCtx->cursorPoint[PAUSE_MAP] = i + DUNGEON_FLOOR_INDEX_4; + pauseCtx->unk_298 = 4.0f; + break; + } + } + } else if (pauseCtx->cursorPoint[PAUSE_MAP] == DUNGEON_STRAY_FAIRIES) { + pauseCtx->cursorXIndex[PAUSE_MAP] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = pauseCtx->unk_256; + pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->unk_256; + } else { + pauseCtx->cursorSlot[PAUSE_MAP] = DUNGEON_STRAY_FAIRIES; + pauseCtx->cursorPoint[PAUSE_MAP] = DUNGEON_STRAY_FAIRIES; + } + } else if ((pauseCtx->cursorSpecialPos == 0) && (pauseCtx->stickAdjY < -30)) { + if ((pauseCtx->cursorPoint[PAUSE_MAP] >= DUNGEON_FLOOR_INDEX_4) && + (pauseCtx->cursorPoint[PAUSE_MAP] <= DUNGEON_FLOOR_INDEX_1)) { + for (i = pauseCtx->cursorPoint[PAUSE_MAP] - (DUNGEON_FLOOR_INDEX_4 - 1); i <= DUNGEON_FLOOR_INDEX_0; + i++) { + if ((gSaveContext.save.permanentSceneFlags[(void)0, gSaveContext.dungeonIndex].unk_14 & + gBitFlags[i]) || + func_801090B0(FLOOR_INDEX_MAX - i)) { + pauseCtx->cursorPoint[PAUSE_MAP] = i + DUNGEON_FLOOR_INDEX_4; + pauseCtx->unk_298 = 4.0f; + break; + } + } + + } else if (pauseCtx->cursorXIndex[PAUSE_MAP] == 0) { + pauseCtx->cursorXIndex[PAUSE_MAP] = 1; + pauseCtx->cursorPoint[PAUSE_MAP] = DUNGEON_STRAY_FAIRIES; + } else { + if (pauseCtx->cursorPoint[PAUSE_MAP] == DUNGEON_STRAY_FAIRIES) { + pauseCtx->cursorPoint[PAUSE_MAP] = DUNGEON_NONE; + } + + while (true) { + pauseCtx->cursorPoint[PAUSE_MAP]++; + if (pauseCtx->cursorPoint[PAUSE_MAP] == DUNGEON_FLOOR_INDEX_4) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + if (CHECK_DUNGEON_ITEM(pauseCtx->cursorPoint[PAUSE_MAP], gSaveContext.dungeonIndex)) { + break; + } + } + } + } + if ((pauseCtx->cursorPoint[PAUSE_MAP] <= DUNGEON_STRAY_FAIRIES) && (pauseCtx->cursorSpecialPos == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + + if ((pauseCtx->cursorXIndex[PAUSE_MAP] == 0) && (pauseCtx->cursorSpecialPos == 0)) { + pauseCtx->unk_256 = pauseCtx->cursorPoint[PAUSE_MAP]; + } + + if (pauseCtx->cursorSpecialPos == 0) { + if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && (msgCtx->msgLength == 0) && + (pauseCtx->cursorPoint[PAUSE_MAP] == DUNGEON_STRAY_FAIRIES)) { + pauseCtx->itemDescriptionOn = true; + func_801514B0(play, 0x17AF, 1); + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) && (msgCtx->msgLength == 0) && + CHECK_DUNGEON_ITEM(pauseCtx->cursorPoint[PAUSE_MAP], gSaveContext.dungeonIndex)) { + pauseCtx->itemDescriptionOn = true; + func_801514B0(play, 0x17AC + pauseCtx->cursorPoint[PAUSE_MAP], 1); + } + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_MAP]) { + play_sound(NA_SE_SY_CURSOR); + } + } + } +} + +TexturePtr sCloudTextures[] = { + gWorldMapClockTownCloud1Tex, // TINGLE_MAP_CLOCK_TOWN + gWorldMapClockTownCloud2Tex, // TINGLE_MAP_CLOCK_TOWN + gWorldMapWoodfallCloud1Tex, // TINGLE_MAP_WOODFALL + gWorldMapWoodfallCloud2Tex, // TINGLE_MAP_WOODFALL + gWorldMapWoodfallCloud3Tex, // TINGLE_MAP_WOODFALL + gWorldMapSnowheadCloud1Tex, // TINGLE_MAP_SNOWHEAD + gWorldMapSnowheadCloud2Tex, // TINGLE_MAP_SNOWHEAD + gWorldMapSnowheadCloud3Tex, // TINGLE_MAP_SNOWHEAD + gWorldMapRomaniRanchCloudTex, // TINGLE_MAP_ROMANI_RANCH + gWorldMapGreatBayCloud1Tex, // TINGLE_MAP_GREAT_BAY + gWorldMapGreatBayCloud2Tex, // TINGLE_MAP_GREAT_BAY + gWorldMapGreatBayCloud3Tex, // TINGLE_MAP_GREAT_BAY + gWorldMapGreatBayCloud4Tex, // TINGLE_MAP_GREAT_BAY + gWorldMapStoneTowerCloud1Tex, // TINGLE_MAP_STONE_TOWER + gWorldMapStoneTowerCloud2Tex, // TINGLE_MAP_STONE_TOWER +}; + +s16 sWorldMapDotPrimColors[][3] = { + { 0, 0, 255 }, + { 255, 255, 0 }, +}; +s16 sWorldMapDotEnvColors[][3] = { + { 255, 255, 0 }, + { 0, 0, 255 }, +}; + +s16 sWorldMapCursorsRectLeft[REGION_MAX] = { + 86, // REGION_GREAT_BAY + 104, // REGION_ZORA_HALL + 145, // REGION_ROMANI_RANCH + 153, // REGION_DEKU_PALACE + 163, // REGION_WOODFALL + 159, // REGION_CLOCK_TOWN + 157, // REGION_SNOWHEAD + 199, // REGION_IKANA_GRAVEYARD + 208, // REGION_IKANA_CANYON + 210, // REGION_GORON_VILLAGE + 218, // REGION_STONE_TOWER +}; + +s16 sWorldMapCursorsRectTop[REGION_MAX] = { + 127, // REGION_GREAT_BAY + 153, // REGION_ZORA_HALL + 138, // REGION_ROMANI_RANCH + 171, // REGION_DEKU_PALACE + 146, // REGION_WOODFALL + 119, // REGION_CLOCK_TOWN + 77, // REGION_SNOWHEAD + 106, // REGION_IKANA_GRAVEYARD + 120, // REGION_IKANA_CANYON + 73, // REGION_GORON_VILLAGE + 99, // REGION_STONE_TOWER +}; + +s16 sGreatFairySpawnRegions[] = { + REGION_CLOCK_TOWN, REGION_WOODFALL, REGION_SNOWHEAD, REGION_GREAT_BAY, REGION_IKANA_CANYON, + REGION_CLOCK_TOWN, REGION_WOODFALL, REGION_SNOWHEAD, REGION_GREAT_BAY, REGION_IKANA_CANYON, +}; + +void KaleidoScope_DrawWorldMap(PlayState* play) { + s16 sceneId; + s16 t; + s16 n; + s16 j; + s16 k; + s16 i; + PauseContext* pauseCtx = &play->pauseCtx; + s16 rectLeft; + s16 rectRight; + + OPEN_DISPS(play->state.gfxCtx); + + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MAP] * 4, pauseCtx->mapPageVtx); + + // Draw the world map image + if ((pauseCtx->pageIndex == PAUSE_MAP) && (pauseCtx->state == PAUSE_STATE_MAIN) && + ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) || (pauseCtx->mainState == PAUSE_MAIN_STATE_EQUIP_ITEM)) && + YREG(6) && (pauseCtx->state != PAUSE_STATE_SAVEPROMPT) && !IS_PAUSE_STATE_GAMEOVER) { + + // Draw the world map image flat + // Because it is flat, the texture is loaded by filling it in 8 rows at a time. + // 8 is chosen because it is smaller than `TMEM_SIZE / 2 / textureWidth` and divides the texture's height. + // Each loaded chunk must have `size <= TMEM_SIZE / 2` + // because the texture is color-indexed, so the TLUT uses the other half of TMEM. + + func_8012C628(play->state.gfxCtx); + + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); + gDPLoadTLUT_pal256(POLY_OPA_DISP++, gWorldMapImageTLUT); + gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + // Process the 128 rows of pixels for gWorldMapImageTex, 8 rows at a time over 16 iterations + // Loop over yPos (t), textureIndex (j) + for (t = 62, j = 0; j < 16; j++, t += 8) { + gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + j * (WORLD_MAP_IMAGE_TEX_WIDTH * 8), + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_TEX_WIDTH, 8, 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); + + rectLeft = 51 << 2; + rectRight = rectLeft + (WORLD_MAP_IMAGE_TEX_WIDTH << 2); + gSPTextureRectangle(POLY_OPA_DISP++, rectLeft, t << 2, rectRight, (t << 2) + (8 << 2), G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + } + + func_8012C8AC(play->state.gfxCtx); + + } else { + // Draw the world map angled + // Because it is at an angle, vertices are used to place it. + // The structure of the loops here is to satisfy the constraints of both TMEM and the size of the vertex cache. + // - Each loop iteration loads 9 rows, because 9 is the largest number smaller than + // `TMEM_SIZE / 2 / textureWidth`. + // - Each loop is at most 8 iterations long because each row uses 4 vertices and the vertex cache has size + // `32 = 8 * 4`. + // . + // Hence there is one loop of length 8, one of length 6, and then the remaining `128 - (8 + 6) * 9 = 2` rows are + // drawn at the end. + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); + gDPLoadTLUT_pal256(POLY_OPA_DISP++, gWorldMapImageTLUT); + gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + // Set the vertices for the first 8 quads attached to the world map texture. + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[204], 8 * 4, 0); + + // Process the first 72 rows of pixels for gWorldMapImageTex, 9 rows at a time over 8 iterations + // Loop over quadIndex of this loop (i), quadIndex of the entire texture (k), vtxIndex (j) + for (i = 0, k = 0, j = 0; i < 8; i++, k++, j += 4) { + gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_TEX_WIDTH * 9), + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_TEX_WIDTH, 9, 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); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + } + + // Set the vertices for the last 7 quads attached to the world map texture: + // 6 quads with a height of 9, 1 quad with a height of 2 + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[236], (6 + 1) * 4, 0); + + // Process the next 54 rows of pixels for gWorldMapImageTex, 9 rows at a time over 6 iterations + // Loop over quadIndex of this loop (i), quadIndex of the entire texture (k), vtxIndex (j) + for (i = 0, j = 0; i < 6; i++, k++, j += 4) { + gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_TEX_WIDTH * 9), + G_IM_FMT_CI, G_IM_SIZ_8b, WORLD_MAP_IMAGE_TEX_WIDTH, 9, 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); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + } + + // Process the last 2 rows of pixels for gWorldMapImageTex + gDPLoadTextureBlock(POLY_OPA_DISP++, (u8*)gWorldMapImageTex + k * (WORLD_MAP_IMAGE_TEX_WIDTH * 9), G_IM_FMT_CI, + G_IM_SIZ_8b, WORLD_MAP_IMAGE_TEX_WIDTH, 2, 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); + + gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); + } + + func_8012C8AC(play->state.gfxCtx); + + gDPPipeSync(POLY_OPA_DISP++); + + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, + ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 215, 235, 235, pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 40, 60, 100, 0); + + // Draw clouds over the world map + // Iterate over cloud bits (n) + for (n = 0; n < 15; n++) { + if (!(((void)0, gSaveContext.save.worldMapCloudVisibility) & gBitFlags[n])) { + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[60 + n * 4], 4, 0); + + POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, sCloudTextures[n], D_8082B7F0[n], D_8082B838[n], 0); + } + } + + if (IS_PAUSE_STATE_OWLWARP) { + 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, 0, R_PAUSE_OWLWARP_ALPHA); + gDPFillRectangle(POLY_OPA_DISP++, 50, 62, 270, 190); + } + + func_8012C8AC(play->state.gfxCtx); + + if (!IS_PAUSE_STATE_OWLWARP) { + // Browsing the world map regions on the pause menu + gDPLoadTextureBlock(POLY_OPA_DISP++, gWorldMapDotTex, G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 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); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, + PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sWorldMapDotPrimColors[0][0], sWorldMapDotPrimColors[0][1], + sWorldMapDotPrimColors[0][2], pauseCtx->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, sWorldMapDotEnvColors[0][0], sWorldMapDotEnvColors[0][1], + sWorldMapDotEnvColors[0][2], 0); + + if (R_PAUSE_DBG_MAP_CLOUD_ON) { + gSaveContext.save.worldMapCloudVisibility |= (u16)~0x8000; + + pauseCtx->mapPageVtx[120].v.ob[0] = pauseCtx->mapPageVtx[122].v.ob[0] = R_PAUSE_DBG_MAP_CLOUD_X; + + pauseCtx->mapPageVtx[121].v.ob[0] = pauseCtx->mapPageVtx[123].v.ob[0] = + pauseCtx->mapPageVtx[120].v.ob[0] + 8; + + pauseCtx->mapPageVtx[120].v.ob[1] = pauseCtx->mapPageVtx[121].v.ob[1] = R_PAUSE_DBG_MAP_CLOUD_Y; + + pauseCtx->mapPageVtx[122].v.ob[1] = pauseCtx->mapPageVtx[123].v.ob[1] = + pauseCtx->mapPageVtx[120].v.ob[1] - 8; + } + + // Loop over RegionId (i), unused vtxIndex (j), unused (k) + for (i = 0, j = 0; i < REGION_MAX; i++, k++, j += 4) { + if (pauseCtx->worldMapPoints[i]) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[120 + i * 4], 4, 0); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + } + + } else { + // Selecting an owl warp + gDPPipeSync(POLY_OPA_DISP++); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPLoadTextureBlock(POLY_OPA_DISP++, gWorldMapOwlFaceTex, G_IM_FMT_RGBA, G_IM_SIZ_32b, 24, 12, 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); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (R_PAUSE_DBG_MAP_CLOUD_ON) { + gSaveContext.save.worldMapCloudVisibility |= (u16)~0x8000; + + pauseCtx->mapPageVtx[164].v.ob[0] = pauseCtx->mapPageVtx[166].v.ob[0] = R_PAUSE_DBG_MAP_CLOUD_X; + + pauseCtx->mapPageVtx[165].v.ob[0] = pauseCtx->mapPageVtx[167].v.ob[0] = + pauseCtx->mapPageVtx[164].v.ob[0] + 24; + + pauseCtx->mapPageVtx[164].v.ob[1] = pauseCtx->mapPageVtx[165].v.ob[1] = R_PAUSE_DBG_MAP_CLOUD_Y; + + pauseCtx->mapPageVtx[166].v.ob[1] = pauseCtx->mapPageVtx[167].v.ob[1] = + pauseCtx->mapPageVtx[164].v.ob[1] - 12; + } + + // Loop over OwlWarpId (i), unused vtxIndex (j), unused (k) + for (i = 0, j = 0; i < OWL_WARP_ENTRANCE; i++, k++, j += 4) { + if (pauseCtx->worldMapPoints[i]) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->mapPageVtx[164 + i * 4], 4, 0); + gSP1Quadrangle(POLY_OPA_DISP++, 0, 2, 3, 1, 0); + } + } + } + + // Find and draw Player's face at the current region based on the current scene + // If (pauseCtx->state == PAUSE_STATE_MAIN), then the other pauseCtx->state conditions are redundant + // and always return true + if ((pauseCtx->pageIndex == PAUSE_MAP) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->state != PAUSE_STATE_SAVEPROMPT) && + !IS_PAUSE_STATE_GAMEOVER) { + j = 0; + n = 0; + + sceneId = play->sceneId; + + // Map grottos/shrines to sceneId's to be used in different regions + if (sceneId == SCENE_KAKUSIANA) { + if (play->roomCtx.curRoom.num == 5) { + sceneId = SCENE_11GORONNOSATO; + } else if ((play->roomCtx.curRoom.num == 6) || (play->roomCtx.curRoom.num == 8) || + (play->roomCtx.curRoom.num == 12)) { + sceneId = SCENE_22DEKUCITY; + } else { + sceneId = Entrance_GetSceneIdAbsolute(((void)0, gSaveContext.respawn[RESPAWN_MODE_UNK_3].entrance)); + } + } + + // Find the regionId that player is currently in + // Loop over regionId (n) and regionIdIndex (j) + while (true) { + if ((gSceneIdsPerRegion[n][j] == 0xFFFF)) { + n++; + j = 0; + if (n == REGION_MAX) { + n = 0; + + // Special case for fairy fountains + if (sceneId == SCENE_YOUSEI_IZUMI) { + j = play->curSpawn; + n = sGreatFairySpawnRegions[j]; + break; + } + + while (true) { + if (gSceneIdsPerRegion[n][j] == 0xFFFF) { + n++; + if (n == REGION_MAX) { + break; + } + j = 0; + if (Entrance_GetSceneIdAbsolute( + ((void)0, gSaveContext.respawn[RESPAWN_MODE_UNK_3].entrance)) == + gSceneIdsPerRegion[n][j]) { + break; + } + } + j++; + } + break; + } + } + + if (sceneId == gSceneIdsPerRegion[n][j]) { + break; + } + j++; + } + + // Draw Player's face at the current region + if (n != REGION_MAX) { + KaleidoScope_SetView(pauseCtx, pauseCtx->eye.x, pauseCtx->eye.y, pauseCtx->eye.z); + func_8012C628(play->state.gfxCtx); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + POLY_OPA_DISP = Gfx_DrawTexRectRGBA16(POLY_OPA_DISP, &D_09007500, 16, 16, sWorldMapCursorsRectLeft[n], + sWorldMapCursorsRectTop[n], 16, 16, 1 << 10, 1 << 10); + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + CLOSE_DISPS(play->state.gfxCtx); +} + +u16 sOwlWarpPauseItems[] = { + 0xAF, // OWL_WARP_GREAT_BAY_COAST + 0xB3, // OWL_WARP_ZORA_CAPE + 0xAA, // OWL_WARP_SNOWHEAD + 0xB1, // OWL_WARP_MOUNTAIN_VILLAGE + 0xA9, // OWL_WARP_CLOCK_TOWN + 0xB2, // OWL_WARP_MILK_ROAD + 0xA8, // OWL_WARP_WOODFALL + 0xB0, // OWL_WARP_SOUTHERN_SWAMP + 0xAC, // OWL_WARP_IKANA_CANYON + 0xAE, // OWL_WARP_STONE_TOWER +}; + +void KaleidoScope_UpdateWorldMapCursor(PlayState* play) { + static u16 sStickAdjTimer = 0; // unused timer that counts up every frame. Resets on reading a stickAdj. + PauseContext* pauseCtx = &play->pauseCtx; + s16 oldCursorPoint; + + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (pauseCtx->pageIndex == PAUSE_MAP)) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + + if (pauseCtx->cursorSpecialPos == 0) { + if (pauseCtx->stickAdjX > 30) { + pauseCtx->unk_298 = 4.0f; + sStickAdjTimer = 0; + + while (true) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]++; + if (pauseCtx->cursorPoint[PAUSE_WORLD_MAP] >= REGION_MAX) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + break; + } + if (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]) { + break; + } + } + } else if (pauseCtx->stickAdjX < -30) { + pauseCtx->unk_298 = 4.0f; + sStickAdjTimer = 0; + + while (true) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]--; + if (pauseCtx->cursorPoint[PAUSE_WORLD_MAP] < REGION_GREAT_BAY) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + break; + } + if (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]) { + break; + } + } + } else { + sStickAdjTimer++; + } + + if (pauseCtx->cursorSpecialPos == 0) { + pauseCtx->cursorItem[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + // Used as cursor vtxIndex + pauseCtx->cursorSlot[PAUSE_MAP] = 31 + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + } + } else { + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickAdjX > 30) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = -1; + pauseCtx->cursorSpecialPos = 0; + pauseCtx->unk_298 = 4.0f; + + while (true) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]++; + if (pauseCtx->cursorPoint[PAUSE_WORLD_MAP] > REGION_STONE_TOWER) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + break; + } + if (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]) { + break; + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + pauseCtx->cursorItem[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + // Used as cursor vtxIndex + pauseCtx->cursorSlot[PAUSE_MAP] = 31 + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + } + play_sound(NA_SE_SY_CURSOR); + sStickAdjTimer = 0; + } + } else if (pauseCtx->stickAdjX < -30) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = 11; + pauseCtx->cursorSpecialPos = 0; + pauseCtx->unk_298 = 4.0f; + + while (true) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]--; + if (pauseCtx->cursorPoint[PAUSE_WORLD_MAP] < 0) { + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + break; + } + if (pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]) { + break; + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + pauseCtx->cursorItem[PAUSE_MAP] = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + // Used as cursor vtxIndex + pauseCtx->cursorSlot[PAUSE_MAP] = 31 + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + } + play_sound(NA_SE_SY_CURSOR); + sStickAdjTimer = 0; + } + } + + if (!pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]) { + pauseCtx->cursorItem[PAUSE_MAP] = PAUSE_ITEM_NONE; + } + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_WORLD_MAP]) { + play_sound(NA_SE_SY_CURSOR); + } + } else if (pauseCtx->state == PAUSE_STATE_OWLWARP_SELECT) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_BLUE; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + + if (pauseCtx->stickAdjX > 30) { + pauseCtx->unk_298 = 4.0f; + sStickAdjTimer = 0; + do { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]++; + if (pauseCtx->cursorPoint[PAUSE_WORLD_MAP] > OWL_WARP_STONE_TOWER) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = OWL_WARP_GREAT_BAY_COAST; + } + } while (!pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]); + } else if (pauseCtx->stickAdjX < -30) { + pauseCtx->unk_298 = 4.0f; + sStickAdjTimer = 0; + do { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]--; + if (pauseCtx->cursorPoint[PAUSE_WORLD_MAP] < OWL_WARP_GREAT_BAY_COAST) { + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = OWL_WARP_STONE_TOWER; + } + } while (!pauseCtx->worldMapPoints[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]); + } else { + sStickAdjTimer++; + } + + //! TODO: Is the `0xA4` here related to `0xA3` being the last recored item in the `ItemId` enum? + pauseCtx->cursorItem[PAUSE_MAP] = sOwlWarpPauseItems[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]] - 0xA4; + // Used as cursor vtxIndex + pauseCtx->cursorSlot[PAUSE_MAP] = 31 + pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_WORLD_MAP]) { + play_sound(NA_SE_SY_CURSOR); + } + } +} 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..219ecd7a9 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 @@ -1,25 +1,810 @@ /* * File: z_kaleido_mask.c * Overlay: ovl_kaleido_scope - * Description: + * Description: Pause Menu - Mask Page */ #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 sMaskEquipState = EQUIP_STATE_MAGIC_ARROW_GROW_ORB; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8081FF80.s") +// Timer to hold magic arrow icon over magic arrow slot before moving when equipping. +s16 sMaskEquipMagicArrowSlotHoldTimer = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808204AC.s") +// Number of frames to move icon from slot to target position when equipping. +s16 sMaskEquipAnimTimer = 10; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80820FA4.s") +u8 gMaskPlayerFormSlotRestrictions[PLAYER_FORM_MAX][NUM_MASK_SLOTS] = { + // Fierce Deity + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + false, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + false, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + false, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Goron + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Zora + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Deku + { + false, // SLOT_MASK_POSTMAN + false, // SLOT_MASK_ALL_NIGHT + false, // SLOT_MASK_BLAST + false, // SLOT_MASK_STONE + false, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + false, // SLOT_MASK_KEATON + false, // SLOT_MASK_BREMEN + false, // SLOT_MASK_BUNNY + false, // SLOT_MASK_DON_GERO + false, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + false, // SLOT_MASK_ROMANI + false, // SLOT_MASK_CIRCUS_LEADER + false, // SLOT_MASK_KAFEIS_MASK + false, // SLOT_MASK_COUPLE + false, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + false, // SLOT_MASK_KAMARO + false, // SLOT_MASK_GIBDO + false, // SLOT_MASK_GARO + false, // SLOT_MASK_CAPTAIN + false, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, + // Human + { + true, // SLOT_MASK_POSTMAN + true, // SLOT_MASK_ALL_NIGHT + true, // SLOT_MASK_BLAST + true, // SLOT_MASK_STONE + true, // SLOT_MASK_GREAT_FAIRY + true, // SLOT_MASK_DEKU + true, // SLOT_MASK_KEATON + true, // SLOT_MASK_BREMEN + true, // SLOT_MASK_BUNNY + true, // SLOT_MASK_DON_GERO + true, // SLOT_MASK_SCENTS + true, // SLOT_MASK_GORON + true, // SLOT_MASK_ROMANI + true, // SLOT_MASK_CIRCUS_LEADER + true, // SLOT_MASK_KAFEIS_MASK + true, // SLOT_MASK_COUPLE + true, // SLOT_MASK_TRUTH + true, // SLOT_MASK_ZORA + true, // SLOT_MASK_KAMARO + true, // SLOT_MASK_GIBDO + true, // SLOT_MASK_GARO + true, // SLOT_MASK_CAPTAIN + true, // SLOT_MASK_GIANT + true, // SLOT_MASK_FIERCE_DEITY + }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821730.s") +#define SET_MOON_MASK_BIT(masksGivenOnMoonIndex, masksGivenOnMoonFlag) \ + ((masksGivenOnMoonIndex) << 8 | (masksGivenOnMoonFlag)) +#define CHECK_GIVEN_MASK_ON_MOON(maskIndex) \ + (gSaveContext.masksGivenOnMoon[sMasksGivenOnMoonBits[maskIndex] >> 8] & (u8)sMasksGivenOnMoonBits[maskIndex]) + +u16 sMasksGivenOnMoonBits[] = { + SET_MOON_MASK_BIT(1, 0x1), // SLOT_MASK_POSTMAN + SET_MOON_MASK_BIT(0, 0x4), // SLOT_MASK_ALL_NIGHT + SET_MOON_MASK_BIT(2, 0x2), // SLOT_MASK_BLAST + SET_MOON_MASK_BIT(1, 0x80), // SLOT_MASK_STONE + SET_MOON_MASK_BIT(1, 0x4), // SLOT_MASK_GREAT_FAIRY + SET_MOON_MASK_BIT(2, 0x10), // SLOT_MASK_DEKU + SET_MOON_MASK_BIT(0, 0x10), // SLOT_MASK_KEATON + SET_MOON_MASK_BIT(2, 0x1), // SLOT_MASK_BREMEN + SET_MOON_MASK_BIT(0, 0x8), // SLOT_MASK_BUNNY + SET_MOON_MASK_BIT(1, 0x10), // SLOT_MASK_DON_GERO + SET_MOON_MASK_BIT(2, 0x4), // SLOT_MASK_SCENTS + SET_MOON_MASK_BIT(2, 0x20), // SLOT_MASK_GORON + SET_MOON_MASK_BIT(0, 0x40), // SLOT_MASK_ROMANI + SET_MOON_MASK_BIT(0, 0x80), // SLOT_MASK_CIRCUS_LEADER + SET_MOON_MASK_BIT(0, 0x2), // SLOT_MASK_KAFEIS_MASK + SET_MOON_MASK_BIT(1, 0x2), // SLOT_MASK_COUPLE + SET_MOON_MASK_BIT(0, 0x1), // SLOT_MASK_TRUTH + SET_MOON_MASK_BIT(2, 0x40), // SLOT_MASK_ZORA + SET_MOON_MASK_BIT(1, 0x20), // SLOT_MASK_KAMARO + SET_MOON_MASK_BIT(1, 0x8), // SLOT_MASK_GIBDO + SET_MOON_MASK_BIT(0, 0x20), // SLOT_MASK_GARO + SET_MOON_MASK_BIT(1, 0x40), // SLOT_MASK_CAPTAIN + SET_MOON_MASK_BIT(2, 0x8), // SLOT_MASK_GIANT + SET_MOON_MASK_BIT(2, 0X80), // SLOT_MASK_FIERCE_DEITY +}; + +s16 sMaskMagicArrowEffectsR[] = { 255, 100, 255 }; +s16 sMaskMagicArrowEffectsG[] = { 0, 100, 255 }; +s16 sMaskMagicArrowEffectsB[] = { 0, 255, 100 }; + +void KaleidoScope_DrawMaskSelect(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; + u16 i; + u16 j; + + OPEN_DISPS(play->state.gfxCtx); + + KaleidoScope_SetCursorVtx(pauseCtx, pauseCtx->cursorSlot[PAUSE_MASK] * 4, pauseCtx->maskVtx); + + func_8012C8AC(play->state.gfxCtx); + + // Draw a white box around the items that are equipped on the C buttons + // Loop over c-buttons (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + for (i = 0, j = NUM_MASK_SLOTS * 4; i < 3; i++, j += 4) { + if (GET_CUR_FORM_BTN_ITEM(i + 1) != ITEM_NONE) { + if (GET_CUR_FORM_BTN_SLOT(i + 1) >= NUM_ITEM_SLOTS) { + gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j], 4, 0); + POLY_OPA_DISP = Gfx_DrawTexQuadIA8(POLY_OPA_DISP, gEquippedItemOutlineTex, 32, 32, 0); + } + } + } + + gDPPipeSync(POLY_OPA_DISP++); + + // Draw the item icons + // Loop over slots (i) and vtx offset (j) + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + for (j = 0, i = 0; i < NUM_MASK_SLOTS; i++, j += 4) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha); + + if (((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS]) != ITEM_NONE) { + if (!CHECK_GIVEN_MASK_ON_MOON(i)) { + if ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && (pauseCtx->pageIndex == PAUSE_MASK) && + (pauseCtx->cursorSpecialPos == 0) && + gMaskPlayerFormSlotRestrictions[(void)0, gSaveContext.save.playerForm][i]) { + if ((sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) && (i == SLOT_ARROW_ICE)) { + // Possible bug: + // Supposed to be `SLOT_BOW`, unchanged from OoT, instead increase size of ice arrow icon + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, + sMaskMagicArrowEffectsR[pauseCtx->equipTargetItem - 0xB5], + sMaskMagicArrowEffectsG[pauseCtx->equipTargetItem - 0xB5], + sMaskMagicArrowEffectsB[pauseCtx->equipTargetItem - 0xB5], pauseCtx->alpha); + + pauseCtx->maskVtx[j + 0].v.ob[0] = pauseCtx->maskVtx[j + 2].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] - 2; + pauseCtx->maskVtx[j + 1].v.ob[0] = pauseCtx->maskVtx[j + 3].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] + 32; + pauseCtx->maskVtx[j + 0].v.ob[1] = pauseCtx->maskVtx[j + 1].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] + 2; + pauseCtx->maskVtx[j + 2].v.ob[1] = pauseCtx->maskVtx[j + 3].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] - 32; + + } else if (i == pauseCtx->cursorSlot[PAUSE_MASK]) { + // Increase the size of the selected item + pauseCtx->maskVtx[j + 0].v.ob[0] = pauseCtx->maskVtx[j + 2].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] - 2; + pauseCtx->maskVtx[j + 1].v.ob[0] = pauseCtx->maskVtx[j + 3].v.ob[0] = + pauseCtx->maskVtx[j + 0].v.ob[0] + 32; + pauseCtx->maskVtx[j + 0].v.ob[1] = pauseCtx->maskVtx[j + 1].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] + 2; + pauseCtx->maskVtx[j + 2].v.ob[1] = pauseCtx->maskVtx[j + 3].v.ob[1] = + pauseCtx->maskVtx[j + 0].v.ob[1] - 32; + } + } + + gSPVertex(POLY_OPA_DISP++, &pauseCtx->maskVtx[j + 0], 4, 0); + KaleidoScope_DrawTexQuadRGBA32( + play->state.gfxCtx, gItemIcons[((void)0, gSaveContext.save.inventory.items[i + NUM_ITEM_SLOTS])], + 32, 32, 0); + } + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} + +u8 sMaskPlayerFormItems[] = { + ITEM_MASK_FIERCE_DEITY, ITEM_MASK_GORON, ITEM_MASK_ZORA, ITEM_MASK_DEKU, ITEM_NONE, +}; + +void KaleidoScope_UpdateMaskCursor(PlayState* play) { + Input* input = CONTROLLER1(&play->state); + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + u16 vtxIndex; + u16 cursorItem; + u16 cursorSlot; + s16 cursorPoint; + s16 cursorXIndex; + s16 cursorYIndex; + s16 oldCursorPoint; + s16 moveCursorResult; + s16 pad2; + + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + pauseCtx->nameColorSet = PAUSE_NAME_COLOR_SET_WHITE; + + if ((pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + (pauseCtx->pageIndex == PAUSE_MASK) && !pauseCtx->itemDescriptionOn) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; + oldCursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; + + cursorItem = pauseCtx->cursorItem[PAUSE_MASK]; + + // Move cursor left/right + if (pauseCtx->cursorSpecialPos == 0) { + // cursor is currently on a slot + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; + + if (ABS_ALT(pauseCtx->stickAdjX) > 30) { + cursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; + cursorXIndex = pauseCtx->cursorXIndex[PAUSE_MASK]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_MASK]; + + // Search for slot to move to + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjX < -30) { + // move cursor left + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorXIndex[PAUSE_MASK] != 0) { + pauseCtx->cursorXIndex[PAUSE_MASK]--; + pauseCtx->cursorPoint[PAUSE_MASK]--; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK]++; + + if (pauseCtx->cursorYIndex[PAUSE_MASK] >= 4) { + pauseCtx->cursorYIndex[PAUSE_MASK] = 0; + } + + pauseCtx->cursorPoint[PAUSE_MASK] = + pauseCtx->cursorXIndex[PAUSE_MASK] + (pauseCtx->cursorYIndex[PAUSE_MASK] * 6); + + if (pauseCtx->cursorPoint[PAUSE_MASK] >= NUM_MASK_SLOTS) { + pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK]; + } + + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_MASK]) { + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + } + } + } else if (pauseCtx->stickAdjX > 30) { + // move cursor right + pauseCtx->unk_298 = 4.0f; + if (pauseCtx->cursorXIndex[PAUSE_MASK] <= 4) { + pauseCtx->cursorXIndex[PAUSE_MASK]++; + pauseCtx->cursorPoint[PAUSE_MASK]++; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK]++; + + if (pauseCtx->cursorYIndex[PAUSE_MASK] >= 4) { + pauseCtx->cursorYIndex[PAUSE_MASK] = 0; + } + + pauseCtx->cursorPoint[PAUSE_MASK] = + pauseCtx->cursorXIndex[PAUSE_MASK] + (pauseCtx->cursorYIndex[PAUSE_MASK] * 6); + + if (pauseCtx->cursorPoint[PAUSE_MASK] >= NUM_MASK_SLOTS) { + pauseCtx->cursorPoint[PAUSE_MASK] = pauseCtx->cursorXIndex[PAUSE_MASK]; + } + + if (cursorYIndex == pauseCtx->cursorYIndex[PAUSE_MASK]) { + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + } + } + } + } + + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } + } + } else if (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) { + if (pauseCtx->stickAdjX > 30) { + func_80821A04(play); + cursorYIndex = 0; + cursorXIndex = 0; + cursorPoint = 0; // top row, left column (SLOT_MASK_POSTMAN) + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if ((gSaveContext.save.inventory.items[cursorPoint + NUM_ITEM_SLOTS] != ITEM_NONE) && + !CHECK_GIVEN_MASK_ON_MOON(cursorPoint)) { + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + break; + } + + // move 1 row down and retry + cursorYIndex++; + cursorPoint += 6; + if (cursorYIndex < 4) { + continue; + } + + // move 1 column right and retry + cursorYIndex = 0; + cursorPoint = cursorXIndex + 1; + cursorXIndex = cursorPoint; + if (cursorXIndex < 6) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); + break; + } + } + } else { // PAUSE_CURSOR_PAGE_RIGHT + //! FAKE: + if (1) {} + if (pauseCtx->stickAdjX < -30) { + func_80821A04(play); + cursorXIndex = 5; + cursorPoint = 5; // top row, right column (SLOT_MASK_DEKU) + cursorYIndex = 0; + + // Search for slot to move to + while (true) { + // Check if current cursor has an item in its slot + if ((gSaveContext.save.inventory.items[cursorPoint + NUM_ITEM_SLOTS] != ITEM_NONE) && + !CHECK_GIVEN_MASK_ON_MOON(cursorPoint)) { + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + pauseCtx->cursorXIndex[PAUSE_MASK] = cursorXIndex; + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + break; + } + + // move 1 row down and retry + cursorYIndex++; + cursorPoint += 6; + if (cursorYIndex < 4) { + continue; + } + + // move 1 column left and retry + cursorYIndex = 0; + cursorPoint = cursorXIndex - 1; + cursorXIndex = cursorPoint; + if (cursorXIndex >= 0) { + continue; + } + + // No item available + KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_LEFT); + break; + } + } + } + + if (pauseCtx->cursorSpecialPos == 0) { + // move cursor up/down + if (ABS_ALT(pauseCtx->stickAdjY) > 30) { + moveCursorResult = PAUSE_CURSOR_RESULT_NONE; + + cursorPoint = pauseCtx->cursorPoint[PAUSE_MASK]; + cursorYIndex = pauseCtx->cursorYIndex[PAUSE_MASK]; + + while (moveCursorResult == PAUSE_CURSOR_RESULT_NONE) { + if (pauseCtx->stickAdjY > 30) { + // move cursor up + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_MASK] != 0) { + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorYIndex[PAUSE_MASK]--; + pauseCtx->cursorPoint[PAUSE_MASK] -= 6; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + } + } else if (pauseCtx->stickAdjY < -30) { + // move cursor down + moveCursorResult = PAUSE_CURSOR_RESULT_SPECIAL_POS; + if (pauseCtx->cursorYIndex[PAUSE_MASK] < 3) { + pauseCtx->unk_298 = 4.0f; + pauseCtx->cursorYIndex[PAUSE_MASK]++; + pauseCtx->cursorPoint[PAUSE_MASK] += 6; + moveCursorResult = PAUSE_CURSOR_RESULT_SLOT; + } else { + pauseCtx->cursorYIndex[PAUSE_MASK] = cursorYIndex; + pauseCtx->cursorPoint[PAUSE_MASK] = cursorPoint; + } + } + } + } + + cursorSlot = pauseCtx->cursorPoint[PAUSE_MASK]; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; + + if (moveCursorResult == PAUSE_CURSOR_RESULT_SLOT) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } else if (moveCursorResult != PAUSE_CURSOR_RESULT_SPECIAL_POS) { + cursorItem = gSaveContext.save.inventory.items[pauseCtx->cursorPoint[PAUSE_MASK] + NUM_ITEM_SLOTS]; + if (CHECK_GIVEN_MASK_ON_MOON(pauseCtx->cursorPoint[PAUSE_MASK])) { + cursorItem = ITEM_NONE; + } + } + + if (cursorItem == ITEM_NONE) { + cursorItem = PAUSE_ITEM_NONE; + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_WHITE; + } + + if ((cursorItem != PAUSE_ITEM_NONE) && (msgCtx->msgLength == 0)) { + if (gSaveContext.buttonStatus[EQUIP_SLOT_A] == BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + } else if (gSaveContext.buttonStatus[EQUIP_SLOT_A] != BTN_DISABLED) { + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + } + + pauseCtx->cursorItem[PAUSE_MASK] = cursorItem; + pauseCtx->cursorSlot[PAUSE_MASK] = cursorSlot; + if (cursorItem != PAUSE_ITEM_NONE) { + // Equip item to the C buttons + if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && !pauseCtx->itemDescriptionOn && + (pauseCtx->state == PAUSE_STATE_MAIN) && (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + CHECK_BTN_ANY(input->press.button, BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { + + // Ensure that a mask is not unequipped while being used + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + if (((Player_GetCurMaskItemId(play) != ITEM_NONE) && + (Player_GetCurMaskItemId(play) == BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT))) || + ((sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] != ITEM_NONE) && + (sMaskPlayerFormItems[((void)0, gSaveContext.save.playerForm)] == + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } + + if ((Player_GetEnvironmentalHazard(play) >= PLAYER_ENV_HAZARD_UNDERWATER_FLOOR) && + (Player_GetEnvironmentalHazard(play) <= PLAYER_ENV_HAZARD_UNDERWATER_FREE) && + ((cursorSlot == (SLOT_MASK_DEKU - NUM_ITEM_SLOTS)) || + (cursorSlot == (SLOT_MASK_GORON - NUM_ITEM_SLOTS)))) { + play_sound(NA_SE_SY_ERROR); + return; + } + + if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_LEFT; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_DOWN; + } else if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) { + pauseCtx->equipTargetCBtn = PAUSE_EQUIP_C_RIGHT; + } + + // Equip item to the C buttons + pauseCtx->equipTargetItem = cursorItem; + pauseCtx->equipTargetSlot = cursorSlot + NUM_ITEM_SLOTS; + pauseCtx->mainState = PAUSE_MAIN_STATE_EQUIP_MASK; + vtxIndex = cursorSlot * 4; + pauseCtx->equipAnimX = pauseCtx->maskVtx[vtxIndex].v.ob[0] * 10; + pauseCtx->equipAnimY = pauseCtx->maskVtx[vtxIndex].v.ob[1] * 10; + pauseCtx->equipAnimAlpha = 255; + sMaskEquipMagicArrowSlotHoldTimer = 0; + sMaskEquipState = EQUIP_STATE_MOVE_TO_C_BTN; + sMaskEquipAnimTimer = 10; + play_sound(NA_SE_SY_DECIDE); + } else if ((pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && (pauseCtx->state == PAUSE_STATE_MAIN) && + (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) && + CHECK_BTN_ALL(input->press.button, BTN_A) && (msgCtx->msgLength == 0)) { + // Give description on item through a message box + pauseCtx->itemDescriptionOn = true; + if (pauseCtx->cursorYIndex[PAUSE_MASK] < 2) { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_MASK], 3); + } else { + func_801514B0(play, 0x1700 + pauseCtx->cursorItem[PAUSE_MASK], 1); + } + } + } + } else { + pauseCtx->cursorItem[PAUSE_MASK] = PAUSE_ITEM_NONE; + } + + if (oldCursorPoint != pauseCtx->cursorPoint[PAUSE_MASK]) { + play_sound(NA_SE_SY_CURSOR); + } + } else if ((pauseCtx->mainState == PAUSE_MAIN_STATE_EQUIP_MASK) && (pauseCtx->pageIndex == PAUSE_MASK)) { + pauseCtx->cursorColorSet = PAUSE_CURSOR_COLOR_SET_YELLOW; + } +} + +s16 sMaskCButtonPosX[] = { 660, 900, 1140 }; +s16 sMaskCButtonPosY[] = { 1100, 920, 1100 }; + +void KaleidoScope_UpdateMaskEquip(PlayState* play) { + static s16 sMaskEquipMagicArrowBowSlotHoldTimer = 0; + PauseContext* pauseCtx = &play->pauseCtx; + Vtx* bowItemVtx; + u16 offsetX; + u16 offsetY; + + // Grow glowing orb when equipping magic arrows + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_GROW_ORB) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + sMaskEquipState++; + } + // Hover over magic arrow slot when the next state is reached + sMaskEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT) { + sMaskEquipMagicArrowBowSlotHoldTimer--; + + if (sMaskEquipMagicArrowBowSlotHoldTimer == 0) { + pauseCtx->equipTargetItem -= 0xB5 - ITEM_BOW_ARROW_FIRE; + pauseCtx->equipTargetSlot = SLOT_BOW; + sMaskEquipAnimTimer = 6; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + sMaskEquipState++; + play_sound(NA_SE_SY_SYNTH_MAGIC_ARROW); + } + return; + } + + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + bowItemVtx = &pauseCtx->itemVtx[12]; + offsetX = ABS_ALT(pauseCtx->equipAnimX - bowItemVtx->v.ob[0] * 10) / sMaskEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - bowItemVtx->v.ob[1] * 10) / sMaskEquipAnimTimer; + } else { + offsetX = ABS_ALT(pauseCtx->equipAnimX - sMaskCButtonPosX[pauseCtx->equipTargetCBtn]) / sMaskEquipAnimTimer; + offsetY = ABS_ALT(pauseCtx->equipAnimY - sMaskCButtonPosY[pauseCtx->equipTargetCBtn]) / sMaskEquipAnimTimer; + } + + if ((pauseCtx->equipTargetItem >= 0xB5) && (pauseCtx->equipAnimAlpha < 254)) { + pauseCtx->equipAnimAlpha += 14; + if (pauseCtx->equipAnimAlpha > 255) { + pauseCtx->equipAnimAlpha = 254; + } + sMaskEquipMagicArrowSlotHoldTimer = 5; + return; + } + + if (sMaskEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimScale -= pauseCtx->equipAnimShrinkRate / sMaskEquipAnimTimer; + pauseCtx->equipAnimShrinkRate -= pauseCtx->equipAnimShrinkRate / sMaskEquipAnimTimer; + + // Update coordinates of item icon while being equipped + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + // target is the bow slot + if (pauseCtx->equipAnimX >= (pauseCtx->itemVtx[12].v.ob[0] * 10)) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= (pauseCtx->itemVtx[12].v.ob[1] * 10)) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } else { + // target is the c button + if (pauseCtx->equipAnimX >= sMaskCButtonPosX[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimX -= offsetX; + } else { + pauseCtx->equipAnimX += offsetX; + } + + if (pauseCtx->equipAnimY >= sMaskCButtonPosY[pauseCtx->equipTargetCBtn]) { + pauseCtx->equipAnimY -= offsetY; + } else { + pauseCtx->equipAnimY += offsetY; + } + } + + sMaskEquipAnimTimer--; + if (sMaskEquipAnimTimer == 0) { + if (sMaskEquipState == EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT) { + sMaskEquipState++; + sMaskEquipMagicArrowBowSlotHoldTimer = 4; + return; + } + + // Equip mask onto c buttons + if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_LEFT) { + // Swap if mask is already equipped on CDown or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Equip mask on CLeft + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_LEFT); + } else if (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_DOWN) { + // Swap if mask is already equipped on CLeft or CRight. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_RIGHT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = SLOT_NONE; + } + } + + // Equip mask on CDown + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_DOWN); + } else { // (pauseCtx->equipTargetCBtn == PAUSE_EQUIP_C_RIGHT) + // Swap if mask is already equipped on CLeft or CDown. + if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_LEFT); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_LEFT) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_LEFT) = SLOT_NONE; + } + } else if (pauseCtx->equipTargetSlot == C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN)) { + if ((BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) & 0xFF) != ITEM_NONE) { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT); + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT); + Interface_LoadItemIcon(play, EQUIP_SLOT_C_DOWN); + } else { + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_DOWN) = ITEM_NONE; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_DOWN) = SLOT_NONE; + } + } + + // Equip mask on CRight + BUTTON_ITEM_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetItem; + C_SLOT_EQUIP(0, EQUIP_SLOT_C_RIGHT) = pauseCtx->equipTargetSlot; + Interface_LoadItemIconImpl(play, EQUIP_SLOT_C_RIGHT); + } + + // Reset params + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + sMaskEquipAnimTimer = 10; + pauseCtx->equipAnimScale = 320; + pauseCtx->equipAnimShrinkRate = 40; + } + } else { + sMaskEquipMagicArrowSlotHoldTimer--; + if (sMaskEquipMagicArrowSlotHoldTimer == 0) { + pauseCtx->equipAnimAlpha = 255; + } + } +} diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c new file mode 100644 index 000000000..13e233b58 --- /dev/null +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_prompt.c @@ -0,0 +1,51 @@ +/* + * File: z_kaleido_prompt.c + * Overlay: ovl_kaleido_scope + * Description: Pause Menu - Save and Continue Prompt + */ + +#include "z_kaleido_scope.h" + +s16 sPromptAlphaTargets[] = { 100, 255 }; + +// Unused remnant of OoT +void KaleidoScope_UpdatePrompt(PlayState* play) { + static s16 sPromptAlphaTargetIndex = 0; + static s16 sPromptAlphaTimer = 10; + PauseContext* pauseCtx = &play->pauseCtx; + Input* input = CONTROLLER1(&play->state); + s8 relStickX = input->rel.stick_x; + s16 alphaStep; + + if (((pauseCtx->state == PAUSE_STATE_SAVEPROMPT) && (pauseCtx->savePromptState == PAUSE_SAVEPROMPT_STATE_1)) || + (pauseCtx->state == PAUSE_STATE_GAMEOVER_SAVE_PROMPT) || + (pauseCtx->state == PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT)) { + + // Move the prompt + if ((pauseCtx->promptChoice == PAUSE_PROMPT_YES) && (relStickX >= 30)) { + // Move right to the no prompt + play_sound(NA_SE_SY_CURSOR); + pauseCtx->promptChoice = PAUSE_PROMPT_NO; + } else if ((pauseCtx->promptChoice != PAUSE_PROMPT_YES) && (relStickX <= -30)) { + // Move left to the yes prompt + play_sound(NA_SE_SY_CURSOR); + pauseCtx->promptChoice = PAUSE_PROMPT_YES; + } + + // Update the alpha for the green glowing orb above the prompt + alphaStep = ABS_ALT(pauseCtx->promptAlpha - sPromptAlphaTargets[sPromptAlphaTargetIndex]) / sPromptAlphaTimer; + + if (pauseCtx->promptAlpha >= sPromptAlphaTargets[sPromptAlphaTargetIndex]) { + pauseCtx->promptAlpha -= alphaStep; + } else { + pauseCtx->promptAlpha += alphaStep; + } + + sPromptAlphaTimer--; + if (sPromptAlphaTimer == 0) { + pauseCtx->promptAlpha = sPromptAlphaTargets[sPromptAlphaTargetIndex]; + sPromptAlphaTimer = sPromptAlphaTargetIndex + 20; + sPromptAlphaTargetIndex ^= 1; + } + } +} 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..7349db241 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,182 @@ -#ifndef _Z64_KALEIDO_SCOPE_H_ -#define _Z64_KALEIDO_SCOPE_H_ +#ifndef Z_KALEIDO_SCOPE_H +#define Z_KALEIDO_SCOPE_H #include "global.h" +#define PAUSE_ITEM_NONE 999 +#define PAUSE_CURSOR_PAGE_LEFT 10 +#define PAUSE_CURSOR_PAGE_RIGHT 11 + +typedef enum { + /* 0 */ PAUSE_ITEM, + /* 1 */ PAUSE_MAP, + /* 2 */ PAUSE_QUEST, + /* 3 */ PAUSE_MASK, + /* 4 */ PAUSE_WORLD_MAP +} PauseMenuPage; + +// Direction of pause pages +#define PAUSE_ITEM_X (0) +#define PAUSE_ITEM_Z (-1) +#define PAUSE_MAP_X (1) +#define PAUSE_MAP_Z (0) +#define PAUSE_QUEST_X (0) +#define PAUSE_QUEST_Z (1) +#define PAUSE_MASK_X (-1) +#define PAUSE_MASK_Z (0) + +#define PAUSE_EYE_DIST (64.0f) + +typedef enum { + /* 0x00 */ PAUSE_STATE_OFF, + /* 0x01 */ PAUSE_STATE_OPENING_0, + /* 0x02 */ PAUSE_STATE_OPENING_1, + /* 0x03 */ PAUSE_STATE_OPENING_2, + /* 0x04 */ PAUSE_STATE_OPENING_3, + /* 0x05 */ PAUSE_STATE_OPENING_4, + /* 0x06 */ PAUSE_STATE_MAIN, // Pause menu ready for player inputs. + /* 0x07 */ PAUSE_STATE_SAVEPROMPT, + /* 0x08 */ PAUSE_STATE_GAMEOVER_0, + /* 0x09 */ PAUSE_STATE_GAMEOVER_1, + /* 0x0A */ PAUSE_STATE_GAMEOVER_2, + /* 0x0B */ PAUSE_STATE_GAMEOVER_3, + /* 0x0C */ PAUSE_STATE_GAMEOVER_4, + /* 0x0D */ PAUSE_STATE_GAMEOVER_5, + /* 0x0E */ PAUSE_STATE_GAMEOVER_SAVE_PROMPT, + /* 0x0F */ PAUSE_STATE_GAMEOVER_7, + /* 0x10 */ PAUSE_STATE_GAMEOVER_8, + /* 0x11 */ PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT, + /* 0x12 */ PAUSE_STATE_GAMEOVER_10, + /* 0x13 */ PAUSE_STATE_OWLWARP_0, + /* 0x14 */ PAUSE_STATE_OWLWARP_1, + /* 0x15 */ PAUSE_STATE_OWLWARP_2, + /* 0x16 */ PAUSE_STATE_OWLWARP_3, + /* 0x17 */ PAUSE_STATE_OWLWARP_SELECT, // Selecting the destination + /* 0x18 */ PAUSE_STATE_OWLWARP_CONFIRM, // Confirming the choice given + /* 0x19 */ PAUSE_STATE_OWLWARP_6, + /* 0x1A */ PAUSE_STATE_UNPAUSE_SETUP, // Unpause + /* 0x1B */ PAUSE_STATE_UNPAUSE_CLOSE +} PauseState; + +typedef enum { + /* 0x00 */ PAUSE_MAIN_STATE_IDLE, // Await input for the next action + /* 0x01 */ PAUSE_MAIN_STATE_SWITCHING_PAGE, + /* 0x02 */ PAUSE_MAIN_STATE_SONG_PLAYBACK, + /* 0x03 */ PAUSE_MAIN_STATE_EQUIP_ITEM, + /* 0x04 */ PAUSE_MAIN_STATE_SONG_PROMPT_INIT, + /* 0x05 */ PAUSE_MAIN_STATE_SONG_PROMPT, + /* 0x06 */ PAUSE_MAIN_STATE_SONG_PROMPT_DONE, + /* 0x07 */ PAUSE_MAIN_STATE_SONG_PROMPT_UNUSED, + /* 0x08 */ PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG, // Await input but the cursor is on a song + /* 0x09 */ PAUSE_MAIN_STATE_SONG_PLAYBACK_INIT, + /* 0x0F */ PAUSE_MAIN_STATE_EQUIP_MASK = 0xF, + /* 0x10 */ PAUSE_MAIN_STATE_BOMBERS_NOTEBOOK_OPEN, + /* 0x11 */ PAUSE_MAIN_STATE_UNK +} PauseMainState; + +typedef enum { + /* 0x00 */ PAUSE_SAVEPROMPT_STATE_0, + /* 0x01 */ PAUSE_SAVEPROMPT_STATE_1, + /* 0x02 */ PAUSE_SAVEPROMPT_STATE_2, + /* 0x03 */ PAUSE_SAVEPROMPT_STATE_3, + /* 0x04 */ PAUSE_SAVEPROMPT_STATE_4, + /* 0x05 */ PAUSE_SAVEPROMPT_STATE_5, + /* 0x06 */ PAUSE_SAVEPROMPT_STATE_6, + /* 0x07 */ PAUSE_SAVEPROMPT_STATE_7 +} PauseSavePromptState; + +#define IS_PAUSE_STATE_GAMEOVER \ + ((pauseCtx->state >= PAUSE_STATE_GAMEOVER_0) && (pauseCtx->state <= PAUSE_STATE_GAMEOVER_10)) + +#define IS_PAUSE_STATE_OWLWARP \ + ((pauseCtx->state >= PAUSE_STATE_OWLWARP_2) && (pauseCtx->state <= PAUSE_STATE_OWLWARP_6)) + +#define IS_PAUSE_MAIN_STATE_SAVE_PROMPT \ + ((pauseCtx->mainState >= PAUSE_MAIN_STATE_SONG_PROMPT_INIT) && \ + (pauseCtx->mainState <= PAUSE_MAIN_STATE_SONG_PROMPT_DONE)) + +typedef enum { + /* 0 */ PAUSE_EQUIP_C_LEFT, + /* 1 */ PAUSE_EQUIP_C_DOWN, + /* 2 */ PAUSE_EQUIP_C_RIGHT +} PauseEquipCButton; + +typedef enum { + /* 0 */ EQUIP_STATE_MAGIC_ARROW_GROW_ORB, + /* 1 */ EQUIP_STATE_MAGIC_ARROW_MOVE_TO_BOW_SLOT, + /* 2 */ EQUIP_STATE_MAGIC_ARROW_HOVER_OVER_BOW_SLOT, + /* 3 */ EQUIP_STATE_MOVE_TO_C_BTN +} EquipState; + +typedef enum { + /* 0 */ DEBUG_EDITOR_NONE, + /* 1 */ DEBUG_EDITOR_INVENTORY_INIT, + /* 2 */ DEBUG_EDITOR_INVENTORY, + /* 3 */ DEBUG_EDITOR_EVENTS +} DebugEditor; + +typedef enum { + /* 0 */ PAUSE_BG_PRERENDER_OFF, + /* 1 */ PAUSE_BG_PRERENDER_SETUP, // The current frame is only drawn for the purpose of serving as the pause background. + /* 2 */ PAUSE_BG_PRERENDER_PROCESS, // The previous frame was PAUSE_BG_PRERENDER_DRAW, now apply prerender filters. + /* 3 */ PAUSE_BG_PRERENDER_DONE, // The pause background is ready to be used. + /* 4 */ PAUSE_BG_PRERENDER_UNK4, + /* 5 */ PAUSE_BG_PRERENDER_MAX +} PauseBgPreRenderState; + +#define PAUSE_NAME_COLOR_SET_WHITE 0 +#define PAUSE_NAME_COLOR_SET_GREY 1 + +#define PAUSE_CURSOR_COLOR_SET_WHITE 0 +#define PAUSE_CURSOR_COLOR_SET_YELLOW 2 +#define PAUSE_CURSOR_COLOR_SET_BLUE 4 + +// To be used for Item-Page cursor and Mask-Page cursor +typedef enum { + /* 0 */ PAUSE_CURSOR_RESULT_NONE, + /* 1 */ PAUSE_CURSOR_RESULT_SLOT, + /* 2 */ PAUSE_CURSOR_RESULT_SPECIAL_POS +} PauseMoveCursorResult; + +#define NUM_ITEM_SLOTS 24 +#define NUM_MASK_SLOTS 24 + +#define PAUSE_PROMPT_YES 0 +#define PAUSE_PROMPT_NO 4 + +// NES +void KaleidoScope_MoveCursorToSpecialPos(PlayState* play, s16 cursorSpecialPos); +void KaleidoScope_DrawTexQuadRGBA32(GraphicsContext* gfxCtx, TexturePtr texture, u16 width, u16 height, u16 point); +void KaleidoScope_SetView(PauseContext* pauseCtx, f32 eyeX, f32 eyeY, f32 eyeZ); +void func_80821A04(PlayState* play); + +// Map +void KaleidoScope_DrawDungeonMap(PlayState* play); +void KaleidoScope_UpdateDungeonCursor(PlayState* play); +void KaleidoScope_DrawWorldMap(PlayState* play); +void KaleidoScope_UpdateWorldMapCursor(PlayState* play); + +// Collect +void KaleidoScope_DrawQuestStatus(PlayState* play); +void KaleidoScope_UpdateQuestCursor(PlayState* play); + +// Item +void KaleidoScope_SetCursorVtx(PauseContext* pauseCtx, u16 index, Vtx* vtx); +void KaleidoScope_DrawItemSelect(PlayState* play); +void KaleidoScope_UpdateItemCursor(PlayState* play); +void KaleidoScope_UpdateItemEquip(PlayState* play); + +// Mask +void KaleidoScope_DrawMaskSelect(PlayState* play); +void KaleidoScope_UpdateMaskCursor(PlayState* play); +void KaleidoScope_UpdateMaskEquip(PlayState* play); + +// Prompt +void KaleidoScope_UpdatePrompt(PlayState* play); + +// 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..a56afd71b 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 @@ -5,6 +5,8 @@ */ #include "z_kaleido_scope.h" +#include "overlays/gamestates/ovl_opening/z_opening.h" +#include "z64view.h" extern UNK_TYPE D_02001360; extern UNK_TYPE D_020044A0; @@ -16,21 +18,470 @@ extern UNK_TYPE D_0B000000; extern UNK_TYPE D_0C000000; extern UNK_TYPE D_0C006C00; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821900.s") +extern u8 sUnpausedButtonStatus[5]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8082192C.s") +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, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821958.s") +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, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821984.s") +s16 sGameOverPrimR = 0; +s16 sGameOverPrimG = 0; +s16 sGameOverPrimB = 0; +s16 sGameOverPrimAlpha = 255; +s16 sCursorPrimR = 0; +s16 sCursorPrimG = 0; +s16 sCursorPrimB = 0; +s16 sCursorEnvR = 0; +s16 sCursorEnvG = 0; +s16 sCursorEnvB = 0; +s16 sGameOverEnvR = 255; +s16 sGameOverEnvG = 0; +s16 sGameOverEnvB = 0; + +s16 sInDungeonScene = false; + +f32 sPageSwitchEyeDx[] = { + -PAUSE_EYE_DIST * (PAUSE_MAP_X - PAUSE_ITEM_X) / 16, // From PAUSE_ITEM to PAUSE_MAP (switching right) + -PAUSE_EYE_DIST*(PAUSE_MASK_X - PAUSE_ITEM_X) / 16, // From PAUSE_ITEM to PAUSE_MASK (switching left) + -PAUSE_EYE_DIST*(PAUSE_QUEST_X - PAUSE_MAP_X) / 16, // From PAUSE_MAP to PAUSE_QUEST (switching right) + -PAUSE_EYE_DIST*(PAUSE_ITEM_X - PAUSE_MAP_X) / 16, // From PAUSE_MAP to PAUSE_ITEM (switching left) + -PAUSE_EYE_DIST*(PAUSE_MASK_X - PAUSE_QUEST_X) / 16, // From PAUSE_QUEST to PAUSE_MASK (switching right) + -PAUSE_EYE_DIST*(PAUSE_MAP_X - PAUSE_QUEST_X) / 16, // From PAUSE_QUEST to PAUSE_MAP (switching left) + -PAUSE_EYE_DIST*(PAUSE_ITEM_X - PAUSE_MASK_X) / 16, // From PAUSE_MASK to PAUSE_ITEM (switching right) + -PAUSE_EYE_DIST*(PAUSE_QUEST_X - PAUSE_MASK_X) / 16, // From PAUSE_MASK to PAUSE_QUEST (switching left) +}; + +f32 sPageSwitchEyeDz[] = { + -PAUSE_EYE_DIST * (PAUSE_MAP_Z - PAUSE_ITEM_Z) / 16, // From PAUSE_ITEM to PAUSE_MAP (switching right) + -PAUSE_EYE_DIST*(PAUSE_MASK_Z - PAUSE_ITEM_Z) / 16, // From PAUSE_ITEM to PAUSE_MASK (switching left) + -PAUSE_EYE_DIST*(PAUSE_QUEST_Z - PAUSE_MAP_Z) / 16, // From PAUSE_MAP to PAUSE_QUEST (switching right) + -PAUSE_EYE_DIST*(PAUSE_ITEM_Z - PAUSE_MAP_Z) / 16, // From PAUSE_MAP to PAUSE_ITEM (switching left) + -PAUSE_EYE_DIST*(PAUSE_MASK_Z - PAUSE_QUEST_Z) / 16, // From PAUSE_QUEST to PAUSE_MASK (switching right) + -PAUSE_EYE_DIST*(PAUSE_MAP_Z - PAUSE_QUEST_Z) / 16, // From PAUSE_QUEST to PAUSE_MAP (switching left) + -PAUSE_EYE_DIST*(PAUSE_ITEM_Z - PAUSE_MASK_Z) / 16, // From PAUSE_MASK to PAUSE_ITEM (switching right) + -PAUSE_EYE_DIST*(PAUSE_QUEST_Z - PAUSE_MASK_Z) / 16, // From PAUSE_MASK to PAUSE_QUEST (switching left) +}; + +u16 sPageSwitchNextPageIndex[] = { + PAUSE_MAP, // From PAUSE_ITEM (switching right) + PAUSE_MASK, // From PAUSE_ITEM (switching left) + PAUSE_QUEST, // From PAUSE_MAP (switching right) + PAUSE_ITEM, // From PAUSE_MAP (switching left) + PAUSE_MASK, // From PAUSE_QUEST (switching right) + PAUSE_MAP, // From PAUSE_QUEST (switching left) + PAUSE_ITEM, // From PAUSE_MASK (switching right) + PAUSE_QUEST, // From PAUSE_MASK (switching left) +}; + +f32 sPauseMenuVerticalOffset = 0.0f; +f32 D_8082B90C = 0.0f; +f32 sPauseCursorLeftMoveOffsetX = 40.0f; +f32 sPauseCursorRightMoveOffsetX = -40.0f; + +s16 sPauseCursorLeftX = 0; +s16 sPauseCursorRightX = 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, +}; + +// TODO: Also applies to owl warps +s16 sGameOverRectPosY = 66; + +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 sQuestVtxRectLeft[] = { + 45, // QUEST_REMAINS_ODOLWA + 78, // QUEST_REMAINS_GOHT + 10, // QUEST_REMAINS_GYORG + 45, // QUEST_REMAINS_TWINMOLD + 80, // QUEST_SHIELD + 11, // QUEST_SWORD + -109, // QUEST_SONG_SONATA + -87, // QUEST_SONG_LULLABY + -65, // QUEST_SONG_BOSSA_NOVA + -41, // QUEST_SONG_ELEGY + -19, // QUEST_SONG_OATH + -18, // QUEST_SONG_SARIA + -109, // QUEST_SONG_TIME + -87, // QUEST_SONG_HEALING + -65, // QUEST_SONG_EPONA + -41, // QUEST_SONG_SOARING + -19, // QUEST_SONG_STORMS + -18, // QUEST_SONG_SUN + -103, // QUEST_BOMBERS_NOTEBOOK + 7, // QUEST_QUIVER + 82, // QUEST_BOMB_BAG + -110, // QUEST_SKULL_TOKEN (unused) + -54, // QUEST_HEART_PIECE + -98, // ocarina song button index 0 + -86, // ocarina song button index 1 + -74, // ocarina song button index 2 + -62, // ocarina song button index 3 + -50, // ocarina song button index 4 + -38, // ocarina song button index 5 + -26, // ocarina song button index 6 + -14, // ocarina song button index 7 + -98, // ocarina input button index 0 + -86, // ocarina input button index 1 + -74, // ocarina input button index 2 + -62, // ocarina input button index 3 + -50, // ocarina input button index 4 + -38, // ocarina input button index 5 + -26, // ocarina input button index 6 + -14, // ocarina input button index 7 +}; + +s16 sQuestVtxRectTop[] = { + 62, // QUEST_REMAINS_ODOLWA + 42, // QUEST_REMAINS_GOHT + 42, // QUEST_REMAINS_GYORG + 20, // QUEST_REMAINS_TWINMOLD + -9, // QUEST_SHIELD + -9, // QUEST_SWORD + -20, // QUEST_SONG_SONATA + -20, // QUEST_SONG_LULLABY + -20, // QUEST_SONG_BOSSA_NOVA + -20, // QUEST_SONG_ELEGY + -20, // QUEST_SONG_OATH + -20, // QUEST_SONG_SARIA + 2, // QUEST_SONG_TIME + 2, // QUEST_SONG_HEALING + 2, // QUEST_SONG_EPONA + 2, // QUEST_SONG_SOARING + 2, // QUEST_SONG_STORMS + 2, // QUEST_SONG_SUN + 54, // QUEST_BOMBERS_NOTEBOOK + -44, // QUEST_QUIVER + -44, // QUEST_BOMB_BAG + 34, // QUEST_SKULL_TOKEN (unused) + 58, // QUEST_HEART_PIECE + -52, // ocarina song button index 0 + -52, // ocarina song button index 1 + -52, // ocarina song button index 2 + -52, // ocarina song button index 3 + -52, // ocarina song button index 4 + -52, // ocarina song button index 5 + -52, // ocarina song button index 6 + -52, // ocarina song button index 7 + -52, // ocarina input button index 0 + -52, // ocarina input button index 1 + -52, // ocarina input button index 2 + -52, // ocarina input button index 3 + -52, // ocarina input button index 4 + -52, // ocarina input button index 5 + -52, // ocarina input button index 6 + -52, // ocarina input button index 7 +}; + +s16 sQuestVtxWidths[] = { + 32, // QUEST_REMAINS_ODOLWA + 32, // QUEST_REMAINS_GOHT + 32, // QUEST_REMAINS_GYORG + 32, // QUEST_REMAINS_TWINMOLD + 32, // QUEST_SHIELD + 32, // QUEST_SWORD + 16, // QUEST_SONG_SONATA + 16, // QUEST_SONG_LULLABY + 16, // QUEST_SONG_BOSSA_NOVA + 16, // QUEST_SONG_ELEGY + 16, // QUEST_SONG_OATH + 16, // QUEST_SONG_SARIA + 16, // QUEST_SONG_TIME + 16, // QUEST_SONG_HEALING + 16, // QUEST_SONG_EPONA + 16, // QUEST_SONG_SOARING + 16, // QUEST_SONG_STORMS + 16, // QUEST_SONG_SUN + 32, // QUEST_BOMBERS_NOTEBOOK + 32, // QUEST_QUIVER + 32, // QUEST_BOMB_BAG + 24, // QUEST_SKULL_TOKEN (unused) + 48, // QUEST_HEART_PIECE + 16, // ocarina song button index 0 + 16, // ocarina song button index 1 + 16, // ocarina song button index 2 + 16, // ocarina song button index 3 + 16, // ocarina song button index 4 + 16, // ocarina song button index 5 + 16, // ocarina song button index 6 + 16, // ocarina song button index 7 + 16, // ocarina input button index 0 + 16, // ocarina input button index 1 + 16, // ocarina input button index 2 + 16, // ocarina input button index 3 + 16, // ocarina input button index 4 + 16, // ocarina input button index 5 + 16, // ocarina input button index 6 + 16, // ocarina input button index 7 +}; + +s16 sQuestVtxHeights[] = { + 32, // QUEST_REMAINS_ODOLWA + 32, // QUEST_REMAINS_GOHT + 32, // QUEST_REMAINS_GYORG + 32, // QUEST_REMAINS_TWINMOLD + 32, // QUEST_SHIELD + 32, // QUEST_SWORD + 24, // QUEST_SONG_SONATA + 24, // QUEST_SONG_LULLABY + 24, // QUEST_SONG_BOSSA_NOVA + 24, // QUEST_SONG_ELEGY + 24, // QUEST_SONG_OATH + 24, // QUEST_SONG_SARIA + 24, // QUEST_SONG_TIME + 24, // QUEST_SONG_HEALING + 24, // QUEST_SONG_EPONA + 24, // QUEST_SONG_SOARING + 24, // QUEST_SONG_STORMS + 24, // QUEST_SONG_SUN + 32, // QUEST_BOMBERS_NOTEBOOK + 32, // QUEST_QUIVER + 32, // QUEST_BOMB_BAG + 24, // QUEST_SKULL_TOKEN (unused) + 48, // QUEST_HEART_PIECE + 16, // ocarina song button index 0 + 16, // ocarina song button index 1 + 16, // ocarina song button index 2 + 16, // ocarina song button index 3 + 16, // ocarina song button index 4 + 16, // ocarina song button index 5 + 16, // ocarina song button index 6 + 16, // ocarina song button index 7 + 16, // ocarina input button index 0 + 16, // ocarina input button index 1 + 16, // ocarina input button index 2 + 16, // ocarina input button index 3 + 16, // ocarina input button index 4 + 16, // ocarina input button index 5 + 16, // ocarina input button index 6 + 16, // ocarina input button index 7 +}; +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; + +void func_80821900(void* segment, u32 texIndex) { + func_80178E3C(SEGMENT_ROM_START(map_name_static), texIndex, segment, 0x400); +} + +void func_8082192C(void* segment, u32 texIndex) { + func_80178E3C(SEGMENT_ROM_START(map_name_static), texIndex, segment, 0xA00); +} + +void func_80821958(void* segment, u32 texIndex) { + func_80178E3C(SEGMENT_ROM_START(item_name_static), texIndex, segment, 0x400); +} + +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_MoveCursorToSpecialPos.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821A04.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821AD4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_DrawTexQuadRGBA32.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821CC4.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821D84.s") +void KaleidoScope_HandlePageToggles(PlayState* play, Input* input); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_HandlePageToggles.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80821F30.s") @@ -38,17 +489,20 @@ extern UNK_TYPE D_0C006C00; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80823350.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80824738.s") +void KaleidoScope_UpdateNamePanel(PlayState* play); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateNamePanel.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808248D0.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80824B90.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808256E4.s") +void KaleidoScope_UpdateOwlWarpNamePanel(PlayState* play); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateOwlWarpNamePanel.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_8082585C.s") +void KaleidoScope_UpdateSwitchPage(PlayState* play, Input* input); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_UpdateSwitchPage.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808259D4.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_SetView.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80825A50.s") @@ -62,8 +516,964 @@ extern UNK_TYPE D_0C006C00; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_Draw.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_808286D8.s") +void KaleidoScope_GrayOutTextureRGBA32(u32* texture, u16 pixelCount); +#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_GrayOutTextureRGBA32.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/func_80828788.s") +void KaleidoScope_UpdateOpening(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_kaleido_scope/KaleidoScope_Update.s") + pauseCtx->eye.x += sPageSwitchEyeDx[pauseCtx->nextPageMode] * 2.0f; + pauseCtx->eye.z += sPageSwitchEyeDz[pauseCtx->nextPageMode] * 2.0f; + pauseCtx->switchPageTimer += 8; + + if (pauseCtx->switchPageTimer == 64) { + // Finished opening + func_80112C0C(play, 1); + + if (pauseCtx->cursorSpecialPos == 0) { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = D_801C6A98[pauseCtx->pageIndex][0]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = D_801C6A98[pauseCtx->pageIndex][1]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = D_801C6A98[pauseCtx->pageIndex][1]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = D_801C6A98[pauseCtx->pageIndex][1]; + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_ENABLED; + } else { + gSaveContext.buttonStatus[EQUIP_SLOT_B] = BTN_ENABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = BTN_DISABLED; + gSaveContext.buttonStatus[EQUIP_SLOT_A] = BTN_DISABLED; + } + + pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + pauseCtx->state++; // PAUSE_STATE_MAIN + pauseCtx->alpha = 255; + func_80115844(play, DO_ACTION_RETURN); + } else if (pauseCtx->switchPageTimer == 64) { + pauseCtx->pageIndex = sPageSwitchNextPageIndex[pauseCtx->nextPageMode]; + pauseCtx->nextPageMode = (pauseCtx->pageIndex * 2) + 1; + } +} + +void KaleidoScope_Update(PlayState* play) { + static u16 sCursorPointsToOcarinaModes[] = { + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + }; + static s16 sUnpausedHudVisibility = HUD_VISIBILITY_IDLE; + static s16 sNextMainState = PAUSE_MAIN_STATE_IDLE; + static s16 sDelayTimer = 10; + static s16 sGameOverColorTimer = 0; + static s16 sStickXRepeatTimer = 0; + static s16 sStickYRepeatTimer = 0; + static s16 sStickXRepeatState = 0; + static s16 sStickYRepeatState = 0; + PauseContext* pauseCtx = &play->pauseCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; + GameOverContext* gameOverCtx = &play->gameOverCtx; + SramContext* sramCtx = &play->sramCtx; + Input* input = CONTROLLER1(&play->state); + size_t size0; + size_t size1; + size_t size2; + u16 itemId; + u16 worldMapCursorPoint; + void* iconItemLangSegment; + s16 stepR; + s16 stepG; + s16 stepB; + s16 stepA; + s16 stickAdjX = input->rel.stick_x; + + func_80109428(play); + + pauseCtx->stickAdjX = input->rel.stick_x; + pauseCtx->stickAdjY = input->rel.stick_y; + + switch (pauseCtx->state) { + case PAUSE_STATE_OPENING_2: + sUnpausedHudVisibility = gSaveContext.hudVisibility; + sPauseMenuVerticalOffset = -6240.0f; + + sUnpausedButtonStatus[EQUIP_SLOT_B] = gSaveContext.buttonStatus[EQUIP_SLOT_B]; + sUnpausedButtonStatus[EQUIP_SLOT_C_LEFT] = gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT]; + sUnpausedButtonStatus[EQUIP_SLOT_C_DOWN] = gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN]; + sUnpausedButtonStatus[EQUIP_SLOT_C_RIGHT] = gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT]; + sUnpausedButtonStatus[EQUIP_SLOT_A] = gSaveContext.buttonStatus[EQUIP_SLOT_A]; + + pauseCtx->cursorXIndex[PAUSE_MAP] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + DUNGEON_FLOOR_INDEX_4; + pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->unk_256 = R_REVERSE_FLOOR_INDEX + DUNGEON_FLOOR_INDEX_4; + + sPauseCursorLeftX = -175; + sPauseCursorRightX = 155; + pauseCtx->roll = -314.0f; + + pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)play->objectCtx.spaceStart); + size0 = SEGMENT_ROM_SIZE(icon_item_static_old); + func_80178E7C((uintptr_t)SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + + gSegments[0x08] = PHYSICAL_TO_VIRTUAL(pauseCtx->iconItemSegment); + + for (itemId = 0; itemId <= ITEM_BOW_ARROW_FIRE; itemId++) { + if (!gPlayerFormItemRestrictions[(void)0, gSaveContext.save.playerForm][(s32)itemId]) { + KaleidoScope_GrayOutTextureRGBA32(Lib_SegmentedToVirtual(gItemIcons[(s32)itemId]), 0x400); + } + } + + pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); + size1 = SEGMENT_ROM_SIZE(icon_item_24_static_old); + func_80178E7C((uintptr_t)SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, size1); + + pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size1); + if (func_8010A0A4(play)) { + size_t size = SEGMENT_ROM_SIZE(icon_item_dungeon_static); + + DmaMgr_SendRequest0(pauseCtx->iconItemAltSegment, SEGMENT_ROM_START(icon_item_dungeon_static), size); + iconItemLangSegment = + func_801068FC(play, (void*)ALIGN16((uintptr_t)pauseCtx->iconItemAltSegment + size), size); + sInDungeonScene = true; + } else { + size_t size; + + sInDungeonScene = false; + size = SEGMENT_ROM_SIZE(icon_item_field_static); + DmaMgr_SendRequest0(pauseCtx->iconItemAltSegment, _icon_item_field_staticSegmentRomStart, size); + iconItemLangSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemAltSegment + size); + } + + pauseCtx->iconItemLangSegment = iconItemLangSegment; + size2 = SEGMENT_ROM_SIZE(icon_item_jpn_static); + DmaMgr_SendRequest0(pauseCtx->iconItemLangSegment, SEGMENT_ROM_START(icon_item_jpn_static), size2); + + pauseCtx->nameSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemLangSegment + size2); + func_8011552C(play, DO_ACTION_INFO); + if (((void)0, gSaveContext.worldMapArea) < 0x16) { + func_8082192C(pauseCtx->nameSegment + 0x400, ((void)0, gSaveContext.worldMapArea)); + } + + pauseCtx->iconItemVtxSegment = (void*)ALIGN16((uintptr_t)pauseCtx->nameSegment + 0xA00); + DmaMgr_SendRequest0(pauseCtx->iconItemVtxSegment, SEGMENT_ROM_START(icon_item_vtx_static), + SEGMENT_ROM_SIZE(icon_item_vtx_static)); + + pauseCtx->unk_2B6 = 255; + pauseCtx->unk_2B7 = 255; + pauseCtx->unk_2B8 = 255; + pauseCtx->state = PAUSE_STATE_OPENING_3; + break; + + case PAUSE_STATE_OPENING_3: + pauseCtx->infoPanelOffsetY += 10; + pauseCtx->itemPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = pauseCtx->maskPageRoll -= 40.0f; + + interfaceCtx->startAlpha += 63; + sPauseCursorLeftX += (s16)(sPauseCursorLeftMoveOffsetX / 4); + sPauseCursorRightX += (s16)(sPauseCursorRightMoveOffsetX / 4); + pauseCtx->alpha += 31; + if (pauseCtx->itemPageRoll == 0) { + interfaceCtx->startAlpha = 255; + sPauseMenuVerticalOffset = 0.0f; + pauseCtx->state = PAUSE_STATE_OPENING_4; + } + + KaleidoScope_UpdateOpening(play); + break; + + case PAUSE_STATE_OPENING_4: + pauseCtx->alpha += 31; + KaleidoScope_UpdateOpening(play); + + if (pauseCtx->state == PAUSE_STATE_MAIN) { + KaleidoScope_UpdateNamePanel(play); + } + break; + + case PAUSE_STATE_MAIN: + switch (pauseCtx->mainState) { + case PAUSE_MAIN_STATE_IDLE: + if (!pauseCtx->itemDescriptionOn && + (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_B))) { + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->state = PAUSE_STATE_UNPAUSE_SETUP; + sPauseMenuVerticalOffset = -6240.0f; + func_801A3AEC(0); + } + break; + + case PAUSE_MAIN_STATE_SWITCHING_PAGE: + KaleidoScope_UpdateSwitchPage(play, input); + break; + + case PAUSE_MAIN_STATE_SONG_PLAYBACK: + // Song is in playback + pauseCtx->ocarinaStaff = AudioOcarina_GetPlaybackStaff(); + if (pauseCtx->ocarinaStaff->state == 0) { + // Song playback is finished, give song prompt to player + pauseCtx->mainState = PAUSE_MAIN_STATE_SONG_PROMPT_INIT; + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + break; + + case PAUSE_MAIN_STATE_EQUIP_ITEM: + KaleidoScope_UpdateItemEquip(play); + break; + + case PAUSE_MAIN_STATE_SONG_PROMPT_INIT: + break; + + case PAUSE_MAIN_STATE_SONG_PROMPT: + pauseCtx->ocarinaStaff = AudioOcarina_GetPlayingStaff(); + + if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_B)) { + // Abort having the player play the song and close the pause menu + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->state = PAUSE_STATE_UNPAUSE_SETUP; + sPauseMenuVerticalOffset = -6240.0f; + func_801A3AEC(0); + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + } else if (pauseCtx->ocarinaStaff->state == pauseCtx->ocarinaSongIndex) { + // The player successfully played the song + play_sound(NA_SE_SY_TRE_BOX_APPEAR); + sNextMainState = PAUSE_MAIN_STATE_IDLE; + sDelayTimer = 30; + pauseCtx->mainState = PAUSE_MAIN_STATE_SONG_PROMPT_DONE; + } else if (pauseCtx->ocarinaStaff->state == 0xFF) { + // The player failed to play the song + play_sound(NA_SE_SY_OCARINA_ERROR); + sNextMainState = PAUSE_MAIN_STATE_SONG_PROMPT_INIT; + sDelayTimer = 20; + pauseCtx->mainState = PAUSE_MAIN_STATE_SONG_PROMPT_DONE; + } + break; + + case PAUSE_MAIN_STATE_SONG_PROMPT_DONE: + sDelayTimer--; + if (sDelayTimer == 0) { + pauseCtx->mainState = sNextMainState; + if (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + } + } + break; + + case PAUSE_MAIN_STATE_SONG_PROMPT_UNUSED: + break; + + case PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG: + if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_B)) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->state = PAUSE_STATE_UNPAUSE_SETUP; + sPauseMenuVerticalOffset = -6240.0f; + func_801A3AEC(0); + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + } + break; + + case PAUSE_MAIN_STATE_SONG_PLAYBACK_INIT: + break; + + case PAUSE_MAIN_STATE_EQUIP_MASK: + KaleidoScope_UpdateMaskEquip(play); + break; + + case PAUSE_MAIN_STATE_BOMBERS_NOTEBOOK_OPEN: + if (!play->pauseCtx.bombersNotebookOpen) { + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + } + break; + + default: + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + break; + } + break; + + case PAUSE_STATE_SAVEPROMPT: + switch (pauseCtx->savePromptState) { + case PAUSE_SAVEPROMPT_STATE_0: + pauseCtx->roll -= 78.5f; + sPauseCursorLeftX -= (s16)(sPauseCursorLeftMoveOffsetX / 4); + sPauseCursorRightX -= (s16)(sPauseCursorRightMoveOffsetX / 4); + if (pauseCtx->roll <= -628.0f) { + pauseCtx->roll = -628.0f; + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_1; + } + break; + + case PAUSE_SAVEPROMPT_STATE_1: + if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_CUP)) { + if (pauseCtx->promptChoice != PAUSE_PROMPT_YES) { + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_2; + } else { + play_sound(NA_SE_SY_PIECE_OF_HEART); + Play_SaveCycleSceneFlags(&play->state); + gSaveContext.save.playerData.savedSceneId = play->sceneId; + func_8014546C(sramCtx); + if (gSaveContext.unk_3F3F == 0) { + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_5; + } else { + func_80147008(sramCtx, D_801C67C8[gSaveContext.fileNum], + D_801C67F0[gSaveContext.fileNum]); + func_80147020(sramCtx); + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_4; + } + sDelayTimer = 90; + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_START)) { + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_3; + sPauseMenuVerticalOffset = -6240.0f; + D_8082B90C = pauseCtx->roll; + func_801A3AEC(0); + } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_2; + D_8082B90C = pauseCtx->roll; + } + break; + + case PAUSE_SAVEPROMPT_STATE_4: + if (sramCtx->status == 0) { + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_5; + } + break; + + case PAUSE_SAVEPROMPT_STATE_5: + if (CHECK_BTN_ALL(input->press.button, BTN_B) || CHECK_BTN_ALL(input->press.button, BTN_A) || + CHECK_BTN_ALL(input->press.button, BTN_START) || (--sDelayTimer == 0)) { + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_3; + sPauseMenuVerticalOffset = -6240.0f; + D_8082B90C = pauseCtx->roll; + func_801A3AEC(0); + } + break; + + case PAUSE_SAVEPROMPT_STATE_3: + case PAUSE_SAVEPROMPT_STATE_7: + if (pauseCtx->roll != (D_8082B90C + 160.0f)) { + pauseCtx->itemPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = + pauseCtx->maskPageRoll += 40.0f; + pauseCtx->roll += 40.0f; + pauseCtx->infoPanelOffsetY -= 10; + sPauseCursorLeftX -= (s16)(sPauseCursorLeftMoveOffsetX / 4); + sPauseCursorRightX -= (s16)(sPauseCursorRightMoveOffsetX / 4); + pauseCtx->alpha -= 63; + if (pauseCtx->roll == (D_8082B90C + 160.0f)) { + pauseCtx->alpha = 0; + } + } else { + pauseCtx->debugEditor = DEBUG_EDITOR_NONE; + pauseCtx->state = PAUSE_STATE_UNPAUSE_CLOSE; + pauseCtx->itemPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = + pauseCtx->maskPageRoll = 160.0f; + pauseCtx->roll = -434.0f; + pauseCtx->namedItem = PAUSE_ITEM_NONE; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + } + break; + + case PAUSE_SAVEPROMPT_STATE_2: + pauseCtx->roll += 78.5f; + sPauseCursorLeftX += (s16)(sPauseCursorLeftMoveOffsetX / 4); + sPauseCursorRightX += (s16)(sPauseCursorRightMoveOffsetX / 4); + if (pauseCtx->roll >= -314.0f) { + pauseCtx->state = PAUSE_STATE_MAIN; + pauseCtx->savePromptState = PAUSE_SAVEPROMPT_STATE_0; + pauseCtx->roll = -314.0f; + pauseCtx->itemPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = + pauseCtx->maskPageRoll = 0.0f; + func_8011552C(play, DO_ACTION_INFO); + gSaveContext.buttonStatus[EQUIP_SLOT_B] = D_801C6A98[pauseCtx->pageIndex + 1][0]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = D_801C6A98[pauseCtx->pageIndex + 1][1]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = D_801C6A98[pauseCtx->pageIndex + 1][1]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = D_801C6A98[pauseCtx->pageIndex + 1][1]; + if ((pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_LEFT) || + (pauseCtx->cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT)) { + KaleidoScope_MoveCursorToSpecialPos(play, pauseCtx->cursorSpecialPos); + } else { + func_80821A04(play); + } + } + break; + + case PAUSE_SAVEPROMPT_STATE_6: + if (interfaceCtx->screenFillAlpha != 255) { + interfaceCtx->screenFillAlpha += 10; + if (interfaceCtx->screenFillAlpha >= 255) { + interfaceCtx->screenFillAlpha = 255; + pauseCtx->state = PAUSE_STATE_OFF; + Game_SetFramerateDivisor(&play->state, 3); + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_UNK4; + Object_LoadAll(&play->objectCtx); + BgCheck_InitCollisionHeaders(&play->colCtx, play); + STOP_GAMESTATE(&play->state); + SET_NEXT_GAMESTATE(&play->state, TitleSetup_Init, sizeof(TitleSetupState)); + func_801A4058(0x14); + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; + } + } + break; + } + break; + + case PAUSE_STATE_GAMEOVER_2: + pauseCtx->cursorSlot[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + DUNGEON_FLOOR_INDEX_4; + pauseCtx->cursorPoint[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + DUNGEON_FLOOR_INDEX_4; + sPauseCursorLeftX = -175; + sPauseCursorRightX = 155; + pauseCtx->roll = -434.0f; + Interface_SetHudVisibility(HUD_VISIBILITY_NONE); + + pauseCtx->iconItemSegment = + (void*)(((uintptr_t)play->objectCtx.spaceStart + 0x30) & ~0x3F); // Messed up ALIGN64 + size0 = SEGMENT_ROM_SIZE(icon_item_static_old); + func_80178E7C(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + + pauseCtx->iconItem24Segment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); + size1 = SEGMENT_ROM_SIZE(icon_item_24_static_old); + func_80178E7C(SEGMENT_ROM_START(icon_item_24_static_test), pauseCtx->iconItem24Segment, size1); + + pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItem24Segment + size1); + size2 = SEGMENT_ROM_SIZE(icon_item_gameover_static); + DmaMgr_SendRequest0(pauseCtx->iconItemAltSegment, SEGMENT_ROM_START(icon_item_gameover_static), size2); + + pauseCtx->iconItemLangSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemAltSegment + size2); + DmaMgr_SendRequest0(pauseCtx->iconItemLangSegment, SEGMENT_ROM_START(icon_item_jpn_static), + SEGMENT_ROM_SIZE(icon_item_jpn_static)); + + gSaveContext.timerStates[TIMER_ID_MOON_CRASH] = TIMER_STATE_OFF; + + sGameOverPrimR = 255; + sGameOverPrimG = 130; + sGameOverPrimB = 0; + sGameOverPrimAlpha = 0; + sGameOverEnvR = 30; + sGameOverEnvG = 0; + sGameOverEnvB = 0; + sGameOverRectPosY = 98; + sGameOverColorTimer = 30; + + pauseCtx->promptChoice = PAUSE_PROMPT_YES; + pauseCtx->state++; + if (gameOverCtx->state == GAMEOVER_INACTIVE) { + pauseCtx->state++; + } + break; + + case PAUSE_STATE_GAMEOVER_3: + stepR = ABS_ALT(sGameOverPrimR - 30) / sGameOverColorTimer; + stepG = ABS_ALT(sGameOverPrimG - 0) / sGameOverColorTimer; + stepB = ABS_ALT(sGameOverPrimB - 0) / sGameOverColorTimer; + stepA = ABS_ALT(sGameOverPrimAlpha - 255) / sGameOverColorTimer; + if (sGameOverPrimR >= 30) { + sGameOverPrimR -= stepR; + } else { + sGameOverPrimR += stepR; + } + if (sGameOverPrimG >= 0) { + sGameOverPrimG -= stepG; + } else { + sGameOverPrimG += stepG; + } + if (sGameOverPrimB >= 0) { + sGameOverPrimB -= stepB; + } else { + sGameOverPrimB += stepB; + } + if (sGameOverPrimAlpha >= 255) { + sGameOverPrimAlpha -= stepA; + } else { + sGameOverPrimAlpha += stepA; + } + + stepR = ABS_ALT(sGameOverEnvR - 255) / sGameOverColorTimer; + stepG = ABS_ALT(sGameOverEnvG - 130) / sGameOverColorTimer; + stepB = ABS_ALT(sGameOverEnvB - 0) / sGameOverColorTimer; + if (sGameOverEnvR >= 255) { + sGameOverEnvR -= stepR; + } else { + sGameOverEnvR += stepR; + } + if (sGameOverEnvG >= 130) { + sGameOverEnvG -= stepG; + } else { + sGameOverEnvG += stepG; + } + if (sGameOverEnvB >= 0) { + sGameOverEnvB -= stepB; + } else { + sGameOverEnvB += stepB; + } + + sGameOverColorTimer--; + if (sGameOverColorTimer == 0) { + sGameOverPrimR = 30; + sGameOverPrimG = 0; + sGameOverPrimB = 0; + sGameOverPrimAlpha = 255; + + sGameOverEnvR = 255; + sGameOverEnvG = 130; + sGameOverEnvB = 0; + + sGameOverColorTimer = 40; + pauseCtx->state++; + } + break; + + case PAUSE_STATE_GAMEOVER_4: + sGameOverColorTimer--; + if (sGameOverColorTimer == 0) { + pauseCtx->state = PAUSE_STATE_GAMEOVER_5; + } + break; + + case PAUSE_STATE_GAMEOVER_5: + pauseCtx->infoPanelOffsetY += 10; + pauseCtx->roll -= 40.0f; + pauseCtx->itemPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = pauseCtx->maskPageRoll = + pauseCtx->roll; + interfaceCtx->startAlpha += 63; + sGameOverRectPosY -= 3; + sPauseCursorLeftX += (s16)(sPauseCursorLeftMoveOffsetX / 4); + sPauseCursorRightX += (s16)(sPauseCursorRightMoveOffsetX / 4); + pauseCtx->alpha += 31; + if (pauseCtx->roll < -628.0f) { + pauseCtx->roll = -628.0f; + interfaceCtx->startAlpha = 255; + sGameOverRectPosY = 66; + sPauseMenuVerticalOffset = 0.0f; + pauseCtx->alpha = 255; + if (gameOverCtx->state == GAMEOVER_INACTIVE) { + pauseCtx->state = PAUSE_STATE_GAMEOVER_SAVE_PROMPT; + } else { + pauseCtx->state = PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT; + } + } + break; + + case PAUSE_STATE_GAMEOVER_SAVE_PROMPT: + if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + if (pauseCtx->promptChoice != PAUSE_PROMPT_YES) { + pauseCtx->promptChoice = PAUSE_PROMPT_YES; + play_sound(NA_SE_SY_DECIDE); + pauseCtx->state = PAUSE_STATE_OFF; + Game_SetFramerateDivisor(&play->state, 3); + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_UNK4; + Object_LoadAll(&play->objectCtx); + BgCheck_InitCollisionHeaders(&play->colCtx, play); + } else { + play_sound(NA_SE_SY_PIECE_OF_HEART); + pauseCtx->promptChoice = PAUSE_PROMPT_YES; + Play_SaveCycleSceneFlags(&play->state); + gSaveContext.save.playerData.savedSceneId = play->sceneId; + gSaveContext.save.playerData.health = 0x30; + func_8014546C(sramCtx); + if (gSaveContext.unk_3F3F == 0) { + pauseCtx->state = PAUSE_STATE_GAMEOVER_8; + } else { + func_80147008(sramCtx, D_801C67C8[gSaveContext.fileNum], D_801C67F0[gSaveContext.fileNum]); + func_80147020(sramCtx); + pauseCtx->state = PAUSE_STATE_GAMEOVER_7; + } + sDelayTimer = 90; + } + } else if ((pauseCtx->promptChoice == PAUSE_PROMPT_YES) && (stickAdjX >= 30)) { + play_sound(NA_SE_SY_CURSOR); + pauseCtx->promptChoice = PAUSE_PROMPT_NO; + } else if ((pauseCtx->promptChoice != PAUSE_PROMPT_YES) && (stickAdjX <= -30)) { + play_sound(NA_SE_SY_CURSOR); + pauseCtx->promptChoice = PAUSE_PROMPT_YES; + } + break; + + case PAUSE_STATE_GAMEOVER_7: + if (sramCtx->status == 0) { + pauseCtx->state = PAUSE_STATE_OFF; + Game_SetFramerateDivisor(&play->state, 3); + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_UNK4; + Object_LoadAll(&play->objectCtx); + BgCheck_InitCollisionHeaders(&play->colCtx, play); + } + break; + + case PAUSE_STATE_GAMEOVER_8: + sDelayTimer--; + if (sDelayTimer == 0) { + pauseCtx->state = PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT; + gameOverCtx->state++; + } else if ((sDelayTimer <= 80) && + (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START))) { + pauseCtx->state = PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT; + gameOverCtx->state++; + func_801A3AEC(0); + } + break; + + case PAUSE_STATE_GAMEOVER_CONTINUE_PROMPT: + if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_START)) { + if (pauseCtx->promptChoice == PAUSE_PROMPT_YES) { + play_sound(NA_SE_SY_PIECE_OF_HEART); + Play_SaveCycleSceneFlags(&play->state); + if (gSaveContext.save.entrance == ENTRANCE(UNSET_0D, 0)) {} + } else { // PAUSE_PROMPT_NO + play_sound(NA_SE_SY_DECIDE); + } + pauseCtx->state = PAUSE_STATE_GAMEOVER_10; + } + break; + + case PAUSE_STATE_GAMEOVER_10: + if (interfaceCtx->screenFillAlpha != 255) { + interfaceCtx->screenFillAlpha += 10; + if (interfaceCtx->screenFillAlpha >= 255) { + interfaceCtx->screenFillAlpha = 255; + + pauseCtx->state = PAUSE_STATE_OFF; + Game_SetFramerateDivisor(&play->state, 3); + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_UNK4; + Object_LoadAll(&play->objectCtx); + BgCheck_InitCollisionHeaders(&play->colCtx, play); + + if (pauseCtx->promptChoice == PAUSE_PROMPT_YES) { + func_80169FDC(&play->state); + gSaveContext.respawnFlag = -2; + gSaveContext.nextTransitionType = TRANS_TYPE_02; + gSaveContext.save.playerData.health = 0x30; + Audio_SetSpec(0xA); + gSaveContext.healthAccumulator = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; + gSaveContext.magicFlag = 0; + gSaveContext.magicCapacity = 0; + gSaveContext.magicFillTarget = gSaveContext.save.playerData.magic; + gSaveContext.save.playerData.magicLevel = 0; + gSaveContext.save.playerData.magic = 0; + } else { // PAUSE_PROMPT_NO + STOP_GAMESTATE(&play->state); + SET_NEXT_GAMESTATE(&play->state, TitleSetup_Init, sizeof(TitleSetupState)); + } + } + } + break; + + case PAUSE_STATE_OWLWARP_2: + sPauseMenuVerticalOffset = -6240.0f; + + sUnpausedButtonStatus[EQUIP_SLOT_B] = gSaveContext.buttonStatus[EQUIP_SLOT_B]; + sUnpausedButtonStatus[EQUIP_SLOT_C_LEFT] = gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT]; + sUnpausedButtonStatus[EQUIP_SLOT_C_DOWN] = gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN]; + sUnpausedButtonStatus[EQUIP_SLOT_C_RIGHT] = gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT]; + sUnpausedButtonStatus[EQUIP_SLOT_A] = gSaveContext.buttonStatus[EQUIP_SLOT_A]; + + pauseCtx->cursorXIndex[PAUSE_MAP] = 0; + pauseCtx->cursorSlot[PAUSE_MAP] = R_REVERSE_FLOOR_INDEX + DUNGEON_FLOOR_INDEX_4; + pauseCtx->cursorPoint[PAUSE_MAP] = pauseCtx->unk_256 = R_REVERSE_FLOOR_INDEX + DUNGEON_FLOOR_INDEX_4; + + sPauseCursorLeftX = -175; + sPauseCursorRightX = 155; + + pauseCtx->iconItemSegment = (void*)ALIGN16((uintptr_t)play->objectCtx.spaceStart); + size0 = SEGMENT_ROM_SIZE(icon_item_static_old); + func_80178E7C(SEGMENT_ROM_START(icon_item_static_test), pauseCtx->iconItemSegment, size0); + + pauseCtx->iconItemAltSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemSegment + size0); + sInDungeonScene = false; + size1 = SEGMENT_ROM_SIZE(icon_item_field_static); + DmaMgr_SendRequest0(pauseCtx->iconItemAltSegment, SEGMENT_ROM_START(icon_item_field_static), size1); + + pauseCtx->iconItemLangSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemAltSegment + size1); + size2 = SEGMENT_ROM_SIZE(icon_item_jpn_static); + DmaMgr_SendRequest0(pauseCtx->iconItemLangSegment, SEGMENT_ROM_START(icon_item_jpn_static), size2); + + pauseCtx->nameSegment = (void*)ALIGN16((uintptr_t)pauseCtx->iconItemLangSegment + size2); + func_8011552C(play, DO_ACTION_WARP); + worldMapCursorPoint = pauseCtx->cursorPoint[PAUSE_WORLD_MAP]; + func_80821900(pauseCtx->nameSegment, worldMapCursorPoint); + + pauseCtx->iconItemVtxSegment = (void*)ALIGN16((uintptr_t)pauseCtx->nameSegment + 0xA00); + DmaMgr_SendRequest0(pauseCtx->iconItemVtxSegment, SEGMENT_ROM_START(icon_item_vtx_static), + SEGMENT_ROM_SIZE(icon_item_vtx_static)); + + pauseCtx->state = PAUSE_STATE_OWLWARP_3; + sGameOverRectPosY = 98; + pauseCtx->promptChoice = PAUSE_PROMPT_YES; + break; + + case PAUSE_STATE_OWLWARP_3: + R_PAUSE_OWLWARP_ALPHA += 20; + pauseCtx->infoPanelOffsetY += 10; + pauseCtx->mapPageRoll -= 40.0f; + interfaceCtx->startAlpha += 63; + sGameOverRectPosY -= 3; + sPauseCursorLeftX += (s16)(sPauseCursorLeftMoveOffsetX / 4); + sPauseCursorRightX += (s16)(sPauseCursorRightMoveOffsetX / 4); + pauseCtx->alpha += 31; + + if (pauseCtx->mapPageRoll == 0) { + interfaceCtx->startAlpha = 255; + sPauseMenuVerticalOffset = 0.0f; + pauseCtx->alpha = 255; + pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; + pauseCtx->cursorSpecialPos = 0; + pauseCtx->state = PAUSE_STATE_OWLWARP_SELECT; + R_PAUSE_OWLWARP_ALPHA = 120; + } + break; + + case PAUSE_STATE_OWLWARP_SELECT: + if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_B)) { + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->state = PAUSE_STATE_OWLWARP_6; + sPauseMenuVerticalOffset = -6240.0f; + func_801A3AEC(0); + play->msgCtx.ocarinaMode = 4; + gSaveContext.prevHudVisibility = HUD_VISIBILITY_ALL; + } else if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + play_sound(NA_SE_SY_DECIDE); + Message_StartTextbox(play, 0x1B93, NULL); + pauseCtx->state = PAUSE_STATE_OWLWARP_CONFIRM; + } else { + KaleidoScope_UpdateOwlWarpNamePanel(play); + } + break; + + case PAUSE_STATE_OWLWARP_CONFIRM: + if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + msgCtx->msgLength = 0; + msgCtx->msgMode = 0; + if (msgCtx->choiceIndex == 0) { + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->state = PAUSE_STATE_OWLWARP_6; + sPauseMenuVerticalOffset = -6240.0f; + func_801A3AEC(0); + play->msgCtx.ocarinaMode = sCursorPointsToOcarinaModes[pauseCtx->cursorPoint[PAUSE_WORLD_MAP]]; + play_sound(NA_SE_SY_DECIDE); + } else { + pauseCtx->state = PAUSE_STATE_OWLWARP_SELECT; + func_8011552C(play, DO_ACTION_WARP); + play_sound(NA_SE_SY_MESSAGE_PASS); + } + } else if (CHECK_BTN_ALL(input->press.button, BTN_B)) { + msgCtx->msgLength = 0; + msgCtx->msgMode = 0; + pauseCtx->state = PAUSE_STATE_OWLWARP_SELECT; + play_sound(NA_SE_SY_MESSAGE_PASS); + } else if (CHECK_BTN_ALL(input->press.button, BTN_START)) { + msgCtx->msgLength = 0; + msgCtx->msgMode = 0; + func_8011552C(play, DO_ACTION_NONE); + pauseCtx->state = PAUSE_STATE_OWLWARP_6; + sPauseMenuVerticalOffset = -6240.0f; + func_801A3AEC(0); + play->msgCtx.ocarinaMode = 4; + gSaveContext.prevHudVisibility = HUD_VISIBILITY_ALL; + } + break; + + case PAUSE_STATE_OWLWARP_6: + if (pauseCtx->mapPageRoll != 160.0f) { + R_PAUSE_OWLWARP_ALPHA -= 60; + if (R_PAUSE_OWLWARP_ALPHA <= 0) { + R_PAUSE_OWLWARP_ALPHA = 0; + } + pauseCtx->infoPanelOffsetY -= 10; + pauseCtx->mapPageRoll += 40.0f; + interfaceCtx->startAlpha -= 63; + sPauseCursorLeftX -= (s16)(sPauseCursorLeftMoveOffsetX / 4); + sPauseCursorRightX -= (s16)(sPauseCursorRightMoveOffsetX / 4); + pauseCtx->alpha -= 63; + if (pauseCtx->mapPageRoll == 160.0f) { + pauseCtx->alpha = 0; + } + } else { + pauseCtx->debugEditor = DEBUG_EDITOR_NONE; + pauseCtx->state = PAUSE_STATE_UNPAUSE_CLOSE; + pauseCtx->itemPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = pauseCtx->maskPageRoll = + 160.0f; + pauseCtx->namedItem = PAUSE_ITEM_NONE; + interfaceCtx->startAlpha = 0; + pauseCtx->pageIndex = pauseCtx->unk_2C8; + pauseCtx->cursorPoint[PAUSE_WORLD_MAP] = pauseCtx->unk_2CA; + } + break; + + case PAUSE_STATE_UNPAUSE_SETUP: + if (pauseCtx->itemPageRoll != 160.0f) { + pauseCtx->infoPanelOffsetY -= 10; + pauseCtx->itemPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = pauseCtx->maskPageRoll += + 40.0f; + interfaceCtx->startAlpha -= 63; + sPauseCursorLeftX -= (s16)(sPauseCursorLeftMoveOffsetX / 4); + sPauseCursorRightX -= (s16)(sPauseCursorRightMoveOffsetX / 4); + pauseCtx->alpha -= 63; + if (pauseCtx->itemPageRoll == 160.0f) { + pauseCtx->alpha = 0; + } + } else { + pauseCtx->debugEditor = DEBUG_EDITOR_NONE; + pauseCtx->state = PAUSE_STATE_UNPAUSE_CLOSE; + pauseCtx->maskPageRoll = 160.0f; + pauseCtx->questPageRoll = 160.0f; + pauseCtx->mapPageRoll = 160.0f; + pauseCtx->itemPageRoll = 160.0f; + pauseCtx->namedItem = PAUSE_ITEM_NONE; + interfaceCtx->startAlpha = 0; + } + break; + + case PAUSE_STATE_UNPAUSE_CLOSE: + pauseCtx->state = PAUSE_STATE_OFF; + Game_SetFramerateDivisor(&play->state, 3); + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_UNK4; + Object_LoadAll(&play->objectCtx); + BgCheck_InitCollisionHeaders(&play->colCtx, play); + + gSaveContext.buttonStatus[EQUIP_SLOT_B] = sUnpausedButtonStatus[EQUIP_SLOT_B]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_LEFT] = sUnpausedButtonStatus[EQUIP_SLOT_C_LEFT]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_DOWN] = sUnpausedButtonStatus[EQUIP_SLOT_C_DOWN]; + gSaveContext.buttonStatus[EQUIP_SLOT_C_RIGHT] = sUnpausedButtonStatus[EQUIP_SLOT_C_RIGHT]; + gSaveContext.buttonStatus[EQUIP_SLOT_A] = sUnpausedButtonStatus[EQUIP_SLOT_A]; + + func_80110038(play); + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(HUD_VISIBILITY_ALL); + MsgEvent_SendNullTask(); + func_80143324(play, &play->skyboxCtx, play->skyboxId); + + if ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF)) { + func_80115844(play, DO_ACTION_STOP); + func_8011552C(play, DO_ACTION_STOP); + Interface_SetHudVisibility(HUD_VISIBILITY_A_B_C); + } else { + interfaceCtx->unk_222 = interfaceCtx->unk_224 = 0; + } + gSaveContext.hudVisibility = HUD_VISIBILITY_IDLE; + Interface_SetHudVisibility(sUnpausedHudVisibility); + func_801A3A7C(0); + break; + } + + // If stickAdj is held, set a delay to allow the cursor to read the next input. + // The first delay is given a longer time than all subsequent delays. + if (!IS_PAUSE_STATE_GAMEOVER && (pauseCtx->state != PAUSE_STATE_SAVEPROMPT)) { + if (pauseCtx->stickAdjX < -30) { + if (sStickXRepeatState == -1) { + sStickXRepeatTimer--; + if (sStickXRepeatTimer < 0) { + // Allow the input to register and apply the delay for all subsequent repeated inputs + sStickXRepeatTimer = 2; + } else { + // Cancel the current input + pauseCtx->stickAdjX = 0; + } + } else { + // Allow the input to register and apply the delay for the first repeated input + sStickXRepeatTimer = 10; + sStickXRepeatState = -1; + } + } else if (pauseCtx->stickAdjX > 30) { + if (sStickXRepeatState == 1) { + sStickXRepeatTimer--; + if (sStickXRepeatTimer < 0) { + // Allow the input to register and apply the delay for all subsequent repeated inputs + sStickXRepeatTimer = 2; + } else { + // Cancel the current input + pauseCtx->stickAdjX = 0; + } + } else { + // Allow the input to register and apply the delay for the first repeated input + sStickXRepeatTimer = 10; + sStickXRepeatState = 1; + } + } else { + sStickXRepeatState = 0; + } + + if (pauseCtx->stickAdjY < -30) { + if (sStickYRepeatState == -1) { + sStickYRepeatTimer--; + if (sStickYRepeatTimer < 0) { + // Allow the input to register and apply the delay for all subsequent repeated inputs + sStickYRepeatTimer = 2; + } else { + // Cancel the current input + pauseCtx->stickAdjY = 0; + } + } else { + // Allow the input to register and apply the delay for the first repeated input + sStickYRepeatTimer = 10; + sStickYRepeatState = -1; + } + } else if (pauseCtx->stickAdjY > 30) { + if (sStickYRepeatState == 1) { + sStickYRepeatTimer--; + if (sStickYRepeatTimer < 0) { + // Allow the input to register and apply the delay for all subsequent repeated inputs + sStickYRepeatTimer = 2; + } else { + // Cancel the current input + pauseCtx->stickAdjY = 0; + } + } else { + // Allow the input to register and apply the delay for the first repeated input + sStickYRepeatTimer = 10; + sStickYRepeatState = 1; + } + } else { + sStickYRepeatState = 0; + } + } + + // Process the Cursor input + if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_DONE) && (pauseCtx->debugEditor == DEBUG_EDITOR_NONE) && + !IS_PAUSE_STATE_OWLWARP && + (((pauseCtx->state >= PAUSE_STATE_OPENING_3) && (pauseCtx->state <= PAUSE_STATE_SAVEPROMPT)) || + ((pauseCtx->state >= PAUSE_STATE_GAMEOVER_2) && (pauseCtx->state <= PAUSE_STATE_UNPAUSE_SETUP)))) { + if (!IS_PAUSE_STATE_GAMEOVER) { + switch (pauseCtx->pageIndex) { + case PAUSE_ITEM: + KaleidoScope_UpdateItemCursor(play); + break; + + case PAUSE_MAP: + if (sInDungeonScene) { + KaleidoScope_UpdateDungeonCursor(play); + } else { + KaleidoScope_UpdateWorldMapCursor(play); + } + break; + + case PAUSE_QUEST: + KaleidoScope_UpdateQuestCursor(play); + break; + + case PAUSE_MASK: + KaleidoScope_UpdateMaskCursor(play); + break; + } + + if ((pauseCtx->state == PAUSE_STATE_MAIN) && + ((pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE) || + (pauseCtx->mainState == PAUSE_MAIN_STATE_IDLE_CURSOR_ON_SONG))) { + KaleidoScope_HandlePageToggles(play, input); + } + } + if (pauseCtx->state == PAUSE_STATE_MAIN) { + KaleidoScope_UpdateNamePanel(play); + } + } else if (pauseCtx->state == PAUSE_STATE_OWLWARP_SELECT) { + KaleidoScope_UpdateWorldMapCursor(play); + KaleidoScope_UpdateNamePanel(play); + } + + // Update the inventory editor + if ((pauseCtx->debugEditor == DEBUG_EDITOR_INVENTORY_INIT) || (pauseCtx->debugEditor == DEBUG_EDITOR_INVENTORY)) { + KaleidoScope_UpdateInventoryEditor(play); + } +} 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 ddbb4547d..3144cab20 100644 --- a/tools/ZAPD/.gitrepo +++ b/tools/ZAPD/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/zeldaret/ZAPD.git branch = master - commit = 87cb648b4311d20673452111edaf4d38a5290c28 - parent = 06412c070f0240eacfaa860eee99b9c723245b7f + commit = 5786abbdd2d0fd14907e03575a0bd972c1fe9b28 + parent = e451a103ba5d14af3dd14acfa54a6b4999fd951f method = merge - cmdver = 0.4.3 + cmdver = 0.4.5 diff --git a/tools/ZAPD/ExporterTest/CollisionExporter.cpp b/tools/ZAPD/ExporterTest/CollisionExporter.cpp index 87b9a05a2..db5ad1a79 100644 --- a/tools/ZAPD/ExporterTest/CollisionExporter.cpp +++ b/tools/ZAPD/ExporterTest/CollisionExporter.cpp @@ -58,9 +58,11 @@ void ExporterExample_Collision::Save(ZResource* res, [[maybe_unused]] fs::path o writer->Seek(col->polyTypeDefSegmentOffset, SeekOffsetType::Start); - for (uint16_t i = 0; i < col->polygonTypes.size(); i++) - writer->Write(col->polygonTypes[i]); - + for (const auto& poly : col->polygonTypes) + { + writer->Write(poly.data[0]); + writer->Write(poly.data[1]); + } writer->Seek(col->camDataSegmentOffset, SeekOffsetType::Start); for (auto entry : col->camData->entries) diff --git a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj index 5bdfc7aa6..341f72ceb 100644 --- a/tools/ZAPD/ExporterTest/ExporterTest.vcxproj +++ b/tools/ZAPD/ExporterTest/ExporterTest.vcxproj @@ -30,7 +30,7 @@ Application true - v143 + v142 Unicode @@ -43,7 +43,7 @@ StaticLibrary true - v143 + v142 Unicode diff --git a/tools/ZAPD/ExporterTest/RoomExporter.cpp b/tools/ZAPD/ExporterTest/RoomExporter.cpp index 6c5552d8f..9a5ea19d1 100644 --- a/tools/ZAPD/ExporterTest/RoomExporter.cpp +++ b/tools/ZAPD/ExporterTest/RoomExporter.cpp @@ -334,7 +334,7 @@ void ExporterExample_Room::Save(ZResource* res, fs::path outPath, BinaryWriter* writer->Write(entry.rotX); writer->Write(entry.rotY); writer->Write(entry.rotZ); - writer->Write(entry.initVar); + writer->Write(entry.params); } writer->Seek(oldOffset, SeekOffsetType::Start); diff --git a/tools/ZAPD/Jenkinsfile b/tools/ZAPD/Jenkinsfile index 9c4dde712..48535a51c 100644 --- a/tools/ZAPD/Jenkinsfile +++ b/tools/ZAPD/Jenkinsfile @@ -68,6 +68,15 @@ pipeline { } } + // INSTALL PYTHON DEPENDENCIES, currently MM only + stage('Install Python dependencies') { + steps { + dir('mm') { + sh 'python3 -m pip install -r requirements.txt' + } + } + } + // BUILD THE REPOS stage('Build repos') { parallel { @@ -82,7 +91,7 @@ pipeline { steps { dir('mm') { sh 'make -j disasm' - sh 'make -j all' + sh 'make -j' } } } diff --git a/tools/ZAPD/Makefile b/tools/ZAPD/Makefile index 2b47a8039..e725f94f8 100644 --- a/tools/ZAPD/Makefile +++ b/tools/ZAPD/Makefile @@ -15,7 +15,7 @@ else CXX := g++ endif -INC := -I ZAPD -I lib/elfio -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils +INC := -I ZAPD -I lib/libgfxd -I lib/tinyxml2 -I ZAPDUtils CXXFLAGS := -fpic -std=c++17 -Wall -Wextra -fno-omit-frame-pointer OPTFLAGS := diff --git a/tools/ZAPD/README.md b/tools/ZAPD/README.md index 448aea033..bb96bab1b 100644 --- a/tools/ZAPD/README.md +++ b/tools/ZAPD/README.md @@ -71,9 +71,6 @@ ZAPD needs a _File parsing mode_ to be passed as first parameter. The options ar - `blb`: "Build blob" mode. - In this mode, ZAPD expects a BIN file as input and a filename as ouput. - ZAPD will try to convert the given BIN into the contents of a `uint8_t` C array. -- `bovl`: "Build overlay" mode. - - In this mode, ZAPD expects an overlay C file as input, a filename as ouput and an overlay configuration path (`-cfg`). - - ZAPD will generate a reloc `.s` file. ZAPD also accepts the following list of extra parameters: @@ -102,8 +99,6 @@ ZAPD also accepts the following list of extra parameters: - `ia16` - `ci4` - `ci8` -- `-cfg PATH`: Set cfg path (for overlays). - - Can be used only in `bovl` mode. - `-rconf PATH` Read Config File. - `-eh`: Enable error handler. - Only available in non-Windows environments. diff --git a/tools/ZAPD/ZAPD/CrashHandler.cpp b/tools/ZAPD/ZAPD/CrashHandler.cpp new file mode 100644 index 000000000..356866536 --- /dev/null +++ b/tools/ZAPD/ZAPD/CrashHandler.cpp @@ -0,0 +1,205 @@ +#include "CrashHandler.h" +#include "Utils/StringHelper.h" + +#if __has_include() +#define HAS_POSIX 1 +#else +#define HAS_POSIX 0 +#endif + +#include +#include +#include +#include + +#if HAS_POSIX == 1 +#include +#include // for __cxa_demangle +#include // for dladdr +#include +#include +#elif defined(_MSC_VER) +#include +#include + +#include + +#pragma comment(lib, "Dbghelp.lib") +#endif + +// Feel free to add more crash messages. +static std::array crashEasterEgg = { + "\tYou've met with a terrible fate, haven't you?", + "\tSEA BEARS FOAM. SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY: CRASSSH!", + "\tZAPD has fallen and cannot get up.", + "\tIT'S A SECRET TO EVERYBODY. \n\tBut it shouldn't be, you'd better ask about it!", + "\tI AM ERROR.", + "\tGRUMBLE,GRUMBLE...", + "\tDODONGO DISLIKES SMOKE \n\tAnd ZAPD dislikes whatever you fed it.", + "\tMay the way of the Hero lead \n\tto the debugger.", + "\tTHE WIND FISH SLUMBERS LONG... \n\tTHE HERO'S LIFE GONE... ", + "\tSEA BEARS FOAM, SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY CRASSSH!", + "\tYou've met with a terrible fate, haven't you?", + "\tMaster, I calculate a 100% probability that ZAPD has crashed. \n\tAdditionally, the " + "batteries in your Wii Remote are nearly depleted.", + "\t CONGRATURATIONS! \n" + "\tAll Pages are displayed.\n" + "\t THANK YOU! \n" + "\t You are great debugger!", + "\tRCP is HUNG UP!!\n" + "\tOh! MY GOD!!", +}; + +#if HAS_POSIX == 1 +void ErrorHandler(int sig) +{ + std::array arr; + constexpr size_t nMaxFrames = arr.size(); + size_t size = backtrace(arr.data(), nMaxFrames); + char** symbols = backtrace_symbols(arr.data(), nMaxFrames); + + fprintf(stderr, "\nZAPD crashed. (Signal: %i)\n", sig); + + srand(time(nullptr)); + auto easterIndex = rand() % crashEasterEgg.size(); + + fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); + + fprintf(stderr, "Traceback:\n"); + for (size_t i = 1; i < size; i++) + { + Dl_info info; + uint32_t gotAddress = dladdr(arr[i], &info); + std::string functionName(symbols[i]); + + if (gotAddress != 0 && info.dli_sname != nullptr) + { + int32_t status; + char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); + const char* nameFound = info.dli_sname; + + if (status == 0) + { + nameFound = demangled; + } + + functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound, + (char*)arr[i] - (char*)info.dli_saddr); + free(demangled); + } + + fprintf(stderr, "%-3zd %s\n", i, functionName.c_str()); + } + + fprintf(stderr, "\n"); + + free(symbols); + exit(1); +} +#elif defined(_MSC_VER) + +void printStack(CONTEXT* ctx) +{ + BOOL result; + HANDLE process; + HANDLE thread; + HMODULE hModule; + ULONG frame; + DWORD64 displacement; + DWORD disp; + + srand(time(nullptr)); + auto easterIndex = rand() % crashEasterEgg.size(); + + fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); + +#if defined(_M_AMD64) + STACKFRAME64 stack; + memset(&stack, 0, sizeof(STACKFRAME64)); +#else + STACKFRAME stack; + memset(&stack, 0, sizeof(STACKFRAME)); +#endif + + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME + sizeof(TCHAR)]; + char module[512]; + + PSYMBOL_INFO symbol = (PSYMBOL_INFO)buffer; + + CONTEXT ctx2; + memcpy(&ctx2, ctx, sizeof(CONTEXT)); + + process = GetCurrentProcess(); + thread = GetCurrentThread(); + SymInitialize(process, nullptr, TRUE); + + constexpr DWORD machineType = +#if defined(_M_AMD64) + IMAGE_FILE_MACHINE_AMD64; +#else + IMAGE_FILE_MACHINE_I386; +#endif + + displacement = 0; + + for (frame = 0;; frame++) + { + result = StackWalk(machineType, process, thread, &stack, &ctx2, nullptr, + SymFunctionTableAccess, SymGetModuleBase, nullptr); + if (!result) + { + break; + } + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_SYM_NAME; + SymFromAddr(process, (ULONG64)stack.AddrPC.Offset, &displacement, symbol); +#if defined(_M_AMD64) + IMAGEHLP_LINE64 line; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); +#else + IMAGEHLP_LINE line; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE); +#endif + if (SymGetLineFromAddr(process, stack.AddrPC.Offset, &disp, &line)) + { + fprintf(stderr, "%u\t %s in %s: line: %lu: \n", frame, symbol->Name, line.FileName, + line.LineNumber); + } + + else + { + fprintf(stderr, "%u\tat % s\n", frame, symbol->Name); + hModule = nullptr; + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | + GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, + (LPCTSTR)(stack.AddrPC.Offset), &hModule); + + if (hModule != nullptr) + { + GetModuleFileNameA(hModule, module, 512 - 1); + } + fprintf(stderr, "%u\tIn %s\n", frame, module); + } + } +} + +LONG seh_filter(_EXCEPTION_POINTERS* ex) +{ + fprintf(stderr, "EXCEPTION 0x%x occured\n", ex->ExceptionRecord->ExceptionCode); + printStack(ex->ContextRecord); + return EXCEPTION_EXECUTE_HANDLER; +} +#endif + +void CrashHandler_Init() +{ +#if HAS_POSIX == 1 + signal(SIGSEGV, ErrorHandler); + signal(SIGABRT, ErrorHandler); +#elif defined(_MSC_VER) + SetUnhandledExceptionFilter(seh_filter); +#else + HANDLE_WARNING(WarningType::Always, + "tried to set error handler, but this ZAPD build lacks support for one", ""); +#endif +} diff --git a/tools/ZAPD/ZAPD/CrashHandler.h b/tools/ZAPD/ZAPD/CrashHandler.h new file mode 100644 index 000000000..102778bec --- /dev/null +++ b/tools/ZAPD/ZAPD/CrashHandler.h @@ -0,0 +1,6 @@ +#ifndef CRASH_HANDLER_H +#define CRASH_HANDLER_H + +void CrashHandler_Init(); + +#endif diff --git a/tools/ZAPD/ZAPD/GameConfig.cpp b/tools/ZAPD/ZAPD/GameConfig.cpp index ae29ba28f..777cf9d49 100644 --- a/tools/ZAPD/ZAPD/GameConfig.cpp +++ b/tools/ZAPD/ZAPD/GameConfig.cpp @@ -94,6 +94,26 @@ void GameConfig::ConfigFunc_ObjectList(const tinyxml2::XMLElement& element) objectList.emplace_back(std::move(line)); } +void GameConfig::ConfigFunc_EntranceList(const tinyxml2::XMLElement& element) +{ + std::string fileName = element.Attribute("File"); + std::vector lines = + File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); + + for (auto& line : lines) + entranceList.emplace_back(std::move(line)); +} + +void GameConfig::ConfigFunc_specialEntranceList(const tinyxml2::XMLElement& element) +{ + std::string fileName = element.Attribute("File"); + std::vector lines = + File::ReadAllLines(Path::GetDirectoryName(configFilePath) / fileName); + + for (auto& line : lines) + specialEntranceList.emplace_back(std::move(line)); +} + void GameConfig::ConfigFunc_TexturePool(const tinyxml2::XMLElement& element) { std::string fileName = element.Attribute("File"); @@ -145,10 +165,12 @@ void GameConfig::ConfigFunc_ExternalFile(const tinyxml2::XMLElement& element) void GameConfig::ReadConfigFile(const fs::path& argConfigFilePath) { - static const std::map ConfigFuncDictionary = { + static const std::unordered_map ConfigFuncDictionary = { {"SymbolMap", &GameConfig::ConfigFunc_SymbolMap}, {"ActorList", &GameConfig::ConfigFunc_ActorList}, {"ObjectList", &GameConfig::ConfigFunc_ObjectList}, + {"EntranceList", &GameConfig::ConfigFunc_EntranceList}, + {"SpecialEntranceList", &GameConfig::ConfigFunc_specialEntranceList}, {"TexturePool", &GameConfig::ConfigFunc_TexturePool}, {"BGConfig", &GameConfig::ConfigFunc_BGConfig}, {"ExternalXMLFolder", &GameConfig::ConfigFunc_ExternalXMLFolder}, diff --git a/tools/ZAPD/ZAPD/GameConfig.h b/tools/ZAPD/ZAPD/GameConfig.h index c478d16ce..2a783d10a 100644 --- a/tools/ZAPD/ZAPD/GameConfig.h +++ b/tools/ZAPD/ZAPD/GameConfig.h @@ -31,6 +31,8 @@ public: std::map symbolMap; std::vector actorList; std::vector objectList; + std::vector entranceList; + std::vector specialEntranceList; std::map texturePool; // Key = CRC // ZBackground @@ -49,6 +51,8 @@ public: void ConfigFunc_SymbolMap(const tinyxml2::XMLElement& element); void ConfigFunc_ActorList(const tinyxml2::XMLElement& element); void ConfigFunc_ObjectList(const tinyxml2::XMLElement& element); + void ConfigFunc_EntranceList(const tinyxml2::XMLElement& element); + void ConfigFunc_specialEntranceList(const tinyxml2::XMLElement& element); void ConfigFunc_TexturePool(const tinyxml2::XMLElement& element); void ConfigFunc_BGConfig(const tinyxml2::XMLElement& element); void ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element); diff --git a/tools/ZAPD/ZAPD/ImageBackend.cpp b/tools/ZAPD/ZAPD/ImageBackend.cpp index 8accb6b4e..307945b40 100644 --- a/tools/ZAPD/ZAPD/ImageBackend.cpp +++ b/tools/ZAPD/ZAPD/ImageBackend.cpp @@ -398,7 +398,7 @@ void ImageBackend::SetPaletteIndex(size_t index, uint8_t nR, uint8_t nG, uint8_t alphaPalette[index] = nA; } -void ImageBackend::SetPalette(const ImageBackend& pal) +void ImageBackend::SetPalette(const ImageBackend& pal, uint32_t offset) { assert(isColorIndexed); size_t bytePerPixel = pal.GetBytesPerPixel(); @@ -422,7 +422,7 @@ void ImageBackend::SetPalette(const ImageBackend& pal) uint8_t g = pal.pixelMatrix[y][x * bytePerPixel + 1]; uint8_t b = pal.pixelMatrix[y][x * bytePerPixel + 2]; uint8_t a = pal.pixelMatrix[y][x * bytePerPixel + 3]; - SetPaletteIndex(index, r, g, b, a); + SetPaletteIndex(index + offset, r, g, b, a); } } } diff --git a/tools/ZAPD/ZAPD/ImageBackend.h b/tools/ZAPD/ZAPD/ImageBackend.h index 9e05a2eed..0b1f4806c 100644 --- a/tools/ZAPD/ZAPD/ImageBackend.h +++ b/tools/ZAPD/ZAPD/ImageBackend.h @@ -42,8 +42,9 @@ public: void SetGrayscalePixel(size_t y, size_t x, uint8_t grayscale, uint8_t alpha = 0); void SetIndexedPixel(size_t y, size_t x, uint8_t index, uint8_t grayscale); + void SetIndexedPixel(size_t y, size_t x, uint8_t index, RGBAPixel pixel); void SetPaletteIndex(size_t index, uint8_t nR, uint8_t nG, uint8_t nB, uint8_t nA); - void SetPalette(const ImageBackend& pal); + void SetPalette(const ImageBackend& pal, uint32_t offset = 0); uint32_t GetWidth() const; uint32_t GetHeight() const; diff --git a/tools/ZAPD/ZAPD/Main.cpp b/tools/ZAPD/ZAPD/Main.cpp index 531edc094..2563154e5 100644 --- a/tools/ZAPD/ZAPD/Main.cpp +++ b/tools/ZAPD/ZAPD/Main.cpp @@ -1,5 +1,4 @@ #include "Globals.h" -#include "Overlays/ZOverlay.h" #include "Utils/Directory.h" #include "Utils/File.h" #include "Utils/Path.h" @@ -10,22 +9,12 @@ #include "ZFile.h" #include "ZTexture.h" -#if !defined(_MSC_VER) && !defined(__CYGWIN__) -#include -#include -#include -#include // for __cxa_demangle -#include // for dladdr -#include -#include -#endif +#include "CrashHandler.h" #include #include #include "tinyxml2.h" -extern const char gBuildHash[]; - bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, ZFileMode fileMode); @@ -33,61 +22,7 @@ void BuildAssetTexture(const fs::path& pngFilePath, TextureType texType, const f void BuildAssetBackground(const fs::path& imageFilePath, const fs::path& outPath); void BuildAssetBlob(const fs::path& blobFilePath, const fs::path& outPath); -#if !defined(_MSC_VER) && !defined(__CYGWIN__) -#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0])) -void ErrorHandler(int sig) -{ - void* array[4096]; - const size_t nMaxFrames = sizeof(array) / sizeof(array[0]); - size_t size = backtrace(array, nMaxFrames); - char** symbols = backtrace_symbols(array, nMaxFrames); - - fprintf(stderr, "\nZAPD crashed. (Signal: %i)\n", sig); - - // Feel free to add more crash messages. - const char* crashEasterEgg[] = { - "\tYou've met with a terrible fate, haven't you?", - "\tSEA BEARS FOAM. SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY: CRASSSH!", - "\tZAPD has fallen and cannot get up.", - }; - - srand(time(nullptr)); - auto easterIndex = rand() % ARRAY_COUNT(crashEasterEgg); - - fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); - - fprintf(stderr, "Traceback:\n"); - for (size_t i = 1; i < size; i++) - { - Dl_info info; - uint32_t gotAddress = dladdr(array[i], &info); - std::string functionName(symbols[i]); - - if (gotAddress != 0 && info.dli_sname != nullptr) - { - int32_t status; - char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); - const char* nameFound = info.dli_sname; - - if (status == 0) - { - nameFound = demangled; - } - - functionName = StringHelper::Sprintf("%s (+0x%X)", nameFound, - (char*)array[i] - (char*)info.dli_saddr); - free(demangled); - } - - fprintf(stderr, "%-3zd %s\n", i, functionName.c_str()); - } - - fprintf(stderr, "\n"); - - free(symbols); - exit(1); -} -#endif +extern const char gBuildHash[]; int main(int argc, char* argv[]) { @@ -175,26 +110,13 @@ int main(int argc, char* argv[]) { Globals::Instance->texType = ZTexture::GetTextureTypeFromString(argv[++i]); } - else if (arg == "-cfg") // Set cfg path (for overlays) - // TODO: Change the name of this to something else so it doesn't - // get confused with XML config files. - { - Globals::Instance->cfgPath = argv[++i]; - } else if (arg == "-rconf") // Read Config File { Globals::Instance->cfg.ReadConfigFile(argv[++i]); } else if (arg == "-eh") // Enable Error Handler { -#if !defined(_MSC_VER) && !defined(__CYGWIN__) - signal(SIGSEGV, ErrorHandler); - signal(SIGABRT, ErrorHandler); -#else - HANDLE_WARNING(WarningType::Always, - "tried to set error handler, but this ZAPD build lacks support for one", - ""); -#endif + CrashHandler_Init(); } else if (arg == "-v") // Verbose { @@ -231,8 +153,6 @@ int main(int argc, char* argv[]) fileMode = ZFileMode::BuildTexture; else if (buildMode == "bren") fileMode = ZFileMode::BuildBackground; - else if (buildMode == "bovl") - fileMode = ZFileMode::BuildOverlay; else if (buildMode == "bsf") fileMode = ZFileMode::BuildSourceFile; else if (buildMode == "bblb") @@ -314,16 +234,6 @@ int main(int argc, char* argv[]) { BuildAssetBlob(Globals::Instance->inputPath, Globals::Instance->outputPath); } - else if (fileMode == ZFileMode::BuildOverlay) - { - ZOverlay* overlay = - ZOverlay::FromBuild(Path::GetDirectoryName(Globals::Instance->inputPath), - Path::GetDirectoryName(Globals::Instance->cfgPath)); - - if (overlay != nullptr) - File::WriteAllText(Globals::Instance->outputPath.string(), - overlay->GetSourceOutputCode("")); - } delete g; return 0; diff --git a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp index b69f47321..edefbc051 100644 --- a/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp +++ b/tools/ZAPD/ZAPD/OtherStructs/CutsceneMM_Commands.cpp @@ -54,6 +54,7 @@ CutsceneMMCommand_GenericCmd::CutsceneMMCommand_GenericCmd(const std::vector(cmdId); + entries.reserve(numEntries); for (size_t i = 0; i < numEntries; i++) { auto* entry = new CutsceneSubCommandEntry_GenericMMCmd(rawData, rawDataIndex, cmdId); @@ -96,6 +97,7 @@ CutsceneMMCommand_Camera::CutsceneMMCommand_Camera(const std::vector& r { rawDataIndex += 4; + entries.reserve(numEntries); for (size_t i = 0; i < numEntries / 4; i++) { auto* entry = new CutsceneSubCommandEntry_Camera(rawData, rawDataIndex); @@ -138,6 +140,7 @@ CutsceneMMCommand_FadeScreen::CutsceneMMCommand_FadeScreen(const std::vector& { rawDataIndex += 4; + entries.reserve(numEntries); for (size_t i = 0; i < numEntries; i++) { auto* entry = new CutsceneSubCommandEntry_FadeSeq(rawData, rawDataIndex); @@ -199,6 +203,7 @@ CutsceneMMCommand_NonImplemented::CutsceneMMCommand_NonImplemented( { rawDataIndex += 4; + entries.reserve(numEntries); for (size_t i = 0; i < numEntries; i++) { auto* entry = new CutsceneSubCommandEntry_NonImplemented(rawData, rawDataIndex); diff --git a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp index a716176b9..8ae4c69d7 100644 --- a/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp +++ b/tools/ZAPD/ZAPD/OtherStructs/Cutscene_Commands.cpp @@ -154,6 +154,7 @@ CutsceneCommand_GenericCmd::CutsceneCommand_GenericCmd(const std::vector(cmdId); + entries.reserve(numEntries); for (size_t i = 0; i < numEntries; i++) { @@ -320,6 +321,7 @@ CutsceneCommand_Rumble::CutsceneCommand_Rumble(const std::vector& rawDa { rawDataIndex += 4; + entries.reserve(numEntries); for (size_t i = 0; i < numEntries; i++) { auto* entry = new CutsceneSubCommandEntry_Rumble(rawData, rawDataIndex); @@ -363,6 +365,7 @@ CutsceneCommand_SetTime::CutsceneCommand_SetTime(const std::vector& raw { rawDataIndex += 4; + entries.reserve(numEntries); for (size_t i = 0; i < numEntries; i++) { auto* entry = new CutsceneSubCommandEntry_SetTime(rawData, rawDataIndex); @@ -438,6 +441,7 @@ CutsceneCommand_TextBox::CutsceneCommand_TextBox(const std::vector& raw { rawDataIndex += 4; + entries.reserve(numEntries); for (size_t i = 0; i < numEntries; i++) { auto* entry = new CutsceneSubCommandEntry_TextBox(rawData, rawDataIndex); @@ -516,6 +520,7 @@ CutsceneCommand_ActorAction::CutsceneCommand_ActorAction(const std::vectorsegment) { uint32_t unk_8_Offset = Seg2Filespace(unk_8, parent->baseAddress); + + unk_8_arr.reserve(unk_0); for (size_t i = 0; i < unk_0; i++) { Struct_800A57C0 unk8_data(parent); @@ -117,6 +119,8 @@ void Struct_800A598C::ParseRawData() if (unk_C != 0 && GETSEGNUM(unk_8) == parent->segment) { uint32_t unk_C_Offset = Seg2Filespace(unk_C, parent->baseAddress); + + unk_C_arr.reserve(unk_2); for (size_t i = 0; i < unk_2; i++) { Struct_800A598C_2 unkC_data(parent); @@ -244,6 +248,8 @@ void Struct_800A5E28::ParseRawData() if (unk_4 != 0 && GETSEGNUM(unk_4) == parent->segment) { uint32_t unk_4_Offset = Seg2Filespace(unk_4, parent->baseAddress); + + unk_4_arr.reserve(unk_2); for (size_t i = 0; i < unk_2; i++) { Struct_800A598C unk_4_data(parent); diff --git a/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp b/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp deleted file mode 100644 index 113c4ef33..000000000 --- a/tools/ZAPD/ZAPD/Overlays/ZOverlay.cpp +++ /dev/null @@ -1,352 +0,0 @@ -#include "ZOverlay.h" - -#include -#include -#include "Globals.h" -#include "Utils/Directory.h" -#include "Utils/File.h" -#include "Utils/Path.h" -#include "Utils/StringHelper.h" -#include "WarningHandler.h" - -using namespace ELFIO; - -const char* RelocationEntry::GetSectionName() const -{ - switch (sectionType) - { - case SectionType::Text: - return ".text"; - case SectionType::Data: - return ".data"; - case SectionType::RoData: - return ".rodata"; - case SectionType::Bss: - return ".bss"; - case SectionType::ERROR: - return ".ERROR"; - } - assert(!"Oh no :c"); -} - -const char* RelocationEntry::GetRelocTypeName() const -{ - switch (relocationType) - { - case RelocationType::R_MIPS_32: - return "R_MIPS_32"; - case RelocationType::R_MIPS_26: - return "R_MIPS_26"; - case RelocationType::R_MIPS_HI16: - return "R_MIPS_HI16"; - case RelocationType::R_MIPS_LO16: - return "R_MIPS_LO16"; - } - assert(!"Oh no :c"); -} - -ZOverlay::ZOverlay() -{ - name = ""; - entries = std::vector(); -} - -ZOverlay::ZOverlay(const std::string& nName) : ZOverlay() -{ - name = nName; -} - -ZOverlay::~ZOverlay() -{ - for (auto entry : entries) - if (entry) - delete entry; - entries.clear(); -} - -static const std::unordered_set sRelSections = { - ".rel.text", - ".rel.data", - ".rel.rodata", -}; -static const std::unordered_set sSections = { - ".text", ".data", ".symtab", ".rodata", ".rodata.str1.4", ".rodata.cst4", ".rodata.cst8", -}; - -ZOverlay* ZOverlay::FromBuild(fs::path buildPath, fs::path cfgFolderPath) -{ - std::string cfgText = File::ReadAllText(cfgFolderPath / "overlay.cfg"); - std::vector cfgLines = StringHelper::Split(cfgText, "\n"); - - ZOverlay* ovl = new ZOverlay(StringHelper::Strip(cfgLines[0], "\r")); - ovl->cfgLines = cfgLines; - - int32_t sectionOffs[5] = {0}; - std::vector textRelocs; - std::vector dataRelocs; - std::vector rodataRelocs; - - // get the elf files - std::vector readers; - for (size_t i = 1; i < cfgLines.size(); i++) - { - std::string elfPath = - (buildPath / (cfgLines[i].substr(0, cfgLines[i].size() - 2) + ".o")).string(); - elfio* reader = new elfio(); - - if (!reader->load(elfPath)) - { - // not all files were compiled - for (auto r : readers) - delete r; - readers.clear(); - - delete ovl; - return nullptr; - } - - readers.push_back(reader); - } - - for (size_t curReaderId = 0; curReaderId < readers.size(); curReaderId++) - { - auto& curReader = readers[curReaderId]; - - Elf_Half sec_num = curReader->sections.size(); - for (int32_t i = 0; i < sec_num; i++) - { - section* pSec = curReader->sections[i]; - - if (pSec->get_type() != SHT_REL || - sRelSections.find(pSec->get_name()) == sRelSections.end()) - { - continue; - } - - symbol_section_accessor currentSymbols(*curReader, - curReader->sections[(Elf_Half)pSec->get_link()]); - - SectionType sectionType = GetSectionTypeFromStr(pSec->get_name()); - - if (sectionType == SectionType::ERROR) - { - HANDLE_WARNING(WarningType::Always, "one of the section types returned ERROR", ""); - } - - relocation_section_accessor relocs(*curReader, pSec); - for (Elf_Xword j = 0; j < relocs.get_entries_num(); j++) - { - Elf64_Addr offset = 0; - Elf_Word symbol = 0; - Elf_Word type = 0; - { - Elf_Sxword addend = 0; - relocs.get_entry(j, offset, symbol, type, addend); - } - - std::string curSymName; - Elf_Half curSymShndx = SHN_UNDEF; - { - Elf64_Addr value; - Elf_Xword size; - unsigned char bind; - unsigned char type; - unsigned char other; - currentSymbols.get_symbol(symbol, curSymName, value, size, bind, type, - curSymShndx, other); - } - - // check symbols outside the elf but within the overlay - if (curSymShndx == SHN_UNDEF) - { - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf("Symbol '%s' doesn't exist in current .o file (%s). Searching...\n", - curSymName.c_str(), cfgLines[curReaderId + 1].c_str()); - } - - for (size_t readerId = 0; readerId < readers.size(); readerId++) - { - auto& reader = readers[readerId]; - - if (curSymShndx != SHN_UNDEF) - break; - - if (reader == curReader) - continue; - - auto sectionData = reader->sections[(Elf_Half)pSec->get_link()]; - curSymShndx = - ovl->FindSymbolInSection(curSymName, sectionData, *reader, readerId); - if (curSymShndx != SHN_UNDEF) - break; - - if (Globals::Instance->gccCompat) - { - // Symbol wasn't found, try checking every section - Elf_Half sec_num = reader->sections.size(); - for (int32_t otherSectionIdx = 0; otherSectionIdx < sec_num; - otherSectionIdx++) - { - if (curSymShndx != SHN_UNDEF) - { - break; - } - - auto sectionDataIter = reader->sections[otherSectionIdx]; - - curSymShndx = ovl->FindSymbolInSection(curSymName, sectionDataIter, - *reader, readerId); - } - } - } - } - - if (curSymShndx != SHN_UNDEF) - { - RelocationType typeConverted = (RelocationType)type; - offset += sectionOffs[static_cast(sectionType)]; - - RelocationEntry* reloc = - new RelocationEntry(sectionType, typeConverted, offset); - - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf(".word 0x%08X # %s %s 0x%04X\n", reloc->CalcRelocationWord(), - reloc->GetSectionName(), reloc->GetRelocTypeName(), reloc->offset); - } - - // this is to keep the correct reloc entry order - if (sectionType == SectionType::Text) - textRelocs.push_back(reloc); - if (sectionType == SectionType::Data) - dataRelocs.push_back(reloc); - if (sectionType == SectionType::RoData) - rodataRelocs.push_back(reloc); - } - } - } - - // increase section offsets - for (int32_t i = 0; i < sec_num; i++) - { - section* pSec = curReader->sections[i]; - if (pSec->get_type() == SHT_PROGBITS && - sSections.find(pSec->get_name()) != sSections.end()) - { - SectionType sectionType = GetSectionTypeFromStr(pSec->get_name()); - sectionOffs[static_cast(sectionType)] += pSec->get_size(); - } - } - } - - ovl->entries.reserve(textRelocs.size() + dataRelocs.size() + rodataRelocs.size()); - ovl->entries.insert(ovl->entries.end(), textRelocs.begin(), textRelocs.end()); - ovl->entries.insert(ovl->entries.end(), dataRelocs.begin(), dataRelocs.end()); - ovl->entries.insert(ovl->entries.end(), rodataRelocs.begin(), rodataRelocs.end()); - - for (auto r : readers) - delete r; - readers.clear(); - - return ovl; -} - -std::string ZOverlay::GetSourceOutputCode([[maybe_unused]] const std::string& prefix) -{ - std::string output; - - output += ".section .ovl\n"; - - output += StringHelper::Sprintf("# %sOverlayInfo\n", name.c_str()); - output += StringHelper::Sprintf(".word _%sSegmentTextSize\n", name.c_str()); - output += StringHelper::Sprintf(".word _%sSegmentDataSize\n", name.c_str()); - output += StringHelper::Sprintf(".word _%sSegmentRoDataSize\n", name.c_str()); - output += StringHelper::Sprintf(".word _%sSegmentBssSize\n", name.c_str()); - output += "\n"; - - output += StringHelper::Sprintf(".word %i # reloc_count\n", entries.size()); - - for (size_t i = 0; i < entries.size(); i++) - { - RelocationEntry* reloc = entries[i]; - output += StringHelper::Sprintf(".word 0x%08X # %s %s 0x%04X\n", - reloc->CalcRelocationWord(), reloc->GetSectionName(), - reloc->GetRelocTypeName(), reloc->offset); - } - - size_t offset = (entries.size() * 4) + 20; - - while (offset % 16 != 12) - { - output += ".word 0\n"; - offset += 4; - } - - output += "\n"; - output += - StringHelper::Sprintf(".word 0x%08X # %sOverlayInfoOffset\n", offset + 4, name.c_str()); - return output; -} - -SectionType ZOverlay::GetSectionTypeFromStr(const std::string& sectionName) -{ - if (sectionName == ".rel.text" || sectionName == ".text") - return SectionType::Text; - else if (sectionName == ".rel.data" || sectionName == ".data") - return SectionType::Data; - else if (sectionName == ".rel.rodata" || sectionName == ".rodata" || - sectionName == ".rodata.str1.4" || sectionName == ".rodata.cst4") - return SectionType::RoData; - else if (sectionName == ".rel.bss" || sectionName == ".bss") - return SectionType::Bss; - - return SectionType::ERROR; -} - -ELFIO::Elf_Half ZOverlay::FindSymbolInSection(const std::string& curSymName, - ELFIO::section* sectionData, ELFIO::elfio& reader, - size_t readerId) -{ - if (sectionData == nullptr) - return SHN_UNDEF; - - auto sectionDataName = sectionData->get_name(); - if (sSections.find(sectionDataName) == sSections.end()) - return SHN_UNDEF; - -#ifdef DEVELOPMENT - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf("\t File '%s' section: %s \n", cfgLines[readerId + 1].c_str(), - sectionDataName.c_str()); - } -#endif - - symbol_section_accessor symbols(reader, sectionData); - - Elf_Xword symbolNum = symbols.get_symbols_num(); - for (Elf_Xword symIdx = 0; symIdx < symbolNum; symIdx++) - { - Elf_Half shndx = SHN_UNDEF; - Elf64_Addr value; - std::string name; - Elf_Xword size; - unsigned char bind; - unsigned char type; - unsigned char other; - - symbols.get_symbol(symIdx, name, value, size, bind, type, shndx, other); - - if (name == curSymName) - { - if (Globals::Instance->verbosity >= VerbosityLevel::VERBOSITY_DEBUG) - { - printf("\t Symbol '%s' found in '%s' '%s' \n", curSymName.c_str(), - cfgLines[readerId + 1].c_str(), sectionDataName.c_str()); - } - return shndx; - } - } - return SHN_UNDEF; -} diff --git a/tools/ZAPD/ZAPD/Overlays/ZOverlay.h b/tools/ZAPD/ZAPD/Overlays/ZOverlay.h deleted file mode 100644 index 98ead9013..000000000 --- a/tools/ZAPD/ZAPD/Overlays/ZOverlay.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once - -#include "Utils/Directory.h" -#include "ZResource.h" -#include "elfio/elfio.hpp" -#include "tinyxml2.h" - -enum class SectionType -{ - Text = 1, - Data = 2, - RoData = 3, - Bss = 4, - ERROR = 255 -}; - -enum class RelocationType -{ - R_MIPS_32 = 2, - R_MIPS_26 = 4, - R_MIPS_HI16 = 5, - R_MIPS_LO16 = 6, -}; - -class RelocationEntry -{ -public: - SectionType sectionType; - RelocationType relocationType; - int32_t offset; - - RelocationEntry(SectionType nSecType, RelocationType nRelType, int32_t nOffset) - { - sectionType = nSecType; - relocationType = nRelType; - offset = nOffset; - } - - uint32_t CalcRelocationWord() - { - uint32_t relocationWord = 0; - - relocationWord |= static_cast(sectionType) << 30; - relocationWord |= static_cast(relocationType) << 24; - relocationWord |= offset; - - return relocationWord; - } - - const char* GetSectionName() const; - const char* GetRelocTypeName() const; -}; - -class ZOverlay -{ -public: - std::string name; - - ZOverlay(const std::string& nName); - ~ZOverlay(); - static ZOverlay* FromBuild(fs::path buildPath, fs::path cfgFolderPath); - std::string GetSourceOutputCode(const std::string& prefix); - -private: - std::vector entries; - std::vector cfgLines; - - ZOverlay(); - - static SectionType GetSectionTypeFromStr(const std::string& sectionName); - // static std::string GetOverlayNameFromElf(ELFIO::elfio& reader); - - ELFIO::Elf_Half FindSymbolInSection(const std::string& curSymName, ELFIO::section* sectionData, - ELFIO::elfio& reader, size_t readerId); -}; diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj b/tools/ZAPD/ZAPD/ZAPD.vcxproj index f3bb35a3f..505e41100 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj @@ -30,26 +30,26 @@ Application true - v143 + v142 MultiByte Application false - v143 + v142 true MultiByte Application true - v143 + v142 MultiByte Application false - v143 + v142 true MultiByte @@ -91,13 +91,15 @@ stdcpp17 stdc11 _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true true + Console - cd .. -mkdir build\ZAPD + cd .. +mkdir build\ZAPD python ZAPD/genbuildinfo.py @@ -112,15 +114,17 @@ mkdir build\ZAPD EnableFastChecks stdc11 MultiThreadedDebug + true true ZAPDUtils.lib;/WHOLEARCHIVE:ExporterExample.lib;%(AdditionalDependencies) false + Console - cd .. -mkdir build\ZAPD + cd .. +mkdir build\ZAPD python ZAPD/genbuildinfo.py @@ -132,14 +136,15 @@ mkdir build\ZAPD true true true + true true true - cd .. -mkdir build\ZAPD + cd .. +mkdir build\ZAPD python ZAPD/genbuildinfo.py @@ -153,14 +158,15 @@ mkdir build\ZAPD true stdcpplatest _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true true true - cd .. -mkdir build\ZAPD + cd .. +mkdir build\ZAPD python ZAPD/genbuildinfo.py @@ -173,6 +179,7 @@ mkdir build\ZAPD + @@ -182,8 +189,8 @@ mkdir build\ZAPD - + @@ -236,6 +243,7 @@ mkdir build\ZAPD + @@ -261,6 +269,7 @@ mkdir build\ZAPD + @@ -270,8 +279,8 @@ mkdir build\ZAPD - + @@ -324,6 +333,7 @@ mkdir build\ZAPD + diff --git a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters index 4de236fad..ce89882fe 100644 --- a/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters +++ b/tools/ZAPD/ZAPD/ZAPD.vcxproj.filters @@ -165,9 +165,6 @@ Source Files\Z64 - - Source Files\Z64 - Source Files\Z64 @@ -288,6 +285,12 @@ Source Files\Z64 + + Source Files + + + Source Files\Z64 + @@ -413,9 +416,6 @@ Header Files\Libraries - - Header Files\Z64 - Header Files\Z64 @@ -548,6 +548,12 @@ Header Files\Z64 + + Header Files + + + Header Files\Z64 + diff --git a/tools/ZAPD/ZAPD/ZActorList.cpp b/tools/ZAPD/ZAPD/ZActorList.cpp new file mode 100644 index 000000000..ee5cb4d44 --- /dev/null +++ b/tools/ZAPD/ZAPD/ZActorList.cpp @@ -0,0 +1,194 @@ +#include "ZActorList.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "WarningHandler.h" +#include "ZFile.h" +#include "ZRoom/ZNames.h" + +REGISTER_ZFILENODE(ActorList, ZActorList); + +ZActorList::ZActorList(ZFile* nParent) : ZResource(nParent) +{ + RegisterRequiredAttribute("Count"); +} + +void ZActorList::ExtractFromBinary(uint32_t nRawDataIndex, uint8_t nNumActors) +{ + rawDataIndex = nRawDataIndex; + numActors = nNumActors; + + // Don't parse raw data of external files + if (parent->GetMode() == ZFileMode::ExternalFile) + return; + + ParseRawData(); +} + +void ZActorList::ParseXML(tinyxml2::XMLElement* reader) +{ + ZResource::ParseXML(reader); + + numActors = StringHelper::StrToL(registeredAttributes.at("Count").value); + + if (numActors < 1) + { + HANDLE_ERROR_RESOURCE( + WarningType::InvalidAttributeValue, parent, this, rawDataIndex, + StringHelper::Sprintf("invalid value '%d' found for 'NumPaths' attribute", numActors), + "Should be at least '1'"); + } +} + +void ZActorList::ParseRawData() +{ + ZResource::ParseRawData(); + + offset_t currentPtr = rawDataIndex; + size_t largestlength = 0; + + for (size_t i = 0; i < numActors; i++) + { + ActorSpawnEntry entry(parent->GetRawData(), currentPtr); + + currentPtr += entry.GetRawDataSize(); + actors.push_back(entry); + + size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size(); + if (actorNameLength > largestlength) + largestlength = actorNameLength; + } + + for (auto& entry : actors) + { + entry.SetLargestActorName(largestlength); + } +} + +Declaration* ZActorList::DeclareVar(const std::string& prefix, const std::string& bodyStr) +{ + std::string auxName = name; + + if (name == "") + auxName = GetDefaultName(prefix); + + Declaration* decl = + parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(), + GetSourceTypeName(), name, GetActorListArraySize(), bodyStr); + decl->staticConf = staticConf; + + return decl; +} + +std::string ZActorList::GetBodySourceCode() const +{ + std::string declaration; + + size_t index = 0; + for (auto& entry : actors) + { + declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str()); + + if (index < actors.size() - 1) + declaration += "\n"; + + index++; + } + + return declaration; +} + +std::string ZActorList::GetSourceTypeName() const +{ + return actors.front().GetSourceTypeName(); +} + +ZResourceType ZActorList::GetResourceType() const +{ + return ZResourceType::ActorList; +} + +size_t ZActorList::GetRawDataSize() const +{ + return actors.size() * actors.front().GetRawDataSize(); +} + +size_t ZActorList::GetActorListArraySize() const +{ + size_t actorCount = 0; + + // Doing an else-if here so we only do the loop when the game is SW97. + // Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count + // for it. + if (Globals::Instance->game == ZGame::OOT_SW97) + { + actorCount = 0; + + for (const auto& entry : actors) + if (entry.GetActorId() != 0x22) + actorCount++; + } + else + { + actorCount = actors.size(); + } + + return actorCount; +} + +/* ActorSpawnEntry */ + +ActorSpawnEntry::ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex) +{ + actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); + posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); + posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); + posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); + rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); + rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); + rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + params = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); +} + +std::string ActorSpawnEntry::GetBodySourceCode() const +{ + std::string body; + + std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1); + body = + StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str()); + + body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ); + if (Globals::Instance->game == ZGame::MM_RETAIL) + body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" + ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" + ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ", + (rotX >> 7) & 0b111111111, rotX & 0b1111111, + (rotY >> 7) & 0b111111111, rotY & 0b1111111, + (rotZ >> 7) & 0b111111111, rotZ & 0b1111111); + else + body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ); + body += StringHelper::Sprintf("0x%04X", params); + + return body; +} + +std::string ActorSpawnEntry::GetSourceTypeName() const +{ + return "ActorEntry"; +} + +size_t ActorSpawnEntry::GetRawDataSize() const +{ + return 16; +} + +uint16_t ActorSpawnEntry::GetActorId() const +{ + return actorNum; +} + +void ActorSpawnEntry::SetLargestActorName(size_t nameSize) +{ + largestActorName = nameSize; +} diff --git a/tools/ZAPD/ZAPD/ZActorList.h b/tools/ZAPD/ZAPD/ZActorList.h new file mode 100644 index 000000000..7cc63da2f --- /dev/null +++ b/tools/ZAPD/ZAPD/ZActorList.h @@ -0,0 +1,52 @@ +#pragma once + +#include "ZResource.h" + +class ActorSpawnEntry +{ +public: + uint16_t actorNum; + int16_t posX; + int16_t posY; + int16_t posZ; + uint16_t rotX; + uint16_t rotY; + uint16_t rotZ; + uint16_t params; + size_t largestActorName = 16; + + ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex); + + std::string GetBodySourceCode() const; + + std::string GetSourceTypeName() const; + size_t GetRawDataSize() const; + + uint16_t GetActorId() const; + void SetLargestActorName(size_t nameSize); +}; + +class ZActorList : public ZResource +{ +public: + std::vector actors; + uint32_t numActors = 0; + + ZActorList(ZFile* nParent); + + void ExtractFromBinary(offset_t nRawDataIndex, uint8_t nNumActors); + + void ParseXML(tinyxml2::XMLElement* reader) override; + void ParseRawData() override; + + Declaration* DeclareVar(const std::string& prefix, const std::string& bodyStr) override; + std::string GetBodySourceCode() const override; + + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; + + size_t GetRawDataSize() const override; + +protected: + size_t GetActorListArraySize() const; +}; diff --git a/tools/ZAPD/ZAPD/ZArray.cpp b/tools/ZAPD/ZAPD/ZArray.cpp index d4f55d6c8..0a9797ba0 100644 --- a/tools/ZAPD/ZAPD/ZArray.cpp +++ b/tools/ZAPD/ZAPD/ZArray.cpp @@ -43,6 +43,7 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader) auto nodeMap = ZFile::GetNodeMap(); size_t childIndex = rawDataIndex; + resList.reserve(arrayCnt); for (size_t i = 0; i < arrayCnt; i++) { ZResource* res = nodeMap->at(childName)(parent); @@ -94,7 +95,7 @@ Declaration* ZArray::DeclareVar(const std::string& prefix, const std::string& bo std::string ZArray::GetBodySourceCode() const { - std::string output = ""; + std::string output; for (size_t i = 0; i < arrayCnt; i++) { @@ -107,6 +108,7 @@ std::string ZArray::GetBodySourceCode() const case ZResourceType::Scalar: case ZResourceType::Vertex: case ZResourceType::CollisionPoly: + case ZResourceType::SurfaceType: output += resList.at(i)->GetBodySourceCode(); break; @@ -125,7 +127,7 @@ std::string ZArray::GetBodySourceCode() const size_t ZArray::GetRawDataSize() const { size_t size = 0; - for (auto res : resList) + for (const auto res : resList) size += res->GetRawDataSize(); return size; } diff --git a/tools/ZAPD/ZAPD/ZCollision.cpp b/tools/ZAPD/ZAPD/ZCollision.cpp index 992332db7..5bd3d93a6 100644 --- a/tools/ZAPD/ZAPD/ZCollision.cpp +++ b/tools/ZAPD/ZAPD/ZCollision.cpp @@ -51,7 +51,7 @@ void ZCollisionHeader::ParseRawData() vertices.reserve(numVerts); polygons.reserve(numPolygons); - uint32_t currentPtr = vtxSegmentOffset; + offset_t currentPtr = vtxSegmentOffset; for (uint16_t i = 0; i < numVerts; i++) { @@ -61,7 +61,7 @@ void ZCollisionHeader::ParseRawData() currentPtr += vec.GetRawDataSize(); vertices.push_back(vec); } - + for (uint16_t i = 0; i < numPolygons; i++) { ZCollisionPoly poly(parent); @@ -72,14 +72,21 @@ void ZCollisionHeader::ParseRawData() uint16_t highestPolyType = 0; - for (ZCollisionPoly poly : polygons) + for (const 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))); + { + ZSurfaceType surfaceType(parent); + surfaceType.SetRawDataIndex(polyTypeDefSegmentOffset + (i * 8)); + surfaceType.ParseRawData(); + polygonTypes.push_back(surfaceType); + } + // polygonTypes.push_back( + // BitConverter::ToUInt64BE(rawData, polyTypeDefSegmentOffset + (i * 8))); if (camDataAddress != SEGMENTED_NULL) { @@ -158,24 +165,22 @@ void ZCollisionHeader::DeclareReferences(const std::string& prefix) declaration += "\n"; } - parent->AddDeclarationArray( - polySegmentOffset, DeclarationAlignment::Align4, polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(), - StringHelper::Sprintf("%sPolygons", auxName.c_str()), polygons.size(), declaration); + parent->AddDeclarationArray(polySegmentOffset, DeclarationAlignment::Align4, + polygons.size() * 16, polygons[0].GetSourceTypeName().c_str(), + StringHelper::Sprintf("%sPolygons", auxName.c_str()), + polygons.size(), declaration); } declaration.clear(); - for (size_t i = 0; i < polygonTypes.size(); i++) + for (const auto& polyType : polygonTypes) { - declaration += StringHelper::Sprintf("\t{ 0x%08lX, 0x%08lX },", polygonTypes[i] >> 32, - polygonTypes[i] & 0xFFFFFFFF); - - if (i < polygonTypes.size() - 1) - declaration += "\n"; + declaration += StringHelper::Sprintf("\t%s,", polyType.GetBodySourceCode().c_str()); } - if (polyTypeDefAddress != 0) + if (polyTypeDefAddress != SEGMENTED_NULL) parent->AddDeclarationArray(polyTypeDefSegmentOffset, DeclarationAlignment::Align4, - polygonTypes.size() * 8, "SurfaceType", + polygonTypes.size() * 8, + polygonTypes[0].GetSourceTypeName().c_str(), StringHelper::Sprintf("%sSurfaceType", auxName.c_str()), polygonTypes.size(), declaration); diff --git a/tools/ZAPD/ZAPD/ZCollision.h b/tools/ZAPD/ZAPD/ZCollision.h index 7481a8526..35c632144 100644 --- a/tools/ZAPD/ZAPD/ZCollision.h +++ b/tools/ZAPD/ZAPD/ZCollision.h @@ -1,22 +1,11 @@ #pragma once +#include "ZCollisionPoly.h" #include "ZFile.h" #include "ZResource.h" #include "ZRoom/ZRoom.h" +#include "ZSurfaceType.h" #include "ZVector.h" -#include "ZCollisionPoly.h" - -#if 0 -class PolygonEntry -{ -public: - uint16_t type; - uint16_t vtxA, vtxB, vtxC; - uint16_t a, b, c, d; - - PolygonEntry(const std::vector& rawData, uint32_t rawDataIndex); -}; -#endif class WaterBoxHeader { @@ -82,7 +71,7 @@ public: std::vector vertices; std::vector polygons; - std::vector polygonTypes; + std::vector polygonTypes; std::vector waterBoxes; CameraDataList* camData = nullptr; diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.cpp b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp index eb2c14ab9..c4eb2d461 100644 --- a/tools/ZAPD/ZAPD/ZCollisionPoly.cpp +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.cpp @@ -16,61 +16,63 @@ 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); + const auto& rawData = parent->GetRawData(); + type = BitConverter::ToUInt16BE(rawData, rawDataIndex + 0); - normX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - normY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - normZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); + vtxA = BitConverter::ToUInt16BE(rawData, rawDataIndex + 2); + vtxB = BitConverter::ToUInt16BE(rawData, rawDataIndex + 4); + vtxC = BitConverter::ToUInt16BE(rawData, rawDataIndex + 6); - dist = BitConverter::ToUInt16BE(rawData, rawDataIndex + 14); + 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; + std::string declaration; + std::string auxName = name; - if (name == "") - auxName = GetDefaultName(prefix); + if (name == "") + auxName = GetDefaultName(prefix); - parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4,GetRawDataSize(), GetSourceTypeName(), name.c_str(),GetBodySourceCode()); + parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(), + GetSourceTypeName(), name.c_str(), GetBodySourceCode()); } std::string ZCollisionPoly::GetBodySourceCode() const { - std::string declaration; + 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; + 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); + return StringHelper::Sprintf("%sCollisionPoly_%06X", prefix.c_str(), rawDataIndex); } - ZResourceType ZCollisionPoly::GetResourceType() const { - return ZResourceType::CollisionPoly; + return ZResourceType::CollisionPoly; } size_t ZCollisionPoly::GetRawDataSize() const { - return 16; + return 16; } std::string ZCollisionPoly::GetSourceTypeName() const { - return "CollisionPoly"; + return "CollisionPoly"; } bool ZCollisionPoly::DoesSupportArray() const { - return true; + return true; } \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZCollisionPoly.h b/tools/ZAPD/ZAPD/ZCollisionPoly.h index 9596d2253..64b98ba1d 100644 --- a/tools/ZAPD/ZAPD/ZCollisionPoly.h +++ b/tools/ZAPD/ZAPD/ZCollisionPoly.h @@ -3,28 +3,27 @@ #include "ZFile.h" #include "ZResource.h" - class ZCollisionPoly : public ZResource { -public: - uint16_t type; +public: + uint16_t type; uint16_t vtxA, vtxB, vtxC; uint16_t normX, normY, normZ; - uint16_t dist; + uint16_t dist; - ZCollisionPoly(ZFile* nParent); - ~ZCollisionPoly(); + ZCollisionPoly(ZFile* nParent); + ~ZCollisionPoly(); - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; + 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 GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; - bool DoesSupportArray() const override; + bool DoesSupportArray() const override; - size_t GetRawDataSize() const override; + size_t GetRawDataSize() const override; }; \ No newline at end of file diff --git a/tools/ZAPD/ZAPD/ZCutscene.cpp b/tools/ZAPD/ZAPD/ZCutscene.cpp index 62f814b13..a3bfe0e07 100644 --- a/tools/ZAPD/ZAPD/ZCutscene.cpp +++ b/tools/ZAPD/ZAPD/ZCutscene.cpp @@ -76,7 +76,7 @@ void ZCutscene::ParseRawData() endFrame = BitConverter::ToInt32BE(rawData, rawDataIndex + 4); offset_t currentPtr = rawDataIndex + 8; - + commands.reserve(numCommands); for (int32_t i = 0; i < numCommands; i++) { uint32_t id = BitConverter::ToUInt32BE(rawData, currentPtr); diff --git a/tools/ZAPD/ZAPD/ZDisplayList.cpp b/tools/ZAPD/ZAPD/ZDisplayList.cpp index 5e9b1b205..3b50c1fd3 100644 --- a/tools/ZAPD/ZAPD/ZDisplayList.cpp +++ b/tools/ZAPD/ZAPD/ZDisplayList.cpp @@ -94,6 +94,7 @@ void ZDisplayList::ParseRawData() instructions.reserve(numInstructions); uint32_t ptr = rawDataIndex; + instructions.reserve(numInstructions); for (size_t i = 0; i < numInstructions; i++) { instructions.push_back(BitConverter::ToUInt64BE(rawData, ptr)); @@ -1839,7 +1840,7 @@ void ZDisplayList::DeclareReferences(const std::string& prefix) // Generate Vertex Declarations std::vector vtxKeys; - + vtxKeys.reserve(vertices.size()); for (auto& item : vertices) vtxKeys.push_back(item.first); diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index b81399e2a..09776505d 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -213,7 +213,14 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename) // Check for repeated attributes. if (offsetXml != nullptr) { - rawDataIndex = strtol(StringHelper::Split(offsetXml, "0x")[1].c_str(), NULL, 16); + std::string offsetStr = StringHelper::Split(offsetXml, "0x")[1]; + if (!StringHelper::HasOnlyHexDigits(offsetStr)) + { + HANDLE_ERROR(WarningType::InvalidXML, + StringHelper::Sprintf("Invalid offset %s entered", offsetStr.c_str()), + ""); + } + rawDataIndex = strtol(offsetStr.c_str(), NULL, 16); if (offsetSet.find(offsetXml) != offsetSet.end()) { @@ -420,6 +427,7 @@ ZResource* ZFile::FindResource(offset_t rawDataIndex) std::vector ZFile::GetResourcesOfType(ZResourceType resType) { std::vector resList; + resList.reserve(resources.size()); for (ZResource* res : resources) { @@ -776,10 +784,10 @@ void ZFile::GenerateSourceHeaderFiles() { OutputFormatter formatter; - std::string objectNameUpper = StringHelper::ToUpper(GetName()); + std::string guard = StringHelper::ToUpper(outName.stem().string()); - formatter.Write(StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n", - objectNameUpper.c_str(), objectNameUpper.c_str())); + formatter.Write( + StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n", guard.c_str(), guard.c_str())); for (ZResource* res : resources) { @@ -1169,6 +1177,7 @@ void ZFile::HandleUnaccountedData() uint32_t lastSize = 0; std::vector declsAddresses; + declsAddresses.reserve(declarations.size()); for (const auto& item : declarations) { declsAddresses.push_back(item.first); diff --git a/tools/ZAPD/ZAPD/ZFile.h b/tools/ZAPD/ZAPD/ZFile.h index 275e27f1b..e4980eb68 100644 --- a/tools/ZAPD/ZAPD/ZFile.h +++ b/tools/ZAPD/ZAPD/ZFile.h @@ -31,8 +31,8 @@ class ZFile { public: std::map declarations; - std::string defines; std::vector resources; + std::string defines; // Default to using virtual addresses uint32_t segment = 0x80; diff --git a/tools/ZAPD/ZAPD/ZPath.cpp b/tools/ZAPD/ZAPD/ZPath.cpp index e19513db3..0dac87a1b 100644 --- a/tools/ZAPD/ZAPD/ZPath.cpp +++ b/tools/ZAPD/ZAPD/ZPath.cpp @@ -35,6 +35,7 @@ void ZPath::ParseRawData() uint32_t currentPtr = rawDataIndex; + pathways.reserve(numPaths); for (size_t pathIndex = 0; pathIndex < numPaths; pathIndex++) { PathwayEntry path(parent); @@ -125,6 +126,7 @@ void PathwayEntry::ParseRawData() uint32_t currentPtr = GETSEGOFFSET(listSegmentAddress); + points.reserve(numPoints); for (int32_t i = 0; i < numPoints; i++) { ZVector vec(parent); diff --git a/tools/ZAPD/ZAPD/ZResource.h b/tools/ZAPD/ZAPD/ZResource.h index 35984679c..f97b259c6 100644 --- a/tools/ZAPD/ZAPD/ZResource.h +++ b/tools/ZAPD/ZAPD/ZResource.h @@ -25,6 +25,7 @@ class ZFile; enum class ZResourceType { Error, + ActorList, Animation, Array, AltHeader, @@ -46,6 +47,7 @@ enum class ZResourceType Scene, Skeleton, String, + SurfaceType, Symbol, Texture, TextureAnimation, diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp index 60391a9d1..15f2c6b45 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorCutsceneList.cpp @@ -14,8 +14,9 @@ void SetActorCutsceneList::ParseRawData() { ZRoomCommand::ParseRawData(); int numCutscenes = cmdArg1; - int32_t currentPtr = segmentOffset; + offset_t currentPtr = segmentOffset; + cutscenes.reserve(numCutscenes); for (int32_t i = 0; i < numCutscenes; i++) { ActorCutsceneEntry entry(parent->GetRawData(), currentPtr); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp index 919d86f57..4d16f9377 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.cpp @@ -1,10 +1,10 @@ #include "SetActorList.h" +#include + #include "Globals.h" #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" -#include "ZFile.h" -#include "ZRoom/ZNames.h" #include "ZRoom/ZRoom.h" SetActorList::SetActorList(ZFile* nParent) : ZRoomCommand(nParent) @@ -15,104 +15,38 @@ void SetActorList::ParseRawData() { ZRoomCommand::ParseRawData(); numActors = cmdArg1; + + actorList = new ZActorList(parent); + actorList->ExtractFromBinary(segmentOffset, numActors); } void SetActorList::DeclareReferences(const std::string& prefix) { - if (numActors != 0 && cmdArg2 != 0) + if (parent->HasDeclaration(segmentOffset)) { - std::string varName = - StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationPlaceholder(segmentOffset, varName); - } -} - -void SetActorList::ParseRawDataLate() -{ - ZRoomCommand::ParseRawDataLate(); - size_t actorsAmount = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 0x10; - - uint32_t currentPtr = segmentOffset; - - for (size_t i = 0; i < actorsAmount; i++) - { - ActorSpawnEntry entry(parent->GetRawData(), currentPtr); - - currentPtr += entry.GetRawDataSize(); - actors.push_back(entry); - } -} - -void SetActorList::DeclareReferencesLate(const std::string& prefix) -{ - if (actors.empty()) + delete actorList; + actorList = static_cast(parent->FindResource(segmentOffset)); + assert(actorList != nullptr); + assert(actorList->GetResourceType() == ZResourceType::ActorList); return; - - std::string declaration; - - size_t largestlength = 0; - for (const auto& entry : actors) - { - size_t actorNameLength = ZNames::GetActorName(entry.GetActorId()).size(); - if (actorNameLength > largestlength) - largestlength = actorNameLength; } - size_t index = 0; - for (auto& entry : actors) + if (actorList->GetName() == "") { - entry.SetLargestActorName(largestlength); - declaration += StringHelper::Sprintf("\t{ %s },", entry.GetBodySourceCode().c_str()); - - if (index < actors.size() - 1) - declaration += "\n"; - - index++; + actorList->SetName(actorList->GetDefaultName(prefix)); } - - const auto& entry = actors.front(); - - std::string varName = StringHelper::Sprintf("%sActorList_%06X", prefix.c_str(), segmentOffset); - parent->AddDeclarationArray(segmentOffset, DeclarationAlignment::Align4, - actors.size() * entry.GetRawDataSize(), entry.GetSourceTypeName(), - varName, GetActorListArraySize(), declaration); + actorList->DeclareVar(prefix, ""); + parent->AddResource(actorList); } std::string SetActorList::GetBodySourceCode() const { std::string listName; Globals::Instance->GetSegmentedPtrName(cmdArg2, parent, "ActorEntry", listName); - if (numActors != actors.size()) - { - printf("%s: numActors(%i) ~ actors(%li)\n", parent->GetName().c_str(), numActors, - actors.size()); - } + return StringHelper::Sprintf("SCENE_CMD_ACTOR_LIST(%i, %s)", numActors, listName.c_str()); } -size_t SetActorList::GetActorListArraySize() const -{ - size_t actorCount = 0; - - // Doing an else-if here so we only do the loop when the game is SW97. - // Actor 0x22 is removed from SW97, so we need to ensure that we don't increment the actor count - // for it. - if (Globals::Instance->game == ZGame::OOT_SW97) - { - actorCount = 0; - - for (const auto& entry : actors) - if (entry.GetActorId() != 0x22) - actorCount++; - } - else - { - actorCount = actors.size(); - } - - return actorCount; -} - std::string SetActorList::GetCommandCName() const { return "SCmdActorList"; @@ -122,58 +56,3 @@ RoomCommand SetActorList::GetRoomCommand() const { return RoomCommand::SetActorList; } - -ActorSpawnEntry::ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex) -{ - actorNum = BitConverter::ToInt16BE(rawData, rawDataIndex + 0); - posX = BitConverter::ToInt16BE(rawData, rawDataIndex + 2); - posY = BitConverter::ToInt16BE(rawData, rawDataIndex + 4); - posZ = BitConverter::ToInt16BE(rawData, rawDataIndex + 6); - rotX = BitConverter::ToUInt16BE(rawData, rawDataIndex + 8); - rotY = BitConverter::ToUInt16BE(rawData, rawDataIndex + 10); - rotZ = BitConverter::ToUInt16BE(rawData, rawDataIndex + 12); - initVar = BitConverter::ToInt16BE(rawData, rawDataIndex + 14); -} - -std::string ActorSpawnEntry::GetBodySourceCode() const -{ - std::string body; - - std::string actorNameFmt = StringHelper::Sprintf("%%-%zus ", largestActorName + 1); - body = - StringHelper::Sprintf(actorNameFmt.c_str(), (ZNames::GetActorName(actorNum) + ",").c_str()); - - body += StringHelper::Sprintf("{ %6i, %6i, %6i }, ", posX, posY, posZ); - if (Globals::Instance->game == ZGame::MM_RETAIL) - body += StringHelper::Sprintf("{ SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" - ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X)" - ", SPAWN_ROT_FLAGS(%#5hX, 0x%04X) }, ", - (rotX >> 7) & 0b111111111, rotX & 0b1111111, - (rotY >> 7) & 0b111111111, rotY & 0b1111111, - (rotZ >> 7) & 0b111111111, rotZ & 0b1111111); - else - body += StringHelper::Sprintf("{ %#6hX, %#6hX, %#6hX }, ", rotX, rotY, rotZ); - body += StringHelper::Sprintf("0x%04X", initVar); - - return body; -} - -std::string ActorSpawnEntry::GetSourceTypeName() const -{ - return "ActorEntry"; -} - -int32_t ActorSpawnEntry::GetRawDataSize() const -{ - return 16; -} - -uint16_t ActorSpawnEntry::GetActorId() const -{ - return actorNum; -} - -void ActorSpawnEntry::SetLargestActorName(size_t nameSize) -{ - largestActorName = nameSize; -} diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.h index 7b341256c..9122c15bb 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetActorList.h @@ -1,45 +1,19 @@ #pragma once +#include "ZActorList.h" #include "ZRoom/ZRoomCommand.h" -class ActorSpawnEntry -{ -public: - uint16_t actorNum; - int16_t posX; - int16_t posY; - int16_t posZ; - uint16_t rotX; - uint16_t rotY; - uint16_t rotZ; - uint16_t initVar; - size_t largestActorName = 16; - - ActorSpawnEntry(const std::vector& rawData, uint32_t rawDataIndex); - - std::string GetBodySourceCode() const; - - std::string GetSourceTypeName() const; - int32_t GetRawDataSize() const; - - uint16_t GetActorId() const; - void SetLargestActorName(size_t nameSize); -}; - class SetActorList : public ZRoomCommand { public: - uint8_t numActors; - std::vector actors; + uint32_t numActors; + ZActorList* actorList = nullptr; SetActorList(ZFile* nParent); void ParseRawData() override; void DeclareReferences(const std::string& prefix) override; - void ParseRawDataLate() override; - void DeclareReferencesLate(const std::string& prefix) override; - std::string GetBodySourceCode() const override; RoomCommand GetRoomCommand() const override; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp index 629d4a0b0..1687b5462 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetAlternateHeaders.cpp @@ -21,9 +21,10 @@ void SetAlternateHeaders::DeclareReferences([[maybe_unused]] const std::string& void SetAlternateHeaders::ParseRawDataLate() { - int numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4; + size_t numHeaders = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 4; - for (int32_t i = 0; i < numHeaders; i++) + headers.reserve(numHeaders); + for (uint32_t i = 0; i < numHeaders; i++) { int32_t address = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + (i * 4)); headers.push_back(address); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp index 5cf0a3d03..ada1a1038 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCsCamera.cpp @@ -18,6 +18,7 @@ void SetCsCamera::ParseRawData() uint32_t currentPtr = segmentOffset; int32_t numPoints = 0; + cameras.reserve(numCameras); for (int32_t i = 0; i < numCameras; i++) { CsCameraEntry entry(parent->GetRawData(), currentPtr); @@ -31,6 +32,7 @@ void SetCsCamera::ParseRawData() { uint32_t currentPtr = cameras.at(0).GetSegmentOffset(); + points.reserve(numPoints); for (int32_t i = 0; i < numPoints; i++) { ZVector vec(parent); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp index 3820203ef..51df68ca1 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetCutscenes.cpp @@ -20,6 +20,7 @@ void SetCutscenes::ParseRawData() { int32_t currentPtr = segmentOffset; + cutsceneEntries.reserve(numCutscenes); for (uint8_t i = 0; i < numCutscenes; i++) { CutsceneEntry entry(parent->GetRawData(), currentPtr); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp index 8099bacf1..c92f56c4e 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetEntranceList.cpp @@ -24,10 +24,11 @@ void SetEntranceList::DeclareReferences([[maybe_unused]] const std::string& pref void SetEntranceList::ParseRawDataLate() { // Parse Entrances and Generate Declaration - int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; + uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; uint32_t currentPtr = segmentOffset; - for (int32_t i = 0; i < numEntrances; i++) + entrances.reserve(numEntrances); + for (uint32_t i = 0; i < numEntrances; i++) { EntranceEntry entry(parent->GetRawData(), currentPtr); entrances.push_back(entry); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp index ddc4c5d43..80ccc6b05 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetExitList.cpp @@ -4,6 +4,7 @@ #include "Utils/BitConverter.h" #include "Utils/StringHelper.h" #include "ZFile.h" +#include "ZRoom/ZNames.h" #include "ZRoom/ZRoom.h" SetExitList::SetExitList(ZFile* nParent) : ZRoomCommand(nParent) @@ -23,10 +24,11 @@ void SetExitList::DeclareReferences([[maybe_unused]] const std::string& prefix) void SetExitList::ParseRawDataLate() { // Parse Entrances and Generate Declaration - int numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; + uint32_t numEntrances = zRoom->GetDeclarationSizeFromNeighbor(segmentOffset) / 2; uint32_t currentPtr = segmentOffset; - for (int32_t i = 0; i < numEntrances; i++) + exits.reserve(numEntrances); + for (uint32_t i = 0; i < numEntrances; i++) { uint16_t exit = BitConverter::ToUInt16BE(parent->GetRawData(), currentPtr); exits.push_back(exit); @@ -43,7 +45,8 @@ void SetExitList::DeclareReferencesLate([[maybe_unused]] const std::string& pref for (size_t i = 0; i < exits.size(); i++) { - declaration += StringHelper::Sprintf(" 0x%04X,", exits.at(i)); + declaration += + StringHelper::Sprintf(" %s,", ZNames::GetEntranceName(exits[i]).c_str()); if (i + 1 < exits.size()) declaration += "\n"; } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp index 2e023ff20..0d0f0ff79 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightList.cpp @@ -15,6 +15,8 @@ void SetLightList::ParseRawData() numLights = cmdArg1; int32_t currentPtr = segmentOffset; + + lights.reserve(this->numLights); for (int i = 0; i < this->numLights; i++) { LightInfo light(parent->GetRawData(), currentPtr); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp index 08cd83d14..ba5785cfc 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetLightingSettings.cpp @@ -15,6 +15,7 @@ void SetLightingSettings::ParseRawData() ZRoomCommand::ParseRawData(); uint8_t numLights = cmdArg1; + settings.reserve(numLights); for (int i = 0; i < numLights; i++) settings.push_back(LightingSettings(parent->GetRawData(), segmentOffset + (i * 22))); } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp index ba0bbe2c2..89c8c8c88 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMesh.cpp @@ -442,6 +442,8 @@ void PolygonType1::DeclareReferences(const std::string& prefix) { listAddress = Seg2Filespace(list, parent->baseAddress); uint32_t auxPtr = listAddress; + + multiList.reserve(count); for (size_t i = 0; i < count; ++i) { BgImage bg(false, prefix, auxPtr, parent); @@ -545,6 +547,8 @@ void PolygonType2::ParseRawData() end = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0x08); uint32_t currentPtr = GETSEGOFFSET(start); + + polyDLists.reserve(num); for (size_t i = 0; i < num; i++) { PolygonDlist entry(parent); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp index ec432b7d9..b1985f890 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapChests.cpp @@ -15,8 +15,9 @@ void SetMinimapChests::ParseRawData() ZRoomCommand::ParseRawData(); int numChests = cmdArg1; - int32_t currentPtr = segmentOffset; + offset_t currentPtr = segmentOffset; + chests.reserve(numChests); for (int32_t i = 0; i < numChests; i++) { MinimapChest chest(parent->GetRawData(), currentPtr); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp index be5d8f15d..a5aac2a54 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.cpp @@ -15,10 +15,11 @@ void SetMinimapList::ParseRawData() ZRoomCommand::ParseRawData(); listSegmentAddr = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset); listSegmentOffset = GETSEGOFFSET(listSegmentAddr); - unk4 = BitConverter::ToInt32BE(parent->GetRawData(), segmentOffset + 4); + scale = BitConverter::ToInt16BE(parent->GetRawData(), segmentOffset + 4); - int32_t currentPtr = listSegmentOffset; + uint32_t currentPtr = listSegmentOffset; + minimaps.reserve(zRoom->roomCount); for (int32_t i = 0; i < zRoom->roomCount; i++) { MinimapEntry entry(parent->GetRawData(), currentPtr); @@ -53,7 +54,7 @@ void SetMinimapList::DeclareReferences(const std::string& prefix) { std::string listName; Globals::Instance->GetSegmentedPtrName(listSegmentAddr, parent, "MinimapEntry", listName); - std::string declaration = StringHelper::Sprintf("\n\t%s, 0x%08X\n", listName.c_str(), unk4); + std::string declaration = StringHelper::Sprintf("\n\t%s, %d\n", listName.c_str(), scale); parent->AddDeclaration( segmentOffset, DeclarationAlignment::Align4, 8, "MinimapList", diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.h b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.h index 5b18b3dd7..fcf7ad7a6 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.h +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetMinimapList.h @@ -35,5 +35,5 @@ public: private: segptr_t listSegmentAddr; uint32_t listSegmentOffset; - uint32_t unk4; + int16_t scale; }; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp index fdd41e6cb..3048aa2d4 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetObjectList.cpp @@ -17,6 +17,7 @@ void SetObjectList::ParseRawData() uint8_t objectCnt = parent->GetRawData().at(rawDataIndex + 1); uint32_t currentPtr = segmentOffset; + objects.reserve(objectCnt); for (uint8_t i = 0; i < objectCnt; i++) { uint16_t objectIndex = BitConverter::ToInt16BE(parent->GetRawData(), currentPtr); diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp index 20138dd4d..24969a14d 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetRoomList.cpp @@ -69,6 +69,7 @@ void RomFile::ParseRawData() uint32_t currentPtr = rawDataIndex; + rooms.reserve(numRooms); for (int32_t i = 0; i < numRooms; i++) { RoomEntry entry(parent->GetRawData(), currentPtr); @@ -104,8 +105,9 @@ std::string RomFile::GetBodySourceCode() const if (!isFirst) declaration += "\n"; - declaration += StringHelper::Sprintf("\t{ _%sSegmentRomStart, _%sSegmentRomEnd },", - roomName.c_str(), roomName.c_str()); + declaration += StringHelper::Sprintf( + "\t{ (uintptr_t)_%sSegmentRomStart, (uintptr_t)_%sSegmentRomEnd },", + roomName.c_str(), roomName.c_str()); isFirst = false; } } diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp index f75b5e0d5..14ca16a96 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetStartPositionList.cpp @@ -16,9 +16,10 @@ void SetStartPositionList::ParseRawData() ZRoomCommand::ParseRawData(); uint8_t numActors = cmdArg1; - uint32_t currentPtr = segmentOffset; + offset_t currentPtr = segmentOffset; - for (int32_t i = 0; i < numActors; i++) + actors.reserve(numActors); + for (uint32_t i = 0; i < numActors; i++) { actors.push_back(ActorSpawnEntry(parent->GetRawData(), currentPtr)); currentPtr += 16; diff --git a/tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp b/tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp index a33d1c6e1..67e3e4e18 100644 --- a/tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp +++ b/tools/ZAPD/ZAPD/ZRoom/Commands/SetTransitionActorList.cpp @@ -17,6 +17,7 @@ void SetTransitionActorList::ParseRawData() int numActors = cmdArg1; uint32_t currentPtr = segmentOffset; + transitionActors.reserve(numActors); for (int32_t i = 0; i < numActors; i++) { TransitionActorEntry entry(parent->GetRawData(), currentPtr); diff --git a/tools/ZAPD/ZAPD/ZRoom/ZNames.h b/tools/ZAPD/ZAPD/ZRoom/ZNames.h index 94e08de0d..667407c36 100644 --- a/tools/ZAPD/ZAPD/ZRoom/ZNames.h +++ b/tools/ZAPD/ZAPD/ZRoom/ZNames.h @@ -12,17 +12,17 @@ public: { if (id >= Globals::Instance->cfg.objectList.size()) return StringHelper::Sprintf("0x%04X", id); - return Globals::Instance->cfg.objectList.at(id); + return Globals::Instance->cfg.objectList[id]; } - static std::string GetActorName(int32_t id) + static std::string GetActorName(uint16_t id) { switch (Globals::Instance->game) { case ZGame::OOT_RETAIL: case ZGame::OOT_SW97: if (id < ZNames::GetNumActors()) - return Globals::Instance->cfg.actorList.at(id); + return Globals::Instance->cfg.actorList[id]; else return StringHelper::Sprintf("0x%04X", id); case ZGame::MM_RETAIL: @@ -31,7 +31,7 @@ public: id &= 0xFFF; std::string name; if (id < ZNames::GetNumActors()) - name = Globals::Instance->cfg.actorList.at(id); + name = Globals::Instance->cfg.actorList[id]; else name = StringHelper::Sprintf("0x%04X", id); @@ -45,5 +45,20 @@ public: return ""; } - static int32_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); } + static std::string GetEntranceName(uint16_t id) + { + if (ZNames::GetNumEntrances() == 0 || ZNames::GetNumSpecialEntrances() == 0) + return StringHelper::Sprintf("0x%04X", id); + + if (id < ZNames::GetNumEntrances()) + return Globals::Instance->cfg.entranceList[id]; + else if ((id >= 0x7FF9 && id <= 0x7FFF) && !((id - 0x7FF9U) > GetNumSpecialEntrances())) // Special entrances + return Globals::Instance->cfg.specialEntranceList[id - 0x7FF9]; + else + return StringHelper::Sprintf("0x%04X", id); + } + + static size_t GetNumActors() { return Globals::Instance->cfg.actorList.size(); } + static size_t GetNumEntrances() { return Globals::Instance->cfg.entranceList.size(); } + static size_t GetNumSpecialEntrances() { return Globals::Instance->cfg.specialEntranceList.size(); } }; diff --git a/tools/ZAPD/ZAPD/ZSkeleton.cpp b/tools/ZAPD/ZAPD/ZSkeleton.cpp index b3f7ce8c0..ca680c5f5 100644 --- a/tools/ZAPD/ZAPD/ZSkeleton.cpp +++ b/tools/ZAPD/ZAPD/ZSkeleton.cpp @@ -287,6 +287,8 @@ void ZLimbTable::ParseRawData() const auto& rawData = parent->GetRawData(); uint32_t ptr = rawDataIndex; + + limbsAddresses.reserve(count); for (size_t i = 0; i < count; i++) { limbsAddresses.push_back(BitConverter::ToUInt32BE(rawData, ptr)); @@ -301,7 +303,7 @@ void ZLimbTable::DeclareReferences(const std::string& prefix) varPrefix = prefix; ZResource::DeclareReferences(varPrefix); - + limbsReferences.reserve(count); for (size_t i = 0; i < count; i++) { segptr_t limbAddress = limbsAddresses[i]; diff --git a/tools/ZAPD/ZAPD/ZSurfaceType.cpp b/tools/ZAPD/ZAPD/ZSurfaceType.cpp new file mode 100644 index 000000000..27e73accc --- /dev/null +++ b/tools/ZAPD/ZAPD/ZSurfaceType.cpp @@ -0,0 +1,65 @@ +#include "ZSurfaceType.h" + +#include "Globals.h" +#include "Utils/BitConverter.h" +#include "Utils/StringHelper.h" + +REGISTER_ZFILENODE(SurfaceType, ZSurfaceType); + +ZSurfaceType::ZSurfaceType(ZFile* nParent) : ZResource(nParent) +{ +} + +ZSurfaceType::~ZSurfaceType() +{ +} + +void ZSurfaceType::ParseRawData() +{ + const auto& rawData = parent->GetRawData(); + + data[0] = BitConverter::ToUInt32BE(rawData, rawDataIndex + 0); + data[1] = BitConverter::ToUInt32BE(rawData, rawDataIndex + 4); +} + +void ZSurfaceType::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 ZSurfaceType::GetBodySourceCode() const +{ + return StringHelper::Sprintf("{0x%08X, 0x%08X}", data[0], data[1]); +} + +std::string ZSurfaceType::GetDefaultName(const std::string& prefix) const +{ + return StringHelper::Sprintf("%sSurfaceType_%06X", prefix.c_str(), rawDataIndex); +} + +ZResourceType ZSurfaceType::GetResourceType() const +{ + return ZResourceType::SurfaceType; +} + +size_t ZSurfaceType::GetRawDataSize() const +{ + return 8; +} + +std::string ZSurfaceType::GetSourceTypeName() const +{ + return "SurfaceType"; +} + +bool ZSurfaceType::DoesSupportArray() const +{ + return true; +} diff --git a/tools/ZAPD/ZAPD/ZSurfaceType.h b/tools/ZAPD/ZAPD/ZSurfaceType.h new file mode 100644 index 000000000..3bbddee8c --- /dev/null +++ b/tools/ZAPD/ZAPD/ZSurfaceType.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include "ZFile.h" +#include "ZResource.h" + +class ZSurfaceType : public ZResource +{ +public: + std::array data; + + ZSurfaceType(ZFile* nParent); + ~ZSurfaceType(); + + 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; +}; diff --git a/tools/ZAPD/ZAPD/ZTexture.cpp b/tools/ZAPD/ZAPD/ZTexture.cpp index a9cb53941..74b7c7d10 100644 --- a/tools/ZAPD/ZAPD/ZTexture.cpp +++ b/tools/ZAPD/ZAPD/ZTexture.cpp @@ -17,11 +17,15 @@ ZTexture::ZTexture(ZFile* nParent) : ZResource(nParent) width = 0; height = 0; dWordAligned = true; + splitTlut = false; RegisterRequiredAttribute("Width"); RegisterRequiredAttribute("Height"); RegisterRequiredAttribute("Format"); RegisterOptionalAttribute("TlutOffset"); + RegisterOptionalAttribute("ExternalTlut"); + RegisterOptionalAttribute("ExternalTlutOffset"); + RegisterOptionalAttribute("SplitTlut"); } void ZTexture::ExtractFromBinary(uint32_t nRawDataIndex, int32_t nWidth, int32_t nHeight, @@ -56,6 +60,7 @@ void ZTexture::ParseXML(tinyxml2::XMLElement* reader) std::string widthXml = registeredAttributes.at("Width").value; std::string heightXml = registeredAttributes.at("Height").value; + std::string SplitTlutXml = registeredAttributes.at("SplitTlut").value; if (!StringHelper::HasOnlyDigits(widthXml)) { @@ -72,6 +77,27 @@ void ZTexture::ParseXML(tinyxml2::XMLElement* reader) errorHeader, ""); } + if (!registeredAttributes.at("ExternalTlut").wasSet && + registeredAttributes.at("SplitTlut").wasSet) + { + std::string errorHeader = + StringHelper::Sprintf("SplitTlut set without using an external tlut"); + HANDLE_WARNING_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, + errorHeader, ""); + } + + if (!SplitTlutXml.empty()) + { + if (!tinyxml2::XMLUtil::ToBool(SplitTlutXml.c_str(), &splitTlut)) + { + std::string errorHeader = StringHelper::Sprintf( + "Invalid value passed to SplitTlut: '%s'. Valid values are true, false, 1, 0", + SplitTlutXml.c_str()); + HANDLE_ERROR_RESOURCE(WarningType::InvalidAttributeValue, parent, this, rawDataIndex, + errorHeader, ""); + } + } + width = StringHelper::StrToL(widthXml); height = StringHelper::StrToL(heightXml); @@ -145,6 +171,47 @@ void ZTexture::ParseRawData() } } +void ZTexture::ParseRawDataLate() +{ + if (registeredAttributes["ExternalTlut"].wasSet) + { + const std::string externPalette = registeredAttributes["ExternalTlut"].value; + for (const auto& file : Globals::Instance->files) + { + if (file->GetName() == externPalette) + { + offset_t palOffset = 0; + if (registeredAttributes["ExternalTlutOffset"].wasSet) + { + palOffset = + StringHelper::StrToL(registeredAttributes["ExternalTlutOffset"].value, 16); + } + else + { + HANDLE_WARNING_RESOURCE( + WarningType::MissingOffsets, parent, this, rawDataIndex, + StringHelper::Sprintf( + "No ExternalTlutOffset Given. Assuming offset of 0x0"), + ""); + } + for (const auto& res : file->resources) + { + if (res->GetRawDataIndex() == palOffset) + { + ZTexture* palette = (ZTexture*)res; + ZTexture tlutTemp(file); + + tlut = &tlutTemp; + tlut->ExtractFromBinary(palOffset, palette->width, palette->height, + TextureType::RGBA16bpp, true); + SetTlut(tlut); + } + } + } + } + } +} + void ZTexture::PrepareBitmapRGBA16() { textureData.InitEmptyRGBImage(width, height, true); @@ -871,7 +938,7 @@ void ZTexture::SetTlut(ZTexture* nTlut) assert(nTlut->isPalette); tlut = nTlut; - textureData.SetPalette(tlut->textureData); + textureData.SetPalette(tlut->textureData, splitTlut ? 128 : 0); } bool ZTexture::HasTlut() const diff --git a/tools/ZAPD/ZAPD/ZTexture.h b/tools/ZAPD/ZAPD/ZTexture.h index 6f2c49935..8cece3ff2 100644 --- a/tools/ZAPD/ZAPD/ZTexture.h +++ b/tools/ZAPD/ZAPD/ZTexture.h @@ -28,6 +28,7 @@ protected: std::vector textureDataRaw; // When reading from a PNG file. uint32_t tlutOffset = static_cast(-1); ZTexture* tlut = nullptr; + bool splitTlut; void PrepareBitmapRGBA16(); void PrepareBitmapRGBA32(); @@ -88,4 +89,5 @@ public: bool IsColorIndexed() const; void SetTlut(ZTexture* nTlut); bool HasTlut() const; + void ParseRawDataLate() override; }; diff --git a/tools/ZAPD/ZAPD/ZVector.cpp b/tools/ZAPD/ZAPD/ZVector.cpp index a5a059e35..607aac86d 100644 --- a/tools/ZAPD/ZAPD/ZVector.cpp +++ b/tools/ZAPD/ZAPD/ZVector.cpp @@ -48,7 +48,7 @@ void ZVector::ParseRawData() int32_t currentRawDataIndex = rawDataIndex; // TODO: this shouldn't be necessary. scalars.clear(); - + scalars.reserve(dimensions); for (uint32_t i = 0; i < dimensions; i++) { ZScalar scalar(parent); diff --git a/tools/ZAPD/ZAPDUtils/Utils/File.h b/tools/ZAPD/ZAPDUtils/Utils/File.h index 084152f79..7bc5d2950 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/File.h +++ b/tools/ZAPD/ZAPDUtils/Utils/File.h @@ -33,6 +33,8 @@ public: static std::string ReadAllText(const fs::path& filePath) { std::ifstream file(filePath, std::ios::in | std::ios::binary | std::ios::ate); + if (!file.is_open()) + return ""; int32_t fileSize = (int32_t)file.tellg(); file.seekg(0); char* data = new char[fileSize + 1]; diff --git a/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h b/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h index 2289927d8..8560d6b09 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h +++ b/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h @@ -106,6 +106,11 @@ public: return std::all_of(str.begin(), str.end(), ::isdigit); } + static bool HasOnlyHexDigits(const std::string& str) + { + return std::all_of(str.begin(), str.end(), ::isxdigit); + } + static std::string ToUpper(const std::string& str) { std::string buff = str; diff --git a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj index c0ef260dd..4b91c2aeb 100644 --- a/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj +++ b/tools/ZAPD/ZAPDUtils/ZAPDUtils.vcxproj @@ -29,7 +29,7 @@ Application true - v143 + v142 Unicode @@ -42,7 +42,7 @@ StaticLibrary true - v143 + v142 MultiByte diff --git a/tools/ZAPD/docs/zapd_extraction_xml_reference.md b/tools/ZAPD/docs/zapd_extraction_xml_reference.md index 89ce33a6e..edbdf857f 100644 --- a/tools/ZAPD/docs/zapd_extraction_xml_reference.md +++ b/tools/ZAPD/docs/zapd_extraction_xml_reference.md @@ -149,12 +149,15 @@ u64 gCraterSmokeConeTex[] = { - Attributes: - - `Name`: Required. Suxffixed by `Tex`, unless it is a palette, in that case it is suffixed by `TLUT`. + - `Name`: Required. Suffixed by `Tex`, unless it is a palette, in that case it is suffixed by `TLUT`. - `OutName`: Required. The filename of the extracted `.png` file. - `Format`: Required. The format of the image. Valid values: `rgba32`, `rgba16`, `i4`, `i8`, `ia4`, `ia8`, `ia16`, `ci4` and `ci8`. - `Width`: Required. Width in pixels of the image. - `Height`: Required. Height in pixels of the image. - `TlutOffset`: Optional. Specifies the tlut's offset used by this texture. This attribute is only valid if `Format` is either `ci4` or `ci8`, otherwise an exception would be thrown. + - `ExternalTlut`: Optional. Specifies that the texture's tlut is in a different file. Takes the filename of the file that contains the tlut. + - `ExternalTlutOffset`: Optional. Specifies the offset in the `ExternalTlut` of the tlut for the given texture. + - `SplitTlut`: Optional. Specifies that the given texture should take from the upper half of the tlut. Takes a bool, i.e. one of `true`, `false`, `1`, `0`. The following is a list of the texture formats the Nintendo 64 supports, with their gfxdis names and ZAPD format names. @@ -185,7 +188,7 @@ If you want to know more about this formats, you can check [`gsDPLoadTextureBloc - Attributes: - - `Name`: Required. Suxffixed by `Background`. + - `Name`: Required. Suffixed by `Background`. - `OutName`: Required. The filename of the extracted `.jpg` file. ※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. You can use this to name them if you don't like the autogenerated name. @@ -213,7 +216,7 @@ u8 gFireTempleBlob_00CCC0[] = { - Attributes: - - `Name`: Required. Suxffixed by `Blob`. + - `Name`: Required. Suffixed by `Blob`. - `Size`: Required. Amount of bytes to extract. Hex. ※ We usually use blobs when we can't figure out the content's type of chunk of data. @@ -232,7 +235,7 @@ A.k.a. Display list, or Gfx. - Attributes: - - `Name`: Required. Suxffixed by `DL`. + - `Name`: Required. Suffixed by `DL`. ------------------------- @@ -246,7 +249,7 @@ A data type exclusive to Majora's Mask, that has scrolling, color changing, and - Attributes: - - `Name`: Required. Suxffixed by `TexAnim`. + - `Name`: Required. Suffixed by `TexAnim`. ------------------------- @@ -306,7 +309,7 @@ Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be decl - Attributes: - - `Name`: Required. Suxffixed by `AltHeader`. + - `Name`: Required. Suffixed by `AltHeader`. ------------------------- @@ -320,7 +323,7 @@ Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be decl - Attributes: - - `Name`: Required. Suxffixed by `Anim`. + - `Name`: Required. Suffixed by `Anim`. ------------------------- @@ -334,7 +337,7 @@ Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be decl - Attributes: - - `Name`: Required. Suxffixed by `Anim`. + - `Name`: Required. Suffixed by `Anim`. ------------------------- @@ -348,7 +351,7 @@ Like `Scene`s and `Room`s, `AltHeader`s is special too. It should always be decl - Attributes: - - `Name`: Required. Suxffixed by `Anim`. + - `Name`: Required. Suffixed by `Anim`. - `SkelOffset`: Required. Offset of the `CurveSkeleton` (I.e. a [`Skeleton`](#skeleton) resource with `Type="Curve"`) related to this animation. ------------------------- @@ -365,7 +368,7 @@ Useful only for the unused `object_human`'s animation data. - Attributes: - - `Name`: Required. Suxffixed by `Anim`. + - `Name`: Required. Suffixed by `Anim`. ------------------------- @@ -379,7 +382,7 @@ Useful only for the unused `object_human`'s animation data. - Attributes: - - `Name`: Required. Suxffixed by `Skel`. + - `Name`: Required. Suffixed by `Skel`. - `Type`: Required. Valid values: `Normal`, `Flex` and `Curve`. - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. - `EnumName`: Optional. The name of `typedef`'d limb enum. @@ -404,7 +407,7 @@ The required data is providing the `EnumName`, `LimbNone` and `LimbMax` attribut - Attributes: - - `Name`: Required. Suxffixed by `Skel`. + - `Name`: Required. Suffixed by `Skel`. - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. - `Count`: Required. Amount of limbs. Integer. - `EnumName`: Optional. The name of `typedef`'d limb enum. @@ -425,7 +428,7 @@ See [Skeleton](#skeleton) for info on the limb enum generation. - Attributes: - - `Name`: Required. Suxffixed by `Limb`. + - `Name`: Required. Suffixed by `Limb`. - `LimbType`: Required. Valid values: `Standard`, `LOD`, `Skin`, `Curve` and `Legacy`. - `EnumName`: Optional. The name used for this limb in the limbs enum. It must be either present in every limb or in none. @@ -468,7 +471,7 @@ extern u8 gJsjutanShadowTex[2048]; - Attributes: - - `Name`: Required. Suxffixed by `Col`. + - `Name`: Required. Suffixed by `Col`. ------------------------- @@ -490,7 +493,7 @@ u64 pad34F8 = { 0 }; - Attributes: - - `Name`: Required. Suxffixed by ~~`TBD`~~. + - `Name`: Required. Suffixed by ~~`TBD`~~. - `Type`: Required. Valid values: `s8`, `u8`, `x8`, `s16`, `u16`, `x16`, `s32`, `u32`, `x32`, `s64`, `u64`, `x64`, `f32` and `f64`. ※ Can be wrapped in an [`Array`](#array) tag. @@ -544,7 +547,7 @@ Vec3s D_04002040[24] = { - Attributes: - - `Name`: Required. Suxffixed by ~~`TBD`~~. + - `Name`: Required. Suffixed by ~~`TBD`~~. - `Type`: Required. Specifies the vector's type (`Vec3s`, `Vec3i` and `Vec3f`). Valid values: `s16`, `s32` and `f32`. - `Dimensions`: Required. The amount of dimensions of the vector. Valid values: `3`. @@ -564,7 +567,7 @@ Vec3s D_04002040[24] = { - Attributes: - - `Name`: Required. Suxffixed by `Vtx`. + - `Name`: Required. Suffixed by `Vtx`. ※ Can be wrapped in an [`Array`](#array) tag. @@ -580,7 +583,7 @@ Vec3s D_04002040[24] = { - Attributes: - - `Name`: Required. Suxffixed by `Mtx`. + - `Name`: Required. Suffixed by `Mtx`. ※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. @@ -596,7 +599,7 @@ Vec3s D_04002040[24] = { - Attributes: - - `Name`: Required. Suxffixed by `Cs`. + - `Name`: Required. Suffixed by `Cs`. ※ Explicit use of this tag isn't often necesary because it would probably be extracted automatically by another extracted element. @@ -633,7 +636,7 @@ Currently, only [`Pointer`](#pointer), [`Scalar`](#scalar), [`Vector`](#vector) - Attributes: - - `Name`: Required. Suxffixed by `Path`. + - `Name`: Required. Suffixed by `Path`. - `NumPaths`: Optional. The amount of paths contained in the array. It must be a positive integer. ------------------------- @@ -650,7 +653,7 @@ Allows the extraction of the specific data of the player animations which are fo - Attributes: - - `Name`: Required. Suxffixed by `AnimData`. + - `Name`: Required. Suffixed by `AnimData`. - `FrameCount`: Required. The length of the animation in frames. It must be a positive integer. ------------------------- diff --git a/tools/ZAPD/lib/elfio/elfio/elf_types.hpp b/tools/ZAPD/lib/elfio/elfio/elf_types.hpp deleted file mode 100644 index 63d025a58..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elf_types.hpp +++ /dev/null @@ -1,851 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFTYPES_H -#define ELFTYPES_H - -#ifndef ELFIO_NO_OWN_TYPES - #if !defined(ELFIO_NO_CSTDINT) && !defined(ELFIO_NO_INTTYPES) - #include - #else - typedef unsigned char uint8_t; - typedef signed char int8_t; - typedef unsigned short uint16_t; - typedef signed short int16_t; - #ifdef _MSC_VER - typedef unsigned __int32 uint32_t; - typedef signed __int32 int32_t; - typedef unsigned __int64 uint64_t; - typedef signed __int64 int64_t; - #else - typedef unsigned int uint32_t; - typedef signed int int32_t; - typedef unsigned long long uint64_t; - typedef signed long long int64_t; - #endif // _MSC_VER - #endif // ELFIO_NO_CSTDINT -#endif // ELFIO_NO_OWN_TYPES - -namespace ELFIO { - -// Attention! Platform depended definitions. -typedef uint16_t Elf_Half; -typedef uint32_t Elf_Word; -typedef int32_t Elf_Sword; -typedef uint64_t Elf_Xword; -typedef int64_t Elf_Sxword; - -typedef uint32_t Elf32_Addr; -typedef uint32_t Elf32_Off; -typedef uint64_t Elf64_Addr; -typedef uint64_t Elf64_Off; - -#define Elf32_Half Elf_Half -#define Elf64_Half Elf_Half -#define Elf32_Word Elf_Word -#define Elf64_Word Elf_Word -#define Elf32_Sword Elf_Sword -#define Elf64_Sword Elf_Sword - -/////////////////////// -// ELF Header Constants - -// File type -#define ET_NONE 0 -#define ET_REL 1 -#define ET_EXEC 2 -#define ET_DYN 3 -#define ET_CORE 4 -#define ET_LOOS 0xFE00 -#define ET_HIOS 0xFEFF -#define ET_LOPROC 0xFF00 -#define ET_HIPROC 0xFFFF - - -#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_486 6 // Intel 80486// Reserved for future use -#define EM_860 7 // Intel 80860 -#define EM_MIPS 8 // MIPS R3000 (officially, big-endian only) -#define EM_S370 9 // IBM System/370 -#define EM_MIPS_RS3_LE 10 // MIPS R3000 little-endian (Oct 4 1999 Draft) Deprecated -#define EM_res011 11 // Reserved -#define EM_res012 12 // Reserved -#define EM_res013 13 // Reserved -#define EM_res014 14 // Reserved -#define EM_PARISC 15 // HPPA -#define EM_res016 16 // Reserved -#define EM_VPP550 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 // 64-bit PowerPC -#define EM_S390 22 // IBM S/390 -#define EM_SPU 23 // Sony/Toshiba/IBM SPU -#define EM_res024 24 // Reserved -#define EM_res025 25 // Reserved -#define EM_res026 26 // Reserved -#define EM_res027 27 // Reserved -#define EM_res028 28 // Reserved -#define EM_res029 29 // Reserved -#define EM_res030 30 // Reserved -#define EM_res031 31 // Reserved -#define EM_res032 32 // Reserved -#define EM_res033 33 // Reserved -#define EM_res034 34 // Reserved -#define EM_res035 35 // Reserved -#define EM_V800 36 // NEC V800 series -#define EM_FR20 37 // Fujitsu FR20 -#define EM_RH32 38 // TRW RH32 -#define EM_MCORE 39 // Motorola M*Core // May also be taken by Fujitsu MMA -#define EM_RCE 39 // Old name for MCore -#define EM_ARM 40 // ARM -#define EM_OLD_ALPHA 41 // Digital Alpha -#define EM_SH 42 // Renesas (formerly Hitachi) / SuperH SH -#define EM_SPARCV9 43 // SPARC v9 64-bit -#define EM_TRICORE 44 // Siemens Tricore embedded processor -#define EM_ARC 45 // ARC Cores -#define EM_H8_300 46 // Renesas (formerly Hitachi) H8/300 -#define EM_H8_300H 47 // Renesas (formerly Hitachi) H8/300H -#define EM_H8S 48 // Renesas (formerly Hitachi) H8S -#define EM_H8_500 49 // Renesas (formerly Hitachi) H8/500 -#define EM_IA_64 50 // Intel IA-64 Processor -#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 Multimedia Accelerator -#define EM_PCP 55 // Siemens PCP -#define EM_NCPU 56 // Sony nCPU embedded RISC processor -#define EM_NDR1 57 // Denso NDR1 microprocesspr -#define EM_STARCORE 58 // Motorola Star*Core processor -#define EM_ME16 59 // Toyota ME16 processor -#define EM_ST100 60 // STMicroelectronics ST100 processor -#define EM_TINYJ 61 // Advanced Logic Corp. TinyJ embedded processor -#define EM_X86_64 62 // Advanced Micro Devices X86-64 processor -#define EM_PDSP 63 // Sony DSP Processor -#define EM_PDP10 64 // Digital Equipment Corp. PDP-10 -#define EM_PDP11 65 // Digital Equipment Corp. PDP-11 -#define EM_FX66 66 // Siemens FX66 microcontroller -#define EM_ST9PLUS 67 // STMicroelectronics ST9+ 8/16 bit microcontroller -#define EM_ST7 68 // STMicroelectronics ST7 8-bit microcontroller -#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 cpu -#define EM_VAX 75 // Digital VAX -#define EM_CRIS 76 // Axis Communications 32-bit embedded processor -#define EM_JAVELIN 77 // Infineon Technologies 32-bit embedded cpu -#define EM_FIREPATH 78 // Element 14 64-bit DSP processor -#define EM_ZSP 79 // LSI Logic's 16-bit DSP processor -#define EM_MMIX 80 // Donald Knuth's educational 64-bit processor -#define EM_HUANY 81 // Harvard's machine-independent format -#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 // Renesas M32R (formerly 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_A5 93 // ARC Cores Tangent-A5 -#define EM_XTENSA 94 // Tensilica Xtensa Architecture -#define EM_VIDEOCORE 95 // Alphamosaic VideoCore processor -#define EM_TMM_GPP 96 // Thompson Multimedia General Purpose Processor -#define EM_NS32K 97 // National Semiconductor 32000 series -#define EM_TPC 98 // Tenor Network TPC processor -#define EM_SNP1K 99 // Trebia SNP 1000 processor -#define EM_ST200 100 // STMicroelectronics ST200 microcontroller -#define EM_IP2K 101 // Ubicom IP2022 micro controller -#define EM_MAX 102 // MAX Processor -#define EM_CR 103 // National Semiconductor CompactRISC -#define EM_F2MC16 104 // Fujitsu F2MC16 -#define EM_MSP430 105 // TI msp430 micro controller -#define EM_BLACKFIN 106 // ADI Blackfin -#define EM_SE_C33 107 // S1C33 Family of Seiko Epson processors -#define EM_SEP 108 // Sharp embedded microprocessor -#define EM_ARCA 109 // Arca RISC Microprocessor -#define EM_UNICORE 110 // Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University -#define EM_EXCESS 111 // eXcess: 16/32/64-bit configurable embedded CPU -#define EM_DXP 112 // Icera Semiconductor Inc. Deep Execution Processor -#define EM_ALTERA_NIOS2 113 // Altera Nios II soft-core processor -#define EM_CRX 114 // National Semiconductor CRX -#define EM_XGATE 115 // Motorola XGATE embedded processor -#define EM_C166 116 // Infineon C16x/XC16x processor -#define EM_M16C 117 // Renesas M16C series microprocessors -#define EM_DSPIC30F 118 // Microchip Technology dsPIC30F Digital Signal Controller -#define EM_CE 119 // Freescale Communication Engine RISC core -#define EM_M32C 120 // Renesas M32C series microprocessors -#define EM_res121 121 // Reserved -#define EM_res122 122 // Reserved -#define EM_res123 123 // Reserved -#define EM_res124 124 // Reserved -#define EM_res125 125 // Reserved -#define EM_res126 126 // Reserved -#define EM_res127 127 // Reserved -#define EM_res128 128 // Reserved -#define EM_res129 129 // Reserved -#define EM_res130 130 // Reserved -#define EM_TSK3000 131 // Altium TSK3000 core -#define EM_RS08 132 // Freescale RS08 embedded processor -#define EM_res133 133 // Reserved -#define EM_ECOG2 134 // Cyan Technology eCOG2 microprocessor -#define EM_SCORE 135 // Sunplus Score -#define EM_SCORE7 135 // Sunplus S+core7 RISC processor -#define EM_DSP24 136 // New Japan Radio (NJR) 24-bit DSP Processor -#define EM_VIDEOCORE3 137 // Broadcom VideoCore III processor -#define EM_LATTICEMICO32 138 // RISC processor for Lattice FPGA architecture -#define EM_SE_C17 139 // Seiko Epson C17 family -#define EM_TI_C6000 140 // Texas Instruments TMS320C6000 DSP family -#define EM_TI_C2000 141 // Texas Instruments TMS320C2000 DSP family -#define EM_TI_C5500 142 // Texas Instruments TMS320C55x DSP family -#define EM_res143 143 // Reserved -#define EM_res144 144 // Reserved -#define EM_res145 145 // Reserved -#define EM_res146 146 // Reserved -#define EM_res147 147 // Reserved -#define EM_res148 148 // Reserved -#define EM_res149 149 // Reserved -#define EM_res150 150 // Reserved -#define EM_res151 151 // Reserved -#define EM_res152 152 // Reserved -#define EM_res153 153 // Reserved -#define EM_res154 154 // Reserved -#define EM_res155 155 // Reserved -#define EM_res156 156 // Reserved -#define EM_res157 157 // Reserved -#define EM_res158 158 // Reserved -#define EM_res159 159 // Reserved -#define EM_MMDSP_PLUS 160 // STMicroelectronics 64bit VLIW Data Signal Processor -#define EM_CYPRESS_M8C 161 // Cypress M8C microprocessor -#define EM_R32C 162 // Renesas R32C series microprocessors -#define EM_TRIMEDIA 163 // NXP Semiconductors TriMedia architecture family -#define EM_QDSP6 164 // QUALCOMM DSP6 Processor -#define EM_8051 165 // Intel 8051 and variants -#define EM_STXP7X 166 // STMicroelectronics STxP7x family -#define EM_NDS32 167 // Andes Technology compact code size embedded RISC processor family -#define EM_ECOG1 168 // Cyan Technology eCOG1X family -#define EM_ECOG1X 168 // Cyan Technology eCOG1X family -#define EM_MAXQ30 169 // Dallas Semiconductor MAXQ30 Core Micro-controllers -#define EM_XIMO16 170 // New Japan Radio (NJR) 16-bit DSP Processor -#define EM_MANIK 171 // M2000 Reconfigurable RISC Microprocessor -#define EM_CRAYNV2 172 // Cray Inc. NV2 vector architecture -#define EM_RX 173 // Renesas RX family -#define EM_METAG 174 // Imagination Technologies META processor architecture -#define EM_MCST_ELBRUS 175 // MCST Elbrus general purpose hardware architecture -#define EM_ECOG16 176 // Cyan Technology eCOG16 family -#define EM_CR16 177 // National Semiconductor CompactRISC 16-bit processor -#define EM_ETPU 178 // Freescale Extended Time Processing Unit -#define EM_SLE9X 179 // Infineon Technologies SLE9X core -#define EM_L1OM 180 // Intel L1OM -#define EM_INTEL181 181 // Reserved by Intel -#define EM_INTEL182 182 // Reserved by Intel -#define EM_res183 183 // Reserved by ARM -#define EM_res184 184 // Reserved by ARM -#define EM_AVR32 185 // Atmel Corporation 32-bit microprocessor family -#define EM_STM8 186 // STMicroeletronics STM8 8-bit microcontroller -#define EM_TILE64 187 // Tilera TILE64 multicore architecture family -#define EM_TILEPRO 188 // Tilera TILEPro multicore architecture family -#define EM_MICROBLAZE 189 // Xilinx MicroBlaze 32-bit RISC soft processor core -#define EM_CUDA 190 // NVIDIA CUDA architecture -#define EM_TILEGX 191 // Tilera TILE-Gx multicore architecture family -#define EM_CLOUDSHIELD 192 // CloudShield architecture family -#define EM_COREA_1ST 193 // KIPO-KAIST Core-A 1st generation processor family -#define EM_COREA_2ND 194 // KIPO-KAIST Core-A 2nd generation processor family -#define EM_ARC_COMPACT2 195 // Synopsys ARCompact V2 -#define EM_OPEN8 196 // Open8 8-bit RISC soft processor core -#define EM_RL78 197 // Renesas RL78 family -#define EM_VIDEOCORE5 198 // Broadcom VideoCore V processor -#define EM_78KOR 199 // Renesas 78KOR family -#define EM_56800EX 200 // Freescale 56800EX Digital Signal Controller (DSC) -#define EM_BA1 201 // Beyond BA1 CPU architecture -#define EM_BA2 202 // Beyond BA2 CPU architecture -#define EM_XCORE 203 // XMOS xCORE processor family -#define EM_MCHP_PIC 204 // Microchip 8-bit PIC(r) family -#define EM_INTEL205 205 // Reserved by Intel -#define EM_INTEL206 206 // Reserved by Intel -#define EM_INTEL207 207 // Reserved by Intel -#define EM_INTEL208 208 // Reserved by Intel -#define EM_INTEL209 209 // Reserved by Intel -#define EM_KM32 210 // KM211 KM32 32-bit processor -#define EM_KMX32 211 // KM211 KMX32 32-bit processor -#define EM_KMX16 212 // KM211 KMX16 16-bit processor -#define EM_KMX8 213 // KM211 KMX8 8-bit processor -#define EM_KVARC 214 // KM211 KVARC processor -#define EM_CDP 215 // Paneve CDP architecture family -#define EM_COGE 216 // Cognitive Smart Memory Processor -#define EM_COOL 217 // iCelero CoolEngine -#define EM_NORC 218 // Nanoradio Optimized RISC -#define EM_CSR_KALIMBA 219 // CSR Kalimba architecture family -#define EM_Z80 220 // Zilog Z80 -#define EM_VISIUM 221 // Controls and Data Services VISIUMcore processor -#define EM_FT32 222 // FTDI Chip FT32 high performance 32-bit RISC architecture -#define EM_MOXIE 223 // Moxie processor family -#define EM_AMDGPU 224 // AMD GPU architecture -#define EM_RISCV 243 // RISC-V -#define EM_LANAI 244 // Lanai processor -#define EM_CEVA 245 // CEVA Processor Architecture Family -#define EM_CEVA_X2 246 // CEVA X2 Processor Family -#define EM_BPF 247 // Linux BPF – in-kernel virtual machine - -// File version -#define EV_NONE 0 -#define EV_CURRENT 1 - -// Identification index -#define EI_MAG0 0 -#define EI_MAG1 1 -#define EI_MAG2 2 -#define EI_MAG3 3 -#define EI_CLASS 4 -#define EI_DATA 5 -#define EI_VERSION 6 -#define EI_OSABI 7 -#define EI_ABIVERSION 8 -#define EI_PAD 9 -#define EI_NIDENT 16 - -// Magic number -#define ELFMAG0 0x7F -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' - -// File class -#define ELFCLASSNONE 0 -#define ELFCLASS32 1 -#define ELFCLASS64 2 - -// Encoding -#define ELFDATANONE 0 -#define ELFDATA2LSB 1 -#define ELFDATA2MSB 2 - -// OS extensions -#define ELFOSABI_NONE 0 // No extensions or unspecified -#define ELFOSABI_HPUX 1 // Hewlett-Packard HP-UX -#define ELFOSABI_NETBSD 2 // NetBSD -#define ELFOSABI_LINUX 3 // Linux -#define ELFOSABI_SOLARIS 6 // Sun Solaris -#define ELFOSABI_AIX 7 // AIX -#define ELFOSABI_IRIX 8 // IRIX -#define ELFOSABI_FREEBSD 9 // FreeBSD -#define ELFOSABI_TRU64 10 // Compaq TRU64 UNIX -#define ELFOSABI_MODESTO 11 // Novell Modesto -#define ELFOSABI_OPENBSD 12 // Open BSD -#define ELFOSABI_OPENVMS 13 // Open VMS -#define ELFOSABI_NSK 14 // Hewlett-Packard Non-Stop Kernel -#define ELFOSABI_AROS 15 // Amiga Research OS -#define ELFOSABI_FENIXOS 16 // The FenixOS highly scalable multi-core OS -// 64-255 Architecture-specific value range -#define ELFOSABI_AMDGPU_HSA 64 // AMDGPU OS for HSA compatible compute - // kernels. -#define ELFOSABI_AMDGPU_PAL 65 // AMDGPU OS for AMD PAL compatible graphics - // shaders and compute kernels. -#define ELFOSABI_AMDGPU_MESA3D 66 // AMDGPU OS for Mesa3D compatible graphics - // shaders and compute kernels. - - -// AMDGPU specific e_flags -#define EF_AMDGPU_MACH 0x0ff // AMDGPU processor selection mask. -#define EF_AMDGPU_XNACK 0x100 // Indicates if the XNACK target feature is - // enabled for all code contained in the ELF. -// AMDGPU processors -#define EF_AMDGPU_MACH_NONE 0x000 // Unspecified processor. -#define EF_AMDGPU_MACH_R600_R600 0x001 -#define EF_AMDGPU_MACH_R600_R630 0x002 -#define EF_AMDGPU_MACH_R600_RS880 0x003 -#define EF_AMDGPU_MACH_R600_RV670 0x004 -#define EF_AMDGPU_MACH_R600_RV710 0x005 -#define EF_AMDGPU_MACH_R600_RV730 0x006 -#define EF_AMDGPU_MACH_R600_RV770 0x007 -#define EF_AMDGPU_MACH_R600_CEDAR 0x008 -#define EF_AMDGPU_MACH_R600_CYPRESS 0x009 -#define EF_AMDGPU_MACH_R600_JUNIPER 0x00a -#define EF_AMDGPU_MACH_R600_REDWOOD 0x00b -#define EF_AMDGPU_MACH_R600_SUMO 0x00c -#define EF_AMDGPU_MACH_R600_BARTS 0x00d -#define EF_AMDGPU_MACH_R600_CAICOS 0x00e -#define EF_AMDGPU_MACH_R600_CAYMAN 0x00f -#define EF_AMDGPU_MACH_R600_TURKS 0x010 -#define EF_AMDGPU_MACH_R600_RESERVED_FIRST 0x011 -#define EF_AMDGPU_MACH_R600_RESERVED_LAST 0x01f -#define EF_AMDGPU_MACH_R600_FIRST EF_AMDGPU_MACH_R600_R600 -#define EF_AMDGPU_MACH_R600_LAST EF_AMDGPU_MACH_R600_TURKS -#define EF_AMDGPU_MACH_AMDGCN_GFX600 0x020 -#define EF_AMDGPU_MACH_AMDGCN_GFX601 0x021 -#define EF_AMDGPU_MACH_AMDGCN_GFX700 0x022 -#define EF_AMDGPU_MACH_AMDGCN_GFX701 0x023 -#define EF_AMDGPU_MACH_AMDGCN_GFX702 0x024 -#define EF_AMDGPU_MACH_AMDGCN_GFX703 0x025 -#define EF_AMDGPU_MACH_AMDGCN_GFX704 0x026 -#define EF_AMDGPU_MACH_AMDGCN_GFX801 0x028 -#define EF_AMDGPU_MACH_AMDGCN_GFX802 0x029 -#define EF_AMDGPU_MACH_AMDGCN_GFX803 0x02a -#define EF_AMDGPU_MACH_AMDGCN_GFX810 0x02b -#define EF_AMDGPU_MACH_AMDGCN_GFX900 0x02c -#define EF_AMDGPU_MACH_AMDGCN_GFX902 0x02d -#define EF_AMDGPU_MACH_AMDGCN_GFX904 0x02e -#define EF_AMDGPU_MACH_AMDGCN_GFX906 0x02f -#define EF_AMDGPU_MACH_AMDGCN_RESERVED0 0x027 -#define EF_AMDGPU_MACH_AMDGCN_RESERVED1 0x030 -#define EF_AMDGPU_MACH_AMDGCN_FIRST EF_AMDGPU_MACH_AMDGCN_GFX600 -#define EF_AMDGPU_MACH_AMDGCN_LAST EF_AMDGPU_MACH_AMDGCN_GFX906 - -///////////////////// -// Sections constants - -// Section indexes -#define SHN_UNDEF 0 -#define SHN_LORESERVE 0xFF00 -#define SHN_LOPROC 0xFF00 -#define SHN_HIPROC 0xFF1F -#define SHN_LOOS 0xFF20 -#define SHN_HIOS 0xFF3F -#define SHN_ABS 0xFFF1 -#define SHN_COMMON 0xFFF2 -#define SHN_XINDEX 0xFFFF -#define SHN_HIRESERVE 0xFFFF - -// Section types -#define SHT_NULL 0 -#define SHT_PROGBITS 1 -#define SHT_SYMTAB 2 -#define SHT_STRTAB 3 -#define SHT_RELA 4 -#define SHT_HASH 5 -#define SHT_DYNAMIC 6 -#define SHT_NOTE 7 -#define SHT_NOBITS 8 -#define SHT_REL 9 -#define SHT_SHLIB 10 -#define SHT_DYNSYM 11 -#define SHT_INIT_ARRAY 14 -#define SHT_FINI_ARRAY 15 -#define SHT_PREINIT_ARRAY 16 -#define SHT_GROUP 17 -#define SHT_SYMTAB_SHNDX 18 -#define SHT_LOOS 0x60000000 -#define SHT_HIOS 0x6fffffff -#define SHT_LOPROC 0x70000000 -#define SHT_HIPROC 0x7FFFFFFF -#define SHT_LOUSER 0x80000000 -#define SHT_HIUSER 0xFFFFFFFF - -// Section attribute flags -#define SHF_WRITE 0x1 -#define SHF_ALLOC 0x2 -#define SHF_EXECINSTR 0x4 -#define SHF_MERGE 0x10 -#define SHF_STRINGS 0x20 -#define SHF_INFO_LINK 0x40 -#define SHF_LINK_ORDER 0x80 -#define SHF_OS_NONCONFORMING 0x100 -#define SHF_GROUP 0x200 -#define SHF_TLS 0x400 -#define SHF_MASKOS 0x0ff00000 -#define SHF_MASKPROC 0xF0000000 - -// Section group flags -#define GRP_COMDAT 0x1 -#define GRP_MASKOS 0x0ff00000 -#define GRP_MASKPROC 0xf0000000 - -// Symbol binding -#define STB_LOCAL 0 -#define STB_GLOBAL 1 -#define STB_WEAK 2 -#define STB_LOOS 10 -#define STB_HIOS 12 -#define STB_MULTIDEF 13 -#define STB_LOPROC 13 -#define STB_HIPROC 15 - -// Note types -#define NT_AMDGPU_METADATA 1 -#define NT_AMD_AMDGPU_HSA_METADATA 10 -#define NT_AMD_AMDGPU_ISA 11 -#define NT_AMD_AMDGPU_PAL_METADATA 12 - -// Symbol types -#define STT_NOTYPE 0 -#define STT_OBJECT 1 -#define STT_FUNC 2 -#define STT_SECTION 3 -#define STT_FILE 4 -#define STT_COMMON 5 -#define STT_TLS 6 -#define STT_LOOS 10 -#define STT_AMDGPU_HSA_KERNEL 10 -#define STT_HIOS 12 -#define STT_LOPROC 13 -#define STT_HIPROC 15 - -// Symbol visibility -#define STV_DEFAULT 0 -#define STV_INTERNAL 1 -#define STV_HIDDEN 2 -#define STV_PROTECTED 3 - -// Undefined name -#define STN_UNDEF 0 - -// Relocation types -#define R_386_NONE 0 -#define R_X86_64_NONE 0 -#define R_AMDGPU_NONE 0 -#define R_386_32 1 -#define R_X86_64_64 1 -#define R_AMDGPU_ABS32_LO 1 -#define R_386_PC32 2 -#define R_X86_64_PC32 2 -#define R_AMDGPU_ABS32_HI 2 -#define R_386_GOT32 3 -#define R_X86_64_GOT32 3 -#define R_AMDGPU_ABS64 3 -#define R_386_PLT32 4 -#define R_X86_64_PLT32 4 -#define R_AMDGPU_REL32 4 -#define R_386_COPY 5 -#define R_X86_64_COPY 5 -#define R_AMDGPU_REL64 5 -#define R_386_GLOB_DAT 6 -#define R_X86_64_GLOB_DAT 6 -#define R_AMDGPU_ABS32 6 -#define R_386_JMP_SLOT 7 -#define R_X86_64_JUMP_SLOT 7 -#define R_AMDGPU_GOTPCREL 7 -#define R_386_RELATIVE 8 -#define R_X86_64_RELATIVE 8 -#define R_AMDGPU_GOTPCREL32_LO 8 -#define R_386_GOTOFF 9 -#define R_X86_64_GOTPCREL 9 -#define R_AMDGPU_GOTPCREL32_HI 9 -#define R_386_GOTPC 10 -#define R_X86_64_32 10 -#define R_AMDGPU_REL32_LO 10 -#define R_386_32PLT 11 -#define R_X86_64_32S 11 -#define R_AMDGPU_REL32_HI 11 -#define R_X86_64_16 12 -#define R_X86_64_PC16 13 -#define R_AMDGPU_RELATIVE64 13 -#define R_386_TLS_TPOFF 14 -#define R_X86_64_8 14 -#define R_386_TLS_IE 15 -#define R_X86_64_PC8 15 -#define R_386_TLS_GOTIE 16 -#define R_X86_64_DTPMOD64 16 -#define R_386_TLS_LE 17 -#define R_X86_64_DTPOFF64 17 -#define R_386_TLS_GD 18 -#define R_X86_64_TPOFF64 18 -#define R_386_TLS_LDM 19 -#define R_X86_64_TLSGD 19 -#define R_386_16 20 -#define R_X86_64_TLSLD 20 -#define R_386_PC16 21 -#define R_X86_64_DTPOFF32 21 -#define R_386_8 22 -#define R_X86_64_GOTTPOFF 22 -#define R_386_PC8 23 -#define R_X86_64_TPOFF32 23 -#define R_386_TLS_GD_32 24 -#define R_X86_64_PC64 24 -#define R_386_TLS_GD_PUSH 25 -#define R_X86_64_GOTOFF64 25 -#define R_386_TLS_GD_CALL 26 -#define R_X86_64_GOTPC32 26 -#define R_386_TLS_GD_POP 27 -#define R_X86_64_GOT64 27 -#define R_386_TLS_LDM_32 28 -#define R_X86_64_GOTPCREL64 28 -#define R_386_TLS_LDM_PUSH 29 -#define R_X86_64_GOTPC64 29 -#define R_386_TLS_LDM_CALL 30 -#define R_X86_64_GOTPLT64 30 -#define R_386_TLS_LDM_POP 31 -#define R_X86_64_PLTOFF64 31 -#define R_386_TLS_LDO_32 32 -#define R_386_TLS_IE_32 33 -#define R_386_TLS_LE_32 34 -#define R_X86_64_GOTPC32_TLSDESC 34 -#define R_386_TLS_DTPMOD32 35 -#define R_X86_64_TLSDESC_CALL 35 -#define R_386_TLS_DTPOFF32 36 -#define R_X86_64_TLSDESC 36 -#define R_386_TLS_TPOFF32 37 -#define R_X86_64_IRELATIVE 37 -#define R_386_SIZE32 38 -#define R_386_TLS_GOTDESC 39 -#define R_386_TLS_DESC_CALL 40 -#define R_386_TLS_DESC 41 -#define R_386_IRELATIVE 42 -#define R_386_GOT32X 43 -#define R_X86_64_GNU_VTINHERIT 250 -#define R_X86_64_GNU_VTENTRY 251 - -// Segment types -#define PT_NULL 0 -#define PT_LOAD 1 -#define PT_DYNAMIC 2 -#define PT_INTERP 3 -#define PT_NOTE 4 -#define PT_SHLIB 5 -#define PT_PHDR 6 -#define PT_TLS 7 -#define PT_LOOS 0x60000000 -#define PT_HIOS 0x6fffffff -#define PT_LOPROC 0x70000000 -#define PT_HIPROC 0x7FFFFFFF - -// Segment flags -#define PF_X 1 // Execute -#define PF_W 2 // Write -#define PF_R 4 // Read -#define PF_MASKOS 0x0ff00000 // Unspecified -#define PF_MASKPROC 0xf0000000 // Unspecified - -// Dynamic Array Tags -#define DT_NULL 0 -#define DT_NEEDED 1 -#define DT_PLTRELSZ 2 -#define DT_PLTGOT 3 -#define DT_HASH 4 -#define DT_STRTAB 5 -#define DT_SYMTAB 6 -#define DT_RELA 7 -#define DT_RELASZ 8 -#define DT_RELAENT 9 -#define DT_STRSZ 10 -#define DT_SYMENT 11 -#define DT_INIT 12 -#define DT_FINI 13 -#define DT_SONAME 14 -#define DT_RPATH 15 -#define DT_SYMBOLIC 16 -#define DT_REL 17 -#define DT_RELSZ 18 -#define DT_RELENT 19 -#define DT_PLTREL 20 -#define DT_DEBUG 21 -#define DT_TEXTREL 22 -#define DT_JMPREL 23 -#define DT_BIND_NOW 24 -#define DT_INIT_ARRAY 25 -#define DT_FINI_ARRAY 26 -#define DT_INIT_ARRAYSZ 27 -#define DT_FINI_ARRAYSZ 28 -#define DT_RUNPATH 29 -#define DT_FLAGS 30 -#define DT_ENCODING 32 -#define DT_PREINIT_ARRAY 32 -#define DT_PREINIT_ARRAYSZ 33 -#define DT_MAXPOSTAGS 34 -#define DT_LOOS 0x6000000D -#define DT_HIOS 0x6ffff000 -#define DT_LOPROC 0x70000000 -#define DT_HIPROC 0x7FFFFFFF - -// DT_FLAGS values -#define DF_ORIGIN 0x1 -#define DF_SYMBOLIC 0x2 -#define DF_TEXTREL 0x4 -#define DF_BIND_NOW 0x8 -#define DF_STATIC_TLS 0x10 - - -// ELF file header -struct Elf32_Ehdr { - unsigned char e_ident[EI_NIDENT]; - Elf_Half e_type; - Elf_Half e_machine; - Elf_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf_Word e_flags; - Elf_Half e_ehsize; - Elf_Half e_phentsize; - Elf_Half e_phnum; - Elf_Half e_shentsize; - Elf_Half e_shnum; - Elf_Half e_shstrndx; -}; - -struct Elf64_Ehdr { - unsigned char e_ident[EI_NIDENT]; - Elf_Half e_type; - Elf_Half e_machine; - Elf_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf_Word e_flags; - Elf_Half e_ehsize; - Elf_Half e_phentsize; - Elf_Half e_phnum; - Elf_Half e_shentsize; - Elf_Half e_shnum; - Elf_Half e_shstrndx; -}; - - -// Section header -struct Elf32_Shdr { - Elf_Word sh_name; - Elf_Word sh_type; - Elf_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf_Word sh_size; - Elf_Word sh_link; - Elf_Word sh_info; - Elf_Word sh_addralign; - Elf_Word sh_entsize; -}; - -struct Elf64_Shdr { - Elf_Word sh_name; - Elf_Word sh_type; - Elf_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf_Xword sh_size; - Elf_Word sh_link; - Elf_Word sh_info; - Elf_Xword sh_addralign; - Elf_Xword sh_entsize; -}; - - -// Segment header -struct Elf32_Phdr { - Elf_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf_Word p_filesz; - Elf_Word p_memsz; - Elf_Word p_flags; - Elf_Word p_align; -}; - -struct Elf64_Phdr { - Elf_Word p_type; - Elf_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf_Xword p_filesz; - Elf_Xword p_memsz; - Elf_Xword p_align; -}; - - -// Symbol table entry -struct Elf32_Sym { - Elf_Word st_name; - Elf32_Addr st_value; - Elf_Word st_size; - unsigned char st_info; - unsigned char st_other; - Elf_Half st_shndx; -}; - -struct Elf64_Sym { - Elf_Word st_name; - unsigned char st_info; - unsigned char st_other; - Elf_Half st_shndx; - Elf64_Addr st_value; - Elf_Xword st_size; -}; - - -#define ELF_ST_BIND(i) ((i)>>4) -#define ELF_ST_TYPE(i) ((i)&0xf) -#define ELF_ST_INFO(b,t) (((b)<<4)+((t)&0xf)) - -#define ELF_ST_VISIBILITY(o) ((o)&0x3) - - -// Relocation entries -struct Elf32_Rel { - Elf32_Addr r_offset; - Elf_Word r_info; -}; - -struct Elf32_Rela { - Elf32_Addr r_offset; - Elf_Word r_info; - Elf_Sword r_addend; -}; - -struct Elf64_Rel { - Elf64_Addr r_offset; - Elf_Xword r_info; -}; - -struct Elf64_Rela { - Elf64_Addr r_offset; - Elf_Xword r_info; - Elf_Sxword r_addend; -}; - - -#define ELF32_R_SYM(i) ((i)>>8) -#define ELF32_R_TYPE(i) ((unsigned char)(i)) -#define ELF32_R_INFO(s,t) (((s)<<8 )+(unsigned char)(t)) - -#define ELF64_R_SYM(i) ((i)>>32) -#define ELF64_R_TYPE(i) ((i)&0xffffffffL) -#define ELF64_R_INFO(s,t) ((((int64_t)(s))<<32)+((t)&0xffffffffL)) - -// Dynamic structure -struct Elf32_Dyn { - Elf_Sword d_tag; - union { - Elf_Word d_val; - Elf32_Addr d_ptr; - } d_un; -}; - -struct Elf64_Dyn { - Elf_Sxword d_tag; - union { - Elf_Xword d_val; - Elf64_Addr d_ptr; - } d_un; -}; - -} // namespace ELFIO - -#endif // ELFTYPES_H diff --git a/tools/ZAPD/lib/elfio/elfio/elfio.hpp b/tools/ZAPD/lib/elfio/elfio/elfio.hpp deleted file mode 100644 index f997b5dfc..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio.hpp +++ /dev/null @@ -1,955 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_HPP -#define ELFIO_HPP - -#ifdef _MSC_VER -#pragma warning ( push ) -#pragma warning(disable:4996) -#pragma warning(disable:4355) -#pragma warning(disable:4244) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define ELFIO_HEADER_ACCESS_GET( TYPE, FNAME ) \ -TYPE \ -get_##FNAME() const \ -{ \ - return header? header->get_##FNAME() : 0; \ -} - -#define ELFIO_HEADER_ACCESS_GET_SET( TYPE, FNAME ) \ -TYPE \ -get_##FNAME() const \ -{ \ - return header? header->get_##FNAME() : 0; \ -} \ -void \ -set_##FNAME( TYPE val ) \ -{ \ - if (header) { \ - header->set_##FNAME( val ); \ - } \ -} \ - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class elfio -{ - public: -//------------------------------------------------------------------------------ - elfio() : sections( this ), segments( this ) - { - header = 0; - current_file_pos = 0; - create( ELFCLASS32, ELFDATA2LSB ); - } - -//------------------------------------------------------------------------------ - ~elfio() - { - clean(); - } - -//------------------------------------------------------------------------------ - void create( unsigned char file_class, unsigned char encoding ) - { - clean(); - convertor.setup( encoding ); - header = create_header( file_class, encoding ); - create_mandatory_sections(); - } - -//------------------------------------------------------------------------------ - bool load( const std::string& file_name ) - { - std::ifstream stream; - stream.open( file_name.c_str(), std::ios::in | std::ios::binary ); - if ( !stream ) { - return false; - } - - return load(stream); - } - -//------------------------------------------------------------------------------ - bool load( std::istream &stream ) - { - clean(); - - unsigned char e_ident[EI_NIDENT]; - // Read ELF file signature - stream.read( reinterpret_cast( &e_ident ), sizeof( e_ident ) ); - - // Is it ELF file? - if ( stream.gcount() != sizeof( e_ident ) || - e_ident[EI_MAG0] != ELFMAG0 || - e_ident[EI_MAG1] != ELFMAG1 || - e_ident[EI_MAG2] != ELFMAG2 || - e_ident[EI_MAG3] != ELFMAG3 ) { - return false; - } - - if ( ( e_ident[EI_CLASS] != ELFCLASS64 ) && - ( e_ident[EI_CLASS] != ELFCLASS32 )) { - return false; - } - - convertor.setup( e_ident[EI_DATA] ); - header = create_header( e_ident[EI_CLASS], e_ident[EI_DATA] ); - if ( 0 == header ) { - return false; - } - if ( !header->load( stream ) ) { - return false; - } - - load_sections( stream ); - bool is_still_good = load_segments( stream ); - return is_still_good; - } - -//------------------------------------------------------------------------------ - bool save( const std::string& file_name ) - { - std::ofstream stream; - stream.open( file_name.c_str(), std::ios::out | std::ios::binary ); - if ( !stream ) { - return false; - } - - return save(stream); - } - -//------------------------------------------------------------------------------ - bool save( std::ostream &stream ) - { - if ( !stream || !header) { - return false; - } - - bool is_still_good = true; - // Define layout specific header fields - // The position of the segment table is fixed after the header. - // The position of the section table is variable and needs to be fixed - // before saving. - header->set_segments_num( segments.size() ); - header->set_segments_offset( segments.size() ? header->get_header_size() : 0 ); - header->set_sections_num( sections.size() ); - header->set_sections_offset( 0 ); - - // Layout the first section right after the segment table - current_file_pos = header->get_header_size() + - header->get_segment_entry_size() * header->get_segments_num(); - - calc_segment_alignment(); - - is_still_good = layout_segments_and_their_sections(); - is_still_good = is_still_good && layout_sections_without_segments(); - is_still_good = is_still_good && layout_section_table(); - - is_still_good = is_still_good && save_header( stream ); - is_still_good = is_still_good && save_sections( stream ); - is_still_good = is_still_good && save_segments( stream ); - - return is_still_good; - } - -//------------------------------------------------------------------------------ - // ELF header access functions - ELFIO_HEADER_ACCESS_GET( unsigned char, class ); - ELFIO_HEADER_ACCESS_GET( unsigned char, elf_version ); - ELFIO_HEADER_ACCESS_GET( unsigned char, encoding ); - ELFIO_HEADER_ACCESS_GET( Elf_Word, version ); - ELFIO_HEADER_ACCESS_GET( Elf_Half, header_size ); - ELFIO_HEADER_ACCESS_GET( Elf_Half, section_entry_size ); - ELFIO_HEADER_ACCESS_GET( Elf_Half, segment_entry_size ); - - ELFIO_HEADER_ACCESS_GET_SET( unsigned char, os_abi ); - ELFIO_HEADER_ACCESS_GET_SET( unsigned char, abi_version ); - ELFIO_HEADER_ACCESS_GET_SET( Elf_Half, type ); - ELFIO_HEADER_ACCESS_GET_SET( Elf_Half, machine ); - ELFIO_HEADER_ACCESS_GET_SET( Elf_Word, flags ); - ELFIO_HEADER_ACCESS_GET_SET( Elf64_Addr, entry ); - ELFIO_HEADER_ACCESS_GET_SET( Elf64_Off, sections_offset ); - ELFIO_HEADER_ACCESS_GET_SET( Elf64_Off, segments_offset ); - ELFIO_HEADER_ACCESS_GET_SET( Elf_Half, section_name_str_index ); - -//------------------------------------------------------------------------------ - const endianess_convertor& get_convertor() const - { - return convertor; - } - -//------------------------------------------------------------------------------ - Elf_Xword get_default_entry_size( Elf_Word section_type ) const - { - switch( section_type ) { - case SHT_RELA: - if ( header->get_class() == ELFCLASS64 ) { - return sizeof( Elf64_Rela ); - } - else { - return sizeof( Elf32_Rela ); - } - case SHT_REL: - if ( header->get_class() == ELFCLASS64 ) { - return sizeof( Elf64_Rel ); - } - else { - return sizeof( Elf32_Rel ); - } - case SHT_SYMTAB: - if ( header->get_class() == ELFCLASS64 ) { - return sizeof( Elf64_Sym ); - } - else { - return sizeof( Elf32_Sym ); - } - case SHT_DYNAMIC: - if ( header->get_class() == ELFCLASS64 ) { - return sizeof( Elf64_Dyn ); - } - else { - return sizeof( Elf32_Dyn ); - } - default: - return 0; - } - } - -//------------------------------------------------------------------------------ - private: - bool is_offset_in_section( Elf64_Off offset, const section* sec ) const { - return offset >= sec->get_offset() && offset < sec->get_offset()+sec->get_size(); - } - -//------------------------------------------------------------------------------ - public: - - //! returns an empty string if no problems are detected, - //! or a string containing an error message if problems are found - std::string validate() const { - - // check for overlapping sections in the file - for ( int i = 0; i < sections.size(); ++i) { - for ( int j = i+1; j < sections.size(); ++j ) { - const section* a = sections[i]; - const section* b = sections[j]; - if ( !(a->get_type() & SHT_NOBITS) - && !(b->get_type() & SHT_NOBITS) - && (a->get_size() > 0) - && (b->get_size() > 0) - && (a->get_offset() > 0) - && (b->get_offset() > 0)) { - if ( is_offset_in_section( a->get_offset(), b ) - || is_offset_in_section( a->get_offset()+a->get_size()-1, b ) - || is_offset_in_section( b->get_offset(), a ) - || is_offset_in_section( b->get_offset()+b->get_size()-1, a )) { - return "Sections " + a->get_name() + " and " + b->get_name() + " overlap in file"; - } - } - } - } - - // more checks to be added here... - - return ""; - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - void clean() - { - delete header; - header = 0; - - std::vector::const_iterator it; - for ( it = sections_.begin(); it != sections_.end(); ++it ) { - delete *it; - } - sections_.clear(); - - std::vector::const_iterator it1; - for ( it1 = segments_.begin(); it1 != segments_.end(); ++it1 ) { - delete *it1; - } - segments_.clear(); - } - -//------------------------------------------------------------------------------ - elf_header* create_header( unsigned char file_class, unsigned char encoding ) - { - elf_header* new_header = 0; - - if ( file_class == ELFCLASS64 ) { - new_header = new elf_header_impl< Elf64_Ehdr >( &convertor, - encoding ); - } - else if ( file_class == ELFCLASS32 ) { - new_header = new elf_header_impl< Elf32_Ehdr >( &convertor, - encoding ); - } - else { - return 0; - } - - return new_header; - } - -//------------------------------------------------------------------------------ - section* create_section() - { - section* new_section; - unsigned char file_class = get_class(); - - if ( file_class == ELFCLASS64 ) { - new_section = new section_impl( &convertor ); - } - else if ( file_class == ELFCLASS32 ) { - new_section = new section_impl( &convertor ); - } - else { - return 0; - } - - new_section->set_index( (Elf_Half)sections_.size() ); - sections_.push_back( new_section ); - - return new_section; - } - - -//------------------------------------------------------------------------------ - segment* create_segment() - { - segment* new_segment; - unsigned char file_class = header->get_class(); - - if ( file_class == ELFCLASS64 ) { - new_segment = new segment_impl( &convertor ); - } - else if ( file_class == ELFCLASS32 ) { - new_segment = new segment_impl( &convertor ); - } - else { - return 0; - } - - new_segment->set_index( (Elf_Half)segments_.size() ); - segments_.push_back( new_segment ); - - return new_segment; - } - -//------------------------------------------------------------------------------ - void create_mandatory_sections() - { - // Create null section without calling to 'add_section' as no string - // section containing section names exists yet - section* sec0 = create_section(); - sec0->set_index( 0 ); - sec0->set_name( "" ); - sec0->set_name_string_offset( 0 ); - - set_section_name_str_index( 1 ); - section* shstrtab = sections.add( ".shstrtab" ); - shstrtab->set_type( SHT_STRTAB ); - shstrtab->set_addr_align( 1 ); - } - -//------------------------------------------------------------------------------ - Elf_Half load_sections( std::istream& stream ) - { - Elf_Half entry_size = header->get_section_entry_size(); - Elf_Half num = header->get_sections_num(); - Elf64_Off offset = header->get_sections_offset(); - - for ( Elf_Half i = 0; i < num; ++i ) { - section* sec = create_section(); - sec->load( stream, (std::streamoff)offset + i * entry_size ); - sec->set_index( i ); - // To mark that the section is not permitted to reassign address - // during layout calculation - sec->set_address( sec->get_address() ); - } - - Elf_Half shstrndx = get_section_name_str_index(); - - if ( SHN_UNDEF != shstrndx ) { - string_section_accessor str_reader( sections[shstrndx] ); - for ( Elf_Half i = 0; i < num; ++i ) { - Elf_Word section_offset = sections[i]->get_name_string_offset(); - const char* p = str_reader.get_string( section_offset ); - if ( p != 0 ) { - sections[i]->set_name( p ); - } - } - } - - return num; - } - -//------------------------------------------------------------------------------ - //! Checks whether the addresses of the section entirely fall within the given segment. - //! It doesn't matter if the addresses are memory addresses, or file offsets, - //! they just need to be in the same address space - bool is_sect_in_seg ( Elf64_Off sect_begin, Elf_Xword sect_size, Elf64_Off seg_begin, Elf64_Off seg_end ) { - return seg_begin <= sect_begin - && sect_begin + sect_size <= seg_end - && sect_begin < seg_end; // this is important criteria when sect_size == 0 - // Example: seg_begin=10, seg_end=12 (-> covering the bytes 10 and 11) - // sect_begin=12, sect_size=0 -> shall return false! - } - -//------------------------------------------------------------------------------ - bool load_segments( std::istream& stream ) - { - Elf_Half entry_size = header->get_segment_entry_size(); - Elf_Half num = header->get_segments_num(); - Elf64_Off offset = header->get_segments_offset(); - - for ( Elf_Half i = 0; i < num; ++i ) { - segment* seg; - unsigned char file_class = header->get_class(); - - if ( file_class == ELFCLASS64 ) { - seg = new segment_impl( &convertor ); - } - else if ( file_class == ELFCLASS32 ) { - seg = new segment_impl( &convertor ); - } - else { - return false; - } - - seg->load( stream, (std::streamoff)offset + i * entry_size ); - seg->set_index( i ); - - // Add sections to the segments (similar to readelfs algorithm) - Elf64_Off segBaseOffset = seg->get_offset(); - Elf64_Off segEndOffset = segBaseOffset + seg->get_file_size(); - Elf64_Off segVBaseAddr = seg->get_virtual_address(); - Elf64_Off segVEndAddr = segVBaseAddr + seg->get_memory_size(); - for( Elf_Half j = 0; j < sections.size(); ++j ) { - const section* psec = sections[j]; - - // SHF_ALLOC sections are matched based on the virtual address - // otherwise the file offset is matched - if( psec->get_flags() & SHF_ALLOC - ? is_sect_in_seg( psec->get_address(), psec->get_size(), segVBaseAddr, segVEndAddr ) - : is_sect_in_seg( psec->get_offset(), psec->get_size(), segBaseOffset, segEndOffset )) { - // Alignment of segment shall not be updated, to preserve original value - // It will be re-calculated on saving. - seg->add_section_index( psec->get_index(), 0 ); - } - } - - // Add section into the segments' container - segments_.push_back( seg ); - } - - return true; - } - -//------------------------------------------------------------------------------ - bool save_header( std::ostream& stream ) - { - return header->save( stream ); - } - -//------------------------------------------------------------------------------ - bool save_sections( std::ostream& stream ) - { - for ( unsigned int i = 0; i < sections_.size(); ++i ) { - section *sec = sections_.at(i); - - std::streampos headerPosition = - (std::streamoff)header->get_sections_offset() + - header->get_section_entry_size() * sec->get_index(); - - sec->save(stream,headerPosition,sec->get_offset()); - } - return true; - } - -//------------------------------------------------------------------------------ - bool save_segments( std::ostream& stream ) - { - for ( unsigned int i = 0; i < segments_.size(); ++i ) { - segment *seg = segments_.at(i); - - std::streampos headerPosition = header->get_segments_offset() + - header->get_segment_entry_size()*seg->get_index(); - - seg->save( stream, headerPosition, seg->get_offset() ); - } - return true; - } - -//------------------------------------------------------------------------------ - bool is_section_without_segment( unsigned int section_index ) - { - bool found = false; - - for ( unsigned int j = 0; !found && ( j < segments.size() ); ++j ) { - for ( unsigned int k = 0; - !found && ( k < segments[j]->get_sections_num() ); - ++k ) { - found = segments[j]->get_section_index_at( k ) == section_index; - } - } - - return !found; - } - -//------------------------------------------------------------------------------ - bool is_subsequence_of( segment* seg1, segment* seg2 ) - { - // Return 'true' if sections of seg1 are a subset of sections in seg2 - const std::vector& sections1 = seg1->get_sections(); - const std::vector& sections2 = seg2->get_sections(); - - bool found = false; - if ( sections1.size() < sections2.size() ) { - found = std::includes( sections2.begin(), sections2.end(), - sections1.begin(), sections1.end() ); - } - - return found; - } - -//------------------------------------------------------------------------------ - std::vector get_ordered_segments( ) - { - std::vector res; - std::deque worklist; - - res.reserve(segments.size()); - std::copy( segments_.begin(), segments_.end(), - std::back_inserter( worklist )) ; - - // Bring the segments which start at address 0 to the front - size_t nextSlot = 0; - for( size_t i = 0; i < worklist.size(); ++i ) { - if( i != nextSlot && worklist[i]->is_offset_initialized() - && worklist[i]->get_offset() == 0 ) { - if (worklist[nextSlot]->get_offset() == 0) { - ++nextSlot; - } - std::swap(worklist[i],worklist[nextSlot]); - ++nextSlot; - } - } - - while ( !worklist.empty() ) { - segment *seg = worklist.front(); - worklist.pop_front(); - - size_t i = 0; - for ( ; i < worklist.size(); ++i ) { - if ( is_subsequence_of( seg, worklist[i] ) ) { - break; - } - } - - if ( i < worklist.size() ) - worklist.push_back(seg); - else - res.push_back(seg); - } - - return res; - } - - -//------------------------------------------------------------------------------ - bool layout_sections_without_segments( ) - { - for ( unsigned int i = 0; i < sections_.size(); ++i ) { - if ( is_section_without_segment( i ) ) { - section *sec = sections_[i]; - - Elf_Xword section_align = sec->get_addr_align(); - if ( section_align > 1 && current_file_pos % section_align != 0 ) { - current_file_pos += section_align - - current_file_pos % section_align; - } - - if ( 0 != sec->get_index() ) - sec->set_offset(current_file_pos); - - if ( SHT_NOBITS != sec->get_type() && - SHT_NULL != sec->get_type() ) { - current_file_pos += sec->get_size(); - } - } - } - - return true; - } - - -//------------------------------------------------------------------------------ - void calc_segment_alignment( ) - { - for( std::vector::iterator s = segments_.begin(); s != segments_.end(); ++s ) { - segment* seg = *s; - for ( int i = 0; i < seg->get_sections_num(); ++i ) { - section* sect = sections_[ seg->get_section_index_at(i) ]; - if ( sect->get_addr_align() > seg->get_align() ) { - seg->set_align( sect->get_addr_align() ); - } - } - } - } - -//------------------------------------------------------------------------------ - bool layout_segments_and_their_sections( ) - { - std::vector worklist; - std::vector section_generated(sections.size(),false); - - // Get segments in a order in where segments which contain a - // sub sequence of other segments are located at the end - worklist = get_ordered_segments(); - - for ( unsigned int i = 0; i < worklist.size(); ++i ) { - Elf_Xword segment_memory = 0; - Elf_Xword segment_filesize = 0; - Elf_Xword seg_start_pos = current_file_pos; - segment* seg = worklist[i]; - - // Special case: PHDR segment - // This segment contains the program headers but no sections - if ( seg->get_type() == PT_PHDR && seg->get_sections_num() == 0 ) { - seg_start_pos = header->get_segments_offset(); - segment_memory = segment_filesize = - header->get_segment_entry_size() * header->get_segments_num(); - } - // Special case: - // Segments which start with the NULL section and have further sections - else if ( seg->get_sections_num() > 1 - && sections[seg->get_section_index_at( 0 )]->get_type() == SHT_NULL ) { - seg_start_pos = 0; - if ( seg->get_sections_num() ) { - segment_memory = segment_filesize = current_file_pos; - } - } - // New segments with not generated sections - // have to be aligned - else if ( seg->get_sections_num() - && !section_generated[seg->get_section_index_at( 0 )] ) { - Elf_Xword align = seg->get_align() > 0 ? seg->get_align() : 1; - Elf64_Off cur_page_alignment = current_file_pos % align; - Elf64_Off req_page_alignment = seg->get_virtual_address() % align; - Elf64_Off error = req_page_alignment - cur_page_alignment; - - current_file_pos += ( seg->get_align() + error ) % align; - seg_start_pos = current_file_pos; - } - else if ( seg->get_sections_num() ) { - seg_start_pos = sections[seg->get_section_index_at( 0 )]->get_offset(); - } - - // Write segment's data - for ( unsigned int j = 0; j < seg->get_sections_num(); ++j ) { - Elf_Half index = seg->get_section_index_at( j ); - - section* sec = sections[ index ]; - - // The NULL section is always generated - if ( SHT_NULL == sec->get_type()) { - section_generated[index] = true; - continue; - } - - Elf_Xword secAlign = 0; - // Fix up the alignment - if ( !section_generated[index] && sec->is_address_initialized() - && SHT_NOBITS != sec->get_type() - && SHT_NULL != sec->get_type() - && 0 != sec->get_size() ) { - // Align the sections based on the virtual addresses - // when possible (this is what matters for execution) - Elf64_Off req_offset = sec->get_address() - seg->get_virtual_address(); - Elf64_Off cur_offset = current_file_pos - seg_start_pos; - if ( req_offset < cur_offset) { - // something has gone awfully wrong, abort! - // secAlign would turn out negative, seeking backwards and overwriting previous data - return false; - } - secAlign = req_offset - cur_offset; - } - else if (!section_generated[index] && !sec->is_address_initialized() ) { - // If no address has been specified then only the section - // alignment constraint has to be matched - Elf_Xword align = sec->get_addr_align(); - if (align == 0) { - align = 1; - } - Elf64_Off error = current_file_pos % align; - secAlign = ( align - error ) % align; - } - else if (section_generated[index] ) { - // Alignment for already generated sections - secAlign = sec->get_offset() - seg_start_pos - segment_filesize; - } - - // Determine the segment file and memory sizes - // Special case .tbss section (NOBITS) in non TLS segment - if ( (sec->get_flags() & SHF_ALLOC) - && !( (sec->get_flags() & SHF_TLS) && (seg->get_type() != PT_TLS) - && ( SHT_NOBITS == sec->get_type())) ) - segment_memory += sec->get_size() + secAlign; - if ( SHT_NOBITS != sec->get_type() && SHT_NULL != sec->get_type() ) - segment_filesize += sec->get_size() + secAlign; - - // Nothing to be done when generating nested segments - if(section_generated[index]) { - continue; - } - - current_file_pos += secAlign; - - // Set the section addresses when missing - if ( !sec->is_address_initialized() ) - sec->set_address( seg->get_virtual_address() - + current_file_pos - seg_start_pos); - - if ( 0 != sec->get_index() ) - sec->set_offset(current_file_pos); - - if ( SHT_NOBITS != sec->get_type() && SHT_NULL != sec->get_type() ) - current_file_pos += sec->get_size(); - section_generated[index] = true; - } - - seg->set_file_size( segment_filesize ); - - // If we already have a memory size from loading an elf file (value > 0), - // it must not shrink! - // Memory size may be bigger than file size and it is the loader's job to do something - // with the surplus bytes in memory, like initializing them with a defined value. - if ( seg->get_memory_size() < segment_memory ) { - seg->set_memory_size( segment_memory ); - } - - seg->set_offset(seg_start_pos); - } - - return true; - } - -//------------------------------------------------------------------------------ - bool layout_section_table() - { - // Simply place the section table at the end for now - Elf64_Off alignmentError = current_file_pos % 4; - current_file_pos += ( 4 - alignmentError ) % 4; - header->set_sections_offset(current_file_pos); - return true; - } - - -//------------------------------------------------------------------------------ - public: - friend class Sections; - class Sections { - public: -//------------------------------------------------------------------------------ - Sections( elfio* parent_ ) : - parent( parent_ ) - { - } - -//------------------------------------------------------------------------------ - Elf_Half size() const - { - return (Elf_Half)parent->sections_.size(); - } - -//------------------------------------------------------------------------------ - section* operator[]( unsigned int index ) const - { - section* sec = 0; - - if ( index < parent->sections_.size() ) { - sec = parent->sections_[index]; - } - - return sec; - } - -//------------------------------------------------------------------------------ - section* operator[]( const std::string& name ) const - { - section* sec = 0; - - std::vector::const_iterator it; - for ( it = parent->sections_.begin(); - it != parent->sections_.end(); - ++it ) { - if ( (*it)->get_name() == name ) { - sec = *it; - break; - } - } - - return sec; - } - -//------------------------------------------------------------------------------ - section* add( const std::string& name ) - { - section* new_section = parent->create_section(); - new_section->set_name( name ); - - Elf_Half str_index = parent->get_section_name_str_index(); - section* string_table( parent->sections_[str_index] ); - string_section_accessor str_writer( string_table ); - Elf_Word pos = str_writer.add_string( name ); - new_section->set_name_string_offset( pos ); - - return new_section; - } - -//------------------------------------------------------------------------------ - std::vector::iterator begin() { - return parent->sections_.begin(); - } - -//------------------------------------------------------------------------------ - std::vector::iterator end() { - return parent->sections_.end(); - } - -//------------------------------------------------------------------------------ - std::vector::const_iterator begin() const { - return parent->sections_.cbegin(); - } - -//------------------------------------------------------------------------------ - std::vector::const_iterator end() const { - return parent->sections_.cend(); - } - -//------------------------------------------------------------------------------ - private: - elfio* parent; - } sections; - -//------------------------------------------------------------------------------ - public: - friend class Segments; - class Segments { - public: -//------------------------------------------------------------------------------ - Segments( elfio* parent_ ) : - parent( parent_ ) - { - } - -//------------------------------------------------------------------------------ - Elf_Half size() const - { - return (Elf_Half)parent->segments_.size(); - } - -//------------------------------------------------------------------------------ - segment* operator[]( unsigned int index ) const - { - return parent->segments_[index]; - } - - -//------------------------------------------------------------------------------ - segment* add() - { - return parent->create_segment(); - } - -//------------------------------------------------------------------------------ - std::vector::iterator begin() { - return parent->segments_.begin(); - } - -//------------------------------------------------------------------------------ - std::vector::iterator end() { - return parent->segments_.end(); - } - -//------------------------------------------------------------------------------ - std::vector::const_iterator begin() const { - return parent->segments_.cbegin(); - } - -//------------------------------------------------------------------------------ - std::vector::const_iterator end() const { - return parent->segments_.cend(); - } - -//------------------------------------------------------------------------------ - private: - elfio* parent; - } segments; - -//------------------------------------------------------------------------------ - private: - elf_header* header; - std::vector sections_; - std::vector segments_; - endianess_convertor convertor; - - Elf_Xword current_file_pos; -}; - -} // namespace ELFIO - -#include -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning ( pop ) -#endif - -#endif // ELFIO_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_dump.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_dump.hpp deleted file mode 100644 index 4ace66514..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_dump.hpp +++ /dev/null @@ -1,976 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_DUMP_HPP -#define ELFIO_DUMP_HPP - -#include -#include -#include -#include -#include -#include - -namespace ELFIO { - - -static struct class_table_t { - const char key; - const char* str; -} class_table [] = -{ - { ELFCLASS32, "ELF32" }, - { ELFCLASS64, "ELF64" }, -}; - - -static struct endian_table_t { - const char key; - const char* str; -} endian_table [] = -{ - { ELFDATANONE, "None" }, - { ELFDATA2LSB, "Little endian" }, - { ELFDATA2MSB, "Big endian" }, -}; - - -static struct version_table_t { - const Elf64_Word key; - const char* str; -} version_table [] = -{ - { EV_NONE , "None" }, - { EV_CURRENT, "Current" }, -}; - - -static struct type_table_t { - const Elf32_Half key; - const char* str; -} type_table [] = -{ - { ET_NONE, "No file type" }, - { ET_REL , "Relocatable file" }, - { ET_EXEC, "Executable file" }, - { ET_DYN , "Shared object file" }, - { ET_CORE, "Core file" }, -}; - - -static struct machine_table_t { - const Elf64_Half key; - const char* str; -} machine_table [] = -{ - { EM_NONE , "No machine" }, - { EM_M32 , "AT&T WE 32100" }, - { EM_SPARC , "SUN SPARC" }, - { EM_386 , "Intel 80386" }, - { EM_68K , "Motorola m68k family" }, - { EM_88K , "Motorola m88k family" }, - { EM_486 , "Intel 80486// Reserved for future use" }, - { EM_860 , "Intel 80860" }, - { EM_MIPS , "MIPS R3000 (officially, big-endian only)" }, - { EM_S370 , "IBM System/370" }, - { EM_MIPS_RS3_LE , "MIPS R3000 little-endian (Oct 4 1999 Draft) Deprecated" }, - { EM_res011 , "Reserved" }, - { EM_res012 , "Reserved" }, - { EM_res013 , "Reserved" }, - { EM_res014 , "Reserved" }, - { EM_PARISC , "HPPA" }, - { EM_res016 , "Reserved" }, - { EM_VPP550 , "Fujitsu VPP500" }, - { EM_SPARC32PLUS , "Sun's v8plus" }, - { EM_960 , "Intel 80960" }, - { EM_PPC , "PowerPC" }, - { EM_PPC64 , "64-bit PowerPC" }, - { EM_S390 , "IBM S/390" }, - { EM_SPU , "Sony/Toshiba/IBM SPU" }, - { EM_res024 , "Reserved" }, - { EM_res025 , "Reserved" }, - { EM_res026 , "Reserved" }, - { EM_res027 , "Reserved" }, - { EM_res028 , "Reserved" }, - { EM_res029 , "Reserved" }, - { EM_res030 , "Reserved" }, - { EM_res031 , "Reserved" }, - { EM_res032 , "Reserved" }, - { EM_res033 , "Reserved" }, - { EM_res034 , "Reserved" }, - { EM_res035 , "Reserved" }, - { EM_V800 , "NEC V800 series" }, - { EM_FR20 , "Fujitsu FR20" }, - { EM_RH32 , "TRW RH32" }, - { EM_MCORE , "Motorola M*Core // May also be taken by Fujitsu MMA" }, - { EM_RCE , "Old name for MCore" }, - { EM_ARM , "ARM" }, - { EM_OLD_ALPHA , "Digital Alpha" }, - { EM_SH , "Renesas (formerly Hitachi) / SuperH SH" }, - { EM_SPARCV9 , "SPARC v9 64-bit" }, - { EM_TRICORE , "Siemens Tricore embedded processor" }, - { EM_ARC , "ARC Cores" }, - { EM_H8_300 , "Renesas (formerly Hitachi) H8/300" }, - { EM_H8_300H , "Renesas (formerly Hitachi) H8/300H" }, - { EM_H8S , "Renesas (formerly Hitachi) H8S" }, - { EM_H8_500 , "Renesas (formerly Hitachi) H8/500" }, - { EM_IA_64 , "Intel IA-64 Processor" }, - { EM_MIPS_X , "Stanford MIPS-X" }, - { EM_COLDFIRE , "Motorola Coldfire" }, - { EM_68HC12 , "Motorola M68HC12" }, - { EM_MMA , "Fujitsu Multimedia Accelerator" }, - { EM_PCP , "Siemens PCP" }, - { EM_NCPU , "Sony nCPU embedded RISC processor" }, - { EM_NDR1 , "Denso NDR1 microprocesspr" }, - { EM_STARCORE , "Motorola Star*Core processor" }, - { EM_ME16 , "Toyota ME16 processor" }, - { EM_ST100 , "STMicroelectronics ST100 processor" }, - { EM_TINYJ , "Advanced Logic Corp. TinyJ embedded processor" }, - { EM_X86_64 , "Advanced Micro Devices X86-64 processor" }, - { EM_PDSP , "Sony DSP Processor" }, - { EM_PDP10 , "Digital Equipment Corp. PDP-10" }, - { EM_PDP11 , "Digital Equipment Corp. PDP-11" }, - { EM_FX66 , "Siemens FX66 microcontroller" }, - { EM_ST9PLUS , "STMicroelectronics ST9+ 8/16 bit microcontroller" }, - { EM_ST7 , "STMicroelectronics ST7 8-bit microcontroller" }, - { EM_68HC16 , "Motorola MC68HC16 Microcontroller" }, - { EM_68HC11 , "Motorola MC68HC11 Microcontroller" }, - { EM_68HC08 , "Motorola MC68HC08 Microcontroller" }, - { EM_68HC05 , "Motorola MC68HC05 Microcontroller" }, - { EM_SVX , "Silicon Graphics SVx" }, - { EM_ST19 , "STMicroelectronics ST19 8-bit cpu" }, - { EM_VAX , "Digital VAX" }, - { EM_CRIS , "Axis Communications 32-bit embedded processor" }, - { EM_JAVELIN , "Infineon Technologies 32-bit embedded cpu" }, - { EM_FIREPATH , "Element 14 64-bit DSP processor" }, - { EM_ZSP , "LSI Logic's 16-bit DSP processor" }, - { EM_MMIX , "Donald Knuth's educational 64-bit processor" }, - { EM_HUANY , "Harvard's machine-independent format" }, - { EM_PRISM , "SiTera Prism" }, - { EM_AVR , "Atmel AVR 8-bit microcontroller" }, - { EM_FR30 , "Fujitsu FR30" }, - { EM_D10V , "Mitsubishi D10V" }, - { EM_D30V , "Mitsubishi D30V" }, - { EM_V850 , "NEC v850" }, - { EM_M32R , "Renesas M32R (formerly Mitsubishi M32R)" }, - { EM_MN10300 , "Matsushita MN10300" }, - { EM_MN10200 , "Matsushita MN10200" }, - { EM_PJ , "picoJava" }, - { EM_OPENRISC , "OpenRISC 32-bit embedded processor" }, - { EM_ARC_A5 , "ARC Cores Tangent-A5" }, - { EM_XTENSA , "Tensilica Xtensa Architecture" }, - { EM_VIDEOCORE , "Alphamosaic VideoCore processor" }, - { EM_TMM_GPP , "Thompson Multimedia General Purpose Processor" }, - { EM_NS32K , "National Semiconductor 32000 series" }, - { EM_TPC , "Tenor Network TPC processor" }, - { EM_SNP1K , "Trebia SNP 1000 processor" }, - { EM_ST200 , "STMicroelectronics ST200 microcontroller" }, - { EM_IP2K , "Ubicom IP2022 micro controller" }, - { EM_MAX , "MAX Processor" }, - { EM_CR , "National Semiconductor CompactRISC" }, - { EM_F2MC16 , "Fujitsu F2MC16" }, - { EM_MSP430 , "TI msp430 micro controller" }, - { EM_BLACKFIN , "ADI Blackfin" }, - { EM_SE_C33 , "S1C33 Family of Seiko Epson processors" }, - { EM_SEP , "Sharp embedded microprocessor" }, - { EM_ARCA , "Arca RISC Microprocessor" }, - { EM_UNICORE , "Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University" }, - { EM_EXCESS , "eXcess: 16/32/64-bit configurable embedded CPU" }, - { EM_DXP , "Icera Semiconductor Inc. Deep Execution Processor" }, - { EM_ALTERA_NIOS2 , "Altera Nios II soft-core processor" }, - { EM_CRX , "National Semiconductor CRX" }, - { EM_XGATE , "Motorola XGATE embedded processor" }, - { EM_C166 , "Infineon C16x/XC16x processor" }, - { EM_M16C , "Renesas M16C series microprocessors" }, - { EM_DSPIC30F , "Microchip Technology dsPIC30F Digital Signal Controller" }, - { EM_CE , "Freescale Communication Engine RISC core" }, - { EM_M32C , "Renesas M32C series microprocessors" }, - { EM_res121 , "Reserved" }, - { EM_res122 , "Reserved" }, - { EM_res123 , "Reserved" }, - { EM_res124 , "Reserved" }, - { EM_res125 , "Reserved" }, - { EM_res126 , "Reserved" }, - { EM_res127 , "Reserved" }, - { EM_res128 , "Reserved" }, - { EM_res129 , "Reserved" }, - { EM_res130 , "Reserved" }, - { EM_TSK3000 , "Altium TSK3000 core" }, - { EM_RS08 , "Freescale RS08 embedded processor" }, - { EM_res133 , "Reserved" }, - { EM_ECOG2 , "Cyan Technology eCOG2 microprocessor" }, - { EM_SCORE , "Sunplus Score" }, - { EM_SCORE7 , "Sunplus S+core7 RISC processor" }, - { EM_DSP24 , "New Japan Radio (NJR) 24-bit DSP Processor" }, - { EM_VIDEOCORE3 , "Broadcom VideoCore III processor" }, - { EM_LATTICEMICO32, "RISC processor for Lattice FPGA architecture" }, - { EM_SE_C17 , "Seiko Epson C17 family" }, - { EM_TI_C6000 , "Texas Instruments TMS320C6000 DSP family" }, - { EM_TI_C2000 , "Texas Instruments TMS320C2000 DSP family" }, - { EM_TI_C5500 , "Texas Instruments TMS320C55x DSP family" }, - { EM_res143 , "Reserved" }, - { EM_res144 , "Reserved" }, - { EM_res145 , "Reserved" }, - { EM_res146 , "Reserved" }, - { EM_res147 , "Reserved" }, - { EM_res148 , "Reserved" }, - { EM_res149 , "Reserved" }, - { EM_res150 , "Reserved" }, - { EM_res151 , "Reserved" }, - { EM_res152 , "Reserved" }, - { EM_res153 , "Reserved" }, - { EM_res154 , "Reserved" }, - { EM_res155 , "Reserved" }, - { EM_res156 , "Reserved" }, - { EM_res157 , "Reserved" }, - { EM_res158 , "Reserved" }, - { EM_res159 , "Reserved" }, - { EM_MMDSP_PLUS , "STMicroelectronics 64bit VLIW Data Signal Processor" }, - { EM_CYPRESS_M8C , "Cypress M8C microprocessor" }, - { EM_R32C , "Renesas R32C series microprocessors" }, - { EM_TRIMEDIA , "NXP Semiconductors TriMedia architecture family" }, - { EM_QDSP6 , "QUALCOMM DSP6 Processor" }, - { EM_8051 , "Intel 8051 and variants" }, - { EM_STXP7X , "STMicroelectronics STxP7x family" }, - { EM_NDS32 , "Andes Technology compact code size embedded RISC processor family" }, - { EM_ECOG1 , "Cyan Technology eCOG1X family" }, - { EM_ECOG1X , "Cyan Technology eCOG1X family" }, - { EM_MAXQ30 , "Dallas Semiconductor MAXQ30 Core Micro-controllers" }, - { EM_XIMO16 , "New Japan Radio (NJR) 16-bit DSP Processor" }, - { EM_MANIK , "M2000 Reconfigurable RISC Microprocessor" }, - { EM_CRAYNV2 , "Cray Inc. NV2 vector architecture" }, - { EM_RX , "Renesas RX family" }, - { EM_METAG , "Imagination Technologies META processor architecture" }, - { EM_MCST_ELBRUS , "MCST Elbrus general purpose hardware architecture" }, - { EM_ECOG16 , "Cyan Technology eCOG16 family" }, - { EM_CR16 , "National Semiconductor CompactRISC 16-bit processor" }, - { EM_ETPU , "Freescale Extended Time Processing Unit" }, - { EM_SLE9X , "Infineon Technologies SLE9X core" }, - { EM_L1OM , "Intel L1OM" }, - { EM_INTEL181 , "Reserved by Intel" }, - { EM_INTEL182 , "Reserved by Intel" }, - { EM_res183 , "Reserved by ARM" }, - { EM_res184 , "Reserved by ARM" }, - { EM_AVR32 , "Atmel Corporation 32-bit microprocessor family" }, - { EM_STM8 , "STMicroeletronics STM8 8-bit microcontroller" }, - { EM_TILE64 , "Tilera TILE64 multicore architecture family" }, - { EM_TILEPRO , "Tilera TILEPro multicore architecture family" }, - { EM_MICROBLAZE , "Xilinx MicroBlaze 32-bit RISC soft processor core" }, - { EM_CUDA , "NVIDIA CUDA architecture " }, -}; - - -static struct section_type_table_t { - const Elf64_Half key; - const char* str; -} section_type_table [] = -{ - { SHT_NULL , "NULL" }, - { SHT_PROGBITS , "PROGBITS" }, - { SHT_SYMTAB , "SYMTAB" }, - { SHT_STRTAB , "STRTAB" }, - { SHT_RELA , "RELA" }, - { SHT_HASH , "HASH" }, - { SHT_DYNAMIC , "DYNAMIC" }, - { SHT_NOTE , "NOTE" }, - { SHT_NOBITS , "NOBITS" }, - { SHT_REL , "REL" }, - { SHT_SHLIB , "SHLIB" }, - { SHT_DYNSYM , "DYNSYM" }, - { SHT_INIT_ARRAY , "INIT_ARRAY" }, - { SHT_FINI_ARRAY , "FINI_ARRAY" }, - { SHT_PREINIT_ARRAY, "PREINIT_ARRAY" }, - { SHT_GROUP , "GROUP" }, - { SHT_SYMTAB_SHNDX , "SYMTAB_SHNDX " }, -}; - - -static struct segment_type_table_t { - const Elf_Word key; - const char* str; -} segment_type_table [] = -{ - { PT_NULL , "NULL" }, - { PT_LOAD , "LOAD" }, - { PT_DYNAMIC, "DYNAMIC" }, - { PT_INTERP , "INTERP" }, - { PT_NOTE , "NOTE" }, - { PT_SHLIB , "SHLIB" }, - { PT_PHDR , "PHDR" }, - { PT_TLS , "TLS" }, -}; - - -static struct segment_flag_table_t { - const Elf_Word key; - const char* str; -} segment_flag_table [] = -{ - { 0, "" }, - { 1, "X" }, - { 2, "W" }, - { 3, "WX" }, - { 4, "R" }, - { 5, "RX" }, - { 6, "RW" }, - { 7, "RWX" }, -}; - - -static struct symbol_bind_t { - const Elf_Word key; - const char* str; -} symbol_bind_table [] = -{ - { STB_LOCAL , "LOCAL" }, - { STB_GLOBAL , "GLOBAL" }, - { STB_WEAK , "WEAK" }, - { STB_LOOS , "LOOS" }, - { STB_HIOS , "HIOS" }, - { STB_MULTIDEF, "MULTIDEF" }, - { STB_LOPROC , "LOPROC" }, - { STB_HIPROC , "HIPROC" }, -}; - - -static struct symbol_type_t { - const Elf_Word key; - const char* str; -} symbol_type_table [] = -{ - { STT_NOTYPE , "NOTYPE" }, - { STT_OBJECT , "OBJECT" }, - { STT_FUNC , "FUNC" }, - { STT_SECTION, "SECTION" }, - { STT_FILE , "FILE" }, - { STT_COMMON , "COMMON" }, - { STT_TLS , "TLS" }, - { STT_LOOS , "LOOS" }, - { STT_HIOS , "HIOS" }, - { STT_LOPROC , "LOPROC" }, - { STT_HIPROC , "HIPROC" }, -}; - - -static struct dynamic_tag_t { - const Elf_Word key; - const char* str; -} dynamic_tag_table [] = -{ - { DT_NULL , "NULL" }, - { DT_NEEDED , "NEEDED" }, - { DT_PLTRELSZ , "PLTRELSZ" }, - { DT_PLTGOT , "PLTGOT" }, - { DT_HASH , "HASH" }, - { DT_STRTAB , "STRTAB" }, - { DT_SYMTAB , "SYMTAB" }, - { DT_RELA , "RELA" }, - { DT_RELASZ , "RELASZ" }, - { DT_RELAENT , "RELAENT" }, - { DT_STRSZ , "STRSZ" }, - { DT_SYMENT , "SYMENT" }, - { DT_INIT , "INIT" }, - { DT_FINI , "FINI" }, - { DT_SONAME , "SONAME" }, - { DT_RPATH , "RPATH" }, - { DT_SYMBOLIC , "SYMBOLIC" }, - { DT_REL , "REL" }, - { DT_RELSZ , "RELSZ" }, - { DT_RELENT , "RELENT" }, - { DT_PLTREL , "PLTREL" }, - { DT_DEBUG , "DEBUG" }, - { DT_TEXTREL , "TEXTREL" }, - { DT_JMPREL , "JMPREL" }, - { DT_BIND_NOW , "BIND_NOW" }, - { DT_INIT_ARRAY , "INIT_ARRAY" }, - { DT_FINI_ARRAY , "FINI_ARRAY" }, - { DT_INIT_ARRAYSZ , "INIT_ARRAYSZ" }, - { DT_FINI_ARRAYSZ , "FINI_ARRAYSZ" }, - { DT_RUNPATH , "RUNPATH" }, - { DT_FLAGS , "FLAGS" }, - { DT_ENCODING , "ENCODING" }, - { DT_PREINIT_ARRAY , "PREINIT_ARRAY" }, - { DT_PREINIT_ARRAYSZ, "PREINIT_ARRAYSZ" }, - { DT_MAXPOSTAGS , "MAXPOSTAGS" }, -}; - -static const ELFIO::Elf_Xword MAX_DATA_ENTRIES = 64; - -//------------------------------------------------------------------------------ -class dump -{ -#define DUMP_DEC_FORMAT( width ) std::setw(width) << std::setfill( ' ' ) << \ - std::dec << std::right -#define DUMP_HEX_FORMAT( width ) std::setw(width) << std::setfill( '0' ) << \ - std::hex << std::right -#define DUMP_STR_FORMAT( width ) std::setw(width) << std::setfill( ' ' ) << \ - std::hex << std::left - - public: -//------------------------------------------------------------------------------ - static void - header( std::ostream& out, const elfio& reader ) - { - if (!reader.get_header_size()) - { - return; - } - out << "ELF Header" << std::endl << std::endl - << " Class: " << str_class( reader.get_class() ) << std::endl - << " Encoding: " << str_endian( reader.get_encoding() ) << std::endl - << " ELFVersion: " << str_version( reader.get_elf_version() ) << std::endl - << " Type: " << str_type( reader.get_type() ) << std::endl - << " Machine: " << str_machine( reader.get_machine() ) << std::endl - << " Version: " << str_version( reader.get_version() ) << std::endl - << " Entry: " << "0x" << std::hex << reader.get_entry() << std::endl - << " Flags: " << "0x" << std::hex << reader.get_flags() << std::endl - << std::endl; - } - -//------------------------------------------------------------------------------ - static void - section_headers( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.sections.size(); - - if ( n == 0 ) { - return; - } - - out << "Section Headers:" << std::endl; - if ( reader.get_class() == ELFCLASS32 ) { // Output for 32-bit - out << "[ Nr ] Type Addr Size ES Flg Lk Inf Al Name" << std::endl; - } - else { // Output for 64-bit - out << "[ Nr ] Type Addr Size ES Flg" << std::endl - << " Lk Inf Al Name" << std::endl; - } - - for ( Elf_Half i = 0; i < n; ++i ) { // For all sections - section* sec = reader.sections[i]; - section_header( out, i, sec, reader.get_class() ); - } - - out << "Key to Flags: W (write), A (alloc), X (execute)\n\n" - << std::endl; - } - -//------------------------------------------------------------------------------ - static void - section_header( std::ostream& out, Elf_Half no, const section* sec, - unsigned char elf_class ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - if ( elf_class == ELFCLASS32 ) { // Output for 32-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 17 ) << str_section_type( sec->get_type() ) << " " - << DUMP_HEX_FORMAT( 8 ) << sec->get_address() << " " - << DUMP_HEX_FORMAT( 8 ) << sec->get_size() << " " - << DUMP_HEX_FORMAT( 2 ) << sec->get_entry_size() << " " - << DUMP_STR_FORMAT( 3 ) << section_flags( sec->get_flags() ) << " " - << DUMP_HEX_FORMAT( 2 ) << sec->get_link() << " " - << DUMP_HEX_FORMAT( 3 ) << sec->get_info() << " " - << DUMP_HEX_FORMAT( 2 ) << sec->get_addr_align() << " " - << DUMP_STR_FORMAT( 17 ) << sec->get_name() << " " - << std::endl; - } - else { // Output for 64-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 17 ) << str_section_type( sec->get_type() ) << " " - << DUMP_HEX_FORMAT( 16 ) << sec->get_address() << " " - << DUMP_HEX_FORMAT( 16 ) << sec->get_size() << " " - << DUMP_HEX_FORMAT( 4 ) << sec->get_entry_size() << " " - << DUMP_STR_FORMAT( 3 ) << section_flags( sec->get_flags() ) << " " - << std::endl - << " " - << DUMP_HEX_FORMAT( 4 ) << sec->get_link() << " " - << DUMP_HEX_FORMAT( 4 ) << sec->get_info() << " " - << DUMP_HEX_FORMAT( 4 ) << sec->get_addr_align() << " " - << DUMP_STR_FORMAT( 17 ) << sec->get_name() << " " - << std::endl; - } - - out.flags(original_flags); - - return; - } - -//------------------------------------------------------------------------------ - static void - segment_headers( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.segments.size(); - if ( n == 0 ) { - return; - } - - out << "Segment headers:" << std::endl; - if ( reader.get_class() == ELFCLASS32 ) { // Output for 32-bit - out << "[ Nr ] Type VirtAddr PhysAddr FileSize Mem.Size Flags Align" - << std::endl; - } - else { // Output for 64-bit - out << "[ Nr ] Type VirtAddr PhysAddr Flags" << std::endl - << " FileSize Mem.Size Align" - << std::endl; - } - - for ( Elf_Half i = 0; i < n; ++i ) { - segment* seg = reader.segments[i]; - segment_header( out, i, seg, reader.get_class() ); - } - - out << std::endl; - } - -//------------------------------------------------------------------------------ - static void - segment_header( std::ostream& out, Elf_Half no, const segment* seg, - unsigned int elf_class ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - if ( elf_class == ELFCLASS32 ) { // Output for 32-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 14 ) << str_segment_type( seg->get_type() ) << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_virtual_address() << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_physical_address() << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_file_size() << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_memory_size() << " " - << DUMP_STR_FORMAT( 8 ) << str_segment_flag( seg->get_flags() ) << " " - << DUMP_HEX_FORMAT( 8 ) << seg->get_align() << " " - << std::endl; - } - else { // Output for 64-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 14 ) << str_segment_type( seg->get_type() ) << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_virtual_address() << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_physical_address() << " " - << DUMP_STR_FORMAT( 16 ) << str_segment_flag( seg->get_flags() ) << " " - << std::endl - << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_file_size() << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_memory_size() << " " - << DUMP_HEX_FORMAT( 16 ) << seg->get_align() << " " - << std::endl; - } - - out.flags(original_flags); - } - -//------------------------------------------------------------------------------ - static void - symbol_tables( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.sections.size(); - for ( Elf_Half i = 0; i < n; ++i ) { // For all sections - section* sec = reader.sections[i]; - if ( SHT_SYMTAB == sec->get_type() || SHT_DYNSYM == sec->get_type() ) { - symbol_section_accessor symbols( reader, sec ); - - Elf_Xword sym_no = symbols.get_symbols_num(); - if ( sym_no > 0 ) { - out << "Symbol table (" << sec->get_name() << ")" << std::endl; - if ( reader.get_class() == ELFCLASS32 ) { // Output for 32-bit - out << "[ Nr ] Value Size Type Bind Sect Name" - << std::endl; - } - else { // Output for 64-bit - out << "[ Nr ] Value Size Type Bind Sect" << std::endl - << " Name" - << std::endl; - } - for ( Elf_Half i = 0; i < sym_no; ++i ) { - std::string name; - Elf64_Addr value = 0; - Elf_Xword size = 0; - unsigned char bind = 0; - unsigned char type = 0; - Elf_Half section = 0; - unsigned char other = 0; - symbols.get_symbol( i, name, value, size, bind, type, section, other ); - symbol_table( out, i, name, value, size, bind, type, section, reader.get_class() ); - } - - out << std::endl; - } - } - } - } - -//------------------------------------------------------------------------------ - static void - symbol_table( std::ostream& out, - Elf_Half no, - std::string& name, - Elf64_Addr value, - Elf_Xword size, - unsigned char bind, - unsigned char type, - Elf_Half section, - unsigned int elf_class ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - if ( elf_class == ELFCLASS32 ) { // Output for 32-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_HEX_FORMAT( 8 ) << value << " " - << DUMP_HEX_FORMAT( 8 ) << size << " " - << DUMP_STR_FORMAT( 7 ) << str_symbol_type( type ) << " " - << DUMP_STR_FORMAT( 8 ) << str_symbol_bind( bind ) << " " - << DUMP_DEC_FORMAT( 5 ) << section << " " - << DUMP_STR_FORMAT( 1 ) << name << " " - << std::endl; - } - else { // Output for 64-bit - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_HEX_FORMAT( 16 ) << value << " " - << DUMP_HEX_FORMAT( 16 ) << size << " " - << DUMP_STR_FORMAT( 7 ) << str_symbol_type( type ) << " " - << DUMP_STR_FORMAT( 8 ) << str_symbol_bind( bind ) << " " - << DUMP_DEC_FORMAT( 5 ) << section << " " - << std::endl - << " " - << DUMP_STR_FORMAT( 1 ) << name << " " - << std::endl; - } - - out.flags(original_flags); - } - -//------------------------------------------------------------------------------ - static void - notes( std::ostream& out, const elfio& reader ) - { - Elf_Half no = reader.sections.size(); - for ( Elf_Half i = 0; i < no; ++i ) { // For all sections - section* sec = reader.sections[i]; - if ( SHT_NOTE == sec->get_type() ) { // Look at notes - note_section_accessor notes( reader, sec ); - int no_notes = notes.get_notes_num(); - if ( no > 0 ) { - out << "Note section (" << sec->get_name() << ")" << std::endl - << " No Type Name" - << std::endl; - for ( int j = 0; j < no_notes; ++j ) { // For all notes - Elf_Word type; - std::string name; - void* desc; - Elf_Word descsz; - - if ( notes.get_note(j, type, name, desc, descsz) ) { - // 'name' usually contains \0 at the end. Try to fix it - name = name.c_str(); - note( out, j, type, name ); - } - } - - out << std::endl; - } - } - } - } - -//------------------------------------------------------------------------------ - static void - note( std::ostream& out, - int no, - Elf_Word type, - const std::string& name ) - { - out << " [" - << DUMP_DEC_FORMAT( 2 ) << no - << "] " - << DUMP_HEX_FORMAT( 8 ) << type << " " - << DUMP_STR_FORMAT( 1 ) << name - << std::endl; - } - -//------------------------------------------------------------------------------ - static void - dynamic_tags( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.sections.size(); - for ( Elf_Half i = 0; i < n; ++i ) { // For all sections - section* sec = reader.sections[i]; - if ( SHT_DYNAMIC == sec->get_type() ) { - dynamic_section_accessor dynamic( reader, sec ); - - Elf_Xword dyn_no = dynamic.get_entries_num(); - if ( dyn_no > 0 ) { - out << "Dynamic section (" << sec->get_name() << ")" << std::endl; - out << "[ Nr ] Tag Name/Value" << std::endl; - for ( Elf_Xword i = 0; i < dyn_no; ++i ) { - Elf_Xword tag = 0; - Elf_Xword value = 0; - std::string str; - dynamic.get_entry( i, tag, value, str ); - dynamic_tag( out, i, tag, value, str, reader.get_class() ); - if ( DT_NULL == tag ) { - break; - } - } - - out << std::endl; - } - } - } - } - -//------------------------------------------------------------------------------ - static void - dynamic_tag( std::ostream& out, - Elf_Xword no, - Elf_Xword tag, - Elf_Xword value, - std::string str, - unsigned int /*elf_class*/ ) - { - out << "[" - << DUMP_DEC_FORMAT( 5 ) << no - << "] " - << DUMP_STR_FORMAT( 16 ) << str_dynamic_tag( tag ) << " "; - if ( str.empty() ) { - out << DUMP_HEX_FORMAT( 16 ) << value << " "; - } - else { - out << DUMP_STR_FORMAT( 32 ) << str << " "; - } - out << std::endl; - } - -//------------------------------------------------------------------------------ - static void - section_data( std::ostream& out, const section* sec ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - out << sec->get_name() << std::endl; - const char* pdata = sec->get_data(); - if ( pdata ){ - ELFIO::Elf_Xword i; - for ( i = 0; i < std::min( sec->get_size(), MAX_DATA_ENTRIES ); ++i ) { - if ( i % 16 == 0 ) { - out << "[" << DUMP_HEX_FORMAT( 8 ) << i << "]"; - } - - out << " " << DUMP_HEX_FORMAT( 2 ) << ( pdata[i] & 0x000000FF ); - - if ( i % 16 == 15 ) { - out << std::endl; - } - } - if ( i % 16 != 0 ) { - out << std::endl; - } - - out.flags(original_flags); - } - - return; - } - -//------------------------------------------------------------------------------ - static void - section_datas( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.sections.size(); - - if ( n == 0 ) { - return; - } - - out << "Section Data:" << std::endl; - - for ( Elf_Half i = 1; i < n; ++i ) { // For all sections - section* sec = reader.sections[i]; - if ( sec->get_type() == SHT_NOBITS ) { - continue; - } - section_data( out, sec ); - } - - out << std::endl; - } - -//------------------------------------------------------------------------------ - static void - segment_data( std::ostream& out, Elf_Half no, const segment* seg ) - { - std::ios_base::fmtflags original_flags = out.flags(); - - out << "Segment # " << no << std::endl; - const char* pdata = seg->get_data(); - if ( pdata ) { - ELFIO::Elf_Xword i; - for ( i = 0; i < std::min( seg->get_file_size(), MAX_DATA_ENTRIES ); ++i ) { - if ( i % 16 == 0 ) { - out << "[" << DUMP_HEX_FORMAT( 8 ) << i << "]"; - } - - out << " " << DUMP_HEX_FORMAT( 2 ) << ( pdata[i] & 0x000000FF ); - - if ( i % 16 == 15 ) { - out << std::endl; - } - } - if ( i % 16 != 0 ) { - out << std::endl; - } - - out.flags(original_flags); - } - - return; - } - -//------------------------------------------------------------------------------ - static void - segment_datas( std::ostream& out, const elfio& reader ) - { - Elf_Half n = reader.segments.size(); - - if ( n == 0 ) { - return; - } - - out << "Segment Data:" << std::endl; - - for ( Elf_Half i = 0; i < n; ++i ) { // For all sections - segment* seg = reader.segments[i]; - segment_data( out, i, seg ); - } - - out << std::endl; - } - - private: -//------------------------------------------------------------------------------ - template< typename T, typename K > - std::string - static - find_value_in_table( const T& table, const K& key ) - { - std::string res = "?"; - for ( unsigned int i = 0; i < sizeof( table )/sizeof( table[0] ); ++i ) { - if ( table[i].key == key ) { - res = table[i].str; - break; - } - } - - return res; - } - - -//------------------------------------------------------------------------------ - template< typename T, typename K > - static - std::string - format_assoc( const T& table, const K& key ) - { - std::string str = find_value_in_table( table, key ); - if ( str == "?" ) { - std::ostringstream oss; - oss << str << " (0x" << std::hex << key << ")"; - str = oss.str(); - } - - return str; - } - - -//------------------------------------------------------------------------------ - template< typename T > - static - std::string - format_assoc( const T& table, const char key ) - { - return format_assoc( table, (const int)key ); - } - - -//------------------------------------------------------------------------------ - static - std::string - section_flags( Elf_Xword flags ) - { - std::string ret = ""; - if ( flags & SHF_WRITE ) { - ret += "W"; - } - if ( flags & SHF_ALLOC ) { - ret += "A"; - } - if ( flags & SHF_EXECINSTR ) { - ret += "X"; - } - - return ret; - } - - -//------------------------------------------------------------------------------ -#define STR_FUNC_TABLE( name ) \ - template< typename T > \ - static \ - std::string \ - str_##name( const T key ) \ - { \ - return format_assoc( name##_table, key ); \ - } - - STR_FUNC_TABLE( class ) - STR_FUNC_TABLE( endian ) - STR_FUNC_TABLE( version ) - STR_FUNC_TABLE( type ) - STR_FUNC_TABLE( machine ) - STR_FUNC_TABLE( section_type ) - STR_FUNC_TABLE( segment_type ) - STR_FUNC_TABLE( segment_flag ) - STR_FUNC_TABLE( symbol_bind ) - STR_FUNC_TABLE( symbol_type ) - STR_FUNC_TABLE( dynamic_tag ) - -#undef STR_FUNC_TABLE -#undef DUMP_DEC_FORMAT -#undef DUMP_HEX_FORMAT -#undef DUMP_STR_FORMAT -}; // class dump - - -}; // namespace ELFIO - -#endif // ELFIO_DUMP_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_dynamic.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_dynamic.hpp deleted file mode 100644 index 42f26805b..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_dynamic.hpp +++ /dev/null @@ -1,257 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_DYNAMIC_HPP -#define ELFIO_DYNAMIC_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -template< class S > -class dynamic_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - dynamic_section_accessor_template( const elfio& elf_file_, S* section_ ) : - elf_file( elf_file_ ), - dynamic_section( section_ ) - { - } - -//------------------------------------------------------------------------------ - Elf_Xword - get_entries_num() const - { - Elf_Xword nRet = 0; - - if ( 0 != dynamic_section->get_entry_size() ) { - nRet = dynamic_section->get_size() / dynamic_section->get_entry_size(); - } - - return nRet; - } - -//------------------------------------------------------------------------------ - bool - get_entry( Elf_Xword index, - Elf_Xword& tag, - Elf_Xword& value, - std::string& str ) const - { - if ( index >= get_entries_num() ) { // Is index valid - return false; - } - - if ( elf_file.get_class() == ELFCLASS32 ) { - generic_get_entry_dyn< Elf32_Dyn >( index, tag, value ); - } - else { - generic_get_entry_dyn< Elf64_Dyn >( index, tag, value ); - } - - // If the tag may have a string table reference, prepare the string - if ( tag == DT_NEEDED || - tag == DT_SONAME || - tag == DT_RPATH || - tag == DT_RUNPATH ) { - string_section_accessor strsec = - elf_file.sections[ get_string_table_index() ]; - const char* result = strsec.get_string( value ); - if ( 0 == result ) { - str.clear(); - return false; - } - str = result; - } - else { - str.clear(); - } - - return true; - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf_Xword tag, - Elf_Xword value ) - { - if ( elf_file.get_class() == ELFCLASS32 ) { - generic_add_entry< Elf32_Dyn >( tag, value ); - } - else { - generic_add_entry< Elf64_Dyn >( tag, value ); - } - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf_Xword tag, - const std::string& str ) - { - string_section_accessor strsec = - elf_file.sections[ get_string_table_index() ]; - Elf_Xword value = strsec.add_string( str ); - add_entry( tag, value ); - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - Elf_Half - get_string_table_index() const - { - return (Elf_Half)dynamic_section->get_link(); - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_get_entry_dyn( Elf_Xword index, - Elf_Xword& tag, - Elf_Xword& value ) const - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - // Check unusual case when dynamic section has no data - if( dynamic_section->get_data() == 0 || - ( index + 1 ) * dynamic_section->get_entry_size() > dynamic_section->get_size() ) { - tag = DT_NULL; - value = 0; - return; - } - - const T* pEntry = reinterpret_cast( - dynamic_section->get_data() + - index * dynamic_section->get_entry_size() ); - tag = convertor( pEntry->d_tag ); - switch ( tag ) { - case DT_NULL: - case DT_SYMBOLIC: - case DT_TEXTREL: - case DT_BIND_NOW: - value = 0; - break; - case DT_NEEDED: - case DT_PLTRELSZ: - case DT_RELASZ: - case DT_RELAENT: - case DT_STRSZ: - case DT_SYMENT: - case DT_SONAME: - case DT_RPATH: - case DT_RELSZ: - case DT_RELENT: - case DT_PLTREL: - case DT_INIT_ARRAYSZ: - case DT_FINI_ARRAYSZ: - case DT_RUNPATH: - case DT_FLAGS: - case DT_PREINIT_ARRAYSZ: - value = convertor( pEntry->d_un.d_val ); - break; - case DT_PLTGOT: - case DT_HASH: - case DT_STRTAB: - case DT_SYMTAB: - case DT_RELA: - case DT_INIT: - case DT_FINI: - case DT_REL: - case DT_DEBUG: - case DT_JMPREL: - case DT_INIT_ARRAY: - case DT_FINI_ARRAY: - case DT_PREINIT_ARRAY: - default: - value = convertor( pEntry->d_un.d_ptr ); - break; - } - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_add_entry( Elf_Xword tag, Elf_Xword value ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - - switch ( tag ) { - case DT_NULL: - case DT_SYMBOLIC: - case DT_TEXTREL: - case DT_BIND_NOW: - value = 0; - case DT_NEEDED: - case DT_PLTRELSZ: - case DT_RELASZ: - case DT_RELAENT: - case DT_STRSZ: - case DT_SYMENT: - case DT_SONAME: - case DT_RPATH: - case DT_RELSZ: - case DT_RELENT: - case DT_PLTREL: - case DT_INIT_ARRAYSZ: - case DT_FINI_ARRAYSZ: - case DT_RUNPATH: - case DT_FLAGS: - case DT_PREINIT_ARRAYSZ: - entry.d_un.d_val = convertor( value ); - break; - case DT_PLTGOT: - case DT_HASH: - case DT_STRTAB: - case DT_SYMTAB: - case DT_RELA: - case DT_INIT: - case DT_FINI: - case DT_REL: - case DT_DEBUG: - case DT_JMPREL: - case DT_INIT_ARRAY: - case DT_FINI_ARRAY: - case DT_PREINIT_ARRAY: - default: - entry.d_un.d_ptr = convertor( value ); - break; - } - - entry.d_tag = convertor( tag ); - - dynamic_section->append_data( reinterpret_cast( &entry ), sizeof( entry ) ); - } - -//------------------------------------------------------------------------------ - private: - const elfio& elf_file; - S* dynamic_section; -}; - -using dynamic_section_accessor = dynamic_section_accessor_template
; -using const_dynamic_section_accessor = dynamic_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_DYNAMIC_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_header.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_header.hpp deleted file mode 100644 index 6f8da0285..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_header.hpp +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELF_HEADER_HPP -#define ELF_HEADER_HPP - -#include - -namespace ELFIO { - -class elf_header -{ - public: - virtual ~elf_header() {}; - virtual bool load( std::istream& stream ) = 0; - virtual bool save( std::ostream& stream ) const = 0; - - // ELF header functions - ELFIO_GET_ACCESS_DECL( unsigned char, class ); - ELFIO_GET_ACCESS_DECL( unsigned char, elf_version ); - ELFIO_GET_ACCESS_DECL( unsigned char, encoding ); - ELFIO_GET_ACCESS_DECL( Elf_Half, header_size ); - ELFIO_GET_ACCESS_DECL( Elf_Half, section_entry_size ); - ELFIO_GET_ACCESS_DECL( Elf_Half, segment_entry_size ); - - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, version ); - ELFIO_GET_SET_ACCESS_DECL( unsigned char, os_abi ); - ELFIO_GET_SET_ACCESS_DECL( unsigned char, abi_version ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, type ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, machine ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, flags ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Addr, entry ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, sections_num ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Off, sections_offset ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, segments_num ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Off, segments_offset ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Half, section_name_str_index ); -}; - - -template< class T > struct elf_header_impl_types; -template<> struct elf_header_impl_types { - typedef Elf32_Phdr Phdr_type; - typedef Elf32_Shdr Shdr_type; - static const unsigned char file_class = ELFCLASS32; -}; -template<> struct elf_header_impl_types { - typedef Elf64_Phdr Phdr_type; - typedef Elf64_Shdr Shdr_type; - static const unsigned char file_class = ELFCLASS64; -}; - -template< class T > class elf_header_impl : public elf_header -{ - public: - elf_header_impl( endianess_convertor* convertor_, - unsigned char encoding ) - { - convertor = convertor_; - - std::fill_n( reinterpret_cast( &header ), sizeof( header ), '\0' ); - - header.e_ident[EI_MAG0] = ELFMAG0; - header.e_ident[EI_MAG1] = ELFMAG1; - header.e_ident[EI_MAG2] = ELFMAG2; - header.e_ident[EI_MAG3] = ELFMAG3; - header.e_ident[EI_CLASS] = elf_header_impl_types::file_class; - header.e_ident[EI_DATA] = encoding; - header.e_ident[EI_VERSION] = EV_CURRENT; - header.e_version = (*convertor)( (Elf_Word)EV_CURRENT ); - header.e_ehsize = ( sizeof( header ) ); - header.e_ehsize = (*convertor)( header.e_ehsize ); - header.e_shstrndx = (*convertor)( (Elf_Half)1 ); - header.e_phentsize = sizeof( typename elf_header_impl_types::Phdr_type ); - header.e_shentsize = sizeof( typename elf_header_impl_types::Shdr_type ); - header.e_phentsize = (*convertor)( header.e_phentsize ); - header.e_shentsize = (*convertor)( header.e_shentsize ); - } - - bool - load( std::istream& stream ) - { - stream.seekg( 0 ); - stream.read( reinterpret_cast( &header ), sizeof( header ) ); - - return (stream.gcount() == sizeof( header ) ); - } - - bool - save( std::ostream& stream ) const - { - stream.seekp( 0 ); - stream.write( reinterpret_cast( &header ), sizeof( header ) ); - - return stream.good(); - } - - // ELF header functions - ELFIO_GET_ACCESS( unsigned char, class, header.e_ident[EI_CLASS] ); - ELFIO_GET_ACCESS( unsigned char, elf_version, header.e_ident[EI_VERSION] ); - ELFIO_GET_ACCESS( unsigned char, encoding, header.e_ident[EI_DATA] ); - ELFIO_GET_ACCESS( Elf_Half, header_size, header.e_ehsize ); - ELFIO_GET_ACCESS( Elf_Half, section_entry_size, header.e_shentsize ); - ELFIO_GET_ACCESS( Elf_Half, segment_entry_size, header.e_phentsize ); - - ELFIO_GET_SET_ACCESS( Elf_Word, version, header.e_version); - ELFIO_GET_SET_ACCESS( unsigned char, os_abi, header.e_ident[EI_OSABI] ); - ELFIO_GET_SET_ACCESS( unsigned char, abi_version, header.e_ident[EI_ABIVERSION] ); - ELFIO_GET_SET_ACCESS( Elf_Half, type, header.e_type ); - ELFIO_GET_SET_ACCESS( Elf_Half, machine, header.e_machine ); - ELFIO_GET_SET_ACCESS( Elf_Word, flags, header.e_flags ); - ELFIO_GET_SET_ACCESS( Elf_Half, section_name_str_index, header.e_shstrndx ); - ELFIO_GET_SET_ACCESS( Elf64_Addr, entry, header.e_entry ); - ELFIO_GET_SET_ACCESS( Elf_Half, sections_num, header.e_shnum ); - ELFIO_GET_SET_ACCESS( Elf64_Off, sections_offset, header.e_shoff ); - ELFIO_GET_SET_ACCESS( Elf_Half, segments_num, header.e_phnum ); - ELFIO_GET_SET_ACCESS( Elf64_Off, segments_offset, header.e_phoff ); - - private: - T header; - endianess_convertor* convertor; -}; - -} // namespace ELFIO - -#endif // ELF_HEADER_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_note.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_note.hpp deleted file mode 100644 index 8619c7385..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_note.hpp +++ /dev/null @@ -1,170 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_NOTE_HPP -#define ELFIO_NOTE_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -// There are discrepancies in documentations. SCO documentation -// (http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section) -// requires 8 byte entries alignment for 64-bit ELF file, -// but Oracle's definition uses the same structure -// for 32-bit and 64-bit formats. -// (https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html) -// -// It looks like EM_X86_64 Linux implementation is similar to Oracle's -// definition. Therefore, the same alignment works for both formats -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -template< class S > -class note_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - note_section_accessor_template( const elfio& elf_file_, S* section_ ) : - elf_file( elf_file_ ), note_section( section_ ) - { - process_section(); - } - -//------------------------------------------------------------------------------ - Elf_Word - get_notes_num() const - { - return (Elf_Word)note_start_positions.size(); - } - -//------------------------------------------------------------------------------ - bool - get_note( Elf_Word index, - Elf_Word& type, - std::string& name, - void*& desc, - Elf_Word& descSize ) const - { - if ( index >= note_section->get_size() ) { - return false; - } - - const char* pData = note_section->get_data() + note_start_positions[index]; - int align = sizeof( Elf_Word ); - - const endianess_convertor& convertor = elf_file.get_convertor(); - type = convertor( *(const Elf_Word*)( pData + 2*align ) ); - Elf_Word namesz = convertor( *(const Elf_Word*)( pData ) ); - descSize = convertor( *(const Elf_Word*)( pData + sizeof( namesz ) ) ); - Elf_Xword max_name_size = note_section->get_size() - note_start_positions[index]; - if ( namesz > max_name_size || - namesz + descSize > max_name_size ) { - return false; - } - name.assign( pData + 3*align, namesz - 1); - if ( 0 == descSize ) { - desc = 0; - } - else { - desc = const_cast ( pData + 3*align + - ( ( namesz + align - 1 )/align )*align ); - } - - return true; - } - -//------------------------------------------------------------------------------ - void add_note( Elf_Word type, - const std::string& name, - const void* desc, - Elf_Word descSize ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - int align = sizeof( Elf_Word ); - Elf_Word nameLen = (Elf_Word)name.size() + 1; - Elf_Word nameLenConv = convertor( nameLen ); - std::string buffer( reinterpret_cast( &nameLenConv ), align ); - Elf_Word descSizeConv = convertor( descSize ); - buffer.append( reinterpret_cast( &descSizeConv ), align ); - type = convertor( type ); - buffer.append( reinterpret_cast( &type ), align ); - buffer.append( name ); - buffer.append( 1, '\x00' ); - const char pad[] = { '\0', '\0', '\0', '\0' }; - if ( nameLen % align != 0 ) { - buffer.append( pad, align - nameLen % align ); - } - if ( desc != 0 && descSize != 0 ) { - buffer.append( reinterpret_cast( desc ), descSize ); - if ( descSize % align != 0 ) { - buffer.append( pad, align - descSize % align ); - } - } - - note_start_positions.push_back( note_section->get_size() ); - note_section->append_data( buffer ); - } - - private: -//------------------------------------------------------------------------------ - void process_section() - { - const endianess_convertor& convertor = elf_file.get_convertor(); - const char* data = note_section->get_data(); - Elf_Xword size = note_section->get_size(); - Elf_Xword current = 0; - - note_start_positions.clear(); - - // Is it empty? - if ( 0 == data || 0 == size ) { - return; - } - - int align = sizeof( Elf_Word ); - while ( current + 3*align <= size ) { - note_start_positions.push_back( current ); - Elf_Word namesz = convertor( - *(const Elf_Word*)( data + current ) ); - Elf_Word descsz = convertor( - *(const Elf_Word*)( data + current + sizeof( namesz ) ) ); - - current += 3*sizeof( Elf_Word ) + - ( ( namesz + align - 1 ) / align ) * align + - ( ( descsz + align - 1 ) / align ) * align; - } - } - -//------------------------------------------------------------------------------ - private: - const elfio& elf_file; - S* note_section; - std::vector note_start_positions; -}; - -using note_section_accessor = note_section_accessor_template
; -using const_note_section_accessor = note_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_NOTE_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_relocation.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_relocation.hpp deleted file mode 100644 index 238598e97..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_relocation.hpp +++ /dev/null @@ -1,373 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_RELOCATION_HPP -#define ELFIO_RELOCATION_HPP - -namespace ELFIO { - -template struct get_sym_and_type; -template<> struct get_sym_and_type< Elf32_Rel > -{ - static int get_r_sym( Elf_Xword info ) - { - return ELF32_R_SYM( (Elf_Word)info ); - } - static int get_r_type( Elf_Xword info ) - { - return ELF32_R_TYPE( (Elf_Word)info ); - } -}; -template<> struct get_sym_and_type< Elf32_Rela > -{ - static int get_r_sym( Elf_Xword info ) - { - return ELF32_R_SYM( (Elf_Word)info ); - } - static int get_r_type( Elf_Xword info ) - { - return ELF32_R_TYPE( (Elf_Word)info ); - } -}; -template<> struct get_sym_and_type< Elf64_Rel > -{ - static int get_r_sym( Elf_Xword info ) - { - return ELF64_R_SYM( info ); - } - static int get_r_type( Elf_Xword info ) - { - return ELF64_R_TYPE( info ); - } -}; -template<> struct get_sym_and_type< Elf64_Rela > -{ - static int get_r_sym( Elf_Xword info ) - { - return ELF64_R_SYM( info ); - } - static int get_r_type( Elf_Xword info ) - { - return ELF64_R_TYPE( info ); - } -}; - - -//------------------------------------------------------------------------------ -template< class S > -class relocation_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - relocation_section_accessor_template( const elfio& elf_file_, S* section_ ) : - elf_file( elf_file_ ), - relocation_section( section_ ) - { - } - -//------------------------------------------------------------------------------ - Elf_Xword - get_entries_num() const - { - Elf_Xword nRet = 0; - - if ( 0 != relocation_section->get_entry_size() ) { - nRet = relocation_section->get_size() / relocation_section->get_entry_size(); - } - - return nRet; - } - -//------------------------------------------------------------------------------ - bool - get_entry( Elf_Xword index, - Elf64_Addr& offset, - Elf_Word& symbol, - Elf_Word& type, - Elf_Sxword& addend ) const - { - if ( index >= get_entries_num() ) { // Is index valid - return false; - } - - if ( elf_file.get_class() == ELFCLASS32 ) { - if ( SHT_REL == relocation_section->get_type() ) { - generic_get_entry_rel< Elf32_Rel >( index, offset, symbol, - type, addend ); - } - else if ( SHT_RELA == relocation_section->get_type() ) { - generic_get_entry_rela< Elf32_Rela >( index, offset, symbol, - type, addend ); - } - } - else { - if ( SHT_REL == relocation_section->get_type() ) { - generic_get_entry_rel< Elf64_Rel >( index, offset, symbol, - type, addend ); - } - else if ( SHT_RELA == relocation_section->get_type() ) { - generic_get_entry_rela< Elf64_Rela >( index, offset, symbol, - type, addend ); - } - } - - return true; - } - -//------------------------------------------------------------------------------ - bool - get_entry( Elf_Xword index, - Elf64_Addr& offset, - Elf64_Addr& symbolValue, - std::string& symbolName, - Elf_Word& type, - Elf_Sxword& addend, - Elf_Sxword& calcValue ) const - { - // Do regular job - Elf_Word symbol; - bool ret = get_entry( index, offset, symbol, type, addend ); - - // Find the symbol - Elf_Xword size; - unsigned char bind; - unsigned char symbolType; - Elf_Half section; - unsigned char other; - - symbol_section_accessor symbols( elf_file, elf_file.sections[get_symbol_table_index()] ); - ret = ret && symbols.get_symbol( symbol, symbolName, symbolValue, - size, bind, symbolType, section, other ); - - if ( ret ) { // Was it successful? - switch ( type ) { - case R_386_NONE: // none - calcValue = 0; - break; - case R_386_32: // S + A - calcValue = symbolValue + addend; - break; - case R_386_PC32: // S + A - P - calcValue = symbolValue + addend - offset; - break; - case R_386_GOT32: // G + A - P - calcValue = 0; - break; - case R_386_PLT32: // L + A - P - calcValue = 0; - break; - case R_386_COPY: // none - calcValue = 0; - break; - case R_386_GLOB_DAT: // S - case R_386_JMP_SLOT: // S - calcValue = symbolValue; - break; - case R_386_RELATIVE: // B + A - calcValue = addend; - break; - case R_386_GOTOFF: // S + A - GOT - calcValue = 0; - break; - case R_386_GOTPC: // GOT + A - P - calcValue = 0; - break; - default: // Not recognized symbol! - calcValue = 0; - break; - } - } - - return ret; - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf64_Addr offset, Elf_Xword info ) - { - if ( elf_file.get_class() == ELFCLASS32 ) { - generic_add_entry< Elf32_Rel >( offset, info ); - } - else { - generic_add_entry< Elf64_Rel >( offset, info ); - } - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf64_Addr offset, Elf_Word symbol, unsigned char type ) - { - Elf_Xword info; - if ( elf_file.get_class() == ELFCLASS32 ) { - info = ELF32_R_INFO( (Elf_Xword)symbol, type ); - } - else { - info = ELF64_R_INFO((Elf_Xword)symbol, type ); - } - - add_entry( offset, info ); - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf64_Addr offset, Elf_Xword info, Elf_Sxword addend ) - { - if ( elf_file.get_class() == ELFCLASS32 ) { - generic_add_entry< Elf32_Rela >( offset, info, addend ); - } - else { - generic_add_entry< Elf64_Rela >( offset, info, addend ); - } - } - -//------------------------------------------------------------------------------ - void - add_entry( Elf64_Addr offset, Elf_Word symbol, unsigned char type, - Elf_Sxword addend ) - { - Elf_Xword info; - if ( elf_file.get_class() == ELFCLASS32 ) { - info = ELF32_R_INFO( (Elf_Xword)symbol, type ); - } - else { - info = ELF64_R_INFO( (Elf_Xword)symbol, type ); - } - - add_entry( offset, info, addend ); - } - -//------------------------------------------------------------------------------ - void - add_entry( string_section_accessor str_writer, - const char* str, - symbol_section_accessor sym_writer, - Elf64_Addr value, - Elf_Word size, - unsigned char sym_info, - unsigned char other, - Elf_Half shndx, - Elf64_Addr offset, - unsigned char type ) - { - Elf_Word str_index = str_writer.add_string( str ); - Elf_Word sym_index = sym_writer.add_symbol( str_index, value, size, - sym_info, other, shndx ); - add_entry( offset, sym_index, type ); - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - Elf_Half - get_symbol_table_index() const - { - return (Elf_Half)relocation_section->get_link(); - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_get_entry_rel( Elf_Xword index, - Elf64_Addr& offset, - Elf_Word& symbol, - Elf_Word& type, - Elf_Sxword& addend ) const - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - const T* pEntry = reinterpret_cast( - relocation_section->get_data() + - index * relocation_section->get_entry_size() ); - offset = convertor( pEntry->r_offset ); - Elf_Xword tmp = convertor( pEntry->r_info ); - symbol = get_sym_and_type::get_r_sym( tmp ); - type = get_sym_and_type::get_r_type( tmp ); - addend = 0; - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_get_entry_rela( Elf_Xword index, - Elf64_Addr& offset, - Elf_Word& symbol, - Elf_Word& type, - Elf_Sxword& addend ) const - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - const T* pEntry = reinterpret_cast( - relocation_section->get_data() + - index * relocation_section->get_entry_size() ); - offset = convertor( pEntry->r_offset ); - Elf_Xword tmp = convertor( pEntry->r_info ); - symbol = get_sym_and_type::get_r_sym( tmp ); - type = get_sym_and_type::get_r_type( tmp ); - addend = convertor( pEntry->r_addend ); - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_add_entry( Elf64_Addr offset, Elf_Xword info ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.r_offset = offset; - entry.r_info = info; - entry.r_offset = convertor( entry.r_offset ); - entry.r_info = convertor( entry.r_info ); - - relocation_section->append_data( reinterpret_cast( &entry ), sizeof( entry ) ); - } - -//------------------------------------------------------------------------------ - template< class T > - void - generic_add_entry( Elf64_Addr offset, Elf_Xword info, Elf_Sxword addend ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.r_offset = offset; - entry.r_info = info; - entry.r_addend = addend; - entry.r_offset = convertor( entry.r_offset ); - entry.r_info = convertor( entry.r_info ); - entry.r_addend = convertor( entry.r_addend ); - - relocation_section->append_data( reinterpret_cast( &entry ), sizeof( entry ) ); - } - -//------------------------------------------------------------------------------ - private: - const elfio& elf_file; - S* relocation_section; -}; - -using relocation_section_accessor = relocation_section_accessor_template
; -using const_relocation_section_accessor = relocation_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_RELOCATION_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_section.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_section.hpp deleted file mode 100644 index 3bfc2333c..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_section.hpp +++ /dev/null @@ -1,314 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_SECTION_HPP -#define ELFIO_SECTION_HPP - -#include -#include - -namespace ELFIO { - -class section -{ - friend class elfio; - public: - virtual ~section() {}; - - ELFIO_GET_ACCESS_DECL ( Elf_Half, index ); - ELFIO_GET_SET_ACCESS_DECL( std::string, name ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, type ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, flags ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, info ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, link ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, addr_align ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, entry_size ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Addr, address ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, size ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, name_string_offset ); - ELFIO_GET_ACCESS_DECL ( Elf64_Off, offset ); - size_t stream_size; - size_t get_stream_size() const - { - return stream_size; - } - - void set_stream_size(size_t value) - { - stream_size = value; - } - - virtual const char* get_data() const = 0; - virtual void set_data( const char* pData, Elf_Word size ) = 0; - virtual void set_data( const std::string& data ) = 0; - virtual void append_data( const char* pData, Elf_Word size ) = 0; - virtual void append_data( const std::string& data ) = 0; - - protected: - ELFIO_SET_ACCESS_DECL( Elf64_Off, offset ); - ELFIO_SET_ACCESS_DECL( Elf_Half, index ); - - virtual void load( std::istream& stream, - std::streampos header_offset ) = 0; - virtual void save( std::ostream& stream, - std::streampos header_offset, - std::streampos data_offset ) = 0; - virtual bool is_address_initialized() const = 0; -}; - - -template< class T > -class section_impl : public section -{ - public: -//------------------------------------------------------------------------------ - section_impl( const endianess_convertor* convertor_ ) : convertor( convertor_ ) - { - std::fill_n( reinterpret_cast( &header ), sizeof( header ), '\0' ); - is_address_set = false; - data = 0; - data_size = 0; - } - -//------------------------------------------------------------------------------ - ~section_impl() - { - delete [] data; - } - -//------------------------------------------------------------------------------ - // Section info functions - ELFIO_GET_SET_ACCESS( Elf_Word, type, header.sh_type ); - ELFIO_GET_SET_ACCESS( Elf_Xword, flags, header.sh_flags ); - ELFIO_GET_SET_ACCESS( Elf_Xword, size, header.sh_size ); - ELFIO_GET_SET_ACCESS( Elf_Word, link, header.sh_link ); - ELFIO_GET_SET_ACCESS( Elf_Word, info, header.sh_info ); - ELFIO_GET_SET_ACCESS( Elf_Xword, addr_align, header.sh_addralign ); - ELFIO_GET_SET_ACCESS( Elf_Xword, entry_size, header.sh_entsize ); - ELFIO_GET_SET_ACCESS( Elf_Word, name_string_offset, header.sh_name ); - ELFIO_GET_ACCESS ( Elf64_Addr, address, header.sh_addr ); - -//------------------------------------------------------------------------------ - Elf_Half - get_index() const - { - return index; - } - - -//------------------------------------------------------------------------------ - std::string - get_name() const - { - return name; - } - -//------------------------------------------------------------------------------ - void - set_name( std::string name_ ) - { - name = name_; - } - -//------------------------------------------------------------------------------ - void - set_address( Elf64_Addr value ) - { - header.sh_addr = value; - header.sh_addr = (*convertor)( header.sh_addr ); - is_address_set = true; - } - -//------------------------------------------------------------------------------ - bool - is_address_initialized() const - { - return is_address_set; - } - -//------------------------------------------------------------------------------ - const char* - get_data() const - { - return data; - } - -//------------------------------------------------------------------------------ - void - set_data( const char* raw_data, Elf_Word size ) - { - if ( get_type() != SHT_NOBITS ) { - delete [] data; - try { - data = new char[size]; - } catch (const std::bad_alloc&) { - data = 0; - data_size = 0; - size = 0; - } - if ( 0 != data && 0 != raw_data ) { - data_size = size; - std::copy( raw_data, raw_data + size, data ); - } - } - - set_size( size ); - } - -//------------------------------------------------------------------------------ - void - set_data( const std::string& str_data ) - { - return set_data( str_data.c_str(), (Elf_Word)str_data.size() ); - } - -//------------------------------------------------------------------------------ - void - append_data( const char* raw_data, Elf_Word size ) - { - if ( get_type() != SHT_NOBITS ) { - if ( get_size() + size < data_size ) { - std::copy( raw_data, raw_data + size, data + get_size() ); - } - else { - data_size = 2*( data_size + size); - char* new_data; - try { - new_data = new char[data_size]; - } catch (const std::bad_alloc&) { - new_data = 0; - size = 0; - } - if ( 0 != new_data ) { - std::copy( data, data + get_size(), new_data ); - std::copy( raw_data, raw_data + size, new_data + get_size() ); - delete [] data; - data = new_data; - } - } - set_size( get_size() + size ); - } - } - -//------------------------------------------------------------------------------ - void - append_data( const std::string& str_data ) - { - return append_data( str_data.c_str(), (Elf_Word)str_data.size() ); - } - -//------------------------------------------------------------------------------ - protected: -//------------------------------------------------------------------------------ - ELFIO_GET_SET_ACCESS( Elf64_Off, offset, header.sh_offset ); - -//------------------------------------------------------------------------------ - void - set_index( Elf_Half value ) - { - index = value; - } - -//------------------------------------------------------------------------------ - void - load( std::istream& stream, - std::streampos header_offset ) - { - std::fill_n( reinterpret_cast( &header ), sizeof( header ), '\0' ); - - stream.seekg ( 0, stream.end ); - set_stream_size ( stream.tellg() ); - - stream.seekg( header_offset ); - stream.read( reinterpret_cast( &header ), sizeof( header ) ); - - - Elf_Xword size = get_size(); - if ( 0 == data && SHT_NULL != get_type() && SHT_NOBITS != get_type() && size < get_stream_size()) { - try { - data = new char[size + 1]; - } catch (const std::bad_alloc&) { - data = 0; - data_size = 0; - } - - if ( ( 0 != size ) && ( 0 != data ) ) { - stream.seekg( (*convertor)( header.sh_offset ) ); - stream.read( data, size ); - data[size] = 0; // Ensure data is ended with 0 to avoid oob read - data_size = size; - } - } - } - -//------------------------------------------------------------------------------ - void - save( std::ostream& stream, - std::streampos header_offset, - std::streampos data_offset ) - { - if ( 0 != get_index() ) { - header.sh_offset = data_offset; - header.sh_offset = (*convertor)( header.sh_offset ); - } - - save_header( stream, header_offset ); - if ( get_type() != SHT_NOBITS && get_type() != SHT_NULL && - get_size() != 0 && data != 0 ) { - save_data( stream, data_offset ); - } - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - void - save_header( std::ostream& stream, - std::streampos header_offset ) const - { - stream.seekp( header_offset ); - stream.write( reinterpret_cast( &header ), sizeof( header ) ); - } - -//------------------------------------------------------------------------------ - void - save_data( std::ostream& stream, - std::streampos data_offset ) const - { - stream.seekp( data_offset ); - stream.write( get_data(), get_size() ); - } - -//------------------------------------------------------------------------------ - private: - T header; - Elf_Half index; - std::string name; - char* data; - Elf_Word data_size; - const endianess_convertor* convertor; - bool is_address_set; -}; - -} // namespace ELFIO - -#endif // ELFIO_SECTION_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_segment.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_segment.hpp deleted file mode 100644 index 642fd2907..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_segment.hpp +++ /dev/null @@ -1,246 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_SEGMENT_HPP -#define ELFIO_SEGMENT_HPP - -#include -#include - -namespace ELFIO { - -class segment -{ - friend class elfio; - public: - virtual ~segment() {}; - - ELFIO_GET_ACCESS_DECL ( Elf_Half, index ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, type ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Word, flags ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, align ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Addr, virtual_address ); - ELFIO_GET_SET_ACCESS_DECL( Elf64_Addr, physical_address ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, file_size ); - ELFIO_GET_SET_ACCESS_DECL( Elf_Xword, memory_size ); - ELFIO_GET_ACCESS_DECL( Elf64_Off, offset ); - - virtual const char* get_data() const = 0; - - virtual Elf_Half add_section_index( Elf_Half index, Elf_Xword addr_align ) = 0; - virtual Elf_Half get_sections_num() const = 0; - virtual Elf_Half get_section_index_at( Elf_Half num ) const = 0; - virtual bool is_offset_initialized() const = 0; - - protected: - ELFIO_SET_ACCESS_DECL( Elf64_Off, offset ); - ELFIO_SET_ACCESS_DECL( Elf_Half, index ); - - virtual const std::vector& get_sections() const = 0; - virtual void load( std::istream& stream, std::streampos header_offset ) = 0; - virtual void save( std::ostream& stream, std::streampos header_offset, - std::streampos data_offset ) = 0; -}; - - -//------------------------------------------------------------------------------ -template< class T > -class segment_impl : public segment -{ - public: -//------------------------------------------------------------------------------ - segment_impl( endianess_convertor* convertor_ ) : - stream_size( 0 ), index( 0 ), data( 0 ), convertor( convertor_ ) - { - is_offset_set = false; - std::fill_n( reinterpret_cast( &ph ), sizeof( ph ), '\0' ); - } - -//------------------------------------------------------------------------------ - virtual ~segment_impl() - { - delete [] data; - } - -//------------------------------------------------------------------------------ - // Section info functions - ELFIO_GET_SET_ACCESS( Elf_Word, type, ph.p_type ); - ELFIO_GET_SET_ACCESS( Elf_Word, flags, ph.p_flags ); - ELFIO_GET_SET_ACCESS( Elf_Xword, align, ph.p_align ); - ELFIO_GET_SET_ACCESS( Elf64_Addr, virtual_address, ph.p_vaddr ); - ELFIO_GET_SET_ACCESS( Elf64_Addr, physical_address, ph.p_paddr ); - ELFIO_GET_SET_ACCESS( Elf_Xword, file_size, ph.p_filesz ); - ELFIO_GET_SET_ACCESS( Elf_Xword, memory_size, ph.p_memsz ); - ELFIO_GET_ACCESS( Elf64_Off, offset, ph.p_offset ); - size_t stream_size; - -//------------------------------------------------------------------------------ - size_t - get_stream_size() const - { - return stream_size; - } - -//------------------------------------------------------------------------------ - void - set_stream_size(size_t value) - { - stream_size = value; - } - -//------------------------------------------------------------------------------ - Elf_Half - get_index() const - { - return index; - } - -//------------------------------------------------------------------------------ - const char* - get_data() const - { - return data; - } - -//------------------------------------------------------------------------------ - Elf_Half - add_section_index( Elf_Half sec_index, Elf_Xword addr_align ) - { - sections.push_back( sec_index ); - if ( addr_align > get_align() ) { - set_align( addr_align ); - } - - return (Elf_Half)sections.size(); - } - -//------------------------------------------------------------------------------ - Elf_Half - get_sections_num() const - { - return (Elf_Half)sections.size(); - } - -//------------------------------------------------------------------------------ - Elf_Half - get_section_index_at( Elf_Half num ) const - { - if ( num < sections.size() ) { - return sections[num]; - } - - return Elf_Half(-1); - } - -//------------------------------------------------------------------------------ - protected: -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ - void - set_offset( Elf64_Off value ) - { - ph.p_offset = value; - ph.p_offset = (*convertor)( ph.p_offset ); - is_offset_set = true; - } - -//------------------------------------------------------------------------------ - bool - is_offset_initialized() const - { - return is_offset_set; - } - -//------------------------------------------------------------------------------ - const std::vector& - get_sections() const - { - return sections; - } - -//------------------------------------------------------------------------------ - void - set_index( Elf_Half value ) - { - index = value; - } - -//------------------------------------------------------------------------------ - void - load( std::istream& stream, - std::streampos header_offset ) - { - - stream.seekg ( 0, stream.end ); - set_stream_size ( stream.tellg() ); - - stream.seekg( header_offset ); - stream.read( reinterpret_cast( &ph ), sizeof( ph ) ); - is_offset_set = true; - - if ( PT_NULL != get_type() && 0 != get_file_size() ) { - stream.seekg( (*convertor)( ph.p_offset ) ); - Elf_Xword size = get_file_size(); - - if ( size > get_stream_size() ) { - data = 0; - } - else { - try { - data = new char[size + 1]; - } catch (const std::bad_alloc&) { - data = 0; - } - - if ( 0 != data ) { - stream.read( data, size ); - data[size] = 0; - } - } - } - } - -//------------------------------------------------------------------------------ - void save( std::ostream& stream, - std::streampos header_offset, - std::streampos data_offset ) - { - ph.p_offset = data_offset; - ph.p_offset = (*convertor)(ph.p_offset); - stream.seekp( header_offset ); - stream.write( reinterpret_cast( &ph ), sizeof( ph ) ); - } - -//------------------------------------------------------------------------------ - private: - T ph; - Elf_Half index; - char* data; - std::vector sections; - endianess_convertor* convertor; - bool is_offset_set; -}; - -} // namespace ELFIO - -#endif // ELFIO_SEGMENT_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_strings.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_strings.hpp deleted file mode 100644 index 552f00029..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_strings.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_STRINGS_HPP -#define ELFIO_STRINGS_HPP - -#include -#include -#include - -namespace ELFIO { - -//------------------------------------------------------------------------------ -template< class S > -class string_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - string_section_accessor_template( S* section_ ) : - string_section( section_ ) - { - } - - -//------------------------------------------------------------------------------ - const char* - get_string( Elf_Word index ) const - { - if ( string_section ) { - if ( index < string_section->get_size() ) { - const char* data = string_section->get_data(); - if ( 0 != data ) { - return data + index; - } - } - } - - return 0; - } - - -//------------------------------------------------------------------------------ - Elf_Word - add_string( const char* str ) - { - Elf_Word current_position = 0; - - if (string_section) { - // Strings are addeded to the end of the current section data - current_position = (Elf_Word)string_section->get_size(); - - if ( current_position == 0 ) { - char empty_string = '\0'; - string_section->append_data( &empty_string, 1 ); - current_position++; - } - string_section->append_data( str, (Elf_Word)std::strlen( str ) + 1 ); - } - - return current_position; - } - - -//------------------------------------------------------------------------------ - Elf_Word - add_string( const std::string& str ) - { - return add_string( str.c_str() ); - } - -//------------------------------------------------------------------------------ - private: - S* string_section; -}; - -using string_section_accessor = string_section_accessor_template
; -using const_string_section_accessor = string_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_STRINGS_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_symbols.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_symbols.hpp deleted file mode 100644 index d18756a9a..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_symbols.hpp +++ /dev/null @@ -1,282 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_SYMBOLS_HPP -#define ELFIO_SYMBOLS_HPP - -namespace ELFIO { - -//------------------------------------------------------------------------------ -template< class S > -class symbol_section_accessor_template -{ - public: -//------------------------------------------------------------------------------ - symbol_section_accessor_template( const elfio& elf_file_, S* symbol_section_ ) : - elf_file( elf_file_ ), - symbol_section( symbol_section_ ) - { - find_hash_section(); - } - -//------------------------------------------------------------------------------ - Elf_Xword - get_symbols_num() const - { - Elf_Xword nRet = 0; - if ( 0 != symbol_section->get_entry_size() ) { - nRet = symbol_section->get_size() / symbol_section->get_entry_size(); - } - - return nRet; - } - -//------------------------------------------------------------------------------ - bool - get_symbol( Elf_Xword index, - std::string& name, - Elf64_Addr& value, - Elf_Xword& size, - unsigned char& bind, - unsigned char& type, - Elf_Half& section_index, - unsigned char& other ) const - { - bool ret = false; - - if ( elf_file.get_class() == ELFCLASS32 ) { - ret = generic_get_symbol( index, name, value, size, bind, - type, section_index, other ); - } - else { - ret = generic_get_symbol( index, name, value, size, bind, - type, section_index, other ); - } - - return ret; - } - -//------------------------------------------------------------------------------ - bool - get_symbol( const std::string& name, - Elf64_Addr& value, - Elf_Xword& size, - unsigned char& bind, - unsigned char& type, - Elf_Half& section_index, - unsigned char& other ) const - { - bool ret = false; - - if ( 0 != get_hash_table_index() ) { - Elf_Word nbucket = *(const Elf_Word*)hash_section->get_data(); - Elf_Word nchain = *(const Elf_Word*)( hash_section->get_data() + - sizeof( Elf_Word ) ); - Elf_Word val = elf_hash( (const unsigned char*)name.c_str() ); - - Elf_Word y = *(const Elf_Word*)( hash_section->get_data() + - ( 2 + val % nbucket ) * sizeof( Elf_Word ) ); - std::string str; - get_symbol( y, str, value, size, bind, type, section_index, other ); - while ( str != name && STN_UNDEF != y && y < nchain ) { - y = *(const Elf_Word*)( hash_section->get_data() + - ( 2 + nbucket + y ) * sizeof( Elf_Word ) ); - get_symbol( y, str, value, size, bind, type, section_index, other ); - } - if ( str == name ) { - ret = true; - } - } - - return ret; - } - -//------------------------------------------------------------------------------ - Elf_Word - add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size, - unsigned char info, unsigned char other, - Elf_Half shndx ) - { - Elf_Word nRet; - - if ( symbol_section->get_size() == 0 ) { - if ( elf_file.get_class() == ELFCLASS32 ) { - nRet = generic_add_symbol( 0, 0, 0, 0, 0, 0 ); - } - else { - nRet = generic_add_symbol( 0, 0, 0, 0, 0, 0 ); - } - } - - if ( elf_file.get_class() == ELFCLASS32 ) { - nRet = generic_add_symbol( name, value, size, info, other, - shndx ); - } - else { - nRet = generic_add_symbol( name, value, size, info, other, - shndx ); - } - - return nRet; - } - -//------------------------------------------------------------------------------ - Elf_Word - add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size, - unsigned char bind, unsigned char type, unsigned char other, - Elf_Half shndx ) - { - return add_symbol( name, value, size, ELF_ST_INFO( bind, type ), other, shndx ); - } - -//------------------------------------------------------------------------------ - Elf_Word - add_symbol( string_section_accessor& pStrWriter, const char* str, - Elf64_Addr value, Elf_Xword size, - unsigned char info, unsigned char other, - Elf_Half shndx ) - { - Elf_Word index = pStrWriter.add_string( str ); - return add_symbol( index, value, size, info, other, shndx ); - } - -//------------------------------------------------------------------------------ - Elf_Word - add_symbol( string_section_accessor& pStrWriter, const char* str, - Elf64_Addr value, Elf_Xword size, - unsigned char bind, unsigned char type, unsigned char other, - Elf_Half shndx ) - { - return add_symbol( pStrWriter, str, value, size, ELF_ST_INFO( bind, type ), other, shndx ); - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - void - find_hash_section() - { - hash_section = 0; - hash_section_index = 0; - Elf_Half nSecNo = elf_file.sections.size(); - for ( Elf_Half i = 0; i < nSecNo && 0 == hash_section_index; ++i ) { - const section* sec = elf_file.sections[i]; - if ( sec->get_link() == symbol_section->get_index() ) { - hash_section = sec; - hash_section_index = i; - } - } - } - -//------------------------------------------------------------------------------ - Elf_Half - get_string_table_index() const - { - return (Elf_Half)symbol_section->get_link(); - } - -//------------------------------------------------------------------------------ - Elf_Half - get_hash_table_index() const - { - return hash_section_index; - } - -//------------------------------------------------------------------------------ - template< class T > - bool - generic_get_symbol( Elf_Xword index, - std::string& name, Elf64_Addr& value, - Elf_Xword& size, - unsigned char& bind, unsigned char& type, - Elf_Half& section_index, - unsigned char& other ) const - { - bool ret = false; - - if ( index < get_symbols_num() ) { - const T* pSym = reinterpret_cast( - symbol_section->get_data() + - index * symbol_section->get_entry_size() ); - - const endianess_convertor& convertor = elf_file.get_convertor(); - - section* string_section = elf_file.sections[get_string_table_index()]; - string_section_accessor str_reader( string_section ); - const char* pStr = str_reader.get_string( convertor( pSym->st_name ) ); - if ( 0 != pStr ) { - name = pStr; - } - value = convertor( pSym->st_value ); - size = convertor( pSym->st_size ); - bind = ELF_ST_BIND( pSym->st_info ); - type = ELF_ST_TYPE( pSym->st_info ); - section_index = convertor( pSym->st_shndx ); - other = pSym->st_other; - - ret = true; - } - - return ret; - } - -//------------------------------------------------------------------------------ - template< class T > - Elf_Word - generic_add_symbol( Elf_Word name, Elf64_Addr value, Elf_Xword size, - unsigned char info, unsigned char other, - Elf_Half shndx ) - { - const endianess_convertor& convertor = elf_file.get_convertor(); - - T entry; - entry.st_name = convertor( name ); - entry.st_value = value; - entry.st_value = convertor( entry.st_value ); - entry.st_size = size; - entry.st_size = convertor( entry.st_size ); - entry.st_info = convertor( info ); - entry.st_other = convertor( other ); - entry.st_shndx = convertor( shndx ); - - symbol_section->append_data( reinterpret_cast( &entry ), - sizeof( entry ) ); - - Elf_Word nRet = symbol_section->get_size() / sizeof( entry ) - 1; - - return nRet; - } - -//------------------------------------------------------------------------------ - private: - const elfio& elf_file; - S* symbol_section; - Elf_Half hash_section_index; - const section* hash_section; -}; - -using symbol_section_accessor = symbol_section_accessor_template
; -using const_symbol_section_accessor = symbol_section_accessor_template; - -} // namespace ELFIO - -#endif // ELFIO_SYMBOLS_HPP diff --git a/tools/ZAPD/lib/elfio/elfio/elfio_utils.hpp b/tools/ZAPD/lib/elfio/elfio/elfio_utils.hpp deleted file mode 100644 index 2baf5a77c..000000000 --- a/tools/ZAPD/lib/elfio/elfio/elfio_utils.hpp +++ /dev/null @@ -1,209 +0,0 @@ -/* -Copyright (C) 2001-2015 by Serge Lamikhov-Center - -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. -*/ - -#ifndef ELFIO_UTILS_HPP -#define ELFIO_UTILS_HPP - -#define ELFIO_GET_ACCESS( TYPE, NAME, FIELD ) \ - TYPE get_##NAME() const \ - { \ - return (*convertor)( FIELD ); \ - } -#define ELFIO_SET_ACCESS( TYPE, NAME, FIELD ) \ - void set_##NAME( TYPE value ) \ - { \ - FIELD = value; \ - FIELD = (*convertor)( FIELD ); \ - } -#define ELFIO_GET_SET_ACCESS( TYPE, NAME, FIELD ) \ - TYPE get_##NAME() const \ - { \ - return (*convertor)( FIELD ); \ - } \ - void set_##NAME( TYPE value ) \ - { \ - FIELD = value; \ - FIELD = (*convertor)( FIELD ); \ - } - -#define ELFIO_GET_ACCESS_DECL( TYPE, NAME ) \ - virtual TYPE get_##NAME() const = 0 - -#define ELFIO_SET_ACCESS_DECL( TYPE, NAME ) \ - virtual void set_##NAME( TYPE value ) = 0 - -#define ELFIO_GET_SET_ACCESS_DECL( TYPE, NAME ) \ - virtual TYPE get_##NAME() const = 0; \ - virtual void set_##NAME( TYPE value ) = 0 - -namespace ELFIO { - -//------------------------------------------------------------------------------ -class endianess_convertor { - public: -//------------------------------------------------------------------------------ - endianess_convertor() - { - need_conversion = false; - } - -//------------------------------------------------------------------------------ - void - setup( unsigned char elf_file_encoding ) - { - need_conversion = ( elf_file_encoding != get_host_encoding() ); - } - -//------------------------------------------------------------------------------ - uint64_t - operator()( uint64_t value ) const - { - if ( !need_conversion ) { - return value; - } - value = - ( ( value & 0x00000000000000FFull ) << 56 ) | - ( ( value & 0x000000000000FF00ull ) << 40 ) | - ( ( value & 0x0000000000FF0000ull ) << 24 ) | - ( ( value & 0x00000000FF000000ull ) << 8 ) | - ( ( value & 0x000000FF00000000ull ) >> 8 ) | - ( ( value & 0x0000FF0000000000ull ) >> 24 ) | - ( ( value & 0x00FF000000000000ull ) >> 40 ) | - ( ( value & 0xFF00000000000000ull ) >> 56 ); - - return value; - } - -//------------------------------------------------------------------------------ - int64_t - operator()( int64_t value ) const - { - if ( !need_conversion ) { - return value; - } - return (int64_t)(*this)( (uint64_t)value ); - } - -//------------------------------------------------------------------------------ - uint32_t - operator()( uint32_t value ) const - { - if ( !need_conversion ) { - return value; - } - value = - ( ( value & 0x000000FF ) << 24 ) | - ( ( value & 0x0000FF00 ) << 8 ) | - ( ( value & 0x00FF0000 ) >> 8 ) | - ( ( value & 0xFF000000 ) >> 24 ); - - return value; - } - -//------------------------------------------------------------------------------ - int32_t - operator()( int32_t value ) const - { - if ( !need_conversion ) { - return value; - } - return (int32_t)(*this)( (uint32_t)value ); - } - -//------------------------------------------------------------------------------ - uint16_t - operator()( uint16_t value ) const - { - if ( !need_conversion ) { - return value; - } - value = - ( ( value & 0x00FF ) << 8 ) | - ( ( value & 0xFF00 ) >> 8 ); - - return value; - } - -//------------------------------------------------------------------------------ - int16_t - operator()( int16_t value ) const - { - if ( !need_conversion ) { - return value; - } - return (int16_t)(*this)( (uint16_t)value ); - } - -//------------------------------------------------------------------------------ - int8_t - operator()( int8_t value ) const - { - return value; - } - -//------------------------------------------------------------------------------ - uint8_t - operator()( uint8_t value ) const - { - return value; - } - -//------------------------------------------------------------------------------ - private: -//------------------------------------------------------------------------------ - unsigned char - get_host_encoding() const - { - static const int tmp = 1; - if ( 1 == *(const char*)&tmp ) { - return ELFDATA2LSB; - } - else { - return ELFDATA2MSB; - } - } - -//------------------------------------------------------------------------------ - private: - bool need_conversion; -}; - - -//------------------------------------------------------------------------------ -inline -uint32_t -elf_hash( const unsigned char *name ) -{ - uint32_t h = 0, g; - while ( *name ) { - h = (h << 4) + *name++; - g = h & 0xf0000000; - if ( g != 0 ) - h ^= g >> 24; - h &= ~g; - } - return h; -} - -} // namespace ELFIO - -#endif // ELFIO_UTILS_HPP diff --git a/tools/ZAPDConfigs/MM/ObjectList_MM.txt b/tools/ZAPDConfigs/MM/ObjectList_MM.txt index c3848574c..93c17e298 100644 --- a/tools/ZAPDConfigs/MM/ObjectList_MM.txt +++ b/tools/ZAPDConfigs/MM/ObjectList_MM.txt @@ -393,7 +393,7 @@ OBJECT_DRIFTICE OBJECT_FALL OBJECT_HANAREYAMA_OBJ OBJECT_CRACE_OBJECT -OBJECT_DNQ +OBJECT_DNO OBJECT_OBJ_TOKEIDAI OBJECT_EG OBJECT_TRU @@ -466,7 +466,7 @@ OBJECT_GG OBJECT_MARUTA OBJECT_GHAKA OBJECT_OYU -OBJECT_DNP +OBJECT_DNQ OBJECT_DAI OBJECT_KGY OBJECT_FB @@ -497,7 +497,7 @@ OBJECT_GI_LOACH OBJECT_GI_SEAHORSE OBJECT_BIGPO OBJECT_HARIKO -OBJECT_DNO +OBJECT_DNJ OBJECT_SINKAI_KABE OBJECT_KIN2_OBJ OBJECT_ISHI 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/elf2rom.c b/tools/buildtools/elf2rom.c index 8f4441293..1473246ce 100644 --- a/tools/buildtools/elf2rom.c +++ b/tools/buildtools/elf2rom.c @@ -12,45 +12,41 @@ #define ROM_SEG_START_SUFFIX ".rom_start" #define ROM_SEG_END_SUFFIX ".rom_end" -struct RomSegment -{ - const char *name; - const void *data; +struct RomSegment { + const char* name; + const void* data; int size; int romStart; int romEnd; }; -static struct RomSegment *g_romSegments = NULL; +static struct RomSegment* g_romSegments = NULL; static int g_romSegmentsCount = 0; static int g_romSize; -static bool parse_number(const char *str, int *num) -{ - char *endptr; +static bool parse_number(const char* str, int* num) { + char* endptr; long int n = strtol(str, &endptr, 0); *num = n; return endptr > str; } -static unsigned int round_up(unsigned int num, unsigned int multiple) -{ +static unsigned int round_up(unsigned int num, unsigned int multiple) { num += multiple - 1; return num / multiple * multiple; } -static char *sprintf_alloc(const char *fmt, ...) -{ +static char* sprintf_alloc(const char* fmt, ...) { va_list args; int size; - char *buffer; + char* buffer; va_start(args, fmt); size = vsnprintf(NULL, 0, fmt, args) + 1; va_end(args); buffer = malloc(size); - + va_start(args, fmt); vsprintf(buffer, fmt, args); va_end(args); @@ -58,8 +54,7 @@ static char *sprintf_alloc(const char *fmt, ...) return buffer; } -static struct RomSegment *add_rom_segment(const char *name) -{ +static struct RomSegment* add_rom_segment(const char* name) { int index = g_romSegmentsCount; g_romSegmentsCount++; @@ -71,50 +66,44 @@ static struct RomSegment *add_rom_segment(const char *name) return &g_romSegments[index]; } -static void find_segment_info(struct Elf32 *elf, struct RomSegment *segment) -{ +static void find_segment_info(struct Elf32* elf, struct RomSegment* segment) { int i; - char *romStartSymName = sprintf_alloc("_%sSegmentRomStart", segment->name); - char *romEndSymName = sprintf_alloc("_%sSegmentRomEnd", segment->name); + char* romStartSymName = sprintf_alloc("_%sSegmentRomStart", segment->name); + char* romEndSymName = sprintf_alloc("_%sSegmentRomEnd", segment->name); segment->romStart = -1; segment->romEnd = -1; // TODO: use a hashmap for this instead of an O(n) loop - for (i = 0; i < elf->numsymbols; i++) - { + for (i = 0; i < elf->numsymbols; i++) { struct Elf32_Symbol sym; - + if (!elf32_get_symbol(elf, &sym, i)) util_fatal_error("invalid or corrupt ELF file"); - if (strcmp(sym.name, romStartSymName) == 0) - { + if (strcmp(sym.name, romStartSymName) == 0) { segment->romStart = sym.value; if (segment->romEnd != -1) break; - } - else if (strcmp(sym.name, romEndSymName) == 0) - { + } else if (strcmp(sym.name, romEndSymName) == 0) { segment->romEnd = sym.value; if (segment->romStart != -1) break; } } - + if (segment->romStart == -1) util_fatal_error("ROM start address of %s is not defined\n", segment->name); if (segment->romEnd == -1) util_fatal_error("ROM end address of %s is not defined\n", segment->name); - + free(romStartSymName); free(romEndSymName); } -static void parse_input_file(const char *filename) -{ +static void parse_input_file(const char* filename) { struct Elf32 elf; - const void *data; + const void* data; size_t size; int i; @@ -125,45 +114,40 @@ static void parse_input_file(const char *filename) // get ROM segments // sections of type SHT_PROGBITS and whose name is ..secname are considered ROM segments - for (i = 0; i < elf.shnum; i++) - { + for (i = 0; i < elf.shnum; i++) { struct Elf32_Section sec; - struct RomSegment *segment; + struct RomSegment* segment; if (!elf32_get_section(&elf, &sec, i)) util_fatal_error("invalid or corrupt ELF file"); - if (sec.type == SHT_PROGBITS && sec.name[0] == '.' && sec.name[1] == '.' - // HACK! ld sometimes marks NOLOAD sections as SHT_PROGBITS for no apparent reason, - // so we must ignore the ..secname.bss sections explicitly - && strchr(sec.name + 2, '.') == NULL) - { - + if (sec.type == SHT_PROGBITS && sec.name[0] == '.' && + sec.name[1] == '.' + // HACK! ld sometimes marks NOLOAD sections as SHT_PROGBITS for no apparent reason, + // so we must ignore the ..secname.bss sections explicitly + && strchr(sec.name + 2, '.') == NULL) { + segment = add_rom_segment(sec.name + 2); find_segment_info(&elf, segment); segment->data = elf.data + sec.offset; } - } // find ROM size - for (i = 0; i < elf.numsymbols; i++) - { + for (i = 0; i < elf.numsymbols; i++) { struct Elf32_Symbol sym; if (!elf32_get_symbol(&elf, &sym, i)) util_fatal_error("invalid or corrupt ELF file"); - if (strcmp(sym.name, "_RomSize") == 0) - { + if (strcmp(sym.name, "_RomSize") == 0) { g_romSize = sym.value; goto got_rom_size; } } util_fatal_error("could not find symbol _RomSize"); - got_rom_size: +got_rom_size: // verify segment info - for (i = 0; i < g_romSegmentsCount; i++) - { + for (i = 0; i < g_romSegmentsCount; i++) { if (g_romSegments[i].romStart == -1) util_fatal_error("segment %s has no ROM start address defined.", g_romSegments[i].name); if (g_romSegments[i].romEnd == -1) @@ -172,23 +156,21 @@ static void parse_input_file(const char *filename) } // Writes the N64 ROM, padding the file size to a multiple of 1 MiB -static void write_rom_file(const char *filename, int cicType) -{ +static void write_rom_file(const char* filename, int cicType) { size_t fileSize = round_up(g_romSize, 0x100000); - uint8_t *buffer = calloc(fileSize, 1); + uint8_t* buffer = calloc(fileSize, 1); int i; uint32_t chksum[2]; // write segments - for (i = 0; i < g_romSegmentsCount; i++) - { + for (i = 0; i < g_romSegmentsCount; i++) { int size = g_romSegments[i].romEnd - g_romSegments[i].romStart; memcpy(buffer + g_romSegments[i].romStart, g_romSegments[i].data, size); } // pad the remaining space with 0xFF - for (i = g_romSize; i < (int) fileSize; i++) + for (i = g_romSize; i < (int)fileSize; i++) buffer[i] = 0xFF; // write checksum @@ -201,67 +183,51 @@ static void write_rom_file(const char *filename, int cicType) free(buffer); } -static void usage(const char *execname) -{ +static void usage(const char* execname) { printf("usage: %s\n", execname); } -int main(int argc, char **argv) -{ +int main(int argc, char** argv) { int i; - const char *inputFileName = NULL; - const char *outputFileName = NULL; + const char* inputFileName = NULL; + const char* outputFileName = NULL; int cicType = -1; - for (i = 1; i < argc; i++) - { - if (argv[i][0] == '-') - { - if (strcmp(argv[i], "-cic") == 0) - { + for (i = 1; i < argc; i++) { + if (argv[i][0] == '-') { + if (strcmp(argv[i], "-cic") == 0) { i++; - if (i >= argc || !parse_number(argv[i], &cicType)) - { + if (i >= argc || !parse_number(argv[i], &cicType)) { fputs("error: expected number after -cic\n", stderr); goto bad_args; } - } - else if (strcmp(argv[i], "-help") == 0) - { + } else if (strcmp(argv[i], "-help") == 0) { usage(argv[0]); return 0; - } - else - { + } else { fprintf(stderr, "unknown option %s\n", argv[i]); goto bad_args; } - } - else - { + } else { if (inputFileName == NULL) inputFileName = argv[i]; else if (outputFileName == NULL) outputFileName = argv[i]; - else - { + else { fputs("error: too many parameters specified\n", stderr); goto bad_args; } } } - if (inputFileName == NULL) - { + if (inputFileName == NULL) { fputs("error: no input file specified\n", stderr); goto bad_args; } - if (outputFileName == NULL) - { + if (outputFileName == NULL) { fputs("error: no output file specified\n", stderr); goto bad_args; } - if (cicType == -1) - { + if (cicType == -1) { fputs("error: no CIC type specified\n", stderr); goto bad_args; } diff --git a/tools/buildtools/elf32.c b/tools/buildtools/elf32.c index f5dcafc0d..7540406fb 100644 --- a/tools/buildtools/elf32.c +++ b/tools/buildtools/elf32.c @@ -5,36 +5,23 @@ #include "elf32.h" -static uint16_t read16_le(const uint8_t *data) -{ - return data[0] << 0 - | data[1] << 8; +static uint16_t read16_le(const uint8_t* data) { + return data[0] << 0 | data[1] << 8; } -static uint32_t read32_le(const uint8_t *data) -{ - return data[0] << 0 - | data[1] << 8 - | data[2] << 16 - | data[3] << 24; +static uint32_t read32_le(const uint8_t* data) { + return data[0] << 0 | data[1] << 8 | data[2] << 16 | data[3] << 24; } -static uint16_t read16_be(const uint8_t *data) -{ - return data[0] << 8 - | data[1] << 0; +static uint16_t read16_be(const uint8_t* data) { + return data[0] << 8 | data[1] << 0; } -static uint32_t read32_be(const uint8_t *data) -{ - return data[0] << 24 - | data[1] << 16 - | data[2] << 8 - | data[3] << 0; +static uint32_t read32_be(const uint8_t* data) { + return data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3] << 0; } -static const void *get_section_header(struct Elf32 *e, int secnum) -{ +static const void* get_section_header(struct Elf32* e, int secnum) { size_t secoffset = e->shoff + secnum * 0x28; if (secnum >= e->shnum || secoffset >= e->dataSize) @@ -42,76 +29,70 @@ static const void *get_section_header(struct Elf32 *e, int secnum) return e->data + secoffset; } -static const void *get_section_contents(struct Elf32 *e, int secnum) -{ +static const void* get_section_contents(struct Elf32* e, int secnum) { size_t secoffset = e->shoff + secnum * 0x28; size_t dataoffset; - + if (secnum >= e->shnum || secoffset >= e->dataSize) return NULL; dataoffset = e->read32(e->data + secoffset + 0x10); return e->data + dataoffset; } -static bool verify_magic(const uint8_t *data) -{ +static bool verify_magic(const uint8_t* data) { return (data[0] == 0x7F && data[1] == 'E' && data[2] == 'L' && data[3] == 'F'); } -bool elf32_init(struct Elf32 *e, const void *data, size_t size) -{ +bool elf32_init(struct Elf32* e, const void* data, size_t size) { unsigned int i; e->data = data; e->dataSize = size; if (size < 0x34) - return false; // not big enough for header + return false; // not big enough for header if (!verify_magic(e->data)) return false; if (e->data[4] != 1) - return false; // must be 32-bit + return false; // must be 32-bit e->endian = e->data[5]; - switch (e->endian) - { - case 1: - e->read16 = read16_le; - e->read32 = read32_le; - break; - case 2: - e->read16 = read16_be; - e->read32 = read32_be; - break; - default: - return false; + switch (e->endian) { + case 1: + e->read16 = read16_le; + e->read32 = read32_le; + break; + case 2: + e->read16 = read16_be; + e->read32 = read32_be; + break; + default: + return false; } - e->type = e->read16(e->data + 0x10); - e->machine = e->read16(e->data + 0x12); - e->version = e->data[6]; - e->entry = e->read32(e->data + 0x18); - e->phoff = e->read32(e->data + 0x1C); - e->shoff = e->read32(e->data + 0x20); - e->ehsize = e->read16(e->data + 0x28); + e->type = e->read16(e->data + 0x10); + e->machine = e->read16(e->data + 0x12); + e->version = e->data[6]; + e->entry = e->read32(e->data + 0x18); + e->phoff = e->read32(e->data + 0x1C); + e->shoff = e->read32(e->data + 0x20); + e->ehsize = e->read16(e->data + 0x28); e->phentsize = e->read16(e->data + 0x2A); - e->phnum = e->read16(e->data + 0x2C); + e->phnum = e->read16(e->data + 0x2C); e->shentsize = e->read16(e->data + 0x2E); - e->shnum = e->read16(e->data + 0x30); - e->shstrndx = e->read16(e->data + 0x32); - + e->shnum = e->read16(e->data + 0x30); + e->shstrndx = e->read16(e->data + 0x32); + // find symbol table section e->symtabndx = -1; - for (i = 0; i < e->shnum; i++) - { - const uint8_t *sechdr = get_section_header(e, i); + for (i = 0; i < e->shnum; i++) { + const uint8_t* sechdr = get_section_header(e, i); uint32_t type = e->read32(sechdr + 0x04); - - if (type == SHT_SYMTAB) - { + + if (type == SHT_SYMTAB) { e->symtabndx = i; break; } @@ -119,59 +100,53 @@ bool elf32_init(struct Elf32 *e, const void *data, size_t size) // find .strtab section e->strtabndx = -1; - for (i = 0; i < e->shnum; i++) - { - const uint8_t *sechdr = get_section_header(e, i); + for (i = 0; i < e->shnum; i++) { + const uint8_t* sechdr = get_section_header(e, i); uint32_t type = e->read32(sechdr + 0x04); - - if (type == SHT_STRTAB) - { - const char *strings = get_section_contents(e, e->shstrndx); - const char *secname = strings + e->read32(sechdr + 0); - - if (strcmp(secname, ".strtab") == 0) - { + + if (type == SHT_STRTAB) { + const char* strings = get_section_contents(e, e->shstrndx); + const char* secname = strings + e->read32(sechdr + 0); + + if (strcmp(secname, ".strtab") == 0) { e->strtabndx = i; break; } } } - + e->numsymbols = 0; - if (e->symtabndx != -1) - { - const uint8_t *sechdr = get_section_header(e, e->symtabndx); - //const uint8_t *symtab = get_section_contents(e, e->symtabndx); - + if (e->symtabndx != -1) { + const uint8_t* sechdr = get_section_header(e, e->symtabndx); + // const uint8_t *symtab = get_section_contents(e, e->symtabndx); + e->numsymbols = e->read32(sechdr + 0x14) / e->read32(sechdr + 0x24); } if (e->shoff + e->shstrndx * 0x28 >= e->dataSize) return false; - + return true; } -bool elf32_get_section(struct Elf32 *e, struct Elf32_Section *sec, int secnum) -{ - const uint8_t *sechdr = get_section_header(e, secnum); - const char *strings = get_section_contents(e, e->shstrndx); +bool elf32_get_section(struct Elf32* e, struct Elf32_Section* sec, int secnum) { + const uint8_t* sechdr = get_section_header(e, secnum); + const char* strings = get_section_contents(e, e->shstrndx); - sec->name = strings + e->read32(sechdr + 0); - sec->type = e->read32(sechdr + 0x04); - sec->flags = e->read32(sechdr + 0x08); - sec->addr = e->read32(sechdr + 0x0C); - sec->offset = e->read32(sechdr + 0x10); + sec->name = strings + e->read32(sechdr + 0); + sec->type = e->read32(sechdr + 0x04); + sec->flags = e->read32(sechdr + 0x08); + sec->addr = e->read32(sechdr + 0x0C); + sec->offset = e->read32(sechdr + 0x10); sec->addralign = e->read32(sechdr + 0x20); - sec->entsize = e->read32(sechdr + 0x24); + sec->entsize = e->read32(sechdr + 0x24); return true; } -bool elf32_get_symbol(struct Elf32 *e, struct Elf32_Symbol *sym, int symnum) -{ - const uint8_t *sechdr; - const uint8_t *symtab; - const char *strings; +bool elf32_get_symbol(struct Elf32* e, struct Elf32_Symbol* sym, int symnum) { + const uint8_t* sechdr; + const uint8_t* symtab; + const char* strings; int symcount; if (e->symtabndx == -1) diff --git a/tools/buildtools/elf32.h b/tools/buildtools/elf32.h index 666f6e917..0dae635f2 100644 --- a/tools/buildtools/elf32.h +++ b/tools/buildtools/elf32.h @@ -1,22 +1,22 @@ -#ifndef _ELF_H_ -#define _ELF_H_ +#ifndef ELF32_H +#define ELF32_H -enum -{ +#include +#include + +enum { ELF_MACHINE_NONE = 0, ELF_MACHINE_MIPS = 8, }; -enum -{ +enum { ELF_TYPE_RELOC = 1, ELF_TYPE_EXEC, ELF_TYPE_SHARED, ELF_TYPE_CORE, }; -struct Elf32 -{ +struct Elf32 { uint8_t endian; uint16_t type; uint16_t machine; @@ -34,23 +34,21 @@ struct Elf32 int strtabndx; int numsymbols; - const uint8_t *data; + const uint8_t* data; size_t dataSize; - uint16_t (*read16)(const uint8_t *); - uint32_t (*read32)(const uint8_t *); + uint16_t (*read16)(const uint8_t*); + uint32_t (*read32)(const uint8_t*); }; -enum -{ +enum { SHT_NULL = 0, SHT_PROGBITS, SHT_SYMTAB, SHT_STRTAB, }; -struct Elf32_Section -{ - const char *name; +struct Elf32_Section { + const char* name; uint32_t type; uint32_t flags; uint32_t addr; @@ -59,14 +57,13 @@ struct Elf32_Section uint32_t entsize; }; -struct Elf32_Symbol -{ - const char *name; +struct Elf32_Symbol { + const char* name; uint32_t value; }; -bool elf32_init(struct Elf32 *e, const void *data, size_t size); -bool elf32_get_section(struct Elf32 *e, struct Elf32_Section *sec, int secnum); -bool elf32_get_symbol(struct Elf32 *e, struct Elf32_Symbol *sym, int symnum); +bool elf32_init(struct Elf32* e, const void* data, size_t size); +bool elf32_get_section(struct Elf32* e, struct Elf32_Section* sec, int secnum); +bool elf32_get_symbol(struct Elf32* e, struct Elf32_Symbol* sym, int symnum); #endif diff --git a/tools/buildtools/makeromfs.c b/tools/buildtools/makeromfs.c index a61c8e019..198f8adc5 100644 --- a/tools/buildtools/makeromfs.c +++ b/tools/buildtools/makeromfs.c @@ -12,18 +12,16 @@ #define ROM_SIZE 0x02000000 -enum InputObjType -{ +enum InputObjType { OBJ_NULL, OBJ_FILE, OBJ_TABLE, }; -struct InputFile -{ +struct InputFile { enum InputObjType type; - const char *name; - uint8_t *data; + const char* name; + uint8_t* data; size_t size; unsigned int valign; @@ -33,73 +31,58 @@ struct InputFile uint32_t physEnd; }; -static struct InputFile *g_inputFiles = NULL; +static struct InputFile* g_inputFiles = NULL; static int g_inputFilesCount = 0; -static unsigned int round_up(unsigned int num, unsigned int multiple) -{ +static unsigned int round_up(unsigned int num, unsigned int multiple) { num += multiple - 1; return num / multiple * multiple; } -static bool is_yaz0_header(const uint8_t *data) -{ - return data[0] == 'Y' - && data[1] == 'a' - && data[2] == 'z' - && data[3] == '0'; +static bool is_yaz0_header(const uint8_t* data) { + return data[0] == 'Y' && data[1] == 'a' && data[2] == 'z' && data[3] == '0'; } -static void compute_offsets(void) -{ +static void compute_offsets(void) { size_t physOffset = 0; size_t virtOffset = 0; int i; - for (i = 0; i < g_inputFilesCount; i++) - { + for (i = 0; i < g_inputFilesCount; i++) { bool compressed = false; - if (g_inputFiles[i].type == OBJ_FILE) - { + if (g_inputFiles[i].type == OBJ_FILE) { if (is_yaz0_header(g_inputFiles[i].data)) compressed = true; - } - else if (g_inputFiles[i].type == OBJ_TABLE) - { + } else if (g_inputFiles[i].type == OBJ_TABLE) { g_inputFiles[i].size = g_inputFilesCount * 16; } virtOffset = round_up(virtOffset, g_inputFiles[i].valign); - if (g_inputFiles[i].type == OBJ_NULL) - { + if (g_inputFiles[i].type == OBJ_NULL) { g_inputFiles[i].virtStart = 0; - g_inputFiles[i].virtEnd = 0; + g_inputFiles[i].virtEnd = 0; g_inputFiles[i].physStart = 0; - g_inputFiles[i].physEnd = 0; - } - else if (compressed) - { + g_inputFiles[i].physEnd = 0; + } else if (compressed) { size_t compSize = round_up(g_inputFiles[i].size, 16); size_t uncompSize = util_read_uint32_be(g_inputFiles[i].data + 4); g_inputFiles[i].virtStart = virtOffset; - g_inputFiles[i].virtEnd = virtOffset + uncompSize; + g_inputFiles[i].virtEnd = virtOffset + uncompSize; g_inputFiles[i].physStart = physOffset; - g_inputFiles[i].physEnd = physOffset + compSize; + g_inputFiles[i].physEnd = physOffset + compSize; physOffset += compSize; virtOffset += uncompSize; - } - else - { + } else { size_t size = g_inputFiles[i].size; g_inputFiles[i].virtStart = virtOffset; - g_inputFiles[i].virtEnd = virtOffset + size; + g_inputFiles[i].virtEnd = virtOffset + size; g_inputFiles[i].physStart = physOffset; - g_inputFiles[i].physEnd = 0; + g_inputFiles[i].physEnd = 0; physOffset += size; virtOffset += size; @@ -107,17 +90,15 @@ static void compute_offsets(void) } } -static void build_rom(const char *filename) -{ - uint8_t *romData = calloc(ROM_SIZE, 1); +static void build_rom(const char* filename) { + uint8_t* romData = calloc(ROM_SIZE, 1); size_t pos = 0; int i; int j; uint32_t chksum[2]; - FILE *outFile; + FILE* outFile; - for (i = 0; i < g_inputFilesCount; i++) - { + for (i = 0; i < g_inputFilesCount; i++) { size_t size = g_inputFiles[i].size; if (pos + round_up(size, 16) > ROM_SIZE) @@ -125,34 +106,31 @@ static void build_rom(const char *filename) assert(pos % 16 == 0); - switch (g_inputFiles[i].type) - { - case OBJ_FILE: - // write file data - memcpy(romData + pos, g_inputFiles[i].data, size); - pos += round_up(size, 16); + switch (g_inputFiles[i].type) { + case OBJ_FILE: + // write file data + memcpy(romData + pos, g_inputFiles[i].data, size); + pos += round_up(size, 16); - free(g_inputFiles[i].data); - break; - case OBJ_TABLE: - for (j = 0; j < g_inputFilesCount; j++) - { - util_write_uint32_be(romData + pos + 0, g_inputFiles[j].virtStart); - util_write_uint32_be(romData + pos + 4, g_inputFiles[j].virtEnd); - util_write_uint32_be(romData + pos + 8, g_inputFiles[j].physStart); - util_write_uint32_be(romData + pos + 12, g_inputFiles[j].physEnd); + free(g_inputFiles[i].data); + break; + case OBJ_TABLE: + for (j = 0; j < g_inputFilesCount; j++) { + util_write_uint32_be(romData + pos + 0, g_inputFiles[j].virtStart); + util_write_uint32_be(romData + pos + 4, g_inputFiles[j].virtEnd); + util_write_uint32_be(romData + pos + 8, g_inputFiles[j].physStart); + util_write_uint32_be(romData + pos + 12, g_inputFiles[j].physEnd); - pos += 16; - } - break; - case OBJ_NULL: - break; + pos += 16; + } + break; + case OBJ_NULL: + break; } } // Pad the rest of the ROM - while (pos < ROM_SIZE) - { + while (pos < ROM_SIZE) { // This is such a weird thing to pad with. Whatever, Nintendo. romData[pos] = pos & 0xFF; pos++; @@ -173,8 +151,7 @@ static void build_rom(const char *filename) free(romData); } -static struct InputFile *new_file(void) -{ +static struct InputFile* new_file(void) { int index = g_inputFilesCount; g_inputFilesCount++; @@ -186,15 +163,13 @@ static struct InputFile *new_file(void) } // null terminates the current token and returns a pointer to the next token -static char *token_split(char *str) -{ - while (!isspace(*str)) - { +static char* token_split(char* str) { + while (!isspace(*str)) { if (*str == 0) - return str; // end of string + return str; // end of string str++; } - *str = 0; // terminate token + *str = 0; // terminate token str++; // skip remaining whitespace @@ -204,104 +179,94 @@ static char *token_split(char *str) } // null terminates the current line and returns a pointer to the next line -static char *line_split(char *str) -{ - while (*str != '\n') - { +static char* line_split(char* str) { + while (*str != '\n') { if (*str == 0) - return str; // end of string + return str; // end of string str++; } - *str = 0; // terminate line + *str = 0; // terminate line return str + 1; } -static void parse_line(char *line, int lineNum) -{ - char *token = line; +static void parse_line(char* line, int lineNum) { + char* token = line; int i = 0; - char *filename = NULL; + char* filename = NULL; enum InputObjType type = -1; int valign = 1; - struct InputFile *file; + struct InputFile* file; // iterate through each token - while (token[0] != 0) - { - char *nextToken = token_split(token); + while (token[0] != 0) { + char* nextToken = token_split(token); - if (token[0] == '#') // comment - ignore rest of line + if (token[0] == '#') // comment - ignore rest of line return; - switch (i) - { - case 0: - if (strcmp(token, "file") == 0) - type = OBJ_FILE; - else if (strcmp(token, "filetable") == 0) - type = OBJ_TABLE; - else if (strcmp(token, "null") == 0) - type = OBJ_NULL; - else - util_fatal_error("unknown object type '%s' on line %i", token, lineNum); - break; - case 1: - filename = token; - break; - case 2: - { + switch (i) { + case 0: + if (strcmp(token, "file") == 0) + type = OBJ_FILE; + else if (strcmp(token, "filetable") == 0) + type = OBJ_TABLE; + else if (strcmp(token, "null") == 0) + type = OBJ_NULL; + else + util_fatal_error("unknown object type '%s' on line %i", token, lineNum); + break; + case 1: + filename = token; + break; + case 2: { int n; if (sscanf(token, "align(%i)", &n) == 1) valign = n; else goto junk; - } - break; - default: - junk: - util_fatal_error("junk '%s' on line %i", token, lineNum); - break; + } break; + default: + junk: + util_fatal_error("junk '%s' on line %i", token, lineNum); + break; } token = nextToken; i++; } - if (i == 0) // empty line + if (i == 0) // empty line return; file = new_file(); file->valign = valign; - switch (type) - { - case OBJ_FILE: - if (filename == NULL) - util_fatal_error("no filename specified on line %i", lineNum); - file->type = OBJ_FILE; - file->data = util_read_whole_file(filename, &file->size); - break; - case OBJ_TABLE: - file->type = OBJ_TABLE; - break; - case OBJ_NULL: - file->type = OBJ_NULL; - file->size = 0; - break; + switch (type) { + case OBJ_FILE: + if (filename == NULL) + util_fatal_error("no filename specified on line %i", lineNum); + file->type = OBJ_FILE; + file->data = util_read_whole_file(filename, &file->size); + break; + case OBJ_TABLE: + file->type = OBJ_TABLE; + break; + case OBJ_NULL: + file->type = OBJ_NULL; + file->size = 0; + break; } } -static void parse_list(char *list) -{ - char *line = list; +static void parse_list(char* list) { + char* line = list; int lineNum = 1; // iterate through each line - while (line[0] != 0) - { - char *nextLine = line_split(line); + while (line[0] != 0) { + char* nextLine = line_split(line); parse_line(line, lineNum); @@ -310,8 +275,7 @@ static void parse_list(char *list) } } -static void usage(const char *execName) -{ +static void usage(const char* execName) { printf("usage: %s FILE_LIST OUTPUT_FILE\n" "where FILE_LIST is a list of files to include\n" "and OUTPUT_FILE is the name of the output ROM\n" @@ -319,12 +283,10 @@ static void usage(const char *execName) execName); } -int main(int argc, char **argv) -{ - char *list; +int main(int argc, char** argv) { + char* list; - if (argc != 3) - { + if (argc != 3) { puts("invalid args"); usage(argv[0]); return 1; 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/n64chksum.c b/tools/buildtools/n64chksum.c index 64cfd3aad..add34b029 100644 --- a/tools/buildtools/n64chksum.c +++ b/tools/buildtools/n64chksum.c @@ -6,12 +6,11 @@ #include "n64chksum.h" #include "util.h" -//Based on uCON64's N64 checksum algorithm by Andreas Sterbenz +// Based on uCON64's N64 checksum algorithm by Andreas Sterbenz #define ROL(i, b) (((i) << (b)) | ((i) >> (32 - (b)))) -bool n64chksum_calculate(const uint8_t *romData, int cicType, uint32_t *chksum) -{ +bool n64chksum_calculate(const uint8_t* romData, int cicType, uint32_t* chksum) { unsigned int seed; unsigned int t1, t2, t3, t4, t5, t6; size_t pos; @@ -20,29 +19,27 @@ bool n64chksum_calculate(const uint8_t *romData, int cicType, uint32_t *chksum) const size_t END = START + 0x100000; // determine initial seed - switch (cicType) - { - case 6101: - case 6102: - seed = 0xF8CA4DDC; - break; - case 6103: - seed = 0xA3886759; - break; - case 6105: - seed = 0xDF26F436; - break; - case 6106: - seed = 0x1FEA617A; - break; - default: - return false; // unknown CIC type + switch (cicType) { + case 6101: + case 6102: + seed = 0xF8CA4DDC; + break; + case 6103: + seed = 0xA3886759; + break; + case 6105: + seed = 0xDF26F436; + break; + case 6106: + seed = 0x1FEA617A; + break; + default: + return false; // unknown CIC type } t1 = t2 = t3 = t4 = t5 = t6 = seed; - for (pos = START; pos < END; pos += 4) - { + for (pos = START; pos < END; pos += 4) { unsigned int d = util_read_uint32_be(romData + pos); unsigned int r = ROL(d, (d & 0x1F)); @@ -65,18 +62,13 @@ bool n64chksum_calculate(const uint8_t *romData, int cicType, uint32_t *chksum) t1 += t5 ^ d; } - if (cicType == 6103) - { + if (cicType == 6103) { chksum[0] = (t6 ^ t4) + t3; chksum[1] = (t5 ^ t2) + t1; - } - else if (cicType == 6106) - { + } else if (cicType == 6106) { chksum[0] = (t6 * t4) + t3; chksum[1] = (t5 * t2) + t1; - } - else - { + } else { chksum[0] = t6 ^ t4 ^ t3; chksum[1] = t5 ^ t2 ^ t1; } diff --git a/tools/buildtools/n64chksum.h b/tools/buildtools/n64chksum.h index 0ca13a819..5cea0edc8 100644 --- a/tools/buildtools/n64chksum.h +++ b/tools/buildtools/n64chksum.h @@ -1,6 +1,6 @@ -#ifndef _N64CHKSUM_H_ -#define _N64CHKSUM_H_ +#ifndef N64CHKSUM_H +#define N64CHKSUM_H -bool n64chksum_calculate(const uint8_t *romData, int cicType, uint32_t *chksum); +bool n64chksum_calculate(const uint8_t* romData, int cicType, uint32_t* chksum); #endif 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..01c6b3d84 --- /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..941ac1ffd 100644 --- a/tools/buildtools/util.c +++ b/tools/buildtools/util.c @@ -8,26 +8,24 @@ #include "util.h" // displays an error message and exits -void util_fatal_error(const char *msgfmt, ...) -{ +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 -void *util_read_whole_file(const char *filename, size_t *pSize) -{ - FILE *file = fopen(filename, "rb"); - uint8_t *buffer; +// 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"); + uint8_t* buffer; size_t size; if (file == NULL) @@ -56,30 +54,24 @@ void *util_read_whole_file(const char *filename, size_t *pSize) } // writes data to file -void util_write_whole_file(const char *filename, const void *data, size_t size) -{ - FILE *file = fopen(filename, "wb"); - +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); } -uint32_t util_read_uint32_be(const uint8_t *data) -{ - return data[0] << 24 - | data[1] << 16 - | data[2] << 8 - | data[3] << 0; +uint32_t util_read_uint32_be(const uint8_t* data) { + return data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3] << 0; } // writes a big-endian 32-bit integer -void util_write_uint32_be(uint8_t *data, uint32_t val) -{ +void util_write_uint32_be(uint8_t* data, uint32_t val) { data[0] = val >> 24; data[1] = val >> 16; data[2] = val >> 8; diff --git a/tools/buildtools/util.h b/tools/buildtools/util.h index 8659e6f35..d07340706 100644 --- a/tools/buildtools/util.h +++ b/tools/buildtools/util.h @@ -1,17 +1,24 @@ -#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, ...); -void *util_read_whole_file(const char *filename, size_t *pSize); +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); +void util_write_whole_file(const char* filename, const void* data, size_t size); -uint32_t util_read_uint32_be(const uint8_t *data); +uint32_t util_read_uint32_be(const uint8_t* data); -void util_write_uint32_be(uint8_t *data, uint32_t val); +void util_write_uint32_be(uint8_t* data, uint32_t val); #endif diff --git a/tools/buildtools/yaz0.c b/tools/buildtools/yaz0.c index 5b3156e44..346b37e79 100644 --- a/tools/buildtools/yaz0.c +++ b/tools/buildtools/yaz0.c @@ -10,31 +10,25 @@ // src points to the yaz0 source data (to the "real" source data, not at the header!) // dst points to a buffer uncompressedSize bytes large (you get uncompressedSize from // the second 4 bytes in the Yaz0 header). -void yaz0_decode(uint8_t* src, uint8_t* dst, int uncompressedSize) -{ - int srcPlace = 0, dstPlace = 0; // current read/write positions +void yaz0_decode(uint8_t* src, uint8_t* dst, int uncompressedSize) { + int srcPlace = 0, dstPlace = 0; // current read/write positions - unsigned int validBitCount = 0; // number of valid bits left in "code" byte + unsigned int validBitCount = 0; // number of valid bits left in "code" byte uint8_t currCodeByte; - while (dstPlace < uncompressedSize) - { + while (dstPlace < uncompressedSize) { // read new "code" byte if the current one is used up - if (validBitCount == 0) - { + if (validBitCount == 0) { currCodeByte = src[srcPlace]; ++srcPlace; validBitCount = 8; } - if ((currCodeByte & 0x80) != 0) - { + if ((currCodeByte & 0x80) != 0) { // straight copy dst[dstPlace] = src[srcPlace]; dstPlace++; srcPlace++; - } - else - { + } else { // RLE part uint8_t byte1 = src[srcPlace]; uint8_t byte2 = src[srcPlace + 1]; @@ -44,19 +38,15 @@ void yaz0_decode(uint8_t* src, uint8_t* dst, int uncompressedSize) unsigned int copySource = dstPlace - (dist + 1); unsigned int numBytes = byte1 >> 4; - if (numBytes == 0) - { + if (numBytes == 0) { numBytes = src[srcPlace] + 0x12; srcPlace++; - } - else - { + } else { numBytes += 2; } // copy run - for (unsigned int i = 0; i < numBytes; ++i) - { + for (unsigned int i = 0; i < numBytes; ++i) { dst[dstPlace] = dst[copySource]; copySource++; dstPlace++; @@ -77,8 +67,7 @@ typedef uint8_t uint8_t; #define MAX_RUNLEN (0xFF + 0x12) // simple and straight encoding scheme for Yaz0 -static uint32_t simpleEnc(uint8_t *src, int size, int pos, uint32_t *pMatchPos) -{ +static uint32_t simpleEnc(uint8_t* src, int size, int pos, uint32_t* pMatchPos) { int numBytes = 1; int matchPos = 0; @@ -92,17 +81,14 @@ static uint32_t simpleEnc(uint8_t *src, int size, int pos, uint32_t *pMatchPos) if (end > MAX_RUNLEN) end = MAX_RUNLEN; - for (int i = startPos; i < pos; i++) - { + for (int i = startPos; i < pos; i++) { int j; - for (j = 0; j < end; j++) - { + for (j = 0; j < end; j++) { if (src[i + j] != src[j + pos]) break; } - if (j > numBytes) - { + if (j > numBytes) { numBytes = j; matchPos = i; } @@ -117,8 +103,7 @@ static uint32_t simpleEnc(uint8_t *src, int size, int pos, uint32_t *pMatchPos) } // a lookahead encoding scheme for ngc Yaz0 -static uint32_t nintendoEnc(uint8_t *src, int size, int pos, uint32_t *pMatchPos) -{ +static uint32_t nintendoEnc(uint8_t* src, int size, int pos, uint32_t* pMatchPos) { uint32_t numBytes = 1; static uint32_t numBytes1; static uint32_t matchPos; @@ -128,8 +113,7 @@ static uint32_t nintendoEnc(uint8_t *src, int size, int pos, uint32_t *pMatchPos // was determined by look-ahead try. // so just use it. this is not the best optimization, // but nintendo's choice for speed. - if (prevFlag == 1) - { + if (prevFlag == 1) { *pMatchPos = matchPos; prevFlag = 0; return numBytes1; @@ -140,13 +124,11 @@ static uint32_t nintendoEnc(uint8_t *src, int size, int pos, uint32_t *pMatchPos *pMatchPos = matchPos; // if this position is RLE encoded, then compare to copying 1 byte and next position(pos+1) encoding - if (numBytes >= 3) - { + if (numBytes >= 3) { numBytes1 = simpleEnc(src, size, pos + 1, &matchPos); // if the next position encoding is +2 longer than current position, choose it. // this does not guarantee the best optimization, but fairly good optimization with speed. - if (numBytes1 >= numBytes + 2) - { + if (numBytes1 >= numBytes + 2) { numBytes = 1; prevFlag = 1; } @@ -154,8 +136,7 @@ static uint32_t nintendoEnc(uint8_t *src, int size, int pos, uint32_t *pMatchPos return numBytes; } -int yaz0_encode(uint8_t *src, uint8_t *dst, int srcSize) -{ +int yaz0_encode(uint8_t* src, uint8_t* dst, int srcSize) { int srcPos = 0; int dstPos = 0; int bufPos = 0; @@ -163,30 +144,26 @@ int yaz0_encode(uint8_t *src, uint8_t *dst, int srcSize) uint8_t buf[24]; // 8 codes * 3 bytes maximum uint32_t validBitCount = 0; // number of valid bits left in "code" byte - uint8_t currCodeByte = 0; // a bitfield, set bits meaning copy, unset meaning RLE + uint8_t currCodeByte = 0; // a bitfield, set bits meaning copy, unset meaning RLE - while (srcPos < srcSize) - { + while (srcPos < srcSize) { uint32_t numBytes; uint32_t matchPos; numBytes = nintendoEnc(src, srcSize, srcPos, &matchPos); - if (numBytes < 3) - { + if (numBytes < 3) { // straight copy buf[bufPos] = src[srcPos]; bufPos++; srcPos++; - //set flag for straight copy + // set flag for straight copy currCodeByte |= (0x80 >> validBitCount); - } - else - { - //RLE part + } else { + // RLE part uint32_t dist = srcPos - matchPos - 1; uint8_t byte1, byte2, byte3; - if (numBytes >= 0x12) // 3 byte encoding + if (numBytes >= 0x12) // 3 byte encoding { byte1 = 0 | (dist >> 8); byte2 = dist & 0xFF; @@ -197,8 +174,7 @@ int yaz0_encode(uint8_t *src, uint8_t *dst, int srcSize) numBytes = MAX_RUNLEN; byte3 = numBytes - 0x12; buf[bufPos++] = byte3; - } - else // 2 byte encoding + } else // 2 byte encoding { byte1 = ((numBytes - 2) << 4) | (dist >> 8); byte2 = dist & 0xFF; @@ -211,8 +187,7 @@ int yaz0_encode(uint8_t *src, uint8_t *dst, int srcSize) validBitCount++; // write eight codes - if (validBitCount == 8) - { + if (validBitCount == 8) { dst[dstPos++] = currCodeByte; for (int j = 0; j < bufPos; j++) dst[dstPos++] = buf[j]; @@ -223,8 +198,7 @@ int yaz0_encode(uint8_t *src, uint8_t *dst, int srcSize) } } - if (validBitCount > 0) - { + if (validBitCount > 0) { dst[dstPos++] = currCodeByte; for (int j = 0; j < bufPos; j++) dst[dstPos++] = buf[j]; diff --git a/tools/buildtools/yaz0.h b/tools/buildtools/yaz0.h index 0cc3703ec..97656aac5 100644 --- a/tools/buildtools/yaz0.h +++ b/tools/buildtools/yaz0.h @@ -1,10 +1,10 @@ -#ifndef _YAZ0_H_ -#define _YAZ0_H_ +#ifndef YAZ0_H +#define YAZ0_H -int yaz0_encode2(uint8_t *src, uint8_t *dest, int uncompressedSize); +int yaz0_encode2(uint8_t* src, uint8_t* dest, int uncompressedSize); void yaz0_decode(uint8_t* src, uint8_t* dst, int uncompressedSize); -int yaz0_encode(uint8_t *src, uint8_t *dest, int srcSize); +int yaz0_encode(uint8_t* src, uint8_t* dest, int srcSize); -#endif // _YAZ0_H_ +#endif // YAZ0_H diff --git a/tools/check_format.sh b/tools/check_format.sh index d8119e743..1195a9c59 100755 --- a/tools/check_format.sh +++ b/tools/check_format.sh @@ -1,7 +1,7 @@ #!/bin/bash STATUSOLD=`git status --porcelain` -./format.sh +./format.py -j if [ $? -ne 0 ] then echo "Formatter failed. Exiting." @@ -12,7 +12,7 @@ STATUSNEW=`git status --porcelain` if [ "${STATUSOLD}" != "${STATUSNEW}" ]; then echo "" - echo "Misformatted files found. Run ./format.sh and verify codegen is not impacted." + echo "Misformatted files found. Run ./format.py and verify codegen is not impacted." echo "" diff --unified=0 --label "Old git status" <(echo "${STATUSOLD}") --label "New git status" <(echo "${STATUSNEW}") echo "" 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/dma_filenames.txt b/tools/disasm/dma_filenames.txt index e9a743615..aaa17ab6d 100644 --- a/tools/disasm/dma_filenames.txt +++ b/tools/disasm/dma_filenames.txt @@ -885,7 +885,7 @@ 'object_fall', 'object_hanareyama_obj', 'object_crace_object', - 'object_dnq', + 'object_dno', 'object_obj_tokeidai', 'object_eg', 'object_tru', @@ -956,7 +956,7 @@ 'object_maruta', 'object_ghaka', 'object_oyu', - 'object_dnp', + 'object_dnq', 'object_dai', 'object_kgy', 'object_fb', @@ -977,7 +977,7 @@ 'object_gi_seahorse', 'object_bigpo', 'object_hariko', - 'object_dno', + 'object_dnj', 'object_sinkai_kabe', 'object_kin2_obj', 'object_ishi', diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index d8cd09c99..340a773d6 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -425,9 +425,10 @@ 0x80138BA0 : "z_skin_matrix", 0x8013A240 : "z_snap", 0x8013A7C0 : "z_sub_s", - 0x8013EC10 : "code_8013EC10", + 0x8013EC10 : "z_rumble", 0x8013EE60 : "z_view", 0x80140260 : "z_vimode", + 0x80140CE0 : "code_80140CE0", 0x80140E80 : "code_80140E80", 0x801418B0 : "z_vismono", 0x801420C0 : "code_801420C0", @@ -464,6 +465,7 @@ 0x80174F10 : "padmgr", 0x80176280 : "sched", 0x80177390 : "speed_meter", + 0x801780F0 : "su_mtx", 0x80178750 : "sys_cmpdma", 0x80178F30 : "sys_initial_check", 0x80179300 : "sys_math", @@ -471,7 +473,7 @@ 0x8017FEB0 : "sys_math_atan", 0x80180160 : "sys_matrix", 0x80182C90 : "sys_ucode", - 0x80182CE0 : "", + 0x80182CE0 : "sys_rumble", 0x80183070 : "code_80183070", 0x801830A0 : "c_keyframe", 0x80185660 : "sys_slowly", @@ -482,9 +484,9 @@ 0x801877D0 : "audio_synthesis", 0x8018B0F0 : "audio_heap", 0x8018EB60 : "audio_load", - 0x80192BE0 : "code_80192BE0", + 0x80192BE0 : "audio_thread", 0x80194710 : "audio_dcache", - 0x80194790 : "code_80194790", + 0x80194790 : "aisetnextbuf", 0x80194930 : "audio_playback", 0x80196A00 : "audio_effects", 0x801974D0 : "audio_seqplayer", @@ -506,7 +508,7 @@ 0x801AAAB0 : "aspMain", 0x801ABAB0 : "gspS2DEX2.fifo", 0x801AD370 : "njpgdspMain", - 0x801ADE60 : "", + 0x801ADE60 : "z_en_a_keep", 0x801ADEC0 : "z_en_item00", 0x801AE240 : "z_eff_blure", 0x801AE2F0 : "z_eff_shield_particle", @@ -526,7 +528,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 +546,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", @@ -558,7 +560,7 @@ 0x801C5CB0 : "z_skelanime", 0x801C5CD0 : "z_skin_matrix", 0x801C5D10 : "z_sub_s", - 0x801C5DD0 : "z_vimode", + 0x801C5DD0 : "code_80140CE0", 0x801C5E30 : "z_vr_box", 0x801C5FC0 : "z_sram_NES", 0x801C6A70 : "z_message", @@ -581,12 +583,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", + 0x801D5FF0 : "audio_thread", + 0x801D6010 : "aisetnextbuf", 0x801D6190 : "audio_effects", 0x801D61A0 : "audio_seqplayer", 0x801D6200 : "audio_dramStack", @@ -596,6 +599,7 @@ 0x801D9090 : "audio_sound_params", 0x801DB470 : "code_801A5BD0", 0x801DB4C0 : "code_801A7B10", + 0x801DB4E0 : "audio_init_params", # .rodata section 0x801DBDF0 : "z_en_item00", @@ -638,7 +642,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", @@ -668,7 +672,7 @@ 0x801E0280 : "audio_synthesis", 0x801E02B0 : "audio_heap", 0x801E0300 : "audio_load", - 0x801E0390 : "code_80192BE0", + 0x801E0390 : "audio_thread", 0x801E04E0 : "audio_playback", 0x801E0510 : "audio_effects", 0x801E0540 : "audio_seqplayer", @@ -711,7 +715,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 bdb5188e3..633b73c48 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",), @@ -486,8 +486,8 @@ 0x80096930:("__osMemcpy",), 0x800A5AC0:("EnAObj_Init",), 0x800A5B6C:("EnAObj_Destroy",), - 0x800A5B98:("EnAObj_Update1",), - 0x800A5C28:("EnAObj_Update2",), + 0x800A5B98:("EnAObj_Idle",), + 0x800A5C28:("EnAObj_Talk",), 0x800A5C60:("EnAObj_Update",), 0x800A5CB8:("EnAObj_Draw",), 0x800A5D00:("EnItem00_SetObject",), @@ -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",), @@ -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",), @@ -703,7 +703,7 @@ 0x800B6584:("func_800B6584",), 0x800B6608:("func_800B6608",), 0x800B6680:("func_800B6680",), - 0x800B670C:("Actor_MarkForDeath",), + 0x800B670C:("Actor_Kill",), 0x800B672C:("Actor_SetWorldToHome",), 0x800B675C:("Actor_SetFocus",), 0x800B67A0:("Actor_SetWorldRotToShape",), @@ -754,7 +754,7 @@ 0x800B742C:("Actor_ActorAIsFacingActorB",), 0x800B748C:("Actor_IsFacingAndNearPlayer",), 0x800B750C:("Actor_ActorAIsFacingAndNearActorB",), - 0x800B75A0:("func_800B75A0",), + 0x800B75A0:("Actor_GetSlopeDirection",), 0x800B761C:("func_800B761C",), 0x800B7678:("func_800B7678",), 0x800B78B8:("Actor_UpdateBgCheckInfo",), @@ -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",), @@ -811,7 +811,7 @@ 0x800B9084:("func_800B9084",), 0x800B9098:("func_800B9098",), 0x800B90AC:("func_800B90AC",), - 0x800B90F4:("func_800B90F4",), + 0x800B90F4:("Actor_DeactivateLens",), 0x800B9120:("func_800B9120",), 0x800B9170:("Actor_InitContext",), 0x800B9334:("Actor_SpawnSetupActors",), @@ -821,8 +821,8 @@ 0x800B9D1C:("func_800B9D1C",), 0x800B9E3C:("Actor_DrawAllSetup",), 0x800B9E4C:("Actor_RecordUndrawnActor",), - 0x800B9E84:("func_800B9E84",), - 0x800B9EF4:("func_800B9EF4",), + 0x800B9E84:("Actor_DrawLensOverlay",), + 0x800B9EF4:("Actor_DrawLensActors",), 0x800BA2D8:("func_800BA2D8",), 0x800BA2FC:("func_800BA2FC",), 0x800BA42C:("Actor_DrawAll",), @@ -859,8 +859,8 @@ 0x800BC5B8:("Actor_IsTargeted",), 0x800BC5EC:("Actor_OtherIsTargeted",), 0x800BC620:("func_800BC620",), - 0x800BC770:("func_800BC770",), - 0x800BC7D8:("func_800BC7D8",), + 0x800BC770:("Actor_AddQuake",), + 0x800BC7D8:("Actor_AddQuakeWithSpeed",), 0x800BC848:("func_800BC848",), 0x800BC8B8:("Actor_DrawDoorLock",), 0x800BCB50:("Actor_SpawnShieldParticlesMetal",), @@ -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",), @@ -1075,7 +1075,7 @@ 0x800C9CEC:("SurfaceType_IsHookshotSurface",), 0x800C9D14:("SurfaceType_IsIgnoredByEntities",), 0x800C9D50:("SurfaceType_IsIgnoredByProjectiles",), - 0x800C9D8C:("SurfaceType_GetConveyorType",), + 0x800C9D8C:("SurfaceType_IsFloorConveyor",), 0x800C9DDC:("func_800C9DDC",), 0x800C9E18:("SurfaceType_GetConveyorSpeed",), 0x800C9E40:("SurfaceType_GetConveyorDirection",), @@ -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",), @@ -1182,84 +1182,84 @@ 0x800CEAD8:("func_800CEAD8",), 0x800CEC38:("func_800CEC38",), 0x800CED90:("func_800CED90",), - 0x800CF3A4:("Camera_ModeNop",), - 0x800CF3B4:("Camera_ModeNORM1",), - 0x800D0874:("Camera_ModeNORM2",), - 0x800D0894:("Camera_ModeNORM3",), - 0x800D1228:("Camera_ModeNORM4",), - 0x800D12B8:("Camera_ModeNORM0",), - 0x800D1A78:("Camera_ModePARA1",), - 0x800D2AA8:("Camera_ModePARA2",), - 0x800D2AC8:("Camera_ModePARA3",), - 0x800D2AE8:("Camera_ModePARA4",), - 0x800D2B08:("Camera_ModePARA0",), - 0x800D2B28:("Camera_ModeJUMP1",), - 0x800D2B48:("Camera_ModeJUMP2",), - 0x800D3520:("Camera_ModeJUMP3",), - 0x800D41E0:("Camera_ModeJUMP4",), - 0x800D4200:("Camera_ModeJUMP0",), - 0x800D4220:("Camera_ModeBATT1",), - 0x800D55A8:("Camera_ModeBATT2",), - 0x800D55C8:("Camera_ModeBATT3",), - 0x800D55E8:("Camera_ModeBATT4",), - 0x800D5608:("Camera_ModeBATT0",), - 0x800D5628:("Camera_ModeKEEP1",), - 0x800D67DC:("Camera_ModeKEEP2",), - 0x800D67FC:("Camera_ModeKEEP3",), - 0x800D73C8:("Camera_ModeKEEP4",), - 0x800D7FA4:("Camera_ModeKEEP0",), - 0x800D7FC4:("Camera_ModeFIXD1",), - 0x800D83C8:("Camera_ModeFIXD2",), - 0x800D8E08:("Camera_ModeFIXD3",), - 0x800D8E28:("Camera_ModeFIXD4",), - 0x800D8E48:("Camera_ModeFIXD0",), - 0x800D8E68:("Camera_ModeSUBJ1",), - 0x800D947C:("Camera_ModeSUBJ2",), - 0x800D949C:("Camera_ModeSUBJ3",), - 0x800D94BC:("Camera_ModeSUBJ4",), - 0x800D94DC:("Camera_ModeSUBJ0",), - 0x800D94FC:("Camera_ModeDATA0",), - 0x800D951C:("Camera_ModeDATA1",), - 0x800D953C:("Camera_ModeDATA2",), - 0x800D955C:("Camera_ModeDATA3",), - 0x800D957C:("Camera_ModeDATA4",), - 0x800D959C:("Camera_ModeUNIQ1",), - 0x800D95BC:("Camera_ModeUNIQ2",), - 0x800D99D0:("Camera_ModeUNIQ3",), - 0x800D9A2C:("Camera_ModeUNIQ4",), - 0x800D9A88:("Camera_ModeUNIQ5",), - 0x800D9AE4:("Camera_ModeUNIQ0",), - 0x800DA3B8:("Camera_ModeUNIQ6",), - 0x800DA4EC:("Camera_ModeUNIQ7",), - 0x800DA50C:("Camera_ModeUNIQ8",), - 0x800DA52C:("Camera_ModeUNIQ9",), - 0x800DA54C:("Camera_ModeDEMO1",), - 0x800DAD10:("Camera_ModeDEMO2",), - 0x800DB804:("Camera_ModeDEMO3",), - 0x800DBB14:("Camera_ModeDEMO4",), - 0x800DC270:("Camera_ModeDEMO5",), - 0x800DC718:("Camera_ModeDEMO6",), - 0x800DC738:("Camera_ModeDEMO7",), - 0x800DC758:("Camera_ModeDEMO8",), - 0x800DC778:("Camera_ModeDEMO9",), - 0x800DC798:("Camera_ModeDEMO0",), - 0x800DCC90:("Camera_ModeSPEC0",), - 0x800DCCB0:("Camera_ModeSPEC1",), - 0x800DCCD0:("Camera_ModeSPEC2",), - 0x800DCCF0:("Camera_ModeSPEC3",), - 0x800DCD10:("Camera_ModeSPEC4",), - 0x800DCD30:("Camera_ModeSPEC5",), - 0x800DD0FC:("Camera_ModeSPEC6",), - 0x800DD11C:("Camera_ModeSPEC7",), - 0x800DD13C:("Camera_ModeSPEC8",), - 0x800DD5B8:("Camera_ModeSPEC9",), + 0x800CF3A4:("Camera_Noop",), + 0x800CF3B4:("Camera_Normal1",), + 0x800D0874:("Camera_Normal2",), + 0x800D0894:("Camera_Normal3",), + 0x800D1228:("Camera_Normal4",), + 0x800D12B8:("Camera_Normal0",), + 0x800D1A78:("Camera_Parallel1",), + 0x800D2AA8:("Camera_Parallel2",), + 0x800D2AC8:("Camera_Parallel3",), + 0x800D2AE8:("Camera_Parallel4",), + 0x800D2B08:("Camera_Parallel0",), + 0x800D2B28:("Camera_Jump1",), + 0x800D2B48:("Camera_Jump2",), + 0x800D3520:("Camera_Jump3",), + 0x800D41E0:("Camera_Jump4",), + 0x800D4200:("Camera_Jump0",), + 0x800D4220:("Camera_Battle1",), + 0x800D55A8:("Camera_Battle2",), + 0x800D55C8:("Camera_Battle3",), + 0x800D55E8:("Camera_Battle4",), + 0x800D5608:("Camera_Battle0",), + 0x800D5628:("Camera_KeepOn1",), + 0x800D67DC:("Camera_KeepOn2",), + 0x800D67FC:("Camera_KeepOn3",), + 0x800D73C8:("Camera_KeepOn4",), + 0x800D7FA4:("Camera_KeepOn0",), + 0x800D7FC4:("Camera_Fixed1",), + 0x800D83C8:("Camera_Fixed2",), + 0x800D8E08:("Camera_Fixed3",), + 0x800D8E28:("Camera_Fixed4",), + 0x800D8E48:("Camera_Fixed0",), + 0x800D8E68:("Camera_Subject1",), + 0x800D947C:("Camera_Subject2",), + 0x800D949C:("Camera_Subject3",), + 0x800D94BC:("Camera_Subject4",), + 0x800D94DC:("Camera_Subject0",), + 0x800D94FC:("Camera_Data0",), + 0x800D951C:("Camera_Data1",), + 0x800D953C:("Camera_Data2",), + 0x800D955C:("Camera_Data3",), + 0x800D957C:("Camera_Data4",), + 0x800D959C:("Camera_Unique1",), + 0x800D95BC:("Camera_Unique2",), + 0x800D99D0:("Camera_Unique3",), + 0x800D9A2C:("Camera_Unique4",), + 0x800D9A88:("Camera_Unique5",), + 0x800D9AE4:("Camera_Unique0",), + 0x800DA3B8:("Camera_Unique6",), + 0x800DA4EC:("Camera_Unique7",), + 0x800DA50C:("Camera_Unique8",), + 0x800DA52C:("Camera_Unique9",), + 0x800DA54C:("Camera_Demo1",), + 0x800DAD10:("Camera_Demo2",), + 0x800DB804:("Camera_Demo3",), + 0x800DBB14:("Camera_Demo4",), + 0x800DC270:("Camera_Demo5",), + 0x800DC718:("Camera_Demo6",), + 0x800DC738:("Camera_Demo7",), + 0x800DC758:("Camera_Demo8",), + 0x800DC778:("Camera_Demo9",), + 0x800DC798:("Camera_Demo0",), + 0x800DCC90:("Camera_Special0",), + 0x800DCCB0:("Camera_Special1",), + 0x800DCCD0:("Camera_Special2",), + 0x800DCCF0:("Camera_Special3",), + 0x800DCD10:("Camera_Special4",), + 0x800DCD30:("Camera_Special5",), + 0x800DD0FC:("Camera_Special6",), + 0x800DD11C:("Camera_Special7",), + 0x800DD13C:("Camera_Special8",), + 0x800DD5B8:("Camera_Special9",), 0x800DDD58:("Camera_Alloc",), 0x800DDDA8:("Camera_Free",), 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",), @@ -1525,8 +1525,8 @@ 0x800E9564:("DebugDisplay_DrawObjects",), 0x800E95F4:("DebugDisplay_DrawSpriteI8",), 0x800E97D8:("DebugDisplay_DrawPolygon",), - 0x800E992C:("func_800E992C",), - 0x800E99B0:("func_800E99B0",), + 0x800E992C:("DebugDisplay_DrawPath",), + 0x800E99B0:("DebugDisplay_PathDisplayList",), 0x800E9C90:("func_800E9C90",), 0x800E9CA0:("func_800E9CA0",), 0x800E9CFC:("func_800E9CFC",), @@ -1578,34 +1578,34 @@ 0x800EDF24:("Cutscene_ActorTranslateAndYaw",), 0x800EDF78:("Cutscene_ActorTranslateAndYawSmooth",), 0x800EE0CC:("Cutscene_ActorTranslateXZAndYawSmooth",), - 0x800EE1D8:("Cutscene_GetSceneSetupIndex",), + 0x800EE1D8:("Cutscene_GetSceneLayer",), 0x800EE200:("Cutscene_GetActorActionIndex",), 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",), @@ -1615,7 +1615,7 @@ 0x800F048C:("SoundSource_Add",), 0x800F0568:("SoundSource_PlaySfxAtFixedWorldPos",), 0x800F0590:("SoundSource_PlaySfxEachFrameAtFixedWorldPos",), - 0x800F05C0:("ElfMessage_GetFirstCycleHint",), + 0x800F05C0:("QuestHint_GetTatlTextId",), 0x800F07C0:("EnHy_ChangeAnim",), 0x800F0888:("EnHy_FindNearestDoor",), 0x800F0944:("EnHy_ChangeObjectAndAnim",), @@ -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",), @@ -1768,9 +1768,9 @@ 0x800FDC94:("func_800FDC94",), 0x800FE390:("func_800FE390",), 0x800FE3E0:("func_800FE3E0",), - 0x800FE484:("func_800FE484",), - 0x800FE498:("func_800FE498",), - 0x800FE4A8:("func_800FE4A8",), + 0x800FE484:("Environment_StopTime",), + 0x800FE498:("Environment_StartTime",), + 0x800FE4A8:("Environment_IsTimeStopped",), 0x800FE4B8:("func_800FE4B8",), 0x800FE590:("func_800FE590",), 0x800FE5D0:("func_800FE5D0",), @@ -1854,8 +1854,8 @@ 0x801004FC:("Lib_Nop801004FC",), 0x80100504:("Lib_SegmentedToVirtual",), 0x8010053C:("Lib_SegmentedToVirtualNull",), - 0x80100584:("Lib_PhysicalToVirtual",), - 0x801005A0:("Lib_PhysicalToVirtualNull",), + 0x80100584:("Lib_VirtualToPhysical",), + 0x801005A0:("Lib_PhysicalToVirtual",), 0x801005C0:("LifeMeter_Init",), 0x8010069C:("LifeMeter_UpdateColors",), 0x80100A80:("func_80100A80",), @@ -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",), @@ -2083,64 +2083,64 @@ 0x8010C930:("OLib_Vec3fDiffBinAng",), 0x8010C9C8:("OLib_DbCameraVec3fDiff",), 0x8010CAA0:("OLib_DbCameraVec3fSum",), - 0x8010CB80:("func_8010CB80",), - 0x8010CD98:("func_8010CD98",), - 0x8010CFBC:("func_8010CFBC",), - 0x8010D2D4:("func_8010D2D4",), - 0x8010D480:("func_8010D480",), - 0x8010D7D0:("func_8010D7D0",), - 0x8010D9F4:("func_8010D9F4",), - 0x8010DC58:("func_8010DC58",), - 0x8010DE38:("func_8010DE38",), - 0x8010E028:("func_8010E028",), - 0x8010E968:("func_8010E968",), - 0x8010E9F0:("func_8010E9F0",), - 0x8010EA9C:("func_8010EA9C",), - 0x8010EB50:("func_8010EB50",), - 0x8010EBA0:("func_8010EBA0",), - 0x8010EC54:("func_8010EC54",), - 0x8010EE74:("func_8010EE74",), - 0x8010EF68:("Interface_ChangeAlpha",), - 0x8010EF9C:("func_8010EF9C",), - 0x8010F0D4:("func_8010F0D4",), - 0x8010F1A8:("func_8010F1A8",), + 0x8010CB80:("Gfx_DrawTexRectRGBA16",), + 0x8010CD98:("Gfx_DrawTexRectIA8",), + 0x8010CFBC:("Gfx_DrawTexRectIA8_DropShadow",), + 0x8010D2D4:("Gfx_DrawRect_DropShadow",), + 0x8010D480:("Gfx_DrawTexRectIA8_DropShadowOffset",), + 0x8010D7D0:("Gfx_DrawTexRectI8",), + 0x8010D9F4:("Gfx_DrawTexRect4b",), + 0x8010DC58:("Gfx_DrawTexQuadIA8",), + 0x8010DE38:("Gfx_DrawTexQuad4b",), + 0x8010E028:("Interface_SetVertices",), + 0x8010E968:("Interface_PostmanTimerCallback",), + 0x8010E9F0:("Interface_StartTimer",), + 0x8010EA9C:("Interface_StartPostmanTimer",), + 0x8010EB50:("Interface_StartGoronRaceTimer",), + 0x8010EBA0:("Interface_StartBottleTimer",), + 0x8010EC54:("Interface_GetCompressedTimerDigits",), + 0x8010EE74:("Interface_NewDay",), + 0x8010EF68:("Interface_SetHudVisibility",), + 0x8010EF9C:("Interface_UpdateButtonAlphasByStatus",), + 0x8010F0D4:("Interface_UpdateButtonAlphas",), + 0x8010F1A8:("Interface_UpdateHudAlphas",), 0x80110038:("func_80110038",), 0x80111CB4:("func_80111CB4",), - 0x801129E4:("func_801129E4",), - 0x80112AF4:("func_80112AF4",), - 0x80112AFC:("func_80112AFC",), - 0x80112B40:("func_80112B40",), - 0x80112BE4:("func_80112BE4",), + 0x801129E4:("Interface_SetSceneRestrictions",), + 0x80112AF4:("Interface_Noop",), + 0x80112AFC:("Interface_InitMinigame",), + 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",), - 0x80115D14:("Parameter_AddMagic",), - 0x80115D5C:("func_80115D5C",), - 0x80115DB4:("func_80115DB4",), - 0x80116088:("func_80116088",), - 0x80116114:("func_80116114",), - 0x80116348:("func_80116348",), - 0x80116918:("func_80116918",), + 0x80115908:("Health_ChangeBy",), + 0x801159C0:("Health_GiveHearts",), + 0x801159EC:("Rupees_ChangeBy",), + 0x80115A14:("Inventory_ChangeAmmo",), + 0x80115D14:("Magic_Add",), + 0x80115D5C:("Magic_Reset",), + 0x80115DB4:("Magic_Consume",), + 0x80116088:("Magic_UpdateAddRequest",), + 0x80116114:("Magic_FlashMeterBorder",), + 0x80116348:("Magic_Update",), + 0x80116918:("Magic_DrawMeter",), 0x80116FD8:("func_80116FD8",), 0x801170B8:("func_801170B8",), 0x80117100:("func_80117100",), @@ -2150,23 +2150,23 @@ 0x80118890:("func_80118890",), 0x80118BA4:("func_80118BA4",), 0x80119030:("func_80119030",), - 0x80119610:("func_80119610",), - 0x8011B4E0:("func_8011B4E0",), - 0x8011B5C0:("func_8011B5C0",), - 0x8011B9E0:("func_8011B9E0",), - 0x8011BF70:("func_8011BF70",), - 0x8011C4C4:("func_8011C4C4",), - 0x8011C808:("func_8011C808",), - 0x8011C898:("func_8011C898",), - 0x8011CA64:("func_8011CA64",), - 0x8011E3B4:("func_8011E3B4",), - 0x8011E730:("func_8011E730",), - 0x8011F0E0:("func_8011F0E0",), - 0x80120F90:("func_80120F90",), - 0x80121064:("func_80121064",), - 0x801210E0:("func_801210E0",), - 0x80121F94:("func_80121F94",), - 0x80121FC4:("func_80121FC4",), + 0x80119610:("Interface_DrawClock",), + 0x8011B4E0:("Interface_SetPerfectLetters",), + 0x8011B5C0:("Interface_UpdatePerfectLettersType1",), + 0x8011B9E0:("Interface_UpdatePerfectLettersType2",), + 0x8011BF70:("Interface_UpdatePerfectLettersType3",), + 0x8011C4C4:("Interface_DrawPerfectLetters",), + 0x8011C808:("Interface_StartMoonCrash",), + 0x8011C898:("Interface_GetTimerDigits",), + 0x8011CA64:("Interface_DrawTimers",), + 0x8011E3B4:("Interface_UpdateBottleTimers",), + 0x8011E730:("Interface_DrawMinigameIcons",), + 0x8011F0E0:("Interface_Draw",), + 0x80120F90:("Interface_LoadStory",), + 0x80121064:("Interface_AllocStory",), + 0x801210E0:("Interface_Update",), + 0x80121F94:("Interface_Destroy",), + 0x80121FC4:("Interface_Init",), 0x801224E0:("Path_GetByIndex",), 0x80122524:("Path_OrientAndGetDistSq",), 0x801225CC:("Path_CopyLastPoint",), @@ -2182,60 +2182,60 @@ 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",), - 0x801239AC:("func_801239AC",), - 0x80123AA4:("func_80123AA4",), - 0x80123BD4:("func_80123BD4",), + 0x80123960:("Player_ActionToModelGroup",), + 0x801239AC:("Player_SetModelsForHoldingShield",), + 0x80123AA4:("Player_SetModels",), + 0x80123BD4:("Player_SetModelGroup",), 0x80123C58:("func_80123C58",), 0x80123C90:("Player_SetEquipmentData",), - 0x80123D50:("func_80123D50",), + 0x80123D50:("Player_UpdateBottleHeld",), 0x80123DA4:("func_80123DA4",), 0x80123DC0:("func_80123DC0",), 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",), + 0x80124278:("Player_ActionToSword",), 0x801242B4:("func_801242B4",), - 0x801242DC:("func_801242DC",), + 0x801242DC:("Player_GetEnvironmentalHazard",), 0x80124420:("func_80124420",), 0x80124618:("func_80124618",), - 0x801246F4:("func_801246F4",), + 0x801246F4:("Player_DrawImpl",), 0x80124870:("func_80124870",), 0x80124CC4:("func_80124CC4",), 0x80124F18:("func_80124F18",), @@ -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,23 +2254,23 @@ 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",), - 0x80127594:("func_80127594",), - 0x801278F8:("func_801278F8",), - 0x80127A60:("func_80127A60",), + 0x8012754C:("Player_DrawCouplesMask",), + 0x80127594:("Player_DrawCircusLeadersMask",), + 0x801278F8:("Player_DrawBlastMask",), + 0x80127A60:("Player_DrawBunnyHood",), 0x80127B64:("func_80127B64",), 0x80127BE8:("func_80127BE8",), 0x80127DA4:("func_80127DA4",), 0x80128388:("func_80128388",), - 0x801284A0:("func_801284A0",), + 0x801284A0:("Player_DrawGreatFairysMask",), 0x80128640:("func_80128640",), 0x80128B74:("func_80128B74",), 0x80128BD0:("func_80128BD0",), @@ -2282,15 +2282,15 @@ 0x8012A038:("PreNMI_Init",), 0x8012A080:("Quake_Random",), 0x8012A0AC:("Quake_UpdateShakeInfo",), - 0x8012A2B8:("Quake_Callback1",), - 0x8012A340:("Quake_Callback5",), - 0x8012A3B4:("Quake_Callback6",), - 0x8012A438:("Quake_Callback3",), - 0x8012A4D0:("Quake_Callback2",), - 0x8012A540:("Quake_Callback4",), + 0x8012A2B8:("Quake_CallbackType1",), + 0x8012A340:("Quake_CallbackType5",), + 0x8012A3B4:("Quake_CallbackType6",), + 0x8012A438:("Quake_CallbackType3",), + 0x8012A4D0:("Quake_CallbackType2",), + 0x8012A540:("Quake_CallbackType4",), 0x8012A5D8:("Quake_GetFreeIndex",), 0x8012A638:("Quake_AddImpl",), - 0x8012A6F0:("Quake_Remove",), + 0x8012A6F0:("Quake_RemoveRequest",), 0x8012A718:("Quake_GetRequest",), 0x8012A774:("Quake_SetValue",), 0x8012A8A8:("Quake_SetSpeed",), @@ -2300,7 +2300,7 @@ 0x8012A9E0:("Quake_SetQuakeValues2",), 0x8012AA48:("Quake_Init",), 0x8012AA9C:("Quake_Add",), - 0x8012AAC0:("Quake_RemoveFromIdx",), + 0x8012AAC0:("Quake_Remove",), 0x8012AB08:("Quake_Calc",), 0x8012AE68:("Distortion_Init",), 0x8012AEAC:("Distortion_SetCountdown",), @@ -2410,7 +2410,7 @@ 0x8012ED78:("Inventory_DeleteEquipment",), 0x8012EDE8:("Inventory_ChangeUpgrade",), 0x8012EE34:("Inventory_IsMapVisible",), - 0x8012EF0C:("Inventory_SetMapVisibility",), + 0x8012EF0C:("Inventory_SetWorldMapCloudVisibility",), 0x8012F0EC:("Inventory_SaveDekuPlaygroundHighScore",), 0x8012F1BC:("Inventory_IncrementSkullTokenCount",), 0x8012F22C:("Inventory_GetSkullTokenCount",), @@ -2452,12 +2452,12 @@ 0x80130540:("Scene_HeaderCmdMiniMap",), 0x80130578:("Scene_HeaderCmd1D",), 0x80130588:("Scene_HeaderCmdMiniMapCompassInfo",), - 0x801305B0:("Scene_HeaderCmdSetAreaVisitedFlag",), + 0x801305B0:("Scene_HeaderCmdSetRegionVisitedFlag",), 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",), @@ -2495,8 +2495,8 @@ 0x80131F90:("Scene_DrawConfigMatAnimManualStep",), 0x80131FC0:("Scene_DrawConfigGreatBayTemple",), 0x801322C0:("Entrance_GetTableEntry",), - 0x8013230C:("Entrance_GetSceneNum",), - 0x80132338:("Entrance_GetSceneNumAbsolute",), + 0x8013230C:("Entrance_GetSceneId",), + 0x80132338:("Entrance_GetSceneIdAbsolute",), 0x80132374:("Entrance_GetSpawnNum",), 0x801323A0:("Entrance_GetTransitionFlags",), 0x801323D0:("Schedule_CheckFlagS",), @@ -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:("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:("SubS_FillShadowTex",), 0x8013CD64:("SubS_GenShadowTex",), 0x8013CF04:("SubS_DrawShadowTex",), - 0x8013D0E0:("SubS_ComputeTurnToPointRot",), - 0x8013D2E0:("SubS_TurnToPoint",), + 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",), @@ -2709,45 +2709,45 @@ 0x8013E748:("func_8013E748",), 0x8013E7C0:("SubS_ActorAndPlayerFaceEachOther",), 0x8013E8F8:("func_8013E8F8",), - 0x8013E950:("SubS_TurnToPointStep",), - 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",), - 0x8013F050:("func_8013F050",), + 0x8013EF9C:("View_LookAt",), + 0x8013F050:("View_LookAtUnsafe",), 0x8013F0A0:("View_SetScale",), 0x8013F0C0:("View_GetScale",), - 0x8013F0D0:("func_8013F0D0",), - 0x8013F100:("func_8013F100",), - 0x8013F120:("func_8013F120",), - 0x8013F15C:("func_8013F15C",), + 0x8013F0D0:("View_SetPerspective",), + 0x8013F100:("View_GetPerspective",), + 0x8013F120:("View_SetOrtho",), + 0x8013F15C:("View_GetOrtho",), 0x8013F17C:("View_SetViewport",), 0x8013F1B0:("View_GetViewport",), - 0x8013F1D8:("View_WriteScissor",), - 0x8013F28C:("View_SyncAndWriteScissor",), - 0x8013F2F8:("View_SetScissorForLetterbox",), - 0x8013F3F8:("View_SetDistortionDirRot",), + 0x8013F1D8:("View_SetScissor",), + 0x8013F28C:("View_ClearScissor",), + 0x8013F2F8:("View_ApplyLetterbox",), + 0x8013F3F8:("View_SetDistortionOrientation",), 0x8013F420:("View_SetDistortionScale",), 0x8013F448:("View_SetDistortionSpeed",), 0x8013F45C:("View_InitDistortion",), 0x8013F4C0:("View_ClearDistortion",), 0x8013F4F4:("View_SetDistortion",), 0x8013F54C:("View_StepDistortion",), - 0x8013F6FC:("View_RenderView",), - 0x8013F748:("View_RenderToPerspectiveMatrix",), - 0x8013FA1C:("View_RenderToOrthographicMatrix",), - 0x8013FBC8:("func_8013FBC8",), - 0x8013FD74:("func_8013FD74",), - 0x80140024:("func_80140024",), - 0x801400CC:("func_801400CC",), + 0x8013F6FC:("View_Apply",), + 0x8013F748:("View_ApplyPerspective",), + 0x8013FA1C:("View_ApplyOrtho",), + 0x8013FBC8:("View_ApplyOrthoToOverlay",), + 0x8013FD74:("View_ApplyPerspectiveToOverlay",), + 0x80140024:("View_UpdateViewingMatrix",), + 0x801400CC:("View_ApplyTo",), 0x80140260:("func_80140260",), 0x8014026C:("func_8014026C",), 0x80140730:("func_80140730",), @@ -2769,20 +2769,20 @@ 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",), 0x80142440:("func_80142440",), 0x80143148:("func_80143148",), - 0x801431E8:("func_801431E8",), + 0x801431E8:("Skybox_Setup",), 0x80143324:("func_80143324",), - 0x801434E4:("func_801434E4",), + 0x801434E4:("Skybox_Init",), 0x801435A0:("SkyboxDraw_UpdateMatrix",), 0x80143624:("SkyboxDraw_SetColors",), 0x80143668:("SkyboxDraw_Draw",), @@ -2880,7 +2880,7 @@ 0x80158C04:("Message_LoadLocalizedRupeesNES",), 0x80158D98:("Message_LoadRupeesNES",), 0x80158FB0:("Message_LoadTimeNES",), - 0x8015926C:("Message_LoadAreaTextNES",), + 0x8015926C:("Message_LoadOwlWarpTextNES",), 0x80159438:("func_80159438",), 0x8015966C:("func_8015966C",), 0x8015B198:("func_8015B198",), @@ -2892,14 +2892,14 @@ 0x80160B40:("PlayerCall_Destroy",), 0x80160B80:("PlayerCall_Update",), 0x80160BC0:("PlayerCall_Draw",), - 0x80160C00:("ShrinkWindow_SetLetterboxTarget",), - 0x80160C14:("ShrinkWindow_GetLetterboxTarget",), - 0x80160C28:("ShrinkWindow_SetLetterboxMagnitude",), - 0x80160C3C:("ShrinkWindow_GetLetterboxMagnitude",), - 0x80160C50:("ShrinkWindow_SetPillarboxTarget",), - 0x80160C64:("ShrinkWindow_GetPillarboxTarget",), - 0x80160C78:("ShrinkWindow_SetPillarboxMagnitude",), - 0x80160C8C:("ShrinkWindow_GetPillarboxMagnitude",), + 0x80160C00:("ShrinkWindow_Letterbox_SetSizeTarget",), + 0x80160C14:("ShrinkWindow_Letterbox_GetSizeTarget",), + 0x80160C28:("ShrinkWindow_Letterbox_SetSize",), + 0x80160C3C:("ShrinkWindow_Letterbox_GetSize",), + 0x80160C50:("ShrinkWindow_Pillarbox_SetSizeTarget",), + 0x80160C64:("ShrinkWindow_Pillarbox_GetSizeTarget",), + 0x80160C78:("ShrinkWindow_Pillarbox_SetSize",), + 0x80160C8C:("ShrinkWindow_Pillarbox_GetSize",), 0x80160CA0:("ShrinkWindow_Init",), 0x80160CD4:("ShrinkWindow_Destroy",), 0x80160CE4:("ShrinkWindow_Update",), @@ -2936,8 +2936,8 @@ 0x80163A38:("KaleidoScopeCall_Destroy",), 0x80163A58:("KaleidoScopeCall_Update",), 0x80163C0C:("KaleidoScopeCall_Draw",), - 0x80163C90:("func_80163C90",), - 0x80163D80:("func_80163D80",), + 0x80163C90:("Transition_Init",), + 0x80163D80:("Transition_Destroy",), 0x80163DC0:("func_80163DC0",), 0x8016418C:("func_8016418C",), 0x8016424C:("func_8016424C",), @@ -2964,12 +2964,12 @@ 0x80164C14:("func_80164C14",), 0x80165044:("TransitionCircle_Draw",), 0x80165198:("TransitionCircle_IsDone",), - 0x801651B0:("func_801651B0",), - 0x80165224:("func_80165224",), - 0x80165288:("func_80165288",), - 0x8016537C:("func_8016537C",), - 0x80165438:("func_80165438",), - 0x80165444:("func_80165444",), + 0x801651B0:("TransitionOverlay_VramToRam",), + 0x80165224:("TransitionOverlay_VramToRamArray",), + 0x80165288:("TransitionOverlay_Load",), + 0x8016537C:("TransitionOverlay_Free",), + 0x80165438:("TransitionOverlay_ClearLoadInfo",), + 0x80165444:("TransitionOverlay_SetSegment",), 0x80165460:("func_80165460",), 0x80165608:("func_80165608",), 0x80165630:("func_80165630",), @@ -2986,18 +2986,18 @@ 0x80165EC0:("func_80165EC0",), 0x80166060:("func_80166060",), 0x801660B8:("func_801660B8",), - 0x8016613C:("Play_Fini",), - 0x801663C4:("func_801663C4",), - 0x80166644:("func_80166644",), + 0x8016613C:("Play_Destroy",), + 0x801663C4:("Play_CompressI8ToI5",), + 0x80166644:("Play_DecompressI5ToI8",), 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,26 +3005,26 @@ 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",), - 0x80169CBC:("Play_GetOriginalSceneNumber",), + 0x80169C64:("Play_GetActorCsCamSetting",), + 0x80169C84:("Play_GetActorCsCamFuncData",), + 0x80169CBC:("Play_GetOriginalSceneId",), 0x80169D40:("Play_SaveCycleSceneFlags",), 0x80169DCC:("Play_SetRespawnData",), 0x80169E6C:("Play_SetupRespawnPoint",), @@ -3036,9 +3036,9 @@ 0x8016A01C:("FrameAdvance_IsEnabled",), 0x8016A02C:("func_8016A02C",), 0x8016A0AC:("Play_IsUnderwater",), - 0x8016A168:("func_8016A168",), + 0x8016A168:("Play_IsDebugCamEnabled",), 0x8016A178:("Play_AssignPlayerActorCsIdsFromScene",), - 0x8016A268:("func_8016A268",), + 0x8016A268:("Play_FillScreen",), 0x8016A2C8:("Play_Init",), 0x8016AC10:("func_8016AC10",), 0x8016AE1C:("func_8016AE1C",), @@ -3109,17 +3109,17 @@ 0x80172B3C:("THA_Init",), 0x80172B58:("THA_Ct",), 0x80172B9C:("THA_Dt",), - 0x80172BC0:("func_80172BC0",), + 0x80172BC0:("AudioMgr_StopAllSfxExceptSystem",), 0x80172C30:("func_80172C30",), 0x80172C68:("AudioMgr_HandleRetrace",), 0x80172EAC:("AudioMgr_HandlePRENMI",), 0x80172ED0:("AudioMgr_ThreadEntry",), 0x80173048:("AudioMgr_Unlock",), 0x80173074:("AudioMgr_Init",), - 0x80173130:("TitleSetup_GameStateResetContext",), - 0x801732DC:("TitleSetup_InitImpl",), - 0x8017332C:("TitleSetup_Destroy",), - 0x80173338:("TitleSetup_Init",), + 0x80173130:("Setup_SetRegs",), + 0x801732DC:("Setup_InitImpl",), + 0x8017332C:("Setup_Destroy",), + 0x80173338:("Setup_Init",), 0x80173360:("Game_UpdateFramerateVariables",), 0x801733A8:("Game_SetFramerateDivisor",), 0x801733DC:("GameState_SetFBFilter",), @@ -3134,8 +3134,8 @@ 0x80173880:("GameState_Realloc",), 0x80173950:("GameState_Init",), 0x80173A50:("GameState_Destroy",), - 0x80173B00:("GameState_GetNextStateInit",), - 0x80173B0C:("GameState_GetNextStateSize",), + 0x80173B00:("GameState_GetInit",), + 0x80173B0C:("GameState_GetSize",), 0x80173B18:("GameState_IsRunning",), 0x80173B24:("GameState_GetArenaSize",), 0x80173B48:("func_80173B48",), @@ -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",), @@ -3222,9 +3222,9 @@ 0x80177A84:("func_80177A84",), 0x80177AC8:("func_80177AC8",), 0x80177E58:("SpeedMeter_DrawAllocEntries",), - 0x801780F0:("func_801780F0",), - 0x801781EC:("func_801781EC",), - 0x8017842C:("func_8017842C",), + 0x801780F0:("Mtx_SetTranslateScaleMtx",), + 0x801781EC:("Mtx_SetRotationMtx",), + 0x8017842C:("Mtx_SetTranslationRotationScaleMtx",), 0x80178750:("func_80178750",), 0x80178818:("func_80178818",), 0x80178978:("func_80178978",), @@ -3352,8 +3352,8 @@ 0x8017FEB0:("Math_GetAtan2Tbl",), 0x8017FEE4:("Math_Atan2S",), 0x801800CC:("Math_Atan2F",), - 0x80180100:("Math_FAtan2F",), - 0x8018012C:("Math_Acot2F",), + 0x80180100:("Math_Atan2S_XY",), + 0x8018012C:("Math_Atan2F_XY",), 0x80180160:("Matrix_Init",), 0x8018019C:("Matrix_Push",), 0x801801CC:("Matrix_Pop",), @@ -3397,9 +3397,9 @@ 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",), @@ -3478,76 +3478,76 @@ 0x801872FC:("osFlashWriteBuffer",), 0x801873BC:("osFlashWriteArray",), 0x8018752C:("osFlashReadArray",), - 0x801877D0:("func_801877D0",), - 0x80187B64:("func_80187B64",), - 0x80187BEC:("func_80187BEC",), - 0x80187DE8:("func_80187DE8",), - 0x80187E58:("func_80187E58",), - 0x80187F00:("func_80187F00",), - 0x80187FA8:("func_80187FA8",), - 0x80187FB0:("func_80187FB0",), - 0x80187FD0:("func_80187FD0",), - 0x80187FD8:("func_80187FD8",), - 0x80187FE0:("func_80187FE0",), - 0x80187FE8:("func_80187FE8",), - 0x8018801C:("func_8018801C",), - 0x80188024:("func_80188024",), - 0x8018802C:("func_8018802C",), - 0x80188034:("func_80188034",), - 0x80188068:("func_80188068",), - 0x80188070:("func_80188070",), - 0x80188078:("func_80188078",), - 0x801880A4:("func_801880A4",), - 0x801880AC:("func_801880AC",), - 0x801880B4:("func_801880B4",), - 0x801880BC:("func_801880BC",), - 0x801880C4:("func_801880C4",), - 0x801880E8:("func_801880E8",), - 0x8018811C:("func_8018811C",), - 0x80188124:("func_80188124",), - 0x8018814C:("func_8018814C",), - 0x80188174:("func_80188174",), - 0x80188190:("func_80188190",), - 0x80188198:("func_80188198",), - 0x801881A0:("func_801881A0",), - 0x801881A8:("func_801881A8",), - 0x801881C4:("func_801881C4",), - 0x801881F8:("func_801881F8",), - 0x80188224:("func_80188224",), - 0x8018822C:("func_8018822C",), - 0x80188234:("func_80188234",), - 0x8018823C:("func_8018823C",), - 0x80188244:("func_80188244",), - 0x8018824C:("func_8018824C",), - 0x80188254:("func_80188254",), - 0x8018825C:("func_8018825C",), - 0x80188264:("func_80188264",), - 0x80188288:("func_80188288",), - 0x801882A0:("func_801882A0",), - 0x80188304:("func_80188304",), - 0x801884A0:("func_801884A0",), - 0x80188698:("func_80188698",), - 0x8018883C:("func_8018883C",), - 0x801888E4:("func_801888E4",), - 0x801889A4:("func_801889A4",), - 0x80188A50:("func_80188A50",), - 0x80188AFC:("func_80188AFC",), - 0x80188C48:("func_80188C48",), - 0x80188CB4:("func_80188CB4",), - 0x80188D20:("func_80188D20",), - 0x80188D28:("func_80188D28",), - 0x80188D68:("func_80188D68",), - 0x80188DDC:("func_80188DDC",), - 0x80188FBC:("func_80188FBC",), - 0x80189064:("func_80189064",), - 0x80189620:("func_80189620",), - 0x8018A4B4:("func_8018A4B4",), - 0x8018A768:("func_8018A768",), - 0x8018A808:("func_8018A808",), - 0x8018ACC4:("func_8018ACC4",), - 0x8018AE34:("func_8018AE34",), - 0x8018B0F0:("func_8018B0F0",), - 0x8018B10C:("func_8018B10C",), + 0x801877D0:("AudioSynth_AddReverbBufferEntry",), + 0x80187B64:("AudioSynth_SyncSampleStates",), + 0x80187BEC:("AudioSynth_Update",), + 0x80187DE8:("AudioSynth_DisableSampleStates",), + 0x80187E58:("AudioSynth_LoadMixedReverbSamples",), + 0x80187F00:("AudioSynth_SaveMixedReverbSamples",), + 0x80187FA8:("AudioSynth_Noop1",), + 0x80187FB0:("AudioSynth_ClearBuffer",), + 0x80187FD0:("AudioSynth_Noop2",), + 0x80187FD8:("AudioSynth_Noop3",), + 0x80187FE0:("AudioSynth_Noop4",), + 0x80187FE8:("AudioSynth_Mix",), + 0x8018801C:("AudioSynth_Noop5",), + 0x80188024:("AudioSynth_Noop6",), + 0x8018802C:("AudioSynth_Noop7",), + 0x80188034:("AudioSynth_SetBuffer",), + 0x80188068:("AudioSynth_Noop8",), + 0x80188070:("AudioSynth_Noop9",), + 0x80188078:("AudioSynth_DMemMove",), + 0x801880A4:("AudioSynth_Noop10",), + 0x801880AC:("AudioSynth_Noop11",), + 0x801880B4:("AudioSynth_Noop12",), + 0x801880BC:("AudioSynth_Noop13",), + 0x801880C4:("AudioSynth_InterL",), + 0x801880E8:("AudioSynth_EnvSetup1",), + 0x8018811C:("AudioSynth_Noop14",), + 0x80188124:("AudioSynth_LoadBuffer",), + 0x8018814C:("AudioSynth_SaveBuffer",), + 0x80188174:("AudioSynth_EnvSetup2",), + 0x80188190:("AudioSynth_Noop15",), + 0x80188198:("AudioSynth_Noop16",), + 0x801881A0:("AudioSynth_Noop17",), + 0x801881A8:("AudioSynth_S8Dec",), + 0x801881C4:("AudioSynth_HiLoGain",), + 0x801881F8:("AudioSynth_UnkCmd19",), + 0x80188224:("AudioSynth_Noop18",), + 0x8018822C:("AudioSynth_Noop19",), + 0x80188234:("AudioSynth_Noop20",), + 0x8018823C:("AudioSynth_Noop21",), + 0x80188244:("AudioSynth_Noop22",), + 0x8018824C:("AudioSynth_Noop23",), + 0x80188254:("AudioSynth_Noop24",), + 0x8018825C:("AudioSynth_Noop25",), + 0x80188264:("AudioSynth_LoadFilterBuffer",), + 0x80188288:("AudioSynth_LoadFilterSize",), + 0x801882A0:("AudioSynth_LeakReverb",), + 0x80188304:("AudioSynth_LoadDownsampledReverbSamples",), + 0x801884A0:("AudioSynth_SaveResampledReverbSamples",), + 0x80188698:("AudioSynth_LoadResampledReverbSamples",), + 0x8018883C:("AudioSynth_FilterReverb",), + 0x801888E4:("AudioSynth_MixOtherReverbIndex",), + 0x801889A4:("AudioSynth_LoadDefaultReverbSamples",), + 0x80188A50:("AudioSynth_LoadSubReverbSamples",), + 0x80188AFC:("AudioSynth_SaveResampledReverbSamplesImpl",), + 0x80188C48:("AudioSynth_LoadReverbSamplesImpl",), + 0x80188CB4:("AudioSynth_SaveReverbSamplesImpl",), + 0x80188D20:("AudioSynth_Noop26",), + 0x80188D28:("AudioSynth_LoadSubReverbSamplesWithoutDownsample",), + 0x80188D68:("AudioSynth_LoadReverbSamples",), + 0x80188DDC:("AudioSynth_SaveReverbSamples",), + 0x80188FBC:("AudioSynth_SaveSubReverbSamples",), + 0x80189064:("AudioSynth_ProcessSamples",), + 0x80189620:("AudioSynth_ProcessSample",), + 0x8018A4B4:("AudioSynth_ApplySurroundEffect",), + 0x8018A768:("AudioSynth_FinalResample",), + 0x8018A808:("AudioSynth_ProcessEnvelope",), + 0x8018ACC4:("AudioSynth_LoadWaveSamples",), + 0x8018AE34:("AudioSynth_ApplyHaasEffect",), + 0x8018B0F0:("AudioHeap_CalculateAdsrDecay",), + 0x8018B10C:("AudioHeap_InitAdsrDecayTable",), 0x8018B250:("AudioHeap_ResetLoadStatus",), 0x8018B318:("AudioHeap_DiscardFont",), 0x8018B3FC:("AudioHeap_ReleaseNotesForFont",), @@ -3560,16 +3560,16 @@ 0x8018B640:("AudioHeap_AllocZeroed",), 0x8018B69C:("AudioHeap_TestAlloc",), 0x8018B6E8:("AudioHeap_Alloc",), - 0x8018B740:("AudioHeap_AllocPoolInit",), - 0x8018B768:("AudioHeap_ClearPersistentCache",), - 0x8018B77C:("AudioHeap_ClearTemporaryCache",), + 0x8018B740:("AudioHeap_InitPool",), + 0x8018B768:("AudioHeap_InitPersistentCache",), + 0x8018B77C:("AudioHeap_InitTemporaryCache",), 0x8018B7AC:("AudioHeap_ResetPool",), - 0x8018B7BC:("AudioHeap_PopCache",), + 0x8018B7BC:("AudioHeap_PopPersistentCache",), 0x8018B8FC:("AudioHeap_InitMainPool",), 0x8018B95C:("AudioHeap_InitSessionPool",), 0x8018B9E0:("AudioHeap_InitCachePool",), - 0x8018BA64:("AudioHeap_InitPersistentCache",), - 0x8018BB28:("AudioHeap_InitTemporaryCache",), + 0x8018BA64:("AudioHeap_InitPersistentPoolsAndCaches",), + 0x8018BB28:("AudioHeap_InitTemporaryPoolsAndCaches",), 0x8018BBEC:("AudioHeap_AllocCached",), 0x8018C380:("AudioHeap_SearchCaches",), 0x8018C3D8:("AudioHeap_SearchRegularCaches",), @@ -3645,7 +3645,7 @@ 0x80190B08:("AudioLoad_ProcessLoads",), 0x80190B38:("AudioLoad_SetDmaHandler",), 0x80190B44:("AudioLoad_SetUnusedHandler",), - 0x80190B50:("AudioLoad_InitSoundFontMeta",), + 0x80190B50:("AudioLoad_InitSoundFont",), 0x80190BB0:("AudioLoad_Init",), 0x80190F50:("AudioLoad_InitSlowLoads",), 0x80190F64:("AudioLoad_SlowLoadSample",), @@ -3680,61 +3680,61 @@ 0x80192AE8:("AudioLoad_ScriptLoad",), 0x80192B54:("AudioLoad_ProcessScriptLoads",), 0x80192BAC:("AudioLoad_InitScriptLoads",), - 0x80192BE0:("func_80192BE0",), - 0x80192C00:("func_80192C00",), - 0x8019319C:("func_8019319C",), - 0x801936D8:("func_801936D8",), - 0x8019372C:("func_8019372C",), - 0x80193774:("func_80193774",), - 0x8019380C:("func_8019380C",), - 0x80193858:("func_80193858",), - 0x8019387C:("func_8019387C",), - 0x801938A0:("Audio_QueueCmdS8",), - 0x801938D0:("func_801938D0",), - 0x80193900:("func_80193900",), - 0x80193990:("func_80193990",), - 0x801939A8:("func_801939A8",), - 0x80193AEC:("func_80193AEC",), - 0x80193BA0:("func_80193BA0",), - 0x80193C04:("func_80193C04",), - 0x80193C24:("func_80193C24",), + 0x80192BE0:("AudioThread_Update",), + 0x80192C00:("AudioThread_UpdateImpl",), + 0x8019319C:("AudioThread_ProcessGlobalCmd",), + 0x801936D8:("AudioThread_SetFadeOutTimer",), + 0x8019372C:("AudioThread_SetFadeInTimer",), + 0x80193774:("AudioThread_InitMesgQueuesInternal",), + 0x8019380C:("AudioThread_QueueCmd",), + 0x80193858:("AudioThread_QueueCmdF32",), + 0x8019387C:("AudioThread_QueueCmdS32",), + 0x801938A0:("AudioThread_QueueCmdS8",), + 0x801938D0:("AudioThread_QueueCmdU16",), + 0x80193900:("AudioThread_ScheduleProcessCmds",), + 0x80193990:("AudioThread_ResetCmdQueue",), + 0x801939A8:("AudioThread_ProcessCmd",), + 0x80193AEC:("AudioThread_ProcessCmds",), + 0x80193BA0:("AudioThread_GetExternalLoadQueueMsg",), + 0x80193C04:("AudioThread_GetFontsForSequence",), + 0x80193C24:("AudioThread_GetSampleBankIdsOfFont",), 0x80193C5C:("func_80193C5C",), - 0x80193CB4:("func_80193CB4",), - 0x80193D08:("func_80193D08",), - 0x80193DA4:("func_80193DA4",), - 0x80193DF0:("func_80193DF0",), - 0x80193E44:("func_80193E44",), - 0x80193E6C:("func_80193E6C",), - 0x80193E9C:("func_80193E9C",), - 0x80193EA8:("func_80193EA8",), - 0x80194080:("func_80194080",), - 0x801942BC:("func_801942BC",), - 0x80194304:("func_80194304",), - 0x80194328:("func_80194328",), - 0x8019435C:("func_8019435C",), - 0x8019439C:("func_8019439C",), - 0x801943D0:("func_801943D0",), - 0x8019440C:("func_8019440C",), - 0x80194528:("func_80194528",), - 0x80194548:("func_80194548",), - 0x80194568:("func_80194568",), - 0x80194668:("Audio_NextRandom",), - 0x801946E4:("Audio_InitMesgQueues",), + 0x80193CB4:("AudioThread_WaitForAudioResetQueueP",), + 0x80193D08:("AudioThread_ResetAudioHeap",), + 0x80193DA4:("AudioThread_PreNMIInternal",), + 0x80193DF0:("AudioThread_GetChannelIO",), + 0x80193E44:("AudioThread_GetSeqPlayerIO",), + 0x80193E6C:("AudioThread_InitExternalPool",), + 0x80193E9C:("AudioThread_ResetExternalPool",), + 0x80193EA8:("AudioThread_ProcessSeqPlayerCmd",), + 0x80194080:("AudioThread_ProcessChannelCmd",), + 0x801942BC:("AudioThread_Noop1Cmd",), + 0x80194304:("AudioThread_Noop1CmdZeroed",), + 0x80194328:("AudioThread_Noop2Cmd",), + 0x8019435C:("AudioThread_WaitForAudioTask",), + 0x8019439C:("AudioThread_GetSamplePosFromStart",), + 0x801943D0:("AudioThread_GetSamplePosUntilEnd",), + 0x8019440C:("AudioThread_GetSamplePos",), + 0x80194528:("AudioThread_GetEnabledNotesCount",), + 0x80194548:("AudioThread_GetEnabledSampledNotesCount",), + 0x80194568:("AudioThread_CountAndReleaseNotes",), + 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",), - 0x80194930:("AudioPlayback_InitNoteSub",), + 0x80194930:("AudioPlayback_InitSampleState",), 0x80194DB0:("AudioPlayback_NoteSetResamplingRate",), 0x80194E60:("AudioPlayback_NoteInit",), 0x80194F20:("AudioPlayback_NoteDisable",), 0x80194F84:("AudioPlayback_ProcessNotes",), - 0x801954CC:("AudioPlayback_InstrumentGetSound",), + 0x801954CC:("AudioPlayback_GetInstrumentTunedSample",), 0x80195508:("AudioPlayback_GetInstrumentInner",), 0x801955DC:("AudioPlayback_GetDrum",), - 0x801956C0:("AudioPlayback_GetSfx",), + 0x801956C0:("AudioPlayback_GetSoundEffect",), 0x801957B4:("AudioPlayback_SetFontInstrument",), 0x801958F8:("AudioPlayback_SeqLayerDecayRelease",), 0x80195C40:("AudioPlayback_SeqLayerNoteDecay",), @@ -3767,118 +3767,118 @@ 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",), - 0x8019DFF8:("func_8019DFF8",), - 0x8019E000:("func_8019E000",), - 0x8019E00C:("func_8019E00C",), - 0x8019E014:("func_8019E014",), - 0x8019E0FC:("func_8019E0FC",), - 0x8019E104:("func_8019E104",), + 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:("Audio_Noop1",), + 0x8019E000:("Audio_Noop2",), + 0x8019E00C:("Audio_Noop3",), + 0x8019E014:("Audio_Update",), + 0x8019E0FC:("Audio_Noop4",), + 0x8019E104:("Audio_Noop5",), 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",), @@ -3938,32 +3938,32 @@ 0x801A21FC:("Audio_PlaySariaBgm",), 0x801A2460:("Audio_ClearSariaBgm2",), 0x801A246C:("func_801A246C",), - 0x801A2544:("func_801A2544",), - 0x801A257C:("func_801A257C",), - 0x801A25E4:("func_801A25E4",), - 0x801A2670:("func_801A2670",), - 0x801A2778:("func_801A2778",), + 0x801A2544:("Audio_PlayMorningSceneSequence",), + 0x801A257C:("Audio_StartMorningSceneSequence",), + 0x801A25E4:("Audio_PlaySceneSequence",), + 0x801A2670:("Audio_StartSceneSequence",), + 0x801A2778:("Audio_UpdateSceneSequenceResumePoint",), 0x801A27E8:("func_801A27E8",), 0x801A281C:("func_801A281C",), 0x801A29D4:("func_801A29D4",), 0x801A2BB8:("func_801A2BB8",), 0x801A2C20:("func_801A2C20",), 0x801A2C44:("func_801A2C44",), - 0x801A2C88:("func_801A2C88",), - 0x801A2D54:("func_801A2D54",), + 0x801A2C88:("Audio_PlaySequenceInCutscene",), + 0x801A2D54:("Audio_StopSequenceInCutscene",), 0x801A2DE0:("Audio_IsSequencePlaying",), - 0x801A2E54:("func_801A2E54",), - 0x801A2ED8:("func_801A2ED8",), - 0x801A2F88:("func_801A2F88",), - 0x801A2FC4:("func_801A2FC4",), + 0x801A2E54:("Audio_PlayBgm_StorePrevBgm",), + 0x801A2ED8:("Audio_RestorePrevBgm",), + 0x801A2F88:("Audio_PlayAmbience_StorePrevBgm",), + 0x801A2FC4:("Audio_ForceRestorePreviousBgm",), 0x801A3000:("func_801A3000",), 0x801A3038:("func_801A3038",), - 0x801A3098:("func_801A3098",), + 0x801A3098:("Audio_PlayFanfare",), 0x801A312C:("func_801A312C",), 0x801A31EC:("func_801A31EC",), - 0x801A3238:("func_801A3238",), - 0x801A32CC:("func_801A32CC",), - 0x801A3590:("func_801A3590",), + 0x801A3238:("Audio_PlaySequenceWithSeqPlayerIO",), + 0x801A32CC:("Audio_SetSequenceMode",), + 0x801A3590:("Audio_UpdateEnemyBgmVolume",), 0x801A36F0:("func_801A36F0",), 0x801A3950:("func_801A3950",), 0x801A39F8:("func_801A39F8",), @@ -3982,7 +3982,7 @@ 0x801A3F6C:("func_801A3F6C",), 0x801A3FB4:("func_801A3FB4",), 0x801A3FFC:("func_801A3FFC",), - 0x801A400C:("audio_setBGM",), + 0x801A400C:("Audio_SetSpec",), 0x801A4058:("func_801A4058",), 0x801A41C8:("func_801A41C8",), 0x801A41F8:("func_801A41F8",), @@ -3990,20 +3990,20 @@ 0x801A42C8:("func_801A42C8",), 0x801A4324:("func_801A4324",), 0x801A4348:("func_801A4348",), - 0x801A4380:("func_801A4380",), + 0x801A4380:("Audio_SetSfxVolumeExceptSystemAndOcarinaBanks",), 0x801A4428:("func_801A4428",), 0x801A44A4:("Audio_PreNMI",), - 0x801A44C4:("func_801A44C4",), + 0x801A44C4:("Audio_ResetRequestedSceneSeqId",), 0x801A44D4:("func_801A44D4",), 0x801A46F8:("func_801A46F8",), 0x801A4748:("func_801A4748",), 0x801A479C:("func_801A479C",), - 0x801A47DC:("func_801A47DC",), - 0x801A48E0:("func_801A48E0",), - 0x801A4A28:("func_801A4A28",), - 0x801A4B80:("func_801A4B80",), - 0x801A4C30:("func_801A4C30",), - 0x801A4C54:("func_801A4C54",), + 0x801A47DC:("Audio_SetAmbienceChannelIO",), + 0x801A48E0:("Audio_StartAmbience",), + 0x801A4A28:("Audio_PlayAmbience",), + 0x801A4B80:("Audio_SetAmbienceRandomBend",), + 0x801A4C30:("Audio_Init",), + 0x801A4C54:("AudioSfx_Init",), 0x801A4D00:("func_801A4D00",), 0x801A4D50:("func_801A4D50",), 0x801A4DA4:("func_801A4DA4",), @@ -4030,34 +4030,34 @@ 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",), - 0x801A7D04:("func_801A7D04",), + 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:("Audio_StopSequence",), 0x801A7D84:("func_801A7D84",), 0x801A89A8:("Audio_QueueSeqCmd",), 0x801A89D0:("func_801A89D0",), - 0x801A8A50:("func_801A8A50",), + 0x801A8A50:("Audio_GetActiveSequence",), 0x801A8ABC:("func_801A8ABC",), 0x801A8B14:("func_801A8B14",), 0x801A8B2C:("func_801A8B2C",), @@ -4083,30 +4083,30 @@ 0x801AA624:("GameOver_FadeLights",), 0x801AA68C:("GameOver_Update",), 0x801AAAA0:("func_801AAAA0",), - 0x80800000:("Title_UpdateCounters",), - 0x8080009C:("Title_RenderView",), - 0x80800134:("Title_Draw",), - 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",), - 0x80803DF0:("Opening_SetupForTitleCutscene",), + 0x80800000:("ConsoleLogo_UpdateCounters",), + 0x8080009C:("ConsoleLogo_RenderView",), + 0x80800134:("ConsoleLogo_Draw",), + 0x8080066C:("ConsoleLogo_Main",), + 0x8080071C:("ConsoleLogo_Destroy",), + 0x8080074C:("ConsoleLogo_Init",), + 0x80800910:("MapSelect_LoadConsoleLogo",), + 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:("TitleSetup_SetupTitleScreen",), 0x80803EA0:("func_80803EA0",), - 0x80803EC0:("Opening_Main",), - 0x80803F0C:("Opening_Destroy",), - 0x80803F30:("Opening_Init",), + 0x80803EC0:("TitleSetup_Main",), + 0x80803F0C:("TitleSetup_Destroy",), + 0x80803F30:("TitleSetup_Init",), 0x80804010:("func_80804010",), 0x808041A0:("func_808041A0",), 0x80804654:("func_80804654",), @@ -4152,11 +4152,11 @@ 0x8080A708:("func_8080A708",), 0x8080BBFC:("func_8080BBFC",), 0x8080BC20:("func_8080BC20",), - 0x8080BC44:("FileChoose_nop8080bc44",), - 0x8080BC4C:("FileChoose_nop8080BC4C",), + 0x8080BC44:("FileSelect_nop8080bc44",), + 0x8080BC4C:("FileSelect_nop8080BC4C",), 0x8080BC58:("func_8080BC58",), 0x8080BDAC:("func_8080BDAC",), - 0x8080BDDC:("FileChoose_RenderView",), + 0x8080BDDC:("FileSelect_RenderView",), 0x8080BE60:("func_8080BE60",), 0x8080C040:("func_8080C040",), 0x8080C228:("func_8080C228",), @@ -4185,64 +4185,64 @@ 0x80812D94:("func_80812D94",), 0x80812E94:("func_80812E94",), 0x80812ED0:("func_80812ED0",), - 0x8081313C:("FileChoose_UpdateAndDrawSkybox",), - 0x80813268:("FileChoose_Main",), + 0x8081313C:("FileSelect_UpdateAndDrawSkybox",), + 0x80813268:("FileSelect_Main",), 0x80813908:("func_80813908",), - 0x80813C74:("FileChoose_Destroy",), - 0x80813C98:("FileChoose_Init",), - 0x80814EB0:("Daytelop_Update",), - 0x80814FE8:("Daytelop_Draw",), - 0x808156B4:("Daytelop_Main",), - 0x8081574C:("Daytelop_Destroy",), - 0x80815770:("Daytelop_nop80815770",), - 0x8081577C:("Daytelop_LoadGraphics",), - 0x80815820:("Daytelop_Init",), - 0x808160A0:("func_808160A0",), - 0x80817B5C:("func_80817B5C",), - 0x80818904:("func_80818904",), - 0x80818920:("func_80818920",), - 0x808190C4:("func_808190C4",), - 0x80819238:("func_80819238",), - 0x80819F04:("func_80819F04",), - 0x8081B240:("func_8081B240",), - 0x8081B6BC:("func_8081B6BC",), - 0x8081B6EC:("func_8081B6EC",), - 0x8081BCA8:("func_8081BCA8",), - 0x8081C684:("func_8081C684",), - 0x8081D240:("func_8081D240",), - 0x8081D6DC:("func_8081D6DC",), - 0x8081E118:("func_8081E118",), - 0x8081E7D8:("func_8081E7D8",), - 0x8081FB1C:("func_8081FB1C",), - 0x8081FF80:("func_8081FF80",), - 0x808204AC:("func_808204AC",), - 0x80820FA4:("func_80820FA4",), - 0x80821730:("func_80821730",), + 0x80813C74:("FileSelect_Destroy",), + 0x80813C98:("FileSelect_Init",), + 0x80814EB0:("DayTelop_Update",), + 0x80814FE8:("DayTelop_Draw",), + 0x808156B4:("DayTelop_Main",), + 0x8081574C:("DayTelop_Destroy",), + 0x80815770:("DayTelop_Noop",), + 0x8081577C:("DayTelop_LoadGraphics",), + 0x80815820:("DayTelop_Init",), + 0x808160A0:("KaleidoScope_DrawQuestStatus",), + 0x80817B5C:("KaleidoScope_UpdateQuestCursor",), + 0x80818904:("KaleidoScope_UpdateQuestStatusPoint",), + 0x80818920:("KaleidoScope_DrawInventoryEditorText",), + 0x808190C4:("KaleidoScope_DrawDigit",), + 0x80819238:("KaleidoScope_DrawInventoryEditor",), + 0x80819F04:("KaleidoScope_UpdateInventoryEditor",), + 0x8081B240:("KaleidoScope_DrawAmmoCount",), + 0x8081B6BC:("KaleidoScope_SetCursorVtx",), + 0x8081B6EC:("KaleidoScope_DrawItemSelect",), + 0x8081BCA8:("KaleidoScope_UpdateItemCursor",), + 0x8081C684:("KaleidoScope_UpdateItemEquip",), + 0x8081D240:("KaleidoScope_DrawDungeonStrayFairyCount",), + 0x8081D6DC:("KaleidoScope_DrawDungeonMap",), + 0x8081E118:("KaleidoScope_UpdateDungeonCursor",), + 0x8081E7D8:("KaleidoScope_DrawWorldMap",), + 0x8081FB1C:("KaleidoScope_UpdateWorldMapCursor",), + 0x8081FF80:("KaleidoScope_DrawMaskSelect",), + 0x808204AC:("KaleidoScope_UpdateMaskCursor",), + 0x80820FA4:("KaleidoScope_UpdateMaskEquip",), + 0x80821730:("KaleidoScope_UpdatePrompt",), 0x80821900:("func_80821900",), 0x8082192C:("func_8082192C",), 0x80821958:("func_80821958",), - 0x80821984:("func_80821984",), + 0x80821984:("KaleidoScope_MoveCursorToSpecialPos",), 0x80821A04:("func_80821A04",), - 0x80821AD4:("func_80821AD4",), + 0x80821AD4:("KaleidoScope_DrawTexQuadRGBA32",), 0x80821CC4:("func_80821CC4",), - 0x80821D84:("func_80821D84",), + 0x80821D84:("KaleidoScope_HandlePageToggles",), 0x80821F30:("func_80821F30",), 0x808221DC:("func_808221DC",), 0x80823350:("func_80823350",), - 0x80824738:("func_80824738",), + 0x80824738:("KaleidoScope_UpdateNamePanel",), 0x808248D0:("func_808248D0",), 0x80824B90:("func_80824B90",), - 0x808256E4:("func_808256E4",), - 0x8082585C:("func_8082585C",), - 0x808259D4:("func_808259D4",), + 0x808256E4:("KaleidoScope_UpdateOwlWarpNamePanel",), + 0x8082585C:("KaleidoScope_UpdateSwitchPage",), + 0x808259D4:("KaleidoScope_SetView",), 0x80825A50:("func_80825A50",), 0x80825E28:("func_80825E28",), 0x808274DC:("func_808274DC",), 0x80827A8C:("func_80827A8C",), 0x80827E08:("func_80827E08",), 0x808283D8:("KaleidoScope_Draw",), - 0x808286D8:("func_808286D8",), - 0x80828788:("func_80828788",), + 0x808286D8:("KaleidoScope_GrayOutTextureRGBA32",), + 0x80828788:("KaleidoScope_UpdateOpening",), 0x8082895C:("KaleidoScope_Update",), 0x8082DA90:("func_8082DA90",), 0x8082DABC:("func_8082DABC",), @@ -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",), @@ -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",), @@ -5621,25 +5621,25 @@ 0x8089F2C4:("func_8089F2C4",), 0x8089F380:("EnViewer_Update",), 0x8089F3C8:("EnViewer_Draw",), - 0x8089F4E0:("func_8089F4E0",), + 0x8089F4E0:("EnBubble_SetDimensions",), 0x8089F59C:("func_8089F59C",), 0x8089F5D0:("func_8089F5D0",), - 0x8089F5F4:("func_8089F5F4",), - 0x8089F660:("func_8089F660",), + 0x8089F5F4:("EnBubble_DamagePlayer",), + 0x8089F660:("EnBubble_Explosion",), 0x8089F8BC:("func_8089F8BC",), 0x8089F908:("func_8089F908",), - 0x8089F95C:("func_8089F95C",), - 0x8089F9E4:("func_8089F9E4",), - 0x8089FA54:("func_8089FA54",), + 0x8089F95C:("EnBubble_Vec3fNormalizedReflect",), + 0x8089F9E4:("EnBubble_Vec3fNormalize",), + 0x8089FA54:("EnBubble_Fly",), 0x8089FF30:("func_8089FF30",), - 0x8089FFCC:("func_8089FFCC",), + 0x8089FFCC:("EnBubble_IsPopped",), 0x808A005C:("func_808A005C",), 0x808A0170:("EnBubble_Init",), 0x808A0270:("EnBubble_Destroy",), - 0x808A029C:("func_808A029C",), - 0x808A0350:("func_808A0350",), - 0x808A03A0:("func_808A03A0",), - 0x808A03E8:("func_808A03E8",), + 0x808A029C:("EnBubble_Wait",), + 0x808A0350:("EnBubble_Pop",), + 0x808A03A0:("EnBubble_Disappear",), + 0x808A03E8:("EnBubble_Regrow",), 0x808A0458:("EnBubble_Update",), 0x808A04D4:("EnBubble_Draw",), 0x808A08F0:("DoorShutter_SetupAction",), @@ -5803,9 +5803,9 @@ 0x808AACE0:("EnOssan_WaitForBlink",), 0x808AAD14:("EnOssan_Blink",), 0x808AADB4:("EnOssan_CuriosityShopMan_Init",), - 0x808AAE1C:("EnOssan_PartTimeWorker_Init",), + 0x808AAE1C:("EnOssan_PartTimer_Init",), 0x808AAE84:("EnOssan_CuriosityShopMan_GetWelcome",), - 0x808AAFB0:("EnOssan_PartTimerWorker_GetWelcome",), + 0x808AAFB0:("EnOssan_PartTimer_GetWelcome",), 0x808AB0B0:("EnOssan_SetHaveMet",), 0x808AB16C:("EnOssan_InitShop",), 0x808AB404:("EnOssan_GetCutscenes",), @@ -5814,11 +5814,11 @@ 0x808AB78C:("EnOssan_DrawTextRec",), 0x808AB928:("EnOssan_DrawStickDirectionPrompts",), 0x808ABCD0:("EnOssan_CuriosityShopMan_OverrideLimbDraw",), - 0x808ABD10:("EnOssan_PartTimeWorker_OverrideLimbDraw",), + 0x808ABD10:("EnOssan_PartTimer_OverrideLimbDraw",), 0x808ABD60:("EnOssan_CuriosityShopMan_PostLimbDraw",), - 0x808ABE18:("EnOssan_PartTimeWorker_PostLimbDraw",), + 0x808ABE18:("EnOssan_PartTimer_PostLimbDraw",), 0x808ABE58:("EnOssan_CuriosityShopMan_Draw",), - 0x808ABF30:("EnOssan_PartTimeWorker_Draw",), + 0x808ABF30:("EnOssan_PartTimer_Draw",), 0x808AC920:("EnFamos_Init",), 0x808ACB08:("EnFamos_Destroy",), 0x808ACB58:("EnFamos_SetupAttackDebris",), @@ -5947,18 +5947,18 @@ 0x808B5230:("EnMFire1_Init",), 0x808B5294:("EnMFire1_Destroy",), 0x808B52C0:("EnMFire1_Update",), - 0x808B53C0:("func_808B53C0",), + 0x808B53C0:("EnMThunder_UnkType_Setup",), 0x808B545C:("EnMThunder_Init",), 0x808B5820:("EnMThunder_Destroy",), - 0x808B5890:("func_808B5890",), - 0x808B58CC:("func_808B58CC",), - 0x808B5984:("func_808B5984",), + 0x808B5890:("EnMThunder_AdjustLights",), + 0x808B58CC:("EnMThunder_Spin_AttackNoMagic",), + 0x808B5984:("EnMThunder_Charge",), 0x808B5EEC:("func_808B5EEC",), - 0x808B5F68:("func_808B5F68",), - 0x808B60D4:("func_808B60D4",), - 0x808B6310:("func_808B6310",), + 0x808B5F68:("EnMThunder_Spin_Attack",), + 0x808B60D4:("EnMThunder_SwordBeam_Attack",), + 0x808B6310:("EnMThunder_UnkType_Attack",), 0x808B63E8:("EnMThunder_Update",), - 0x808B65BC:("func_808B65BC",), + 0x808B65BC:("EnMThunder_UnkType_Update",), 0x808B677C:("EnMThunder_Draw",), 0x808B7360:("BgBreakwall_SetupAction",), 0x808B736C:("func_808B736C",), @@ -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",), @@ -6903,14 +6903,14 @@ 0x809199FC:("func_809199FC",), 0x80919D68:("EffDust_Draw",), 0x80919F30:("func_80919F30",), - 0x80919FC8:("func_80919FC8",), - 0x8091A044:("func_8091A044",), - 0x8091A0B8:("func_8091A0B8",), + 0x80919FC8:("BgUmajump_StopCutscene",), + 0x8091A044:("BgUmajump_PlayCutscene",), + 0x8091A0B8:("BgUmajump_CheckDistance",), 0x8091A124:("BgUmajump_Init",), 0x8091A2D8:("BgUmajump_Destroy",), 0x8091A30C:("BgUmajump_Update",), 0x8091A5A0:("func_8091A5A0",), - 0x8091A7B0:("func_8091A7B0",), + 0x8091A7B0:("BgUmajump_Draw",), 0x8091A8A0:("func_8091A8A0",), 0x8091A8C4:("EnInsect_XZDistanceSquared",), 0x8091A8F4:("EnInsect_InBottleRange",), @@ -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",), @@ -7539,18 +7539,18 @@ 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:("ObjBlockstop_CheckForBlock",), @@ -7955,8 +7955,8 @@ 0x80968CB8:("func_80968CB8",), 0x80968DD0:("func_80968DD0",), 0x80968E38:("func_80968E38",), - 0x80968F48:("func_80968F48",), - 0x809691B8:("func_809691B8",), + 0x80968F48:("EnJs_GetRemainingMasks",), + 0x809691B8:("EnJs_TakeMask",), 0x809692A8:("func_809692A8",), 0x8096933C:("func_8096933C",), 0x80969400:("func_80969400",), @@ -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",), @@ -8057,18 +8057,18 @@ 0x80972680:("OceffSpot_SetupAction",), 0x8097268C:("OceffSpot_Init",), 0x809727EC:("OceffSpot_Destroy",), - 0x80972844:("func_80972844",), - 0x809728F8:("func_809728F8",), - 0x80972934:("func_80972934",), + 0x80972844:("OceffSpot_End",), + 0x809728F8:("OceffSpot_Wait",), + 0x80972934:("OceffSpot_GrowCylinder",), 0x80972998:("OceffSpot_Update",), 0x80972C54:("OceffSpot_Draw",), 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",), @@ -8129,25 +8129,25 @@ 0x809765A0:("OceffWipe_Draw",), 0x80977210:("EffectSsDust_Init",), 0x80977394:("EffectSsDust_Draw",), - 0x809776BC:("func_809776BC",), - 0x809777B4:("func_809777B4",), + 0x809776BC:("EffectSsDust_Update",), + 0x809777B4:("EffectSsDust_UpdateFire",), 0x80977A00:("EffectSsKirakira_Init",), 0x80977B5C:("EffectSsKirakira_Draw",), 0x80977DB4:("func_80977DB4",), 0x80977E6C:("func_80977E6C",), 0x80977F28:("func_80977F28",), 0x80978070:("EffectSsBomb2_Init",), - 0x80978138:("func_80978138",), - 0x80978304:("func_80978304",), + 0x80978138:("EffectSsBomb2_DrawFade",), + 0x80978304:("EffectSsBomb2_DrawLayered",), 0x80978628:("EffectSsBomb2_Update",), 0x809788D0:("EffectSsBlast_Init",), 0x809789FC:("EffectSsBlast_Draw",), 0x80978B68:("EffectSsBlast_Update",), 0x80978C30:("EffectSsGSpk_Init",), 0x80978D70:("EffectSsGSpk_Draw",), - 0x80978F40:("func_80978F40",), - 0x80979068:("func_80979068",), - 0x809791B0:("func_809791B0",), + 0x80978F40:("EffectSsGSpk_Update",), + 0x80979068:("EffectSsGSpk_UpdateNoAccel",), + 0x809791B0:("EffectSsDFire_CheckForObject",), 0x80979228:("EffectSsDFire_Init",), 0x8097930C:("EffectSsDFire_Draw",), 0x809794D4:("EffectSsDFire_Update",), @@ -8155,7 +8155,7 @@ 0x80979738:("EffectSsBubble_Draw",), 0x8097985C:("EffectSsBubble_Update",), 0x80979B30:("EffectSsGRipple_Init",), - 0x80979C38:("func_80979C38",), + 0x80979C38:("EffectSsGRipple_DrawRipple",), 0x80979E48:("EffectSsGRipple_Draw",), 0x80979E80:("EffectSsGRipple_Update",), 0x8097A050:("EffectSsGSplash_Init",), @@ -8171,10 +8171,10 @@ 0x8097AD60:("EffectSsDtBubble_Init",), 0x8097AF50:("EffectSsDtBubble_Draw",), 0x8097B160:("EffectSsDtBubble_Update",), - 0x8097B270:("func_8097B270",), + 0x8097B270:("EffectSsHahen_CheckForObject",), 0x8097B2E4:("EffectSsHahen_Init",), - 0x8097B424:("func_8097B424",), - 0x8097B504:("func_8097B504",), + 0x8097B424:("EffectSsHahen_DrawOpa",), + 0x8097B504:("EffectSsHahen_DrawXlu",), 0x8097B5E4:("EffectSsHahen_Draw",), 0x8097B708:("EffectSsHahen_Update",), 0x8097B810:("EffectSsStick_Init",), @@ -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",), @@ -8245,10 +8245,10 @@ 0x8098176C:("func_8098176C",), 0x809817E4:("OceffStorm_Init",), 0x80981904:("OceffStorm_Destroy",), - 0x80981928:("func_80981928",), + 0x80981928:("OceffStorm_DefaultAction",), 0x80981B48:("func_80981B48",), 0x80981B68:("OceffStorm_Update",), - 0x80981BB8:("func_80981BB8",), + 0x80981BB8:("OceffStorm_Draw2",), 0x80981D68:("OceffStorm_Draw",), 0x80983520:("ObjDemo_Init",), 0x80983634:("func_80983634",), @@ -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",), @@ -8412,19 +8412,19 @@ 0x8098F66C:("func_8098F66C",), 0x8098F680:("func_8098F680",), 0x8098F6FC:("ObjMure3_Update",), - 0x8098F800:("func_8098F800",), - 0x8098F8A8:("func_8098F8A8",), - 0x8098F928:("func_8098F928",), + 0x8098F800:("EnTg_ChangeAnim",), + 0x8098F8A8:("EnTg_UpdateCollider",), + 0x8098F928:("EnTg_UpdateSkelAnime",), 0x8098F954:("EnTg_Init",), 0x8098FA44:("EnTg_Destroy",), - 0x8098FA70:("func_8098FA70",), + 0x8098FA70:("EnTg_Idle",), 0x8098FB28:("EnTg_Update",), - 0x8098FBB4:("func_8098FBB4",), - 0x8098FBD0:("func_8098FBD0",), + 0x8098FBB4:("EnTg_OverrideLimbDraw",), + 0x8098FBD0:("EnTg_PostLimbDraw",), 0x8098FC2C:("EnTg_Draw",), - 0x8098FD50:("func_8098FD50",), - 0x8098FEA8:("func_8098FEA8",), - 0x8099000C:("func_8099000C",), + 0x8098FD50:("EnTg_SpawnHeart",), + 0x8098FEA8:("EnTg_UpdateHearts",), + 0x8099000C:("EnTg_DrawHearts",), 0x80990310:("EnWf_Init",), 0x80990784:("EnWf_Destroy",), 0x809907D4:("func_809907D4",), @@ -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",), @@ -8751,36 +8751,36 @@ 0x809A610C:("ObjBoyo_Draw",), 0x809A6280:("EnGrasshopper_Init",), 0x809A64E0:("EnGrasshopper_Destroy",), - 0x809A6524:("func_809A6524",), - 0x809A65D8:("func_809A65D8",), - 0x809A6628:("func_809A6628",), - 0x809A6668:("func_809A6668",), - 0x809A6754:("func_809A6754",), - 0x809A67A4:("func_809A67A4",), - 0x809A6B6C:("func_809A6B6C",), - 0x809A6E18:("func_809A6E18",), - 0x809A6E74:("func_809A6E74",), - 0x809A6F8C:("func_809A6F8C",), - 0x809A700C:("func_809A700C",), - 0x809A7134:("func_809A7134",), - 0x809A71CC:("func_809A71CC",), - 0x809A7494:("func_809A7494",), - 0x809A753C:("func_809A753C",), - 0x809A7844:("func_809A7844",), - 0x809A78EC:("func_809A78EC",), - 0x809A797C:("func_809A797C",), - 0x809A7A8C:("func_809A7A8C",), - 0x809A7AE4:("func_809A7AE4",), - 0x809A7BBC:("func_809A7BBC",), - 0x809A7C98:("func_809A7C98",), - 0x809A7CE0:("func_809A7CE0",), - 0x809A8044:("func_809A8044",), + 0x809A6524:("EnGrasshopper_ChangeAnim",), + 0x809A65D8:("EnGrasshopper_RaiseTail",), + 0x809A6628:("EnGrasshopper_LowerTail",), + 0x809A6668:("EnGrasshopper_DecideAction",), + 0x809A6754:("EnGrasshopper_SetupFly",), + 0x809A67A4:("EnGrasshopper_Fly",), + 0x809A6B6C:("EnGrasshopper_RoamInCircles",), + 0x809A6E18:("EnGrasshopper_SetupBank",), + 0x809A6E74:("EnGrasshopper_Turn",), + 0x809A6F8C:("EnGrasshopper_SetupBounced",), + 0x809A700C:("EnGrasshopper_Bounced",), + 0x809A7134:("EnGrasshopper_SetupApproachPlayer",), + 0x809A71CC:("EnGrasshopper_ApproachPlayer",), + 0x809A7494:("EnGrasshopper_SetupAttack",), + 0x809A753C:("EnGrasshopper_Attack",), + 0x809A7844:("EnGrasshopper_SetupWaitAfterAttack",), + 0x809A78EC:("EnGrasshopper_WaitAfterAttack",), + 0x809A797C:("EnGrasshopper_SetupDamaged",), + 0x809A7A8C:("EnGrasshopper_Damaged",), + 0x809A7AE4:("EnGrasshopper_SetupDead",), + 0x809A7BBC:("EnGrasshopper_Dead",), + 0x809A7C98:("EnGrasshopper_SetupFall",), + 0x809A7CE0:("EnGrasshopper_Fall",), + 0x809A8044:("EnGrasshopper_UpdateDamage",), 0x809A8224:("EnGrasshopper_Update",), - 0x809A847C:("func_809A847C",), + 0x809A847C:("EnGrasshopper_PostLimbDraw",), 0x809A8640:("EnGrasshopper_Draw",), - 0x809A8870:("func_809A8870",), - 0x809A8924:("func_809A8924",), - 0x809A8A64:("func_809A8A64",), + 0x809A8870:("EnGrasshopper_InitializeEffect",), + 0x809A8924:("EnGrasshopper_UpdateEffects",), + 0x809A8A64:("EnGrasshopper_DrawEffects",), 0x809A9110:("func_809A9110",), 0x809A91FC:("func_809A91FC",), 0x809A92D0:("func_809A92D0",), @@ -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,33 +9080,33 @@ 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",), + 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",), @@ -9125,14 +9125,14 @@ 0x809CA27C:("BgIcicle_Draw",), 0x809CA3F0:("EnSyatekiCrow_Init",), 0x809CA5A8:("EnSyatekiCrow_Destroy",), - 0x809CA5D4:("func_809CA5D4",), - 0x809CA67C:("func_809CA67C",), - 0x809CA71C:("func_809CA71C",), - 0x809CA840:("func_809CA840",), - 0x809CA8E4:("func_809CA8E4",), - 0x809CAAF8:("func_809CAAF8",), - 0x809CABC0:("func_809CABC0",), - 0x809CACD0:("func_809CACD0",), + 0x809CA5D4:("EnSyatekiCrow_SetupWaitForSpawn",), + 0x809CA67C:("EnSyatekiCrow_WaitForSpawn",), + 0x809CA71C:("EnSyatekiCrow_SetupWaitToMove",), + 0x809CA840:("EnSyatekiCrow_WaitToMove",), + 0x809CA8E4:("EnSyatekiCrow_Fly",), + 0x809CAAF8:("EnSyatekiCrow_SetupDead",), + 0x809CABC0:("EnSyatekiCrow_Dead",), + 0x809CACD0:("EnSyatekiCrow_UpdateDamage",), 0x809CADE8:("EnSyatekiCrow_Update",), 0x809CAE5C:("EnSyatekiCrow_OverrideLimbDraw",), 0x809CAF2C:("EnSyatekiCrow_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",), @@ -9749,7 +9749,7 @@ 0x80A16D6C:("EnRaf_ClearPixelPetal",), 0x80A16D90:("EnRaf_Init",), 0x80A17018:("EnRaf_Destroy",), - 0x80A17060:("EnRaf_ChangeAnimation",), + 0x80A17060:("EnRaf_ChangeAnim",), 0x80A1712C:("EnRaf_SetupIdle",), 0x80A171D8:("EnRaf_Idle",), 0x80A17414:("EnRaf_SetupGrab",), @@ -9769,9 +9769,9 @@ 0x80A181B4:("EnRaf_Update",), 0x80A1859C:("EnRaf_TransformLimbDraw",), 0x80A18A08:("EnRaf_Draw",), - 0x80A18A90:("EnRaf_InitializeParticle",), - 0x80A18B8C:("EnRaf_UpdateParticles",), - 0x80A18DA0:("EnRaf_DrawParticles",), + 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",), @@ -10063,23 +10063,23 @@ 0x80A2B390:("BgDblueMovebg_Draw",), 0x80A2BC00:("EnSyatekiDekunuts_Init",), 0x80A2BE28:("EnSyatekiDekunuts_Destroy",), - 0x80A2BE54:("func_80A2BE54",), - 0x80A2BF18:("func_80A2BF18",), - 0x80A2BFC4:("func_80A2BFC4",), - 0x80A2C0F8:("func_80A2C0F8",), - 0x80A2C150:("func_80A2C150",), - 0x80A2C168:("func_80A2C168",), - 0x80A2C1AC:("func_80A2C1AC",), - 0x80A2C208:("func_80A2C208",), - 0x80A2C27C:("func_80A2C27C",), - 0x80A2C2E0:("func_80A2C2E0",), - 0x80A2C33C:("func_80A2C33C",), - 0x80A2C3AC:("func_80A2C3AC",), - 0x80A2C3F0:("func_80A2C3F0",), - 0x80A2C478:("func_80A2C478",), - 0x80A2C48C:("func_80A2C48C",), - 0x80A2C4D0:("func_80A2C4D0",), - 0x80A2C5DC:("func_80A2C5DC",), + 0x80A2BE54:("EnSyatekiDekunuts_SetupWaitForSpawn",), + 0x80A2BF18:("EnSyatekiDekunuts_WaitForSpawn",), + 0x80A2BFC4:("EnSyatekiDekunuts_SetupSpawn",), + 0x80A2C0F8:("EnSyatekiDekunuts_Spawn",), + 0x80A2C150:("EnSyatekiDekunuts_SetupWaitToEmerge",), + 0x80A2C168:("EnSyatekiDekunuts_WaitToEmerge",), + 0x80A2C1AC:("EnSyatekiDekunuts_SetupEmerge",), + 0x80A2C208:("EnSyatekiDekunuts_Emerge",), + 0x80A2C27C:("EnSyatekiDekunuts_SetupLookAround",), + 0x80A2C2E0:("EnSyatekiDekunuts_LookAround",), + 0x80A2C33C:("EnSyatekiDekunuts_BonusLookAround",), + 0x80A2C3AC:("EnSyatekiDekunuts_SetupBurrow",), + 0x80A2C3F0:("EnSyatekiDekunuts_Burrow",), + 0x80A2C478:("EnSyatekiDekunuts_SetupGameEnd",), + 0x80A2C48C:("EnSyatekiDekunuts_GameEnd",), + 0x80A2C4D0:("EnSyatekiDekunuts_SetupDead",), + 0x80A2C5DC:("EnSyatekiDekunuts_Dead",), 0x80A2C78C:("EnSyatekiDekunuts_Update",), 0x80A2C8A0:("EnSyatekiDekunuts_OverrideLimbDraw",), 0x80A2C8E8:("EnSyatekiDekunuts_Draw",), @@ -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,27 +10244,27 @@ 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",), - 0x80A38B7C:("func_80A38B7C",), - 0x80A38BF0:("func_80A38BF0",), - 0x80A38C70:("func_80A38C70",), - 0x80A38DF4:("func_80A38DF4",), + 0x80A389A0:("EnRu_ChangeAnim",), + 0x80A38A68:("EnRu_PlayWalkingSound",), + 0x80A38B7C:("EnRu_UpdateEyes",), + 0x80A38BF0:("EnRu_UpdateCollider",), + 0x80A38C70:("EnRu_UpdateModel",), + 0x80A38DF4:("EnRu_DoNothing",), 0x80A38E04:("EnRu_Init",), 0x80A38F10:("EnRu_Destroy",), 0x80A38F3C:("EnRu_Update",), - 0x80A38FB4:("func_80A38FB4",), - 0x80A390F8:("func_80A390F8",), + 0x80A38FB4:("EnRu_OverrideLimbdraw",), + 0x80A390F8:("EnRu_PostLimbdraw",), 0x80A39204:("EnRu_Draw",), 0x80A396B0:("func_80A396B0",), 0x80A3970C:("EnElfgrp_Init",), @@ -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,36 +10436,36 @@ 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",), - 0x80A456A0:("func_80A456A0",), - 0x80A45CD8:("func_80A45CD8",), - 0x80A460A4:("func_80A460A4",), - 0x80A46280:("func_80A46280",), - 0x80A462F8:("func_80A462F8",), - 0x80A46414:("func_80A46414",), - 0x80A4668C:("func_80A4668C",), - 0x80A46764:("func_80A46764",), - 0x80A468CC:("func_80A468CC",), - 0x80A46990:("func_80A46990",), - 0x80A46C88:("func_80A46C88",), - 0x80A46CC4:("func_80A46CC4",), - 0x80A46DDC:("func_80A46DDC",), - 0x80A46E24:("func_80A46E24",), - 0x80A47000:("func_80A47000",), - 0x80A470D8:("func_80A470D8",), - 0x80A47298:("func_80A47298",), - 0x80A473B8:("func_80A473B8",), - 0x80A4767C:("func_80A4767C",), - 0x80A476C8:("func_80A476C8",), - 0x80A477E8:("func_80A477E8",), + 0x80A455C4:("EnWiz_ChangeAnim",), + 0x80A456A0:("EnWiz_HandleIntroCutscene",), + 0x80A45CD8:("EnWiz_SelectPlatform",), + 0x80A460A4:("EnWiz_MoveGhosts",), + 0x80A46280:("EnWiz_StartIntroCutscene",), + 0x80A462F8:("EnWiz_SetupAppear",), + 0x80A46414:("EnWiz_Appear",), + 0x80A4668C:("EnWiz_SetupDance",), + 0x80A46764:("EnWiz_Dance",), + 0x80A468CC:("EnWiz_SetupSecondPhaseCutscene",), + 0x80A46990:("EnWiz_SecondPhaseCutscene",), + 0x80A46C88:("EnWiz_SetupWindUp",), + 0x80A46CC4:("EnWiz_WindUp",), + 0x80A46DDC:("EnWiz_SetupAttack",), + 0x80A46E24:("EnWiz_Attack",), + 0x80A47000:("EnWiz_SetupDisappear",), + 0x80A470D8:("EnWiz_Disappear",), + 0x80A47298:("EnWiz_SetupDamaged",), + 0x80A473B8:("EnWiz_Damaged",), + 0x80A4767C:("EnWiz_SetupDead",), + 0x80A476C8:("EnWiz_Dead",), + 0x80A477E8:("EnWiz_UpdateDamage",), 0x80A47C6C:("EnWiz_Update",), - 0x80A47FCC:("func_80A47FCC",), - 0x80A48138:("func_80A48138",), + 0x80A47FCC:("EnWiz_PostLimbDrawOpa",), + 0x80A48138:("EnWiz_PostLimbDrawXlu",), 0x80A483B4:("EnWiz_Draw",), 0x80A48FE0:("EnWizBrock_Init",), 0x80A490B0:("EnWizBrock_Destroy",), @@ -10475,26 +10475,26 @@ 0x80A49308:("EnWizBrock_Draw",), 0x80A496A0:("EnWizFire_Init",), 0x80A497D4:("EnWizFire_Destroy",), - 0x80A4984C:("func_80A4984C",), - 0x80A49A44:("func_80A49A44",), - 0x80A49F38:("func_80A49F38",), - 0x80A49FD8:("func_80A49FD8",), - 0x80A4A11C:("func_80A4A11C",), - 0x80A4A608:("func_80A4A608",), + 0x80A4984C:("EnWiz_SetupMoveMagicProjectile",), + 0x80A49A44:("EnWiz_MoveMagicProjectile",), + 0x80A49F38:("EnWiz_SetupSmallFlame",), + 0x80A49FD8:("EnWiz_SmallFlame",), + 0x80A4A11C:("EnWiz_Pool",), + 0x80A4A608:("EnWiz_KillMagicProjectile",), 0x80A4A698:("EnWizFire_Update",), - 0x80A4B0C8:("func_80A4B0C8",), - 0x80A4B33C:("func_80A4B33C",), + 0x80A4B0C8:("EnWizFire_DrawIcePool",), + 0x80A4B33C:("EnWizFire_DrawFirePoolAndFlame",), 0x80A4B804:("EnWizFire_Draw",), - 0x80A4BAB4:("func_80A4BAB4",), - 0x80A4BC74:("func_80A4BC74",), - 0x80A4BDDC:("func_80A4BDDC",), - 0x80A4BF78:("func_80A4BF78",), + 0x80A4BAB4:("EnWizFire_DrawSmallFlame",), + 0x80A4BC74:("EnWizFire_InitializeEffect",), + 0x80A4BDDC:("EnWizFire_UpdateEffects",), + 0x80A4BF78:("EnWizFire_DrawEffects",), 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",), @@ -10620,7 +10620,7 @@ 0x80A53E60:("func_80A53E60",), 0x80A541F4:("func_80A541F4",), 0x80A54600:("func_80A54600",), - 0x80A54980:("func_80A54980",), + 0x80A54980:("ObjHugebombiwa_AddQuake",), 0x80A54A0C:("func_80A54A0C",), 0x80A54AC0:("ObjHugebombiwa_Init",), 0x80A54BC4:("ObjHugebombiwa_Destroy",), @@ -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",), @@ -10960,24 +10960,24 @@ 0x80A702B0:("EnMm3_PostLimbDraw",), 0x80A702F0:("EnMm3_Draw",), 0x80A706F0:("BgCraceMovebg_Init",), - 0x80A7090C:("func_80A7090C",), - 0x80A70970:("func_80A70970",), - 0x80A7099C:("func_80A7099C",), - 0x80A709E4:("func_80A709E4",), - 0x80A70A08:("func_80A70A08",), - 0x80A70A84:("func_80A70A84",), - 0x80A70A9C:("func_80A70A9C",), + 0x80A7090C:("BgCraceMovebg_GetRaceStatus",), + 0x80A70970:("BgCraceMovebg_OpeningDoor_SetupIdle",), + 0x80A7099C:("BgCraceMovebg_OpeningDoor_WaitToOpen",), + 0x80A709E4:("BgCraceMovebg_OpeningDoor_SetupOpen",), + 0x80A70A08:("BgCraceMovebg_OpeningDoor_Open",), + 0x80A70A84:("BgCraceMovebg_OpeningDoor_SetupDoNothing",), + 0x80A70A9C:("BgCraceMovebg_OpeningDoor_DoNothing",), 0x80A70AAC:("BgCraceMovebg_Destroy",), 0x80A70B60:("BgCraceMovebg_Update",), - 0x80A70C04:("func_80A70C04",), - 0x80A70D74:("func_80A70D74",), - 0x80A70DA8:("func_80A70DA8",), - 0x80A70E2C:("func_80A70E2C",), - 0x80A70E70:("func_80A70E70",), - 0x80A70F14:("func_80A70F14",), - 0x80A70F2C:("func_80A70F2C",), - 0x80A70FF4:("func_80A70FF4",), - 0x80A71040:("func_80A71040",), + 0x80A70C04:("BgCraceMovebg_ClosingDoor_CheckIfPlayerIsBeyondDoor",), + 0x80A70D74:("BgCraceMovebg_ClosingDoor_SetupIdle",), + 0x80A70DA8:("BgCraceMovebg_ClosingDoor_Idle",), + 0x80A70E2C:("BgCraceMovebg_ClosingDoor_SetupWaitToClose",), + 0x80A70E70:("BgCraceMovebg_ClosingDoor_WaitToClose",), + 0x80A70F14:("BgCraceMovebg_ClosingDoor_SetupClose",), + 0x80A70F2C:("BgCraceMovebg_ClosingDoor_Close",), + 0x80A70FF4:("BgCraceMovebg_ClosingDoor_SetupDoNothing",), + 0x80A71040:("BgCraceMovebg_ClosingDoor_DoNothing",), 0x80A71050:("BgCraceMovebg_Draw",), 0x80A711D0:("func_80A711D0",), 0x80A71424:("func_80A71424",), @@ -11108,48 +11108,48 @@ 0x80A7C5EC:("ObjEtcetera_Update",), 0x80A7C690:("ObjEtcetera_DrawIdle",), 0x80A7C718:("ObjEtcetera_DrawAnimated",), - 0x80A7C990:("func_80A7C990",), - 0x80A7CA18:("func_80A7CA18",), - 0x80A7CBC4:("func_80A7CBC4",), - 0x80A7CD08:("func_80A7CD08",), + 0x80A7C990:("EnEgol_ChangeAnim",), + 0x80A7CA18:("EnEgol_FootstepEffects",), + 0x80A7CBC4:("EnEgol_DestroyBlocks",), + 0x80A7CD08:("EnEgol_GetWaypoint",), 0x80A7CD60:("EnEgol_Init",), 0x80A7D0F0:("EnEgol_Destroy",), - 0x80A7D140:("func_80A7D140",), - 0x80A7D168:("func_80A7D168",), - 0x80A7D1E4:("func_80A7D1E4",), - 0x80A7D240:("func_80A7D240",), - 0x80A7D27C:("func_80A7D27C",), - 0x80A7D2C4:("func_80A7D2C4",), - 0x80A7D710:("func_80A7D710",), - 0x80A7D780:("func_80A7D780",), - 0x80A7DAAC:("func_80A7DAAC",), - 0x80A7DAF0:("func_80A7DAF0",), - 0x80A7E2E8:("func_80A7E2E8",), - 0x80A7E344:("func_80A7E344",), - 0x80A7E478:("func_80A7E478",), - 0x80A7E4B4:("func_80A7E4B4",), - 0x80A7E7EC:("func_80A7E7EC",), - 0x80A7E820:("func_80A7E820",), - 0x80A7E924:("func_80A7E924",), - 0x80A7E970:("func_80A7E970",), - 0x80A7E9D0:("func_80A7E9D0",), - 0x80A7EA28:("func_80A7EA28",), - 0x80A7EA88:("func_80A7EA88",), - 0x80A7EAD8:("func_80A7EAD8",), - 0x80A7EB14:("func_80A7EB14",), - 0x80A7EB54:("func_80A7EB54",), - 0x80A7EB90:("func_80A7EB90",), - 0x80A7EBDC:("func_80A7EBDC",), - 0x80A7EC84:("func_80A7EC84",), - 0x80A7ED14:("func_80A7ED14",), - 0x80A7EFB8:("func_80A7EFB8",), + 0x80A7D140:("EnEgol_SetupWait",), + 0x80A7D168:("EnEgol_Wait",), + 0x80A7D1E4:("EnEgol_SetupStand",), + 0x80A7D240:("EnEgol_Stand",), + 0x80A7D27C:("EnEgol_SetupWalk",), + 0x80A7D2C4:("EnEgol_Walk",), + 0x80A7D710:("EnEgol_SetupRetreat",), + 0x80A7D780:("EnEgol_Retreat",), + 0x80A7DAAC:("EnEgol_SetupLaser",), + 0x80A7DAF0:("EnEgol_Laser",), + 0x80A7E2E8:("EnEgol_SetupStop",), + 0x80A7E344:("EnEgol_Stop",), + 0x80A7E478:("EnEgol_SetupSlam",), + 0x80A7E4B4:("EnEgol_Slam",), + 0x80A7E7EC:("EnEgol_SetupPunch",), + 0x80A7E820:("EnEgol_Punch",), + 0x80A7E924:("EnEgol_SetupSlamWait",), + 0x80A7E970:("EnEgol_SlamWait",), + 0x80A7E9D0:("EnEgol_SetupStunned",), + 0x80A7EA28:("EnEgol_Stunned",), + 0x80A7EA88:("EnEgol_SetupStunEnd",), + 0x80A7EAD8:("EnEgol_StunEnd",), + 0x80A7EB14:("EnEgol_SetupSlamEnd",), + 0x80A7EB54:("EnEgol_SlamEnd",), + 0x80A7EB90:("EnEgol_SetupDamaged",), + 0x80A7EBDC:("EnEgol_Damaged",), + 0x80A7EC84:("EnEgol_StartDeathCutscene",), + 0x80A7ED14:("EnEgol_Death",), + 0x80A7EFB8:("EnEgol_CollisionCheck",), 0x80A7F354:("EnEgol_Update",), - 0x80A7F8E8:("func_80A7F8E8",), - 0x80A7FAFC:("func_80A7FAFC",), + 0x80A7F8E8:("EnEgol_OverrideLimbDraw",), + 0x80A7FAFC:("EnEgol_PostLimbDraw",), 0x80A7FFB8:("EnEgol_Draw",), - 0x80A80508:("func_80A80508",), - 0x80A80750:("func_80A80750",), - 0x80A80904:("func_80A80904",), + 0x80A80508:("EnEgol_SpawnEffect",), + 0x80A80750:("EnEgol_UpdateEffects",), + 0x80A80904:("EnEgol_DrawEffects",), 0x80A811D0:("func_80A811D0",), 0x80A8120C:("func_80A8120C",), 0x80A81288:("func_80A81288",), @@ -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",), @@ -11226,8 +11226,8 @@ 0x80A86460:("func_80A86460",), 0x80A86674:("func_80A86674",), 0x80A86770:("func_80A86770",), - 0x80A868F8:("func_80A868F8",), - 0x80A86924:("func_80A86924",), + 0x80A868F8:("EnTru_UpdateSkelAnime",), + 0x80A86924:("EnTru_ChangeAnim",), 0x80A8697C:("func_80A8697C",), 0x80A869DC:("func_80A869DC",), 0x80A86B0C:("func_80A86B0C",), @@ -11270,7 +11270,7 @@ 0x80A8BFE0:("EnTrt_GetMushroom",), 0x80A8C168:("EnTrt_PayForMushroom",), 0x80A8C1E8:("EnTrt_Goodbye",), - 0x80A8C288:("EnTrt_SetupTryToGiveRedPotion",), + 0x80A8C288:("EnTrt_StartRedPotionConversation",), 0x80A8C488:("EnTrt_GiveRedPotionForKoume",), 0x80A8C564:("EnTrt_GivenRedPotionForKoume",), 0x80A8C64C:("EnTrt_EndConversation",), @@ -11327,8 +11327,8 @@ 0x80A8F7AC:("EnTrt_Init",), 0x80A8F7E8:("EnTrt_Destroy",), 0x80A8F828:("EnTrt_Update",), - 0x80A8F8C4:("EnTrt_UpdateHeadYawAndPitch",), - 0x80A8FA00:("EnTrt_UpdateHeadPosAndRot",), + 0x80A8F8C4:("EnTrt_TrackPlayer",), + 0x80A8FA00:("EnTrt_UpdateLimb",), 0x80A8FB34:("EnTrt_OverrideLimbDraw",), 0x80A8FBB4:("EnTrt_PostLimbDraw",), 0x80A8FC64:("EnTrt_TransformLimbDraw",), @@ -11409,13 +11409,13 @@ 0x80A98F94:("func_80A98F94",), 0x80A99EA0:("EnEstone_Init",), 0x80A9A1B0:("EnEstone_Destroy",), - 0x80A9A1DC:("func_80A9A1DC",), - 0x80A9A4B0:("func_80A9A4B0",), + 0x80A9A1DC:("EnEstone_Active",), + 0x80A9A4B0:("EnEstone_Inactive",), 0x80A9A4E0:("EnEstone_Update",), 0x80A9A600:("EnEstone_Draw",), - 0x80A9A774:("func_80A9A774",), - 0x80A9A870:("func_80A9A870",), - 0x80A9A9C0:("func_80A9A9C0",), + 0x80A9A774:("EnEstone_SpawnEffect",), + 0x80A9A870:("EnEstone_UpdateEffects",), + 0x80A9A9C0:("EnEstone_DrawEffects",), 0x80A9ACD0:("func_80A9ACD0",), 0x80A9ACF0:("func_80A9ACF0",), 0x80A9AD18:("func_80A9AD18",), @@ -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",), @@ -11629,12 +11629,12 @@ 0x80AAEABC:("DmChar07_DoNothing",), 0x80AAEACC:("DmChar07_Update",), 0x80AAEAF0:("DmChar07_Draw",), - 0x80AAF050:("func_80AAF050",), - 0x80AAF15C:("func_80AAF15C",), + 0x80AAF050:("DmChar08_UpdateEyes",), + 0x80AAF15C:("DmChar08_ChangeAnimation",), 0x80AAF1F8:("DmChar08_Init",), 0x80AAF5D8:("DmChar08_Destroy",), - 0x80AAF610:("func_80AAF610",), - 0x80AAF79C:("func_80AAF79C",), + 0x80AAF610:("DmChar08_WaitForSong",), + 0x80AAF79C:("DmChar08_SetupAppearCs",), 0x80AAF884:("func_80AAF884",), 0x80AAF8F4:("func_80AAF8F4",), 0x80AAFA18:("func_80AAFA18",), @@ -11642,30 +11642,30 @@ 0x80AAFAE4:("func_80AAFAE4",), 0x80AAFB04:("func_80AAFB04",), 0x80AAFB94:("func_80AAFB94",), - 0x80AAFBA4:("func_80AAFBA4",), + 0x80AAFBA4:("DmChar08_SpawnBubbles",), 0x80AAFCCC:("func_80AAFCCC",), - 0x80AAFE78:("func_80AAFE78",), + 0x80AAFE78:("DmChar08_DoNothing",), 0x80AAFE88:("func_80AAFE88",), 0x80AB01E8:("func_80AB01E8",), 0x80AB023C:("func_80AB023C",), 0x80AB032C:("func_80AB032C",), 0x80AB096C:("func_80AB096C",), - 0x80AB0A10:("func_80AB0A10",), + 0x80AB0A10:("DmChar08_UpdateCollision",), 0x80AB0CC8:("DmChar08_Update",), - 0x80AB0E3C:("func_80AB0E3C",), - 0x80AB0E7C:("func_80AB0E7C",), - 0x80AB0F90:("func_80AB0F90",), + 0x80AB0E3C:("DmChar08_OverrideLimbDraw",), + 0x80AB0E7C:("DmChar08_PostLimbDraw",), + 0x80AB0F90:("DmChar08_TransformLimbDraw",), 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",), @@ -11794,14 +11794,14 @@ 0x80AB9C4C:("func_80AB9C4C",), 0x80ABA7A0:("EnEgblock_Init",), 0x80ABA868:("EnEgblock_Destroy",), - 0x80ABA8A4:("func_80ABA8A4",), - 0x80ABA988:("func_80ABA988",), - 0x80ABA9B8:("func_80ABA9B8",), + 0x80ABA8A4:("EnEgblock_Active",), + 0x80ABA988:("EnEgblock_Inactive",), + 0x80ABA9B8:("EnEgblock_DoNothing",), 0x80ABA9C8:("EnEgblock_Update",), 0x80ABAA14:("EnEgblock_Draw",), - 0x80ABAAF4:("func_80ABAAF4",), - 0x80ABACB4:("func_80ABACB4",), - 0x80ABAE64:("func_80ABAE64",), + 0x80ABAAF4:("EnEgblock_SpawnEffect",), + 0x80ABACB4:("EnEgblock_UpdateEffects",), + 0x80ABAE64:("EnEgblock_DrawEffects",), 0x80ABB0E0:("EnGuardNuts_Init",), 0x80ABB1E4:("EnGuardNuts_Destroy",), 0x80ABB210:("EnGuardNuts_ChangeAnim",), @@ -11902,21 +11902,21 @@ 0x80AC1D14:("EnPoFusen_Draw",), 0x80AC1ED0:("EnDoorEtc_Init",), 0x80AC2018:("EnDoorEtc_Destroy",), - 0x80AC2044:("func_80AC2044",), - 0x80AC20A8:("func_80AC20A8",), + 0x80AC2044:("EnDoorEtc_IsDistanceGreater",), + 0x80AC20A8:("EnDoorEtc_WaitForObject",), 0x80AC2118:("func_80AC2118",), 0x80AC2154:("func_80AC2154",), 0x80AC21A0:("func_80AC21A0",), 0x80AC2354:("func_80AC2354",), 0x80AC2430:("EnDoorEtc_Update",), - 0x80AC24A8:("func_80AC24A8",), + 0x80AC24A8:("EnDoorEtc_Draw",), 0x80AC26F0:("EnBigokuta_Init",), 0x80AC2874:("EnBigokuta_Destroy",), 0x80AC28B4:("EnBigokuta_SetupCutsceneCamera",), 0x80AC299C:("EnBigokuta_MoveCamera",), 0x80AC2A1C:("EnBigokuta_ResetCamera",), 0x80AC2A7C:("EnBigokuta_ShootPlayer",), - 0x80AC2B4C:("func_80AC2B4C",), + 0x80AC2B4C:("EnBigokuta_ValidatePictograph",), 0x80AC2B98:("EnBigokuta_IsInWater",), 0x80AC2C30:("EnBigokuta_SpawnRipple",), 0x80AC2C84:("EnBigokuta_SetupIdle",), @@ -11956,7 +11956,7 @@ 0x80AC5154:("TransitionTriforce_Update",), 0x80AC5268:("TransitionTriforce_SetColor",), 0x80AC5274:("TransitionTriforce_SetType",), - 0x80AC5280:("func_80AC5280",), + 0x80AC5280:("TransitionTriforce_SetState",), 0x80AC528C:("TransitionTriforce_Draw",), 0x80AC559C:("TransitionTriforce_IsDone",), 0x80AC57B0:("TransitionWipe1_Start",), @@ -12135,21 +12135,21 @@ 0x80AD02FC:("EnFuKago_Update",), 0x80AD0340:("func_80AD0340",), 0x80AD04A4:("EnFuKago_Draw",), - 0x80AD0830:("func_80AD0830",), - 0x80AD08B0:("func_80AD08B0",), - 0x80AD0998:("func_80AD0998",), - 0x80AD0A24:("func_80AD0A24",), - 0x80AD0AB0:("func_80AD0AB0",), - 0x80AD0B38:("func_80AD0B38",), - 0x80AD0E10:("func_80AD0E10",), - 0x80AD10FC:("func_80AD10FC",), - 0x80AD1398:("func_80AD1398",), - 0x80AD144C:("func_80AD144C",), - 0x80AD14C8:("func_80AD14C8",), - 0x80AD1634:("func_80AD1634",), - 0x80AD16A8:("func_80AD16A8",), - 0x80AD19A0:("func_80AD19A0",), - 0x80AD1A4C:("EnOsn_Idle",), + 0x80AD0830:("EnOsn_UpdateCollider",), + 0x80AD08B0:("EnOsn_GetMaskText",), + 0x80AD0998:("EnOsn_TurnAround",), + 0x80AD0A24:("EnOsn_LookFromMask",), + 0x80AD0AB0:("EnOsn_FadeOut",), + 0x80AD0B38:("EnOsn_GetInitialMaskText",), + 0x80AD0E10:("EnOsn_GetInitialText",), + 0x80AD10FC:("EnOsn_HandleConversation",), + 0x80AD1398:("EnOsn_InitCutscene",), + 0x80AD144C:("EnOsn_ChooseAction",), + 0x80AD14C8:("EnOsn_Idle",), + 0x80AD1634:("EnOsn_StartCutscene",), + 0x80AD16A8:("EnOsn_HandleCsAction",), + 0x80AD19A0:("EnOsn_Talk",), + 0x80AD1A4C:("EnOsn_DoNothing",), 0x80AD1A5C:("EnOsn_Init",), 0x80AD1C88:("EnOsn_Destroy",), 0x80AD1CC8:("EnOsn_Update",), @@ -12163,7 +12163,7 @@ 0x80AD3054:("BgCtowerGear_UpdateOrgan",), 0x80AD3124:("BgCtowerGear_Draw",), 0x80AD3164:("BgCtowerGear_DrawOrgan",), - 0x80AD3380:("func_80AD3380",), + 0x80AD3380:("EnTrt2_ChangeAnim",), 0x80AD341C:("func_80AD341C",), 0x80AD349C:("func_80AD349C",), 0x80AD3530:("func_80AD3530",), @@ -12330,15 +12330,15 @@ 0x80ADD7B4:("func_80ADD7B4",), 0x80ADD7CC:("EnSellnuts_TransformLimbDraw",), 0x80ADD8A4:("EnSellnuts_Draw",), - 0x80ADE230:("func_80ADE230",), + 0x80ADE230:("BgDkjailIvy_IvyCutEffects",), 0x80ADE5A4:("BgDkjailIvy_Init",), 0x80ADE664:("BgDkjailIvy_Destroy",), - 0x80ADE6AC:("func_80ADE6AC",), - 0x80ADE6C0:("func_80ADE6C0",), - 0x80ADE734:("func_80ADE734",), - 0x80ADE748:("func_80ADE748",), - 0x80ADE7E0:("func_80ADE7E0",), - 0x80ADE7F4:("func_80ADE7F4",), + 0x80ADE6AC:("BgDkjailIvy_SetupWaitForCut",), + 0x80ADE6C0:("BgDkjailIvy_WaitForCut",), + 0x80ADE734:("BgDkjailIvy_SetupCutscene",), + 0x80ADE748:("BgDkjailIvy_BeginCutscene",), + 0x80ADE7E0:("BgDkjailIvy_SetupFadeOut",), + 0x80ADE7F4:("BgDkjailIvy_FadeOut",), 0x80ADE850:("BgDkjailIvy_Update",), 0x80ADE874:("BgDkjailIvy_Draw",), 0x80ADEA70:("ObjVisiblock_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",), @@ -13136,8 +13136,8 @@ 0x80B1861C:("EnSnowman_Dead",), 0x80B18908:("EnSnowman_SetupSplitDoNothing",), 0x80B189C4:("EnSnowman_SplitDoNothing",), - 0x80B189D4:("EnSnowman_SetupMarkForDeath",), - 0x80B18A04:("EnSnowman_MarkForDeath",), + 0x80B189D4:("EnSnowman_SetupKill",), + 0x80B18A04:("EnSnowman_Kill",), 0x80B18A28:("EnSnowman_CreateSplitEeno",), 0x80B18B30:("EnSnowman_AbsorbEeno",), 0x80B18BB4:("EnSnowman_SetupCombine",), @@ -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,7 +13277,7 @@ 0x80B23F50:("ObjWind_Destroy",), 0x80B23F60:("ObjWind_Update",), 0x80B243C0:("ObjWind_Draw",), - 0x80B24630:("EnRacedog_ChangeAnimation",), + 0x80B24630:("EnRacedog_ChangeAnim",), 0x80B246F4:("EnRacedog_UpdateCollision",), 0x80B2478C:("EnRacedog_GetYRotation",), 0x80B248B8:("EnRacedog_GetFloorRot",), @@ -13293,7 +13293,7 @@ 0x80B25448:("EnRacedog_UpdateRunAnimationPlaySpeed",), 0x80B25490:("EnRacedog_IsOverFinishLine",), 0x80B255AC:("EnRacedog_SpawnFloorDustRing",), - 0x80B256BC:("EnRacedog_PlayWalkSfx",), + 0x80B256BC:("EnRacedog_PlaySfxWalk",), 0x80B25708:("EnRacedog_Update",), 0x80B2583C:("EnRacedog_UpdateSelectionArrow",), 0x80B258D8:("EnRacedog_DrawSelectionArrow",), @@ -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",), @@ -13616,7 +13616,7 @@ 0x80B3C80C:("ObjGhaka_Update",), 0x80B3C858:("ObjGhaka_Draw",), 0x80B3CA20:("func_80B3CA20",), - 0x80B3CC38:("func_80B3CC38",), + 0x80B3CC38:("EnDnp_ChangeAnim",), 0x80B3CC80:("func_80B3CC80",), 0x80B3CD1C:("func_80B3CD1C",), 0x80B3CDA4:("func_80B3CDA4",), @@ -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",), @@ -14230,15 +14230,15 @@ 0x80B64DFC:("func_80B64DFC",), 0x80B654C0:("ObjKendoKanban_Init",), 0x80B65840:("ObjKendoKanban_Destroy",), - 0x80B65880:("func_80B65880",), - 0x80B65894:("func_80B65894",), - 0x80B658A4:("func_80B658A4",), - 0x80B65CE0:("func_80B65CE0",), - 0x80B65D54:("func_80B65D54",), - 0x80B65D68:("func_80B65D68",), - 0x80B65DA8:("func_80B65DA8",), - 0x80B6618C:("func_80B6618C",), - 0x80B66304:("func_80B66304",), + 0x80B65880:("ObjKendoKanban_SetupDoNothing",), + 0x80B65894:("ObjKendoKanban_DoNothing",), + 0x80B658A4:("ObjKendoKanban_SetupTumble",), + 0x80B65CE0:("ObjKendoKanban_Tumble",), + 0x80B65D54:("ObjKendoKanban_SetupSettled",), + 0x80B65D68:("ObjKendoKanban_Settled",), + 0x80B65DA8:("ObjKendoKanban_HandlePhysics",), + 0x80B6618C:("ObjKendoKanban_IsPlayerOnTop",), + 0x80B66304:("ObjKendoKanban_UpdateCollision",), 0x80B66418:("ObjKendoKanban_Update",), 0x80B66454:("ObjKendoKanban_Draw",), 0x80B66A20:("ObjHariko_Init",), @@ -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",), @@ -14322,21 +14322,21 @@ 0x80B6ED58:("BgKin2Fence_DoNothing",), 0x80B6ED68:("BgKin2Fence_Update",), 0x80B6ED8C:("BgKin2Fence_Draw",), - 0x80B6EFA0:("func_80B6EFA0",), - 0x80B6EFEC:("func_80B6EFEC",), - 0x80B6F098:("func_80B6F098",), + 0x80B6EFA0:("BgKin2Picture_IsSkulltulaCollected",), + 0x80B6EFEC:("BgKin2Picture_SpawnSkulltula",), + 0x80B6F098:("BgKin2Picture_SpawnDust",), 0x80B6F2DC:("BgKin2Picture_Init",), 0x80B6F478:("BgKin2Picture_Destroy",), - 0x80B6F4C0:("func_80B6F4C0",), - 0x80B6F4D4:("func_80B6F4D4",), - 0x80B6F5A4:("func_80B6F5A4",), - 0x80B6F5B8:("func_80B6F5B8",), - 0x80B6F61C:("func_80B6F61C",), - 0x80B6F640:("func_80B6F640",), - 0x80B6F708:("func_80B6F708",), - 0x80B6F72C:("func_80B6F72C",), - 0x80B6F8F8:("func_80B6F8F8",), - 0x80B6F90C:("func_80B6F90C",), + 0x80B6F4C0:("BgKin2Picture_SetupWait",), + 0x80B6F4D4:("BgKin2Picture_Wait",), + 0x80B6F5A4:("BgKin2Picture_SetupPlayCutscene",), + 0x80B6F5B8:("BgKin2Picture_PlayCutscene",), + 0x80B6F61C:("BgKin2Picture_SetupShiver",), + 0x80B6F640:("BgKin2Picture_Shiver",), + 0x80B6F708:("BgKin2Picture_SetupFall",), + 0x80B6F72C:("BgKin2Picture_Fall",), + 0x80B6F8F8:("BgKin2Picture_SetupDoNothing",), + 0x80B6F90C:("BgKin2Picture_DoNothing",), 0x80B6F91C:("BgKin2Picture_Update",), 0x80B6F940:("BgKin2Picture_Draw",), 0x80B6FB30:("func_80B6FB30",), @@ -14437,7 +14437,7 @@ 0x80B75658:("EnJg_OverrideLimbDraw",), 0x80B75708:("EnJg_PostLimbDraw",), 0x80B757AC:("EnJg_Draw",), - 0x80B76030:("func_80B76030",), + 0x80B76030:("EnTruMt_ChangeAnim",), 0x80B76110:("func_80B76110",), 0x80B76188:("func_80B76188",), 0x80B761FC:("func_80B761FC",), @@ -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",), @@ -14659,8 +14659,8 @@ 0x80B85858:("func_80B85858",), 0x80B85900:("func_80B85900",), 0x80B85A00:("func_80B85A00",), - 0x80B85E18:("func_80B85E18",), - 0x80B85EA0:("func_80B85EA0",), + 0x80B85E18:("EnKaizoku_ChangeAnim",), + 0x80B85EA0:("EnKaizoku_ValidatePictograph",), 0x80B85F48:("func_80B85F48",), 0x80B85FA8:("func_80B85FA8",), 0x80B86804:("func_80B86804",), @@ -14698,10 +14698,10 @@ 0x80B8971C:("func_80B8971C",), 0x80B89A08:("func_80B89A08",), 0x80B8A0A0:("EnKaizoku_Update",), - 0x80B8A318:("func_80B8A318",), - 0x80B8A468:("func_80B8A468",), - 0x80B8A6B0:("func_80B8A6B0",), - 0x80B8A718:("func_80B8A718",), + 0x80B8A318:("EnKaizoku_OverrideLimbDraw",), + 0x80B8A468:("EnKaizoku_PostLimbDraw",), + 0x80B8A6B0:("EnKaizoku_TransformLimbDraw",), + 0x80B8A718:("EnKaizoku_Draw",), 0x80B8B2D0:("EnGe2_Init",), 0x80B8B504:("EnGe2_Destroy",), 0x80B8B514:("func_80B8B514",), @@ -14954,7 +14954,7 @@ 0x80B9A8E8:("ObjY2lift_Draw",), 0x80B9A980:("ObjY2shutter_Init",), 0x80B9A9EC:("ObjY2shutter_Destroy",), - 0x80B9AA20:("func_80B9AA20",), + 0x80B9AA20:("ObjY2shutter_SetupOpen",), 0x80B9AA54:("ObjY2shutter_Update",), 0x80B9AE00:("ObjY2shutter_Draw",), 0x80B9AF50:("func_80B9AF50",), @@ -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",), @@ -15251,26 +15251,26 @@ 0x80BAE538:("EnSuttari_Draw",), 0x80BAEF70:("EnZod_Init",), 0x80BAF1C0:("EnZod_Destroy",), - 0x80BAF1EC:("func_80BAF1EC",), - 0x80BAF2B4:("func_80BAF2B4",), - 0x80BAF338:("func_80BAF338",), - 0x80BAF3E0:("func_80BAF3E0",), - 0x80BAF4D8:("func_80BAF4D8",), + 0x80BAF1EC:("EnZod_HandleRoomConversation",), + 0x80BAF2B4:("EnZod_PlayerIsFacingTijo",), + 0x80BAF338:("EnZod_ChangeAnim",), + 0x80BAF3E0:("EnZod_UpdateAnimation",), + 0x80BAF4D8:("EnZod_UpdateInstruments",), 0x80BAF7CC:("func_80BAF7CC",), - 0x80BAF99C:("func_80BAF99C",), + 0x80BAF99C:("EnZod_PlayDrumsSequence",), 0x80BAFA44:("func_80BAFA44",), 0x80BAFADC:("func_80BAFADC",), 0x80BAFB84:("func_80BAFB84",), - 0x80BAFC00:("func_80BAFC00",), - 0x80BAFC10:("func_80BAFC10",), - 0x80BAFD00:("func_80BAFD00",), + 0x80BAFC00:("EnZod_DoNothing",), + 0x80BAFC10:("EnZod_Rehearse",), + 0x80BAFD00:("EnZod_SetupRehearse",), 0x80BAFDB4:("func_80BAFDB4",), 0x80BAFE34:("func_80BAFE34",), 0x80BAFF14:("func_80BAFF14",), 0x80BAFF84:("EnZod_Update",), - 0x80BB0128:("func_80BB0128",), - 0x80BB0170:("func_80BB0170",), - 0x80BB01B0:("func_80BB01B0",), + 0x80BB0128:("EnZod_OverrideLimbDraw",), + 0x80BB0170:("EnZod_PostLimbDraw",), + 0x80BB01B0:("EnZod_DrawDrums",), 0x80BB03E8:("EnZod_Draw",), 0x80BB08E0:("EnKujiya_Init",), 0x80BB0998:("EnKujiya_Destroy",), @@ -15380,14 +15380,14 @@ 0x80BB9F24:("ObjChan_ChandelierAction",), 0x80BBA2FC:("ObjChan_InitPot",), 0x80BBA314:("ObjChan_PotAction",), - 0x80BBA488:("ObjChan_CreateSmashParticles",), + 0x80BBA488:("ObjChan_CreateSmashEffects",), 0x80BBA738:("ObjChan_Update",), 0x80BBA78C:("ObjChan_Draw",), 0x80BBA894:("ObjChan_DrawPot",), 0x80BBA930:("func_80BBA930",), 0x80BBACA0:("EnZos_Init",), 0x80BBAE60:("EnZos_Destroy",), - 0x80BBAE84:("func_80BBAE84",), + 0x80BBAE84:("EnZos_ChangeAnim",), 0x80BBAF5C:("func_80BBAF5C",), 0x80BBAFFC:("func_80BBAFFC",), 0x80BBB0D4:("func_80BBB0D4",), @@ -15414,46 +15414,46 @@ 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",), - 0x80BBFE8C:("func_80BBFE8C",), + 0x80BBFDB0:("EnNb_FindActor",), + 0x80BBFE60:("EnNb_UpdateSkelAnime",), + 0x80BBFE8C:("EnNb_ChangeAnim",), 0x80BBFF24:("func_80BBFF24",), 0x80BBFF90:("func_80BBFF90",), 0x80BBFFD4:("func_80BBFFD4",), @@ -15470,17 +15470,17 @@ 0x80BC0A18:("func_80BC0A18",), 0x80BC0B98:("func_80BC0B98",), 0x80BC0C0C:("func_80BC0C0C",), - 0x80BC0C80:("func_80BC0C80",), + 0x80BC0C80:("EnNb_ProcessScheduleOutput",), 0x80BC0D08:("func_80BC0D08",), - 0x80BC0D1C:("func_80BC0D1C",), - 0x80BC0D84:("func_80BC0D84",), + 0x80BC0D1C:("EnNb_HandleSchedule",), + 0x80BC0D84:("EnNb_FollowSchedule",), 0x80BC0EAC:("func_80BC0EAC",), 0x80BC0F60:("EnNb_Init",), 0x80BC1080:("EnNb_Destroy",), 0x80BC10C0:("EnNb_Update",), - 0x80BC1174:("func_80BC1174",), - 0x80BC11B4:("func_80BC11B4",), - 0x80BC1278:("func_80BC1278",), + 0x80BC1174:("EnNb_OverrideLimbDraw",), + 0x80BC11B4:("EnNb_PostLimbDraw",), + 0x80BC1278:("EnNb_TransformLimbDraw",), 0x80BC1374:("EnNb_Draw",), 0x80BC1900:("func_80BC1900",), 0x80BC192C:("func_80BC192C",), @@ -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",), @@ -15595,22 +15595,22 @@ 0x80BC7BBC:("OceffWipe5_Draw",), 0x80BC9270:("EnStoneheishi_Init",), 0x80BC9330:("EnStoneheishi_Destroy",), - 0x80BC935C:("func_80BC935C",), - 0x80BC941C:("func_80BC941C",), + 0x80BC935C:("EnStoneheishi_ChangeAnim",), + 0x80BC941C:("EnStoneheishi_TrackPlayer",), 0x80BC94B0:("func_80BC94B0",), 0x80BC9560:("func_80BC9560",), 0x80BC9660:("func_80BC9660",), 0x80BC9680:("func_80BC9680",), - 0x80BC98EC:("func_80BC98EC",), - 0x80BC9908:("func_80BC9908",), - 0x80BC9A10:("func_80BC9A10",), - 0x80BC9A2C:("func_80BC9A2C",), - 0x80BC9C88:("func_80BC9C88",), + 0x80BC98EC:("EnStoneheishi_SetupCheckGivenItem",), + 0x80BC9908:("EnStoneheishi_CheckGivenItem",), + 0x80BC9A10:("EnStoneheishi_SetupDrinkBottleProcess",), + 0x80BC9A2C:("EnStoneheishi_DrinkBottleProcess",), + 0x80BC9C88:("EnStoneheishi_GiveItemReward",), 0x80BC9D28:("func_80BC9D28",), 0x80BC9E50:("func_80BC9E50",), 0x80BC9EE4:("EnStoneheishi_Update",), - 0x80BCA0AC:("func_80BCA0AC",), - 0x80BCA104:("func_80BCA104",), + 0x80BCA0AC:("EnStoneheishi_OverrideLimbDraw",), + 0x80BCA104:("EnStoneheishi_PostLimbDraw",), 0x80BCA2AC:("EnStoneheishi_Draw",), 0x80BCA5A0:("OceffWipe6_Init",), 0x80BCA5F8:("OceffWipe6_Destroy",), @@ -15668,43 +15668,43 @@ 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",), - 0x80BCF398:("func_80BCF398",), - 0x80BCF468:("func_80BCF468",), - 0x80BCF4AC:("func_80BCF4AC",), - 0x80BCF5F0:("func_80BCF5F0",), - 0x80BCF634:("func_80BCF634",), - 0x80BCF68C:("func_80BCF68C",), - 0x80BCF6D0:("func_80BCF6D0",), - 0x80BCF710:("func_80BCF710",), - 0x80BCF778:("func_80BCF778",), - 0x80BCF7D8:("func_80BCF7D8",), - 0x80BCF88C:("func_80BCF88C",), - 0x80BCF8A0:("func_80BCF8A0",), - 0x80BCF93C:("func_80BCF93C",), - 0x80BCF95C:("func_80BCF95C",), - 0x80BCFC0C:("func_80BCFC0C",), + 0x80BCF354:("EnHg_SetupWait",), + 0x80BCF398:("EnHg_Wait",), + 0x80BCF468:("EnHg_SetupChasePlayer",), + 0x80BCF4AC:("EnHg_ChasePlayer",), + 0x80BCF5F0:("EnHg_SetupChasePlayerWait",), + 0x80BCF634:("EnHg_ChasePlayerWait",), + 0x80BCF68C:("EnHg_SetupReactToHit",), + 0x80BCF6D0:("EnHg_ReactToHit",), + 0x80BCF710:("EnHg_HandleTatlDialog",), + 0x80BCF778:("EnHg_PlayRedeadSfx",), + 0x80BCF7D8:("EnHg_UpdateCollision",), + 0x80BCF88C:("EnHg_SetupCutscene",), + 0x80BCF8A0:("EnHg_PlayCutscene",), + 0x80BCF93C:("EnHg_SetupCsAction",), + 0x80BCF95C:("EnHg_HandleCsAction",), + 0x80BCFC0C:("EnHg_WaitForPlayerAction",), 0x80BCFDC4:("EnHg_Update",), 0x80BCFE54:("EnHg_OverrideLimbDraw",), 0x80BCFE70:("EnHg_PostLimbDraw",), 0x80BCFEC4:("EnHg_Draw",), 0x80BD02B0:("EnHgo_Init",), 0x80BD03C0:("EnHgo_Destroy",), - 0x80BD03EC:("func_80BD03EC",), - 0x80BD0410:("func_80BD0410",), - 0x80BD0420:("func_80BD0420",), - 0x80BD0434:("func_80BD0434",), - 0x80BD049C:("func_80BD049C",), - 0x80BD04E0:("func_80BD04E0",), + 0x80BD03EC:("EnHgo_SetupDoNothing",), + 0x80BD0410:("EnHgo_DoNothing",), + 0x80BD0420:("EnHgo_SetupInitCollision",), + 0x80BD0434:("EnHgo_UpdateCollision",), + 0x80BD049C:("EnHgo_SetupTalk",), + 0x80BD04E0:("EnHgo_Talk",), 0x80BD064C:("EnHgo_SetupDialogueHandler",), 0x80BD0660:("EnHgo_DefaultDialogueHandler",), - 0x80BD06FC:("func_80BD06FC",), - 0x80BD0898:("func_80BD0898",), - 0x80BD0B8C:("func_80BD0B8C",), + 0x80BD06FC:("EnHgo_HandlePlayerChoice",), + 0x80BD0898:("EnHgo_HandleCsAction",), + 0x80BD0B8C:("EnHgo_UpdateModel",), 0x80BD0C30:("EnHgo_Update",), 0x80BD0CF0:("EnHgo_OverrideLimbDraw",), 0x80BD0D38:("EnHgo_PostLimbDraw",), @@ -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",), @@ -15765,16 +15765,16 @@ 0x80BD40D0:("func_80BD40D0",), 0x80BD4108:("ObjHgdoor_Init",), 0x80BD41B4:("ObjHgdoor_Destroy",), - 0x80BD41E8:("ObjHgdoor_SetupCheckShouldOpen",), - 0x80BD41FC:("ObjHgdoor_CheckShouldOpen",), - 0x80BD42AC:("func_80BD42AC",), - 0x80BD42C0:("func_80BD42C0",), - 0x80BD433C:("func_80BD433C",), - 0x80BD4358:("func_80BD4358",), - 0x80BD4460:("func_80BD4460",), - 0x80BD4478:("func_80BD4478",), - 0x80BD44D0:("func_80BD44D0",), - 0x80BD4500:("func_80BD4500",), + 0x80BD41E8:("ObjHgdoor_SetupIdle",), + 0x80BD41FC:("ObjHgdoor_Idle",), + 0x80BD42AC:("ObjHgdoor_SetupCutscene",), + 0x80BD42C0:("ObjHgdoor_PlayCutscene",), + 0x80BD433C:("ObjHgdoor_SetupCsAction",), + 0x80BD4358:("ObjHgdoor_HandleCsAction",), + 0x80BD4460:("ObjHgdoor_SetupStopCs",), + 0x80BD4478:("ObjHgdoor_StopCs",), + 0x80BD44D0:("ObjHgdoor_Rotate",), + 0x80BD4500:("ObjHgdoor_Open",), 0x80BD4540:("ObjHgdoor_Update",), 0x80BD4570:("ObjHgdoor_Draw",), 0x80BD4720:("func_80BD4720",), @@ -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,9 +16059,9 @@ 0x80BE1550:("EnTab_Update",), 0x80BE1648:("EnTab_OverrideLimbDraw",), 0x80BE16B4:("EnTab_PostLimbDraw",), - 0x80BE1704:("EnTab_TransformDraw",), + 0x80BE1704:("EnTab_TransformLimbDraw",), 0x80BE1810:("EnTab_Draw",), - 0x80BE1C80:("func_80BE1C80",), + 0x80BE1C80:("EnNimotsu_UpdateCollision",), 0x80BE1CEC:("EnNimotsu_Init",), 0x80BE1D5C:("EnNimotsu_Destroy",), 0x80BE1D88:("EnNimotsu_Update",), @@ -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",), @@ -16399,16 +16399,16 @@ 0x80BFB0E0:("EnYb_PostLimbDrawXlu",), 0x80BFB14C:("EnYb_Draw",), 0x80BFB480:("EnRz_Init",), - 0x80BFB780:("func_80BFB780",), - 0x80BFB864:("func_80BFB864",), + 0x80BFB780:("EnRz_ActorShadowFunc",), + 0x80BFB864:("EnRz_ChangeAnim",), 0x80BFB9E4:("func_80BFB9E4",), 0x80BFBA1C:("func_80BFBA1C",), - 0x80BFBA50:("func_80BFBA50",), - 0x80BFBB44:("func_80BFBB44",), - 0x80BFBC78:("func_80BFBC78",), + 0x80BFBA50:("EnRz_SetupPath",), + 0x80BFBB44:("EnRz_GetPathStatus",), + 0x80BFBC78:("EnRz_CanTalk",), 0x80BFBCEC:("func_80BFBCEC",), - 0x80BFBD54:("func_80BFBD54",), - 0x80BFBDA0:("func_80BFBDA0",), + 0x80BFBD54:("EnRz_UpdateSkelAnime",), + 0x80BFBDA0:("EnRz_FindSister",), 0x80BFBDFC:("func_80BFBDFC",), 0x80BFBE44:("EnRz_Destroy",), 0x80BFBE70:("func_80BFBE70",), @@ -16425,28 +16425,28 @@ 0x80BFC674:("func_80BFC674",), 0x80BFC728:("func_80BFC728",), 0x80BFC7E0:("func_80BFC7E0",), - 0x80BFC8AC:("func_80BFC8AC",), - 0x80BFC8F8:("func_80BFC8F8",), + 0x80BFC8AC:("EnRz_StopToThink",), + 0x80BFC8F8:("EnRz_Walk",), 0x80BFC9E4:("EnRz_Update",), - 0x80BFCAD0:("func_80BFCAD0",), + 0x80BFCAD0:("EnRz_PostLimbDraw",), 0x80BFCB3C:("EnRz_Draw",), - 0x80BFCFA0:("func_80BFCFA0",), - 0x80BFCFB8:("func_80BFCFB8",), + 0x80BFCFA0:("EnScopecoin_Spin",), + 0x80BFCFB8:("EnScopecoin_CheckCollectible",), 0x80BFD010:("EnScopecoin_Init",), 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",), @@ -16552,9 +16552,9 @@ 0x80C05DE8:("func_80C05DE8",), 0x80C05E7C:("EnBombal_Update",), 0x80C05F30:("EnBombal_Draw",), - 0x80C05F90:("func_80C05F90",), - 0x80C060B8:("func_80C060B8",), - 0x80C06208:("func_80C06208",), + 0x80C05F90:("EnBombal_InitEffects",), + 0x80C060B8:("EnBombal_UpdateEffects",), + 0x80C06208:("EnBombal_DrawEffects",), 0x80C06510:("ObjMoonStone_Init",), 0x80C0661C:("ObjMoonStone_Destroy",), 0x80C0662C:("func_80C0662C",), @@ -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",), @@ -16990,25 +16990,25 @@ 0x80C1E84C:("EnEndingHero_Draw",), 0x80C1E9E0:("DmBal_Init",), 0x80C1EAB4:("DmBal_Destroy",), - 0x80C1EAC4:("func_80C1EAC4",), - 0x80C1EAD8:("func_80C1EAD8",), + 0x80C1EAC4:("DmBal_SetupDoNothing",), + 0x80C1EAD8:("DmBal_DoNothing",), 0x80C1EAE8:("func_80C1EAE8",), 0x80C1EC60:("func_80C1EC60",), - 0x80C1ED0C:("func_80C1ED0C",), - 0x80C1ED64:("func_80C1ED64",), + 0x80C1ED0C:("DmBal_UpdateEyes",), + 0x80C1ED64:("DmBal_SpawnPaper",), 0x80C1EDE4:("DmBal_Update",), - 0x80C1EF80:("func_80C1EF80",), - 0x80C1F060:("func_80C1F060",), + 0x80C1EF80:("DmBal_OverrideLimbDraw",), + 0x80C1F060:("DmBal_PostLimbDraw",), 0x80C1F078:("DmBal_Draw",), 0x80C1F3D0:("EnPaper_Init",), 0x80C1F45C:("EnPaper_Destroy",), - 0x80C1F46C:("func_80C1F46C",), - 0x80C1F480:("func_80C1F480",), - 0x80C1F4E8:("func_80C1F4E8",), - 0x80C1F4FC:("func_80C1F4FC",), - 0x80C1F55C:("func_80C1F55C",), - 0x80C1F6E0:("func_80C1F6E0",), - 0x80C1F87C:("func_80C1F87C",), + 0x80C1F46C:("EnPaper_SetupSpreadConfettiGroup",), + 0x80C1F480:("EnPaper_SpreadConfettiGroup",), + 0x80C1F4E8:("EnPaper_SetupFlyConfettiGroup",), + 0x80C1F4FC:("EnPaper_FlyConfettiGroup",), + 0x80C1F55C:("EnPaper_InitConfettiPiece",), + 0x80C1F6E0:("EnPaper_FlyConfettiPiece",), + 0x80C1F87C:("EnPaper_UpdateWind",), 0x80C1F97C:("EnPaper_Update",), 0x80C1F9D0:("EnPaper_Draw",), 0x80C1FCF0:("EnHintSkb_Init",), @@ -17125,8 +17125,8 @@ 0x80C256AC:("func_80C256AC",), 0x80C25710:("func_80C25710",), 0x80C2572C:("func_80C2572C",), - 0x80C25780:("func_80C25780",), - 0x80C25794:("func_80C25794",), + 0x80C25780:("ObjSwprize_SetupDoNothing",), + 0x80C25794:("ObjSwprize_DoNothing",), 0x80C257A4:("ObjSwprize_Update",), 0x80C258A0:("func_80C258A0",), 0x80C2590C:("func_80C2590C",), 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 fd8ee4d45..4bdd58c06 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), @@ -377,12 +377,12 @@ 0x801ADEC0:("En_Item00_InitVars","ActorInit","",0x20), 0x801ADEE0:("enItem00CylinderInit","ColliderCylinderInit","",0x2c), 0x801ADF0C:("enItem00InitVars","ActorInitVar","[1]",0x4), - 0x801ADF10:("D_801ADF10","ColorRGBA8","",0x4), - 0x801ADF14:("D_801ADF14","ColorRGBA8","",0x4), - 0x801ADF18:("D_801ADF18","Vec3f","",0xc), - 0x801ADF24:("D_801ADF24","Vec3f","",0xc), - 0x801ADF30:("D_801ADF30","UNK_PTR","[5]",0x14), - 0x801ADF44:("D_801ADF44","UNK_PTR","[12]",0x30), + 0x801ADF10:("sEffectPrimColor","ColorRGBA8","",0x4), + 0x801ADF14:("sEffectEnvColor","ColorRGBA8","",0x4), + 0x801ADF18:("sEffectVelocity","Vec3f","",0xc), + 0x801ADF24:("sEffectAccel","Vec3f","",0xc), + 0x801ADF30:("sRupeeTextures","UNK_PTR","[5]",0x14), + 0x801ADF44:("sItemDropTextures","UNK_PTR","[12]",0x30), 0x801ADF74:("sDropTable","u8","[272]",0x110), 0x801AE084:("sDropTableAmounts","u8","[272]",0x110), 0x801AE194:("D_801AE194","s32","[32]",0x80), @@ -454,87 +454,100 @@ 0x801B46DC:("sSceneSubdivisionList","BgCheckSceneSubdivisionEntry","[3]",0x24), 0x801B4700:("sCustomDynapolyMem","BgSpecialSceneMaxObjects","[1]",0x8), 0x801B4708:("D_801B4708","UNK_TYPE1","",0x1), - 0x801B4710:("D_801B4710","UNK_TYPE1","",0x1), - 0x801B4738:("D_801B4738","UNK_TYPE1","",0x1), - 0x801B4768:("D_801B4768","UNK_TYPE1","",0x1), - 0x801B4798:("D_801B4798","UNK_TYPE1","",0x1), - 0x801B47CC:("D_801B47CC","UNK_TYPE1","",0x1), - 0x801B47F0:("D_801B47F0","UNK_TYPE1","",0x1), - 0x801B4824:("D_801B4824","UNK_TYPE1","",0x1), - 0x801B4848:("D_801B4848","UNK_TYPE1","",0x1), - 0x801B486C:("D_801B486C","UNK_TYPE1","",0x1), - 0x801B4890:("D_801B4890","UNK_TYPE1","",0x1), - 0x801B48B0:("D_801B48B0","UNK_TYPE1","",0x1), - 0x801B48D4:("D_801B48D4","UNK_TYPE1","",0x1), - 0x801B48F8:("D_801B48F8","UNK_TYPE1","",0x1), - 0x801B491C:("D_801B491C","UNK_TYPE1","",0x1), - 0x801B4944:("D_801B4944","UNK_TYPE1","",0x1), - 0x801B4974:("D_801B4974","UNK_TYPE1","",0x1), - 0x801B49A4:("D_801B49A4","UNK_TYPE1","",0x1), - 0x801B49D4:("D_801B49D4","UNK_TYPE1","",0x1), - 0x801B4A04:("D_801B4A04","UNK_TYPE1","",0x1), - 0x801B4A34:("D_801B4A34","UNK_TYPE1","",0x1), - 0x801B4A5C:("D_801B4A5C","UNK_TYPE1","",0x1), - 0x801B4A8C:("D_801B4A8C","UNK_TYPE1","",0x1), - 0x801B4ABC:("D_801B4ABC","UNK_TYPE1","",0x1), - 0x801B4AE0:("D_801B4AE0","UNK_TYPE1","",0x1), - 0x801B4B08:("D_801B4B08","UNK_TYPE1","",0x1), - 0x801B4B38:("D_801B4B38","UNK_TYPE1","",0x1), - 0x801B4B60:("D_801B4B60","UNK_TYPE1","",0x1), - 0x801B4B90:("D_801B4B90","UNK_TYPE1","",0x1), - 0x801B4BB8:("D_801B4BB8","UNK_TYPE1","",0x1), - 0x801B4BDC:("D_801B4BDC","UNK_TYPE1","",0x1), - 0x801B4C04:("D_801B4C04","UNK_TYPE1","",0x1), - 0x801B4C34:("D_801B4C34","UNK_TYPE1","",0x1), - 0x801B4C5C:("D_801B4C5C","UNK_TYPE1","",0x1), - 0x801B4C84:("D_801B4C84","UNK_TYPE1","",0x1), - 0x801B4CAC:("D_801B4CAC","UNK_TYPE1","",0x1), - 0x801B4CD4:("D_801B4CD4","UNK_TYPE1","",0x1), - 0x801B4CFC:("D_801B4CFC","UNK_TYPE1","",0x1), - 0x801B4D24:("D_801B4D24","UNK_TYPE1","",0x1), - 0x801B4D34:("D_801B4D34","UNK_TYPE1","",0x1), - 0x801B4D44:("D_801B4D44","UNK_TYPE1","",0x1), - 0x801B4D68:("D_801B4D68","UNK_TYPE1","",0x1), - 0x801B4D8C:("D_801B4D8C","UNK_TYPE1","",0x1), - 0x801B4DB0:("D_801B4DB0","UNK_TYPE1","",0x1), - 0x801B4DD4:("D_801B4DD4","UNK_TYPE1","",0x1), - 0x801B4DF8:("D_801B4DF8","UNK_TYPE1","",0x1), - 0x801B4E2C:("D_801B4E2C","UNK_TYPE1","",0x1), - 0x801B4E5C:("D_801B4E5C","UNK_TYPE1","",0x1), - 0x801B4E90:("D_801B4E90","UNK_TYPE1","",0x1), - 0x801B4EB4:("D_801B4EB4","UNK_TYPE1","",0x1), - 0x801B4ED8:("D_801B4ED8","UNK_TYPE1","",0x1), - 0x801B4EDC:("D_801B4EDC","UNK_TYPE1","",0x1), - 0x801B4EE4:("D_801B4EE4","UNK_TYPE1","",0x1), + 0x801B4710:("sSetNormal0ModeNormalData","UNK_TYPE1","",0x1), + 0x801B4738:("sSetNormal0ModeTargetData","UNK_TYPE1","",0x1), + 0x801B4768:("sSetNormal0ModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B4798:("sSetNormal0ModeBattleData","UNK_TYPE1","",0x1), + 0x801B47CC:("sSetNormal0ModeFirstPersonData","UNK_TYPE1","",0x1), + 0x801B47F0:("sSetNormal0ModeTalkData","UNK_TYPE1","",0x1), + 0x801B4824:("sSetNormal0ModeClimbData","UNK_TYPE1","",0x1), + 0x801B4848:("sSetNormal0ModeBowArrowData","UNK_TYPE1","",0x1), + 0x801B486C:("sSetNormal0ModeBowArrowZData","UNK_TYPE1","",0x1), + 0x801B4890:("sSetNormal0ModeHookshotData","UNK_TYPE1","",0x1), + 0x801B48B0:("sSetNormal0ModeBoomerangData","UNK_TYPE1","",0x1), + 0x801B48D4:("sSetNormal0ModeSlingshotData","UNK_TYPE1","",0x1), + 0x801B48F8:("sSetNormal0ModeClimbZData","UNK_TYPE1","",0x1), + 0x801B4710:("sSetNormal0ModeNormalData","UNK_TYPE1","",0x1), + 0x801B4738:("sSetNormal0ModeTargetData","UNK_TYPE1","",0x1), + 0x801B4768:("sSetNormal0ModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B4798:("sSetNormal0ModeBattleData","UNK_TYPE1","",0x1), + 0x801B47CC:("sSetNormal0ModeFirstPersonData","UNK_TYPE1","",0x1), + 0x801B47F0:("sSetNormal0ModeTalkData","UNK_TYPE1","",0x1), + 0x801B4824:("sSetNormal0ModeClimbData","UNK_TYPE1","",0x1), + 0x801B4848:("sSetNormal0ModeBowArrowData","UNK_TYPE1","",0x1), + 0x801B486C:("sSetNormal0ModeBowArrowZData","UNK_TYPE1","",0x1), + 0x801B4890:("sSetNormal0ModeHookshotData","UNK_TYPE1","",0x1), + 0x801B48B0:("sSetNormal0ModeBoomerangData","UNK_TYPE1","",0x1), + 0x801B48D4:("sSetNormal0ModeSlingshotData","UNK_TYPE1","",0x1), + 0x801B48F8:("sSetNormal0ModeClimbZData","UNK_TYPE1","",0x1), + 0x801B491C:("sSetNormal0ModeJumpData","UNK_TYPE1","",0x1), + 0x801B4944:("sSetNormal0ModeHangData","UNK_TYPE1","",0x1), + 0x801B4974:("sSetNormal0ModeHangZData","UNK_TYPE1","",0x1), + 0x801B49A4:("sSetNormal0ModeFreeFallData","UNK_TYPE1","",0x1), + 0x801B49D4:("sSetNormal0ModeChargeData","UNK_TYPE1","",0x1), + 0x801B4A04:("sSetNormal0ModeChargeZData","UNK_TYPE1","",0x1), + 0x801B4A34:("sSetNormal0ModeStillData","UNK_TYPE1","",0x1), + 0x801B4A5C:("sSetNormal0ModePushPullData","UNK_TYPE1","",0x1), + 0x801B4A8C:("sSetNormal0ModeFollowBoomerangData","UNK_TYPE1","",0x1), + 0x801B4ABC:("sSetNormal0ModeDekuShootData","UNK_TYPE1","",0x1), + 0x801B4AE0:("sSetNormal0ModeGoronDashData","UNK_TYPE1","",0x1), + 0x801B4B08:("sSetNormal0ModeDekuHideData","UNK_TYPE1","",0x1), + 0x801B4B38:("sSetNormal0ModeDekuFlyData","UNK_TYPE1","",0x1), + 0x801B4B60:("sSetNormal0ModeDekuFlyZData","UNK_TYPE1","",0x1), + 0x801B4B90:("sSetNormal0ModeGoronJumpData","UNK_TYPE1","",0x1), + 0x801B4BB8:("sSetNormal0ModeZoraFinData","UNK_TYPE1","",0x1), + 0x801B4BDC:("sSetNormal3ModeNormalData","UNK_TYPE1","",0x1), + 0x801B4C04:("sSetNormal3ModeTargetData","UNK_TYPE1","",0x1), + 0x801B4C34:("sSetNormal3ModeFreeFallData","UNK_TYPE1","",0x1), + 0x801B4C5C:("sSetNormal3ModeGoronJumpData","UNK_TYPE1","",0x1), + 0x801B4C84:("sSetNormal3ModeDekuFlyData","UNK_TYPE1","",0x1), + 0x801B4CAC:("sSetNormal3ModeDekuHideData","UNK_TYPE1","",0x1), + 0x801B4CD4:("sSetNormal3ModeStillData","UNK_TYPE1","",0x1), + 0x801B4CFC:("sSetNormal3ModeGoronDashData","UNK_TYPE1","",0x1), + 0x801B4D24:("sSetPivotDivingModeNormalData","UNK_TYPE1","",0x1), + 0x801B4D34:("sSetPivotDivingModeTargetData","UNK_TYPE1","",0x1), + 0x801B4D44:("sSetHorseModeNormalData","UNK_TYPE1","",0x1), + 0x801B4D68:("sSetHorseModeTargetData","UNK_TYPE1","",0x1), + 0x801B4D8C:("sSetHorseModeJumpData","UNK_TYPE1","",0x1), + 0x801B4DB0:("sSetHorseModeBowArrowData","UNK_TYPE1","",0x1), + 0x801B4DD4:("sSetHorseModeSlingShotData","UNK_TYPE1","",0x1), + 0x801B4DF8:("sSetHorseModeBattleData","UNK_TYPE1","",0x1), + 0x801B4E2C:("sSetHorseModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B4E5C:("sSetHorseModeTalkData","UNK_TYPE1","",0x1), + 0x801B4E90:("sSetHorseModeStillData","UNK_TYPE1","",0x1), + 0x801B4EB4:("sSetZoraDivingModeNormalData","UNK_TYPE1","",0x1), + 0x801B4ED8:("sSetPrerendFixedModeNormalData","UNK_TYPE1","",0x1), + 0x801B4EDC:("sSetPrerendPivotModeNormalData","UNK_TYPE1","",0x1), + 0x801B4EE4:("sSetDoorCModeNormalData","UNK_TYPE1","",0x1), 0x801B4EF0:("D_801B4EF0","UNK_TYPE1","",0x1), - 0x801B4EF4:("D_801B4EF4","UNK_TYPE1","",0x1), + 0x801B4EF4:("sSetCutscenesModeNormalData","UNK_TYPE1","",0x1), 0x801B4EF8:("D_801B4EF8","UNK_TYPE1","",0x1), 0x801B4F20:("D_801B4F20","UNK_TYPE1","",0x1), 0x801B4F50:("D_801B4F50","UNK_TYPE1","",0x1), 0x801B4F78:("D_801B4F78","UNK_TYPE1","",0x1), - 0x801B4FA0:("D_801B4FA0","UNK_TYPE1","",0x1), - 0x801B4FC8:("D_801B4FC8","UNK_TYPE1","",0x1), + 0x801B4FA0:("sSetNormal1ModeNormalData","UNK_TYPE1","",0x1), + 0x801B4FC8:("sSetNormal1ModeStillData","UNK_TYPE1","",0x1), 0x801B4FF0:("D_801B4FF0","UNK_TYPE1","",0x1), 0x801B5018:("D_801B5018","UNK_TYPE1","",0x1), 0x801B5034:("D_801B5034","UNK_TYPE1","",0x1), 0x801B5050:("D_801B5050","UNK_TYPE1","",0x1), 0x801B506C:("D_801B506C","UNK_TYPE1","",0x1), - 0x801B507C:("D_801B507C","UNK_TYPE1","",0x1), - 0x801B5094:("D_801B5094","UNK_TYPE1","",0x1), - 0x801B50BC:("D_801B50BC","UNK_TYPE1","",0x1), - 0x801B50EC:("D_801B50EC","UNK_TYPE1","",0x1), - 0x801B511C:("D_801B511C","UNK_TYPE1","",0x1), - 0x801B5150:("D_801B5150","UNK_TYPE1","",0x1), - 0x801B5180:("D_801B5180","UNK_TYPE1","",0x1), - 0x801B51A8:("D_801B51A8","UNK_TYPE1","",0x1), - 0x801B51D8:("D_801B51D8","UNK_TYPE1","",0x1), - 0x801B51FC:("D_801B51FC","UNK_TYPE1","",0x1), - 0x801B5220:("D_801B5220","UNK_TYPE1","",0x1), - 0x801B5250:("D_801B5250","UNK_TYPE1","",0x1), - 0x801B5280:("D_801B5280","UNK_TYPE1","",0x1), - 0x801B52B0:("D_801B52B0","UNK_TYPE1","",0x1), - 0x801B52E0:("D_801B52E0","UNK_TYPE1","",0x1), - 0x801B5308:("D_801B5308","UNK_TYPE1","",0x1), + 0x801B507C:("sSetSpiralDoorModeNormalData","UNK_TYPE1","",0x1), + 0x801B5094:("sSetDungeon0ModeNormalData","UNK_TYPE1","",0x1), + 0x801B50BC:("sSetDungeon0ModeTargetData","UNK_TYPE1","",0x1), + 0x801B50EC:("sSetDungeon0ModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B511C:("sSetDungeon0ModeBattleData","UNK_TYPE1","",0x1), + 0x801B5150:("sSetDungeon0ModeFollowBoomerangData","UNK_TYPE1","",0x1), + 0x801B5180:("sSetDungeon0ModeJumpData","UNK_TYPE1","",0x1), + 0x801B51A8:("sSetDungeon0ModeFreeFallData","UNK_TYPE1","",0x1), + 0x801B51D8:("sSetDungeon0ModeClimbData","UNK_TYPE1","",0x1), + 0x801B51FC:("sSetDungeon0ModeClimbZData","UNK_TYPE1","",0x1), + 0x801B5220:("sSetDungeon0ModeChargeData","UNK_TYPE1","",0x1), + 0x801B5250:("sSetDungeon0ModeChargeZData","UNK_TYPE1","",0x1), + 0x801B5280:("sSetDungeon0ModeHangData","UNK_TYPE1","",0x1), + 0x801B52B0:("sSetDungeon0ModeHangZData","UNK_TYPE1","",0x1), + 0x801B52E0:("sSetDungeon0ModeStillData","UNK_TYPE1","",0x1), + 0x801B5308:("sSetDungeon0ModePushPullData","UNK_TYPE1","",0x1), 0x801B5338:("D_801B5338","UNK_TYPE1","",0x1), 0x801B535C:("D_801B535C","UNK_TYPE1","",0x1), 0x801B5380:("D_801B5380","UNK_TYPE1","",0x1), @@ -560,71 +573,71 @@ 0x801B5650:("D_801B5650","UNK_TYPE1","",0x1), 0x801B5674:("D_801B5674","UNK_TYPE1","",0x1), 0x801B5698:("D_801B5698","UNK_TYPE1","",0x1), - 0x801B56BC:("D_801B56BC","UNK_TYPE1","",0x1), - 0x801B56E0:("D_801B56E0","UNK_TYPE1","",0x1), - 0x801B5704:("D_801B5704","UNK_TYPE1","",0x1), + 0x801B56BC:("sSetDeathModeNormalData","UNK_TYPE1","",0x1), + 0x801B56E0:("sSetDeathModeJumpData","UNK_TYPE1","",0x1), + 0x801B5704:("sSetDeathModeDekuShootData","UNK_TYPE1","",0x1), 0x801B5728:("D_801B5728","UNK_TYPE1","",0x1), 0x801B574C:("D_801B574C","UNK_TYPE1","",0x1), - 0x801B5770:("D_801B5770","UNK_TYPE1","",0x1), - 0x801B577C:("D_801B577C","UNK_TYPE1","",0x1), - 0x801B57A4:("D_801B57A4","UNK_TYPE1","",0x1), - 0x801B57CC:("D_801B57CC","UNK_TYPE1","",0x1), - 0x801B57F4:("D_801B57F4","UNK_TYPE1","",0x1), + 0x801B5770:("sSetLongChestOpeningModeNormalData","UNK_TYPE1","",0x1), + 0x801B577C:("sSetDungeon1ModeNormalData","UNK_TYPE1","",0x1), + 0x801B57A4:("sSetDungeon1ModeJumpData","UNK_TYPE1","",0x1), + 0x801B57CC:("sSetDungeon1ModeStillData","UNK_TYPE1","",0x1), + 0x801B57F4:("sSetDungeon1ModePushPullData","UNK_TYPE1","",0x1), 0x801B5824:("D_801B5824","UNK_TYPE1","",0x1), 0x801B5834:("D_801B5834","UNK_TYPE1","",0x1), - 0x801B5844:("D_801B5844","UNK_TYPE1","",0x1), - 0x801B5864:("D_801B5864","UNK_TYPE1","",0x1), + 0x801B5844:("sSetMazeModeNormalData","UNK_TYPE1","",0x1), + 0x801B5864:("sSetRemoteBombModeNormalData","UNK_TYPE1","",0x1), 0x801B5884:("D_801B5884","UNK_TYPE1","",0x1), 0x801B58A0:("D_801B58A0","UNK_TYPE1","",0x1), 0x801B58BC:("D_801B58BC","UNK_TYPE1","",0x1), 0x801B58D8:("D_801B58D8","UNK_TYPE1","",0x1), 0x801B58F4:("D_801B58F4","UNK_TYPE1","",0x1), - 0x801B5904:("D_801B5904","UNK_TYPE1","",0x1), - 0x801B5928:("D_801B5928","UNK_TYPE1","",0x1), - 0x801B5950:("D_801B5950","UNK_TYPE1","",0x1), + 0x801B5904:("sSetTowerClimbModeNormalData","UNK_TYPE1","",0x1), + 0x801B5928:("sSetTowerClimbModeJumpData","UNK_TYPE1","",0x1), + 0x801B5950:("sSetTowerClimbModeStillData","UNK_TYPE1","",0x1), 0x801B5978:("D_801B5978","UNK_TYPE1","",0x1), 0x801B59A8:("D_801B59A8","UNK_TYPE1","",0x1), 0x801B59D0:("D_801B59D0","UNK_TYPE1","",0x1), 0x801B59F4:("D_801B59F4","UNK_TYPE1","",0x1), 0x801B5A00:("D_801B5A00","UNK_TYPE1","",0x1), - 0x801B5A0C:("D_801B5A0C","UNK_TYPE1","",0x1), - 0x801B5A30:("D_801B5A30","UNK_TYPE1","",0x1), + 0x801B5A0C:("sSetBoatCruiseModeNormalData","UNK_TYPE1","",0x1), + 0x801B5A30:("sSetVerticalClimbModeClimbData","UNK_TYPE1","",0x1), 0x801B5A64:("D_801B5A64","UNK_TYPE1","",0x1), - 0x801B5A94:("D_801B5A94","UNK_TYPE1","",0x1), - 0x801B5ABC:("D_801B5ABC","UNK_TYPE1","",0x1), - 0x801B5AF0:("D_801B5AF0","UNK_TYPE1","",0x1), - 0x801B5B18:("D_801B5B18","UNK_TYPE1","",0x1), - 0x801B5B40:("D_801B5B40","UNK_TYPE1","",0x1), - 0x801B5B70:("D_801B5B70","UNK_TYPE1","",0x1), - 0x801B5B98:("D_801B5B98","UNK_TYPE1","",0x1), - 0x801B5BC8:("D_801B5BC8","UNK_TYPE1","",0x1), - 0x801B5BFC:("D_801B5BFC","UNK_TYPE1","",0x1), - 0x801B5C30:("D_801B5C30","UNK_TYPE1","",0x1), - 0x801B5C58:("D_801B5C58","UNK_TYPE1","",0x1), + 0x801B5A94:("sSetDungeon2ModeNormalData","UNK_TYPE1","",0x1), + 0x801B5ABC:("sSetDungeon2ModeBattleData","UNK_TYPE1","",0x1), + 0x801B5AF0:("sSetDungeon2ModeJumpData","UNK_TYPE1","",0x1), + 0x801B5B18:("sSetDungeon2ModeStillData","UNK_TYPE1","",0x1), + 0x801B5B40:("sSetDungeon2ModePushPullData","UNK_TYPE1","",0x1), + 0x801B5B70:("sSetBossOdolwaModeNormalData","UNK_TYPE1","",0x1), + 0x801B5B98:("sSetBossOdolwaModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B5BC8:("sSetBossOdolwaModeTalkData","UNK_TYPE1","",0x1), + 0x801B5BFC:("sSetBossOdolwaModeBattleData","UNK_TYPE1","",0x1), + 0x801B5C30:("sSetBossOdolwaModeJumpData","UNK_TYPE1","",0x1), + 0x801B5C58:("sSetBossOdolwaModeStillData","UNK_TYPE1","",0x1), 0x801B5C80:("D_801B5C80","UNK_TYPE1","",0x1), 0x801B5CB0:("D_801B5CB0","UNK_TYPE1","",0x1), 0x801B5CCC:("D_801B5CCC","UNK_TYPE1","",0x1), - 0x801B5CE8:("D_801B5CE8","UNK_TYPE1","",0x1), - 0x801B5D10:("D_801B5D10","UNK_TYPE1","",0x1), - 0x801B5D40:("D_801B5D40","UNK_TYPE1","",0x1), - 0x801B5D74:("D_801B5D74","UNK_TYPE1","",0x1), - 0x801B5D9C:("D_801B5D9C","UNK_TYPE1","",0x1), + 0x801B5CE8:("sSetMiniBossModeNormalData","UNK_TYPE1","",0x1), + 0x801B5D10:("sSetMiniBossModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B5D40:("sSetMiniBossModeBattleData","UNK_TYPE1","",0x1), + 0x801B5D74:("sSetMiniBossModeJumpData","UNK_TYPE1","",0x1), + 0x801B5D9C:("sSetMiniBossModeStillData","UNK_TYPE1","",0x1), 0x801B5DC4:("D_801B5DC4","UNK_TYPE1","",0x1), - 0x801B5DD4:("D_801B5DD4","UNK_TYPE1","",0x1), - 0x801B5DFC:("D_801B5DFC","UNK_TYPE1","",0x1), + 0x801B5DD4:("sSetTreasureChestMinigameModeNormalData","UNK_TYPE1","",0x1), + 0x801B5DFC:("sSetTreasureChestMinigameModeTargetData","UNK_TYPE1","",0x1), 0x801B5E2C:("D_801B5E2C","UNK_TYPE1","",0x1), 0x801B5E48:("D_801B5E48","UNK_TYPE1","",0x1), 0x801B5E64:("D_801B5E64","UNK_TYPE1","",0x1), 0x801B5E8C:("D_801B5E8C","UNK_TYPE1","",0x1), - 0x801B5EB4:("D_801B5EB4","UNK_TYPE1","",0x1), - 0x801B5EDC:("D_801B5EDC","UNK_TYPE1","",0x1), - 0x801B5F0C:("D_801B5F0C","UNK_TYPE1","",0x1), - 0x801B5F34:("D_801B5F34","UNK_TYPE1","",0x1), - 0x801B5F5C:("D_801B5F5C","UNK_TYPE1","",0x1), - 0x801B5F8C:("D_801B5F8C","UNK_TYPE1","",0x1), - 0x801B5FB0:("D_801B5FB0","UNK_TYPE1","",0x1), - 0x801B5FD4:("D_801B5FD4","UNK_TYPE1","",0x1), - 0x801B5FF8:("D_801B5FF8","UNK_TYPE1","",0x1), + 0x801B5EB4:("sSetDungeon3ModeNormalData","UNK_TYPE1","",0x1), + 0x801B5EDC:("sSetDungeon3ModeTargetData","UNK_TYPE1","",0x1), + 0x801B5F0C:("sSetDungeon3ModeJumpData","UNK_TYPE1","",0x1), + 0x801B5F34:("sSetDungeon3ModeStillData","UNK_TYPE1","",0x1), + 0x801B5F5C:("sSetDungeon3ModePushPullData","UNK_TYPE1","",0x1), + 0x801B5F8C:("sSetTelescopeModeNormalData","UNK_TYPE1","",0x1), + 0x801B5FB0:("sSetTelescopeModeTargetData","UNK_TYPE1","",0x1), + 0x801B5FD4:("sSetTelescopeModeFirstPersonData","UNK_TYPE1","",0x1), + 0x801B5FF8:("sSetTelescopeModeDekuHideData","UNK_TYPE1","",0x1), 0x801B601C:("D_801B601C","UNK_TYPE1","",0x1), 0x801B6044:("D_801B6044","UNK_TYPE1","",0x1), 0x801B6074:("D_801B6074","UNK_TYPE1","",0x1), @@ -665,59 +678,59 @@ 0x801B6674:("D_801B6674","UNK_TYPE1","",0x1), 0x801B6698:("D_801B6698","UNK_TYPE1","",0x1), 0x801B66C0:("D_801B66C0","UNK_TYPE1","",0x1), - 0x801B66E8:("D_801B66E8","UNK_TYPE1","",0x1), - 0x801B6710:("D_801B6710","UNK_TYPE1","",0x1), - 0x801B6740:("D_801B6740","UNK_TYPE1","",0x1), - 0x801B6774:("D_801B6774","UNK_TYPE1","",0x1), - 0x801B679C:("D_801B679C","UNK_TYPE1","",0x1), - 0x801B67C4:("D_801B67C4","UNK_TYPE1","",0x1), - 0x801B67EC:("D_801B67EC","UNK_TYPE1","",0x1), - 0x801B681C:("D_801B681C","UNK_TYPE1","",0x1), - 0x801B684C:("D_801B684C","UNK_TYPE1","",0x1), - 0x801B6880:("D_801B6880","UNK_TYPE1","",0x1), - 0x801B68A8:("D_801B68A8","UNK_TYPE1","",0x1), - 0x801B68D0:("D_801B68D0","UNK_TYPE1","",0x1), - 0x801B68F8:("D_801B68F8","UNK_TYPE1","",0x1), - 0x801B692C:("D_801B692C","UNK_TYPE1","",0x1), - 0x801B6954:("D_801B6954","UNK_TYPE1","",0x1), - 0x801B697C:("D_801B697C","UNK_TYPE1","",0x1), - 0x801B69A4:("D_801B69A4","UNK_TYPE1","",0x1), - 0x801B69CC:("D_801B69CC","UNK_TYPE1","",0x1), - 0x801B69FC:("D_801B69FC","UNK_TYPE1","",0x1), - 0x801B6A30:("D_801B6A30","UNK_TYPE1","",0x1), - 0x801B6A58:("D_801B6A58","UNK_TYPE1","",0x1), - 0x801B6A80:("D_801B6A80","UNK_TYPE1","",0x1), - 0x801B6AA8:("D_801B6AA8","UNK_TYPE1","",0x1), - 0x801B6AD0:("D_801B6AD0","UNK_TYPE1","",0x1), - 0x801B6AF8:("D_801B6AF8","UNK_TYPE1","",0x1), - 0x801B6B28:("D_801B6B28","UNK_TYPE1","",0x1), - 0x801B6B50:("D_801B6B50","UNK_TYPE1","",0x1), - 0x801B6B78:("D_801B6B78","UNK_TYPE1","",0x1), - 0x801B6BA0:("D_801B6BA0","UNK_TYPE1","",0x1), - 0x801B6BC8:("D_801B6BC8","UNK_TYPE1","",0x1), - 0x801B6BF0:("D_801B6BF0","UNK_TYPE1","",0x1), - 0x801B6C18:("D_801B6C18","UNK_TYPE1","",0x1), - 0x801B6C48:("D_801B6C48","UNK_TYPE1","",0x1), - 0x801B6C70:("D_801B6C70","UNK_TYPE1","",0x1), + 0x801B66E8:("sSetBossMajoraModeNormalData","UNK_TYPE1","",0x1), + 0x801B6710:("sSetBossMajoraModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B6740:("sSetBossMajoraModeBattleData","UNK_TYPE1","",0x1), + 0x801B6774:("sSetBossMajoraModeJumpData","UNK_TYPE1","",0x1), + 0x801B679C:("sSetBossMajoraModeStillData","UNK_TYPE1","",0x1), + 0x801B67C4:("sSetBossTwinmoldModeNormalData","UNK_TYPE1","",0x1), + 0x801B67EC:("sSetBossTwinmoldModeTargetData","UNK_TYPE1","",0x1), + 0x801B681C:("sSetBossTwinmoldModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B684C:("sSetBossTwinmoldModeBattleData","UNK_TYPE1","",0x1), + 0x801B6880:("sSetBossTwinmoldModeJumpData","UNK_TYPE1","",0x1), + 0x801B68A8:("sSetBossTwinmoldModeStillData","UNK_TYPE1","",0x1), + 0x801B68D0:("sSetBossGohtModeNormalData","UNK_TYPE1","",0x1), + 0x801B68F8:("sSetBossGohtModeBattleData","UNK_TYPE1","",0x1), + 0x801B692C:("sSetBossGohtModeJumpData","UNK_TYPE1","",0x1), + 0x801B6954:("sSetBossGohtModeStillData","UNK_TYPE1","",0x1), + 0x801B697C:("sSetBossGohtModeGoronDashData","UNK_TYPE1","",0x1), + 0x801B69A4:("sSetBossGyorgModeNormalData","UNK_TYPE1","",0x1), + 0x801B69CC:("sSetBossGyorgModeFollowTargetData","UNK_TYPE1","",0x1), + 0x801B69FC:("sSetBossGyorgModeBattleData","UNK_TYPE1","",0x1), + 0x801B6A30:("sSetBossGyorgModeGoronJumpData","UNK_TYPE1","",0x1), + 0x801B6A58:("sSetBossGyorgModeDekuFlyData","UNK_TYPE1","",0x1), + 0x801B6A80:("sSetBossGyorgModeDekuHideData","UNK_TYPE1","",0x1), + 0x801B6AA8:("sSetBossGyorgModeStillData","UNK_TYPE1","",0x1), + 0x801B6AD0:("sSetPinnacleRockModeNormalData","UNK_TYPE1","",0x1), + 0x801B6AF8:("sSetPinnacleRockModeTargetData","UNK_TYPE1","",0x1), + 0x801B6B28:("sSetPinnacleRockModeGoronJumpData","UNK_TYPE1","",0x1), + 0x801B6B50:("sSetPinnacleRockModeDekuFlyData","UNK_TYPE1","",0x1), + 0x801B6B78:("sSetPinnacleRockModeDekuHideData","UNK_TYPE1","",0x1), + 0x801B6BA0:("sSetPinnacleRockModeStillData","UNK_TYPE1","",0x1), + 0x801B6BC8:("sSetPinnacleRockModeGoronDashData","UNK_TYPE1","",0x1), + 0x801B6BF0:("sSetNormal2ModeNormalData","UNK_TYPE1","",0x1), + 0x801B6C18:("sSetNormal2ModeTargetData","UNK_TYPE1","",0x1), + 0x801B6C48:("sSetNormal2ModeJumpData","UNK_TYPE1","",0x1), + 0x801B6C70:("sSetNormal2ModeStillData","UNK_TYPE1","",0x1), 0x801B6C98:("D_801B6C98","UNK_TYPE1","",0x1), 0x801B6CC0:("D_801B6CC0","UNK_TYPE1","",0x1), 0x801B6CF0:("D_801B6CF0","UNK_TYPE1","",0x1), 0x801B6D24:("D_801B6D24","UNK_TYPE1","",0x1), 0x801B6D4C:("D_801B6D4C","UNK_TYPE1","",0x1), 0x801B6D74:("D_801B6D74","UNK_TYPE1","",0x1), - 0x801B6D90:("D_801B6D90","UNK_TYPE1","",0x1), - 0x801B6DB8:("D_801B6DB8","UNK_TYPE1","",0x1), - 0x801B6DE0:("D_801B6DE0","UNK_TYPE1","",0x1), - 0x801B6E08:("D_801B6E08","UNK_TYPE1","",0x1), - 0x801B6E30:("D_801B6E30","UNK_TYPE1","",0x1), - 0x801B6E58:("D_801B6E58","UNK_TYPE1","",0x1), - 0x801B6E80:("D_801B6E80","UNK_TYPE1","",0x1), - 0x801B6EA8:("D_801B6EA8","UNK_TYPE1","",0x1), - 0x801B6ED0:("D_801B6ED0","UNK_TYPE1","",0x1), - 0x801B6EF8:("D_801B6EF8","UNK_TYPE1","",0x1), - 0x801B6F20:("D_801B6F20","UNK_TYPE1","",0x1), - 0x801B6F50:("D_801B6F50","UNK_TYPE1","",0x1), - 0x801B6F78:("D_801B6F78","UNK_TYPE1","",0x1), + 0x801B6D90:("sSetWhirlpoolModeNormalData","UNK_TYPE1","",0x1), + 0x801B6DB8:("sSetWhirlpoolModeFreeFallData","UNK_TYPE1","",0x1), + 0x801B6DE0:("sSetWhirlpoolModeGoronJumpData","UNK_TYPE1","",0x1), + 0x801B6E08:("sSetWhirlpoolModeDekuFlyData","UNK_TYPE1","",0x1), + 0x801B6E30:("sSetWhirlpoolModeDekuHideData","UNK_TYPE1","",0x1), + 0x801B6E58:("sSetWhirlpoolModeGoronDashData","UNK_TYPE1","",0x1), + 0x801B6E80:("sSetCuccoShackModeNormalData","UNK_TYPE1","",0x1), + 0x801B6EA8:("sSetCuccoShackModeStillData","UNK_TYPE1","",0x1), + 0x801B6ED0:("sSetCuccoShackModeDekuHideData","UNK_TYPE1","",0x1), + 0x801B6EF8:("sSetGiantModeNormalData","UNK_TYPE1","",0x1), + 0x801B6F20:("sSetGiantModeTargetData","UNK_TYPE1","",0x1), + 0x801B6F50:("sSetGiantModeJumpData","UNK_TYPE1","",0x1), + 0x801B6F78:("sSetGiantModeStillData","UNK_TYPE1","",0x1), 0x801B6FA0:("D_801B6FA0","UNK_TYPE1","",0x1), 0x801B6FB0:("D_801B6FB0","UNK_TYPE1","",0x1), 0x801B6FD8:("D_801B6FD8","UNK_TYPE1","",0x1), @@ -734,130 +747,129 @@ 0x801B71D4:("D_801B71D4","UNK_TYPE1","",0x1), 0x801B7204:("D_801B7204","UNK_TYPE1","",0x1), 0x801B7210:("D_801B7210","UNK_TYPE1","",0x1), - 0x801B7244:("D_801B7244","UNK_TYPE1","",0x1), - 0x801B7278:("D_801B7278","UNK_TYPE1","",0x1), - 0x801B729C:("D_801B729C","UNK_TYPE1","",0x1), - 0x801B72C0:("D_801B72C0","UNK_TYPE1","",0x1), - 0x801B72E4:("D_801B72E4","UNK_TYPE1","",0x1), - 0x801B7308:("D_801B7308","UNK_TYPE1","",0x1), - 0x801B732C:("D_801B732C","UNK_TYPE1","",0x1), - 0x801B7354:("D_801B7354","UNK_TYPE1","",0x1), - 0x801B7384:("D_801B7384","UNK_TYPE1","",0x1), - 0x801B73AC:("D_801B73AC","UNK_TYPE1","",0x1), - 0x801B73D4:("D_801B73D4","UNK_TYPE1","",0x1), - 0x801B74C4:("D_801B74C4","UNK_TYPE1","",0x1), - 0x801B759C:("D_801B759C","UNK_TYPE1","",0x1), - 0x801B75F4:("D_801B75F4","UNK_TYPE1","",0x1), - 0x801B767C:("D_801B767C","UNK_TYPE1","",0x1), - 0x801B7684:("D_801B7684","UNK_TYPE1","",0x1), - 0x801B768C:("D_801B768C","UNK_TYPE1","",0x1), - 0x801B7694:("D_801B7694","UNK_TYPE1","",0x1), - 0x801B769C:("D_801B769C","UNK_TYPE1","",0x1), - 0x801B76A4:("D_801B76A4","UNK_TYPE1","",0x1), - 0x801B76AC:("D_801B76AC","UNK_TYPE1","",0x1), - 0x801B777C:("D_801B777C","UNK_TYPE1","",0x1), - 0x801B784C:("D_801B784C","UNK_TYPE1","",0x1), - 0x801B791C:("D_801B791C","UNK_TYPE1","",0x1), - 0x801B7984:("D_801B7984","UNK_TYPE1","",0x1), - 0x801B79EC:("D_801B79EC","UNK_TYPE1","",0x1), - 0x801B79F4:("D_801B79F4","UNK_TYPE1","",0x1), - 0x801B7AE4:("D_801B7AE4","UNK_TYPE1","",0x1), - 0x801B7B14:("D_801B7B14","UNK_TYPE1","",0x1), - 0x801B7B44:("D_801B7B44","UNK_TYPE1","",0x1), - 0x801B7B74:("D_801B7B74","UNK_TYPE1","",0x1), - 0x801B7BA4:("D_801B7BA4","UNK_TYPE1","",0x1), - 0x801B7BAC:("D_801B7BAC","UNK_TYPE1","",0x1), - 0x801B7BDC:("D_801B7BDC","UNK_TYPE1","",0x1), - 0x801B7C0C:("D_801B7C0C","UNK_TYPE1","",0x1), - 0x801B7C3C:("D_801B7C3C","UNK_TYPE1","",0x1), - 0x801B7C44:("D_801B7C44","UNK_TYPE1","",0x1), - 0x801B7C54:("D_801B7C54","UNK_TYPE1","",0x1), - 0x801B7C5C:("D_801B7C5C","UNK_TYPE1","",0x1), - 0x801B7C64:("D_801B7C64","UNK_TYPE1","",0x1), - 0x801B7D34:("D_801B7D34","UNK_TYPE1","",0x1), - 0x801B7D3C:("D_801B7D3C","UNK_TYPE1","",0x1), - 0x801B7D44:("D_801B7D44","UNK_TYPE1","",0x1), - 0x801B7D4C:("D_801B7D4C","UNK_TYPE1","",0x1), - 0x801B7D54:("D_801B7D54","UNK_TYPE1","",0x1), - 0x801B7D5C:("D_801B7D5C","UNK_TYPE1","",0x1), - 0x801B7D64:("D_801B7D64","UNK_TYPE1","",0x1), - 0x801B7DCC:("D_801B7DCC","UNK_TYPE1","",0x1), - 0x801B7DD4:("D_801B7DD4","UNK_TYPE1","",0x1), - 0x801B7E3C:("D_801B7E3C","UNK_TYPE1","",0x1), - 0x801B7F0C:("D_801B7F0C","UNK_TYPE1","",0x1), - 0x801B7F14:("D_801B7F14","UNK_TYPE1","",0x1), - 0x801B7F1C:("D_801B7F1C","UNK_TYPE1","",0x1), - 0x801B7F24:("D_801B7F24","UNK_TYPE1","",0x1), - 0x801B7F2C:("D_801B7F2C","UNK_TYPE1","",0x1), - 0x801B7F34:("D_801B7F34","UNK_TYPE1","",0x1), - 0x801B7F3C:("D_801B7F3C","UNK_TYPE1","",0x1), - 0x801B7FAC:("D_801B7FAC","UNK_TYPE1","",0x1), - 0x801B807C:("D_801B807C","UNK_TYPE1","",0x1), - 0x801B8084:("D_801B8084","UNK_TYPE1","",0x1), - 0x801B8154:("D_801B8154","UNK_TYPE1","",0x1), - 0x801B8224:("D_801B8224","UNK_TYPE1","",0x1), - 0x801B82F4:("D_801B82F4","UNK_TYPE1","",0x1), - 0x801B82FC:("D_801B82FC","UNK_TYPE1","",0x1), - 0x801B8304:("D_801B8304","UNK_TYPE1","",0x1), - 0x801B83D4:("D_801B83D4","UNK_TYPE1","",0x1), - 0x801B83DC:("D_801B83DC","UNK_TYPE1","",0x1), - 0x801B8434:("D_801B8434","UNK_TYPE1","",0x1), - 0x801B843C:("D_801B843C","UNK_TYPE1","",0x1), - 0x801B8444:("D_801B8444","UNK_TYPE1","",0x1), - 0x801B8514:("D_801B8514","UNK_TYPE1","",0x1), - 0x801B85E4:("D_801B85E4","UNK_TYPE1","",0x1), - 0x801B8664:("D_801B8664","UNK_TYPE1","",0x1), - 0x801B8754:("D_801B8754","UNK_TYPE1","",0x1), - 0x801B875C:("D_801B875C","UNK_TYPE1","",0x1), - 0x801B87C4:("D_801B87C4","UNK_TYPE1","",0x1), - 0x801B8894:("D_801B8894","UNK_TYPE1","",0x1), - 0x801B8964:("D_801B8964","UNK_TYPE1","",0x1), - 0x801B8A34:("D_801B8A34","UNK_TYPE1","",0x1), - 0x801B8B04:("D_801B8B04","UNK_TYPE1","",0x1), - 0x801B8BD4:("D_801B8BD4","UNK_TYPE1","",0x1), - 0x801B8CAC:("D_801B8CAC","UNK_TYPE1","",0x1), - 0x801B8CB4:("D_801B8CB4","UNK_TYPE1","",0x1), - 0x801B8D8C:("D_801B8D8C","UNK_TYPE1","",0x1), - 0x801B8E5C:("D_801B8E5C","UNK_TYPE1","",0x1), - 0x801B8F2C:("D_801B8F2C","UNK_TYPE1","",0x1), - 0x801B8F34:("D_801B8F34","UNK_TYPE1","",0x1), - 0x801B900C:("D_801B900C","UNK_TYPE1","",0x1), - 0x801B90D4:("D_801B90D4","UNK_TYPE1","",0x1), - 0x801B91A4:("D_801B91A4","UNK_TYPE1","",0x1), - 0x801B91AC:("D_801B91AC","UNK_TYPE1","",0x1), - 0x801B927C:("D_801B927C","UNK_TYPE1","",0x1), - 0x801B9354:("D_801B9354","UNK_TYPE1","",0x1), - 0x801B9424:("D_801B9424","UNK_TYPE1","",0x1), - 0x801B94F4:("D_801B94F4","UNK_TYPE1","",0x1), - 0x801B95C4:("D_801B95C4","UNK_TYPE1","",0x1), - 0x801B95CC:("D_801B95CC","UNK_TYPE1","",0x1), - 0x801B969C:("D_801B969C","UNK_TYPE1","",0x1), - 0x801B976C:("D_801B976C","UNK_TYPE1","",0x1), - 0x801B979C:("D_801B979C","UNK_TYPE1","",0x1), - 0x801B986C:("cameraStates","CameraStateParams","[91]",0x444), - 0x801B9CB0:("D_801B9CB0","UNK_TYPE1","",0x1), - 0x801B9CE2:("D_801B9CE2","UNK_TYPE1","",0x1), - 0x801B9CE4:("D_801B9CE4","UNK_PTR","",0x4), - 0x801B9CE8:("cameraUpdateFuncs","camera_update_func","[71]",0x11c), - 0x801B9E04:("D_801B9E04","UNK_TYPE2","",0x2), - 0x801B9E08:("D_801B9E08","UNK_TYPE4","",0x4), - 0x801B9E0C:("D_801B9E0C","UNK_TYPE4","",0x4), - 0x801B9E10:("D_801B9E10","UNK_TYPE4","",0x4), - 0x801B9E14:("D_801B9E14","UNK_TYPE4","",0x4), + 0x801B7244:("sSetNormal4ModeTalkData","UNK_TYPE1","",0x1), + 0x801B7278:("sSetElegyShellModeNormalData","UNK_TYPE1","",0x1), + 0x801B729C:("sSetElegyShellModeJumpData","UNK_TYPE1","",0x1), + 0x801B72C0:("sSetElegyShellModeDekuShootData","UNK_TYPE1","",0x1), + 0x801B72E4:("sSetElegyShellModeGoronDashData","UNK_TYPE1","",0x1), + 0x801B7308:("sSetElegyShellModeDekuFlyData","UNK_TYPE1","",0x1), + 0x801B732C:("sSetDungeon4ModeNormalData","UNK_TYPE1","",0x1), + 0x801B7354:("sSetDungeon4ModeTargetData","UNK_TYPE1","",0x1), + 0x801B7384:("sSetDungeon4ModeJumpData","UNK_TYPE1","",0x1), + 0x801B73AC:("sSetDungeon4ModeStillData","UNK_TYPE1","",0x1), + 0x801B73D4:("sCamSetNormal0Modes","UNK_TYPE1","",0x1), + 0x801B74C4:("sCamSetNormal3Modes","UNK_TYPE1","",0x1), + 0x801B759C:("sCamSetPivotDivingModes","UNK_TYPE1","",0x1), + 0x801B75F4:("sCamSetHorseModes","UNK_TYPE1","",0x1), + 0x801B767C:("sCamSetZoraDivingModes","UNK_TYPE1","",0x1), + 0x801B7684:("sCamSetPreRendFixedModes","UNK_TYPE1","",0x1), + 0x801B768C:("sCamSetPreRendPivotModes","UNK_TYPE1","",0x1), + 0x801B7694:("sCamSetDoorCModes","UNK_TYPE1","",0x1), + 0x801B769C:("sCamSetDemo0Modes","UNK_TYPE1","",0x1), + 0x801B76A4:("sCamSetFree0Modes","UNK_TYPE1","",0x1), + 0x801B76AC:("sCamSetFukan0Modes","UNK_TYPE1","",0x1), + 0x801B777C:("sCamSetNormal1Modes","UNK_TYPE1","",0x1), + 0x801B784C:("sCamSetNanameModes","UNK_TYPE1","",0x1), + 0x801B791C:("sCamSetCirc0Modes","UNK_TYPE1","",0x1), + 0x801B7984:("sCamSetFixed0Modes","UNK_TYPE1","",0x1), + 0x801B79EC:("sCamSetSpiralDoorModes","UNK_TYPE1","",0x1), + 0x801B79F4:("sCamSetDungeon0Modes","UNK_TYPE1","",0x1), + 0x801B7AE4:("sCamSetItem0Modes","UNK_TYPE1","",0x1), + 0x801B7B14:("sCamSetItem1Modes","UNK_TYPE1","",0x1), + 0x801B7B44:("sCamSetItem2Modes","UNK_TYPE1","",0x1), + 0x801B7B74:("sCamSetItem3Modes","UNK_TYPE1","",0x1), + 0x801B7BA4:("sCamSetNaviModes","UNK_TYPE1","",0x1), + 0x801B7BAC:("sCamSetWarp0Modes","UNK_TYPE1","",0x1), + 0x801B7BDC:("sCamSetDeathModes","UNK_TYPE1","",0x1), + 0x801B7C0C:("sCamSetRebirthModes","UNK_TYPE1","",0x1), + 0x801B7C3C:("sCamSetLongChestOpeningModes","UNK_TYPE1","",0x1), + 0x801B7C44:("sCamSetMaskTransformationModes","UNK_TYPE1","",0x1), + 0x801B7C54:("sCamSetAttentionModes","UNK_TYPE1","",0x1), + 0x801B7C5C:("sCamSetWarp1Modes","UNK_TYPE1","",0x1), + 0x801B7C64:("sCamSetDungeon1Modes","UNK_TYPE1","",0x1), + 0x801B7D34:("sCamSetFixed1Modes","UNK_TYPE1","",0x1), + 0x801B7D3C:("sCamSetFixed2Modes","UNK_TYPE1","",0x1), + 0x801B7D44:("sCamSetMazeModes","UNK_TYPE1","",0x1), + 0x801B7D4C:("sCamSetRemoteBombModes","UNK_TYPE1","",0x1), + 0x801B7D54:("sCamSetCirc1Modes","UNK_TYPE1","",0x1), + 0x801B7D5C:("sCamSetCirc2Modes","UNK_TYPE1","",0x1), + 0x801B7D64:("sCamSetCirc3Modes","UNK_TYPE1","",0x1), + 0x801B7DCC:("sCamSetCirc4Modes","UNK_TYPE1","",0x1), + 0x801B7DD4:("sCamSetFixed3Modes","UNK_TYPE1","",0x1), + 0x801B7E3C:("sCamSetTowerClimbModes","UNK_TYPE1","",0x1), + 0x801B7F0C:("sCamSetParallel0Modes","UNK_TYPE1","",0x1), + 0x801B7F14:("sCamSetNormDModes","UNK_TYPE1","",0x1), + 0x801B7F1C:("sCamSetSubjectDModes","UNK_TYPE1","",0x1), + 0x801B7F24:("sCamSetStart0Modes","UNK_TYPE1","",0x1), + 0x801B7F2C:("sCamSetStart2Modes","UNK_TYPE1","",0x1), + 0x801B7F34:("sCamSetStop0Modes","UNK_TYPE1","",0x1), + 0x801B7F3C:("sCamSetBoatCruiseModes","UNK_TYPE1","",0x1), + 0x801B7FAC:("sCamSetVerticalClimbModes","UNK_TYPE1","",0x1), + 0x801B807C:("sCamSetSidedModes","UNK_TYPE1","",0x1), + 0x801B8084:("sCamSetDungeon2Modes","UNK_TYPE1","",0x1), + 0x801B8154:("sCamSetBossOdolwaModes","UNK_TYPE1","",0x1), + 0x801B8224:("sCamSetKeepBackModes","UNK_TYPE1","",0x1), + 0x801B82F4:("sCamSetCirc6Modes","UNK_TYPE1","",0x1), + 0x801B82FC:("sCamSetCirc7Modes","UNK_TYPE1","",0x1), + 0x801B8304:("sCamSetMiniBossModes","UNK_TYPE1","",0x1), + 0x801B83D4:("sCamSetRFixed1Modes","UNK_TYPE1","",0x1), + 0x801B83DC:("sCamSetTreasureChestMinigameModes","UNK_TYPE1","",0x1), + 0x801B8434:("sCamSetBombBasketModes","UNK_TYPE1","",0x1), + 0x801B843C:("sCamSetCirc8Modes","UNK_TYPE1","",0x1), + 0x801B8444:("sCamSetFukan1Modes","UNK_TYPE1","",0x1), + 0x801B8514:("sCamSetDungeon3Modes","UNK_TYPE1","",0x1), + 0x801B85E4:("sCamSetTelescopeModes","UNK_TYPE1","",0x1), + 0x801B8664:("sCamSetRoom0Modes","UNK_TYPE1","",0x1), + 0x801B8754:("sCamSetRCirc0Modes","UNK_TYPE1","",0x1), + 0x801B875C:("sCamSetCirc9Modes","UNK_TYPE1","",0x1), + 0x801B87C4:("sCamSetOnThePoleModes","UNK_TYPE1","",0x1), + 0x801B8894:("sCamSetInBushModes","UNK_TYPE1","",0x1), + 0x801B8964:("sCamSetBossMajoraModes","UNK_TYPE1","",0x1), + 0x801B8A34:("sCamSetBossTwinmoldModes","UNK_TYPE1","",0x1), + 0x801B8B04:("sCamSetBossGohtModes","UNK_TYPE1","",0x1), + 0x801B8BD4:("sCamSetBossGyorgModes","UNK_TYPE1","",0x1), + 0x801B8CAC:("sCamSetConnect0Modes","UNK_TYPE1","",0x1), + 0x801B8CB4:("sCamSetPinnacleRockModes","UNK_TYPE1","",0x1), + 0x801B8D8C:("sCamSetNormal2Modes","UNK_TYPE1","",0x1), + 0x801B8E5C:("sCamSetBombBowlModes","UNK_TYPE1","",0x1), + 0x801B8F2C:("sCamSetCircAModes","UNK_TYPE1","",0x1), + 0x801B8F34:("sCamSetWhirlpoolModes","UNK_TYPE1","",0x1), + 0x801B900C:("sCamSetCuccoShackModes","UNK_TYPE1","",0x1), + 0x801B90D4:("sCamSetGiantModes","UNK_TYPE1","",0x1), + 0x801B91A4:("sCamSetScene0Modes","UNK_TYPE1","",0x1), + 0x801B91AC:("sCamSetRoom1Modes","UNK_TYPE1","",0x1), + 0x801B927C:("sCamSetWater2Modes","UNK_TYPE1","",0x1), + 0x801B9354:("sCamSetWoodfallSwampModes","UNK_TYPE1","",0x1), + 0x801B9424:("sCamSetForceKeepModes","UNK_TYPE1","",0x1), + 0x801B94F4:("sCamSetParallel1Modes","UNK_TYPE1","",0x1), + 0x801B95C4:("sCamSetStart1Modes","UNK_TYPE1","",0x1), + 0x801B95CC:("sCamSetRoom2Modes","UNK_TYPE1","",0x1), + 0x801B969C:("sCamSetNorm4Modes","UNK_TYPE1","",0x1), + 0x801B976C:("sCamSetElegyShellModes","UNK_TYPE1","",0x1), + 0x801B979C:("sCamSetDungeon4Modes","UNK_TYPE1","",0x1), + 0x801B986C:("sCameraSettings","CameraSetting","[91]",0x444), + 0x801B9CB0:("sGlobalCamDataSettings","s16","[26]",0x34), + 0x801B9CE4:("sGlobalCamDataSettingsPtr","s16*","",0x4), + 0x801B9CE8:("sCameraUpdateHandlers","camera_update_func","[71]",0x11c), + 0x801B9E04:("sCameraNextUID","UNK_TYPE2","",0x2), + 0x801B9E08:("sCameraInterfaceFlags","UNK_TYPE4","",0x4), + 0x801B9E0C:("sCameraHudVisibility","UNK_TYPE4","",0x4), + 0x801B9E10:("sCameraLetterboxSize","UNK_TYPE4","",0x4), + 0x801B9E14:("sCameraNegOne","UNK_TYPE4","",0x4), 0x801B9E18:("D_801B9E18","UNK_TYPE2","",0x2), 0x801B9E34:("D_801B9E34","UNK_TYPE2","",0x2), - 0x801B9E50:("D_801B9E50","UNK_TYPE4","",0x4), - 0x801B9E54:("D_801B9E54","UNK_TYPE4","",0x4), - 0x801B9E58:("D_801B9E58","UNK_TYPE4","",0x4), + 0x801B9E50:("sUpdateCameraDirection","UNK_TYPE4","",0x4), + 0x801B9E54:("sIsFalse","UNK_TYPE4","",0x4), + 0x801B9E58:("sCameraInitSceneTimer","UNK_TYPE4","",0x4), 0x801B9E5C:("D_801B9E5C","UNK_TYPE4","",0x4), 0x801B9E60:("D_801B9E60","f32","",0x4), 0x801B9E64:("D_801B9E64","UNK_TYPE1","",0x1), 0x801B9E84:("D_801B9E84","UNK_TYPE1","",0x1), 0x801B9EB4:("D_801B9EB4","UNK_TYPE4","",0x4), 0x801B9ED4:("D_801B9ED4","UNK_TYPE4","",0x4), - 0x801B9F04:("D_801B9F04","UNK_TYPE4","",0x4), - 0x801B9F0C:("D_801B9F0C","UNK_TYPE2","",0x2), - 0x801B9F10:("D_801B9F10","UNK_TYPE4","",0x4), + 0x801B9F04:("sEarthquakeFreq","UNK_TYPE4","",0x4), + 0x801B9F0C:("sEarthquakeTimer","UNK_TYPE2","",0x2), + 0x801B9F10:("sModeChangeFlags","UNK_TYPE4","",0x4), 0x801B9F20:("sDamageTablePresets","DamageTable","[23]",0x2e0), 0x801BA200:("damageMultipliers","f32","[16]",0x40), 0x801BA240:("defaultCollider","Collider","",0x18), @@ -914,7 +926,7 @@ 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), @@ -930,7 +942,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), @@ -959,9 +971,9 @@ 0x801BDACC:("D_801BDACC","UNK_TYPE4","",0x4), 0x801BDAF0:("D_801BDAF0","UNK_TYPE4","",0x4), 0x801BDAF8:("D_801BDAF8","UNK_TYPE4","",0x4), - 0x801BDB00:("D_801BDB00","UNK_TYPE1","",0x1), - 0x801BDB08:("sKaleidoSetupEyeX","UNK_TYPE1","",0x1), - 0x801BDB18:("sKaleidoSetupEyeZ","UNK_TYPE1","",0x1), + 0x801BDB00:("sKaleidoSetupRightPageIndex","UNK_TYPE1","",0x1), + 0x801BDB08:("sKaleidoSetupRightPageEyeX","UNK_TYPE1","",0x1), + 0x801BDB18:("sKaleidoSetupRightPageEyeZ","UNK_TYPE1","",0x1), 0x801BDB30:("kanfontOrdering","u8","[92]",0x5c), 0x801BDB90:("D_801BDB90","f32","",0x4), 0x801BDB94:("D_801BDB94","UNK_TYPE4","",0x4), @@ -970,7 +982,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,92 +1074,76 @@ 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), - 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), - 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), + 0x801BF6C0:("sRestrictionFlags","RestrictionFlags","[113]",0x1c4), + 0x801BF884:("sPictoState","UNK_TYPE2","",0x2), + 0x801BF888:("sPictoPhotoBeingTaken","UNK_TYPE2","",0x2), + 0x801BF88C:("sHBAScoreTier","UNK_TYPE2","",0x2), + 0x801BF890:("sMinigameScoreDigits","UNK_TYPE2","",0x2), + 0x801BF898:("sCUpInvisible","UNK_TYPE2","",0x2), + 0x801BF89C:("sCUpTimer","UNK_TYPE2","",0x2), + 0x801BF8A0:("sMagicMeterOutlinePrimRed","UNK_TYPE2","",0x2), + 0x801BF8A4:("sMagicMeterOutlinePrimGreen","UNK_TYPE2","",0x2), + 0x801BF8A8:("sMagicMeterOutlinePrimBlue","UNK_TYPE2","",0x2), + 0x801BF8AC:("sMagicBorderRatio","UNK_TYPE2","",0x2), + 0x801BF8B0:("sMagicBorderStep","UNK_TYPE2","",0x2), + 0x801BF8DC:("sEnvHazard","UNK_TYPE2","",0x2), + 0x801BF8E0:("sEnvTimerActive","UNK_TYPE2","",0x2), + 0x801BF8E4:("sPostmanBunnyHoodState","UNK_TYPE2","",0x2), + 0x801BF8E8:("sTimerPausedOsTime","UNK_TYPE4","",0x4), + 0x801BF8F0:("sBottleTimerPausedOsTime","u64","",0x8), + 0x801BF8F8:("D_801BF8F8","u64","[7]",0x38), + 0x801BF930:("D_801BF930","u64","[7]",0x38), + 0x801BF968:("sIsTimerPaused","UNK_TYPE4","",0x4), + 0x801BF96C:("sIsBottleTimerPaused","UNK_TYPE4","",0x4), + 0x801BF970:("sTimerId","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:("sScreenFillSetupDL","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), - 0x801BFA04:("D_801BFA04","UNK_TYPE2","",0x2), - 0x801BFA1C:("D_801BFA1C","UNK_TYPE2","",0x2), - 0x801BFA34:("D_801BFA34","UNK_TYPE2","",0x2), - 0x801BFA4C:("D_801BFA4C","UNK_TYPE2","",0x2), - 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), + 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:("sActionVtxPosX","UNK_TYPE2","",0x2), + 0x801BFA1C:("sActionVtxWidths","UNK_TYPE2","",0x2), + 0x801BFA34:("sActionVtxPosY","UNK_TYPE2","",0x2), + 0x801BFA4C:("sActionVtxHeights","UNK_TYPE2","",0x2), + 0x801BFA64:("sPerfectLettersCenterX","UNK_TYPE2","",0x2), + 0x801BFA74:("sPerfectLettersCenterY","UNK_TYPE2","",0x2), + 0x801BFA84:("sPostmanTimerInputBtnAPressed","UNK_TYPE4","",0x4), + 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), 0x801BFB1C:("D_801BFB1C","UNK_TYPE1","",0x1), 0x801BFB24:("D_801BFB24","UNK_TYPE1","",0x1), - 0x801BFB2C:("D_801BFB2C","UNK_TYPE2","",0x2), + 0x801BFB2C:("sThreeDayClockAlpha","UNK_TYPE2","",0x2), 0x801BFB30:("D_801BFB30","UNK_TYPE2","",0x2), 0x801BFB34:("D_801BFB34","UNK_TYPE2","",0x2), - 0x801BFB38:("D_801BFB38","UNK_TYPE1","",0x1), - 0x801BFB6C:("D_801BFB6C","UNK_TYPE1","",0x1), + 0x801BFB38:("sThreeDayClockHours","UNK_TYPE1","",0x1), + 0x801BFB6C:("sThreeDayClockHourTextures","UNK_TYPE1","",0x1), 0x801BFBCC:("D_801BFBCC","UNK_TYPE2","",0x2), 0x801BFBD0:("D_801BFBD0","UNK_TYPE2","",0x2), 0x801BFBD4:("D_801BFBD4","UNK_TYPE2","",0x2), @@ -1166,86 +1162,69 @@ 0x801BFC08:("D_801BFC08","UNK_TYPE1","",0x1), 0x801BFC0C:("D_801BFC0C","UNK_TYPE1","",0x1), 0x801BFC10:("D_801BFC10","UNK_TYPE1","",0x1), - 0x801BFC14:("D_801BFC14","UNK_TYPE1","",0x1), + 0x801BFC14:("sFinalHoursDigitTextures","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), - 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), - 0x801BFD1C:("D_801BFD1C","UNK_TYPE1","",0x1), - 0x801BFD24:("D_801BFD24","UNK_TYPE1","",0x1), - 0x801BFD2C:("D_801BFD2C","UNK_TYPE1","",0x1), - 0x801BFD40:("D_801BFD40","UNK_TYPE1","",0x1), - 0x801BFD54:("D_801BFD54","UNK_TYPE1","",0x1), - 0x801BFD64:("D_801BFD64","UNK_TYPE1","",0x1), - 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), + 0x801BFC50:("sPerfectLettersType1OffScreenAngles","UNK_TYPE2","",0x2), + 0x801BFC60:("sPerfectLettersType1PrimColorTargets","s16","[6]",0xC), + 0x801BFC6C:("sPerfectLettersType2SpellingOffsetsX","UNK_TYPE4","",0x4), + 0x801BFC7C:("sPerfectLettersType2OffScreenOffsetsX","UNK_TYPE2","",0x2), + 0x801BFC8C:("sPerfectLettersType2PrimColorTargets","UNK_TYPE1","",0x1), + 0x801BFC98:("sPerfectLettersType3SpellingOffsetsX","UNK_TYPE2","",0x2), + 0x801BFCA8:("sPerfectLettersType3OffScreenAngles","UNK_TYPE2","",0x2), + 0x801BFCB8:("sPerfectLettersType3PrimColorTargets","UNK_TYPE1","",0x1), + 0x801BFCC4:("sPerfectLettersTextures","UNK_TYPE4","",0x4), + 0x801BFCE4:("sTimerStateTimer","UNK_TYPE4","",0x4), + 0x801BFCE8:("sTimerDigits","u16","[8]",0x10), + 0x801BFCF8:("sTimerBeepSfxSeconds","UNK_TYPE4","",0x4), + 0x801BFCFC:("D_801BFCFC","UNK_TYPE4","",0x4), + 0x801BFD0C:("D_801BFD0C","UNK_TYPE4","",0x4), + 0x801BFD1C:("sRupeeDigitsFirst","UNK_TYPE1","",0x1), + 0x801BFD24:("sRupeeDigitsCount","UNK_TYPE1","",0x1), + 0x801BFD2C:("sRupeeCounterIconPrimColors","UNK_TYPE1","",0x1), + 0x801BFD40:("sRupeeCounterIconEnvColors","UNK_TYPE1","",0x1), + 0x801BFD54:("sMinigameCountdownTextures","UNK_TYPE1","",0x1), + 0x801BFD64:("sMinigameCountdownTexWidths","UNK_TYPE1","",0x1), + 0x801BFD6C:("sMinigameCountdownPrimColors","UNK_TYPE2","",0x2), + 0x801BFD84:("sStoryTextures","UNK_TYPE1","",0x1), + 0x801BFD8C:("sStoryTLUTs","UNK_TYPE1","",0x1), + 0x801BFD94:("sIsSunsPlayedAtDay","UNK_TYPE4","",0x4), + 0x801BFD98:("sPrevTimeSpeed","UNK_TYPE4","[2]",0x8), + 0x801BFDA0:("sMaskObjectIds","s16","[24]",0x30), 0x801BFDD0:("D_801BFDD0","UNK_TYPE1","",0x1), - 0x801BFDE8:("D_801BFDE8","UNK_TYPE1","",0x1), - 0x801BFE00:("D_801BFE00","UNK_TYPE1","",0x1), + 0x801BFDE8:("sMaskItemIds","UNK_TYPE1","",0x1), + 0x801BFE00:("gPlayerSkeletons","FlexSkeletonHeader*","[5]",0x14), 0x801BFE14:("D_801BFE14","UNK_TYPE1","",0x1), - 0x801BFF34:("D_801BFF34","UNK_TYPE2","",0x2), - 0x801BFF3C:("D_801BFF3C","UNK_TYPE1","",0x1), + 0x801BFF34:("sCItemButtons","UNK_TYPE2","",0x2), + 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), - 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), - 0x801C00EC:("D_801C00EC","UNK_TYPE1","",0x1), - 0x801C0114:("D_801C0114","UNK_TYPE1","",0x1), - 0x801C013C:("D_801C013C","UNK_TYPE1","",0x1), - 0x801C0164:("D_801C0164","UNK_TYPE1","",0x1), + 0x801BFF98:("sPlayerStrengths","UNK_TYPE1","",0x1), + 0x801BFFA0:("sEnvHazardTextTriggers","UNK_TYPE1","",0x1), + 0x801BFFB0:("gPlayerModelTypes","UNK_TYPE1","",0x1), + 0x801BFFFC:("gPlayerWaistDLs","UNK_TYPE1","",0x1), + 0x801C0024:("gPlayerHandHoldingShields","UNK_TYPE1","",0x1), + 0x801C0034:("gPlayerSheath12DLs","UNK_TYPE1","",0x1), + 0x801C005C:("gPlayerSheath13DLs","UNK_TYPE1","",0x1), + 0x801C0084:("gPlayerSheath14DLs","UNK_TYPE1","",0x1), + 0x801C00AC:("gPlayerShields","UNK_TYPE1","",0x1), + 0x801C00BC:("gPlayerSheathedSwords","UNK_TYPE1","",0x1), + 0x801C00D4:("gPlayerSwordSheaths","UNK_TYPE1","",0x1), + 0x801C00EC:("gPlayerLeftHandTwoHandSwordDLs","UNK_TYPE1","",0x1), + 0x801C0114:("gPlayerLeftHandOpenDLs","UNK_TYPE1","",0x1), + 0x801C013C:("gPlayerLeftHandClosedDLs","UNK_TYPE1","",0x1), + 0x801C0164:("gPlayerLeftHandOneHandSwordDLs","UNK_TYPE1","",0x1), 0x801C018C:("D_801C018C","UNK_TYPE1","",0x1), - 0x801C01A4:("D_801C01A4","UNK_TYPE1","",0x1), - 0x801C01CC:("D_801C01CC","UNK_TYPE1","",0x1), - 0x801C01F4:("D_801C01F4","UNK_TYPE1","",0x1), - 0x801C021C:("D_801C021C","UNK_TYPE1","",0x1), - 0x801C0244:("D_801C0244","UNK_TYPE1","",0x1), - 0x801C026C:("D_801C026C","UNK_TYPE1","",0x1), + 0x801C01A4:("gPlayerRightHandOpenDLs","UNK_TYPE1","",0x1), + 0x801C01CC:("gPlayerRightHandClosedDLs","UNK_TYPE1","",0x1), + 0x801C01F4:("gPlayerRightHandBowDLs","UNK_TYPE1","",0x1), + 0x801C021C:("gPlayerRightHandInstrumentDLs","UNK_TYPE1","",0x1), + 0x801C0244:("gPlayerRightHandHookshotDLs","UNK_TYPE1","",0x1), + 0x801C026C:("gPlayerLeftHandBottleDLs","UNK_TYPE1","",0x1), 0x801C0294:("D_801C0294","UNK_TYPE1","",0x1), 0x801C02A8:("D_801C02A8","UNK_TYPE1","",0x1), 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 +1241,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), @@ -1283,19 +1260,17 @@ 0x801C07F0:("D_801C07F0","UNK_TYPE1","",0x1), 0x801C0820:("D_801C0820","UNK_TYPE1","",0x1), 0x801C0838:("D_801C0838","UNK_TYPE1","",0x1), - 0x801C0850:("D_801C0850","UNK_TYPE1","",0x1), - 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), + 0x801C0850:("gCullBackDList","UNK_TYPE1","",0x1), + 0x801C0860:("gCullFrontDList","UNK_TYPE1","",0x1), + 0x801C0870:("sPlayerEyesTextures","UNK_PTR","",0x4), + 0x801C0890:("sPlayerMouthTextures","UNK_TYPE1","",0x1), + 0x801C08A0:("sPlayerFaces","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 +1296,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), @@ -1388,14 +1354,14 @@ 0x801C1E6C:("gItemIcons","UNK_PTR","[131]",0x20C), 0x801C2078:("gItemSlots","u8","[80]",0x50), 0x801C20C8:("gItemPrices","UNK_TYPE1","",0x1), - 0x801C212C:("gScenesPerRegion","SceneIdList","[]",0x252), - 0x801C2380:("sScenesPerTingleMap","u16","[]",0x90), - 0x801C2410:("D_801C2410","UNK_TYPE1","",0x1), + 0x801C212C:("gSceneIdsPerRegion","SceneIdList","[]",0x252), + 0x801C2380:("sSceneIdsPerTingleMap","u16","[]",0x90), + 0x801C2410:("gPlayerFormItemRestrictions","UNK_TYPE1","",0x1), 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,8 +1937,8 @@ 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), - 0x801C5D60:("gShadowDL","UNK_TYPE1","",0x1), - 0x801C5D80:("gShadowVtxDL","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), @@ -1988,12 +1954,10 @@ 0x801C5FC0:("D_801C5FC0","u32","[452]",0x710), 0x801C66D0:("D_801C66D0","UNK_TYPE2","",0x2), 0x801C6798:("D_801C6798","UNK_TYPE4","",0x4), - 0x801C67B0:("D_801C67B0","UNK_TYPE1","",0x1), - 0x801C67C8:("D_801C67C8","s32","[8]",0x20), - 0x801C67E8:("D_801C67E8","UNK_TYPE4","",0x4), - 0x801C67F0:("D_801C67F0","s32","[8]",0x20), - 0x801C6818:("D_801C6818","UNK_TYPE1","",0x1), - 0x801C6838:("D_801C6838","UNK_TYPE4","",0x4), + 0x801C67B0:("gAmmoItems","UNK_TYPE1","",0x1), + 0x801C67C8:("D_801C67C8","s32","[10]",0x28), + 0x801C67F0:("D_801C67F0","s32","[10]",0x28), + 0x801C6818:("D_801C6818","s32","[10]",0x28), 0x801C6840:("D_801C6840","UNK_TYPE1","",0x1), 0x801C6850:("D_801C6850","UNK_TYPE1","",0x1), 0x801C6870:("D_801C6870","UNK_TYPE1","",0x1), @@ -2037,7 +2001,7 @@ 0x801CFC98:("D_801CFC98","UNK_TYPE1","",0x1), 0x801CFCA4:("D_801CFCA4","UNK_TYPE2","",0x2), 0x801CFCAC:("D_801CFCAC","UNK_TYPE2","",0x2), - 0x801CFCB8:("D_801CFCB8","UNK_TYPE1","",0x1), + 0x801CFCB8:("gOcarinaSongItemMap","UNK_TYPE1","",0x1), 0x801CFCD8:("D_801CFCD8","UNK_TYPE2","",0x2), 0x801CFCE4:("D_801CFCE4","UNK_TYPE2","",0x2), 0x801CFCF0:("D_801CFCF0","UNK_TYPE2","",0x2), @@ -2171,7 +2135,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 +2209,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), @@ -2265,11 +2230,11 @@ 0x801D57B4:("gDefaultShortNoteVelocityTable","UNK_TYPE1","",0x1), 0x801D57C4:("gDefaultShortNoteGateTimeTable","UNK_TYPE1","",0x1), 0x801D57D4:("gDefaultEnvelope","UNK_TYPE1","",0x1), - 0x801D57E4:("gZeroNoteSub","UNK_TYPE4","",0x4), - 0x801D5804:("gDefaultNoteSub","UNK_TYPE4","",0x4), - 0x801D5824:("gHeadsetPanQuantization","u16","[64]",0x80), + 0x801D57E4:("gZeroedSampleState","UNK_TYPE4","",0x4), + 0x801D5804:("gDefaultSampleState","UNK_TYPE4","",0x4), + 0x801D5824:("gHaasEffectDelaySize","u16","[64]",0x80), 0x801D58A4:("D_801D58A4","s32","",0x4), - 0x801D58A8:("D_801D58A8","s16","[64]",0x80), + 0x801D58A8:("gInvalidAdpcmCodeBook","s16","[64]",0x80), 0x801D5928:("gHeadsetPanVolume","f32","[128]",0x200), 0x801D5B28:("gStereoPanVolume","f32","[128]",0x200), 0x801D5D28:("gDefaultPanVolume","f32","[128]",0x200), @@ -2282,13 +2247,13 @@ 0x801D5FD4:("D_801D5FD4","UNK_TYPE1","",0x1), 0x801D5FE0:("D_801D5FE0","UNK_PTR","",0x4), 0x801D5FE4:("D_801D5FE4","UNK_TYPE1","",0x1), - 0x801D5FE8:("gAudioContextInitalized","UNK_TYPE4","",0x4), + 0x801D5FE8:("gAudioCtxInitalized","UNK_TYPE4","",0x4), 0x801D5FEC:("D_801D5FEC","UNK_TYPE4","",0x4), - 0x801D5FF0:("D_801D5FF0","UNK_TYPE4","",0x4), - 0x801D5FF4:("D_801D5FF4","UNK_TYPE4","",0x4), - 0x801D5FF8:("D_801D5FF8","UNK_TYPE1","",0x1), - 0x801D5FFC:("D_801D5FFC","UNK_TYPE4","",0x4), - 0x801D6000:("D_801D6000","UNK_PTR","",0x4), + 0x801D5FF0:("sWaitingAudioTask","UNK_TYPE4","",0x4), + 0x801D5FF4:("sMaxWriteReadDiff","UNK_TYPE4","",0x4), + 0x801D5FF8:("sCurCmdRdPos","UNK_TYPE1","",0x1), + 0x801D5FFC:("sAudioRandom","UNK_TYPE4","",0x4), + 0x801D6000:("sAudioOsCount","UNK_PTR","",0x4), 0x801D6010:("D_801D6010","UNK_TYPE1","",0x1), 0x801D6014:("D_801D6014","UNK_TYPE1","",0x1), 0x801D6028:("D_801D6028","UNK_TYPE1","",0x1), @@ -2297,9 +2262,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,18 +2283,18 @@ 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), 0x801D66B8:("sAudioEnvReverb","UNK_TYPE1","",0x1), 0x801D66BC:("sAudioCodeReverb","UNK_TYPE1","",0x1), 0x801D66C0:("sPrevSeqMode","UNK_TYPE1","",0x1), - 0x801D66C4:("sAudioEnemyDist","f32","",0x4), - 0x801D66C8:("sAudioEnemyVol","UNK_TYPE1","",0x1), + 0x801D66C4:("sBgmEnemyDist","f32","",0x4), + 0x801D66C8:("sBgmEnemyVolume","UNK_TYPE1","",0x1), 0x801D66CC:("sPrevMainBgmSeqId","UNK_TYPE2","",0x2), - 0x801D66D0:("sBgmPlayerIOPort7","UNK_TYPE1","",0x1), - 0x801D66D4:("sSceneSeqId2","UNK_TYPE1","",0x1), + 0x801D66D0:("sSeqResumePoint","UNK_TYPE1","",0x1), + 0x801D66D4:("sPrevSceneSeqId","UNK_TYPE1","",0x1), 0x801D66D8:("sNumFramesStill","UNK_TYPE4","",0x4), 0x801D66DC:("sNumFramesMoving","UNK_TYPE4","",0x4), 0x801D66E0:("sAudioBaseFilter","UNK_TYPE1","",0x1), @@ -2342,7 +2307,7 @@ 0x801D66FC:("sObjSoundMainBgmSeqId","UNK_TYPE1","",0x1), 0x801D6700:("sSeqFlags","UNK_TYPE1","",0x1), 0x801D6780:("sSpecReverbs","UNK_TYPE1","",0x1), - 0x801D6794:("sNatureAmbienceData","UNK_TYPE1","",0x1), + 0x801D6794:("sAmbienceData","UNK_TYPE1","",0x1), 0x801D6FB4:("sIsOcarinaInputEnabled","UNK_TYPE1","",0x1), 0x801D6FB8:("sOcarinaInstrumentId","UNK_TYPE1","",0x1), 0x801D6FBC:("sCurOcarinaPitch","UNK_TYPE1","",0x1), @@ -2355,28 +2320,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 +2360,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 +2391,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), @@ -2456,7 +2421,7 @@ 0x801DB870:("D_801DB870","UNK_TYPE1","",0x1), 0x801DB8B8:("D_801DB8B8","UNK_TYPE1","",0x1), 0x801DB900:("D_801DB900","UNK_TYPE1","",0x1), - 0x801DB930:("D_801DB930","UNK_PTR","",0x4), + 0x801DB930:("gReverbSettingsTable","UNK_PTR","",0x4), 0x801DB958:("gAudioSpecs","AudioSpec","[21]",0x498), 0x801DBDF0:("D_801DBDF0","f32","",0x4), 0x801DBDF4:("jtbl_801DBDF4","UNK_PTR","",0x4), @@ -3479,7 +3444,7 @@ 0x801DE868:("D_801DE868","f32","",0x4), 0x801DE86C:("jtbl_801DE86C","UNK_PTR","",0x4), 0x801DE884:("D_801DE884","f32","",0x4), - 0x801DE890:("D_801DE890","UNK_TYPE1","",0x1), + 0x801DE890:("gCircleTex","UNK_TYPE1","",0x1), 0x801DF090:("D_801DF090","f32","",0x4), 0x801DF094:("D_801DF094","f32","",0x4), 0x801DF0A0:("D_801DF0A0","f32","",0x4), @@ -3859,7 +3824,7 @@ 0x801E10B0:("jtbl_801E10B0","UNK_PTR","",0x4), 0x801E10C4:("jtbl_801E10C4","UNK_PTR","",0x4), 0x801E1100:("gAudioTatumInit","s16","[2]",0x4), - 0x801E1104:("gAudioContextInitSizes","AudioContextInitSizes","",0xC), + 0x801E1104:("gAudioHeapInitSizes","AudioHeapInitSizes","",0xC), 0x801E1110:("sGameOverTimer","UNK_TYPE2","",0x2), 0x801E1120:("jtbl_801E1120","UNK_PTR","",0x4), 0x801E1180:("gSoundFontTable","UNK_TYPE2","",0x2), @@ -3906,26 +3871,14 @@ 0x801EDBA8:("D_801EDBA8","Sphere16","",0x8), 0x801EDBB0:("D_801EDBB0","TriNorm","",0x34), 0x801EDBF0:("D_801EDBF0","s16","",0x2), - 0x801EDBF4:("D_801EDBF4","UNK_TYPE1","",0x1), - 0x801EDBF8:("D_801EDBF8","UNK_TYPE1","",0x1), - 0x801EDC00:("D_801EDC00","UNK_TYPE1","",0x1), - 0x801EDC04:("D_801EDC04","UNK_TYPE1","",0x1), - 0x801EDC08:("D_801EDC08","UNK_TYPE1","",0x1), - 0x801EDC0C:("D_801EDC0C","UNK_TYPE1","",0x1), - 0x801EDC10:("D_801EDC10","UNK_TYPE1","",0x1), - 0x801EDC14:("D_801EDC14","UNK_TYPE1","",0x1), - 0x801EDC28:("D_801EDC28","UNK_TYPE1","",0x1), - 0x801EDC30:("D_801EDC30","UNK_TYPE1","",0x1), - 0x801EDC8C:("D_801EDC8C","UNK_TYPE1","",0x1), - 0x801EDC90:("D_801EDC90","UNK_TYPE1","",0x1), - 0x801EDC92:("D_801EDC92","UNK_TYPE1","",0x1), - 0x801EDC94:("D_801EDC94","UNK_TYPE1","",0x1), - 0x801EDC96:("D_801EDC96","UNK_TYPE1","",0x1), - 0x801EDDD0:("D_801EDDD0","UNK_TYPE1","",0x1), - 0x801EDDD4:("D_801EDDD4","UNK_TYPE1","",0x1), - 0x801EDDD8:("D_801EDDD8","UNK_TYPE1","",0x1), - 0x801EDDE0:("D_801EDDE0","UNK_TYPE1","",0x1), - 0x801EDDF0:("D_801EDDF0","UNK_TYPE1","",0x1), + 0x801EDBF4:("D_801EDBF4","f32","",0x4), + 0x801EDBF8:("D_801EDBF8","f32","",0x4), + 0x801EDC00:("D_801EDC00","CameraCollision","",0x28), + 0x801EDC28:("sCamPlayState","PlayState*","",0x4), + 0x801EDC30:("D_801EDC30","SwingAnimation","[4]",0x1A0), + 0x801EDDD0:("D_801EDDD0","Vec3f","",0xc), + 0x801EDDE0:("D_801EDDE0","Vec3f","",0xc), + 0x801EDDF0:("D_801EDDF0","Vec3f","",0xc), 0x801EDE00:("D_801EDE00","Vec3f","",0xc), 0x801EDE10:("D_801EDE10","Vec3f","",0xc), 0x801EDE20:("D_801EDE20","Vec3f","",0xc), @@ -4047,22 +4000,20 @@ 0x801F57B4:("D_801F57B4","UNK_TYPE1","",0x1), 0x801F5834:("D_801F5834","UNK_TYPE1","",0x1), 0x801F5840:("gNMIBuffer","s32*","",0x4), - 0x801F5850:("D_801F5850","UNK_TYPE1","",0x1), - 0x801F58B0:("D_801F58B0","UNK_TYPE1","",0x1), + 0x801F5850:("sPostmanTimerInput","UNK_TYPE1","",0x1), + 0x801F58B0:("D_801F58B0","struct_801F58B0","[3][3]",0xFC), 0x801F59AC:("D_801F59AC","UNK_TYPE1","",0x1), - 0x801F59B0:("D_801F59B0","UNK_TYPE1","",0x1), - 0x801F59C8:("D_801F59C8","UNK_TYPE1","",0x1), - 0x801F59D0:("D_801F59D0","UNK_TYPE1","",0x1), - 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), - 0x801F59F4:("D_801F59F4","UNK_TYPE1","",0x1), - 0x801F59F8:("D_801F59F8","UNK_TYPE1","",0x1), + 0x801F59B0:("D_801F59B0","Vec3f","[2]",0x18), + 0x801F59C8:("D_801F59C8","s32","[2]",0x8), + 0x801F59D0:("D_801F59D0","struct_801F59D0","",0x0A), + 0x801F59DC:("D_801F59DC","Vec3f*","",0x4), + 0x801F59E0:("D_801F59E0","s32","",0x4), + 0x801F59E4:("D_801F59E4","s32","",0x4), + 0x801F59E8:("D_801F59E8","Vec3f","",0xC), + 0x801F59F4:("D_801F59F4","s32","",0x4), + 0x801F59F8:("D_801F59F8","s32","",0x4), 0x801F5A00:("sQuakeRequest","QuakeRequest","[4]",0x90), - 0x801F5A90:("sDistortionContext","DistortionContext","",0xc), + 0x801F5A90:("sDistortionRequest","DistortionRequest","",0xc), 0x801F5AA0:("sMatAnimStep","s32","",0x4), 0x801F5AA4:("sMatAnimFlags","u32","",0x4), 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), @@ -4070,11 +4021,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), @@ -4097,8 +4044,8 @@ 0x801F6B34:("sPlayerCallDestroyFunc","UNK_TYPE1","",0x1), 0x801F6B38:("sPlayerCallUpdateFunc","UNK_TYPE1","",0x1), 0x801F6B3C:("sPlayerCallDrawFunc","UNK_TYPE1","",0x1), - 0x801F6B40:("gShrinkWindowContext","ShrinkWindowContext","",0x4), - 0x801F6B44:("gShrinkWindowContextPtr","ShrinkWindowContext*","",0x4), + 0x801F6B40:("sShrinkWindow","ShrinkWindow","",0x4), + 0x801F6B44:("sShrinkWindowPtr","ShrinkWindow*","",0x4), 0x801F6B50:("D_801F6B50","UNK_TYPE4","",0x4), 0x801F6B58:("D_801F6B58","UNK_TYPE1","",0x1), 0x801F6BF0:("sKaleidoAreaFaultClient","FaultAddrConvClient","",0xC), @@ -4306,14 +4253,14 @@ 0x801FD294:("sSfxVolumeCur","UNK_TYPE1","",0x1), 0x801FD298:("sSfxVolumeTarget","UNK_TYPE1","",0x1), 0x801FD29C:("sSfxVolumeRate","UNK_TYPE1","",0x1), - 0x801FD2A0:("sSceneSeqId1","UNK_TYPE1","",0x1), + 0x801FD2A0:("sRequestedSceneSeqId","UNK_TYPE1","",0x1), 0x801FD2A8:("sSfxChannelState","UNK_TYPE1","",0x1), 0x801FD3A8:("D_801FD3A8","UNK_TYPE1","",0x1), 0x801FD3A9:("D_801FD3A9","UNK_TYPE1","",0x1), 0x801FD3AA:("sRiverSoundBgmTimer","UNK_TYPE1","",0x1), 0x801FD3AB:("sFanfareState","UNK_TYPE1","",0x1), 0x801FD3AC:("sFanfareSeqId","UNK_TYPE1","",0x1), - 0x801FD3AE:("sMuteOnlySfxAndNatureSeq","UNK_TYPE1","",0x1), + 0x801FD3AE:("sMuteOnlySfxAndAmbienceSeq","UNK_TYPE1","",0x1), 0x801FD3AF:("sAllPlayersMutedExceptOcaAndSys","UNK_TYPE1","",0x1), 0x801FD3B0:("sAudioPauseState","UNK_TYPE1","",0x1), 0x801FD3B4:("sSpatialSeqIsActive","u8","[4]",0x4), @@ -4339,22 +4286,22 @@ 0x801FD434:("D_801FD434","UNK_TYPE1","",0x1), 0x801FD435:("sSpatialSeqPlayerIndex","UNK_TYPE1","",0x1), 0x801FD436:("sSpatialSeqFadeTimer","UNK_TYPE1","",0x1), - 0x801FD438:("D_801FD438","UNK_TYPE1","",0x1), + 0x801FD438:("sPrevAmbienceSeqId","UNK_TYPE1","",0x1), 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 +4309,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 +4319,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), @@ -4397,18 +4344,18 @@ 0x8020001E:("D_8020001E","UNK_TYPE1","",0x1), 0x802000C9:("D_802000C9","UNK_TYPE1","",0x1), 0x802000D4:("D_802000D4","UNK_TYPE1","",0x1), - 0x80200140:("D_80200140","UNK_TYPE1","",0x1), + 0x80200140:("gActiveSeqs","UNK_TYPE1","",0x1), 0x8020034A:("D_8020034A","UNK_TYPE1","",0x1), 0x80200B88:("D_80200B88","UNK_TYPE1","",0x1), 0x80200BBA:("D_80200BBA","UNK_TYPE1","",0x1), 0x80200BCC:("D_80200BCC","UNK_TYPE1","",0x1), 0x80200BCE:("D_80200BCE","UNK_TYPE1","",0x1), 0x80200BD0:("D_80200BD0","UNK_TYPE1","",0x1), - 0x80200C70:("gAudioContext","AudioContext","",0x81F8), - 0x80208E68:("D_80208E68","UNK_TYPE4","",0x4), - 0x80208E6C:("D_80208E6C","UNK_TYPE4","",0x4), - 0x80208E70:("D_80208E70","UNK_TYPE4","",0x4), - 0x80208E74:("D_80208E74","UNK_TYPE4","",0x4), + 0x80200C70:("gAudioCtx","AudioContext","",0x81F8), + 0x80208E68:("gAudioCustomUpdateFunction","UNK_TYPE4","",0x4), + 0x80208E6C:("gAudioCustomSeqFunction","UNK_TYPE4","",0x4), + 0x80208E70:("gAudioCustomReverbFunction","UNK_TYPE4","",0x4), + 0x80208E74:("gAudioCustomSynthFunction","UNK_TYPE4","",0x4), 0x80208E90:("sJpegBitStreamPtr","UNK_TYPE1","",0x1), 0x80208E94:("sJpegBitStreamByteIdx","UNK_TYPE1","",0x1), 0x80208E98:("sJpegBitStreamBitIdx","UNK_TYPE1","",0x1), @@ -4419,7 +4366,7 @@ 0x80209EA0:("gGfxPools","GfxPool","[2]",0x40620), 0x8024A4C0:("gAudioHeap","u8","[0x138000]",0x138000), 0x803824C0:("gSystemHeap","u8","[UNK_SIZE]",0x3fdb40), - 0x80780000:("D_80780000","u8","[0x4600]",0x4600), + 0x80780000:("gPictoPhotoI8","u8","[0x4600]",0x4600), 0x80784600:("D_80784600","u8","[0x56200]",0x56200), 0x807DA800:("gFramebuffer0","u16","[SCREEN_HEIGHT][SCREEN_WIDTH]",0x25800), 0x80800860:("titleRotation","s16","",0x2), @@ -4711,124 +4658,115 @@ 0x80815FF4:("sDayLeftTextures","TexturePtr","[4]",0x10), 0x80816004:("sDayRightTextures","TexturePtr","[4]",0x10), 0x80816014:("sHoursLeftTextures","TexturePtr","[3]",0xC), - 0x8082AED0:("D_8082AED0","UNK_TYPE1","",0x1), - 0x8082AED8:("D_8082AED8","UNK_TYPE1","",0x1), - 0x8082AEE0:("D_8082AEE0","UNK_TYPE2","",0x2), - 0x8082AEE4:("D_8082AEE4","UNK_TYPE1","",0x1), - 0x8082AEF0:("D_8082AEF0","UNK_TYPE2","",0x2), - 0x8082AF04:("D_8082AF04","UNK_TYPE2","",0x2), - 0x8082AF24:("D_8082AF24","UNK_TYPE1","",0x1), - 0x8082AF6C:("D_8082AF6C","UNK_TYPE2","",0x2), - 0x8082AF78:("D_8082AF78","UNK_TYPE2","",0x2), - 0x8082AF84:("D_8082AF84","UNK_TYPE2","",0x2), - 0x8082AF90:("D_8082AF90","UNK_TYPE2","",0x2), - 0x8082AF94:("D_8082AF94","UNK_TYPE2","",0x2), - 0x8082AF98:("D_8082AF98","UNK_TYPE2","",0x2), - 0x8082AF9C:("D_8082AF9C","UNK_TYPE2","",0x2), - 0x8082AFA0:("D_8082AFA0","UNK_TYPE2","",0x2), - 0x8082AFA4:("D_8082AFA4","UNK_TYPE2","",0x2), - 0x8082AFA8:("D_8082AFA8","UNK_TYPE2","",0x2), - 0x8082AFAC:("D_8082AFAC","UNK_TYPE2","",0x2), - 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), - 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), - 0x8082B3C0:("D_8082B3C0","UNK_TYPE2","",0x2), - 0x8082B3C4:("D_8082B3C4","UNK_TYPE2","",0x2), - 0x8082B3C8:("D_8082B3C8","UNK_TYPE2","",0x2), - 0x8082B3CC:("D_8082B3CC","UNK_TYPE1","",0x1), - 0x8082B444:("D_8082B444","UNK_TYPE1","",0x1), - 0x8082B454:("D_8082B454","UNK_TYPE1","",0x1), - 0x8082B47C:("D_8082B47C","UNK_TYPE1","",0x1), - 0x8082B484:("D_8082B484","UNK_TYPE1","",0x1), - 0x8082B48C:("D_8082B48C","UNK_TYPE1","",0x1), - 0x8082B494:("D_8082B494","UNK_TYPE2","",0x2), - 0x8082B4A0:("D_8082B4A0","UNK_TYPE4","",0x4), - 0x8082B4AC:("D_8082B4AC","UNK_TYPE1","",0x1), - 0x8082B4BC:("D_8082B4BC","UNK_TYPE1","",0x1), + 0x8082AED0:("sQuestRemainsColorTimerInit","UNK_TYPE1","",0x1), + 0x8082AED8:("sQuestHpColorTimerInit","UNK_TYPE1","",0x1), + 0x8082AEE0:("sQuestSongPlayedOcarinaButtonsNum","UNK_TYPE2","",0x2), + 0x8082AEE4:("sQuestSongPlayedOcarinaButtons","UNK_TYPE1","",0x1), + 0x8082AEF0:("sQuestSongPlayedOcarinaButtonsAlpha","UNK_TYPE2","",0x2), + 0x8082AF04:("sQuestHpPrimColorTargets","UNK_TYPE2","",0x2), + 0x8082AF24:("sQuestRemainsEnvTargets","UNK_TYPE1","",0x1), + 0x8082AF6C:("sQuestRemainsEnvRed","UNK_TYPE2","",0x2), + 0x8082AF78:("sQuestRemainsEnvGreen","UNK_TYPE2","",0x2), + 0x8082AF84:("sQuestRemainsEnvBlue","UNK_TYPE2","",0x2), + 0x8082AF90:("sQuestRemainsColorTimer","UNK_TYPE2","",0x2), + 0x8082AF94:("sQuestRemainsColorTimerIndex","UNK_TYPE2","",0x2), + 0x8082AF98:("sQuestHpPrimRed","UNK_TYPE2","",0x2), + 0x8082AF9C:("sQuestHpPrimGreen","UNK_TYPE2","",0x2), + 0x8082AFA0:("sQuestHpPrimBlue","UNK_TYPE2","",0x2), + 0x8082AFA4:("sQuestHpPrimAlpha","UNK_TYPE2","",0x2), + 0x8082AFA8:("sQuestHpColorTimer","UNK_TYPE2","",0x2), + 0x8082AFAC:("sQuestHpPrimColorTargetIndex","UNK_TYPE2","",0x2), + 0x8082AFB0:("sOcarinaButtonTextures","UNK_TYPE1","",0x1), + 0x8082AFC4:("sQuestSongsPrimRed","UNK_TYPE2","",0x2), + 0x8082AFDC:("sQuestSongsPrimGreen","UNK_TYPE2","",0x2), + 0x8082AFF4:("sQuestSongsPrimBlue","s16","[12]",0x18), + 0x8082B00C:("sQuestUpgradeTextures","void*","[6]",0x18), + 0x8082B024:("sQuestUpgrades","UNK_TYPE1","",0x1), + 0x8082B028:("sQuestSongPlaybackDelayTimer","UNK_TYPE2","",0x2), + 0x8082B02C:("sCursorPointLinks","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:("sEquipState","UNK_TYPE2","",0x2), + 0x8082B3C4:("sEquipMagicArrowSlotHoldTimer","UNK_TYPE2","",0x2), + 0x8082B3C8:("sEquipAnimTimer","UNK_TYPE2","",0x2), + 0x8082B3CC:("gPlayerFormSlotRestrictions","UNK_TYPE1","",0x1), + 0x8082B444:("sAmmoRectLeft","UNK_TYPE1","",0x1), + 0x8082B454:("sAmmoRectHeight","UNK_TYPE1","",0x1), + 0x8082B47C:("sPlayerFormItems","UNK_TYPE1","",0x1), + 0x8082B484:("sCButtonPosX","UNK_TYPE1","",0x1), + 0x8082B48C:("sCButtonPosY","UNK_TYPE1","",0x1), + 0x8082B494:("sEquipMagicArrowBowSlotHoldTimer","UNK_TYPE2","",0x2), + 0x8082B4A0:("sDungeonItemTextures","UNK_TYPE4","",0x4), + 0x8082B4AC:("sDungeonTitleTextures","UNK_TYPE1","",0x1), + 0x8082B4BC:("sDungeonMapFloorIconPosY","UNK_TYPE1","",0x1), 0x8082B4C4:("D_8082B4C4","UNK_TYPE1","",0x1), - 0x8082B4C8:("D_8082B4C8","UNK_TYPE2","",0x2), - 0x8082B4CC:("D_8082B4CC","UNK_TYPE2","",0x2), - 0x8082B4D0:("D_8082B4D0","UNK_TYPE2","",0x2), - 0x8082B4D4:("D_8082B4D4","UNK_TYPE2","",0x2), - 0x8082B4D8:("D_8082B4D8","UNK_TYPE2","",0x2), - 0x8082B4DC:("D_8082B4DC","f32","",0x4), - 0x8082B4E0:("D_8082B4E0","UNK_TYPE1","",0x1), - 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), - 0x8082B584:("D_8082B584","UNK_TYPE2","",0x2), - 0x8082B590:("D_8082B590","UNK_TYPE2","",0x2), - 0x8082B59C:("D_8082B59C","UNK_TYPE1","",0x1), - 0x8082B5B4:("D_8082B5B4","UNK_TYPE1","",0x1), - 0x8082B5CC:("D_8082B5CC","UNK_TYPE1","",0x1), - 0x8082B5E0:("D_8082B5E0","UNK_TYPE1","",0x1), - 0x8082B5F4:("D_8082B5F4","UNK_TYPE2","",0x2), - 0x8082B600:("D_8082B600","UNK_TYPE2","",0x2), - 0x8082B604:("D_8082B604","UNK_TYPE2","",0x2), - 0x8082B608:("D_8082B608","UNK_TYPE2","",0x2), - 0x8082B60C:("D_8082B60C","UNK_TYPE1","",0x1), - 0x8082B684:("D_8082B684","UNK_TYPE2","",0x2), - 0x8082B6CC:("D_8082B6CC","UNK_TYPE1","",0x1), - 0x8082B6D4:("D_8082B6D4","UNK_TYPE1","",0x1), - 0x8082B6DC:("D_8082B6DC","UNK_TYPE1","",0x1), - 0x8082B6E4:("D_8082B6E4","UNK_TYPE2","",0x2), - 0x8082B6F0:("D_8082B6F0","UNK_TYPE1","",0x1), - 0x8082B6F4:("D_8082B6F4","UNK_TYPE2","",0x2), - 0x8082B6F8:("D_8082B6F8","UNK_TYPE2","",0x2), + 0x8082B4C8:("sStrayFairyIconTimer","UNK_TYPE2","",0x2), + 0x8082B4CC:("sStrayFairyIconIndex","UNK_TYPE2","",0x2), + 0x8082B4D0:("sStrayFairyIconAlphaScaleTimer","UNK_TYPE2","",0x2), + 0x8082B4D4:("sStrayFairyIconAlphaScaleState","UNK_TYPE2","",0x2), + 0x8082B4D8:("sStrayFairyIconAlpha","UNK_TYPE2","",0x2), + 0x8082B4DC:("sStrayFairyIconScale","f32","",0x4), + 0x8082B4E0:("sStrayFairyIconTextures","UNK_TYPE1","",0x1), + 0x8082B520:("sStrayFairyIconPrimColors","UNK_TYPE1","",0x1), + 0x8082B52C:("sStrayFairyIconEnvColors","UNK_TYPE1","",0x1), + 0x8082B538:("sStrayFairyIconRectS","UNK_TYPE1","",0x1), + 0x8082B548:("sCloudTextures","s16","[30]",0x3C), + 0x8082B584:("sWorldMapDotPrimColors","UNK_TYPE2","",0x2), + 0x8082B590:("sWorldMapDotEnvColors","UNK_TYPE2","",0x2), + 0x8082B59C:("sWorldMapCursorsRectLeft","UNK_TYPE1","",0x1), + 0x8082B5B4:("sWorldMapCursorsRectTop","UNK_TYPE1","",0x1), + 0x8082B5CC:("sGreatFairySpawnRegions","UNK_TYPE1","",0x1), + 0x8082B5E0:("sOwlWarpPauseItems","UNK_TYPE1","",0x1), + 0x8082B5F4:("sStickAdjTimer","UNK_TYPE2","",0x2), + 0x8082B600:("sMaskEquipState","UNK_TYPE2","",0x2), + 0x8082B604:("sMaskEquipMagicArrowSlotHoldTimer","UNK_TYPE2","",0x2), + 0x8082B608:("sMaskEquipAnimTimer","UNK_TYPE2","",0x2), + 0x8082B60C:("gMaskPlayerFormSlotRestrictions","UNK_TYPE1","",0x1), + 0x8082B684:("sMasksGivenOnMoonBits","UNK_TYPE2","",0x2), + 0x8082B6CC:("sMaskPlayerFormItems","UNK_TYPE1","",0x1), + 0x8082B6D4:("sMaskCButtonPosX","UNK_TYPE1","",0x1), + 0x8082B6DC:("sMaskCButtonPosY","UNK_TYPE1","",0x1), + 0x8082B6E4:("sMaskEquipMagicArrowBowSlotHoldTimer","UNK_TYPE2","",0x2), + 0x8082B6F0:("sPromptAlphaTargets","UNK_TYPE1","",0x1), + 0x8082B6F4:("sPromptAlphaTargetIndex","UNK_TYPE2","",0x2), + 0x8082B6F8:("sPromptAlphaTimer","UNK_TYPE2","",0x2), 0x8082B700:("D_8082B700","UNK_TYPE1","",0x1), 0x8082B73C:("D_8082B73C","UNK_TYPE1","",0x1), 0x8082B778:("D_8082B778","UNK_TYPE1","",0x1), 0x8082B7B4:("D_8082B7B4","UNK_TYPE1","",0x1), 0x8082B7F0:("D_8082B7F0","UNK_TYPE2","",0x2), 0x8082B838:("D_8082B838","UNK_TYPE2","",0x2), - 0x8082B880:("D_8082B880","UNK_TYPE2","",0x2), - 0x8082B884:("D_8082B884","UNK_TYPE2","",0x2), - 0x8082B888:("D_8082B888","UNK_TYPE2","",0x2), - 0x8082B88C:("D_8082B88C","UNK_TYPE2","",0x2), - 0x8082B890:("D_8082B890","UNK_TYPE2","",0x2), - 0x8082B894:("D_8082B894","UNK_TYPE2","",0x2), - 0x8082B898:("D_8082B898","UNK_TYPE2","",0x2), - 0x8082B89C:("D_8082B89C","UNK_TYPE2","",0x2), - 0x8082B8A0:("D_8082B8A0","UNK_TYPE2","",0x2), - 0x8082B8A4:("D_8082B8A4","UNK_TYPE2","",0x2), - 0x8082B8A8:("D_8082B8A8","UNK_TYPE2","",0x2), - 0x8082B8AC:("D_8082B8AC","UNK_TYPE2","",0x2), - 0x8082B8B0:("D_8082B8B0","UNK_TYPE2","",0x2), - 0x8082B8B4:("D_8082B8B4","UNK_TYPE2","",0x2), - 0x8082B8B8:("D_8082B8B8","UNK_TYPE1","",0x1), - 0x8082B8D8:("D_8082B8D8","UNK_TYPE1","",0x1), - 0x8082B8F8:("D_8082B8F8","UNK_TYPE1","",0x1), - 0x8082B908:("D_8082B908","f32","",0x4), + 0x8082B880:("sGameOverPrimR","UNK_TYPE2","",0x2), + 0x8082B884:("sGameOverPrimG","UNK_TYPE2","",0x2), + 0x8082B888:("sGameOverPrimB","UNK_TYPE2","",0x2), + 0x8082B88C:("sGameOverPrimAlpha","UNK_TYPE2","",0x2), + 0x8082B890:("sCursorPrimR","UNK_TYPE2","",0x2), + 0x8082B894:("sCursorPrimG","UNK_TYPE2","",0x2), + 0x8082B898:("sCursorPrimB","UNK_TYPE2","",0x2), + 0x8082B89C:("sCursorEnvR","UNK_TYPE2","",0x2), + 0x8082B8A0:("sCursorEnvG","UNK_TYPE2","",0x2), + 0x8082B8A4:("sCursorEnvB","UNK_TYPE2","",0x2), + 0x8082B8A8:("sGameOverEnvR","UNK_TYPE2","",0x2), + 0x8082B8AC:("sGameOverEnvG","UNK_TYPE2","",0x2), + 0x8082B8B0:("sGameOverEnvB","UNK_TYPE2","",0x2), + 0x8082B8B4:("sInDungeonScene","UNK_TYPE2","",0x2), + 0x8082B8B8:("sPageSwitchEyeDx","UNK_TYPE1","",0x1), + 0x8082B8D8:("sPageSwitchEyeDz","UNK_TYPE1","",0x1), + 0x8082B8F8:("sPageSwitchNextPageIndex","UNK_TYPE1","",0x1), + 0x8082B908:("sPauseMenuVerticalOffset","f32","",0x4), 0x8082B90C:("D_8082B90C","f32","",0x4), - 0x8082B910:("D_8082B910","f32","",0x4), - 0x8082B914:("D_8082B914","f32","",0x4), - 0x8082B918:("D_8082B918","UNK_TYPE2","",0x2), - 0x8082B91C:("D_8082B91C","UNK_TYPE2","",0x2), + 0x8082B910:("sPauseCursorLeftMoveOffsetX","f32","",0x4), + 0x8082B914:("sPauseCursorRightMoveOffsetX","f32","",0x4), + 0x8082B918:("sPauseCursorLeftX","UNK_TYPE2","",0x2), + 0x8082B91C:("sPauseCursorRightX","UNK_TYPE2","",0x2), 0x8082B920:("D_8082B920","UNK_TYPE2","",0x2), 0x8082B924:("D_8082B924","UNK_TYPE2","",0x2), - 0x8082B944:("D_8082B944","UNK_TYPE2","",0x2), + 0x8082B944:("sGameOverRectPosY","UNK_TYPE2","",0x2), 0x8082B948:("D_8082B948","UNK_TYPE2","",0x2), 0x8082B96C:("D_8082B96C","UNK_TYPE2","",0x2), 0x8082B990:("D_8082B990","UNK_TYPE2","",0x2), @@ -4868,10 +4806,10 @@ 0x8082BB38:("D_8082BB38","UNK_PTR","",0x4), 0x8082BB50:("D_8082BB50","UNK_PTR","",0x4), 0x8082BB68:("D_8082BB68","UNK_TYPE2","",0x2), - 0x8082BB74:("D_8082BB74","UNK_TYPE2","",0x2), - 0x8082BBC4:("D_8082BBC4","UNK_TYPE2","",0x2), - 0x8082BC14:("D_8082BC14","UNK_TYPE2","",0x2), - 0x8082BC64:("D_8082BC64","UNK_TYPE2","",0x2), + 0x8082BB74:("sQuestVtxRectLeft","UNK_TYPE2","",0x2), + 0x8082BBC4:("sQuestVtxRectTop","UNK_TYPE2","",0x2), + 0x8082BC14:("sQuestVtxWidths","UNK_TYPE2","",0x2), + 0x8082BC64:("sQuestVtxHeights","UNK_TYPE2","",0x2), 0x8082BCB4:("D_8082BCB4","UNK_TYPE1","",0x1), 0x8082BCCC:("D_8082BCCC","UNK_TYPE1","",0x1), 0x8082BCDC:("D_8082BCDC","UNK_TYPE1","",0x1), @@ -4883,15 +4821,15 @@ 0x8082BDCC:("D_8082BDCC","UNK_TYPE1","",0x1), 0x8082BE28:("D_8082BE28","UNK_TYPE1","",0x1), 0x8082BE84:("D_8082BE84","UNK_TYPE2","",0x2), - 0x8082BE88:("D_8082BE88","UNK_TYPE1","",0x1), - 0x8082BE9C:("D_8082BE9C","UNK_TYPE2","",0x2), - 0x8082BEA0:("D_8082BEA0","UNK_TYPE2","",0x2), - 0x8082BEA4:("D_8082BEA4","UNK_TYPE2","",0x2), - 0x8082BEA8:("D_8082BEA8","UNK_TYPE2","",0x2), - 0x8082BEAC:("D_8082BEAC","UNK_TYPE2","",0x2), - 0x8082BEB0:("D_8082BEB0","UNK_TYPE2","",0x2), - 0x8082BEB4:("D_8082BEB4","UNK_TYPE2","",0x2), - 0x8082BEB8:("D_8082BEB8","UNK_TYPE2","",0x2), + 0x8082BE88:("sCursorPointsToOcarinaModes","UNK_TYPE1","",0x1), + 0x8082BE9C:("sUnpausedHudVisibility","UNK_TYPE2","",0x2), + 0x8082BEA0:("sNextMainState","UNK_TYPE2","",0x2), + 0x8082BEA4:("sDelayTimer","UNK_TYPE2","",0x2), + 0x8082BEA8:("sGameOverColorTimer","UNK_TYPE2","",0x2), + 0x8082BEAC:("sStickXRepeatTimer","UNK_TYPE2","",0x2), + 0x8082BEB0:("sStickYRepeatTimer","UNK_TYPE2","",0x2), + 0x8082BEB4:("sStickXRepeatState","UNK_TYPE2","",0x2), + 0x8082BEB8:("sStickYRepeatState","UNK_TYPE2","",0x2), 0x8082BEC0:("D_8082BEC0","char","[]",0x1), 0x8082BEC4:("D_8082BEC4","char","[]",0x1), 0x8082BED0:("D_8082BED0","char","[]",0x1), @@ -5008,7 +4946,7 @@ 0x8082DA52:("D_8082DA52","UNK_TYPE1","",0x1), 0x8082DA54:("D_8082DA54","UNK_TYPE1","",0x1), 0x8082DA56:("D_8082DA56","UNK_TYPE1","",0x1), - 0x8082DA58:("D_8082DA58","UNK_TYPE1","",0x1), + 0x8082DA58:("sUnpausedButtonStatus","UNK_TYPE1","",0x1), 0x8082DA60:("D_8082DA60","f32","",0x4), 0x8082DA64:("D_8082DA64","f32","",0x4), 0x8082DA68:("D_8082DA68","f32","",0x4), @@ -5791,7 +5729,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), @@ -6410,7 +6348,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), @@ -6430,9 +6368,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), @@ -6826,9 +6764,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), @@ -7047,8 +6984,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), @@ -8498,12 +8435,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), @@ -8590,7 +8527,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), @@ -9228,8 +9165,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), @@ -9586,20 +9523,20 @@ 0x809A61E0:("D_809A61E0","f32","",0x4), 0x809A61E4:("D_809A61E4","f32","",0x4), 0x809A61E8:("D_809A61E8","f32","",0x4), - 0x809A8C80:("D_809A8C80","UNK_TYPE4","",0x4), - 0x809A8C94:("D_809A8C94","UNK_TYPE1","",0x1), - 0x809A8CAC:("D_809A8CAC","UNK_TYPE1","",0x1), - 0x809A8CC4:("D_809A8CC4","UNK_TYPE1","",0x1), - 0x809A8CDC:("D_809A8CDC","UNK_TYPE1","",0x1), + 0x809A8C80:("sOccupiedIndices","UNK_TYPE4","",0x4), + 0x809A8C94:("sLimbIndexToShadowBodyPartsIndex","UNK_TYPE1","",0x1), + 0x809A8CAC:("sParentBodyParts","UNK_TYPE1","",0x1), + 0x809A8CC4:("sShadowSizes","UNK_TYPE1","",0x1), + 0x809A8CDC:("sDamageTable","UNK_TYPE1","",0x1), 0x809A8CFC:("En_Grasshopper_InitVars","UNK_TYPE1","",0x1), - 0x809A8D1C:("D_809A8D1C","UNK_TYPE1","",0x1), - 0x809A8D64:("D_809A8D64","UNK_TYPE1","",0x1), - 0x809A8D74:("D_809A8D74","UNK_TYPE1","",0x1), - 0x809A8D94:("D_809A8D94","UNK_TYPE1","",0x1), - 0x809A8D9C:("D_809A8D9C","UNK_TYPE4","",0x4), - 0x809A8E08:("D_809A8E08","UNK_TYPE4","",0x4), - 0x809A8E14:("D_809A8E14","UNK_TYPE4","",0x4), - 0x809A8E20:("D_809A8E20","UNK_TYPE1","",0x1), + 0x809A8D1C:("sJntSphElementsInit","UNK_TYPE1","",0x1), + 0x809A8D64:("sJntSphInit","UNK_TYPE1","",0x1), + 0x809A8D74:("sAnimations","UNK_TYPE1","",0x1), + 0x809A8D94:("sAnimationModes","UNK_TYPE1","",0x1), + 0x809A8D9C:("sFireVelocityAndAccel","UNK_TYPE4","",0x4), + 0x809A8E08:("sEffectOffsetFromTailTop","UNK_TYPE4","",0x4), + 0x809A8E14:("sZeroVec3f","UNK_TYPE4","",0x4), + 0x809A8E20:("sLightningTextures","UNK_TYPE1","",0x1), 0x809A8E40:("D_809A8E40","f32","",0x4), 0x809A8E44:("D_809A8E44","f32","",0x4), 0x809A8E48:("D_809A8E48","f32","",0x4), @@ -9929,7 +9866,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), @@ -9974,23 +9911,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:("sTownFierceDeityPlayerPos","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), @@ -10006,15 +9943,15 @@ 0x809CA31C:("D_809CA31C","UNK_TYPE1","",0x1), 0x809CA320:("D_809CA320","f32","",0x4), 0x809CA324:("D_809CA324","f32","",0x4), - 0x809CB050:("D_809CB050","UNK_TYPE1","",0x1), + 0x809CB050:("sZeroVec","UNK_TYPE1","",0x1), 0x809CB05C:("En_Syateki_Crow_InitVars","UNK_TYPE1","",0x1), 0x809CB07C:("D_809CB07C","UNK_TYPE1","",0x1), 0x809CB0A0:("D_809CB0A0","UNK_TYPE1","",0x1), 0x809CB0AC:("D_809CB0AC","UNK_PTR","",0x4), 0x809CB0B0:("D_809CB0B0","UNK_TYPE1","",0x1), - 0x809CB0C0:("D_809CB0C0","UNK_TYPE1","",0x1), - 0x809CB0CC:("D_809CB0CC","UNK_TYPE1","",0x1), - 0x809CB0D8:("D_809CB0D8","UNK_TYPE1","",0x1), + 0x809CB0C0:("sVelocity","UNK_TYPE1","",0x1), + 0x809CB0CC:("sAccel","UNK_TYPE1","",0x1), + 0x809CB0D8:("sBodyOffset","UNK_TYPE1","",0x1), 0x809CB0F0:("D_809CB0F0","f32","",0x4), 0x809CB0F4:("D_809CB0F4","f32","",0x4), 0x809CB0F8:("D_809CB0F8","f32","",0x4), @@ -10040,7 +9977,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), @@ -10284,12 +10221,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), @@ -11151,10 +11088,10 @@ 0x80A297D0:("D_80A297D0","f32","",0x4), 0x80A2B870:("D_80A2B870","UNK_TYPE1","",0x1), 0x80A2B88C:("Bg_Dblue_Movebg_InitVars","UNK_TYPE1","",0x1), - 0x80A2B8AC:("D_80A2B8AC","UNK_TYPE1","",0x1), - 0x80A2B8DC:("D_80A2B8DC","UNK_TYPE1","",0x1), - 0x80A2B90C:("D_80A2B90C","UNK_TYPE1","",0x1), - 0x80A2B93C:("D_80A2B93C","UNK_TYPE1","",0x1), + 0x80A2B8AC:("sOpaDLists","UNK_TYPE1","",0x1), + 0x80A2B8DC:("sXluDLists","UNK_TYPE1","",0x1), + 0x80A2B90C:("sColHeaders","UNK_TYPE1","",0x1), + 0x80A2B93C:("sTexAnims","UNK_TYPE1","",0x1), 0x80A2B96C:("D_80A2B96C","UNK_TYPE1","",0x1), 0x80A2B974:("D_80A2B974","UNK_TYPE2","",0x2), 0x80A2B978:("D_80A2B978","UNK_TYPE1","",0x1), @@ -11173,15 +11110,15 @@ 0x80A2BBF4:("D_80A2BBF4","UNK_TYPE1","",0x1), 0x80A2BBF5:("D_80A2BBF5","UNK_TYPE1","",0x1), 0x80A2CA90:("En_Syateki_Dekunuts_InitVars","UNK_TYPE1","",0x1), - 0x80A2CAB0:("D_80A2CAB0","UNK_TYPE1","",0x1), - 0x80A2CADC:("D_80A2CADC","UNK_TYPE4","",0x4), - 0x80A2CAE8:("D_80A2CAE8","UNK_PTR","",0x4), - 0x80A2CB90:("D_80A2CB90","UNK_TYPE1","",0x1), - 0x80A2CB9C:("D_80A2CB9C","UNK_TYPE4","",0x4), - 0x80A2CBA0:("D_80A2CBA0","UNK_TYPE1","",0x1), - 0x80A2CBAC:("D_80A2CBAC","UNK_TYPE1","",0x1), - 0x80A2CBB8:("D_80A2CBB8","UNK_TYPE1","",0x1), - 0x80A2CBBC:("D_80A2CBBC","UNK_TYPE1","",0x1), + 0x80A2CAB0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80A2CADC:("sBonusDekuScrubColliderDimensions","UNK_TYPE4","",0x4), + 0x80A2CAE8:("sAnimationInfo","UNK_PTR","",0x4), + 0x80A2CB90:("sInitChain","UNK_TYPE1","",0x1), + 0x80A2CB9C:("sDrawFlowers","UNK_TYPE4","",0x4), + 0x80A2CBA0:("sVelocity","UNK_TYPE1","",0x1), + 0x80A2CBAC:("sAccel","UNK_TYPE1","",0x1), + 0x80A2CBB8:("sPrimColor","UNK_TYPE1","",0x1), + 0x80A2CBBC:("sEnvColor","UNK_TYPE1","",0x1), 0x80A2CBC0:("D_80A2CBC0","f32","",0x4), 0x80A2D1C0:("Elf_Msg3_InitVars","UNK_TYPE1","",0x1), 0x80A2D1E0:("D_80A2D1E0","UNK_TYPE1","",0x1), @@ -11216,7 +11153,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), @@ -11528,7 +11465,7 @@ 0x80A41938:("D_80A41938","f32","",0x4), 0x80A41D20:("D_80A41D20","UNK_TYPE1","",0x1), 0x80A41D24:("D_80A41D24","UNK_TYPE1","",0x1), - 0x80A41D28:("D_80A41D28","UNK_TYPE1","",0x1), + 0x80A41D28:("sEnTest3_Input","Input","",0x18), 0x80A41D40:("D_80A41D40","f32","",0x4), 0x80A41D44:("D_80A41D44","UNK_TYPE1","",0x1), 0x80A41D48:("D_80A41D48","UNK_TYPE1","",0x1), @@ -11547,12 +11484,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), @@ -11569,8 +11506,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), @@ -11578,18 +11515,18 @@ 0x80A452A4:("D_80A452A4","UNK_TYPE1","",0x1), 0x80A452B0:("D_80A452B0","UNK_TYPE4","",0x4), 0x80A48B30:("En_Wiz_InitVars","UNK_TYPE1","",0x1), - 0x80A48B50:("D_80A48B50","UNK_TYPE1","",0x1), - 0x80A48CB8:("D_80A48CB8","UNK_PTR","",0x4), - 0x80A48CC8:("D_80A48CC8","UNK_TYPE1","",0x1), - 0x80A48CF4:("D_80A48CF4","UNK_TYPE1","",0x1), - 0x80A48D14:("D_80A48D14","UNK_TYPE1","",0x1), - 0x80A48D34:("D_80A48D34","UNK_TYPE1","",0x1), - 0x80A48D4C:("D_80A48D4C","UNK_TYPE1","",0x1), - 0x80A48D54:("D_80A48D54","UNK_TYPE4","",0x4), - 0x80A48D60:("D_80A48D60","UNK_TYPE1","",0x1), - 0x80A48D64:("D_80A48D64","UNK_TYPE1","",0x1), - 0x80A48D68:("D_80A48D68","UNK_TYPE4","",0x4), - 0x80A48D74:("D_80A48D74","UNK_TYPE4","",0x4), + 0x80A48B50:("sJntSphElementsInit","UNK_TYPE1","",0x1), + 0x80A48CB8:("sJntSphInit","UNK_PTR","",0x4), + 0x80A48CC8:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80A48CF4:("sFireWizrobeDamageTable","UNK_TYPE1","",0x1), + 0x80A48D14:("sIceWizrobeDamageTable","UNK_TYPE1","",0x1), + 0x80A48D34:("sAnimations","UNK_TYPE1","",0x1), + 0x80A48D4C:("sAnimationModes","UNK_TYPE1","",0x1), + 0x80A48D54:("staffTargetFlameScale","UNK_TYPE4","",0x4), + 0x80A48D60:("sDustPrimColor","UNK_TYPE1","",0x1), + 0x80A48D64:("sDustEnvTimer","UNK_TYPE1","",0x1), + 0x80A48D68:("staffFlamePos","UNK_TYPE4","",0x4), + 0x80A48D74:("staffFlamePos","UNK_TYPE4","",0x4), 0x80A48D80:("jtbl_80A48D80","UNK_PTR","",0x4), 0x80A48D98:("D_80A48D98","f32","",0x4), 0x80A48D9C:("D_80A48D9C","f32","",0x4), @@ -11617,15 +11554,15 @@ 0x80A495F8:("D_80A495F8","f32","",0x4), 0x80A495FC:("D_80A495FC","f32","",0x4), 0x80A49600:("D_80A49600","f32","",0x4), - 0x80A4C1C0:("D_80A4C1C0","UNK_TYPE4","",0x4), + 0x80A4C1C0:("sPoolHitByIceArrow","UNK_TYPE4","",0x4), 0x80A4C1C4:("En_Wiz_Fire_InitVars","UNK_TYPE1","",0x1), 0x80A4C1E4:("D_80A4C1E4","UNK_TYPE1","",0x1), 0x80A4C210:("D_80A4C210","UNK_TYPE4","",0x4), 0x80A4C21C:("D_80A4C21C","UNK_TYPE4","",0x4), 0x80A4C228:("D_80A4C228","UNK_TYPE4","",0x4), - 0x80A4C234:("D_80A4C234","UNK_TYPE1","",0x1), - 0x80A4C24C:("D_80A4C24C","UNK_TYPE1","",0x1), - 0x80A4C250:("D_80A4C250","UNK_TYPE1","",0x1), + 0x80A4C234:("lightSettingsColors","UNK_TYPE1","",0x1), + 0x80A4C24C:("sSteamPrimColor","UNK_TYPE1","",0x1), + 0x80A4C250:("sSteamEnvColor","UNK_TYPE1","",0x1), 0x80A4C260:("jtbl_80A4C260","UNK_PTR","",0x4), 0x80A4C274:("D_80A4C274","f32","",0x4), 0x80A4C278:("D_80A4C278","f32","",0x4), @@ -11732,7 +11669,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), @@ -11800,20 +11737,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), @@ -12157,12 +12093,12 @@ 0x80A70510:("jtbl_80A70510","UNK_PTR","",0x4), 0x80A7056C:("jtbl_80A7056C","UNK_PTR","",0x4), 0x80A71080:("Bg_Crace_Movebg_InitVars","UNK_TYPE1","",0x1), - 0x80A710A0:("D_80A710A0","UNK_TYPE1","",0x1), - 0x80A710A4:("D_80A710A4","UNK_TYPE1","",0x1), - 0x80A710A8:("D_80A710A8","UNK_TYPE1","",0x1), - 0x80A710AC:("D_80A710AC","UNK_TYPE1","",0x1), + 0x80A710A0:("sHasInitializedIsLoaded","UNK_TYPE1","",0x1), + 0x80A710A4:("sLoadedDoorCount","UNK_TYPE1","",0x1), + 0x80A710A8:("sInitChain","UNK_TYPE1","",0x1), + 0x80A710AC:("sUnitVecZ","UNK_TYPE1","",0x1), 0x80A710C0:("D_80A710C0","f32","",0x4), - 0x80A711B0:("D_80A711B0","UNK_TYPE1","",0x1), + 0x80A711B0:("sIsLoaded","UNK_TYPE1","",0x1), 0x80A739A0:("D_80A739A0","UNK_PTR","",0x4), 0x80A73AE0:("En_Dno_InitVars","UNK_TYPE1","",0x1), 0x80A73B00:("D_80A73B00","UNK_TYPE1","",0x1), @@ -12380,7 +12316,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), @@ -12401,10 +12337,10 @@ 0x80A8B188:("D_80A8B188","UNK_TYPE1","",0x1), 0x80A8B250:("D_80A8B250","UNK_TYPE4","",0x4), 0x80A8B25C:("D_80A8B25C","Color_RGBA8","[6]",0x18), - 0x80A8B280:("D_80A8B280","UNK_TYPE1","",0x1), + 0x80A8B280:("sDustTextures","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), @@ -12504,8 +12440,8 @@ 0x80A9930C:("D_80A9930C","UNK_TYPE1","",0x1), 0x80A993AC:("D_80A993AC","UNK_TYPE1","",0x1), 0x80A993D0:("D_80A993D0","UNK_TYPE1","",0x1), - 0x80A993F4:("D_80A993F4","UNK_TYPE1","",0x1), - 0x80A99404:("D_80A99404","UNK_TYPE1","",0x1), + 0x80A993F4:("sYoungerBrotherEyeTextures","UNK_TYPE1","",0x1), + 0x80A99404:("sYoungerBrotherBeltTextures","UNK_TYPE1","",0x1), 0x80A99410:("D_80A99410","UNK_TYPE1","",0x1), 0x80A9941C:("D_80A9941C","UNK_TYPE1","",0x1), 0x80A99428:("D_80A99428","UNK_TYPE1","",0x1), @@ -12721,21 +12657,21 @@ 0x80AAE960:("Dm_Char06_InitVars","UNK_TYPE1","",0x1), 0x80AAEFF0:("Dm_Char07_InitVars","UNK_TYPE1","",0x1), 0x80AB1370:("Dm_Char08_InitVars","UNK_TYPE1","",0x1), - 0x80AB1390:("D_80AB1390","UNK_TYPE1","",0x1), - 0x80AB1398:("D_80AB1398","UNK_TYPE1","",0x1), - 0x80AB13A0:("D_80AB13A0","UNK_TYPE1","",0x1), - 0x80AB14D0:("D_80AB14D0","UNK_TYPE1","",0x1), - 0x80AB1600:("D_80AB1600","UNK_TYPE2","",0x2), - 0x80AB1648:("D_80AB1648","UNK_TYPE2","",0x2), - 0x80AB1690:("D_80AB1690","UNK_TYPE1","",0x1), + 0x80AB1390:("D_80AB1390","CamData","",0x8), + 0x80AB1398:("D_80AB1398","SurfaceType","",0x8), + 0x80AB13A0:("D_80AB13A0","CollisionPoly","19",0xCC), + 0x80AB14D0:("sTurtleGreatBayTempleColPolygons2","CollisionPoly[]","19",0xCC), + 0x80AB1600:("D_80AB1600","Vec3s[]","12",0x48), + 0x80AB1648:("D_80AB1648","Vec3s[]","12",0x48), + 0x80AB1690:("sTurtleGreatBayTempleCol","CollisionHeader","",0x2C), 0x80AB16A8:("D_80AB16A8","UNK_PTR","",0x4), - 0x80AB16BC:("D_80AB16BC","UNK_TYPE1","",0x1), - 0x80AB1764:("D_80AB1764","UNK_TYPE1","",0x1), - 0x80AB1770:("D_80AB1770","UNK_TYPE2","",0x2), - 0x80AB1774:("D_80AB1774","UNK_TYPE1","",0x1), - 0x80AB1778:("D_80AB1778","UNK_TYPE1","",0x1), - 0x80AB177C:("D_80AB177C","UNK_TYPE4","",0x4), - 0x80AB1788:("D_80AB1788","UNK_TYPE1","",0x1), + 0x80AB16BC:("sLargeTurtleAnimationInfo","AnimationInfo[]","0x7",0xE0), + 0x80AB1764:("sInitChain","InitChainEntry","",0x1), + 0x80AB1770:("D_80AB1770","s16","",0x2), + 0x80AB1774:("sLargeTurtleBubblePrimColor","Color_RGBA8","",0x4), + 0x80AB1778:("sLargeTurtleBubbleEnvColor","Color_RGBA8","",0x4), + 0x80AB177C:("sLargeTurtleBubbelAccel","Vec3f","",0xC), + 0x80AB1788:("sLargeTurtleEyeTextures","TexturePtr","9",0x1), 0x80AB17B0:("jtbl_80AB17B0","UNK_PTR","",0x4), 0x80AB17C8:("D_80AB17C8","f32","",0x4), 0x80AB17CC:("D_80AB17CC","f32","",0x4), @@ -12931,9 +12867,9 @@ 0x80AC1E00:("D_80AC1E00","f32","",0x4), 0x80AC1E04:("D_80AC1E04","f32","",0x4), 0x80AC2580:("En_Door_Etc_InitVars","UNK_TYPE1","",0x1), - 0x80AC25A0:("D_80AC25A0","UNK_TYPE1","",0x1), - 0x80AC25CC:("D_80AC25CC","UNK_TYPE2","",0x2), - 0x80AC2634:("D_80AC2634","UNK_TYPE1","",0x1), + 0x80AC25A0:("sCylinderInit","UNK_TYPE1","",0x1), + 0x80AC25CC:("sObjInfo","UNK_TYPE2","",0x2), + 0x80AC2634:("sInitChain","UNK_TYPE1","",0x1), 0x80AC2650:("D_80AC2650","f32","",0x4), 0x80AC4510:("En_Bigokuta_InitVars","UNK_TYPE1","",0x1), 0x80AC4530:("D_80AC4530","UNK_TYPE1","",0x1), @@ -12988,8 +12924,8 @@ 0x80AC4F60:("D_80AC4F60","f32","",0x4), 0x80AC4F64:("D_80AC4F64","f32","",0x4), 0x80AC5060:("D_80AC5060","UNK_TYPE1","",0x1), - 0x80AC5630:("D_80AC5630","UNK_TYPE1","",0x1), - 0x80AC5660:("D_80AC5660","UNK_TYPE1","",0x1), + 0x80AC5630:("sTriforceWipeDL","UNK_TYPE1","",0x1), + 0x80AC5660:("sTriforceWipeVtx","UNK_TYPE1","",0x1), 0x80AC5700:("TransitionTriforce_InitVars","UNK_PTR","",0x4), 0x80AC5730:("D_80AC5730","f32","",0x4), 0x80AC5734:("D_80AC5734","f32","",0x4), @@ -13235,7 +13171,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), @@ -13390,8 +13326,8 @@ 0x80AF0050:("D_80AF0050","UNK_TYPE1","",0x1), 0x80AF00F0:("Bg_Market_Step_InitVars","UNK_TYPE1","",0x1), 0x80AF0110:("D_80AF0110","UNK_TYPE1","",0x1), - 0x80AF0120:("D_80AF0120","UNK_TYPE1","",0x1), - 0x80AF0128:("D_80AF0128","UNK_TYPE1","",0x1), + 0x80AF0120:("sMarketDLs","UNK_TYPE1","",0x1), + 0x80AF0128:("sBankAdvertisementsAndFakeDoorDLs","UNK_TYPE1","",0x1), 0x80AF0720:("Obj_Lupygamelift_InitVars","UNK_TYPE1","",0x1), 0x80AF0740:("D_80AF0740","UNK_TYPE1","",0x1), 0x80AF0750:("D_80AF0750","f32","",0x4), @@ -13934,7 +13870,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), @@ -13965,27 +13901,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), @@ -14345,8 +14276,8 @@ 0x80B3DCAC:("D_80B3DCAC","UNK_TYPE1","",0x1), 0x80B3DCB8:("sAnimations","UNK_TYPE1","",0x1), 0x80B3DE58:("D_80B3DE58","UNK_TYPE1","",0x1), - 0x80B3DE74:("D_80B3DE74","UNK_TYPE1","",0x1), - 0x80B3DEAC:("D_80B3DEAC","UNK_TYPE1","",0x1), + 0x80B3DE74:("sCsAnimations","UNK_TYPE1","",0x1), + 0x80B3DEAC:("sEyeTextures","UNK_TYPE1","",0x1), 0x80B3DEC0:("D_80B3DEC0","f32","",0x4), 0x80B3DEC4:("D_80B3DEC4","f32","",0x4), 0x80B3DEC8:("D_80B3DEC8","f32","",0x4), @@ -14354,7 +14285,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), @@ -14372,7 +14303,7 @@ 0x80B3FE50:("D_80B3FE50","f32","",0x4), 0x80B3FE54:("D_80B3FE54","f32","",0x4), 0x80B3FE58:("D_80B3FE58","UNK_TYPE1","",0x1), - 0x80B3FE70:("D_80B3FE70","UNK_TYPE1","",0x1), + 0x80B3FE70:("sEyeTextures","TexturePtr[]","0x9",0x4), 0x80B3FE90:("D_80B3FE90","f32","",0x4), 0x80B3FE94:("D_80B3FE94","f32","",0x4), 0x80B40760:("Bg_Goron_Oyu_InitVars","UNK_TYPE1","",0x1), @@ -14400,11 +14331,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), @@ -14630,8 +14561,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), @@ -15047,7 +14978,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), @@ -15055,14 +14986,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), @@ -15151,7 +15080,7 @@ 0x80B82228:("D_80B82228","f32","",0x4), 0x80B8222C:("D_80B8222C","f32","",0x4), 0x80B83A00:("Bg_Dblue_Balance_InitVars","UNK_TYPE1","",0x1), - 0x80B83A20:("D_80B83A20","UNK_TYPE4","",0x4), + 0x80B83A20:("sTypeInfo","UNK_TYPE4","",0x4), 0x80B83A74:("D_80B83A74","UNK_TYPE1","",0x1), 0x80B83A90:("D_80B83A90","UNK_TYPE1","",0x1), 0x80B83A92:("D_80B83A92","UNK_TYPE1","",0x1), @@ -15357,9 +15286,9 @@ 0x80B96178:("D_80B96178","UNK_TYPE1","",0x1), 0x80B963C0:("Obj_Jg_Gakki_InitVars","UNK_TYPE1","",0x1), 0x80B96540:("Bg_Inibs_Movebg_InitVars","UNK_TYPE1","",0x1), - 0x80B96560:("D_80B96560","UNK_TYPE1","",0x1), - 0x80B96568:("D_80B96568","UNK_TYPE1","",0x1), - 0x80B96570:("D_80B96570","UNK_TYPE1","",0x1), + 0x80B96560:("sOpaDLists","UNK_TYPE1","",0x1), + 0x80B96568:("sXluDLists","UNK_TYPE1","",0x1), + 0x80B96570:("sSandTexAnims","UNK_TYPE1","",0x1), 0x80B96578:("D_80B96578","UNK_TYPE1","",0x1), 0x80B998C0:("En_Zot_InitVars","UNK_TYPE1","",0x1), 0x80B998E0:("D_80B998E0","UNK_TYPE1","",0x1), @@ -15385,11 +15314,7 @@ 0x80B9A920:("Obj_Y2lift_InitVars","UNK_TYPE1","",0x1), 0x80B9A940:("D_80B9A940","UNK_TYPE1","",0x1), 0x80B9AE50:("Obj_Y2shutter_InitVars","UNK_TYPE1","",0x1), - 0x80B9AE70:("D_80B9AE70","UNK_TYPE1","",0x1), - 0x80B9AE8C:("D_80B9AE8C","UNK_TYPE1","",0x1), - 0x80B9AE8D:("D_80B9AE8D","UNK_TYPE1","",0x1), - 0x80B9AE8E:("D_80B9AE8E","UNK_TYPE1","",0x1), - 0x80B9AEAE:("D_80B9AEAE","UNK_TYPE1","",0x1), + 0x80B9AE70:("D_80B9AE70","UNK_TYPE1","",0x40), 0x80B9AEB0:("D_80B9AEB0","UNK_TYPE1","",0x1), 0x80B9B660:("Obj_Boat_InitVars","UNK_TYPE1","",0x1), 0x80B9B680:("D_80B9B680","UNK_TYPE1","",0x1), @@ -15675,15 +15600,15 @@ 0x80BBC6F0:("D_80BBC6F0","UNK_TYPE1","",0x1), 0x80BBC71C:("D_80BBC71C","UNK_TYPE1","",0x1), 0x80BBC750:("D_80BBC750","UNK_TYPE1","",0x1), - 0x80BBC75C:("D_80BBC75C","UNK_TYPE1","",0x1), + 0x80BBC75C:("sEyeTextures","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), @@ -15699,7 +15624,7 @@ 0x80BC15D0:("En_Nb_InitVars","UNK_TYPE1","",0x1), 0x80BC15F0:("D_80BC15F0","UNK_TYPE1","",0x1), 0x80BC161C:("D_80BC161C","UNK_TYPE1","",0x1), - 0x80BC1628:("D_80BC1628","UNK_TYPE1","",0x1), + 0x80BC1628:("sAnimationInfo","UNK_TYPE1","",0x1), 0x80BC1690:("jtbl_80BC1690","UNK_PTR","",0x4), 0x80BC16B8:("jtbl_80BC16B8","UNK_PTR","",0x4), 0x80BC16D0:("jtbl_80BC16D0","UNK_PTR","",0x4), @@ -15769,9 +15694,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), @@ -15876,7 +15801,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), @@ -15955,8 +15880,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), @@ -16129,17 +16053,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), @@ -16320,7 +16244,7 @@ 0x80BFCD78:("D_80BFCD78","f32","",0x4), 0x80BFCD7C:("D_80BFCD7C","f32","",0x4), 0x80BFD260:("En_Scopecoin_InitVars","UNK_TYPE1","",0x1), - 0x80BFD280:("D_80BFD280","UNK_TYPE1","",0x1), + 0x80BFD280:("sRupeeTextures","UNK_TYPE1","",0x1), 0x80BFDEA0:("D_80BFDEA0","UNK_TYPE1","",0x1), 0x80BFDEB4:("D_80BFDEB4","UNK_TYPE1","",0x1), 0x80BFDF28:("En_Bjt_InitVars","UNK_TYPE1","",0x1), @@ -16384,7 +16308,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), @@ -16635,7 +16559,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), @@ -16655,7 +16579,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), @@ -16665,7 +16589,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/eventinfconvert.py b/tools/eventinfconvert.py new file mode 100755 index 000000000..7205dfcc9 --- /dev/null +++ b/tools/eventinfconvert.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 + +import argparse +import math +import re + +def isValid(index: int, mask: int) -> bool: + if index < 0 or index > 7: + return False + if mask != (1 << int(math.log2(mask))): + return False + return True + +def getFlagMacro(index: int, mask: int) -> str: + return f"EVENTINF_{index}{int(math.log2(mask))}" + +def getCheckMacro(index: int, mask: int) -> str: + return f"CHECK_EVENTINF({getFlagMacro(index, mask)})" + +def getSetMacro(index: int, mask: int) -> str: + return f"SET_EVENTINF({getFlagMacro(index, mask)})" + +def getClearMacro(index: int, mask: int) -> str: + return f"CLEAR_EVENTINF({getFlagMacro(index, mask)})" + +NUMBER_PATTERN = r"(0[xX])?[0-9a-fA-F]+" + +def applyChange(fileContents: str, compiledRegex: re.Pattern, callback) -> str: + parsedContents = "" + + match = compiledRegex.search(fileContents) + while match: + index = int(match.group("index"), 0) + mask = int(match.group("mask"), 0) + + start, end = match.span() + parsedContents += fileContents[:start] + if isValid(index, mask): + parsedContents += callback(index, mask) + else: + parsedContents += fileContents[start:end] + + fileContents = fileContents[end:] + match = compiledRegex.search(fileContents) + + parsedContents += fileContents + return parsedContents + + +def updateCheck(fileContents: str) -> str: + checkRegex = re.compile(rf"gSaveContext.eventInf\[(?P{NUMBER_PATTERN})\]\s*\&\s*(?P{NUMBER_PATTERN})") + + return applyChange(fileContents, checkRegex, getCheckMacro) + +def updateSet(fileContents: str) -> str: + setRegex = re.compile(rf"gSaveContext.eventInf\[(?P{NUMBER_PATTERN})\]\s*\|=\s*(?P{NUMBER_PATTERN})") + + return applyChange(fileContents, setRegex, getSetMacro) + +def updateClear(fileContents: str) -> str: + clearRegex = re.compile(rf"gSaveContext.eventInf\[(?P{NUMBER_PATTERN})\]\s*\&=\s*(\(u8\))?~(?P{NUMBER_PATTERN})") + + return applyChange(fileContents, clearRegex, getClearMacro) + + +def read_file(filename): + with open(filename) as src_file: + return src_file.read() + +def write_file(filename, contents): + with open(filename, "w") as f: + f.write(contents) + + +def main(): + parser = argparse.ArgumentParser(description="Converts a eventInf access to a macro") + + parser.add_argument("filename", help="Replace every occurrence of numeric eventInf on this file to the corresponding macro") + args = parser.parse_args() + + fileContents = read_file(args.filename) + + parsedContents = updateCheck(fileContents) + parsedContents = updateSet(parsedContents) + parsedContents = updateClear(parsedContents) + + if fileContents != parsedContents: + write_file(args.filename, parsedContents) + +if __name__ == "__main__": + main() diff --git a/tools/extract_baserom.py b/tools/extract_baserom.py index bf9829bcb..03d230e80 100755 --- a/tools/extract_baserom.py +++ b/tools/extract_baserom.py @@ -892,7 +892,7 @@ FILE_NAMES = [ 'object_fall', 'object_hanareyama_obj', 'object_crace_object', - 'object_dnq', + 'object_dno', 'object_obj_tokeidai', 'object_eg', 'object_tru', @@ -963,7 +963,7 @@ FILE_NAMES = [ 'object_maruta', 'object_ghaka', 'object_oyu', - 'object_dnp', + 'object_dnq', 'object_dai', 'object_kgy', 'object_fb', @@ -984,7 +984,7 @@ FILE_NAMES = [ 'object_gi_seahorse', 'object_bigpo', 'object_hariko', - 'object_dno', + 'object_dnj', 'object_sinkai_kabe', 'object_kin2_obj', 'object_ishi', 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/filelists/mm.us.rev1/all.csv b/tools/filelists/mm.us.rev1/all.csv index b76d241e1..c23622330 100644 --- a/tools/filelists/mm.us.rev1/all.csv +++ b/tools/filelists/mm.us.rev1/all.csv @@ -883,7 +883,7 @@ 882,object_fall 883,object_hanareyama_obj 884,object_crace_object -885,object_dnq +885,object_dno 886,object_obj_tokeidai 887,object_eg 888,object_tru @@ -954,7 +954,7 @@ 953,object_maruta 954,object_ghaka 955,object_oyu -956,object_dnp +956,object_dnq 957,object_dai 958,object_kgy 959,object_fb @@ -975,7 +975,7 @@ 974,object_gi_seahorse 975,object_bigpo 976,object_hariko -977,object_dno +977,object_dnj 978,object_sinkai_kabe 979,object_kin2_obj 980,object_ishi diff --git a/tools/filelists/mm.us.rev1/objects.csv b/tools/filelists/mm.us.rev1/objects.csv index 187ec1c11..2e572503e 100644 --- a/tools/filelists/mm.us.rev1/objects.csv +++ b/tools/filelists/mm.us.rev1/objects.csv @@ -233,7 +233,7 @@ 882,object_fall 883,object_hanareyama_obj 884,object_crace_object -885,object_dnq +885,object_dno 886,object_obj_tokeidai 887,object_eg 888,object_tru @@ -304,7 +304,7 @@ 953,object_maruta 954,object_ghaka 955,object_oyu -956,object_dnp +956,object_dnq 957,object_dai 958,object_kgy 959,object_fb @@ -325,7 +325,7 @@ 974,object_gi_seahorse 975,object_bigpo 976,object_hariko -977,object_dno +977,object_dnj 978,object_sinkai_kabe 979,object_kin2_obj 980,object_ishi diff --git a/tools/ido_recomp/linux/5.3/as0 b/tools/ido_recomp/linux/5.3/as0 new file mode 100755 index 000000000..15c169107 Binary files /dev/null and b/tools/ido_recomp/linux/5.3/as0 differ diff --git a/tools/ido_recomp/linux/5.3/as1 b/tools/ido_recomp/linux/5.3/as1 index 41c2545af..1a24f18b2 100755 Binary files a/tools/ido_recomp/linux/5.3/as1 and b/tools/ido_recomp/linux/5.3/as1 differ diff --git a/tools/ido_recomp/linux/5.3/cc b/tools/ido_recomp/linux/5.3/cc index 3dcc53798..65f0d1b2d 100755 Binary files a/tools/ido_recomp/linux/5.3/cc and b/tools/ido_recomp/linux/5.3/cc differ diff --git a/tools/ido_recomp/linux/5.3/cfe b/tools/ido_recomp/linux/5.3/cfe index e9594fafc..cbb4f9d44 100755 Binary files a/tools/ido_recomp/linux/5.3/cfe and b/tools/ido_recomp/linux/5.3/cfe differ diff --git a/tools/ido_recomp/linux/5.3/err.english.cc b/tools/ido_recomp/linux/5.3/err.english.cc old mode 100755 new mode 100644 diff --git a/tools/ido_recomp/linux/5.3/ugen b/tools/ido_recomp/linux/5.3/ugen index b2b662f1d..119d2817b 100755 Binary files a/tools/ido_recomp/linux/5.3/ugen and b/tools/ido_recomp/linux/5.3/ugen differ diff --git a/tools/ido_recomp/linux/5.3/ujoin b/tools/ido_recomp/linux/5.3/ujoin old mode 100644 new mode 100755 index f9c90b8be..4091986a8 Binary files a/tools/ido_recomp/linux/5.3/ujoin and b/tools/ido_recomp/linux/5.3/ujoin differ diff --git a/tools/ido_recomp/linux/5.3/uld b/tools/ido_recomp/linux/5.3/uld old mode 100644 new mode 100755 index f227222bc..653ff37df Binary files a/tools/ido_recomp/linux/5.3/uld and b/tools/ido_recomp/linux/5.3/uld differ diff --git a/tools/ido_recomp/linux/5.3/umerge b/tools/ido_recomp/linux/5.3/umerge old mode 100644 new mode 100755 index 00a8281d2..4b00ffa36 Binary files a/tools/ido_recomp/linux/5.3/umerge and b/tools/ido_recomp/linux/5.3/umerge differ diff --git a/tools/ido_recomp/linux/5.3/uopt b/tools/ido_recomp/linux/5.3/uopt index 5afe7a11c..d5ba32fbd 100755 Binary files a/tools/ido_recomp/linux/5.3/uopt and b/tools/ido_recomp/linux/5.3/uopt differ diff --git a/tools/ido_recomp/linux/5.3/usplit b/tools/ido_recomp/linux/5.3/usplit old mode 100644 new mode 100755 index a1c5ebad6..17d9d3d5d Binary files a/tools/ido_recomp/linux/5.3/usplit and b/tools/ido_recomp/linux/5.3/usplit differ diff --git a/tools/ido_recomp/linux/7.1/as0 b/tools/ido_recomp/linux/7.1/as0 new file mode 100755 index 000000000..e9ef71c63 Binary files /dev/null and b/tools/ido_recomp/linux/7.1/as0 differ diff --git a/tools/ido_recomp/linux/7.1/as1 b/tools/ido_recomp/linux/7.1/as1 index 01dbc6f6b..475079063 100755 Binary files a/tools/ido_recomp/linux/7.1/as1 and b/tools/ido_recomp/linux/7.1/as1 differ diff --git a/tools/ido_recomp/linux/7.1/cc b/tools/ido_recomp/linux/7.1/cc index a7f06afa8..6c68698f3 100755 Binary files a/tools/ido_recomp/linux/7.1/cc and b/tools/ido_recomp/linux/7.1/cc differ diff --git a/tools/ido_recomp/linux/7.1/cfe b/tools/ido_recomp/linux/7.1/cfe index 2c6767e69..2b52669de 100755 Binary files a/tools/ido_recomp/linux/7.1/cfe and b/tools/ido_recomp/linux/7.1/cfe differ diff --git a/tools/ido_recomp/linux/7.1/err.english.cc b/tools/ido_recomp/linux/7.1/err.english.cc old mode 100755 new mode 100644 diff --git a/tools/ido_recomp/linux/7.1/ugen b/tools/ido_recomp/linux/7.1/ugen index f5c1a2e20..340a282c9 100755 Binary files a/tools/ido_recomp/linux/7.1/ugen and b/tools/ido_recomp/linux/7.1/ugen differ diff --git a/tools/ido_recomp/linux/7.1/ujoin b/tools/ido_recomp/linux/7.1/ujoin new file mode 100755 index 000000000..3752698d8 Binary files /dev/null and b/tools/ido_recomp/linux/7.1/ujoin differ diff --git a/tools/ido_recomp/linux/7.1/uld b/tools/ido_recomp/linux/7.1/uld new file mode 100755 index 000000000..2b76d0c18 Binary files /dev/null and b/tools/ido_recomp/linux/7.1/uld differ diff --git a/tools/ido_recomp/linux/7.1/umerge b/tools/ido_recomp/linux/7.1/umerge old mode 100644 new mode 100755 index b0c8c1778..03d68a8f2 Binary files a/tools/ido_recomp/linux/7.1/umerge and b/tools/ido_recomp/linux/7.1/umerge differ diff --git a/tools/ido_recomp/linux/7.1/uopt b/tools/ido_recomp/linux/7.1/uopt index ecf7eab72..feef7f749 100755 Binary files a/tools/ido_recomp/linux/7.1/uopt and b/tools/ido_recomp/linux/7.1/uopt differ diff --git a/tools/ido_recomp/linux/7.1/usplit b/tools/ido_recomp/linux/7.1/usplit new file mode 100755 index 000000000..090200ab5 Binary files /dev/null and b/tools/ido_recomp/linux/7.1/usplit differ diff --git a/tools/ido_recomp/macos/5.3/acpp b/tools/ido_recomp/macos/5.3/acpp deleted file mode 100755 index 043162770..000000000 Binary files a/tools/ido_recomp/macos/5.3/acpp and /dev/null differ diff --git a/tools/ido_recomp/macos/5.3/as0 b/tools/ido_recomp/macos/5.3/as0 index 9cff1dcd7..46e69e09b 100755 Binary files a/tools/ido_recomp/macos/5.3/as0 and b/tools/ido_recomp/macos/5.3/as0 differ diff --git a/tools/ido_recomp/macos/5.3/as1 b/tools/ido_recomp/macos/5.3/as1 index df0142e86..f723cc5c1 100755 Binary files a/tools/ido_recomp/macos/5.3/as1 and b/tools/ido_recomp/macos/5.3/as1 differ diff --git a/tools/ido_recomp/macos/5.3/cc b/tools/ido_recomp/macos/5.3/cc index e9b599bda..d583c6b5b 100755 Binary files a/tools/ido_recomp/macos/5.3/cc and b/tools/ido_recomp/macos/5.3/cc differ diff --git a/tools/ido_recomp/macos/5.3/cfe b/tools/ido_recomp/macos/5.3/cfe index 30e514947..92f76465a 100755 Binary files a/tools/ido_recomp/macos/5.3/cfe and b/tools/ido_recomp/macos/5.3/cfe differ diff --git a/tools/ido_recomp/macos/5.3/copt b/tools/ido_recomp/macos/5.3/copt deleted file mode 100755 index 243c37a29..000000000 Binary files a/tools/ido_recomp/macos/5.3/copt and /dev/null differ diff --git a/tools/ido_recomp/macos/5.3/ugen b/tools/ido_recomp/macos/5.3/ugen index 7f18bf44b..7be477312 100755 Binary files a/tools/ido_recomp/macos/5.3/ugen and b/tools/ido_recomp/macos/5.3/ugen differ diff --git a/tools/ido_recomp/macos/5.3/ujoin b/tools/ido_recomp/macos/5.3/ujoin index 30503f95d..e69611f41 100755 Binary files a/tools/ido_recomp/macos/5.3/ujoin and b/tools/ido_recomp/macos/5.3/ujoin differ diff --git a/tools/ido_recomp/macos/5.3/uld b/tools/ido_recomp/macos/5.3/uld index 13aa261f5..2bcce1cd6 100755 Binary files a/tools/ido_recomp/macos/5.3/uld and b/tools/ido_recomp/macos/5.3/uld differ diff --git a/tools/ido_recomp/macos/5.3/umerge b/tools/ido_recomp/macos/5.3/umerge index c31c866d5..7fdf06e8d 100755 Binary files a/tools/ido_recomp/macos/5.3/umerge and b/tools/ido_recomp/macos/5.3/umerge differ diff --git a/tools/ido_recomp/macos/5.3/uopt b/tools/ido_recomp/macos/5.3/uopt index 7bbaac298..e9b8cbe62 100755 Binary files a/tools/ido_recomp/macos/5.3/uopt and b/tools/ido_recomp/macos/5.3/uopt differ diff --git a/tools/ido_recomp/macos/5.3/usplit b/tools/ido_recomp/macos/5.3/usplit index a95984803..cb28e320c 100755 Binary files a/tools/ido_recomp/macos/5.3/usplit and b/tools/ido_recomp/macos/5.3/usplit differ diff --git a/tools/ido_recomp/macos/7.1/as0 b/tools/ido_recomp/macos/7.1/as0 new file mode 100755 index 000000000..cdb4f9121 Binary files /dev/null and b/tools/ido_recomp/macos/7.1/as0 differ diff --git a/tools/ido_recomp/macos/7.1/as1 b/tools/ido_recomp/macos/7.1/as1 index 88b9f1f7e..93370b495 100755 Binary files a/tools/ido_recomp/macos/7.1/as1 and b/tools/ido_recomp/macos/7.1/as1 differ diff --git a/tools/ido_recomp/macos/7.1/cc b/tools/ido_recomp/macos/7.1/cc index ae54cdbcd..96d45690b 100755 Binary files a/tools/ido_recomp/macos/7.1/cc and b/tools/ido_recomp/macos/7.1/cc differ diff --git a/tools/ido_recomp/macos/7.1/cfe b/tools/ido_recomp/macos/7.1/cfe index 6c468c336..a9f0b56fc 100755 Binary files a/tools/ido_recomp/macos/7.1/cfe and b/tools/ido_recomp/macos/7.1/cfe differ diff --git a/tools/ido_recomp/macos/7.1/ugen b/tools/ido_recomp/macos/7.1/ugen index 3fa7d48fc..801337b48 100755 Binary files a/tools/ido_recomp/macos/7.1/ugen and b/tools/ido_recomp/macos/7.1/ugen differ diff --git a/tools/ido_recomp/macos/7.1/ujoin b/tools/ido_recomp/macos/7.1/ujoin new file mode 100755 index 000000000..620e624f0 Binary files /dev/null and b/tools/ido_recomp/macos/7.1/ujoin differ diff --git a/tools/ido_recomp/macos/7.1/uld b/tools/ido_recomp/macos/7.1/uld new file mode 100755 index 000000000..a7826480f Binary files /dev/null and b/tools/ido_recomp/macos/7.1/uld differ diff --git a/tools/ido_recomp/macos/7.1/umerge b/tools/ido_recomp/macos/7.1/umerge index 3a9d5440c..0f1978051 100755 Binary files a/tools/ido_recomp/macos/7.1/umerge and b/tools/ido_recomp/macos/7.1/umerge differ diff --git a/tools/ido_recomp/macos/7.1/uopt b/tools/ido_recomp/macos/7.1/uopt index b025fa2c5..528151499 100755 Binary files a/tools/ido_recomp/macos/7.1/uopt and b/tools/ido_recomp/macos/7.1/uopt differ diff --git a/tools/ido_recomp/macos/7.1/usplit b/tools/ido_recomp/macos/7.1/usplit new file mode 100755 index 000000000..cc539bdb1 Binary files /dev/null and b/tools/ido_recomp/macos/7.1/usplit differ diff --git a/tools/ido_recomp/windows/5.3/as0.exe b/tools/ido_recomp/windows/5.3/as0.exe new file mode 100755 index 000000000..10c16ca69 Binary files /dev/null and b/tools/ido_recomp/windows/5.3/as0.exe differ diff --git a/tools/ido_recomp/windows/5.3/as1.exe b/tools/ido_recomp/windows/5.3/as1.exe index fb67bb8b5..0ddac02bb 100755 Binary files a/tools/ido_recomp/windows/5.3/as1.exe and b/tools/ido_recomp/windows/5.3/as1.exe differ diff --git a/tools/ido_recomp/windows/5.3/cc.exe b/tools/ido_recomp/windows/5.3/cc.exe index 402d6f489..fdbaea21d 100755 Binary files a/tools/ido_recomp/windows/5.3/cc.exe and b/tools/ido_recomp/windows/5.3/cc.exe differ diff --git a/tools/ido_recomp/windows/5.3/cfe.exe b/tools/ido_recomp/windows/5.3/cfe.exe index 4b2fa59de..abe1063c6 100755 Binary files a/tools/ido_recomp/windows/5.3/cfe.exe and b/tools/ido_recomp/windows/5.3/cfe.exe differ diff --git a/tools/ido_recomp/windows/5.3/err.english.cc b/tools/ido_recomp/windows/5.3/err.english.cc old mode 100755 new mode 100644 diff --git a/tools/ido_recomp/windows/5.3/ugen.exe b/tools/ido_recomp/windows/5.3/ugen.exe index f74ee0d9e..be08a43c9 100755 Binary files a/tools/ido_recomp/windows/5.3/ugen.exe and b/tools/ido_recomp/windows/5.3/ugen.exe differ diff --git a/tools/ido_recomp/windows/5.3/ujoin.exe b/tools/ido_recomp/windows/5.3/ujoin.exe new file mode 100755 index 000000000..b01b5c335 Binary files /dev/null and b/tools/ido_recomp/windows/5.3/ujoin.exe differ diff --git a/tools/ido_recomp/windows/5.3/uld.exe b/tools/ido_recomp/windows/5.3/uld.exe new file mode 100755 index 000000000..34cad1400 Binary files /dev/null and b/tools/ido_recomp/windows/5.3/uld.exe differ diff --git a/tools/ido_recomp/windows/5.3/umerge.exe b/tools/ido_recomp/windows/5.3/umerge.exe new file mode 100755 index 000000000..3ce31e0cb Binary files /dev/null and b/tools/ido_recomp/windows/5.3/umerge.exe differ diff --git a/tools/ido_recomp/windows/5.3/uopt.exe b/tools/ido_recomp/windows/5.3/uopt.exe index 274d7e008..c1fb98c0d 100755 Binary files a/tools/ido_recomp/windows/5.3/uopt.exe and b/tools/ido_recomp/windows/5.3/uopt.exe differ diff --git a/tools/ido_recomp/windows/5.3/usplit.exe b/tools/ido_recomp/windows/5.3/usplit.exe new file mode 100755 index 000000000..d179f1e13 Binary files /dev/null and b/tools/ido_recomp/windows/5.3/usplit.exe differ diff --git a/tools/ido_recomp/windows/7.1/as0.exe b/tools/ido_recomp/windows/7.1/as0.exe new file mode 100755 index 000000000..1a375d73e Binary files /dev/null and b/tools/ido_recomp/windows/7.1/as0.exe differ diff --git a/tools/ido_recomp/windows/7.1/as1.exe b/tools/ido_recomp/windows/7.1/as1.exe index b41eba841..4778d2db6 100755 Binary files a/tools/ido_recomp/windows/7.1/as1.exe and b/tools/ido_recomp/windows/7.1/as1.exe differ diff --git a/tools/ido_recomp/windows/7.1/cc.exe b/tools/ido_recomp/windows/7.1/cc.exe index 1ada0d5bb..887b7cc49 100755 Binary files a/tools/ido_recomp/windows/7.1/cc.exe and b/tools/ido_recomp/windows/7.1/cc.exe differ diff --git a/tools/ido_recomp/windows/7.1/cfe.exe b/tools/ido_recomp/windows/7.1/cfe.exe index 03f8fc7e8..6f5fd9e8d 100755 Binary files a/tools/ido_recomp/windows/7.1/cfe.exe and b/tools/ido_recomp/windows/7.1/cfe.exe differ diff --git a/tools/ido_recomp/windows/7.1/err.english.cc b/tools/ido_recomp/windows/7.1/err.english.cc old mode 100755 new mode 100644 diff --git a/tools/ido_recomp/windows/7.1/ugen.exe b/tools/ido_recomp/windows/7.1/ugen.exe index e6533ab0b..fcc03538c 100755 Binary files a/tools/ido_recomp/windows/7.1/ugen.exe and b/tools/ido_recomp/windows/7.1/ugen.exe differ diff --git a/tools/ido_recomp/windows/7.1/ujoin.exe b/tools/ido_recomp/windows/7.1/ujoin.exe new file mode 100755 index 000000000..9fb3a3f4f Binary files /dev/null and b/tools/ido_recomp/windows/7.1/ujoin.exe differ diff --git a/tools/ido_recomp/windows/7.1/uld.exe b/tools/ido_recomp/windows/7.1/uld.exe new file mode 100755 index 000000000..4a0cc8fe2 Binary files /dev/null and b/tools/ido_recomp/windows/7.1/uld.exe differ diff --git a/tools/ido_recomp/windows/7.1/umerge.exe b/tools/ido_recomp/windows/7.1/umerge.exe new file mode 100755 index 000000000..7cc0b1be6 Binary files /dev/null and b/tools/ido_recomp/windows/7.1/umerge.exe differ diff --git a/tools/ido_recomp/windows/7.1/uopt.exe b/tools/ido_recomp/windows/7.1/uopt.exe index 5033f72b1..4fbd1ab57 100755 Binary files a/tools/ido_recomp/windows/7.1/uopt.exe and b/tools/ido_recomp/windows/7.1/uopt.exe differ diff --git a/tools/ido_recomp/windows/7.1/usplit.exe b/tools/ido_recomp/windows/7.1/usplit.exe new file mode 100755 index 000000000..5c0da6fe6 Binary files /dev/null and b/tools/ido_recomp/windows/7.1/usplit.exe differ diff --git a/tools/namefixer.py b/tools/namefixer.py index 1d6c89a7b..198116315 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -5,10 +5,7 @@ import argparse # all occurrences of keys will be replaced by associated value simpleReplace = { - # "Math_Rand_":"Rand_", - # "ACTORTYPE":"ACTORCAT", - # "DistToLink":"DistToPlayer", - # "HitItem":"HitInfo", + "PLAYER_AP_": "PLAYER_IA_", } # all occurrences of keys will be replaced by associated value, @@ -19,10 +16,13 @@ simpleReplace = { # 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", + "Math_FAtan2F(": "Math_Atan2S_XY(", + "Math_Acot2F": "Math_Atan2F_XY", + "atan_flip": "Math_Atan2F_XY", "atans": "Math_Atan2S", - + # "SysMatrix_StateAlloc": "Matrix_StateAlloc", # "SysMatrix_StatePush": "Matrix_StatePush", # "SysMatrix_StatePop": "Matrix_StatePop", @@ -97,8 +97,15 @@ wordReplace = { "Matrix_InsertRotationAroundUnitVector_s": "Matrix_RotateAxisS", "func_800B78B8": "Actor_UpdateBgCheckInfo", + "func_80123D50": "Player_UpdateBottleHeld", "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", @@ -107,6 +114,7 @@ wordReplace = { "Actor_IsActorFacingActorAndWithinRange": "Actor_ActorAIsFacingAndNearActorB", "Actor_IsActorFacingActor": "Actor_ActorAIsFacingActorB", "Actor_IsActorFacedByActor": "Actor_ActorBIsFacingActorA", + "Actor_MarkForDeath": "Actor_Kill", "func_800B84D0": "Actor_ProcessTalkRequest", "func_8017D668": "Math3D_PointDistToLine2D", "func_800BDFC0": "Gfx_DrawDListOpa", @@ -131,13 +139,30 @@ wordReplace = { "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", + "func_801A5BD0": "AudioSfx_MuteBanks", + "func_801A72CC": "AudioSfx_StopByPos", + "Audio_StopSfxByPos": "AudioSfx_StopByPos", + "Audio_StopSfxById": "AudioSfx_StopById", + "func_801A3098": "Audio_PlayFanfare", + "func_801A8A50": "Audio_GetActiveSequence", + "func_801A2E54": "Audio_PlayBgm_StorePrevBgm", + "func_801A2ED8": "Audio_RestorePrevBgm", + "func_801A2544": "Audio_PlayMorningSceneSequence", + "func_801A25E4": "Audio_PlaySceneSequence", + "func_801A3238": "Audio_PlaySequenceWithSeqPlayerIO", + "func_801A32CC": "Audio_SetSequenceMode", + "func_801A3590": "Audio_UpdateEnemyBgmVolume", + "func_801A47DC": "Audio_SetAmbienceChannelIO", + "func_801A4A28": "Audio_PlayAmbience", + "func_801A7328": "AudioSfx_StopByPosAndId", + "func_801A75E8": "AudioSfx_StopById", "SkelAnime_LodDrawLimb": "SkelAnime_DrawLimbLod", "SkelAnime_LodDraw": "SkelAnime_DrawLod", "SkelAnime_LodDrawLimbSV": "SkelAnime_DrawFlexLimbLod", @@ -248,7 +273,8 @@ wordReplace = { "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", @@ -270,6 +296,9 @@ wordReplace = { "Actor_IsFacingPlayerAndWithinRange": "Actor_IsFacingAndNearPlayer", "func_800BC8B8": "Actor_DrawDoorLock", "func_800B86C8": "Actor_ChangeFocus", + "func_800B90F4": "Actor_DeactivateLens", + "func_800BC770": "Actor_AddQuake", + "func_800DF840": "Camera_ChangeMode", "zelda_malloc": "ZeldaArena_Malloc", "zelda_mallocR": "ZeldaArena_MallocR", "zelda_realloc": "ZeldaArena_Realloc", @@ -386,8 +415,9 @@ wordReplace = { "BgCheck_RelocateMeshHeader": "CollisionHeader_GetVirtual", "BgCheck_RelocateAllMeshHeaders": "BgCheck_InitCollisionHeaders", "BgCheck_GetPolygonAttributes": "SurfaceType_GetData", - "func_800C9704": "SurfaceType_GetCamDataIndex", - "func_800C9924": "SurfaceType_GetCamPosData", + "SurfaceType_GetConveyorType": "SurfaceType_IsFloorConveyor", + "func_800C9704": "SurfaceType_GetBgCamIndex", + "func_800C9924": "BgCheck_GetBgCamFuncData", "func_800C99AC": "SurfaceType_GetSceneExitIndex", "func_800C9B90": "SurfaceType_IsHorseBlocked", "func_800C9BDC": "SurfaceType_GetSfx", @@ -397,7 +427,7 @@ wordReplace = { "func_800C9CEC": "SurfaceType_IsHookshotSurface", "func_800C9D14": "SurfaceType_IsIgnoredByEntities", "func_800C9D50": "SurfaceType_IsIgnoredByProjectiles", - "func_800C9D8C": "SurfaceType_GetConveyorType", + "func_800C9D8C": "SurfaceType_IsFloorConveyor", "func_800C9E18": "SurfaceType_GetConveyorSpeed", "func_800C9E40": "SurfaceType_GetConveyorDirection", "func_800C9E88": "SurfaceType_IsWallDamage", @@ -438,29 +468,72 @@ wordReplace = { "func_800E0308": "Camera_SetTargetActor", "func_800E031C": "Camera_GetWaterYPos", "func_800E02AC": "Camera_SetToTrackActor", + "func_800DFAC8": "Camera_ChangeSetting", + "func_800DFC90": "Camera_GetCamDir", + "func_800DFD04": "Camera_AddQuake", + "func_800DFFAC": "Camera_ChangeDoorCam", "func_801694DC": "Play_CreateSubCamera", "Play_GetActiveCameraIndex": "Play_GetActiveCamId", - "func_80169590": "Play_CameraChangeStatus", + "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_801129E4": "Interface_SetSceneRestrictions", + "func_8011B4E0": "Interface_SetPerfectLetters", + "func_80112AFC": "Interface_InitMinigame", + "func_8010E9F0": "Interface_StartTimer", + "func_8010EA9C": "Interface_StartPostmanTimer", + "func_80121F94": "Interface_Destroy", + "Interface_ChangeAlpha": "Interface_SetHudVisibility", + "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", + "Parameter_AddMagic": "Magic_Add", + "func_80115D5C": "Magic_Reset", + "func_80115DB4": "Magic_Consume", + "func_8013EC44": "Rumble_Override", + "func_8013ECE0": "Rumble_Request", "func_8017D2FC": "Math3D_LineSegVsPlane", "func_800A81F0": "EffectBlure_AddVertex", "func_800A8514": "EffectBlure_AddSpace", "Effect_GetParams": "Effect_GetByIndex", + "func_800FE484": "Environment_StopTime", + "func_800FE498": "Environment_StartTime", + "func_800FE4A8": "Environment_IsTimeStopped", "func_800F5A8C": "Environment_LerpWeight", "func_801A3F54": "Audio_SetCutsceneFlag", "func_800EA0D4": "Cutscene_Start", @@ -469,20 +542,22 @@ wordReplace = { "func_800EDF24": "Cutscene_ActorTranslateAndYaw", "func_800EDF78": "Cutscene_ActorTranslateAndYawSmooth", "func_800EE0CC": "Cutscene_ActorTranslateXZAndYawSmooth", - "func_800EE1D8": "Cutscene_GetSceneSetupIndex", + "func_800EE1D8": "Cutscene_GetSceneLayer", "func_800EE200": "Cutscene_GetActorActionIndex", "func_800EE29C": "Cutscene_CheckActorAction", "func_800EE2F4": "Cutscene_IsPlaying", + "Cutscene_GetSceneSetupIndex": "Cutscene_GetSceneLayer", "func_801343C0": "SkelAnime_DrawTransformFlexOpa", "func_80134148": "SkelAnime_DrawTransformFlexLimbOpa", - "func_80114E90": "Interface_HasEmptyBottle", - "func_80114F2C": "Interface_HasItemInBottle", + "func_80114E90": "Inventory_HasEmptyBottle", + "func_80114F2C": "Inventory_HasItemInBottle", "func_80123C90": "Player_SetEquipmentData", "Quake2_ClearType": "Distortion_ClearType", "Quake2_SetType": "Distortion_SetType", "Quake2_SetCountdown": "Distortion_SetCountdown", "func_800BE680": "Actor_DrawDamageEffects", "func_8012F22C": "Inventory_GetSkullTokenCount", + "Quake_RemoveFromIdx": "Quake_Remove", "func_8013AB00": "SubS_DrawTransformFlex", "func_8013A860": "SubS_DrawTransformFlexLimb", @@ -531,7 +606,7 @@ wordReplace = { "func_80158C04": "Message_LoadLocalizedRupeesNES", "func_80158D98": "Message_LoadRupeesNES", "func_80158FB0": "Message_LoadTimeNES", - "func_8015926C": "Message_LoadAreaTextNES", + "func_8015926C": "Message_LoadOwlWarpTextNES", "func_8015E750": "Message_FindCreditsMessage", "func_80133038": "Schedule_RunScript", @@ -539,6 +614,44 @@ wordReplace = { "EffectSsKiraKira_SpawnSmall": "EffectSsKirakira_SpawnSmall", "EffectSsKiraKira_SpawnDispersed": "EffectSsKirakira_SpawnDispersed", "EffectSsKiraKira_SpawnFocused": "EffectSsKirakira_SpawnFocused", + "Effect_Getplay": "Effect_GetPlayState", + "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_800B90F4": "Actor_DeactivateLens", + + "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", @@ -557,27 +670,33 @@ wordReplace = { "skelAnime.prevFrameRot": "skelAnime.prevRot", "skelAnime.prevFramePos": "skelAnime.prevTransl", "skelAnime.unk3E": "skelAnime.baseTransl", - "actor.minVelocityY": "actor.terminalVelocity", "actor.yDistToWater": "actor.depthInWater", "actor.yDistToPlayer": "actor.playerHeightRel", + "gSaveContext.unk_3F1E": "gSaveContext.hudVisibilityForceButtonAlphasByStatus", + "gSaveContext.unk_3F20": "gSaveContext.nextHudVisibility", + "gSaveContext.unk_3F22": "gSaveContext.hudVisibility", + "gSaveContext.unk_3F24": "gSaveContext.hudVisibilityTimer", + "gSaveContext.unk_3F26": "gSaveContext.prevHudVisibility", "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", - "gSaveContext.magicAcquired": "gSaveContext.save.playerData.magicAcquired", - "gSaveContext.doubleMagic": "gSaveContext.save.playerData.doubleMagic", + "gSaveContext.magicAcquired": "gSaveContext.save.playerData.isMagicAcquired", + "gSaveContext.doubleMagic": "gSaveContext.save.playerData.isDoubleMagicAcquired", "gSaveContext.doubleDefense": "gSaveContext.save.playerData.doubleDefense", "gSaveContext.playerName": "gSaveContext.save.playerData.playerName", "gSaveContext.inventory": "gSaveContext.save.inventory", "gSaveContext.equippedMask": "gSaveContext.save.equippedMask", - "gSaveContext.entranceIndex": "gSaveContext.save.entranceIndex", + "gSaveContext.entranceIndex": "gSaveContext.save.entrance", "gSaveContext.time": "gSaveContext.save.time", - "gSaveContext.unk_14": "gSaveContext.save.daySpeed", + "gSaveContext.save.daySpeed": "gSaveContext.save.timeSpeedOffset", + "gSaveContext.unk_14": "gSaveContext.save.timeSpeedOffset", "gSaveContext.unk_FE6": "gSaveContext.save.bombersCaughtNum", "gSaveContext.unk_FE7": "gSaveContext.save.bombersCaughtOrder", "gSaveContext.linkAge": "gSaveContext.save.linkAge", @@ -588,8 +707,22 @@ wordReplace = { "gSaveContext.skullTokenCount": "gSaveContext.save.skullTokenCount", "gSaveContext.cutscene": "gSaveContext.save.cutscene", "gSaveContext.health": "gSaveContext.save.playerData.health", + "gSaveContext.equips": "gSaveContext.save.equips", "gSaveContext.unk_1016": "gSaveContext.jinxTimer", "gSaveContext.unk_3F58": "gSaveContext.sunsSongState", + "gSaveContext.equips.buttonItems": "gSaveContext.save.equips.buttonItems", + "gSaveContext.unk_48C8": "gSaveContext.dungeonIndex", + "gSaveContext.save.playerData.magicAcquired": "gSaveContext.save.playerData.isMagicAcquired", + "gSaveContext.save.playerDatadoubleMagic": "gSaveContext.save.playerData.isDoubleMagicAcquired", + "gSaveContext.unk_3F28": "gSaveContext.magicState", + "gSaveContext.unk_3F30": "gSaveContext.magicFillTarget", + "gSaveContext.unk_3F2C": "gSaveContext.magicFlag", + "gSaveContext.save.entranceIndex": "gSaveContext.save.entrance", + "gSaveContext.sceneSetupIndex": "gSaveContext.sceneLayer", + "gSaveContext.seqIndex": "gSaveContext.seqId", + "gSaveContext.nightSeqIndex": "gSaveContext.ambienceId", + "gSaveContext.minigameState": "gSaveContext.minigameStatus", + "gSaveContext.unk_3F3C": "gSaveContext.minigameHiddenScore", "player->unk_A87": "player->exchangeItemId", "player->leftHandActor": "player->heldActor", @@ -598,35 +731,80 @@ wordReplace = { "player->unk_388": "player->interactRangeActor", "player->unk_38C": "player->mountSide", "player->unk_394": "player->csMode", + "player->swordQuads": "player->meleeWeaponQuads", + "player->blureEffectIndex": "player->meleeWeaponEffectIndex", + "player->unk_AD8": "player->underwaterTimer", + "player->swordAnimation": "player->meleeWeaponAnimation", + "player->swordState": "player->meleeWeaponState", + "player->swordInfo": "player->meleeWeaponInfo", + "player->itemActionParam": "player->heldItemAction", + "player->heldItemActionParam": "player->itemAction", + "player->unk_A9C": "player->secretRumbleCharge", + "player->unk_AA0": "player->closestSecretDistSq", + "player->unk_B68": "player->fallStartHeight", + "player->unk_B6A": "player->fallDistance", + "player->targetActor": "player->talkActor", + "player->targetActorDistance": "player->talkActorDistance", + "player->unk_730": "player->targetedActor", + "player->ageProperties->unk_92": "player->ageProperties->voiceSfxIdOffset", + "player->ageProperties->unk_94": "player->ageProperties->surfaceSfxIdOffset", + "csCtx.npcActions": "csCtx.actorActions", "csCtx->npcActions": "csCtx->actorActions", "csCtx.unk_12": "csCtx.currentCsIndex", - "globalCtx->mf_187FC": "globalCtx->billboardMtxF", - "globalCtx->projectionMatrix": "globalCtx->viewProjectionMtxF", - "globalCtx->actorCtx.actorList[": "globalCtx->actorCtx.actorLists[", - "globalCtx->envCtx.unk_8C": "globalCtx->envCtx.lightSettings", - "globalCtx->envCtx.unk_E5": "globalCtx->envCtx.fillScreen", - "globalCtx->envCtx.unk_E6": "globalCtx->envCtx.screenFillColor", - "globalCtx->envCtx.unk_C3": "globalCtx->envCtx.lightSettingOverride", - "globalCtx->envCtx.unk_DC": "globalCtx->envCtx.lightBlend", + "globalCtx->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->interfaceCtx.unk_31A": "play->interfaceCtx.storyState", + "play->interfaceCtx.unk_31B": "play->interfaceCtx.storyType", + "play->interfaceCtx.unk_25C": "play->interfaceCtx.minigamePoints", + "play->interfaceCtx.unk_25E": "play->interfaceCtx.minigameHiddenPoints", + "play->interfaceCtx.unk_280": "play->interfaceCtx.minigameState", + "play->interfaceCtx.unk_286": "play->interfaceCtx.perfectLettersOn", + "play->interfaceCtx.hbaAmmo": "play->interfaceCtx.minigameAmmo", - "globalCtx->msgCtx.unk1202A": "globalCtx->msgCtx.ocarinaMode", - "globalCtx->msgCtx.unk1202C": "globalCtx->msgCtx.ocarinaAction", - "globalCtx->msgCtx.unk11F22": "globalCtx->msgCtx.msgMode", - "globalCtx->msgCtx.unk11F04": "globalCtx->msgCtx.currentTextId", + # "play->actorCtx.flags": "play->actorCtx.sceneFlags", + # "play->actorCtx.unk5": "play->actorCtx.flags", + "play->msgCtx.unk11F04": "play->msgCtx.currentTextId", + "play->msgCtx.unk11F10": "play->msgCtx.msgLength", + "play->msgCtx.unk11F22": "play->msgCtx.msgMode", + "play->msgCtx.unk12023": "play->msgCtx.stateTimer", + "play->msgCtx.unk1202A": "play->msgCtx.ocarinaMode", + "play->msgCtx.unk1202C": "play->msgCtx.ocarinaAction", + "play->msgCtx.unk11F04": "play->msgCtx.currentTextId", + "play->actorCtx.unk3": "play->actorCtx.lensActive", + "play->actorCtx.unk4": "play->actorCtx.lensMaskSize", + "play->nextEntranceIndex": "play->nextEntrance", + "play->sceneNum": "play->sceneId", + "play->pauseCtx.unk_1F0": "play->pauseCtx.bombersNotebookOpen", - "D_801D15B0" : "gZeroVec3f", - "D_801D15BC" : "gZeroVec3s", - "D_801D1DE0" : "gIdentityMtx", - "D_801D1E20" : "gIdentityMtxF", - "D_04020658" : "gameplay_keep_Anim_020658", - "D_04022B28" : "gDoorSkel", - "D_04023100" : "gDoorCol", + "gSaveContext.unk_3DC8": "gSaveContext.timerOsTime", + "gSaveContext.unk_3DD0": "gSaveContext.timerStates", + "gSaveContext.unk_3DD7": "gSaveContext.timerDirections", + "gSaveContext.unk_3DE0": "gSaveContext.timerCurTimes", + "gSaveContext.unk_3E18": "gSaveContext.timerTimeLimits", + "gSaveContext.unk_3E50": "gSaveContext.timerStartOsTimes", + "gSaveContext.unk_3E88": "gSaveContext.timerStopTimes", + "gSaveContext.unk_3EC0": "gSaveContext.timerPausedOsTimes", - # Structs - "ActorAnimationEntry": "AnimationInfo", - "ActorAnimationEntryS": "AnimationInfoS", - "struct_80B8E1A8": "AnimationSpeedInfo", + "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", + "D_801D1DE0": "gIdentityMtx", + "D_801D1E20": "gIdentityMtxF", # Macros "CUR_EQUIP_VALUE_VOID": "GET_CUR_EQUIP_VALUE", @@ -634,8 +812,26 @@ wordReplace = { "ICHAIN_F32_DIV1000(minVelocityY,": "ICHAIN_F32_DIV1000(terminalVelocity,", "ICHAIN_F32(minVelocityY,": "ICHAIN_F32(terminalVelocity,", + "ACTORCTX_FLAG_2": "ACTORCTX_FLAG_PICTO_BOX_ON", + + "EXCH_ITEM_MINUS1": "PLAYER_IA_MINUS1", + "EXCH_ITEM_NONE": "PLAYER_IA_NONE", + "EXCH_ITEM_PICTO_BOX": "PLAYER_IA_PICTO_BOX", + "EXCH_ITEM_1E": "PLAYER_IA_BOTTLE_MUSHROOM", + "EXCH_ITEM_MOON_TEAR": "PLAYER_IA_MOON_TEAR", + "EXCH_ITEM_DEED_LAND": "PLAYER_IA_DEED_LAND", + "EXCH_ITEM_ROOM_KEY": "PLAYER_IA_ROOM_KEY", + "EXCH_ITEM_LETTER_TO_KAFEI": "PLAYER_IA_LETTER_TO_KAFEI", + "EXCH_ITEM_2E": "PLAYER_IA_MAGIC_BEANS", + "EXCH_ITEM_DEED_SWAMP": "PLAYER_IA_DEED_SWAMP", + "EXCH_ITEM_DEED_MOUNTAIN": "PLAYER_IA_DEED_MOUNTAIN", + "EXCH_ITEM_DEED_OCEAN": "PLAYER_IA_DEED_OCEAN", + "EXCH_ITEM_LETTER_MAMA": "PLAYER_IA_LETTER_MAMA", + "ITEM_FISHING_POLE": "ITEM_FISHING_ROD", + "PLAYER_AP_FISHING_POLE": "PLAYER_IA_FISHING_ROD", + # Example of custom behaviour: - # "PLAYER": ("GET_PLAYER(globalCtx)", {"ignore": (-1, '"PLAYER"')}), # ignore "PLAYER" in sSoundBankNames + # "PLAYER": ("GET_PLAYER(play)", {"ignore": (-1, '"PLAYER"')}), # ignore "PLAYER" in sSoundBankNames } # [a-zA-Z0-9_] diff --git a/tools/overlayhelpers/scheduledis.py b/tools/overlayhelpers/scheduledis.py index b441b94c7..5eb70d518 100755 --- a/tools/overlayhelpers/scheduledis.py +++ b/tools/overlayhelpers/scheduledis.py @@ -7,8 +7,8 @@ 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_FLAG_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_FLAG_L', 0x05, '>Hh', (1, )), ('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', ( )), @@ -198,6 +198,8 @@ def disassemble_unk_script(data_file, offset): elif arg_type == "H": if (cmd == 0x0A or cmd == 0x0B) and (arg_value < len(scene_names)): arg_formatted = scene_names[arg_value] + elif cmd == 0x00 or cmd == 0x01: + arg_formatted = f"WEEKEVENTREG_{arg_value>>8:02}_{arg_value&0xFF:02X}" else: arg_formatted = f"{arg_value}" elif arg_type == "B": diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index 2676d13ee..691913cdc 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -1,3 +1,5 @@ +compiler_type = "ido" + [preserve_macros] "g[DS]P.*" = "void" "gs[DS]P.*" = "void" @@ -9,12 +11,26 @@ 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" CHECK_NEWF = "int" NULL = "int" +GET_PLAYER = "int" +CHECK_WEEKEVENTREG = "int" +SET_WEEKEVENTREG = "int" +CLEAR_WEEKEVENTREG = "int" +"WEEKEVENTREG_.+" = "int" +CHECK_EVENTINF = "int" +SET_EVENTINF = "int" +CLEAR_EVENTINF = "int" +CLEAR_EVENTINF_ALT = "int" +"EVENTINF_.*" = "int" +".+REG" = "int" [decompme.compilers] "tools/ido_recomp/linux/7.1/cc" = "ido7.1" diff --git a/tools/sizes/boot_functions.csv b/tools/sizes/boot_functions.csv index a86be3b83..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 diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 5b7c0d71d..afb03d3b7 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1,7 +1,7 @@ asm/non_matchings/code/z_en_a_keep/EnAObj_Init.s,EnAObj_Init,0x800A5AC0,0x2B asm/non_matchings/code/z_en_a_keep/EnAObj_Destroy.s,EnAObj_Destroy,0x800A5B6C,0xB -asm/non_matchings/code/z_en_a_keep/EnAObj_Update1.s,EnAObj_Update1,0x800A5B98,0x24 -asm/non_matchings/code/z_en_a_keep/EnAObj_Update2.s,EnAObj_Update2,0x800A5C28,0xE +asm/non_matchings/code/z_en_a_keep/EnAObj_Idle.s,EnAObj_Idle,0x800A5B98,0x24 +asm/non_matchings/code/z_en_a_keep/EnAObj_Talk.s,EnAObj_Talk,0x800A5C28,0xE asm/non_matchings/code/z_en_a_keep/EnAObj_Update.s,EnAObj_Update,0x800A5C60,0x16 asm/non_matchings/code/z_en_a_keep/EnAObj_Draw.s,EnAObj_Draw,0x800A5CB8,0x12 asm/non_matchings/code/z_en_item00/EnItem00_SetObject.s,EnItem00_SetObject,0x800A5D00,0x1C @@ -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 @@ -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 @@ -217,7 +217,7 @@ asm/non_matchings/code/z_actor/func_800B64FC.s,func_800B64FC,0x800B64FC,0x22 asm/non_matchings/code/z_actor/func_800B6584.s,func_800B6584,0x800B6584,0x21 asm/non_matchings/code/z_actor/func_800B6608.s,func_800B6608,0x800B6608,0x1E asm/non_matchings/code/z_actor/func_800B6680.s,func_800B6680,0x800B6680,0x23 -asm/non_matchings/code/z_actor/Actor_MarkForDeath.s,Actor_MarkForDeath,0x800B670C,0x8 +asm/non_matchings/code/z_actor/Actor_Kill.s,Actor_Kill,0x800B670C,0x8 asm/non_matchings/code/z_actor/Actor_SetWorldToHome.s,Actor_SetWorldToHome,0x800B672C,0xC asm/non_matchings/code/z_actor/Actor_SetFocus.s,Actor_SetFocus,0x800B675C,0x11 asm/non_matchings/code/z_actor/Actor_SetWorldRotToShape.s,Actor_SetWorldRotToShape,0x800B67A0,0x8 @@ -268,7 +268,7 @@ asm/non_matchings/code/z_actor/Actor_IsFacingPlayer.s,Actor_IsFacingPlayer,0x800 asm/non_matchings/code/z_actor/Actor_ActorAIsFacingActorB.s,Actor_ActorAIsFacingActorB,0x800B742C,0x18 asm/non_matchings/code/z_actor/Actor_IsFacingAndNearPlayer.s,Actor_IsFacingAndNearPlayer,0x800B748C,0x20 asm/non_matchings/code/z_actor/Actor_ActorAIsFacingAndNearActorB.s,Actor_ActorAIsFacingAndNearActorB,0x800B750C,0x25 -asm/non_matchings/code/z_actor/func_800B75A0.s,func_800B75A0,0x800B75A0,0x1F +asm/non_matchings/code/z_actor/Actor_GetSlopeDirection.s,Actor_GetSlopeDirection,0x800B75A0,0x1F asm/non_matchings/code/z_actor/func_800B761C.s,func_800B761C,0x800B761C,0x17 asm/non_matchings/code/z_actor/func_800B7678.s,func_800B7678,0x800B7678,0x90 asm/non_matchings/code/z_actor/Actor_UpdateBgCheckInfo.s,Actor_UpdateBgCheckInfo,0x800B78B8,0x153 @@ -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 @@ -325,7 +325,7 @@ asm/non_matchings/code/z_actor/func_800B9038.s,func_800B9038,0x800B9038,0x13 asm/non_matchings/code/z_actor/func_800B9084.s,func_800B9084,0x800B9084,0x5 asm/non_matchings/code/z_actor/func_800B9098.s,func_800B9098,0x800B9098,0x5 asm/non_matchings/code/z_actor/func_800B90AC.s,func_800B90AC,0x800B90AC,0x12 -asm/non_matchings/code/z_actor/func_800B90F4.s,func_800B90F4,0x800B90F4,0xB +asm/non_matchings/code/z_actor/Actor_DeactivateLens.s,Actor_DeactivateLens,0x800B90F4,0xB asm/non_matchings/code/z_actor/func_800B9120.s,func_800B9120,0x800B9120,0x14 asm/non_matchings/code/z_actor/Actor_InitContext.s,Actor_InitContext,0x800B9170,0x71 asm/non_matchings/code/z_actor/Actor_SpawnSetupActors.s,Actor_SpawnSetupActors,0x800B9334,0x56 @@ -335,8 +335,8 @@ asm/non_matchings/code/z_actor/Actor_Draw.s,Actor_Draw,0x800B9A04,0xC6 asm/non_matchings/code/z_actor/func_800B9D1C.s,func_800B9D1C,0x800B9D1C,0x48 asm/non_matchings/code/z_actor/Actor_DrawAllSetup.s,Actor_DrawAllSetup,0x800B9E3C,0x4 asm/non_matchings/code/z_actor/Actor_RecordUndrawnActor.s,Actor_RecordUndrawnActor,0x800B9E4C,0xE -asm/non_matchings/code/z_actor/func_800B9E84.s,func_800B9E84,0x800B9E84,0x1C -asm/non_matchings/code/z_actor/func_800B9EF4.s,func_800B9EF4,0x800B9EF4,0xF9 +asm/non_matchings/code/z_actor/Actor_DrawLensOverlay.s,Actor_DrawLensOverlay,0x800B9E84,0x1C +asm/non_matchings/code/z_actor/Actor_DrawLensActors.s,Actor_DrawLensActors,0x800B9EF4,0xF9 asm/non_matchings/code/z_actor/func_800BA2D8.s,func_800BA2D8,0x800BA2D8,0x9 asm/non_matchings/code/z_actor/func_800BA2FC.s,func_800BA2FC,0x800BA2FC,0x4C asm/non_matchings/code/z_actor/Actor_DrawAll.s,Actor_DrawAll,0x800BA42C,0xB4 @@ -373,8 +373,8 @@ asm/non_matchings/code/z_actor/Actor_TestFloorInDirection.s,Actor_TestFloorInDir asm/non_matchings/code/z_actor/Actor_IsTargeted.s,Actor_IsTargeted,0x800BC5B8,0xD asm/non_matchings/code/z_actor/Actor_OtherIsTargeted.s,Actor_OtherIsTargeted,0x800BC5EC,0xD asm/non_matchings/code/z_actor/func_800BC620.s,func_800BC620,0x800BC620,0x54 -asm/non_matchings/code/z_actor/func_800BC770.s,func_800BC770,0x800BC770,0x1A -asm/non_matchings/code/z_actor/func_800BC7D8.s,func_800BC7D8,0x800BC7D8,0x1C +asm/non_matchings/code/z_actor/Actor_AddQuake.s,Actor_AddQuake,0x800BC770,0x1A +asm/non_matchings/code/z_actor/Actor_AddQuakeWithSpeed.s,Actor_AddQuakeWithSpeed,0x800BC7D8,0x1C asm/non_matchings/code/z_actor/func_800BC848.s,func_800BC848,0x800BC848,0x1C asm/non_matchings/code/z_actor/Actor_DrawDoorLock.s,Actor_DrawDoorLock,0x800BC8B8,0xA6 asm/non_matchings/code/z_actor/Actor_SpawnShieldParticlesMetal.s,Actor_SpawnShieldParticlesMetal,0x800BCB50,0x8 @@ -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 @@ -589,7 +589,7 @@ asm/non_matchings/code/z_bgcheck/SurfaceType_GetEcho.s,SurfaceType_GetEcho,0x800 asm/non_matchings/code/z_bgcheck/SurfaceType_IsHookshotSurface.s,SurfaceType_IsHookshotSurface,0x800C9CEC,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_IsIgnoredByEntities.s,SurfaceType_IsIgnoredByEntities,0x800C9D14,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_IsIgnoredByProjectiles.s,SurfaceType_IsIgnoredByProjectiles,0x800C9D50,0xF -asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorType.s,SurfaceType_GetConveyorType,0x800C9D8C,0x14 +asm/non_matchings/code/z_bgcheck/SurfaceType_IsFloorConveyor.s,SurfaceType_IsFloorConveyor,0x800C9D8C,0x14 asm/non_matchings/code/z_bgcheck/func_800C9DDC.s,func_800C9DDC,0x800C9DDC,0xF asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorSpeed.s,SurfaceType_GetConveyorSpeed,0x800C9E18,0xA asm/non_matchings/code/z_bgcheck/SurfaceType_GetConveyorDirection.s,SurfaceType_GetConveyorDirection,0x800C9E40,0x12 @@ -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 @@ -696,84 +696,84 @@ asm/non_matchings/code/z_camera/func_800CE930.s,func_800CE930,0x800CE930,0x6A asm/non_matchings/code/z_camera/func_800CEAD8.s,func_800CEAD8,0x800CEAD8,0x58 asm/non_matchings/code/z_camera/func_800CEC38.s,func_800CEC38,0x800CEC38,0x56 asm/non_matchings/code/z_camera/func_800CED90.s,func_800CED90,0x800CED90,0x185 -asm/non_matchings/code/z_camera/Camera_ModeNop.s,Camera_ModeNop,0x800CF3A4,0x4 -asm/non_matchings/code/z_camera/Camera_ModeNORM1.s,Camera_ModeNORM1,0x800CF3B4,0x530 -asm/non_matchings/code/z_camera/Camera_ModeNORM2.s,Camera_ModeNORM2,0x800D0874,0x8 -asm/non_matchings/code/z_camera/Camera_ModeNORM3.s,Camera_ModeNORM3,0x800D0894,0x265 -asm/non_matchings/code/z_camera/Camera_ModeNORM4.s,Camera_ModeNORM4,0x800D1228,0x24 -asm/non_matchings/code/z_camera/Camera_ModeNORM0.s,Camera_ModeNORM0,0x800D12B8,0x1F0 -asm/non_matchings/code/z_camera/Camera_ModePARA1.s,Camera_ModePARA1,0x800D1A78,0x40C -asm/non_matchings/code/z_camera/Camera_ModePARA2.s,Camera_ModePARA2,0x800D2AA8,0x8 -asm/non_matchings/code/z_camera/Camera_ModePARA3.s,Camera_ModePARA3,0x800D2AC8,0x8 -asm/non_matchings/code/z_camera/Camera_ModePARA4.s,Camera_ModePARA4,0x800D2AE8,0x8 -asm/non_matchings/code/z_camera/Camera_ModePARA0.s,Camera_ModePARA0,0x800D2B08,0x8 -asm/non_matchings/code/z_camera/Camera_ModeJUMP1.s,Camera_ModeJUMP1,0x800D2B28,0x8 -asm/non_matchings/code/z_camera/Camera_ModeJUMP2.s,Camera_ModeJUMP2,0x800D2B48,0x276 -asm/non_matchings/code/z_camera/Camera_ModeJUMP3.s,Camera_ModeJUMP3,0x800D3520,0x330 -asm/non_matchings/code/z_camera/Camera_ModeJUMP4.s,Camera_ModeJUMP4,0x800D41E0,0x8 -asm/non_matchings/code/z_camera/Camera_ModeJUMP0.s,Camera_ModeJUMP0,0x800D4200,0x8 -asm/non_matchings/code/z_camera/Camera_ModeBATT1.s,Camera_ModeBATT1,0x800D4220,0x4E2 -asm/non_matchings/code/z_camera/Camera_ModeBATT2.s,Camera_ModeBATT2,0x800D55A8,0x8 -asm/non_matchings/code/z_camera/Camera_ModeBATT3.s,Camera_ModeBATT3,0x800D55C8,0x8 -asm/non_matchings/code/z_camera/Camera_ModeBATT4.s,Camera_ModeBATT4,0x800D55E8,0x8 -asm/non_matchings/code/z_camera/Camera_ModeBATT0.s,Camera_ModeBATT0,0x800D5608,0x8 -asm/non_matchings/code/z_camera/Camera_ModeKEEP1.s,Camera_ModeKEEP1,0x800D5628,0x46D -asm/non_matchings/code/z_camera/Camera_ModeKEEP2.s,Camera_ModeKEEP2,0x800D67DC,0x8 -asm/non_matchings/code/z_camera/Camera_ModeKEEP3.s,Camera_ModeKEEP3,0x800D67FC,0x2F3 -asm/non_matchings/code/z_camera/Camera_ModeKEEP4.s,Camera_ModeKEEP4,0x800D73C8,0x2F7 -asm/non_matchings/code/z_camera/Camera_ModeKEEP0.s,Camera_ModeKEEP0,0x800D7FA4,0x8 -asm/non_matchings/code/z_camera/Camera_ModeFIXD1.s,Camera_ModeFIXD1,0x800D7FC4,0x101 -asm/non_matchings/code/z_camera/Camera_ModeFIXD2.s,Camera_ModeFIXD2,0x800D83C8,0x290 -asm/non_matchings/code/z_camera/Camera_ModeFIXD3.s,Camera_ModeFIXD3,0x800D8E08,0x8 -asm/non_matchings/code/z_camera/Camera_ModeFIXD4.s,Camera_ModeFIXD4,0x800D8E28,0x8 -asm/non_matchings/code/z_camera/Camera_ModeFIXD0.s,Camera_ModeFIXD0,0x800D8E48,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSUBJ1.s,Camera_ModeSUBJ1,0x800D8E68,0x185 -asm/non_matchings/code/z_camera/Camera_ModeSUBJ2.s,Camera_ModeSUBJ2,0x800D947C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSUBJ3.s,Camera_ModeSUBJ3,0x800D949C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSUBJ4.s,Camera_ModeSUBJ4,0x800D94BC,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSUBJ0.s,Camera_ModeSUBJ0,0x800D94DC,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDATA0.s,Camera_ModeDATA0,0x800D94FC,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDATA1.s,Camera_ModeDATA1,0x800D951C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDATA2.s,Camera_ModeDATA2,0x800D953C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDATA3.s,Camera_ModeDATA3,0x800D955C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDATA4.s,Camera_ModeDATA4,0x800D957C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ1.s,Camera_ModeUNIQ1,0x800D959C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ2.s,Camera_ModeUNIQ2,0x800D95BC,0x105 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ3.s,Camera_ModeUNIQ3,0x800D99D0,0x17 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ4.s,Camera_ModeUNIQ4,0x800D9A2C,0x17 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ5.s,Camera_ModeUNIQ5,0x800D9A88,0x17 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ0.s,Camera_ModeUNIQ0,0x800D9AE4,0x235 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ6.s,Camera_ModeUNIQ6,0x800DA3B8,0x4D -asm/non_matchings/code/z_camera/Camera_ModeUNIQ7.s,Camera_ModeUNIQ7,0x800DA4EC,0x8 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ8.s,Camera_ModeUNIQ8,0x800DA50C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeUNIQ9.s,Camera_ModeUNIQ9,0x800DA52C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDEMO1.s,Camera_ModeDEMO1,0x800DA54C,0x1F1 -asm/non_matchings/code/z_camera/Camera_ModeDEMO2.s,Camera_ModeDEMO2,0x800DAD10,0x2BD -asm/non_matchings/code/z_camera/Camera_ModeDEMO3.s,Camera_ModeDEMO3,0x800DB804,0xC4 -asm/non_matchings/code/z_camera/Camera_ModeDEMO4.s,Camera_ModeDEMO4,0x800DBB14,0x1D7 -asm/non_matchings/code/z_camera/Camera_ModeDEMO5.s,Camera_ModeDEMO5,0x800DC270,0x12A -asm/non_matchings/code/z_camera/Camera_ModeDEMO6.s,Camera_ModeDEMO6,0x800DC718,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDEMO7.s,Camera_ModeDEMO7,0x800DC738,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDEMO8.s,Camera_ModeDEMO8,0x800DC758,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDEMO9.s,Camera_ModeDEMO9,0x800DC778,0x8 -asm/non_matchings/code/z_camera/Camera_ModeDEMO0.s,Camera_ModeDEMO0,0x800DC798,0x13E -asm/non_matchings/code/z_camera/Camera_ModeSPEC0.s,Camera_ModeSPEC0,0x800DCC90,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSPEC1.s,Camera_ModeSPEC1,0x800DCCB0,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSPEC2.s,Camera_ModeSPEC2,0x800DCCD0,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSPEC3.s,Camera_ModeSPEC3,0x800DCCF0,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSPEC4.s,Camera_ModeSPEC4,0x800DCD10,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSPEC5.s,Camera_ModeSPEC5,0x800DCD30,0xF3 -asm/non_matchings/code/z_camera/Camera_ModeSPEC6.s,Camera_ModeSPEC6,0x800DD0FC,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSPEC7.s,Camera_ModeSPEC7,0x800DD11C,0x8 -asm/non_matchings/code/z_camera/Camera_ModeSPEC8.s,Camera_ModeSPEC8,0x800DD13C,0x11F -asm/non_matchings/code/z_camera/Camera_ModeSPEC9.s,Camera_ModeSPEC9,0x800DD5B8,0x1E8 +asm/non_matchings/code/z_camera/Camera_Noop.s,Camera_Noop,0x800CF3A4,0x4 +asm/non_matchings/code/z_camera/Camera_Normal1.s,Camera_Normal1,0x800CF3B4,0x530 +asm/non_matchings/code/z_camera/Camera_Normal2.s,Camera_Normal2,0x800D0874,0x8 +asm/non_matchings/code/z_camera/Camera_Normal3.s,Camera_Normal3,0x800D0894,0x265 +asm/non_matchings/code/z_camera/Camera_Normal4.s,Camera_Normal4,0x800D1228,0x24 +asm/non_matchings/code/z_camera/Camera_Normal0.s,Camera_Normal0,0x800D12B8,0x1F0 +asm/non_matchings/code/z_camera/Camera_Parallel1.s,Camera_Parallel1,0x800D1A78,0x40C +asm/non_matchings/code/z_camera/Camera_Parallel2.s,Camera_Parallel2,0x800D2AA8,0x8 +asm/non_matchings/code/z_camera/Camera_Parallel3.s,Camera_Parallel3,0x800D2AC8,0x8 +asm/non_matchings/code/z_camera/Camera_Parallel4.s,Camera_Parallel4,0x800D2AE8,0x8 +asm/non_matchings/code/z_camera/Camera_Parallel0.s,Camera_Parallel0,0x800D2B08,0x8 +asm/non_matchings/code/z_camera/Camera_Jump1.s,Camera_Jump1,0x800D2B28,0x8 +asm/non_matchings/code/z_camera/Camera_Jump2.s,Camera_Jump2,0x800D2B48,0x276 +asm/non_matchings/code/z_camera/Camera_Jump3.s,Camera_Jump3,0x800D3520,0x330 +asm/non_matchings/code/z_camera/Camera_Jump4.s,Camera_Jump4,0x800D41E0,0x8 +asm/non_matchings/code/z_camera/Camera_Jump0.s,Camera_Jump0,0x800D4200,0x8 +asm/non_matchings/code/z_camera/Camera_Battle1.s,Camera_Battle1,0x800D4220,0x4E2 +asm/non_matchings/code/z_camera/Camera_Battle2.s,Camera_Battle2,0x800D55A8,0x8 +asm/non_matchings/code/z_camera/Camera_Battle3.s,Camera_Battle3,0x800D55C8,0x8 +asm/non_matchings/code/z_camera/Camera_Battle4.s,Camera_Battle4,0x800D55E8,0x8 +asm/non_matchings/code/z_camera/Camera_Battle0.s,Camera_Battle0,0x800D5608,0x8 +asm/non_matchings/code/z_camera/Camera_KeepOn1.s,Camera_KeepOn1,0x800D5628,0x46D +asm/non_matchings/code/z_camera/Camera_KeepOn2.s,Camera_KeepOn2,0x800D67DC,0x8 +asm/non_matchings/code/z_camera/Camera_KeepOn3.s,Camera_KeepOn3,0x800D67FC,0x2F3 +asm/non_matchings/code/z_camera/Camera_KeepOn4.s,Camera_KeepOn4,0x800D73C8,0x2F7 +asm/non_matchings/code/z_camera/Camera_KeepOn0.s,Camera_KeepOn0,0x800D7FA4,0x8 +asm/non_matchings/code/z_camera/Camera_Fixed1.s,Camera_Fixed1,0x800D7FC4,0x101 +asm/non_matchings/code/z_camera/Camera_Fixed2.s,Camera_Fixed2,0x800D83C8,0x290 +asm/non_matchings/code/z_camera/Camera_Fixed3.s,Camera_Fixed3,0x800D8E08,0x8 +asm/non_matchings/code/z_camera/Camera_Fixed4.s,Camera_Fixed4,0x800D8E28,0x8 +asm/non_matchings/code/z_camera/Camera_Fixed0.s,Camera_Fixed0,0x800D8E48,0x8 +asm/non_matchings/code/z_camera/Camera_Subject1.s,Camera_Subject1,0x800D8E68,0x185 +asm/non_matchings/code/z_camera/Camera_Subject2.s,Camera_Subject2,0x800D947C,0x8 +asm/non_matchings/code/z_camera/Camera_Subject3.s,Camera_Subject3,0x800D949C,0x8 +asm/non_matchings/code/z_camera/Camera_Subject4.s,Camera_Subject4,0x800D94BC,0x8 +asm/non_matchings/code/z_camera/Camera_Subject0.s,Camera_Subject0,0x800D94DC,0x8 +asm/non_matchings/code/z_camera/Camera_Data0.s,Camera_Data0,0x800D94FC,0x8 +asm/non_matchings/code/z_camera/Camera_Data1.s,Camera_Data1,0x800D951C,0x8 +asm/non_matchings/code/z_camera/Camera_Data2.s,Camera_Data2,0x800D953C,0x8 +asm/non_matchings/code/z_camera/Camera_Data3.s,Camera_Data3,0x800D955C,0x8 +asm/non_matchings/code/z_camera/Camera_Data4.s,Camera_Data4,0x800D957C,0x8 +asm/non_matchings/code/z_camera/Camera_Unique1.s,Camera_Unique1,0x800D959C,0x8 +asm/non_matchings/code/z_camera/Camera_Unique2.s,Camera_Unique2,0x800D95BC,0x105 +asm/non_matchings/code/z_camera/Camera_Unique3.s,Camera_Unique3,0x800D99D0,0x17 +asm/non_matchings/code/z_camera/Camera_Unique4.s,Camera_Unique4,0x800D9A2C,0x17 +asm/non_matchings/code/z_camera/Camera_Unique5.s,Camera_Unique5,0x800D9A88,0x17 +asm/non_matchings/code/z_camera/Camera_Unique0.s,Camera_Unique0,0x800D9AE4,0x235 +asm/non_matchings/code/z_camera/Camera_Unique6.s,Camera_Unique6,0x800DA3B8,0x4D +asm/non_matchings/code/z_camera/Camera_Unique7.s,Camera_Unique7,0x800DA4EC,0x8 +asm/non_matchings/code/z_camera/Camera_Unique8.s,Camera_Unique8,0x800DA50C,0x8 +asm/non_matchings/code/z_camera/Camera_Unique9.s,Camera_Unique9,0x800DA52C,0x8 +asm/non_matchings/code/z_camera/Camera_Demo1.s,Camera_Demo1,0x800DA54C,0x1F1 +asm/non_matchings/code/z_camera/Camera_Demo2.s,Camera_Demo2,0x800DAD10,0x2BD +asm/non_matchings/code/z_camera/Camera_Demo3.s,Camera_Demo3,0x800DB804,0xC4 +asm/non_matchings/code/z_camera/Camera_Demo4.s,Camera_Demo4,0x800DBB14,0x1D7 +asm/non_matchings/code/z_camera/Camera_Demo5.s,Camera_Demo5,0x800DC270,0x12A +asm/non_matchings/code/z_camera/Camera_Demo6.s,Camera_Demo6,0x800DC718,0x8 +asm/non_matchings/code/z_camera/Camera_Demo7.s,Camera_Demo7,0x800DC738,0x8 +asm/non_matchings/code/z_camera/Camera_Demo8.s,Camera_Demo8,0x800DC758,0x8 +asm/non_matchings/code/z_camera/Camera_Demo9.s,Camera_Demo9,0x800DC778,0x8 +asm/non_matchings/code/z_camera/Camera_Demo0.s,Camera_Demo0,0x800DC798,0x13E +asm/non_matchings/code/z_camera/Camera_Special0.s,Camera_Special0,0x800DCC90,0x8 +asm/non_matchings/code/z_camera/Camera_Special1.s,Camera_Special1,0x800DCCB0,0x8 +asm/non_matchings/code/z_camera/Camera_Special2.s,Camera_Special2,0x800DCCD0,0x8 +asm/non_matchings/code/z_camera/Camera_Special3.s,Camera_Special3,0x800DCCF0,0x8 +asm/non_matchings/code/z_camera/Camera_Special4.s,Camera_Special4,0x800DCD10,0x8 +asm/non_matchings/code/z_camera/Camera_Special5.s,Camera_Special5,0x800DCD30,0xF3 +asm/non_matchings/code/z_camera/Camera_Special6.s,Camera_Special6,0x800DD0FC,0x8 +asm/non_matchings/code/z_camera/Camera_Special7.s,Camera_Special7,0x800DD11C,0x8 +asm/non_matchings/code/z_camera/Camera_Special8.s,Camera_Special8,0x800DD13C,0x11F +asm/non_matchings/code/z_camera/Camera_Special9.s,Camera_Special9,0x800DD5B8,0x1E8 asm/non_matchings/code/z_camera/Camera_Alloc.s,Camera_Alloc,0x800DDD58,0x14 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 @@ -1092,34 +1092,34 @@ asm/non_matchings/code/z_demo/Cutscene_ActorTranslate.s,Cutscene_ActorTranslate, asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYaw.s,Cutscene_ActorTranslateAndYaw,0x800EDF24,0x15 asm/non_matchings/code/z_demo/Cutscene_ActorTranslateAndYawSmooth.s,Cutscene_ActorTranslateAndYawSmooth,0x800EDF78,0x55 asm/non_matchings/code/z_demo/Cutscene_ActorTranslateXZAndYawSmooth.s,Cutscene_ActorTranslateXZAndYawSmooth,0x800EE0CC,0x43 -asm/non_matchings/code/z_demo/Cutscene_GetSceneSetupIndex.s,Cutscene_GetSceneSetupIndex,0x800EE1D8,0xA +asm/non_matchings/code/z_demo/Cutscene_GetSceneLayer.s,Cutscene_GetSceneLayer,0x800EE1D8,0xA asm/non_matchings/code/z_demo/Cutscene_GetActorActionIndex.s,Cutscene_GetActorActionIndex,0x800EE200,0x27 asm/non_matchings/code/z_demo/Cutscene_CheckActorAction.s,Cutscene_CheckActorAction,0x800EE29C,0x16 asm/non_matchings/code/z_demo/Cutscene_IsPlaying.s,Cutscene_IsPlaying,0x800EE2F4,0xB asm/non_matchings/code/z_draw/GetItem_Draw.s,GetItem_Draw,0x800EE320,0x11 -asm/non_matchings/code/z_draw/func_800EE364.s,func_800EE364,0x800EE364,0x27 -asm/non_matchings/code/z_draw/func_800EE400.s,func_800EE400,0x800EE400,0x7F -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 @@ -1282,9 +1282,9 @@ asm/non_matchings/code/z_kankyo/func_800FDAF8.s,func_800FDAF8,0x800FDAF8,0x67 asm/non_matchings/code/z_kankyo/func_800FDC94.s,func_800FDC94,0x800FDC94,0x1BF asm/non_matchings/code/z_kankyo/func_800FE390.s,func_800FE390,0x800FE390,0x14 asm/non_matchings/code/z_kankyo/func_800FE3E0.s,func_800FE3E0,0x800FE3E0,0x29 -asm/non_matchings/code/z_kankyo/func_800FE484.s,func_800FE484,0x800FE484,0x5 -asm/non_matchings/code/z_kankyo/func_800FE498.s,func_800FE498,0x800FE498,0x4 -asm/non_matchings/code/z_kankyo/func_800FE4A8.s,func_800FE4A8,0x800FE4A8,0x4 +asm/non_matchings/code/z_kankyo/Environment_StopTime.s,Environment_StopTime,0x800FE484,0x5 +asm/non_matchings/code/z_kankyo/Environment_StartTime.s,Environment_StartTime,0x800FE498,0x4 +asm/non_matchings/code/z_kankyo/Environment_IsTimeStopped.s,Environment_IsTimeStopped,0x800FE4A8,0x4 asm/non_matchings/code/z_kankyo/func_800FE4B8.s,func_800FE4B8,0x800FE4B8,0x36 asm/non_matchings/code/z_kankyo/func_800FE590.s,func_800FE590,0x800FE590,0x10 asm/non_matchings/code/z_kankyo/func_800FE5D0.s,func_800FE5D0,0x800FE5D0,0x10 @@ -1368,8 +1368,8 @@ asm/non_matchings/code/z_lib/Math_Vec3f_StepTo.s,Math_Vec3f_StepTo,0x80100448,0x asm/non_matchings/code/z_lib/Lib_Nop801004FC.s,Lib_Nop801004FC,0x801004FC,0x2 asm/non_matchings/code/z_lib/Lib_SegmentedToVirtual.s,Lib_SegmentedToVirtual,0x80100504,0xE asm/non_matchings/code/z_lib/Lib_SegmentedToVirtualNull.s,Lib_SegmentedToVirtualNull,0x8010053C,0x12 -asm/non_matchings/code/z_lib/Lib_PhysicalToVirtual.s,Lib_PhysicalToVirtual,0x80100584,0x7 -asm/non_matchings/code/z_lib/Lib_PhysicalToVirtualNull.s,Lib_PhysicalToVirtualNull,0x801005A0,0x8 +asm/non_matchings/code/z_lib/Lib_VirtualToPhysical.s,Lib_VirtualToPhysical,0x80100584,0x7 +asm/non_matchings/code/z_lib/Lib_PhysicalToVirtual.s,Lib_PhysicalToVirtual,0x801005A0,0x8 asm/non_matchings/code/z_lifemeter/LifeMeter_Init.s,LifeMeter_Init,0x801005C0,0x37 asm/non_matchings/code/z_lifemeter/LifeMeter_UpdateColors.s,LifeMeter_UpdateColors,0x8010069C,0xF9 asm/non_matchings/code/z_lifemeter/func_80100A80.s,func_80100A80,0x80100A80,0x8 @@ -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 @@ -1597,64 +1597,64 @@ asm/non_matchings/code/z_olib/OLib_Vec3fDiffDegF.s,OLib_Vec3fDiffDegF,0x8010C8C8 asm/non_matchings/code/z_olib/OLib_Vec3fDiffBinAng.s,OLib_Vec3fDiffBinAng,0x8010C930,0x26 asm/non_matchings/code/z_olib/OLib_DbCameraVec3fDiff.s,OLib_DbCameraVec3fDiff,0x8010C9C8,0x36 asm/non_matchings/code/z_olib/OLib_DbCameraVec3fSum.s,OLib_DbCameraVec3fSum,0x8010CAA0,0x34 -asm/non_matchings/code/z_parameter/func_8010CB80.s,func_8010CB80,0x8010CB80,0x86 -asm/non_matchings/code/z_parameter/func_8010CD98.s,func_8010CD98,0x8010CD98,0x89 -asm/non_matchings/code/z_parameter/func_8010CFBC.s,func_8010CFBC,0x8010CFBC,0xC6 -asm/non_matchings/code/z_parameter/func_8010D2D4.s,func_8010D2D4,0x8010D2D4,0x6B -asm/non_matchings/code/z_parameter/func_8010D480.s,func_8010D480,0x8010D480,0xD4 -asm/non_matchings/code/z_parameter/func_8010D7D0.s,func_8010D7D0,0x8010D7D0,0x89 -asm/non_matchings/code/z_parameter/func_8010D9F4.s,func_8010D9F4,0x8010D9F4,0x99 -asm/non_matchings/code/z_parameter/func_8010DC58.s,func_8010DC58,0x8010DC58,0x78 -asm/non_matchings/code/z_parameter/func_8010DE38.s,func_8010DE38,0x8010DE38,0x7C -asm/non_matchings/code/z_parameter/func_8010E028.s,func_8010E028,0x8010E028,0x250 -asm/non_matchings/code/z_parameter/func_8010E968.s,func_8010E968,0x8010E968,0x22 -asm/non_matchings/code/z_parameter/func_8010E9F0.s,func_8010E9F0,0x8010E9F0,0x2B -asm/non_matchings/code/z_parameter/func_8010EA9C.s,func_8010EA9C,0x8010EA9C,0x2D -asm/non_matchings/code/z_parameter/func_8010EB50.s,func_8010EB50,0x8010EB50,0x14 -asm/non_matchings/code/z_parameter/func_8010EBA0.s,func_8010EBA0,0x8010EBA0,0x2D -asm/non_matchings/code/z_parameter/func_8010EC54.s,func_8010EC54,0x8010EC54,0x88 -asm/non_matchings/code/z_parameter/func_8010EE74.s,func_8010EE74,0x8010EE74,0x3D -asm/non_matchings/code/z_parameter/Interface_ChangeAlpha.s,Interface_ChangeAlpha,0x8010EF68,0xD -asm/non_matchings/code/z_parameter/func_8010EF9C.s,func_8010EF9C,0x8010EF9C,0x4E -asm/non_matchings/code/z_parameter/func_8010F0D4.s,func_8010F0D4,0x8010F0D4,0x35 -asm/non_matchings/code/z_parameter/func_8010F1A8.s,func_8010F1A8,0x8010F1A8,0x3A4 +asm/non_matchings/code/z_parameter/Gfx_DrawTexRectRGBA16.s,Gfx_DrawTexRectRGBA16,0x8010CB80,0x86 +asm/non_matchings/code/z_parameter/Gfx_DrawTexRectIA8.s,Gfx_DrawTexRectIA8,0x8010CD98,0x89 +asm/non_matchings/code/z_parameter/Gfx_DrawTexRectIA8_DropShadow.s,Gfx_DrawTexRectIA8_DropShadow,0x8010CFBC,0xC6 +asm/non_matchings/code/z_parameter/Gfx_DrawRect_DropShadow.s,Gfx_DrawRect_DropShadow,0x8010D2D4,0x6B +asm/non_matchings/code/z_parameter/Gfx_DrawTexRectIA8_DropShadowOffset.s,Gfx_DrawTexRectIA8_DropShadowOffset,0x8010D480,0xD4 +asm/non_matchings/code/z_parameter/Gfx_DrawTexRectI8.s,Gfx_DrawTexRectI8,0x8010D7D0,0x89 +asm/non_matchings/code/z_parameter/Gfx_DrawTexRect4b.s,Gfx_DrawTexRect4b,0x8010D9F4,0x99 +asm/non_matchings/code/z_parameter/Gfx_DrawTexQuadIA8.s,Gfx_DrawTexQuadIA8,0x8010DC58,0x78 +asm/non_matchings/code/z_parameter/Gfx_DrawTexQuad4b.s,Gfx_DrawTexQuad4b,0x8010DE38,0x7C +asm/non_matchings/code/z_parameter/Interface_SetVertices.s,Interface_SetVertices,0x8010E028,0x250 +asm/non_matchings/code/z_parameter/Interface_PostmanTimerCallback.s,Interface_PostmanTimerCallback,0x8010E968,0x22 +asm/non_matchings/code/z_parameter/Interface_StartTimer.s,Interface_StartTimer,0x8010E9F0,0x2B +asm/non_matchings/code/z_parameter/Interface_StartPostmanTimer.s,Interface_StartPostmanTimer,0x8010EA9C,0x2D +asm/non_matchings/code/z_parameter/Interface_StartGoronRaceTimer.s,Interface_StartGoronRaceTimer,0x8010EB50,0x14 +asm/non_matchings/code/z_parameter/Interface_StartBottleTimer.s,Interface_StartBottleTimer,0x8010EBA0,0x2D +asm/non_matchings/code/z_parameter/Interface_GetCompressedTimerDigits.s,Interface_GetCompressedTimerDigits,0x8010EC54,0x88 +asm/non_matchings/code/z_parameter/Interface_NewDay.s,Interface_NewDay,0x8010EE74,0x3D +asm/non_matchings/code/z_parameter/Interface_SetHudVisibility.s,Interface_SetHudVisibility,0x8010EF68,0xD +asm/non_matchings/code/z_parameter/Interface_UpdateButtonAlphasByStatus.s,Interface_UpdateButtonAlphasByStatus,0x8010EF9C,0x4E +asm/non_matchings/code/z_parameter/Interface_UpdateButtonAlphas.s,Interface_UpdateButtonAlphas,0x8010F0D4,0x35 +asm/non_matchings/code/z_parameter/Interface_UpdateHudAlphas.s,Interface_UpdateHudAlphas,0x8010F1A8,0x3A4 asm/non_matchings/code/z_parameter/func_80110038.s,func_80110038,0x80110038,0x71F asm/non_matchings/code/z_parameter/func_80111CB4.s,func_80111CB4,0x80111CB4,0x34C -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_SetSceneRestrictions.s,Interface_SetSceneRestrictions,0x801129E4,0x44 +asm/non_matchings/code/z_parameter/Interface_Noop.s,Interface_Noop,0x80112AF4,0x2 +asm/non_matchings/code/z_parameter/Interface_InitMinigame.s,Interface_InitMinigame,0x80112AFC,0x11 +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/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 -asm/non_matchings/code/z_parameter/func_80116088.s,func_80116088,0x80116088,0x23 -asm/non_matchings/code/z_parameter/func_80116114.s,func_80116114,0x80116114,0x8D -asm/non_matchings/code/z_parameter/func_80116348.s,func_80116348,0x80116348,0x174 -asm/non_matchings/code/z_parameter/func_80116918.s,func_80116918,0x80116918,0x1B0 +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/Magic_Add.s,Magic_Add,0x80115D14,0x12 +asm/non_matchings/code/z_parameter/Magic_Reset.s,Magic_Reset,0x80115D5C,0x16 +asm/non_matchings/code/z_parameter/Magic_Consume.s,Magic_Consume,0x80115DB4,0xB5 +asm/non_matchings/code/z_parameter/Magic_UpdateAddRequest.s,Magic_UpdateAddRequest,0x80116088,0x23 +asm/non_matchings/code/z_parameter/Magic_FlashMeterBorder.s,Magic_FlashMeterBorder,0x80116114,0x8D +asm/non_matchings/code/z_parameter/Magic_Update.s,Magic_Update,0x80116348,0x174 +asm/non_matchings/code/z_parameter/Magic_DrawMeter.s,Magic_DrawMeter,0x80116918,0x1B0 asm/non_matchings/code/z_parameter/func_80116FD8.s,func_80116FD8,0x80116FD8,0x38 asm/non_matchings/code/z_parameter/func_801170B8.s,func_801170B8,0x801170B8,0x12 asm/non_matchings/code/z_parameter/func_80117100.s,func_80117100,0x80117100,0x248 @@ -1664,23 +1664,23 @@ asm/non_matchings/code/z_parameter/func_80118084.s,func_80118084,0x80118084,0x20 asm/non_matchings/code/z_parameter/func_80118890.s,func_80118890,0x80118890,0xC5 asm/non_matchings/code/z_parameter/func_80118BA4.s,func_80118BA4,0x80118BA4,0x123 asm/non_matchings/code/z_parameter/func_80119030.s,func_80119030,0x80119030,0x178 -asm/non_matchings/code/z_parameter/func_80119610.s,func_80119610,0x80119610,0x7B4 -asm/non_matchings/code/z_parameter/func_8011B4E0.s,func_8011B4E0,0x8011B4E0,0x38 -asm/non_matchings/code/z_parameter/func_8011B5C0.s,func_8011B5C0,0x8011B5C0,0x108 -asm/non_matchings/code/z_parameter/func_8011B9E0.s,func_8011B9E0,0x8011B9E0,0x164 -asm/non_matchings/code/z_parameter/func_8011BF70.s,func_8011BF70,0x8011BF70,0x155 -asm/non_matchings/code/z_parameter/func_8011C4C4.s,func_8011C4C4,0x8011C4C4,0xD1 -asm/non_matchings/code/z_parameter/func_8011C808.s,func_8011C808,0x8011C808,0x24 -asm/non_matchings/code/z_parameter/func_8011C898.s,func_8011C898,0x8011C898,0x73 -asm/non_matchings/code/z_parameter/func_8011CA64.s,func_8011CA64,0x8011CA64,0x654 -asm/non_matchings/code/z_parameter/func_8011E3B4.s,func_8011E3B4,0x8011E3B4,0xDF -asm/non_matchings/code/z_parameter/func_8011E730.s,func_8011E730,0x8011E730,0x26C -asm/non_matchings/code/z_parameter/func_8011F0E0.s,func_8011F0E0,0x8011F0E0,0x7AC -asm/non_matchings/code/z_parameter/func_80120F90.s,func_80120F90,0x80120F90,0x35 -asm/non_matchings/code/z_parameter/func_80121064.s,func_80121064,0x80121064,0x1F -asm/non_matchings/code/z_parameter/func_801210E0.s,func_801210E0,0x801210E0,0x3AD -asm/non_matchings/code/z_parameter/func_80121F94.s,func_80121F94,0x80121F94,0xC -asm/non_matchings/code/z_parameter/func_80121FC4.s,func_80121FC4,0x80121FC4,0x147 +asm/non_matchings/code/z_parameter/Interface_DrawClock.s,Interface_DrawClock,0x80119610,0x7B4 +asm/non_matchings/code/z_parameter/Interface_SetPerfectLetters.s,Interface_SetPerfectLetters,0x8011B4E0,0x38 +asm/non_matchings/code/z_parameter/Interface_UpdatePerfectLettersType1.s,Interface_UpdatePerfectLettersType1,0x8011B5C0,0x108 +asm/non_matchings/code/z_parameter/Interface_UpdatePerfectLettersType2.s,Interface_UpdatePerfectLettersType2,0x8011B9E0,0x164 +asm/non_matchings/code/z_parameter/Interface_UpdatePerfectLettersType3.s,Interface_UpdatePerfectLettersType3,0x8011BF70,0x155 +asm/non_matchings/code/z_parameter/Interface_DrawPerfectLetters.s,Interface_DrawPerfectLetters,0x8011C4C4,0xD1 +asm/non_matchings/code/z_parameter/Interface_StartMoonCrash.s,Interface_StartMoonCrash,0x8011C808,0x24 +asm/non_matchings/code/z_parameter/Interface_GetTimerDigits.s,Interface_GetTimerDigits,0x8011C898,0x73 +asm/non_matchings/code/z_parameter/Interface_DrawTimers.s,Interface_DrawTimers,0x8011CA64,0x654 +asm/non_matchings/code/z_parameter/Interface_UpdateBottleTimers.s,Interface_UpdateBottleTimers,0x8011E3B4,0xDF +asm/non_matchings/code/z_parameter/Interface_DrawMinigameIcons.s,Interface_DrawMinigameIcons,0x8011E730,0x26C +asm/non_matchings/code/z_parameter/Interface_Draw.s,Interface_Draw,0x8011F0E0,0x7AC +asm/non_matchings/code/z_parameter/Interface_LoadStory.s,Interface_LoadStory,0x80120F90,0x35 +asm/non_matchings/code/z_parameter/Interface_AllocStory.s,Interface_AllocStory,0x80121064,0x1F +asm/non_matchings/code/z_parameter/Interface_Update.s,Interface_Update,0x801210E0,0x3AD +asm/non_matchings/code/z_parameter/Interface_Destroy.s,Interface_Destroy,0x80121F94,0xC +asm/non_matchings/code/z_parameter/Interface_Init.s,Interface_Init,0x80121FC4,0x147 asm/non_matchings/code/z_path/func_801224E0.s,func_801224E0,0x801224E0,0x11 asm/non_matchings/code/z_path/func_80122524.s,func_80122524,0x80122524,0x2A asm/non_matchings/code/z_path/func_801225CC.s,func_801225CC,0x801225CC,0x25 @@ -1696,60 +1696,60 @@ 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/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_ActionToModelGroup.s,Player_ActionToModelGroup,0x80123960,0x13 +asm/non_matchings/code/z_player_lib/Player_SetModelsForHoldingShield.s,Player_SetModelsForHoldingShield,0x801239AC,0x3E +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 +asm/non_matchings/code/z_player_lib/Player_UpdateBottleHeld.s,Player_UpdateBottleHeld,0x80123D50,0x15 asm/non_matchings/code/z_player_lib/func_80123DA4.s,func_80123DA4,0x80123DA4,0x7 asm/non_matchings/code/z_player_lib/func_80123DC0.s,func_80123DC0,0x80123DC0,0x34 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/Player_ActionToSword.s,Player_ActionToSword,0x80124278,0xF asm/non_matchings/code/z_player_lib/func_801242B4.s,func_801242B4,0x801242B4,0xA -asm/non_matchings/code/z_player_lib/func_801242DC.s,func_801242DC,0x801242DC,0x51 +asm/non_matchings/code/z_player_lib/Player_GetEnvironmentalHazard.s,Player_GetEnvironmentalHazard,0x801242DC,0x51 asm/non_matchings/code/z_player_lib/func_80124420.s,func_80124420,0x80124420,0x7E asm/non_matchings/code/z_player_lib/func_80124618.s,func_80124618,0x80124618,0x37 -asm/non_matchings/code/z_player_lib/func_801246F4.s,func_801246F4,0x801246F4,0x5F +asm/non_matchings/code/z_player_lib/Player_DrawImpl.s,Player_DrawImpl,0x801246F4,0x5F asm/non_matchings/code/z_player_lib/func_80124870.s,func_80124870,0x80124870,0x115 asm/non_matchings/code/z_player_lib/func_80124CC4.s,func_80124CC4,0x80124CC4,0x95 asm/non_matchings/code/z_player_lib/func_80124F18.s,func_80124F18,0x80124F18,0x36 @@ -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,23 +1768,23 @@ 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/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 +asm/non_matchings/code/z_player_lib/Player_DrawCouplesMask.s,Player_DrawCouplesMask,0x8012754C,0x12 +asm/non_matchings/code/z_player_lib/Player_DrawCircusLeadersMask.s,Player_DrawCircusLeadersMask,0x80127594,0xD9 +asm/non_matchings/code/z_player_lib/Player_DrawBlastMask.s,Player_DrawBlastMask,0x801278F8,0x5A +asm/non_matchings/code/z_player_lib/Player_DrawBunnyHood.s,Player_DrawBunnyHood,0x80127A60,0x41 asm/non_matchings/code/z_player_lib/func_80127B64.s,func_80127B64,0x80127B64,0x21 asm/non_matchings/code/z_player_lib/func_80127BE8.s,func_80127BE8,0x80127BE8,0x6F asm/non_matchings/code/z_player_lib/func_80127DA4.s,func_80127DA4,0x80127DA4,0x179 asm/non_matchings/code/z_player_lib/func_80128388.s,func_80128388,0x80128388,0x46 -asm/non_matchings/code/z_player_lib/func_801284A0.s,func_801284A0,0x801284A0,0x68 +asm/non_matchings/code/z_player_lib/Player_DrawGreatFairysMask.s,Player_DrawGreatFairysMask,0x801284A0,0x68 asm/non_matchings/code/z_player_lib/func_80128640.s,func_80128640,0x80128640,0x14D asm/non_matchings/code/z_player_lib/func_80128B74.s,func_80128B74,0x80128B74,0x17 asm/non_matchings/code/z_player_lib/func_80128BD0.s,func_80128BD0,0x80128BD0,0x4C8 @@ -1796,15 +1796,15 @@ asm/non_matchings/code/z_prenmi/PreNMI_Destroy.s,PreNMI_Destroy,0x8012A02C,0x3 asm/non_matchings/code/z_prenmi/PreNMI_Init.s,PreNMI_Init,0x8012A038,0x12 asm/non_matchings/code/z_quake/Quake_Random.s,Quake_Random,0x8012A080,0xB asm/non_matchings/code/z_quake/Quake_UpdateShakeInfo.s,Quake_UpdateShakeInfo,0x8012A0AC,0x83 -asm/non_matchings/code/z_quake/Quake_Callback1.s,Quake_Callback1,0x8012A2B8,0x22 -asm/non_matchings/code/z_quake/Quake_Callback5.s,Quake_Callback5,0x8012A340,0x1D -asm/non_matchings/code/z_quake/Quake_Callback6.s,Quake_Callback6,0x8012A3B4,0x21 -asm/non_matchings/code/z_quake/Quake_Callback3.s,Quake_Callback3,0x8012A438,0x26 -asm/non_matchings/code/z_quake/Quake_Callback2.s,Quake_Callback2,0x8012A4D0,0x1C -asm/non_matchings/code/z_quake/Quake_Callback4.s,Quake_Callback4,0x8012A540,0x26 +asm/non_matchings/code/z_quake/Quake_CallbackType1.s,Quake_CallbackType1,0x8012A2B8,0x22 +asm/non_matchings/code/z_quake/Quake_CallbackType5.s,Quake_CallbackType5,0x8012A340,0x1D +asm/non_matchings/code/z_quake/Quake_CallbackType6.s,Quake_CallbackType6,0x8012A3B4,0x21 +asm/non_matchings/code/z_quake/Quake_CallbackType3.s,Quake_CallbackType3,0x8012A438,0x26 +asm/non_matchings/code/z_quake/Quake_CallbackType2.s,Quake_CallbackType2,0x8012A4D0,0x1C +asm/non_matchings/code/z_quake/Quake_CallbackType4.s,Quake_CallbackType4,0x8012A540,0x26 asm/non_matchings/code/z_quake/Quake_GetFreeIndex.s,Quake_GetFreeIndex,0x8012A5D8,0x18 asm/non_matchings/code/z_quake/Quake_AddImpl.s,Quake_AddImpl,0x8012A638,0x2E -asm/non_matchings/code/z_quake/Quake_Remove.s,Quake_Remove,0x8012A6F0,0xA +asm/non_matchings/code/z_quake/Quake_RemoveRequest.s,Quake_RemoveRequest,0x8012A6F0,0xA asm/non_matchings/code/z_quake/Quake_GetRequest.s,Quake_GetRequest,0x8012A718,0x17 asm/non_matchings/code/z_quake/Quake_SetValue.s,Quake_SetValue,0x8012A774,0x4D asm/non_matchings/code/z_quake/Quake_SetSpeed.s,Quake_SetSpeed,0x8012A8A8,0x12 @@ -1814,7 +1814,7 @@ asm/non_matchings/code/z_quake/Quake_SetQuakeValues.s,Quake_SetQuakeValues,0x801 asm/non_matchings/code/z_quake/Quake_SetQuakeValues2.s,Quake_SetQuakeValues2,0x8012A9E0,0x1A asm/non_matchings/code/z_quake/Quake_Init.s,Quake_Init,0x8012AA48,0x15 asm/non_matchings/code/z_quake/Quake_Add.s,Quake_Add,0x8012AA9C,0x9 -asm/non_matchings/code/z_quake/Quake_RemoveFromIdx.s,Quake_RemoveFromIdx,0x8012AAC0,0x12 +asm/non_matchings/code/z_quake/Quake_Remove.s,Quake_Remove,0x8012AAC0,0x12 asm/non_matchings/code/z_quake/Quake_Calc.s,Quake_Calc,0x8012AB08,0xD8 asm/non_matchings/code/z_quake/Distortion_Init.s,Distortion_Init,0x8012AE68,0x11 asm/non_matchings/code/z_quake/Distortion_SetCountdown.s,Distortion_SetCountdown,0x8012AEAC,0xA @@ -1924,7 +1924,7 @@ asm/non_matchings/code/code_8012EC80/Inventory_ChangeEquipment.s,Inventory_Chang asm/non_matchings/code/code_8012EC80/Inventory_DeleteEquipment.s,Inventory_DeleteEquipment,0x8012ED78,0x1C asm/non_matchings/code/code_8012EC80/Inventory_ChangeUpgrade.s,Inventory_ChangeUpgrade,0x8012EDE8,0x13 asm/non_matchings/code/code_8012EC80/Inventory_IsMapVisible.s,Inventory_IsMapVisible,0x8012EE34,0x36 -asm/non_matchings/code/code_8012EC80/Inventory_SetMapVisibility.s,Inventory_SetMapVisibility,0x8012EF0C,0x78 +asm/non_matchings/code/code_8012EC80/Inventory_SetWorldMapCloudVisibility.s,Inventory_SetWorldMapCloudVisibility,0x8012EF0C,0x78 asm/non_matchings/code/code_8012EC80/Inventory_SaveDekuPlaygroundHighScore.s,Inventory_SaveDekuPlaygroundHighScore,0x8012F0EC,0x34 asm/non_matchings/code/code_8012EC80/Inventory_IncrementSkullTokenCount.s,Inventory_IncrementSkullTokenCount,0x8012F1BC,0x1C asm/non_matchings/code/code_8012EC80/Inventory_GetSkullTokenCount.s,Inventory_GetSkullTokenCount,0x8012F22C,0x13 @@ -1966,12 +1966,12 @@ asm/non_matchings/code/z_scene/Scene_HeaderCmdActorCutsceneList.s,Scene_HeaderCm asm/non_matchings/code/z_scene/Scene_HeaderCmdMiniMap.s,Scene_HeaderCmdMiniMap,0x80130540,0xE asm/non_matchings/code/z_scene/Scene_HeaderCmd1D.s,Scene_HeaderCmd1D,0x80130578,0x4 asm/non_matchings/code/z_scene/Scene_HeaderCmdMiniMapCompassInfo.s,Scene_HeaderCmdMiniMapCompassInfo,0x80130588,0xA -asm/non_matchings/code/z_scene/Scene_HeaderCmdSetAreaVisitedFlag.s,Scene_HeaderCmdSetAreaVisitedFlag,0x801305B0,0x31 +asm/non_matchings/code/z_scene/Scene_HeaderCmdSetRegionVisitedFlag.s,Scene_HeaderCmdSetRegionVisitedFlag,0x801305B0,0x31 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 @@ -2009,8 +2009,8 @@ asm/non_matchings/code/z_scene_proc/Scene_DrawConfig5.s,Scene_DrawConfig5,0x8013 asm/non_matchings/code/z_scene_proc/Scene_DrawConfigMatAnimManualStep.s,Scene_DrawConfigMatAnimManualStep,0x80131F90,0xC asm/non_matchings/code/z_scene_proc/Scene_DrawConfigGreatBayTemple.s,Scene_DrawConfigGreatBayTemple,0x80131FC0,0xC0 asm/non_matchings/code/z_scene_table/Entrance_GetTableEntry.s,Entrance_GetTableEntry,0x801322C0,0x13 -asm/non_matchings/code/z_scene_table/Entrance_GetSceneNum.s,Entrance_GetSceneNum,0x8013230C,0xB -asm/non_matchings/code/z_scene_table/Entrance_GetSceneNumAbsolute.s,Entrance_GetSceneNumAbsolute,0x80132338,0xF +asm/non_matchings/code/z_scene_table/Entrance_GetSceneId.s,Entrance_GetSceneId,0x8013230C,0xB +asm/non_matchings/code/z_scene_table/Entrance_GetSceneIdAbsolute.s,Entrance_GetSceneIdAbsolute,0x80132338,0xF asm/non_matchings/code/z_scene_table/Entrance_GetSpawnNum.s,Entrance_GetSpawnNum,0x80132374,0xB asm/non_matchings/code/z_scene_table/Entrance_GetTransitionFlags.s,Entrance_GetTransitionFlags,0x801323A0,0xC asm/non_matchings/code/code_801323D0/func_801323D0.s,func_801323D0,0x801323D0,0x16 @@ -2175,26 +2175,26 @@ asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0 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/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_ComputeTurnToPointRot.s,SubS_ComputeTurnToPointRot,0x8013D0E0,0x80 -asm/non_matchings/code/z_sub_s/SubS_TurnToPoint.s,SubS_TurnToPoint,0x8013D2E0,0xC2 +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 @@ -2223,45 +2223,45 @@ asm/non_matchings/code/z_sub_s/SubS_FindActorCustom.s,SubS_FindActorCustom,0x801 asm/non_matchings/code/z_sub_s/func_8013E748.s,func_8013E748,0x8013E748,0x1E 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/SubS_TurnToPointStep.s,SubS_TurnToPointStep,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 -asm/non_matchings/code/z_view/func_8013F050.s,func_8013F050,0x8013F050,0x14 +asm/non_matchings/code/z_view/View_LookAt.s,View_LookAt,0x8013EF9C,0x2D +asm/non_matchings/code/z_view/View_LookAtUnsafe.s,View_LookAtUnsafe,0x8013F050,0x14 asm/non_matchings/code/z_view/View_SetScale.s,View_SetScale,0x8013F0A0,0x8 asm/non_matchings/code/z_view/View_GetScale.s,View_GetScale,0x8013F0C0,0x4 -asm/non_matchings/code/z_view/func_8013F0D0.s,func_8013F0D0,0x8013F0D0,0xC -asm/non_matchings/code/z_view/func_8013F100.s,func_8013F100,0x8013F100,0x8 -asm/non_matchings/code/z_view/func_8013F120.s,func_8013F120,0x8013F120,0xF -asm/non_matchings/code/z_view/func_8013F15C.s,func_8013F15C,0x8013F15C,0x8 +asm/non_matchings/code/z_view/View_SetPerspective.s,View_SetPerspective,0x8013F0D0,0xC +asm/non_matchings/code/z_view/View_GetPerspective.s,View_GetPerspective,0x8013F100,0x8 +asm/non_matchings/code/z_view/View_SetOrtho.s,View_SetOrtho,0x8013F120,0xF +asm/non_matchings/code/z_view/View_GetOrtho.s,View_GetOrtho,0x8013F15C,0x8 asm/non_matchings/code/z_view/View_SetViewport.s,View_SetViewport,0x8013F17C,0xD asm/non_matchings/code/z_view/View_GetViewport.s,View_GetViewport,0x8013F1B0,0xA -asm/non_matchings/code/z_view/View_WriteScissor.s,View_WriteScissor,0x8013F1D8,0x2D -asm/non_matchings/code/z_view/View_SyncAndWriteScissor.s,View_SyncAndWriteScissor,0x8013F28C,0x1B -asm/non_matchings/code/z_view/View_SetScissorForLetterbox.s,View_SetScissorForLetterbox,0x8013F2F8,0x40 -asm/non_matchings/code/z_view/View_SetDistortionDirRot.s,View_SetDistortionDirRot,0x8013F3F8,0xA +asm/non_matchings/code/z_view/View_SetScissor.s,View_SetScissor,0x8013F1D8,0x2D +asm/non_matchings/code/z_view/View_ClearScissor.s,View_ClearScissor,0x8013F28C,0x1B +asm/non_matchings/code/z_view/View_ApplyLetterbox.s,View_ApplyLetterbox,0x8013F2F8,0x40 +asm/non_matchings/code/z_view/View_SetDistortionOrientation.s,View_SetDistortionOrientation,0x8013F3F8,0xA asm/non_matchings/code/z_view/View_SetDistortionScale.s,View_SetDistortionScale,0x8013F420,0xA asm/non_matchings/code/z_view/View_SetDistortionSpeed.s,View_SetDistortionSpeed,0x8013F448,0x5 asm/non_matchings/code/z_view/View_InitDistortion.s,View_InitDistortion,0x8013F45C,0x19 asm/non_matchings/code/z_view/View_ClearDistortion.s,View_ClearDistortion,0x8013F4C0,0xD asm/non_matchings/code/z_view/View_SetDistortion.s,View_SetDistortion,0x8013F4F4,0x16 asm/non_matchings/code/z_view/View_StepDistortion.s,View_StepDistortion,0x8013F54C,0x6C -asm/non_matchings/code/z_view/View_RenderView.s,View_RenderView,0x8013F6FC,0x13 -asm/non_matchings/code/z_view/View_RenderToPerspectiveMatrix.s,View_RenderToPerspectiveMatrix,0x8013F748,0xB5 -asm/non_matchings/code/z_view/View_RenderToOrthographicMatrix.s,View_RenderToOrthographicMatrix,0x8013FA1C,0x6B -asm/non_matchings/code/z_view/func_8013FBC8.s,func_8013FBC8,0x8013FBC8,0x6B -asm/non_matchings/code/z_view/func_8013FD74.s,func_8013FD74,0x8013FD74,0xAC -asm/non_matchings/code/z_view/func_80140024.s,func_80140024,0x80140024,0x2A -asm/non_matchings/code/z_view/func_801400CC.s,func_801400CC,0x801400CC,0x65 +asm/non_matchings/code/z_view/View_Apply.s,View_Apply,0x8013F6FC,0x13 +asm/non_matchings/code/z_view/View_ApplyPerspective.s,View_ApplyPerspective,0x8013F748,0xB5 +asm/non_matchings/code/z_view/View_ApplyOrtho.s,View_ApplyOrtho,0x8013FA1C,0x6B +asm/non_matchings/code/z_view/View_ApplyOrthoToOverlay.s,View_ApplyOrthoToOverlay,0x8013FBC8,0x6B +asm/non_matchings/code/z_view/View_ApplyPerspectiveToOverlay.s,View_ApplyPerspectiveToOverlay,0x8013FD74,0xAC +asm/non_matchings/code/z_view/View_UpdateViewingMatrix.s,View_UpdateViewingMatrix,0x80140024,0x2A +asm/non_matchings/code/z_view/View_ApplyTo.s,View_ApplyTo,0x801400CC,0x65 asm/non_matchings/code/z_vimode/func_80140260.s,func_80140260,0x80140260,0x3 asm/non_matchings/code/z_vimode/func_8014026C.s,func_8014026C,0x8014026C,0x131 asm/non_matchings/code/z_vimode/func_80140730.s,func_80140730,0x80140730,0x38 @@ -2283,20 +2283,20 @@ 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 asm/non_matchings/code/z_vr_box/func_80142440.s,func_80142440,0x80142440,0x342 asm/non_matchings/code/z_vr_box/func_80143148.s,func_80143148,0x80143148,0x28 -asm/non_matchings/code/z_vr_box/func_801431E8.s,func_801431E8,0x801431E8,0x4F +asm/non_matchings/code/z_vr_box/Skybox_Setup.s,Skybox_Setup,0x801431E8,0x4F asm/non_matchings/code/z_vr_box/func_80143324.s,func_80143324,0x80143324,0x70 -asm/non_matchings/code/z_vr_box/func_801434E4.s,func_801434E4,0x801434E4,0x2F +asm/non_matchings/code/z_vr_box/Skybox_Init.s,Skybox_Init,0x801434E4,0x2F asm/non_matchings/code/z_vr_box_draw/func_801435A0.s,func_801435A0,0x801435A0,0x21 asm/non_matchings/code/z_vr_box_draw/func_80143624.s,func_80143624,0x80143624,0x11 asm/non_matchings/code/z_vr_box_draw/func_80143668.s,func_80143668,0x80143668,0xE7 @@ -2394,7 +2394,7 @@ asm/non_matchings/code/z_message_nes/Message_LoadPluralRupeesNES.s,Message_LoadP asm/non_matchings/code/z_message_nes/Message_LoadLocalizedRupeesNES.s,Message_LoadLocalizedRupeesNES,0x80158C04,0x65 asm/non_matchings/code/z_message_nes/Message_LoadRupeesNES.s,Message_LoadRupeesNES,0x80158D98,0x86 asm/non_matchings/code/z_message_nes/Message_LoadTimeNES.s,Message_LoadTimeNES,0x80158FB0,0xAF -asm/non_matchings/code/z_message_nes/Message_LoadAreaTextNES.s,Message_LoadAreaTextNES,0x8015926C,0x73 +asm/non_matchings/code/z_message_nes/Message_LoadOwlWarpTextNES.s,Message_LoadOwlWarpTextNES,0x8015926C,0x73 asm/non_matchings/code/z_message_nes/func_80159438.s,func_80159438,0x80159438,0x8D asm/non_matchings/code/z_message_nes/func_8015966C.s,func_8015966C,0x8015966C,0x6CB asm/non_matchings/code/z_message_nes/func_8015B198.s,func_8015B198,0x8015B198,0xD6E @@ -2406,14 +2406,14 @@ asm/non_matchings/code/z_player_call/PlayerCall_Init.s,PlayerCall_Init,0x80160AF asm/non_matchings/code/z_player_call/PlayerCall_Destroy.s,PlayerCall_Destroy,0x80160B40,0x10 asm/non_matchings/code/z_player_call/PlayerCall_Update.s,PlayerCall_Update,0x80160B80,0x10 asm/non_matchings/code/z_player_call/PlayerCall_Draw.s,PlayerCall_Draw,0x80160BC0,0x10 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxTarget.s,ShrinkWindow_SetLetterboxTarget,0x80160C00,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxTarget.s,ShrinkWindow_GetLetterboxTarget,0x80160C14,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetLetterboxMagnitude.s,ShrinkWindow_SetLetterboxMagnitude,0x80160C28,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetLetterboxMagnitude.s,ShrinkWindow_GetLetterboxMagnitude,0x80160C3C,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxTarget.s,ShrinkWindow_SetPillarboxTarget,0x80160C50,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxTarget.s,ShrinkWindow_GetPillarboxTarget,0x80160C64,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_SetPillarboxMagnitude.s,ShrinkWindow_SetPillarboxMagnitude,0x80160C78,0x5 -asm/non_matchings/code/z_shrink_window/ShrinkWindow_GetPillarboxMagnitude.s,ShrinkWindow_GetPillarboxMagnitude,0x80160C8C,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_SetSizeTarget.s,ShrinkWindow_Letterbox_SetSizeTarget,0x80160C00,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_GetSizeTarget.s,ShrinkWindow_Letterbox_GetSizeTarget,0x80160C14,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_SetSize.s,ShrinkWindow_Letterbox_SetSize,0x80160C28,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Letterbox_GetSize.s,ShrinkWindow_Letterbox_GetSize,0x80160C3C,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_SetSizeTarget.s,ShrinkWindow_Pillarbox_SetSizeTarget,0x80160C50,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_GetSizeTarget.s,ShrinkWindow_Pillarbox_GetSizeTarget,0x80160C64,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_SetSize.s,ShrinkWindow_Pillarbox_SetSize,0x80160C78,0x5 +asm/non_matchings/code/z_shrink_window/ShrinkWindow_Pillarbox_GetSize.s,ShrinkWindow_Pillarbox_GetSize,0x80160C8C,0x5 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Init.s,ShrinkWindow_Init,0x80160CA0,0xD asm/non_matchings/code/z_shrink_window/ShrinkWindow_Destroy.s,ShrinkWindow_Destroy,0x80160CD4,0x4 asm/non_matchings/code/z_shrink_window/ShrinkWindow_Update.s,ShrinkWindow_Update,0x80160CE4,0x2D @@ -2450,8 +2450,8 @@ asm/non_matchings/code/z_kaleido_scope_call/func_801639EC.s,func_801639EC,0x8016 asm/non_matchings/code/z_kaleido_scope_call/func_80163A38.s,func_80163A38,0x80163A38,0x8 asm/non_matchings/code/z_kaleido_scope_call/func_80163A58.s,func_80163A58,0x80163A58,0x6D asm/non_matchings/code/z_kaleido_scope_call/func_80163C0C.s,func_80163C0C,0x80163C0C,0x21 -asm/non_matchings/code/z_fbdemo_dlftbls/func_80163C90.s,func_80163C90,0x80163C90,0x3C -asm/non_matchings/code/z_fbdemo_dlftbls/func_80163D80.s,func_80163D80,0x80163D80,0x10 +asm/non_matchings/code/z_fbdemo_dlftbls/Transition_Init.s,Transition_Init,0x80163C90,0x3C +asm/non_matchings/code/z_fbdemo_dlftbls/Transition_Destroy.s,Transition_Destroy,0x80163D80,0x10 asm/non_matchings/code/z_fbdemo/func_80163DC0.s,func_80163DC0,0x80163DC0,0xF3 asm/non_matchings/code/z_fbdemo/func_8016418C.s,func_8016418C,0x8016418C,0x30 asm/non_matchings/code/z_fbdemo/func_8016424C.s,func_8016424C,0x8016424C,0x23 @@ -2478,12 +2478,12 @@ asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_SetType.s,TransitionCirc asm/non_matchings/code/z_fbdemo_circle/func_80164C14.s,func_80164C14,0x80164C14,0x10C asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_Draw.s,TransitionCircle_Draw,0x80165044,0x55 asm/non_matchings/code/z_fbdemo_circle/TransitionCircle_IsDone.s,TransitionCircle_IsDone,0x80165198,0x6 -asm/non_matchings/code/z_overlay/func_801651B0.s,func_801651B0,0x801651B0,0x1D -asm/non_matchings/code/z_overlay/func_80165224.s,func_80165224,0x80165224,0x19 -asm/non_matchings/code/z_overlay/func_80165288.s,func_80165288,0x80165288,0x3D -asm/non_matchings/code/z_overlay/func_8016537C.s,func_8016537C,0x8016537C,0x2F -asm/non_matchings/code/z_overlay/func_80165438.s,func_80165438,0x80165438,0x3 -asm/non_matchings/code/z_overlay/func_80165444.s,func_80165444,0x80165444,0x7 +asm/non_matchings/code/z_overlay/TransitionOverlay_VramToRam.s,TransitionOverlay_VramToRam,0x801651B0,0x1D +asm/non_matchings/code/z_overlay/TransitionOverlay_VramToRamArray.s,TransitionOverlay_VramToRamArray,0x80165224,0x19 +asm/non_matchings/code/z_overlay/TransitionOverlay_Load.s,TransitionOverlay_Load,0x80165288,0x3D +asm/non_matchings/code/z_overlay/TransitionOverlay_Free.s,TransitionOverlay_Free,0x8016537C,0x2F +asm/non_matchings/code/z_overlay/TransitionOverlay_ClearLoadInfo.s,TransitionOverlay_ClearLoadInfo,0x80165438,0x3 +asm/non_matchings/code/z_overlay/TransitionOverlay_SetSegment.s,TransitionOverlay_SetSegment,0x80165444,0x7 asm/non_matchings/code/z_play/func_80165460.s,func_80165460,0x80165460,0x6A asm/non_matchings/code/z_play/func_80165608.s,func_80165608,0x80165608,0xA asm/non_matchings/code/z_play/func_80165630.s,func_80165630,0x80165630,0xA @@ -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/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/Play_Destroy.s,Play_Destroy,0x8016613C,0xA2 +asm/non_matchings/code/z_play/Play_CompressI8ToI5.s,Play_CompressI8ToI5,0x801663C4,0xA0 +asm/non_matchings/code/z_play/Play_DecompressI5ToI8.s,Play_DecompressI5ToI8,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,26 +2519,26 @@ 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_GetOriginalSceneNumber.s,Play_GetOriginalSceneNumber,0x80169CBC,0x21 +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_GetOriginalSceneId.s,Play_GetOriginalSceneId,0x80169CBC,0x21 asm/non_matchings/code/z_play/Play_SaveCycleSceneFlags.s,Play_SaveCycleSceneFlags,0x80169D40,0x23 asm/non_matchings/code/z_play/Play_SetRespawnData.s,Play_SetRespawnData,0x80169DCC,0x28 asm/non_matchings/code/z_play/Play_SetupRespawnPoint.s,Play_SetupRespawnPoint,0x80169E6C,0x18 @@ -2550,9 +2550,9 @@ 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_FillScreen.s,Play_FillScreen,0x8016A268,0x18 asm/non_matchings/code/z_play/Play_Init.s,Play_Init,0x8016A2C8,0x252 asm/non_matchings/code/z_play_hireso/func_8016AC10.s,func_8016AC10,0x8016AC10,0x83 asm/non_matchings/code/z_play_hireso/func_8016AE1C.s,func_8016AE1C,0x8016AE1C,0x117 @@ -2623,17 +2623,17 @@ 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 asm/non_matchings/code/audioMgr/AudioMgr_ThreadEntry.s,AudioMgr_ThreadEntry,0x80172ED0,0x5E asm/non_matchings/code/audioMgr/AudioMgr_Unlock.s,AudioMgr_Unlock,0x80173048,0xB asm/non_matchings/code/audioMgr/AudioMgr_Init.s,AudioMgr_Init,0x80173074,0x2F -asm/non_matchings/code/title_setup/TitleSetup_GameStateResetContext.s,TitleSetup_GameStateResetContext,0x80173130,0x6B -asm/non_matchings/code/title_setup/TitleSetup_InitImpl.s,TitleSetup_InitImpl,0x801732DC,0x14 -asm/non_matchings/code/title_setup/TitleSetup_Destroy.s,TitleSetup_Destroy,0x8017332C,0x3 -asm/non_matchings/code/title_setup/TitleSetup_Init.s,TitleSetup_Init,0x80173338,0xA +asm/non_matchings/code/title_setup/Setup_SetRegs.s,Setup_SetRegs,0x80173130,0x6B +asm/non_matchings/code/title_setup/Setup_InitImpl.s,Setup_InitImpl,0x801732DC,0x14 +asm/non_matchings/code/title_setup/Setup_Destroy.s,Setup_Destroy,0x8017332C,0x3 +asm/non_matchings/code/title_setup/Setup_Init.s,Setup_Init,0x80173338,0xA asm/non_matchings/code/game/Game_UpdateFramerateVariables.s,Game_UpdateFramerateVariables,0x80173360,0x12 asm/non_matchings/code/game/Game_SetFramerateDivisor.s,Game_SetFramerateDivisor,0x801733A8,0xD asm/non_matchings/code/game/GameState_SetFBFilter.s,GameState_SetFBFilter,0x801733DC,0x56 @@ -2648,8 +2648,8 @@ asm/non_matchings/code/game/Game_InitHeap.s,Game_InitHeap,0x80173810,0x1C asm/non_matchings/code/game/Game_ResizeHeap.s,Game_ResizeHeap,0x80173880,0x34 asm/non_matchings/code/game/GameState_Init.s,GameState_Init,0x80173950,0x40 asm/non_matchings/code/game/GameState_Destroy.s,GameState_Destroy,0x80173A50,0x2C -asm/non_matchings/code/game/GameState_GetNextStateInit.s,GameState_GetNextStateInit,0x80173B00,0x3 -asm/non_matchings/code/game/GameState_GetNextStateSize.s,GameState_GetNextStateSize,0x80173B0C,0x3 +asm/non_matchings/code/game/GameState_GetInit.s,GameState_GetInit,0x80173B00,0x3 +asm/non_matchings/code/game/GameState_GetSize.s,GameState_GetSize,0x80173B0C,0x3 asm/non_matchings/code/game/GameState_IsRunning.s,GameState_IsRunning,0x80173B18,0x3 asm/non_matchings/code/game/Game_GetHeapFreeSize.s,Game_GetHeapFreeSize,0x80173B24,0x9 asm/non_matchings/code/game/func_80173B48.s,func_80173B48,0x80173B48,0x2A @@ -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 @@ -2866,8 +2866,8 @@ asm/non_matchings/code/sys_math3d/func_8017FD44.s,func_8017FD44,0x8017FD44,0x5B asm/non_matchings/code/sys_math_atan/Math_GetAtan2Tbl.s,Math_GetAtan2Tbl,0x8017FEB0,0xD 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_math_atan/Math_Atan2S_XY.s,Math_Atan2S_XY,0x80180100,0xB +asm/non_matchings/code/sys_math_atan/Math_Atan2F_XY.s,Math_Atan2F_XY,0x8018012C,0xD 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 @@ -2911,9 +2911,9 @@ asm/non_matchings/code/sys_ucode/SysUcode_GetUCodeBoot.s,SysUcode_GetUCodeBoot,0 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 @@ -2996,74 +2996,74 @@ asm/non_matchings/code/osFlash/func_80187284.s,func_80187284,0x80187284,0x1E asm/non_matchings/code/osFlash/func_801872FC.s,func_801872FC,0x801872FC,0x30 asm/non_matchings/code/osFlash/func_801873BC.s,func_801873BC,0x801873BC,0x5C asm/non_matchings/code/osFlash/func_8018752C.s,func_8018752C,0x8018752C,0x9D -asm/non_matchings/code/audio_synthesis/func_801877D0.s,func_801877D0,0x801877D0,0xE5 -asm/non_matchings/code/audio_synthesis/func_80187B64.s,func_80187B64,0x80187B64,0x22 -asm/non_matchings/code/audio_synthesis/func_80187BEC.s,func_80187BEC,0x80187BEC,0x7F -asm/non_matchings/code/audio_synthesis/func_80187DE8.s,func_80187DE8,0x80187DE8,0x1C -asm/non_matchings/code/audio_synthesis/func_80187E58.s,func_80187E58,0x80187E58,0x2A -asm/non_matchings/code/audio_synthesis/func_80187F00.s,func_80187F00,0x80187F00,0x2A -asm/non_matchings/code/audio_synthesis/func_80187FA8.s,func_80187FA8,0x80187FA8,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FB0.s,func_80187FB0,0x80187FB0,0x8 -asm/non_matchings/code/audio_synthesis/func_80187FD0.s,func_80187FD0,0x80187FD0,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FD8.s,func_80187FD8,0x80187FD8,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FE0.s,func_80187FE0,0x80187FE0,0x2 -asm/non_matchings/code/audio_synthesis/func_80187FE8.s,func_80187FE8,0x80187FE8,0xD -asm/non_matchings/code/audio_synthesis/func_8018801C.s,func_8018801C,0x8018801C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188024.s,func_80188024,0x80188024,0x2 -asm/non_matchings/code/audio_synthesis/func_8018802C.s,func_8018802C,0x8018802C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188034.s,func_80188034,0x80188034,0xD -asm/non_matchings/code/audio_synthesis/func_80188068.s,func_80188068,0x80188068,0x2 -asm/non_matchings/code/audio_synthesis/func_80188070.s,func_80188070,0x80188070,0x2 -asm/non_matchings/code/audio_synthesis/func_80188078.s,func_80188078,0x80188078,0xB -asm/non_matchings/code/audio_synthesis/func_801880A4.s,func_801880A4,0x801880A4,0x2 -asm/non_matchings/code/audio_synthesis/func_801880AC.s,func_801880AC,0x801880AC,0x2 -asm/non_matchings/code/audio_synthesis/func_801880B4.s,func_801880B4,0x801880B4,0x2 -asm/non_matchings/code/audio_synthesis/func_801880BC.s,func_801880BC,0x801880BC,0x2 -asm/non_matchings/code/audio_synthesis/func_801880C4.s,func_801880C4,0x801880C4,0x9 -asm/non_matchings/code/audio_synthesis/func_801880E8.s,func_801880E8,0x801880E8,0xD -asm/non_matchings/code/audio_synthesis/func_8018811C.s,func_8018811C,0x8018811C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188124.s,func_80188124,0x80188124,0xA -asm/non_matchings/code/audio_synthesis/func_8018814C.s,func_8018814C,0x8018814C,0xA -asm/non_matchings/code/audio_synthesis/func_80188174.s,func_80188174,0x80188174,0x7 -asm/non_matchings/code/audio_synthesis/func_80188190.s,func_80188190,0x80188190,0x2 -asm/non_matchings/code/audio_synthesis/func_80188198.s,func_80188198,0x80188198,0x2 -asm/non_matchings/code/audio_synthesis/func_801881A0.s,func_801881A0,0x801881A0,0x2 -asm/non_matchings/code/audio_synthesis/func_801881A8.s,func_801881A8,0x801881A8,0x7 -asm/non_matchings/code/audio_synthesis/func_801881C4.s,func_801881C4,0x801881C4,0xD -asm/non_matchings/code/audio_synthesis/func_801881F8.s,func_801881F8,0x801881F8,0xB -asm/non_matchings/code/audio_synthesis/func_80188224.s,func_80188224,0x80188224,0x2 -asm/non_matchings/code/audio_synthesis/func_8018822C.s,func_8018822C,0x8018822C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188234.s,func_80188234,0x80188234,0x2 -asm/non_matchings/code/audio_synthesis/func_8018823C.s,func_8018823C,0x8018823C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188244.s,func_80188244,0x80188244,0x2 -asm/non_matchings/code/audio_synthesis/func_8018824C.s,func_8018824C,0x8018824C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188254.s,func_80188254,0x80188254,0x2 -asm/non_matchings/code/audio_synthesis/func_8018825C.s,func_8018825C,0x8018825C,0x2 -asm/non_matchings/code/audio_synthesis/func_80188264.s,func_80188264,0x80188264,0x9 -asm/non_matchings/code/audio_synthesis/func_80188288.s,func_80188288,0x80188288,0x6 -asm/non_matchings/code/audio_synthesis/func_801882A0.s,func_801882A0,0x801882A0,0x19 -asm/non_matchings/code/audio_synthesis/func_80188304.s,func_80188304,0x80188304,0x67 -asm/non_matchings/code/audio_synthesis/func_801884A0.s,func_801884A0,0x801884A0,0x7E -asm/non_matchings/code/audio_synthesis/func_80188698.s,func_80188698,0x80188698,0x69 -asm/non_matchings/code/audio_synthesis/func_8018883C.s,func_8018883C,0x8018883C,0x2A -asm/non_matchings/code/audio_synthesis/func_801888E4.s,func_801888E4,0x801888E4,0x30 -asm/non_matchings/code/audio_synthesis/func_801889A4.s,func_801889A4,0x801889A4,0x2B -asm/non_matchings/code/audio_synthesis/func_80188A50.s,func_80188A50,0x80188A50,0x2B -asm/non_matchings/code/audio_synthesis/func_80188AFC.s,func_80188AFC,0x80188AFC,0x53 -asm/non_matchings/code/audio_synthesis/func_80188C48.s,func_80188C48,0x80188C48,0x1B -asm/non_matchings/code/audio_synthesis/func_80188CB4.s,func_80188CB4,0x80188CB4,0x1B -asm/non_matchings/code/audio_synthesis/func_80188D20.s,func_80188D20,0x80188D20,0x2 -asm/non_matchings/code/audio_synthesis/func_80188D28.s,func_80188D28,0x80188D28,0x10 -asm/non_matchings/code/audio_synthesis/func_80188D68.s,func_80188D68,0x80188D68,0x1D -asm/non_matchings/code/audio_synthesis/func_80188DDC.s,func_80188DDC,0x80188DDC,0x78 -asm/non_matchings/code/audio_synthesis/func_80188FBC.s,func_80188FBC,0x80188FBC,0x2A -asm/non_matchings/code/audio_synthesis/func_80189064.s,func_80189064,0x80189064,0x16F -asm/non_matchings/code/audio_synthesis/func_80189620.s,func_80189620,0x80189620,0x3A5 -asm/non_matchings/code/audio_synthesis/func_8018A4B4.s,func_8018A4B4,0x8018A4B4,0xAD -asm/non_matchings/code/audio_synthesis/func_8018A768.s,func_8018A768,0x8018A768,0x28 -asm/non_matchings/code/audio_synthesis/func_8018A808.s,func_8018A808,0x8018A808,0x12F -asm/non_matchings/code/audio_synthesis/func_8018ACC4.s,func_8018ACC4,0x8018ACC4,0x5C -asm/non_matchings/code/audio_synthesis/func_8018AE34.s,func_8018AE34,0x8018AE34,0xAF +asm/non_matchings/code/audio_synthesis/AudioSynth_AddReverbBufferEntry.s,AudioSynth_AddReverbBufferEntry,0x801877D0,0xE5 +asm/non_matchings/code/audio_synthesis/AudioSynth_SyncSampleStates.s,AudioSynth_SyncSampleStates,0x80187B64,0x22 +asm/non_matchings/code/audio_synthesis/AudioSynth_Update.s,AudioSynth_Update,0x80187BEC,0x7F +asm/non_matchings/code/audio_synthesis/AudioSynth_DisableSampleStates.s,AudioSynth_DisableSampleStates,0x80187DE8,0x1C +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadMixedReverbSamples.s,AudioSynth_LoadMixedReverbSamples,0x80187E58,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveMixedReverbSamples.s,AudioSynth_SaveMixedReverbSamples,0x80187F00,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop1.s,AudioSynth_Noop1,0x80187FA8,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_ClearBuffer.s,AudioSynth_ClearBuffer,0x80187FB0,0x8 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop2.s,AudioSynth_Noop2,0x80187FD0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop3.s,AudioSynth_Noop3,0x80187FD8,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop4.s,AudioSynth_Noop4,0x80187FE0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Mix.s,AudioSynth_Mix,0x80187FE8,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop5.s,AudioSynth_Noop5,0x8018801C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop6.s,AudioSynth_Noop6,0x80188024,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop7.s,AudioSynth_Noop7,0x8018802C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_SetBuffer.s,AudioSynth_SetBuffer,0x80188034,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop8.s,AudioSynth_Noop8,0x80188068,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop9.s,AudioSynth_Noop9,0x80188070,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_DMemMove.s,AudioSynth_DMemMove,0x80188078,0xB +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop10.s,AudioSynth_Noop10,0x801880A4,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop11.s,AudioSynth_Noop11,0x801880AC,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop12.s,AudioSynth_Noop12,0x801880B4,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop13.s,AudioSynth_Noop13,0x801880BC,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_InterL.s,AudioSynth_InterL,0x801880C4,0x9 +asm/non_matchings/code/audio_synthesis/AudioSynth_EnvSetup1.s,AudioSynth_EnvSetup1,0x801880E8,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop14.s,AudioSynth_Noop14,0x8018811C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadBuffer.s,AudioSynth_LoadBuffer,0x80188124,0xA +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveBuffer.s,AudioSynth_SaveBuffer,0x8018814C,0xA +asm/non_matchings/code/audio_synthesis/AudioSynth_EnvSetup2.s,AudioSynth_EnvSetup2,0x80188174,0x7 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop15.s,AudioSynth_Noop15,0x80188190,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop16.s,AudioSynth_Noop16,0x80188198,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop17.s,AudioSynth_Noop17,0x801881A0,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_S8Dec.s,AudioSynth_S8Dec,0x801881A8,0x7 +asm/non_matchings/code/audio_synthesis/AudioSynth_HiLoGain.s,AudioSynth_HiLoGain,0x801881C4,0xD +asm/non_matchings/code/audio_synthesis/AudioSynth_UnkCmd19.s,AudioSynth_UnkCmd19,0x801881F8,0xB +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop18.s,AudioSynth_Noop18,0x80188224,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop19.s,AudioSynth_Noop19,0x8018822C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop20.s,AudioSynth_Noop20,0x80188234,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop21.s,AudioSynth_Noop21,0x8018823C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop22.s,AudioSynth_Noop22,0x80188244,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop23.s,AudioSynth_Noop23,0x8018824C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop24.s,AudioSynth_Noop24,0x80188254,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop25.s,AudioSynth_Noop25,0x8018825C,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadFilterBuffer.s,AudioSynth_LoadFilterBuffer,0x80188264,0x9 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadFilterSize.s,AudioSynth_LoadFilterSize,0x80188288,0x6 +asm/non_matchings/code/audio_synthesis/AudioSynth_LeakReverb.s,AudioSynth_LeakReverb,0x801882A0,0x19 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadDownsampledReverbSamples.s,AudioSynth_LoadDownsampledReverbSamples,0x80188304,0x67 +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveResampledReverbSamples.s,AudioSynth_SaveResampledReverbSamples,0x801884A0,0x7E +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadResampledReverbSamples.s,AudioSynth_LoadResampledReverbSamples,0x80188698,0x69 +asm/non_matchings/code/audio_synthesis/AudioSynth_FilterReverb.s,AudioSynth_FilterReverb,0x8018883C,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_MixOtherReverbIndex.s,AudioSynth_MixOtherReverbIndex,0x801888E4,0x30 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadDefaultReverbSamples.s,AudioSynth_LoadDefaultReverbSamples,0x801889A4,0x2B +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadSubReverbSamples.s,AudioSynth_LoadSubReverbSamples,0x80188A50,0x2B +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveResampledReverbSamplesImpl.s,AudioSynth_SaveResampledReverbSamplesImpl,0x80188AFC,0x53 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadReverbSamplesImpl.s,AudioSynth_LoadReverbSamplesImpl,0x80188C48,0x1B +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveReverbSamplesImpl.s,AudioSynth_SaveReverbSamplesImpl,0x80188CB4,0x1B +asm/non_matchings/code/audio_synthesis/AudioSynth_Noop26.s,AudioSynth_Noop26,0x80188D20,0x2 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadSubReverbSamplesWithoutDownsample.s,AudioSynth_LoadSubReverbSamplesWithoutDownsample,0x80188D28,0x10 +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadReverbSamples.s,AudioSynth_LoadReverbSamples,0x80188D68,0x1D +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveReverbSamples.s,AudioSynth_SaveReverbSamples,0x80188DDC,0x78 +asm/non_matchings/code/audio_synthesis/AudioSynth_SaveSubReverbSamples.s,AudioSynth_SaveSubReverbSamples,0x80188FBC,0x2A +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessSamples.s,AudioSynth_ProcessSamples,0x80189064,0x16F +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessSample.s,AudioSynth_ProcessSample,0x80189620,0x3A5 +asm/non_matchings/code/audio_synthesis/AudioSynth_ApplySurroundEffect.s,AudioSynth_ApplySurroundEffect,0x8018A4B4,0xAD +asm/non_matchings/code/audio_synthesis/AudioSynth_FinalResample.s,AudioSynth_FinalResample,0x8018A768,0x28 +asm/non_matchings/code/audio_synthesis/AudioSynth_ProcessEnvelope.s,AudioSynth_ProcessEnvelope,0x8018A808,0x12F +asm/non_matchings/code/audio_synthesis/AudioSynth_LoadWaveSamples.s,AudioSynth_LoadWaveSamples,0x8018ACC4,0x5C +asm/non_matchings/code/audio_synthesis/AudioSynth_ApplyHaasEffect.s,AudioSynth_ApplyHaasEffect,0x8018AE34,0xAF asm/non_matchings/code/audio_heap/AudioHeap_ResetLoadStatus.s,AudioHeap_ResetLoadStatus,0x8018B250,0x32 asm/non_matchings/code/audio_heap/AudioHeap_DiscardFont.s,AudioHeap_DiscardFont,0x8018B318,0x39 asm/non_matchings/code/audio_heap/AudioHeap_ReleaseNotesForFont.s,AudioHeap_ReleaseNotesForFont,0x8018B3FC,0x1E @@ -3076,16 +3076,16 @@ asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemoryZeroed.s,AudioHeap_All asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s,AudioHeap_AllocZeroed,0x8018B640,0x17 asm/non_matchings/code/audio_heap/AudioHeap_TestAlloc.s,AudioHeap_TestAlloc,0x8018B69C,0x13 asm/non_matchings/code/audio_heap/Audio_Alloc.s,Audio_Alloc,0x8018B6E8,0x16 -asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s,AudioHeap_AllocPoolInit,0x8018B740,0xA -asm/non_matchings/code/audio_heap/AudioHeap_ClearPersistentCache.s,AudioHeap_ClearPersistentCache,0x8018B768,0x5 -asm/non_matchings/code/audio_heap/AudioHeap_ClearTemporaryCache.s,AudioHeap_ClearTemporaryCache,0x8018B77C,0xC +asm/non_matchings/code/audio_heap/AudioHeap_InitPool.s,AudioHeap_InitPool,0x8018B740,0xA +asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018B768,0x5 +asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,0x8018B77C,0xC asm/non_matchings/code/audio_heap/AudioHeap_ResetPool.s,AudioHeap_ResetPool,0x8018B7AC,0x4 -asm/non_matchings/code/audio_heap/AudioHeap_PopCache.s,AudioHeap_PopCache,0x8018B7BC,0x50 +asm/non_matchings/code/audio_heap/AudioHeap_PopPersistentCache.s,AudioHeap_PopPersistentCache,0x8018B7BC,0x50 asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s,AudioHeap_InitMainPool,0x8018B8FC,0x18 asm/non_matchings/code/audio_heap/AudioHeap_InitSessionPool.s,AudioHeap_InitSessionPool,0x8018B95C,0x21 asm/non_matchings/code/audio_heap/AudioHeap_InitCachePool.s,AudioHeap_InitCachePool,0x8018B9E0,0x21 -asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018BA64,0x31 -asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,0x8018BB28,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentPoolsAndCaches.s,AudioHeap_InitPersistentPoolsAndCaches,0x8018BA64,0x31 +asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryPoolsAndCaches.s,AudioHeap_InitTemporaryPoolsAndCaches,0x8018BB28,0x31 asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s,AudioHeap_AllocCached,0x8018BBEC,0x1E5 asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s,AudioHeap_SearchCaches,0x8018C380,0x16 asm/non_matchings/code/audio_heap/AudioHeap_SearchRegularCaches.s,AudioHeap_SearchRegularCaches,0x8018C3D8,0x43 @@ -3161,7 +3161,7 @@ asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadInner.s,AudioLoad_AsyncLoad asm/non_matchings/code/audio_load/AudioLoad_ProcessLoads.s,AudioLoad_ProcessLoads,0x80190B08,0xC asm/non_matchings/code/audio_load/AudioLoad_SetDmaHandler.s,AudioLoad_SetDmaHandler,0x80190B38,0x3 asm/non_matchings/code/audio_load/AudioLoad_SetUnusedHandler.s,AudioLoad_SetUnusedHandler,0x80190B44,0x3 -asm/non_matchings/code/audio_load/AudioLoad_InitSoundFontMeta.s,AudioLoad_InitSoundFontMeta,0x80190B50,0x18 +asm/non_matchings/code/audio_load/AudioLoad_InitSoundFont.s,AudioLoad_InitSoundFont,0x80190B50,0x18 asm/non_matchings/code/audio_load/AudioLoad_Init.s,AudioLoad_Init,0x80190BB0,0xE8 asm/non_matchings/code/audio_load/AudioLoad_InitSlowLoads.s,AudioLoad_InitSlowLoads,0x80190F50,0x5 asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSample.s,AudioLoad_SlowLoadSample,0x80190F64,0x74 @@ -3196,61 +3196,61 @@ asm/non_matchings/code/audio_load/AudioLoad_Unused5.s,AudioLoad_Unused5,0x80192A asm/non_matchings/code/audio_load/AudioLoad_ScriptLoad.s,AudioLoad_ScriptLoad,0x80192AE8,0x1B asm/non_matchings/code/audio_load/AudioLoad_ProcessScriptLoads.s,AudioLoad_ProcessScriptLoads,0x80192B54,0x16 asm/non_matchings/code/audio_load/AudioLoad_InitScriptLoads.s,AudioLoad_InitScriptLoads,0x80192BAC,0xD -asm/non_matchings/code/code_80192BE0/func_80192BE0.s,func_80192BE0,0x80192BE0,0x8 -asm/non_matchings/code/code_80192BE0/func_80192C00.s,func_80192C00,0x80192C00,0x167 -asm/non_matchings/code/code_80192BE0/func_8019319C.s,func_8019319C,0x8019319C,0x14F -asm/non_matchings/code/code_80192BE0/func_801936D8.s,func_801936D8,0x801936D8,0x15 -asm/non_matchings/code/code_80192BE0/func_8019372C.s,func_8019372C,0x8019372C,0x12 -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/func_801938D0.s,func_801938D0,0x801938D0,0xC -asm/non_matchings/code/code_80192BE0/func_80193900.s,func_80193900,0x80193900,0x24 -asm/non_matchings/code/code_80192BE0/func_80193990.s,func_80193990,0x80193990,0x6 -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 -asm/non_matchings/code/code_80192BE0/func_80193BA0.s,func_80193BA0,0x80193BA0,0x19 -asm/non_matchings/code/code_80192BE0/func_80193C04.s,func_80193C04,0x80193C04,0x8 -asm/non_matchings/code/code_80192BE0/func_80193C24.s,func_80193C24,0x80193C24,0xE -asm/non_matchings/code/code_80192BE0/func_80193C5C.s,func_80193C5C,0x80193C5C,0x16 -asm/non_matchings/code/code_80192BE0/func_80193CB4.s,func_80193CB4,0x80193CB4,0x15 -asm/non_matchings/code/code_80192BE0/func_80193D08.s,func_80193D08,0x80193D08,0x27 -asm/non_matchings/code/code_80192BE0/func_80193DA4.s,func_80193DA4,0x80193DA4,0x13 -asm/non_matchings/code/code_80192BE0/func_80193DF0.s,func_80193DF0,0x80193DF0,0x15 -asm/non_matchings/code/code_80192BE0/func_80193E44.s,func_80193E44,0x80193E44,0xA -asm/non_matchings/code/code_80192BE0/func_80193E6C.s,func_80193E6C,0x80193E6C,0xC -asm/non_matchings/code/code_80192BE0/func_80193E9C.s,func_80193E9C,0x80193E9C,0x3 -asm/non_matchings/code/code_80192BE0/func_80193EA8.s,func_80193EA8,0x80193EA8,0x76 -asm/non_matchings/code/code_80192BE0/func_80194080.s,func_80194080,0x80194080,0x8F -asm/non_matchings/code/code_80192BE0/func_801942BC.s,func_801942BC,0x801942BC,0x12 -asm/non_matchings/code/code_80192BE0/func_80194304.s,func_80194304,0x80194304,0x9 -asm/non_matchings/code/code_80192BE0/func_80194328.s,func_80194328,0x80194328,0xD -asm/non_matchings/code/code_80192BE0/func_8019435C.s,func_8019435C,0x8019435C,0x10 -asm/non_matchings/code/code_80192BE0/func_8019439C.s,func_8019439C,0x8019439C,0xD -asm/non_matchings/code/code_80192BE0/func_801943D0.s,func_801943D0,0x801943D0,0xF -asm/non_matchings/code/code_80192BE0/func_8019440C.s,func_8019440C,0x8019440C,0x47 -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/audio_thread/AudioThread_Update.s,AudioThread_Update,0x80192BE0,0x8 +asm/non_matchings/code/audio_thread/AudioThread_UpdateImpl.s,AudioThread_UpdateImpl,0x80192C00,0x167 +asm/non_matchings/code/audio_thread/AudioThread_ProcessGlobalCmd.s,AudioThread_ProcessGlobalCmd,0x8019319C,0x14F +asm/non_matchings/code/audio_thread/AudioThread_SetFadeOutTimer.s,AudioThread_SetFadeOutTimer,0x801936D8,0x15 +asm/non_matchings/code/audio_thread/AudioThread_SetFadeInTimer.s,AudioThread_SetFadeInTimer,0x8019372C,0x12 +asm/non_matchings/code/audio_thread/AudioThread_InitMesgQueuesInternal.s,AudioThread_InitMesgQueuesInternal,0x80193774,0x26 +asm/non_matchings/code/audio_thread/AudioThread_QueueCmd.s,AudioThread_QueueCmd,0x8019380C,0x13 +asm/non_matchings/code/audio_thread/AudioThread_QueueCmdF32.s,AudioThread_QueueCmdF32,0x80193858,0x9 +asm/non_matchings/code/audio_thread/AudioThread_QueueCmdS32.s,AudioThread_QueueCmdS32,0x8019387C,0x9 +asm/non_matchings/code/audio_thread/AudioThread_QueueCmdS8.s,AudioThread_QueueCmdS8,0x801938A0,0xC +asm/non_matchings/code/audio_thread/AudioThread_QueueCmdU16.s,AudioThread_QueueCmdU16,0x801938D0,0xC +asm/non_matchings/code/audio_thread/AudioThread_ScheduleProcessCmds.s,AudioThread_ScheduleProcessCmds,0x80193900,0x24 +asm/non_matchings/code/audio_thread/AudioThread_ResetCmdQueue.s,AudioThread_ResetCmdQueue,0x80193990,0x6 +asm/non_matchings/code/audio_thread/AudioThread_ProcessCmd.s,AudioThread_ProcessCmd,0x801939A8,0x51 +asm/non_matchings/code/audio_thread/AudioThread_ProcessCmds.s,AudioThread_ProcessCmds,0x80193AEC,0x2D +asm/non_matchings/code/audio_thread/AudioThread_GetExternalLoadQueueMsg.s,AudioThread_GetExternalLoadQueueMsg,0x80193BA0,0x19 +asm/non_matchings/code/audio_thread/AudioThread_GetFontsForSequence.s,AudioThread_GetFontsForSequence,0x80193C04,0x8 +asm/non_matchings/code/audio_thread/AudioThread_GetSampleBankIdsOfFont.s,AudioThread_GetSampleBankIdsOfFont,0x80193C24,0xE +asm/non_matchings/code/audio_thread/func_80193C5C.s,func_80193C5C,0x80193C5C,0x16 +asm/non_matchings/code/audio_thread/AudioThread_WaitForAudioResetQueueP.s,AudioThread_WaitForAudioResetQueueP,0x80193CB4,0x15 +asm/non_matchings/code/audio_thread/AudioThread_ResetAudioHeap.s,AudioThread_ResetAudioHeap,0x80193D08,0x27 +asm/non_matchings/code/audio_thread/AudioThread_PreNMIInternal.s,AudioThread_PreNMIInternal,0x80193DA4,0x13 +asm/non_matchings/code/audio_thread/AudioThread_GetChannelIO.s,AudioThread_GetChannelIO,0x80193DF0,0x15 +asm/non_matchings/code/audio_thread/AudioThread_GetSeqPlayerIO.s,AudioThread_GetSeqPlayerIO,0x80193E44,0xA +asm/non_matchings/code/audio_thread/AudioThread_InitExternalPool.s,AudioThread_InitExternalPool,0x80193E6C,0xC +asm/non_matchings/code/audio_thread/AudioThread_ResetExternalPool.s,AudioThread_ResetExternalPool,0x80193E9C,0x3 +asm/non_matchings/code/audio_thread/AudioThread_ProcessSeqPlayerCmd.s,AudioThread_ProcessSeqPlayerCmd,0x80193EA8,0x76 +asm/non_matchings/code/audio_thread/AudioThread_ProcessChannelCmd.s,AudioThread_ProcessChannelCmd,0x80194080,0x8F +asm/non_matchings/code/audio_thread/AudioThread_Noop1Cmd.s,AudioThread_Noop1Cmd,0x801942BC,0x12 +asm/non_matchings/code/audio_thread/AudioThread_Noop1CmdZeroed.s,AudioThread_Noop1CmdZeroed,0x80194304,0x9 +asm/non_matchings/code/audio_thread/AudioThread_Noop2Cmd.s,AudioThread_Noop2Cmd,0x80194328,0xD +asm/non_matchings/code/audio_thread/AudioThread_WaitForAudioTask.s,AudioThread_WaitForAudioTask,0x8019435C,0x10 +asm/non_matchings/code/audio_thread/AudioThread_GetSamplePosFromStart.s,AudioThread_GetSamplePosFromStart,0x8019439C,0xD +asm/non_matchings/code/audio_thread/AudioThread_GetSamplePosUntilEnd.s,AudioThread_GetSamplePosUntilEnd,0x801943D0,0xF +asm/non_matchings/code/audio_thread/AudioThread_GetSamplePos.s,AudioThread_GetSamplePos,0x8019440C,0x47 +asm/non_matchings/code/audio_thread/AudioThread_GetEnabledNotesCount.s,AudioThread_GetEnabledNotesCount,0x80194528,0x8 +asm/non_matchings/code/audio_thread/AudioThread_GetEnabledSampledNotesCount.s,AudioThread_GetEnabledSampledNotesCount,0x80194548,0x8 +asm/non_matchings/code/audio_thread/AudioThread_CountAndReleaseNotes.s,AudioThread_CountAndReleaseNotes,0x80194568,0x40 +asm/non_matchings/code/audio_thread/AudioThread_NextRandom.s,AudioThread_NextRandom,0x80194668,0x1F +asm/non_matchings/code/audio_thread/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 -asm/non_matchings/code/audio_playback/AudioPlayback_InitNoteSub.s,AudioPlayback_InitNoteSub,0x80194930,0x120 +asm/non_matchings/code/audio_playback/AudioPlayback_InitSampleState.s,AudioPlayback_InitSampleState,0x80194930,0x120 asm/non_matchings/code/audio_playback/AudioPlayback_NoteSetResamplingRate.s,AudioPlayback_NoteSetResamplingRate,0x80194DB0,0x2C asm/non_matchings/code/audio_playback/AudioPlayback_NoteInit.s,AudioPlayback_NoteInit,0x80194E60,0x30 asm/non_matchings/code/audio_playback/AudioPlayback_NoteDisable.s,AudioPlayback_NoteDisable,0x80194F20,0x19 asm/non_matchings/code/audio_playback/AudioPlayback_ProcessNotes.s,AudioPlayback_ProcessNotes,0x80194F84,0x152 -asm/non_matchings/code/audio_playback/AudioPlayback_InstrumentGetSound.s,AudioPlayback_InstrumentGetSound,0x801954CC,0xF +asm/non_matchings/code/audio_playback/AudioPlayback_GetInstrumentTunedSample.s,AudioPlayback_GetInstrumentTunedSample,0x801954CC,0xF asm/non_matchings/code/audio_playback/AudioPlayback_GetInstrumentInner.s,AudioPlayback_GetInstrumentInner,0x80195508,0x35 asm/non_matchings/code/audio_playback/AudioPlayback_GetDrum.s,AudioPlayback_GetDrum,0x801955DC,0x39 -asm/non_matchings/code/audio_playback/AudioPlayback_GetSfx.s,AudioPlayback_GetSfx,0x801956C0,0x3D +asm/non_matchings/code/audio_playback/AudioPlayback_GetSoundEffect.s,AudioPlayback_GetSoundEffect,0x801956C0,0x3D asm/non_matchings/code/audio_playback/AudioPlayback_SetFontInstrument.s,AudioPlayback_SetFontInstrument,0x801957B4,0x51 asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerDecayRelease.s,AudioPlayback_SeqLayerDecayRelease,0x801958F8,0xD2 asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerNoteDecay.s,AudioPlayback_SeqLayerNoteDecay,0x80195C40,0x8 @@ -3283,118 +3283,118 @@ 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/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 -asm/non_matchings/code/code_8019AF00/func_8019E014.s,func_8019E014,0x8019E014,0x3A -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/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/Audio_Noop1.s,Audio_Noop1,0x8019DFF8,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Noop2.s,Audio_Noop2,0x8019E000,0x3 +asm/non_matchings/code/code_8019AF00/Audio_Noop3.s,Audio_Noop3,0x8019E00C,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Update.s,Audio_Update,0x8019E014,0x3A +asm/non_matchings/code/code_8019AF00/Audio_Noop4.s,Audio_Noop4,0x8019E0FC,0x2 +asm/non_matchings/code/code_8019AF00/Audio_Noop5.s,Audio_Noop5,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 @@ -3454,32 +3454,32 @@ asm/non_matchings/code/code_8019AF00/func_801A2090.s,func_801A2090,0x801A2090,0x asm/non_matchings/code/code_8019AF00/Audio_PlaySariaBgm.s,Audio_PlaySariaBgm,0x801A21FC,0x99 asm/non_matchings/code/code_8019AF00/Audio_ClearSariaBgm2.s,Audio_ClearSariaBgm2,0x801A2460,0x3 asm/non_matchings/code/code_8019AF00/func_801A246C.s,func_801A246C,0x801A246C,0x36 -asm/non_matchings/code/code_8019AF00/func_801A2544.s,func_801A2544,0x801A2544,0xE -asm/non_matchings/code/code_8019AF00/func_801A257C.s,func_801A257C,0x801A257C,0x1A -asm/non_matchings/code/code_8019AF00/func_801A25E4.s,func_801A25E4,0x801A25E4,0x23 -asm/non_matchings/code/code_8019AF00/func_801A2670.s,func_801A2670,0x801A2670,0x42 -asm/non_matchings/code/code_8019AF00/func_801A2778.s,func_801A2778,0x801A2778,0x1C +asm/non_matchings/code/code_8019AF00/Audio_PlayMorningSceneSequence.s,Audio_PlayMorningSceneSequence,0x801A2544,0xE +asm/non_matchings/code/code_8019AF00/Audio_StartMorningSceneSequence.s,Audio_StartMorningSceneSequence,0x801A257C,0x1A +asm/non_matchings/code/code_8019AF00/Audio_PlaySceneSequence.s,Audio_PlaySceneSequence,0x801A25E4,0x23 +asm/non_matchings/code/code_8019AF00/Audio_StartSceneSequence.s,Audio_StartSceneSequence,0x801A2670,0x42 +asm/non_matchings/code/code_8019AF00/Audio_UpdateSceneSequenceResumePoint.s,Audio_UpdateSceneSequenceResumePoint,0x801A2778,0x1C asm/non_matchings/code/code_8019AF00/func_801A27E8.s,func_801A27E8,0x801A27E8,0xD asm/non_matchings/code/code_8019AF00/func_801A281C.s,func_801A281C,0x801A281C,0x6E asm/non_matchings/code/code_8019AF00/func_801A29D4.s,func_801A29D4,0x801A29D4,0x79 asm/non_matchings/code/code_8019AF00/func_801A2BB8.s,func_801A2BB8,0x801A2BB8,0x1A asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x9 asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 -asm/non_matchings/code/code_8019AF00/func_801A2C88.s,func_801A2C88,0x801A2C88,0x33 -asm/non_matchings/code/code_8019AF00/func_801A2D54.s,func_801A2D54,0x801A2D54,0x23 +asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceInCutscene.s,Audio_PlaySequenceInCutscene,0x801A2C88,0x33 +asm/non_matchings/code/code_8019AF00/Audio_StopSequenceInCutscene.s,Audio_StopSequenceInCutscene,0x801A2D54,0x23 asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D -asm/non_matchings/code/code_8019AF00/func_801A2E54.s,func_801A2E54,0x801A2E54,0x21 -asm/non_matchings/code/code_8019AF00/func_801A2ED8.s,func_801A2ED8,0x801A2ED8,0x2C -asm/non_matchings/code/code_8019AF00/func_801A2F88.s,func_801A2F88,0x801A2F88,0xF -asm/non_matchings/code/code_8019AF00/func_801A2FC4.s,func_801A2FC4,0x801A2FC4,0xF +asm/non_matchings/code/code_8019AF00/Audio_PlayBgm_StorePrevBgm.s,Audio_PlayBgm_StorePrevBgm,0x801A2E54,0x21 +asm/non_matchings/code/code_8019AF00/Audio_RestorePrevBgm.s,Audio_RestorePrevBgm,0x801A2ED8,0x2C +asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience_StorePrevBgm.s,Audio_PlayAmbience_StorePrevBgm,0x801A2F88,0xF +asm/non_matchings/code/code_8019AF00/Audio_ForceRestorePreviousBgm.s,Audio_ForceRestorePreviousBgm,0x801A2FC4,0xF asm/non_matchings/code/code_8019AF00/func_801A3000.s,func_801A3000,0x801A3000,0xE asm/non_matchings/code/code_8019AF00/func_801A3038.s,func_801A3038,0x801A3038,0x18 -asm/non_matchings/code/code_8019AF00/func_801A3098.s,func_801A3098,0x801A3098,0x25 +asm/non_matchings/code/code_8019AF00/Audio_PlayFanfare.s,Audio_PlayFanfare,0x801A3098,0x25 asm/non_matchings/code/code_8019AF00/func_801A312C.s,func_801A312C,0x801A312C,0x30 asm/non_matchings/code/code_8019AF00/func_801A31EC.s,func_801A31EC,0x801A31EC,0x13 -asm/non_matchings/code/code_8019AF00/func_801A3238.s,func_801A3238,0x801A3238,0x25 -asm/non_matchings/code/code_8019AF00/func_801A32CC.s,func_801A32CC,0x801A32CC,0xB1 -asm/non_matchings/code/code_8019AF00/func_801A3590.s,func_801A3590,0x801A3590,0x58 +asm/non_matchings/code/code_8019AF00/Audio_PlaySequenceWithSeqPlayerIO.s,Audio_PlaySequenceWithSeqPlayerIO,0x801A3238,0x25 +asm/non_matchings/code/code_8019AF00/Audio_SetSequenceMode.s,Audio_SetSequenceMode,0x801A32CC,0xB1 +asm/non_matchings/code/code_8019AF00/Audio_UpdateEnemyBgmVolume.s,Audio_UpdateEnemyBgmVolume,0x801A3590,0x58 asm/non_matchings/code/code_8019AF00/func_801A36F0.s,func_801A36F0,0x801A36F0,0x98 asm/non_matchings/code/code_8019AF00/func_801A3950.s,func_801A3950,0x801A3950,0x2A asm/non_matchings/code/code_8019AF00/func_801A39F8.s,func_801A39F8,0x801A39F8,0x21 @@ -3498,7 +3498,7 @@ asm/non_matchings/code/code_8019AF00/Audio_SetCutsceneFlag.s,Audio_SetCutsceneFl asm/non_matchings/code/code_8019AF00/func_801A3F6C.s,func_801A3F6C,0x801A3F6C,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FB4.s,func_801A3FB4,0x801A3FB4,0x12 asm/non_matchings/code/code_8019AF00/func_801A3FFC.s,func_801A3FFC,0x801A3FFC,0x4 -asm/non_matchings/code/code_8019AF00/audio_setBGM.s,audio_setBGM,0x801A400C,0x13 +asm/non_matchings/code/code_8019AF00/Audio_SetSpec.s,Audio_SetSpec,0x801A400C,0x13 asm/non_matchings/code/code_8019AF00/func_801A4058.s,func_801A4058,0x801A4058,0x5C asm/non_matchings/code/code_8019AF00/func_801A41C8.s,func_801A41C8,0x801A41C8,0xC asm/non_matchings/code/code_8019AF00/func_801A41F8.s,func_801A41F8,0x801A41F8,0x29 @@ -3506,20 +3506,20 @@ 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 +asm/non_matchings/code/code_8019AF00/Audio_ResetRequestedSceneSeqId.s,Audio_ResetRequestedSceneSeqId,0x801A44C4,0x4 asm/non_matchings/code/code_8019AF00/func_801A44D4.s,func_801A44D4,0x801A44D4,0x89 asm/non_matchings/code/code_8019AF00/func_801A46F8.s,func_801A46F8,0x801A46F8,0x14 asm/non_matchings/code/code_8019AF00/func_801A4748.s,func_801A4748,0x801A4748,0x15 asm/non_matchings/code/code_8019AF00/func_801A479C.s,func_801A479C,0x801A479C,0x10 -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_SetAmbienceChannelIO.s,Audio_SetAmbienceChannelIO,0x801A47DC,0x41 +asm/non_matchings/code/code_8019AF00/Audio_StartAmbience.s,Audio_StartAmbience,0x801A48E0,0x52 +asm/non_matchings/code/code_8019AF00/Audio_PlayAmbience.s,Audio_PlayAmbience,0x801A4A28,0x56 +asm/non_matchings/code/code_8019AF00/Audio_SetAmbienceRandomBend.s,Audio_SetAmbienceRandomBend,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,34 +3546,34 @@ 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_801A7B10/func_801A7D04.s,func_801A7D04,0x801A7D04,0x20 +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/Audio_StopSequence.s,Audio_StopSequence,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 asm/non_matchings/code/code_801A7B10/func_801A89D0.s,func_801A89D0,0x801A89D0,0x20 -asm/non_matchings/code/code_801A7B10/func_801A8A50.s,func_801A8A50,0x801A8A50,0x1B +asm/non_matchings/code/code_801A7B10/Audio_GetActiveSequence.s,Audio_GetActiveSequence,0x801A8A50,0x1B asm/non_matchings/code/code_801A7B10/func_801A8ABC.s,func_801A8ABC,0x801A8ABC,0x16 asm/non_matchings/code/code_801A7B10/func_801A8B14.s,func_801A8B14,0x801A8B14,0x6 asm/non_matchings/code/code_801A7B10/func_801A8B2C.s,func_801A8B2C,0x801A8B2C,0x29 diff --git a/tools/weekeventregconvert.py b/tools/weekeventregconvert.py new file mode 100755 index 000000000..e2092e595 --- /dev/null +++ b/tools/weekeventregconvert.py @@ -0,0 +1,889 @@ +#!/usr/bin/env python3 + +import argparse +import re + +weekEventReg = { + ( 0 << 8) | 0x01: "WEEKEVENTREG_00_01", + ( 0 << 8) | 0x02: "WEEKEVENTREG_00_02", + ( 0 << 8) | 0x04: "WEEKEVENTREG_00_04", + ( 0 << 8) | 0x08: "WEEKEVENTREG_00_08", + ( 0 << 8) | 0x10: "WEEKEVENTREG_00_10", + ( 0 << 8) | 0x20: "WEEKEVENTREG_00_20", + ( 0 << 8) | 0x40: "WEEKEVENTREG_00_40", + ( 0 << 8) | 0x80: "WEEKEVENTREG_00_80", + ( 1 << 8) | 0x01: "WEEKEVENTREG_01_01", + ( 1 << 8) | 0x02: "WEEKEVENTREG_01_02", + ( 1 << 8) | 0x04: "WEEKEVENTREG_01_04", + ( 1 << 8) | 0x08: "WEEKEVENTREG_01_08", + ( 1 << 8) | 0x10: "WEEKEVENTREG_01_10", + ( 1 << 8) | 0x20: "WEEKEVENTREG_01_20", + ( 1 << 8) | 0x40: "WEEKEVENTREG_01_40", + ( 1 << 8) | 0x80: "WEEKEVENTREG_01_80", + ( 2 << 8) | 0x01: "WEEKEVENTREG_02_01", + ( 2 << 8) | 0x02: "WEEKEVENTREG_02_02", + ( 2 << 8) | 0x04: "WEEKEVENTREG_02_04", + ( 2 << 8) | 0x08: "WEEKEVENTREG_02_08", + ( 2 << 8) | 0x10: "WEEKEVENTREG_02_10", + ( 2 << 8) | 0x20: "WEEKEVENTREG_02_20", + ( 2 << 8) | 0x40: "WEEKEVENTREG_02_40", + ( 2 << 8) | 0x80: "WEEKEVENTREG_02_80", + ( 3 << 8) | 0x01: "WEEKEVENTREG_03_01", + ( 3 << 8) | 0x02: "WEEKEVENTREG_03_02", + ( 3 << 8) | 0x04: "WEEKEVENTREG_03_04", + ( 3 << 8) | 0x08: "WEEKEVENTREG_03_08", + ( 3 << 8) | 0x10: "WEEKEVENTREG_03_10", + ( 3 << 8) | 0x20: "WEEKEVENTREG_03_20", + ( 3 << 8) | 0x40: "WEEKEVENTREG_03_40", + ( 3 << 8) | 0x80: "WEEKEVENTREG_03_80", + ( 4 << 8) | 0x01: "WEEKEVENTREG_04_01", + ( 4 << 8) | 0x02: "WEEKEVENTREG_04_02", + ( 4 << 8) | 0x04: "WEEKEVENTREG_04_04", + ( 4 << 8) | 0x08: "WEEKEVENTREG_04_08", + ( 4 << 8) | 0x10: "WEEKEVENTREG_04_10", + ( 4 << 8) | 0x20: "WEEKEVENTREG_04_20", + ( 4 << 8) | 0x40: "WEEKEVENTREG_04_40", + ( 4 << 8) | 0x80: "WEEKEVENTREG_04_80", + ( 5 << 8) | 0x01: "WEEKEVENTREG_05_01", + ( 5 << 8) | 0x02: "WEEKEVENTREG_05_02", + ( 5 << 8) | 0x04: "WEEKEVENTREG_05_04", + ( 5 << 8) | 0x08: "WEEKEVENTREG_05_08", + ( 5 << 8) | 0x10: "WEEKEVENTREG_05_10", + ( 5 << 8) | 0x20: "WEEKEVENTREG_05_20", + ( 5 << 8) | 0x40: "WEEKEVENTREG_05_40", + ( 5 << 8) | 0x80: "WEEKEVENTREG_05_80", + ( 6 << 8) | 0x01: "WEEKEVENTREG_06_01", + ( 6 << 8) | 0x02: "WEEKEVENTREG_06_02", + ( 6 << 8) | 0x04: "WEEKEVENTREG_06_04", + ( 6 << 8) | 0x08: "WEEKEVENTREG_06_08", + ( 6 << 8) | 0x10: "WEEKEVENTREG_06_10", + ( 6 << 8) | 0x20: "WEEKEVENTREG_06_20", + ( 6 << 8) | 0x40: "WEEKEVENTREG_06_40", + ( 6 << 8) | 0x80: "WEEKEVENTREG_06_80", + ( 7 << 8) | 0x01: "WEEKEVENTREG_07_01", + ( 7 << 8) | 0x02: "WEEKEVENTREG_07_02", + ( 7 << 8) | 0x04: "WEEKEVENTREG_07_04", + ( 7 << 8) | 0x08: "WEEKEVENTREG_07_08", + ( 7 << 8) | 0x10: "WEEKEVENTREG_07_10", + ( 7 << 8) | 0x20: "WEEKEVENTREG_07_20", + ( 7 << 8) | 0x40: "WEEKEVENTREG_07_40", + ( 7 << 8) | 0x80: "WEEKEVENTREG_07_80", + ( 8 << 8) | 0x01: "WEEKEVENTREG_08_01", + ( 8 << 8) | 0x02: "WEEKEVENTREG_08_02", + ( 8 << 8) | 0x04: "WEEKEVENTREG_08_04", + ( 8 << 8) | 0x08: "WEEKEVENTREG_08_08", + ( 8 << 8) | 0x10: "WEEKEVENTREG_08_10", + ( 8 << 8) | 0x20: "WEEKEVENTREG_08_20", + ( 8 << 8) | 0x40: "WEEKEVENTREG_08_40", + ( 8 << 8) | 0x80: "WEEKEVENTREG_08_80", + ( 9 << 8) | 0x01: "WEEKEVENTREG_09_01", + ( 9 << 8) | 0x02: "WEEKEVENTREG_09_02", + ( 9 << 8) | 0x04: "WEEKEVENTREG_09_04", + ( 9 << 8) | 0x08: "WEEKEVENTREG_09_08", + ( 9 << 8) | 0x10: "WEEKEVENTREG_09_10", + ( 9 << 8) | 0x20: "WEEKEVENTREG_09_20", + ( 9 << 8) | 0x40: "WEEKEVENTREG_09_40", + ( 9 << 8) | 0x80: "WEEKEVENTREG_09_80", + (10 << 8) | 0x01: "WEEKEVENTREG_10_01", + (10 << 8) | 0x02: "WEEKEVENTREG_10_02", + (10 << 8) | 0x04: "WEEKEVENTREG_10_04", + (10 << 8) | 0x08: "WEEKEVENTREG_10_08", + (10 << 8) | 0x10: "WEEKEVENTREG_10_10", + (10 << 8) | 0x20: "WEEKEVENTREG_10_20", + (10 << 8) | 0x40: "WEEKEVENTREG_10_40", + (10 << 8) | 0x80: "WEEKEVENTREG_10_80", + (11 << 8) | 0x01: "WEEKEVENTREG_11_01", + (11 << 8) | 0x02: "WEEKEVENTREG_11_02", + (11 << 8) | 0x04: "WEEKEVENTREG_11_04", + (11 << 8) | 0x08: "WEEKEVENTREG_11_08", + (11 << 8) | 0x10: "WEEKEVENTREG_11_10", + (11 << 8) | 0x20: "WEEKEVENTREG_11_20", + (11 << 8) | 0x40: "WEEKEVENTREG_11_40", + (11 << 8) | 0x80: "WEEKEVENTREG_11_80", + (12 << 8) | 0x01: "WEEKEVENTREG_12_01", + (12 << 8) | 0x02: "WEEKEVENTREG_12_02", + (12 << 8) | 0x04: "WEEKEVENTREG_12_04", + (12 << 8) | 0x08: "WEEKEVENTREG_12_08", + (12 << 8) | 0x10: "WEEKEVENTREG_12_10", + (12 << 8) | 0x20: "WEEKEVENTREG_12_20", + (12 << 8) | 0x40: "WEEKEVENTREG_12_40", + (12 << 8) | 0x80: "WEEKEVENTREG_12_80", + (13 << 8) | 0x01: "WEEKEVENTREG_13_01", + (13 << 8) | 0x02: "WEEKEVENTREG_13_02", + (13 << 8) | 0x04: "WEEKEVENTREG_13_04", + (13 << 8) | 0x08: "WEEKEVENTREG_13_08", + (13 << 8) | 0x10: "WEEKEVENTREG_13_10", + (13 << 8) | 0x20: "WEEKEVENTREG_13_20", + (13 << 8) | 0x40: "WEEKEVENTREG_13_40", + (13 << 8) | 0x80: "WEEKEVENTREG_13_80", + (14 << 8) | 0x01: "WEEKEVENTREG_14_01", + (14 << 8) | 0x02: "WEEKEVENTREG_14_02", + (14 << 8) | 0x04: "WEEKEVENTREG_14_04", + (14 << 8) | 0x08: "WEEKEVENTREG_DRANK_CHATEAU_ROMANI", + (14 << 8) | 0x10: "WEEKEVENTREG_14_10", + (14 << 8) | 0x20: "WEEKEVENTREG_14_20", + (14 << 8) | 0x40: "WEEKEVENTREG_14_40", + (14 << 8) | 0x80: "WEEKEVENTREG_14_80", + (15 << 8) | 0x01: "WEEKEVENTREG_15_01", + (15 << 8) | 0x02: "WEEKEVENTREG_15_02", + (15 << 8) | 0x04: "WEEKEVENTREG_15_04", + (15 << 8) | 0x08: "WEEKEVENTREG_15_08", + (15 << 8) | 0x10: "WEEKEVENTREG_15_10", + (15 << 8) | 0x20: "WEEKEVENTREG_15_20", + (15 << 8) | 0x40: "WEEKEVENTREG_15_40", + (15 << 8) | 0x80: "WEEKEVENTREG_15_80", + (16 << 8) | 0x01: "WEEKEVENTREG_16_01", + (16 << 8) | 0x02: "WEEKEVENTREG_16_02", + (16 << 8) | 0x04: "WEEKEVENTREG_16_04", + (16 << 8) | 0x08: "WEEKEVENTREG_16_08", + (16 << 8) | 0x10: "WEEKEVENTREG_16_10", + (16 << 8) | 0x20: "WEEKEVENTREG_16_20", + (16 << 8) | 0x40: "WEEKEVENTREG_16_40", + (16 << 8) | 0x80: "WEEKEVENTREG_16_80", + (17 << 8) | 0x01: "WEEKEVENTREG_17_01", + (17 << 8) | 0x02: "WEEKEVENTREG_17_02", + (17 << 8) | 0x04: "WEEKEVENTREG_17_04", + (17 << 8) | 0x08: "WEEKEVENTREG_17_08", + (17 << 8) | 0x10: "WEEKEVENTREG_17_10", + (17 << 8) | 0x20: "WEEKEVENTREG_17_20", + (17 << 8) | 0x40: "WEEKEVENTREG_17_40", + (17 << 8) | 0x80: "WEEKEVENTREG_17_80", + (18 << 8) | 0x01: "WEEKEVENTREG_18_01", + (18 << 8) | 0x02: "WEEKEVENTREG_18_02", + (18 << 8) | 0x04: "WEEKEVENTREG_18_04", + (18 << 8) | 0x08: "WEEKEVENTREG_18_08", + (18 << 8) | 0x10: "WEEKEVENTREG_18_10", + (18 << 8) | 0x20: "WEEKEVENTREG_18_20", + (18 << 8) | 0x40: "WEEKEVENTREG_18_40", + (18 << 8) | 0x80: "WEEKEVENTREG_18_80", + (19 << 8) | 0x01: "WEEKEVENTREG_19_01", + (19 << 8) | 0x02: "WEEKEVENTREG_19_02", + (19 << 8) | 0x04: "WEEKEVENTREG_19_04", + (19 << 8) | 0x08: "WEEKEVENTREG_19_08", + (19 << 8) | 0x10: "WEEKEVENTREG_19_10", + (19 << 8) | 0x20: "WEEKEVENTREG_19_20", + (19 << 8) | 0x40: "WEEKEVENTREG_19_40", + (19 << 8) | 0x80: "WEEKEVENTREG_19_80", + (20 << 8) | 0x01: "WEEKEVENTREG_20_01", + (20 << 8) | 0x02: "WEEKEVENTREG_20_02", + (20 << 8) | 0x04: "WEEKEVENTREG_20_04", + (20 << 8) | 0x08: "WEEKEVENTREG_20_08", + (20 << 8) | 0x10: "WEEKEVENTREG_20_10", + (20 << 8) | 0x20: "WEEKEVENTREG_20_20", + (20 << 8) | 0x40: "WEEKEVENTREG_20_40", + (20 << 8) | 0x80: "WEEKEVENTREG_20_80", + (21 << 8) | 0x01: "WEEKEVENTREG_21_01", + (21 << 8) | 0x02: "WEEKEVENTREG_21_02", + (21 << 8) | 0x04: "WEEKEVENTREG_21_04", + (21 << 8) | 0x08: "WEEKEVENTREG_21_08", + (21 << 8) | 0x10: "WEEKEVENTREG_21_10", + (21 << 8) | 0x20: "WEEKEVENTREG_21_20", + (21 << 8) | 0x40: "WEEKEVENTREG_21_40", + (21 << 8) | 0x80: "WEEKEVENTREG_21_80", + (22 << 8) | 0x01: "WEEKEVENTREG_22_01", + (22 << 8) | 0x02: "WEEKEVENTREG_22_02", + (22 << 8) | 0x04: "WEEKEVENTREG_22_04", + (22 << 8) | 0x08: "WEEKEVENTREG_22_08", + (22 << 8) | 0x10: "WEEKEVENTREG_22_10", + (22 << 8) | 0x20: "WEEKEVENTREG_22_20", + (22 << 8) | 0x40: "WEEKEVENTREG_22_40", + (22 << 8) | 0x80: "WEEKEVENTREG_22_80", + (23 << 8) | 0x01: "WEEKEVENTREG_23_01", + (23 << 8) | 0x02: "WEEKEVENTREG_23_02", + (23 << 8) | 0x04: "WEEKEVENTREG_23_04", + (23 << 8) | 0x08: "WEEKEVENTREG_23_08", + (23 << 8) | 0x10: "WEEKEVENTREG_23_10", + (23 << 8) | 0x20: "WEEKEVENTREG_23_20", + (23 << 8) | 0x40: "WEEKEVENTREG_23_40", + (23 << 8) | 0x80: "WEEKEVENTREG_23_80", + (24 << 8) | 0x01: "WEEKEVENTREG_24_01", + (24 << 8) | 0x02: "WEEKEVENTREG_24_02", + (24 << 8) | 0x04: "WEEKEVENTREG_24_04", + (24 << 8) | 0x08: "WEEKEVENTREG_24_08", + (24 << 8) | 0x10: "WEEKEVENTREG_24_10", + (24 << 8) | 0x20: "WEEKEVENTREG_24_20", + (24 << 8) | 0x40: "WEEKEVENTREG_24_40", + (24 << 8) | 0x80: "WEEKEVENTREG_24_80", + (25 << 8) | 0x01: "WEEKEVENTREG_25_01", + (25 << 8) | 0x02: "WEEKEVENTREG_25_02", + (25 << 8) | 0x04: "WEEKEVENTREG_25_04", + (25 << 8) | 0x08: "WEEKEVENTREG_25_08", + (25 << 8) | 0x10: "WEEKEVENTREG_25_10", + (25 << 8) | 0x20: "WEEKEVENTREG_25_20", + (25 << 8) | 0x40: "WEEKEVENTREG_25_40", + (25 << 8) | 0x80: "WEEKEVENTREG_25_80", + (26 << 8) | 0x01: "WEEKEVENTREG_26_01", + (26 << 8) | 0x02: "WEEKEVENTREG_26_02", + (26 << 8) | 0x04: "WEEKEVENTREG_26_04", + (26 << 8) | 0x08: "WEEKEVENTREG_26_08", + (26 << 8) | 0x10: "WEEKEVENTREG_26_10", + (26 << 8) | 0x20: "WEEKEVENTREG_26_20", + (26 << 8) | 0x40: "WEEKEVENTREG_26_40", + (26 << 8) | 0x80: "WEEKEVENTREG_26_80", + (27 << 8) | 0x01: "WEEKEVENTREG_27_01", + (27 << 8) | 0x02: "WEEKEVENTREG_27_02", + (27 << 8) | 0x04: "WEEKEVENTREG_27_04", + (27 << 8) | 0x08: "WEEKEVENTREG_27_08", + (27 << 8) | 0x10: "WEEKEVENTREG_27_10", + (27 << 8) | 0x20: "WEEKEVENTREG_27_20", + (27 << 8) | 0x40: "WEEKEVENTREG_27_40", + (27 << 8) | 0x80: "WEEKEVENTREG_27_80", + (28 << 8) | 0x01: "WEEKEVENTREG_28_01", + (28 << 8) | 0x02: "WEEKEVENTREG_28_02", + (28 << 8) | 0x04: "WEEKEVENTREG_28_04", + (28 << 8) | 0x08: "WEEKEVENTREG_28_08", + (28 << 8) | 0x10: "WEEKEVENTREG_28_10", + (28 << 8) | 0x20: "WEEKEVENTREG_28_20", + (28 << 8) | 0x40: "WEEKEVENTREG_28_40", + (28 << 8) | 0x80: "WEEKEVENTREG_28_80", + (29 << 8) | 0x01: "WEEKEVENTREG_29_01", + (29 << 8) | 0x02: "WEEKEVENTREG_29_02", + (29 << 8) | 0x04: "WEEKEVENTREG_29_04", + (29 << 8) | 0x08: "WEEKEVENTREG_29_08", + (29 << 8) | 0x10: "WEEKEVENTREG_29_10", + (29 << 8) | 0x20: "WEEKEVENTREG_29_20", + (29 << 8) | 0x40: "WEEKEVENTREG_29_40", + (29 << 8) | 0x80: "WEEKEVENTREG_29_80", + (30 << 8) | 0x01: "WEEKEVENTREG_30_01", + (30 << 8) | 0x02: "WEEKEVENTREG_30_02", + (30 << 8) | 0x04: "WEEKEVENTREG_30_04", + (30 << 8) | 0x08: "WEEKEVENTREG_30_08", + (30 << 8) | 0x10: "WEEKEVENTREG_30_10", + (30 << 8) | 0x20: "WEEKEVENTREG_30_20", + (30 << 8) | 0x40: "WEEKEVENTREG_30_40", + (30 << 8) | 0x80: "WEEKEVENTREG_30_80", + (31 << 8) | 0x01: "WEEKEVENTREG_31_01", + (31 << 8) | 0x02: "WEEKEVENTREG_31_02", + (31 << 8) | 0x04: "WEEKEVENTREG_31_04", + (31 << 8) | 0x08: "WEEKEVENTREG_31_08", + (31 << 8) | 0x10: "WEEKEVENTREG_31_10", + (31 << 8) | 0x20: "WEEKEVENTREG_31_20", + (31 << 8) | 0x40: "WEEKEVENTREG_31_40", + (31 << 8) | 0x80: "WEEKEVENTREG_31_80", + (32 << 8) | 0x01: "WEEKEVENTREG_32_01", + (32 << 8) | 0x02: "WEEKEVENTREG_32_02", + (32 << 8) | 0x04: "WEEKEVENTREG_32_04", + (32 << 8) | 0x08: "WEEKEVENTREG_32_08", + (32 << 8) | 0x10: "WEEKEVENTREG_32_10", + (32 << 8) | 0x20: "WEEKEVENTREG_32_20", + (32 << 8) | 0x40: "WEEKEVENTREG_32_40", + (32 << 8) | 0x80: "WEEKEVENTREG_32_80", + (33 << 8) | 0x01: "WEEKEVENTREG_33_01", + (33 << 8) | 0x02: "WEEKEVENTREG_33_02", + (33 << 8) | 0x04: "WEEKEVENTREG_33_04", + (33 << 8) | 0x08: "WEEKEVENTREG_33_08", + (33 << 8) | 0x10: "WEEKEVENTREG_33_10", + (33 << 8) | 0x20: "WEEKEVENTREG_33_20", + (33 << 8) | 0x40: "WEEKEVENTREG_33_40", + (33 << 8) | 0x80: "WEEKEVENTREG_33_80", + (34 << 8) | 0x01: "WEEKEVENTREG_34_01", + (34 << 8) | 0x02: "WEEKEVENTREG_34_02", + (34 << 8) | 0x04: "WEEKEVENTREG_34_04", + (34 << 8) | 0x08: "WEEKEVENTREG_34_08", + (34 << 8) | 0x10: "WEEKEVENTREG_34_10", + (34 << 8) | 0x20: "WEEKEVENTREG_34_20", + (34 << 8) | 0x40: "WEEKEVENTREG_34_40", + (34 << 8) | 0x80: "WEEKEVENTREG_34_80", + (35 << 8) | 0x01: "WEEKEVENTREG_35_01", + (35 << 8) | 0x02: "WEEKEVENTREG_35_02", + (35 << 8) | 0x04: "WEEKEVENTREG_35_04", + (35 << 8) | 0x08: "WEEKEVENTREG_35_08", + (35 << 8) | 0x10: "WEEKEVENTREG_35_10", + (35 << 8) | 0x20: "WEEKEVENTREG_35_20", + (35 << 8) | 0x40: "WEEKEVENTREG_35_40", + (35 << 8) | 0x80: "WEEKEVENTREG_35_80", + (36 << 8) | 0x01: "WEEKEVENTREG_36_01", + (36 << 8) | 0x02: "WEEKEVENTREG_36_02", + (36 << 8) | 0x04: "WEEKEVENTREG_36_04", + (36 << 8) | 0x08: "WEEKEVENTREG_36_08", + (36 << 8) | 0x10: "WEEKEVENTREG_36_10", + (36 << 8) | 0x20: "WEEKEVENTREG_36_20", + (36 << 8) | 0x40: "WEEKEVENTREG_36_40", + (36 << 8) | 0x80: "WEEKEVENTREG_36_80", + (37 << 8) | 0x01: "WEEKEVENTREG_37_01", + (37 << 8) | 0x02: "WEEKEVENTREG_37_02", + (37 << 8) | 0x04: "WEEKEVENTREG_37_04", + (37 << 8) | 0x08: "WEEKEVENTREG_37_08", + (37 << 8) | 0x10: "WEEKEVENTREG_37_10", + (37 << 8) | 0x20: "WEEKEVENTREG_37_20", + (37 << 8) | 0x40: "WEEKEVENTREG_37_40", + (37 << 8) | 0x80: "WEEKEVENTREG_37_80", + (38 << 8) | 0x01: "WEEKEVENTREG_38_01", + (38 << 8) | 0x02: "WEEKEVENTREG_38_02", + (38 << 8) | 0x04: "WEEKEVENTREG_38_04", + (38 << 8) | 0x08: "WEEKEVENTREG_38_08", + (38 << 8) | 0x10: "WEEKEVENTREG_38_10", + (38 << 8) | 0x20: "WEEKEVENTREG_38_20", + (38 << 8) | 0x40: "WEEKEVENTREG_38_40", + (38 << 8) | 0x80: "WEEKEVENTREG_38_80", + (39 << 8) | 0x01: "WEEKEVENTREG_39_01", + (39 << 8) | 0x02: "WEEKEVENTREG_39_02", + (39 << 8) | 0x04: "WEEKEVENTREG_39_04", + (39 << 8) | 0x08: "WEEKEVENTREG_39_08", + (39 << 8) | 0x10: "WEEKEVENTREG_39_10", + (39 << 8) | 0x20: "WEEKEVENTREG_39_20", + (39 << 8) | 0x40: "WEEKEVENTREG_39_40", + (39 << 8) | 0x80: "WEEKEVENTREG_39_80", + (40 << 8) | 0x01: "WEEKEVENTREG_40_01", + (40 << 8) | 0x02: "WEEKEVENTREG_40_02", + (40 << 8) | 0x04: "WEEKEVENTREG_40_04", + (40 << 8) | 0x08: "WEEKEVENTREG_40_08", + (40 << 8) | 0x10: "WEEKEVENTREG_40_10", + (40 << 8) | 0x20: "WEEKEVENTREG_40_20", + (40 << 8) | 0x40: "WEEKEVENTREG_40_40", + (40 << 8) | 0x80: "WEEKEVENTREG_40_80", + (41 << 8) | 0x01: "WEEKEVENTREG_41_01", + (41 << 8) | 0x02: "WEEKEVENTREG_41_02", + (41 << 8) | 0x04: "WEEKEVENTREG_41_04", + (41 << 8) | 0x08: "WEEKEVENTREG_41_08", + (41 << 8) | 0x10: "WEEKEVENTREG_41_10", + (41 << 8) | 0x20: "WEEKEVENTREG_41_20", + (41 << 8) | 0x40: "WEEKEVENTREG_41_40", + (41 << 8) | 0x80: "WEEKEVENTREG_41_80", + (42 << 8) | 0x01: "WEEKEVENTREG_42_01", + (42 << 8) | 0x02: "WEEKEVENTREG_42_02", + (42 << 8) | 0x04: "WEEKEVENTREG_42_04", + (42 << 8) | 0x08: "WEEKEVENTREG_42_08", + (42 << 8) | 0x10: "WEEKEVENTREG_42_10", + (42 << 8) | 0x20: "WEEKEVENTREG_42_20", + (42 << 8) | 0x40: "WEEKEVENTREG_42_40", + (42 << 8) | 0x80: "WEEKEVENTREG_42_80", + (43 << 8) | 0x01: "WEEKEVENTREG_43_01", + (43 << 8) | 0x02: "WEEKEVENTREG_43_02", + (43 << 8) | 0x04: "WEEKEVENTREG_43_04", + (43 << 8) | 0x08: "WEEKEVENTREG_43_08", + (43 << 8) | 0x10: "WEEKEVENTREG_43_10", + (43 << 8) | 0x20: "WEEKEVENTREG_43_20", + (43 << 8) | 0x40: "WEEKEVENTREG_43_40", + (43 << 8) | 0x80: "WEEKEVENTREG_43_80", + (44 << 8) | 0x01: "WEEKEVENTREG_44_01", + (44 << 8) | 0x02: "WEEKEVENTREG_44_02", + (44 << 8) | 0x04: "WEEKEVENTREG_44_04", + (44 << 8) | 0x08: "WEEKEVENTREG_44_08", + (44 << 8) | 0x10: "WEEKEVENTREG_44_10", + (44 << 8) | 0x20: "WEEKEVENTREG_44_20", + (44 << 8) | 0x40: "WEEKEVENTREG_44_40", + (44 << 8) | 0x80: "WEEKEVENTREG_44_80", + (45 << 8) | 0x01: "WEEKEVENTREG_45_01", + (45 << 8) | 0x02: "WEEKEVENTREG_45_02", + (45 << 8) | 0x04: "WEEKEVENTREG_45_04", + (45 << 8) | 0x08: "WEEKEVENTREG_45_08", + (45 << 8) | 0x10: "WEEKEVENTREG_45_10", + (45 << 8) | 0x20: "WEEKEVENTREG_45_20", + (45 << 8) | 0x40: "WEEKEVENTREG_45_40", + (45 << 8) | 0x80: "WEEKEVENTREG_45_80", + (46 << 8) | 0x01: "WEEKEVENTREG_46_01", + (46 << 8) | 0x02: "WEEKEVENTREG_46_02", + (46 << 8) | 0x04: "WEEKEVENTREG_46_04", + (46 << 8) | 0x08: "WEEKEVENTREG_46_08", + (46 << 8) | 0x10: "WEEKEVENTREG_46_10", + (46 << 8) | 0x20: "WEEKEVENTREG_46_20", + (46 << 8) | 0x40: "WEEKEVENTREG_46_40", + (46 << 8) | 0x80: "WEEKEVENTREG_46_80", + (47 << 8) | 0x01: "WEEKEVENTREG_47_01", + (47 << 8) | 0x02: "WEEKEVENTREG_47_02", + (47 << 8) | 0x04: "WEEKEVENTREG_47_04", + (47 << 8) | 0x08: "WEEKEVENTREG_47_08", + (47 << 8) | 0x10: "WEEKEVENTREG_47_10", + (47 << 8) | 0x20: "WEEKEVENTREG_47_20", + (47 << 8) | 0x40: "WEEKEVENTREG_47_40", + (47 << 8) | 0x80: "WEEKEVENTREG_47_80", + (48 << 8) | 0x01: "WEEKEVENTREG_48_01", + (48 << 8) | 0x02: "WEEKEVENTREG_48_02", + (48 << 8) | 0x04: "WEEKEVENTREG_48_04", + (48 << 8) | 0x08: "WEEKEVENTREG_48_08", + (48 << 8) | 0x10: "WEEKEVENTREG_48_10", + (48 << 8) | 0x20: "WEEKEVENTREG_48_20", + (48 << 8) | 0x40: "WEEKEVENTREG_48_40", + (48 << 8) | 0x80: "WEEKEVENTREG_48_80", + (49 << 8) | 0x01: "WEEKEVENTREG_49_01", + (49 << 8) | 0x02: "WEEKEVENTREG_49_02", + (49 << 8) | 0x04: "WEEKEVENTREG_49_04", + (49 << 8) | 0x08: "WEEKEVENTREG_49_08", + (49 << 8) | 0x10: "WEEKEVENTREG_49_10", + (49 << 8) | 0x20: "WEEKEVENTREG_49_20", + (49 << 8) | 0x40: "WEEKEVENTREG_49_40", + (49 << 8) | 0x80: "WEEKEVENTREG_49_80", + (50 << 8) | 0x01: "WEEKEVENTREG_50_01", + (50 << 8) | 0x02: "WEEKEVENTREG_50_02", + (50 << 8) | 0x04: "WEEKEVENTREG_50_04", + (50 << 8) | 0x08: "WEEKEVENTREG_50_08", + (50 << 8) | 0x10: "WEEKEVENTREG_50_10", + (50 << 8) | 0x20: "WEEKEVENTREG_50_20", + (50 << 8) | 0x40: "WEEKEVENTREG_50_40", + (50 << 8) | 0x80: "WEEKEVENTREG_50_80", + (51 << 8) | 0x01: "WEEKEVENTREG_51_01", + (51 << 8) | 0x02: "WEEKEVENTREG_51_02", + (51 << 8) | 0x04: "WEEKEVENTREG_51_04", + (51 << 8) | 0x08: "WEEKEVENTREG_51_08", + (51 << 8) | 0x10: "WEEKEVENTREG_51_10", + (51 << 8) | 0x20: "WEEKEVENTREG_51_20", + (51 << 8) | 0x40: "WEEKEVENTREG_51_40", + (51 << 8) | 0x80: "WEEKEVENTREG_51_80", + (52 << 8) | 0x01: "WEEKEVENTREG_52_01", + (52 << 8) | 0x02: "WEEKEVENTREG_52_02", + (52 << 8) | 0x04: "WEEKEVENTREG_52_04", + (52 << 8) | 0x08: "WEEKEVENTREG_52_08", + (52 << 8) | 0x10: "WEEKEVENTREG_52_10", + (52 << 8) | 0x20: "WEEKEVENTREG_52_20", + (52 << 8) | 0x40: "WEEKEVENTREG_52_40", + (52 << 8) | 0x80: "WEEKEVENTREG_52_80", + (53 << 8) | 0x01: "WEEKEVENTREG_53_01", + (53 << 8) | 0x02: "WEEKEVENTREG_53_02", + (53 << 8) | 0x04: "WEEKEVENTREG_53_04", + (53 << 8) | 0x08: "WEEKEVENTREG_53_08", + (53 << 8) | 0x10: "WEEKEVENTREG_53_10", + (53 << 8) | 0x20: "WEEKEVENTREG_53_20", + (53 << 8) | 0x40: "WEEKEVENTREG_53_40", + (53 << 8) | 0x80: "WEEKEVENTREG_53_80", + (54 << 8) | 0x01: "WEEKEVENTREG_54_01", + (54 << 8) | 0x02: "WEEKEVENTREG_54_02", + (54 << 8) | 0x04: "WEEKEVENTREG_54_04", + (54 << 8) | 0x08: "WEEKEVENTREG_54_08", + (54 << 8) | 0x10: "WEEKEVENTREG_54_10", + (54 << 8) | 0x20: "WEEKEVENTREG_54_20", + (54 << 8) | 0x40: "WEEKEVENTREG_54_40", + (54 << 8) | 0x80: "WEEKEVENTREG_54_80", + (55 << 8) | 0x01: "WEEKEVENTREG_55_01", + (55 << 8) | 0x02: "WEEKEVENTREG_55_02", + (55 << 8) | 0x04: "WEEKEVENTREG_55_04", + (55 << 8) | 0x08: "WEEKEVENTREG_55_08", + (55 << 8) | 0x10: "WEEKEVENTREG_55_10", + (55 << 8) | 0x20: "WEEKEVENTREG_55_20", + (55 << 8) | 0x40: "WEEKEVENTREG_55_40", + (55 << 8) | 0x80: "WEEKEVENTREG_55_80", + (56 << 8) | 0x01: "WEEKEVENTREG_56_01", + (56 << 8) | 0x02: "WEEKEVENTREG_56_02", + (56 << 8) | 0x04: "WEEKEVENTREG_56_04", + (56 << 8) | 0x08: "WEEKEVENTREG_56_08", + (56 << 8) | 0x10: "WEEKEVENTREG_56_10", + (56 << 8) | 0x20: "WEEKEVENTREG_56_20", + (56 << 8) | 0x40: "WEEKEVENTREG_56_40", + (56 << 8) | 0x80: "WEEKEVENTREG_56_80", + (57 << 8) | 0x01: "WEEKEVENTREG_57_01", + (57 << 8) | 0x02: "WEEKEVENTREG_57_02", + (57 << 8) | 0x04: "WEEKEVENTREG_57_04", + (57 << 8) | 0x08: "WEEKEVENTREG_57_08", + (57 << 8) | 0x10: "WEEKEVENTREG_57_10", + (57 << 8) | 0x20: "WEEKEVENTREG_57_20", + (57 << 8) | 0x40: "WEEKEVENTREG_57_40", + (57 << 8) | 0x80: "WEEKEVENTREG_57_80", + (58 << 8) | 0x01: "WEEKEVENTREG_58_01", + (58 << 8) | 0x02: "WEEKEVENTREG_58_02", + (58 << 8) | 0x04: "WEEKEVENTREG_58_04", + (58 << 8) | 0x08: "WEEKEVENTREG_58_08", + (58 << 8) | 0x10: "WEEKEVENTREG_58_10", + (58 << 8) | 0x20: "WEEKEVENTREG_58_20", + (58 << 8) | 0x40: "WEEKEVENTREG_58_40", + (58 << 8) | 0x80: "WEEKEVENTREG_58_80", + (59 << 8) | 0x01: "WEEKEVENTREG_59_01", + (59 << 8) | 0x02: "WEEKEVENTREG_59_02", + (59 << 8) | 0x08: "WEEKEVENTREG_59_08", + (59 << 8) | 0x04: "WEEKEVENTREG_59_04", + (59 << 8) | 0x10: "WEEKEVENTREG_59_10", + (59 << 8) | 0x20: "WEEKEVENTREG_59_20", + (59 << 8) | 0x40: "WEEKEVENTREG_59_40", + (59 << 8) | 0x80: "WEEKEVENTREG_59_80", + (60 << 8) | 0x01: "WEEKEVENTREG_60_01", + (60 << 8) | 0x02: "WEEKEVENTREG_60_02", + (60 << 8) | 0x04: "WEEKEVENTREG_60_04", + (60 << 8) | 0x08: "WEEKEVENTREG_60_08", + (60 << 8) | 0x10: "WEEKEVENTREG_60_10", + (60 << 8) | 0x20: "WEEKEVENTREG_60_20", + (60 << 8) | 0x40: "WEEKEVENTREG_60_40", + (60 << 8) | 0x80: "WEEKEVENTREG_60_80", + (61 << 8) | 0x01: "WEEKEVENTREG_61_01", + (61 << 8) | 0x02: "WEEKEVENTREG_61_02", + (61 << 8) | 0x04: "WEEKEVENTREG_61_04", + (61 << 8) | 0x08: "WEEKEVENTREG_61_08", + (61 << 8) | 0x10: "WEEKEVENTREG_61_10", + (61 << 8) | 0x20: "WEEKEVENTREG_61_20", + (61 << 8) | 0x40: "WEEKEVENTREG_61_40", + (61 << 8) | 0x80: "WEEKEVENTREG_61_80", + (62 << 8) | 0x01: "WEEKEVENTREG_62_01", + (62 << 8) | 0x02: "WEEKEVENTREG_62_02", + (62 << 8) | 0x04: "WEEKEVENTREG_62_04", + (62 << 8) | 0x08: "WEEKEVENTREG_62_08", + (62 << 8) | 0x10: "WEEKEVENTREG_62_10", + (62 << 8) | 0x20: "WEEKEVENTREG_62_20", + (62 << 8) | 0x40: "WEEKEVENTREG_62_40", + (62 << 8) | 0x80: "WEEKEVENTREG_62_80", + (63 << 8) | 0x01: "WEEKEVENTREG_63_01", + (63 << 8) | 0x02: "WEEKEVENTREG_63_02", + (63 << 8) | 0x04: "WEEKEVENTREG_63_04", + (63 << 8) | 0x08: "WEEKEVENTREG_63_08", + (63 << 8) | 0x10: "WEEKEVENTREG_63_10", + (63 << 8) | 0x20: "WEEKEVENTREG_63_20", + (63 << 8) | 0x40: "WEEKEVENTREG_63_40", + (63 << 8) | 0x80: "WEEKEVENTREG_63_80", + (64 << 8) | 0x01: "WEEKEVENTREG_64_01", + (64 << 8) | 0x02: "WEEKEVENTREG_64_02", + (64 << 8) | 0x04: "WEEKEVENTREG_64_04", + (64 << 8) | 0x08: "WEEKEVENTREG_64_08", + (64 << 8) | 0x10: "WEEKEVENTREG_64_10", + (64 << 8) | 0x20: "WEEKEVENTREG_64_20", + (64 << 8) | 0x40: "WEEKEVENTREG_64_40", + (64 << 8) | 0x80: "WEEKEVENTREG_64_80", + (65 << 8) | 0x01: "WEEKEVENTREG_65_01", + (65 << 8) | 0x02: "WEEKEVENTREG_65_02", + (65 << 8) | 0x04: "WEEKEVENTREG_65_04", + (65 << 8) | 0x08: "WEEKEVENTREG_65_08", + (65 << 8) | 0x10: "WEEKEVENTREG_65_10", + (65 << 8) | 0x20: "WEEKEVENTREG_65_20", + (65 << 8) | 0x40: "WEEKEVENTREG_65_40", + (65 << 8) | 0x80: "WEEKEVENTREG_65_80", + (66 << 8) | 0x01: "WEEKEVENTREG_66_01", + (66 << 8) | 0x02: "WEEKEVENTREG_66_02", + (66 << 8) | 0x04: "WEEKEVENTREG_66_04", + (66 << 8) | 0x08: "WEEKEVENTREG_66_08", + (66 << 8) | 0x10: "WEEKEVENTREG_66_10", + (66 << 8) | 0x20: "WEEKEVENTREG_66_20", + (66 << 8) | 0x40: "WEEKEVENTREG_66_40", + (66 << 8) | 0x80: "WEEKEVENTREG_66_80", + (67 << 8) | 0x01: "WEEKEVENTREG_67_01", + (67 << 8) | 0x02: "WEEKEVENTREG_67_02", + (67 << 8) | 0x04: "WEEKEVENTREG_67_04", + (67 << 8) | 0x08: "WEEKEVENTREG_67_08", + (67 << 8) | 0x10: "WEEKEVENTREG_67_10", + (67 << 8) | 0x20: "WEEKEVENTREG_67_20", + (67 << 8) | 0x40: "WEEKEVENTREG_67_40", + (67 << 8) | 0x80: "WEEKEVENTREG_67_80", + (68 << 8) | 0x01: "WEEKEVENTREG_68_01", + (68 << 8) | 0x02: "WEEKEVENTREG_68_02", + (68 << 8) | 0x04: "WEEKEVENTREG_68_04", + (68 << 8) | 0x08: "WEEKEVENTREG_68_08", + (68 << 8) | 0x10: "WEEKEVENTREG_68_10", + (68 << 8) | 0x20: "WEEKEVENTREG_68_20", + (68 << 8) | 0x40: "WEEKEVENTREG_68_40", + (68 << 8) | 0x80: "WEEKEVENTREG_68_80", + (69 << 8) | 0x01: "WEEKEVENTREG_69_01", + (69 << 8) | 0x02: "WEEKEVENTREG_69_02", + (69 << 8) | 0x04: "WEEKEVENTREG_69_04", + (69 << 8) | 0x08: "WEEKEVENTREG_69_08", + (69 << 8) | 0x10: "WEEKEVENTREG_69_10", + (69 << 8) | 0x20: "WEEKEVENTREG_69_20", + (69 << 8) | 0x40: "WEEKEVENTREG_69_40", + (69 << 8) | 0x80: "WEEKEVENTREG_69_80", + (70 << 8) | 0x01: "WEEKEVENTREG_70_01", + (70 << 8) | 0x02: "WEEKEVENTREG_70_02", + (70 << 8) | 0x04: "WEEKEVENTREG_70_04", + (70 << 8) | 0x08: "WEEKEVENTREG_70_08", + (70 << 8) | 0x10: "WEEKEVENTREG_70_10", + (70 << 8) | 0x20: "WEEKEVENTREG_70_20", + (70 << 8) | 0x40: "WEEKEVENTREG_70_40", + (70 << 8) | 0x80: "WEEKEVENTREG_70_80", + (71 << 8) | 0x01: "WEEKEVENTREG_71_01", + (71 << 8) | 0x02: "WEEKEVENTREG_71_02", + (71 << 8) | 0x04: "WEEKEVENTREG_71_04", + (71 << 8) | 0x08: "WEEKEVENTREG_71_08", + (71 << 8) | 0x10: "WEEKEVENTREG_71_10", + (71 << 8) | 0x20: "WEEKEVENTREG_71_20", + (71 << 8) | 0x40: "WEEKEVENTREG_71_40", + (71 << 8) | 0x80: "WEEKEVENTREG_71_80", + (72 << 8) | 0x01: "WEEKEVENTREG_72_01", + (72 << 8) | 0x02: "WEEKEVENTREG_72_02", + (72 << 8) | 0x04: "WEEKEVENTREG_72_04", + (72 << 8) | 0x08: "WEEKEVENTREG_72_08", + (72 << 8) | 0x10: "WEEKEVENTREG_72_10", + (72 << 8) | 0x20: "WEEKEVENTREG_72_20", + (72 << 8) | 0x40: "WEEKEVENTREG_72_40", + (72 << 8) | 0x80: "WEEKEVENTREG_72_80", + (73 << 8) | 0x01: "WEEKEVENTREG_73_01", + (73 << 8) | 0x02: "WEEKEVENTREG_73_02", + (73 << 8) | 0x04: "WEEKEVENTREG_73_04", + (73 << 8) | 0x08: "WEEKEVENTREG_73_08", + (73 << 8) | 0x10: "WEEKEVENTREG_73_10", + (73 << 8) | 0x20: "WEEKEVENTREG_73_20", + (73 << 8) | 0x40: "WEEKEVENTREG_73_40", + (73 << 8) | 0x80: "WEEKEVENTREG_73_80", + (74 << 8) | 0x01: "WEEKEVENTREG_74_01", + (74 << 8) | 0x02: "WEEKEVENTREG_74_02", + (74 << 8) | 0x04: "WEEKEVENTREG_74_04", + (74 << 8) | 0x08: "WEEKEVENTREG_74_08", + (74 << 8) | 0x10: "WEEKEVENTREG_74_10", + (74 << 8) | 0x20: "WEEKEVENTREG_74_20", + (74 << 8) | 0x40: "WEEKEVENTREG_74_40", + (74 << 8) | 0x80: "WEEKEVENTREG_74_80", + (75 << 8) | 0x01: "WEEKEVENTREG_75_01", + (75 << 8) | 0x02: "WEEKEVENTREG_75_02", + (75 << 8) | 0x04: "WEEKEVENTREG_75_04", + (75 << 8) | 0x08: "WEEKEVENTREG_75_08", + (75 << 8) | 0x10: "WEEKEVENTREG_75_10", + (75 << 8) | 0x20: "WEEKEVENTREG_75_20", + (75 << 8) | 0x40: "WEEKEVENTREG_75_40", + (75 << 8) | 0x80: "WEEKEVENTREG_75_80", + (76 << 8) | 0x01: "WEEKEVENTREG_76_01", + (76 << 8) | 0x02: "WEEKEVENTREG_76_02", + (76 << 8) | 0x04: "WEEKEVENTREG_76_04", + (76 << 8) | 0x08: "WEEKEVENTREG_76_08", + (76 << 8) | 0x10: "WEEKEVENTREG_76_10", + (76 << 8) | 0x20: "WEEKEVENTREG_76_20", + (76 << 8) | 0x40: "WEEKEVENTREG_76_40", + (76 << 8) | 0x80: "WEEKEVENTREG_76_80", + (77 << 8) | 0x01: "WEEKEVENTREG_77_01", + (77 << 8) | 0x02: "WEEKEVENTREG_77_02", + (77 << 8) | 0x04: "WEEKEVENTREG_77_04", + (77 << 8) | 0x08: "WEEKEVENTREG_77_08", + (77 << 8) | 0x10: "WEEKEVENTREG_77_10", + (77 << 8) | 0x20: "WEEKEVENTREG_77_20", + (77 << 8) | 0x40: "WEEKEVENTREG_77_40", + (77 << 8) | 0x80: "WEEKEVENTREG_77_80", + (78 << 8) | 0x01: "WEEKEVENTREG_78_01", + (78 << 8) | 0x02: "WEEKEVENTREG_78_02", + (78 << 8) | 0x04: "WEEKEVENTREG_78_04", + (78 << 8) | 0x08: "WEEKEVENTREG_78_08", + (78 << 8) | 0x10: "WEEKEVENTREG_78_10", + (78 << 8) | 0x20: "WEEKEVENTREG_78_20", + (78 << 8) | 0x40: "WEEKEVENTREG_78_40", + (78 << 8) | 0x80: "WEEKEVENTREG_78_80", + (79 << 8) | 0x01: "WEEKEVENTREG_79_01", + (79 << 8) | 0x02: "WEEKEVENTREG_79_02", + (79 << 8) | 0x04: "WEEKEVENTREG_79_04", + (79 << 8) | 0x08: "WEEKEVENTREG_79_08", + (79 << 8) | 0x10: "WEEKEVENTREG_79_10", + (79 << 8) | 0x20: "WEEKEVENTREG_79_20", + (79 << 8) | 0x40: "WEEKEVENTREG_79_40", + (79 << 8) | 0x80: "WEEKEVENTREG_79_80", + (80 << 8) | 0x01: "WEEKEVENTREG_80_01", + (80 << 8) | 0x02: "WEEKEVENTREG_80_02", + (80 << 8) | 0x04: "WEEKEVENTREG_80_04", + (80 << 8) | 0x08: "WEEKEVENTREG_80_08", + (80 << 8) | 0x10: "WEEKEVENTREG_80_10", + (80 << 8) | 0x20: "WEEKEVENTREG_80_20", + (80 << 8) | 0x40: "WEEKEVENTREG_80_40", + (80 << 8) | 0x80: "WEEKEVENTREG_80_80", + (81 << 8) | 0x01: "WEEKEVENTREG_81_01", + (81 << 8) | 0x02: "WEEKEVENTREG_81_02", + (81 << 8) | 0x04: "WEEKEVENTREG_81_04", + (81 << 8) | 0x08: "WEEKEVENTREG_81_08", + (81 << 8) | 0x10: "WEEKEVENTREG_81_10", + (81 << 8) | 0x20: "WEEKEVENTREG_81_20", + (81 << 8) | 0x40: "WEEKEVENTREG_81_40", + (81 << 8) | 0x80: "WEEKEVENTREG_81_80", + (82 << 8) | 0x01: "WEEKEVENTREG_82_01", + (82 << 8) | 0x02: "WEEKEVENTREG_82_02", + (82 << 8) | 0x04: "WEEKEVENTREG_82_04", + (82 << 8) | 0x08: "WEEKEVENTREG_82_08", + (82 << 8) | 0x10: "WEEKEVENTREG_82_10", + (82 << 8) | 0x20: "WEEKEVENTREG_82_20", + (82 << 8) | 0x40: "WEEKEVENTREG_82_40", + (82 << 8) | 0x80: "WEEKEVENTREG_82_80", + (83 << 8) | 0x01: "WEEKEVENTREG_83_01", + (83 << 8) | 0x02: "WEEKEVENTREG_83_02", + (83 << 8) | 0x04: "WEEKEVENTREG_83_04", + (83 << 8) | 0x08: "WEEKEVENTREG_83_08", + (83 << 8) | 0x10: "WEEKEVENTREG_83_10", + (83 << 8) | 0x20: "WEEKEVENTREG_83_20", + (83 << 8) | 0x40: "WEEKEVENTREG_83_40", + (83 << 8) | 0x80: "WEEKEVENTREG_83_80", + (84 << 8) | 0x01: "WEEKEVENTREG_84_01", + (84 << 8) | 0x02: "WEEKEVENTREG_84_02", + (84 << 8) | 0x04: "WEEKEVENTREG_84_04", + (84 << 8) | 0x08: "WEEKEVENTREG_84_08", + (84 << 8) | 0x10: "WEEKEVENTREG_84_10", + (84 << 8) | 0x20: "WEEKEVENTREG_84_20", + (84 << 8) | 0x40: "WEEKEVENTREG_84_40", + (84 << 8) | 0x80: "WEEKEVENTREG_84_80", + (85 << 8) | 0x01: "WEEKEVENTREG_85_01", + (85 << 8) | 0x02: "WEEKEVENTREG_85_02", + (85 << 8) | 0x04: "WEEKEVENTREG_85_04", + (85 << 8) | 0x08: "WEEKEVENTREG_85_08", + (85 << 8) | 0x10: "WEEKEVENTREG_85_10", + (85 << 8) | 0x20: "WEEKEVENTREG_85_20", + (85 << 8) | 0x40: "WEEKEVENTREG_85_40", + (85 << 8) | 0x80: "WEEKEVENTREG_85_80", + (86 << 8) | 0x01: "WEEKEVENTREG_86_01", + (86 << 8) | 0x02: "WEEKEVENTREG_86_02", + (86 << 8) | 0x04: "WEEKEVENTREG_86_04", + (86 << 8) | 0x08: "WEEKEVENTREG_86_08", + (86 << 8) | 0x10: "WEEKEVENTREG_86_10", + (86 << 8) | 0x20: "WEEKEVENTREG_86_20", + (86 << 8) | 0x40: "WEEKEVENTREG_86_40", + (86 << 8) | 0x80: "WEEKEVENTREG_86_80", + (87 << 8) | 0x01: "WEEKEVENTREG_87_01", + (87 << 8) | 0x02: "WEEKEVENTREG_87_02", + (87 << 8) | 0x04: "WEEKEVENTREG_87_04", + (87 << 8) | 0x08: "WEEKEVENTREG_87_08", + (87 << 8) | 0x10: "WEEKEVENTREG_87_10", + (87 << 8) | 0x20: "WEEKEVENTREG_87_20", + (87 << 8) | 0x40: "WEEKEVENTREG_87_40", + (87 << 8) | 0x80: "WEEKEVENTREG_87_80", + (88 << 8) | 0x01: "WEEKEVENTREG_88_01", + (88 << 8) | 0x02: "WEEKEVENTREG_88_02", + (88 << 8) | 0x04: "WEEKEVENTREG_88_04", + (88 << 8) | 0x08: "WEEKEVENTREG_88_08", + (88 << 8) | 0x10: "WEEKEVENTREG_88_10", + (88 << 8) | 0x20: "WEEKEVENTREG_88_20", + (88 << 8) | 0x40: "WEEKEVENTREG_88_40", + (88 << 8) | 0x80: "WEEKEVENTREG_88_80", + (89 << 8) | 0x01: "WEEKEVENTREG_89_01", + (89 << 8) | 0x02: "WEEKEVENTREG_89_02", + (89 << 8) | 0x04: "WEEKEVENTREG_89_04", + (89 << 8) | 0x08: "WEEKEVENTREG_89_08", + (89 << 8) | 0x10: "WEEKEVENTREG_89_10", + (89 << 8) | 0x20: "WEEKEVENTREG_89_20", + (89 << 8) | 0x40: "WEEKEVENTREG_89_40", + (89 << 8) | 0x80: "WEEKEVENTREG_89_80", + (90 << 8) | 0x01: "WEEKEVENTREG_90_01", + (90 << 8) | 0x02: "WEEKEVENTREG_90_02", + (90 << 8) | 0x04: "WEEKEVENTREG_90_04", + (90 << 8) | 0x08: "WEEKEVENTREG_90_08", + (90 << 8) | 0x10: "WEEKEVENTREG_90_10", + (90 << 8) | 0x20: "WEEKEVENTREG_90_20", + (90 << 8) | 0x40: "WEEKEVENTREG_90_40", + (90 << 8) | 0x80: "WEEKEVENTREG_90_80", + (91 << 8) | 0x01: "WEEKEVENTREG_91_01", + (91 << 8) | 0x02: "WEEKEVENTREG_91_02", + (91 << 8) | 0x04: "WEEKEVENTREG_91_04", + (91 << 8) | 0x08: "WEEKEVENTREG_91_08", + (91 << 8) | 0x10: "WEEKEVENTREG_91_10", + (91 << 8) | 0x20: "WEEKEVENTREG_91_20", + (91 << 8) | 0x40: "WEEKEVENTREG_91_40", + (91 << 8) | 0x80: "WEEKEVENTREG_91_80", + (92 << 8) | 0x01: "WEEKEVENTREG_92_01", + (92 << 8) | 0x02: "WEEKEVENTREG_92_02", + (92 << 8) | 0x04: "WEEKEVENTREG_92_04", + (92 << 8) | 0x08: "WEEKEVENTREG_92_08", + (92 << 8) | 0x10: "WEEKEVENTREG_92_10", + (92 << 8) | 0x20: "WEEKEVENTREG_92_20", + (92 << 8) | 0x40: "WEEKEVENTREG_92_40", + (92 << 8) | 0x80: "WEEKEVENTREG_92_80", + (93 << 8) | 0x01: "WEEKEVENTREG_93_01", + (93 << 8) | 0x02: "WEEKEVENTREG_93_02", + (93 << 8) | 0x04: "WEEKEVENTREG_93_04", + (93 << 8) | 0x08: "WEEKEVENTREG_93_08", + (93 << 8) | 0x10: "WEEKEVENTREG_93_10", + (93 << 8) | 0x20: "WEEKEVENTREG_93_20", + (93 << 8) | 0x40: "WEEKEVENTREG_93_40", + (93 << 8) | 0x80: "WEEKEVENTREG_93_80", + (94 << 8) | 0x01: "WEEKEVENTREG_94_01", + (94 << 8) | 0x02: "WEEKEVENTREG_94_02", + (94 << 8) | 0x04: "WEEKEVENTREG_94_04", + (94 << 8) | 0x08: "WEEKEVENTREG_94_08", + (94 << 8) | 0x10: "WEEKEVENTREG_94_10", + (94 << 8) | 0x20: "WEEKEVENTREG_94_20", + (94 << 8) | 0x40: "WEEKEVENTREG_94_40", + (94 << 8) | 0x80: "WEEKEVENTREG_94_80", + (95 << 8) | 0x01: "WEEKEVENTREG_95_01", + (95 << 8) | 0x02: "WEEKEVENTREG_95_02", + (95 << 8) | 0x04: "WEEKEVENTREG_95_04", + (95 << 8) | 0x08: "WEEKEVENTREG_95_08", + (95 << 8) | 0x10: "WEEKEVENTREG_95_10", + (95 << 8) | 0x20: "WEEKEVENTREG_95_20", + (95 << 8) | 0x40: "WEEKEVENTREG_95_40", + (95 << 8) | 0x80: "WEEKEVENTREG_95_80", + (96 << 8) | 0x01: "WEEKEVENTREG_96_01", + (96 << 8) | 0x02: "WEEKEVENTREG_96_02", + (96 << 8) | 0x04: "WEEKEVENTREG_96_04", + (96 << 8) | 0x08: "WEEKEVENTREG_96_08", + (96 << 8) | 0x10: "WEEKEVENTREG_96_10", + (96 << 8) | 0x20: "WEEKEVENTREG_96_20", + (96 << 8) | 0x40: "WEEKEVENTREG_96_40", + (96 << 8) | 0x80: "WEEKEVENTREG_96_80", + (97 << 8) | 0x01: "WEEKEVENTREG_97_01", + (97 << 8) | 0x02: "WEEKEVENTREG_97_02", + (97 << 8) | 0x04: "WEEKEVENTREG_97_04", + (97 << 8) | 0x08: "WEEKEVENTREG_97_08", + (97 << 8) | 0x10: "WEEKEVENTREG_97_10", + (97 << 8) | 0x20: "WEEKEVENTREG_97_20", + (97 << 8) | 0x40: "WEEKEVENTREG_97_40", + (97 << 8) | 0x80: "WEEKEVENTREG_97_80", + (98 << 8) | 0x01: "WEEKEVENTREG_98_01", + (98 << 8) | 0x02: "WEEKEVENTREG_98_02", + (98 << 8) | 0x04: "WEEKEVENTREG_98_04", + (98 << 8) | 0x08: "WEEKEVENTREG_98_08", + (98 << 8) | 0x10: "WEEKEVENTREG_98_10", + (98 << 8) | 0x20: "WEEKEVENTREG_98_20", + (98 << 8) | 0x40: "WEEKEVENTREG_98_40", + (98 << 8) | 0x80: "WEEKEVENTREG_98_80", + (99 << 8) | 0x01: "WEEKEVENTREG_99_01", + (99 << 8) | 0x02: "WEEKEVENTREG_99_02", + (99 << 8) | 0x04: "WEEKEVENTREG_99_04", + (99 << 8) | 0x08: "WEEKEVENTREG_99_08", + (99 << 8) | 0x10: "WEEKEVENTREG_99_10", + (99 << 8) | 0x20: "WEEKEVENTREG_99_20", + (99 << 8) | 0x40: "WEEKEVENTREG_99_40", + (99 << 8) | 0x80: "WEEKEVENTREG_99_80", +} + +def getFlagMacro(index: int, mask: int) -> str: + flag = (index << 8) | mask + if flag in weekEventReg: + return weekEventReg[flag] + return f"WEEKEVENTREG_{index:02}_{mask:02X}" + +def getCheckMacro(index: int, mask: int) -> str: + return f"CHECK_WEEKEVENTREG({getFlagMacro(index, mask)})" + +def getSetMacro(index: int, mask: int) -> str: + return f"SET_WEEKEVENTREG({getFlagMacro(index, mask)})" + +def getClearMacro(index: int, mask: int) -> str: + return f"CLEAR_WEEKEVENTREG({getFlagMacro(index, mask)})" + +NUMBER_PATTERN = r"(0[xX])?[0-9a-fA-F]+" + +def applyChange(fileContents: str, compiledRegex: re.Pattern, callback) -> str: + parsedContents = "" + + match = compiledRegex.search(fileContents) + while match: + index = int(match.group("index"), 0) + mask = int(match.group("mask"), 0) + + start, end = match.span() + parsedContents += fileContents[:start] + parsedContents += callback(index, mask) + + fileContents = fileContents[end:] + match = compiledRegex.search(fileContents) + + parsedContents += fileContents + return parsedContents + + +def updateCheck(fileContents: str) -> str: + # gSaveContext.save.weekEventReg[86] & 2 + checkRegex = re.compile(rf"gSaveContext.save.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\&\s*(?P{NUMBER_PATTERN})") + + return applyChange(fileContents, checkRegex, getCheckMacro) + +def updateSet(fileContents: str) -> str: + # gSaveContext.save.weekEventReg[51] |= 0x10 + setRegex = re.compile(rf"gSaveContext.save.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\|=\s*(?P{NUMBER_PATTERN})") + + return applyChange(fileContents, setRegex, getSetMacro) + +def updateClear(fileContents: str) -> str: + # gSaveContext.save.weekEventReg[85] &= (u8)~0x80 + clearRegex = re.compile(rf"gSaveContext.save.weekEventReg\[(?P{NUMBER_PATTERN})\]\s*\&=\s*(\(u8\))?~(?P{NUMBER_PATTERN})") + + return applyChange(fileContents, clearRegex, getClearMacro) + + +def read_file(filename): + with open(filename) as src_file: + return src_file.read() + +def write_file(filename, contents): + with open(filename, "w") as f: + f.write(contents) + + +def main(): + parser = argparse.ArgumentParser(description="Converts a weekEventReg access to a macro") + + parser.add_argument("filename", help="Replace every occurrence of numeric weekEventReg on this file to the corresponding macro") + args = parser.parse_args() + + fileContents = read_file(args.filename) + + parsedContents = updateCheck(fileContents) + parsedContents = updateSet(parsedContents) + parsedContents = updateClear(parsedContents) + + if fileContents != parsedContents: + write_file(args.filename, parsedContents) + +if __name__ == "__main__": + main() diff --git a/undefined_syms.txt b/undefined_syms.txt index f24e3b627..649b781ce 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -131,6 +131,8 @@ D_80025D00 = 0x80025D00; rspbootTextSize = 0x160; rspbootTextEnd = rspbootTextStart + rspbootTextSize; +aspMainTextEnd = aspMainTextStart + 0x1000; +aspMainDataEnd = aspMainDataStart + 0x2E0; // Segmented Addresses @@ -385,10 +387,6 @@ D_04014560 = 0x04014560; D_04015DB0 = 0x04015DB0; D_04015FA0 = 0x04015FA0; 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,18 +422,13 @@ 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_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; @@ -540,18 +533,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; @@ -585,113 +566,14 @@ D_06004240 = 0x06004240; D_06003B08 = 0x06003B08; D_06003E80 = 0x06003E80; -// ovl_Bg_Fire_Wall - -D_06000040 = 0x06000040; - -// ovl_Bg_Fu_Mizu - -D_06002FC0 = 0x06002FC0; -D_060037D8 = 0x060037D8; -D_060037F8 = 0x060037F8; - // ovl_Bg_Haka_Bombwall -D_06000040 = 0x06000040; -D_06000148 = 0x06000148; D_06001680 = 0x06001680; -// ovl_Bg_Hakugin_Bombwall - -D_06009830 = 0x06009830; - -// ovl_Bg_Hakugin_Elvpole - -D_0600ACB8 = 0x0600ACB8; -D_0600BF40 = 0x0600BF40; - -// ovl_Bg_Icefloe - -D_060001E0 = 0x060001E0; -D_06000C90 = 0x06000C90; - // ovl_Bg_Ikana_Bombwall D_06000288 = 0x06000288; -// ovl_Bg_Ikana_Dharma - -D_060008C8 = 0x060008C8; -D_06000C50 = 0x06000C50; - -// ovl_Bg_Ikana_Mirror - -D_060014B0 = 0x060014B0; -D_06001678 = 0x06001678; -D_06001880 = 0x06001880; -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; -D_060002C0 = 0x060002C0; -D_06000360 = 0x06000360; -D_06000490 = 0x06000490; - -// ovl_Bg_Kin2_Picture - -D_06000658 = 0x06000658; -D_06000798 = 0x06000798; - -// ovl_Bg_Last_Bwall - -D_06000098 = 0x06000098; - -// ovl_Bg_Open_Shutter - -D_060003E8 = 0x060003E8; -D_06001640 = 0x06001640; - - -// ovl_Bg_Sinkai_Kabe - -D_06000048 = 0x06000048; - -// ovl_Bg_Spout_Fire - -D_06000040 = 0x06000040; - -// ovl_Bg_Umajump - -D_06001220 = 0x06001220; -D_06001438 = 0x06001438; -D_06001558 = 0x06001558; - // ovl_Boss_01 D_06000C44 = 0x06000C44; @@ -743,14 +625,6 @@ D_06006E50 = 0x06006E50; D_06007488 = 0x06007488; D_06007908 = 0x06007908; -// ovl_Boss_06 - -D_06018BD0 = 0x06018BD0; -D_06018CF0 = 0x06018CF0; -D_06018DE0 = 0x06018DE0; -D_06019360 = 0x06019360; -D_060193B0 = 0x060193B0; - // ovl_Boss_07 D_06000194 = 0x06000194; @@ -845,118 +719,17 @@ D_0600B5A0 = 0x0600B5A0; D_06010C40 = 0x06010C40; D_060129F0 = 0x060129F0; -// ovl_Demo_Tre_Lgt - -D_06007D78 = 0x06007D78; - -// ovl_Dm_Ah - -D_06009E70 = 0x06009E70; - -// ovl_Dm_Al - -D_0600A0D8 = 0x0600A0D8; - -// ovl_Dm_Bal - -D_060005FC = 0x060005FC; -D_06001804 = 0x06001804; -D_0600A6D0 = 0x0600A6D0; - -// ovl_Dm_Char02 - -D_0600AD68 = 0x0600AD68; - -// ovl_Dm_Char03 - -D_06020550 = 0x06020550; - -// ovl_Dm_Char06 - -D_060013A8 = 0x060013A8; -D_06006868 = 0x06006868; - -// ovl_Dm_Char08 - -D_06002328 = 0x06002328; -D_06002470 = 0x06002470; -D_06004E70 = 0x06004E70; -D_0600E748 = 0x0600E748; - -// ovl_Dm_Char09 - -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; D_06011458 = 0x06011458; -// ovl_Dm_Zl - -D_0600DE08 = 0x0600DE08; -D_0600E038 = 0x0600E038; - -// ovl_Door_Warp1 - -D_06003230 = 0x06003230; -D_060044D8 = 0x060044D8; -D_06004690 = 0x06004690; -D_060057D8 = 0x060057D8; -D_060058C8 = 0x060058C8; -D_06007238 = 0x06007238; - -// ovl_Effect_Ss_D_Fire - -D_060098A0 = 0x060098A0; - -// ovl_Effect_Ss_Extra - -D_06000DC0 = 0x06000DC0; - -// ovl_Eff_Kamejima_Wave - -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; D_06008A38 = 0x06008A38; D_06009F60 = 0x06009F60; -// ovl_Eff_Zoraband - -D_06000180 = 0x06000180; -D_060002A8 = 0x060002A8; -D_06000F38 = 0x06000F38; - // ovl_En_An D_06000308 = 0x06000308; @@ -970,25 +743,6 @@ D_06012618 = 0x06012618; D_0600B380 = 0x0600B380; -// ovl_En_Ani - -D_060007FC = 0x060007FC; -D_06000C14 = 0x06000C14; -D_060011CC = 0x060011CC; -D_06001D48 = 0x06001D48; -D_060027A0 = 0x060027A0; -D_060028A0 = 0x060028A0; -D_06009220 = 0x06009220; -D_06009D34 = 0x06009D34; - -// ovl_En_Az - -D_06007438 = 0x06007438; -D_0600C94C = 0x0600C94C; -D_06017990 = 0x06017990; -D_0601ABF0 = 0x0601ABF0; -D_0601AD00 = 0x0601AD00; - // ovl_En_Bal D_060005FC = 0x060005FC; @@ -998,64 +752,6 @@ D_0600B604 = 0x0600B604; D_0600CB78 = 0x0600CB78; D_0600D530 = 0x0600D530; -// ovl_En_Bat - -D_060000A0 = 0x060000A0; -D_060000C8 = 0x060000C8; - -// ovl_En_Bee - -D_0600005C = 0x0600005C; -D_06001398 = 0x06001398; - -// ovl_En_Bh - -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; -D_06000D78 = 0x06000D78; - -// ovl_En_Bombers2 - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - -// ovl_En_Bomjimb - -D_060064B8 = 0x060064B8; -D_0600F82C = 0x0600F82C; - -// ovl_En_Box - -D_0600043C = 0x0600043C; -D_060006F0 = 0x060006F0; -D_06000A50 = 0x06000A50; -D_06000DB0 = 0x06000DB0; -D_060012E8 = 0x060012E8; -D_06001850 = 0x06001850; -D_06001D58 = 0x06001D58; -D_060066A0 = 0x060066A0; -D_060080E8 = 0x060080E8; - // ovl_En_Bsb D_06000C50 = 0x06000C50; @@ -1063,15 +759,6 @@ D_06004894 = 0x06004894; D_060086BC = 0x060086BC; D_0600C3E0 = 0x0600C3E0; -// ovl_En_Bubble - -D_06001000 = 0x06001000; - -// ovl_En_Crow - -D_060000F0 = 0x060000F0; -D_060010C0 = 0x060010C0; - // ovl_En_Death D_06000E64 = 0x06000E64; @@ -1103,20 +790,10 @@ D_06001828 = 0x06001828; D_06002A40 = 0x06002A40; D_06003070 = 0x06003070; -// ovl_En_Demo_heishi - -D_06003BFC = 0x06003BFC; -D_0600D640 = 0x0600D640; - // ovl_En_Dnh D_06002950 = 0x06002950; -// ovl_En_Ds2n - -D_06008038 = 0x06008038; -D_06008170 = 0x06008170; - // ovl_En_Dt D_0600112C = 0x0600112C; @@ -1148,31 +825,6 @@ D_060009A0 = 0x060009A0; D_06010240 = 0x06010240; -// ovl_En_Fall2 - -D_06005EF4 = 0x06005EF4; -D_06005F10 = 0x06005F10; -D_06008840 = 0x06008840; -D_06008898 = 0x06008898; - -// ovl_En_Famos - -D_060000F8 = 0x060000F8; -D_06003D38 = 0x06003D38; -D_06003DC8 = 0x06003DC8; - -// ovl_En_Fishing - -D_060029C0 = 0x060029C0; -D_0600007C = 0x0600007C; -D_0600CFE0 = 0x0600CFE0; -D_06011058 = 0x06011058; - -// ovl_En_Ge1 - -D_06002B98 = 0x06002B98; -D_06002CA0 = 0x06002CA0; - // ovl_En_Ge2 D_0600030C = 0x0600030C; @@ -1188,43 +840,6 @@ D_0600A344 = 0x0600A344; D_06001EFC = 0x06001EFC; D_0600A808 = 0x0600A808; -// ovl_En_Grasshopper - -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; @@ -1241,15 +856,6 @@ D_06012FC8 = 0x06012FC8; D_06013928 = 0x06013928; D_06016588 = 0x06016588; -// ovl_En_Js - -D_06010880 = 0x06010880; -D_06010CD8 = 0x06010CD8; -D_060164B8 = 0x060164B8; -D_06016F58 = 0x06016F58; -D_0601764C = 0x0601764C; -D_06017E98 = 0x06017E98; - // ovl_En_Jso D_060081F4 = 0x060081F4; @@ -1261,16 +867,6 @@ D_06002ED8 = 0x06002ED8; D_06003168 = 0x06003168; D_060081F4 = 0x060081F4; -// ovl_En_Kaizoku - -D_060058B8 = 0x060058B8; -D_0600D828 = 0x0600D828; - -// ovl_En_Kanban - -D_06000C30 = 0x06000C30; -D_06001630 = 0x06001630; - // ovl_En_Kitan D_06000CE8 = 0x06000CE8; @@ -1337,22 +933,6 @@ D_06021E34 = 0x06021E34; D_06022728 = 0x06022728; D_06022CAC = 0x06022CAC; -// ovl_En_Lift_Nuts - -D_060029E8 = 0x060029E8; -D_0600AC70 = 0x0600AC70; - -// ovl_En_Mag - -D_06000000 = 0x06000000; -D_06009000 = 0x06009000; -D_06009680 = 0x06009680; -D_06009D00 = 0x06009D00; -D_06010F40 = 0x06010F40; -D_06011740 = 0x06011740; -D_06011BC0 = 0x06011BC0; -D_06011E48 = 0x06011E48; - // ovl_En_Mnk D_06003584 = 0x06003584; @@ -1364,25 +944,6 @@ D_060105DC = 0x060105DC; D_06019B88 = 0x06019B88; D_0601D518 = 0x0601D518; -// ovl_En_Nb - -D_06008C40 = 0x06008C40; - -// ovl_En_Neo_Reeba - -D_060001E4 = 0x060001E4; -D_06001EE8 = 0x06001EE8; - -// ovl_En_Nimotsu - -D_06013380 = 0x06013380; - -// ovl_En_Nwc - -D_060000E8 = 0x060000E8; -D_060002E8 = 0x060002E8; -D_06002530 = 0x06002530; - // ovl_En_Okuta D_0600044C = 0x0600044C; @@ -1394,16 +955,6 @@ D_06003EE4 = 0x06003EE4; D_06004204 = 0x06004204; D_0600466C = 0x0600466C; -// ovl_En_Osn - -D_060192A0 = 0x060192A0; -D_060201BC = 0x060201BC; -D_060202F0 = 0x060202F0; - -// ovl_En_Paper - -D_0600D5A0 = 0x0600D5A0; - // ovl_En_Po_Composer D_0600188C = 0x0600188C; @@ -1413,37 +964,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; -D_06004188 = 0x06004188; -D_06004340 = 0x06004340; - -// ovl_En_Pst - -D_06001A80 = 0x06001A80; - -// ovl_En_Rat - -D_06000174 = 0x06000174; -D_0600026C = 0x0600026C; -D_06001858 = 0x06001858; - -// ovl_En_Ru - -D_0600C700 = 0x0600C700; - -// ovl_En_Rz - -D_06003A20 = 0x06003A20; -D_0600D768 = 0x0600D768; -D_0600D8D8 = 0x0600D8D8; - // ovl_En_Slime D_060004C0 = 0x060004C0; @@ -1460,28 +980,11 @@ D_06001AA0 = 0x06001AA0; D_06000304 = 0x06000304; -// ovl_En_Sth2 - -D_060031F8 = 0x060031F8; - -// ovl_En_Stone_heishi - -D_06000630 = 0x06000630; -D_06000768 = 0x06000768; -D_06003BFC = 0x06003BFC; -D_0600D640 = 0x0600D640; - // ovl_En_Stop_heishi D_06006C18 = 0x06006C18; D_0600D640 = 0x0600D640; -// ovl_En_S_Goro - -D_060091A8 = 0x060091A8; -D_06011AC8 = 0x06011AC8; -D_06012DE0 = 0x06012DE0; - // ovl_En_Takaraya D_06000968 = 0x06000968; @@ -1491,45 +994,17 @@ D_06009890 = 0x06009890; D_0600A280 = 0x0600A280; D_0600AD98 = 0x0600AD98; -// ovl_En_Tanron2 - -D_06003450 = 0x06003450; -D_060034C8 = 0x060034C8; -D_06004510 = 0x06004510; -D_06004550 = 0x06004550; - -// ovl_En_Tanron4 - -D_06000168 = 0x06000168; -D_06000E68 = 0x06000E68; - // ovl_En_Test3 D_0600CB60 = 0x0600CB60; D_0600EDD0 = 0x0600EDD0; D_0600F7EC = 0x0600F7EC; -// ovl_En_Tg - -D_0600B0A0 = 0x0600B0A0; -D_0600B0E0 = 0x0600B0E0; -D_0600B2B0 = 0x0600B2B0; - -// ovl_En_Trt - -D_0600FEF0 = 0x0600FEF0; -D_06000A44 = 0x06000A44; - // ovl_En_Tru D_0601A820 = 0x0601A820; D_0601A830 = 0x0601A830; -// ovl_En_Twig - -D_060014C8 = 0x060014C8; -D_06001C38 = 0x06001C38; - // ovl_En_Wdhand D_060000F4 = 0x060000F4; @@ -1540,14 +1015,6 @@ D_060014C0 = 0x060014C0; D_060015B0 = 0x060015B0; D_06001E20 = 0x06001E20; -// ovl_En_Wiz - -D_06001860 = 0x06001860; -D_0600211C = 0x0600211C; -D_060025F0 = 0x060025F0; -D_060066C0 = 0x060066C0; -D_0600B320 = 0x0600B320; - // ovl_En_Zl4 D_06013328 = 0x06013328; @@ -1558,106 +1025,17 @@ D_06000D94 = 0x06000D94; D_06007650 = 0x06007650; D_0600D658 = 0x0600D658; -// ovl_Mir_Ray3 - -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_Jgame_Light - -D_060003A0 = 0x060003A0; - -// ovl_Obj_Lift - -D_06000D10 = 0x06000D10; -D_06000F00 = 0x06000F00; - -// ovl_Obj_Lupygamelift - -D_060048D0 = 0x060048D0; -D_060071B8 = 0x060071B8; - // ovl_Obj_Mine D_06000030 = 0x06000030; D_06002068 = 0x06002068; D_06002188 = 0x06002188; -// ovl_Obj_Ocarinalift - -D_06001DB0 = 0x06001DB0; -D_06001E40 = 0x06001E40; -D_060048D0 = 0x060048D0; - -// ovl_Obj_Shutter - -D_060011E0 = 0x060011E0; - // ovl_Obj_Takaraya_Wall D_06000B70 = 0x06000B70; D_06000D60 = 0x06000D60; -// ovl_Obj_Taru - -D_06000420 = 0x06000420; -D_06000FC8 = 0x06000FC8; -D_06001040 = 0x06001040; -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;